From 66a517cac0cb1a37efefea2b9923fb1090ff0316 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 14 Apr 2012 15:09:19 +0200 Subject: [PATCH] Bug 743438 - Move some style rule functions from nsIContent to Element; r=mounir sr=bz --- content/base/public/Element.h | 53 +++++++++++++++++++++-- content/base/public/nsIContent.h | 53 +---------------------- content/base/src/nsGenericDOMDataNode.cpp | 35 --------------- content/base/src/nsGenericDOMDataNode.h | 12 ----- content/base/src/nsGenericElement.cpp | 2 +- content/base/src/nsGenericElement.h | 6 +-- content/base/src/nsStyledElement.cpp | 2 +- content/base/src/nsStyledElement.h | 6 +-- 8 files changed, 60 insertions(+), 109 deletions(-) diff --git a/content/base/public/Element.h b/content/base/public/Element.h index 5d0f0e408c70..a24fae03e450 100644 --- a/content/base/public/Element.h +++ b/content/base/public/Element.h @@ -88,9 +88,9 @@ namespace dom { class Link; // IID for the dom::Element interface -#define NS_ELEMENT_IID \ -{ 0xa1588efb, 0x5a84, 0x49cd, \ - { 0x99, 0x1a, 0xac, 0x84, 0x9d, 0x92, 0x05, 0x0f } } +#define NS_ELEMENT_IID \ +{ 0xab6554b0, 0xb675, 0x45a7, \ + { 0xac, 0x23, 0x44, 0x1c, 0x94, 0x5f, 0x3b, 0xee } } class Element : public nsIContent { @@ -171,6 +171,53 @@ public: */ void ClearStyleStateLocks(); + /** + * Get the inline style rule, if any, for this element. + */ + virtual css::StyleRule* GetInlineStyleRule() = 0; + + /** + * Set the inline style rule for this element. This will send an appropriate + * AttributeChanged notification if aNotify is true. + */ + virtual nsresult SetInlineStyleRule(css::StyleRule* aStyleRule, + const nsAString* aSerialized, + bool aNotify) = 0; + + /** + * Get the SMIL override style rule for this element. If the rule hasn't been + * created, this method simply returns null. + */ + virtual css::StyleRule* GetSMILOverrideStyleRule() = 0; + + /** + * Set the SMIL override style rule for this element. If aNotify is true, this + * method will notify the document's pres context, so that the style changes + * will be noticed. + */ + virtual nsresult SetSMILOverrideStyleRule(css::StyleRule* aStyleRule, + bool aNotify) = 0; + + /** + * Returns a new nsISMILAttr that allows the caller to animate the given + * attribute on this element. + * + * The CALLER OWNS the result and is responsible for deleting it. + */ + virtual nsISMILAttr* GetAnimatedAttr(PRInt32 aNamespaceID, nsIAtom* aName) = 0; + + /** + * Get the SMIL override style for this element. This is a style declaration + * that is applied *after* the inline style, and it can be used e.g. to store + * animated style values. + * + * Note: This method is analogous to the 'GetStyle' method in + * nsGenericHTMLElement and nsStyledElement. + * + * TODO: Bug 744157 - All callers QI to nsICSSDeclaration. + */ + virtual nsIDOMCSSStyleDeclaration* GetSMILOverrideStyle() = 0; + protected: /** * Method to get the _intrinsic_ content state of this element. This is the diff --git a/content/base/public/nsIContent.h b/content/base/public/nsIContent.h index 0900eb587501..4ab761748c6a 100644 --- a/content/base/public/nsIContent.h +++ b/content/base/public/nsIContent.h @@ -77,8 +77,8 @@ enum nsLinkState { // IID for the nsIContent interface #define NS_ICONTENT_IID \ -{ 0x94671671, 0x9e1b, 0x447a, \ - { 0xad, 0xb7, 0xc3, 0x2e, 0x05, 0x6a, 0x96, 0xc9 } } +{ 0xa887c108, 0xc25e, 0x42ab, \ + { 0x87, 0xef, 0xad, 0x4b, 0xee, 0x50, 0x28, 0x28 } } /** * A node of content in a document's content model. This interface @@ -793,22 +793,6 @@ public: */ NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) = 0; - /** - * Get the inline style rule, if any, for this content node - */ - virtual mozilla::css::StyleRule* GetInlineStyleRule() = 0; - - /** - * Set the inline style rule for this node. This will send an - * appropriate AttributeChanged notification if aNotify is true. If - * a serialized form of aStyleRule is available, a pointer to it - * should be passed in aSerialized. Otherwise, aSerialized should - * be null. - */ - NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, - const nsAString* aSerialized, - bool aNotify) = 0; - /** * Is the attribute named stored in the mapped attributes? * @@ -875,39 +859,6 @@ public: mPrimaryFrame = aFrame; } - /* - * Returns a new nsISMILAttr that allows the caller to animate the given - * attribute on this element. - * - * The CALLER OWNS the result and is responsible for deleting it. - */ - virtual nsISMILAttr* GetAnimatedAttr(PRInt32 aNamespaceID, nsIAtom* aName) = 0; - - /** - * Get the SMIL override style for this content node. This is a style - * declaration that is applied *after* the inline style, and it can be used - * e.g. to store animated style values. - * - * Note: This method is analogous to the 'GetStyle' method in - * nsGenericHTMLElement and nsStyledElement. - */ - virtual nsIDOMCSSStyleDeclaration* GetSMILOverrideStyle() = 0; - - /** - * Get the SMIL override style rule for this content node. If the rule - * hasn't been created (or if this nsIContent object doesn't support SMIL - * override style), this method simply returns null. - */ - virtual mozilla::css::StyleRule* GetSMILOverrideStyleRule() = 0; - - /** - * Set the SMIL override style rule for this node. If aNotify is true, this - * method will notify the document's pres context, so that the style changes - * will be noticed. - */ - virtual nsresult SetSMILOverrideStyleRule(mozilla::css::StyleRule* aStyleRule, - bool aNotify) = 0; - nsresult LookupNamespaceURIInternal(const nsAString& aNamespacePrefix, nsAString& aNamespaceURI) const; diff --git a/content/base/src/nsGenericDOMDataNode.cpp b/content/base/src/nsGenericDOMDataNode.cpp index 8310fb50ca04..bdd9114c22df 100644 --- a/content/base/src/nsGenericDOMDataNode.cpp +++ b/content/base/src/nsGenericDOMDataNode.cpp @@ -949,41 +949,6 @@ nsGenericDOMDataNode::WalkContentStyleRules(nsRuleWalker* aRuleWalker) return NS_OK; } -nsIDOMCSSStyleDeclaration* -nsGenericDOMDataNode::GetSMILOverrideStyle() -{ - return nsnull; -} - -css::StyleRule* -nsGenericDOMDataNode::GetSMILOverrideStyleRule() -{ - return nsnull; -} - -nsresult -nsGenericDOMDataNode::SetSMILOverrideStyleRule(css::StyleRule* aStyleRule, - bool aNotify) -{ - NS_NOTREACHED("How come we're setting SMILOverrideStyle on a non-element?"); - return NS_ERROR_UNEXPECTED; -} - -css::StyleRule* -nsGenericDOMDataNode::GetInlineStyleRule() -{ - return nsnull; -} - -NS_IMETHODIMP -nsGenericDOMDataNode::SetInlineStyleRule(css::StyleRule* aStyleRule, - const nsAString* aSerialized, - bool aNotify) -{ - NS_NOTREACHED("How come we're setting inline style on a non-element?"); - return NS_ERROR_UNEXPECTED; -} - NS_IMETHODIMP_(bool) nsGenericDOMDataNode::IsAttributeMapped(const nsIAtom* aAttribute) const { diff --git a/content/base/src/nsGenericDOMDataNode.h b/content/base/src/nsGenericDOMDataNode.h index 60be35625ed8..1225277afc23 100644 --- a/content/base/src/nsGenericDOMDataNode.h +++ b/content/base/src/nsGenericDOMDataNode.h @@ -226,15 +226,6 @@ public: virtual void DestroyContent(); virtual void SaveSubtreeState(); - virtual nsISMILAttr* GetAnimatedAttr(PRInt32 /*aNamespaceID*/, nsIAtom* /*aName*/) - { - return nsnull; - } - virtual nsIDOMCSSStyleDeclaration* GetSMILOverrideStyle(); - virtual mozilla::css::StyleRule* GetSMILOverrideStyleRule(); - virtual nsresult SetSMILOverrideStyleRule(mozilla::css::StyleRule* aStyleRule, - bool aNotify); - #ifdef DEBUG virtual void List(FILE* out, PRInt32 aIndent) const; virtual void DumpContent(FILE* out, PRInt32 aIndent, bool aDumpAll) const; @@ -247,9 +238,6 @@ public: virtual nsIAtom* DoGetID() const; virtual const nsAttrValue* DoGetClasses() const; NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker); - virtual mozilla::css::StyleRule* GetInlineStyleRule(); - NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, - const nsAString* aSerialized, bool aNotify); NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, PRInt32 aModType) const; diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index ec0820b718e6..4a36c64d6d49 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -3610,7 +3610,7 @@ nsGenericElement::GetInlineStyleRule() return nsnull; } -NS_IMETHODIMP +nsresult nsGenericElement::SetInlineStyleRule(css::StyleRule* aStyleRule, const nsAString* aSerialized, bool aNotify) diff --git a/content/base/src/nsGenericElement.h b/content/base/src/nsGenericElement.h index b8b3adcae136..9c43b44f4e4b 100644 --- a/content/base/src/nsGenericElement.h +++ b/content/base/src/nsGenericElement.h @@ -368,9 +368,9 @@ public: virtual const nsAttrValue* DoGetClasses() const; NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker); virtual mozilla::css::StyleRule* GetInlineStyleRule(); - NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, - const nsAString* aSerialized, - bool aNotify); + virtual nsresult SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, + const nsAString* aSerialized, + bool aNotify); NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, diff --git a/content/base/src/nsStyledElement.cpp b/content/base/src/nsStyledElement.cpp index 90850146c542..655e88da419c 100644 --- a/content/base/src/nsStyledElement.cpp +++ b/content/base/src/nsStyledElement.cpp @@ -161,7 +161,7 @@ nsStyledElementNotElementCSSInlineStyle::AfterSetAttr(PRInt32 aNamespaceID, aNotify); } -NS_IMETHODIMP +nsresult nsStyledElementNotElementCSSInlineStyle::SetInlineStyleRule(css::StyleRule* aStyleRule, const nsAString* aSerialized, bool aNotify) diff --git a/content/base/src/nsStyledElement.h b/content/base/src/nsStyledElement.h index d4f4daeac135..f65be3d9e65c 100644 --- a/content/base/src/nsStyledElement.h +++ b/content/base/src/nsStyledElement.h @@ -74,9 +74,9 @@ public: virtual const nsAttrValue* DoGetClasses() const; virtual mozilla::css::StyleRule* GetInlineStyleRule(); - NS_IMETHOD SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, - const nsAString* aSerialized, - bool aNotify); + virtual nsresult SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, + const nsAString* aSerialized, + bool aNotify); virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, bool aNotify);