mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 571635 - Make nsCSSStyleSheet::GetStyleRuleAt return a css::Rule*. r=dbaron
This commit is contained in:
parent
0c4e665c39
commit
074406a500
@ -1111,10 +1111,9 @@ nsTreeSanitizer::SanitizeStyleSheet(const nsAString& aOriginal,
|
||||
// Loop through all the rules found in the CSS text
|
||||
int32_t ruleCount = sheet->StyleRuleCount();
|
||||
for (int32_t i = 0; i < ruleCount; ++i) {
|
||||
nsRefPtr<mozilla::css::Rule> rule;
|
||||
rv = sheet->GetStyleRuleAt(i, *getter_AddRefs(rule));
|
||||
if (NS_FAILED(rv))
|
||||
continue; NS_ASSERTION(rule, "We should have a rule by now");
|
||||
mozilla::css::Rule* rule = sheet->GetStyleRuleAt(i);
|
||||
if (!rule)
|
||||
continue;
|
||||
switch (rule->GetType()) {
|
||||
default:
|
||||
didSanitize = true;
|
||||
|
@ -952,8 +952,7 @@ CSSParserImpl::ParseSheet(const nsAString& aInput,
|
||||
|
||||
int32_t ruleCount = mSheet->StyleRuleCount();
|
||||
if (0 < ruleCount) {
|
||||
css::Rule* lastRule = nullptr;
|
||||
mSheet->GetStyleRuleAt(ruleCount - 1, lastRule);
|
||||
const css::Rule* lastRule = mSheet->GetStyleRuleAt(ruleCount - 1);
|
||||
if (lastRule) {
|
||||
switch (lastRule->GetType()) {
|
||||
case css::Rule::CHARSET_RULE:
|
||||
@ -967,7 +966,6 @@ CSSParserImpl::ParseSheet(const nsAString& aInput,
|
||||
mSection = eCSSSection_General;
|
||||
break;
|
||||
}
|
||||
NS_RELEASE(lastRule);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -112,26 +112,20 @@ CSSRuleListImpl::GetLength(uint32_t* aLength)
|
||||
nsIDOMCSSRule*
|
||||
CSSRuleListImpl::GetItemAt(uint32_t aIndex, nsresult* aResult)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (mStyleSheet) {
|
||||
// ensure rules have correct parent
|
||||
if (mStyleSheet->EnsureUniqueInner() !=
|
||||
nsCSSStyleSheet::eUniqueInner_CloneFailed) {
|
||||
nsRefPtr<css::Rule> rule;
|
||||
|
||||
result = mStyleSheet->GetStyleRuleAt(aIndex, *getter_AddRefs(rule));
|
||||
css::Rule* rule = mStyleSheet->GetStyleRuleAt(aIndex);
|
||||
if (rule) {
|
||||
*aResult = NS_OK;
|
||||
return rule->GetDOMRule();
|
||||
}
|
||||
if (result == NS_ERROR_ILLEGAL_VALUE) {
|
||||
result = NS_OK; // per spec: "Return Value ... null if ... not a valid index."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*aResult = result;
|
||||
// Per spec: "Return Value ... null if ... not a valid index."
|
||||
*aResult = NS_OK;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1502,18 +1496,12 @@ nsCSSStyleSheet::StyleRuleCount() const
|
||||
return mInner->mOrderedRules.Count();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCSSStyleSheet::GetStyleRuleAt(int32_t aIndex, css::Rule*& aRule) const
|
||||
css::Rule*
|
||||
nsCSSStyleSheet::GetStyleRuleAt(int32_t aIndex) const
|
||||
{
|
||||
// Important: If this function is ever made scriptable, we must add
|
||||
// a security check here. See GetCssRules below for an example.
|
||||
aRule = mInner->mOrderedRules.SafeObjectAt(aIndex);
|
||||
if (aRule) {
|
||||
NS_ADDREF(aRule);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
return mInner->mOrderedRules.SafeObjectAt(aIndex);
|
||||
}
|
||||
|
||||
int32_t
|
||||
|
@ -147,7 +147,7 @@ public:
|
||||
void ReplaceStyleRule(mozilla::css::Rule* aOld, mozilla::css::Rule* aNew);
|
||||
|
||||
int32_t StyleRuleCount() const;
|
||||
nsresult GetStyleRuleAt(int32_t aIndex, mozilla::css::Rule*& aRule) const;
|
||||
mozilla::css::Rule* GetStyleRuleAt(int32_t aIndex) const;
|
||||
|
||||
nsresult DeleteRuleFromGroup(mozilla::css::GroupRule* aGroup, uint32_t aIndex);
|
||||
nsresult InsertRuleIntoGroup(const nsAString& aRule, mozilla::css::GroupRule* aGroup, uint32_t aIndex, uint32_t* _retval);
|
||||
|
Loading…
Reference in New Issue
Block a user