mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 648925 - Part 4: DeCOMtaminate GetDOMRule and GetDOMRuleWeak. r=bzbarsky
This commit is contained in:
parent
94aa5754fd
commit
17b6db1001
@ -178,11 +178,10 @@ inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement,
|
||||
if (!rules) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsRefPtr<mozilla::css::StyleRule> cssRule;
|
||||
nsCOMPtr<nsIDOMCSSRule> domRule;
|
||||
for ( ; !ruleNode->IsRoot(); ruleNode = ruleNode->GetParent()) {
|
||||
cssRule = do_QueryObject(ruleNode->GetRule());
|
||||
if (cssRule) {
|
||||
cssRule->GetDOMRule(getter_AddRefs(domRule));
|
||||
nsCOMPtr<nsIDOMCSSRule> domRule = cssRule->GetDOMRule();
|
||||
if (domRule)
|
||||
rules->InsertElementAt(domRule, 0);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ virtual void MapRuleInfoInto(nsRuleData* aRuleData);
|
||||
|
||||
#define DECL_STYLE_RULE_INHERIT \
|
||||
DECL_STYLE_RULE_INHERIT_NO_DOMRULE \
|
||||
virtual nsIDOMCSSRule* GetDOMRuleWeak(nsresult* aResult);
|
||||
virtual nsIDOMCSSRule* GetDOMRule();
|
||||
|
||||
class Rule : public nsIStyleRule {
|
||||
protected:
|
||||
@ -125,13 +125,7 @@ public:
|
||||
|
||||
// Note that this returns null for inline style rules since they aren't
|
||||
// supposed to have a DOM rule representation (and our code wouldn't work).
|
||||
nsresult GetDOMRule(nsIDOMCSSRule** aDOMRule)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_IF_ADDREF(*aDOMRule = GetDOMRuleWeak(&rv));
|
||||
return rv;
|
||||
}
|
||||
virtual nsIDOMCSSRule* GetDOMRuleWeak(nsresult* aResult) = 0;
|
||||
virtual nsIDOMCSSRule* GetDOMRule() = 0;
|
||||
|
||||
// to implement methods on nsIDOMCSSRule
|
||||
nsresult GetParentRule(nsIDOMCSSRule** aParentRule);
|
||||
|
@ -1068,7 +1068,8 @@ DOMCSSDeclarationImpl::GetParentRule(nsIDOMCSSRule **aParent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return mRule->GetDOMRule(aParent);
|
||||
NS_IF_ADDREF(*aParent = mRule->GetDOMRule());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -1338,10 +1339,9 @@ StyleRule::Clone() const
|
||||
return clone.forget();
|
||||
}
|
||||
|
||||
nsIDOMCSSRule*
|
||||
StyleRule::GetDOMRuleWeak(nsresult *aResult)
|
||||
/* virtual */ nsIDOMCSSRule*
|
||||
StyleRule::GetDOMRule()
|
||||
{
|
||||
*aResult = NS_OK;
|
||||
if (!mSheet) {
|
||||
// inline style rules aren't supposed to have a DOM rule object, only
|
||||
// a declaration.
|
||||
@ -1349,10 +1349,6 @@ StyleRule::GetDOMRuleWeak(nsresult *aResult)
|
||||
}
|
||||
if (!mDOMRule) {
|
||||
mDOMRule = new DOMCSSStyleRule(this);
|
||||
if (!mDOMRule) {
|
||||
*aResult = NS_ERROR_OUT_OF_MEMORY;
|
||||
return nsnull;
|
||||
}
|
||||
NS_ADDREF(mDOMRule);
|
||||
}
|
||||
return mDOMRule;
|
||||
|
@ -348,7 +348,7 @@ public:
|
||||
|
||||
virtual already_AddRefed<Rule> Clone() const;
|
||||
|
||||
nsIDOMCSSRule* GetDOMRuleWeak(nsresult* aResult);
|
||||
virtual nsIDOMCSSRule* GetDOMRule();
|
||||
|
||||
// The new mapping function.
|
||||
virtual void MapRuleInfoInto(nsRuleData* aRuleData);
|
||||
|
@ -68,8 +68,8 @@
|
||||
namespace css = mozilla::css;
|
||||
|
||||
#define IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(class_, super_) \
|
||||
nsIDOMCSSRule* class_::GetDOMRuleWeak(nsresult *aResult) \
|
||||
{ *aResult = NS_OK; return this; }
|
||||
/* virtual */ nsIDOMCSSRule* class_::GetDOMRule() \
|
||||
{ return this; }
|
||||
#define IMPL_STYLE_RULE_INHERIT_MAP_RULE_INFO_INTO(class_, super_) \
|
||||
/* virtual */ void class_::MapRuleInfoInto(nsRuleData* aRuleData) \
|
||||
{ NS_ABORT_IF_FALSE(PR_FALSE, "should not be called"); }
|
||||
@ -99,9 +99,10 @@ nsresult
|
||||
Rule::GetParentRule(nsIDOMCSSRule** aParentRule)
|
||||
{
|
||||
if (mParentRule) {
|
||||
return mParentRule->GetDOMRule(aParentRule);
|
||||
NS_IF_ADDREF(*aParentRule = mParentRule->GetDOMRule());
|
||||
} else {
|
||||
*aParentRule = nsnull;
|
||||
}
|
||||
*aParentRule = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -182,7 +183,7 @@ GroupRuleRuleList::GetItemAt(PRUint32 aIndex, nsresult* aResult)
|
||||
if (mGroupRule) {
|
||||
nsRefPtr<Rule> rule = mGroupRule->GetStyleRuleAt(aIndex);
|
||||
if (rule) {
|
||||
return rule->GetDOMRuleWeak(aResult);
|
||||
return rule->GetDOMRule();
|
||||
}
|
||||
}
|
||||
|
||||
@ -637,8 +638,7 @@ GroupRule::AppendRulesToCssText(nsAString& aCssText)
|
||||
// get all the rules
|
||||
for (PRInt32 index = 0, count = mRules.Count(); index < count; ++index) {
|
||||
Rule* rule = mRules.ObjectAt(index);
|
||||
nsCOMPtr<nsIDOMCSSRule> domRule;
|
||||
rule->GetDOMRule(getter_AddRefs(domRule));
|
||||
nsIDOMCSSRule* domRule = rule->GetDOMRule();
|
||||
if (domRule) {
|
||||
nsAutoString cssText;
|
||||
domRule->GetCssText(cssText);
|
||||
@ -1527,7 +1527,8 @@ nsCSSFontFaceStyleDecl::Item(PRUint32 index, nsAString & aResult NS_OUTPARAM)
|
||||
NS_IMETHODIMP
|
||||
nsCSSFontFaceStyleDecl::GetParentRule(nsIDOMCSSRule** aParentRule)
|
||||
{
|
||||
return ContainingRule()->GetDOMRule(aParentRule);
|
||||
NS_IF_ADDREF(*aParentRule = ContainingRule()->GetDOMRule());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,9 +93,8 @@ public:
|
||||
virtual void SetStyleSheet(nsCSSStyleSheet* aSheet); //override GroupRule
|
||||
virtual PRInt32 GetType() const;
|
||||
virtual already_AddRefed<Rule> Clone() const;
|
||||
virtual nsIDOMCSSRule* GetDOMRuleWeak(nsresult *aResult)
|
||||
virtual nsIDOMCSSRule* GetDOMRule()
|
||||
{
|
||||
*aResult = NS_OK;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -136,9 +135,8 @@ public:
|
||||
// Rule methods
|
||||
virtual PRInt32 GetType() const;
|
||||
virtual already_AddRefed<Rule> Clone() const;
|
||||
virtual nsIDOMCSSRule* GetDOMRuleWeak(nsresult *aResult)
|
||||
virtual nsIDOMCSSRule* GetDOMRule()
|
||||
{
|
||||
*aResult = NS_OK;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -416,9 +414,8 @@ public:
|
||||
// Rule methods
|
||||
virtual PRInt32 GetType() const;
|
||||
virtual already_AddRefed<mozilla::css::Rule> Clone() const;
|
||||
virtual nsIDOMCSSRule* GetDOMRuleWeak(nsresult *aResult)
|
||||
virtual nsIDOMCSSRule* GetDOMRule()
|
||||
{
|
||||
*aResult = NS_OK;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,8 @@ CSSRuleListImpl::GetItemAt(PRUint32 aIndex, nsresult* aResult)
|
||||
|
||||
result = mStyleSheet->GetStyleRuleAt(aIndex, *getter_AddRefs(rule));
|
||||
if (rule) {
|
||||
return rule->GetDOMRuleWeak(aResult);
|
||||
*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."
|
||||
@ -1699,11 +1700,11 @@ NS_IMETHODIMP
|
||||
nsCSSStyleSheet::GetOwnerRule(nsIDOMCSSRule** aOwnerRule)
|
||||
{
|
||||
if (mOwnerRule) {
|
||||
return mOwnerRule->GetDOMRule(aOwnerRule);
|
||||
NS_IF_ADDREF(*aOwnerRule = mOwnerRule->GetDOMRule());
|
||||
} else {
|
||||
*aOwnerRule = nsnull;
|
||||
}
|
||||
|
||||
*aOwnerRule = nsnull;
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
Loading…
Reference in New Issue
Block a user