Bug 523294 part 1. Change the signature of HasAttributeDependentStyle. r=dbaron
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 10 Dec 2009 14:36:03 -0800
changeset 35533 eb86d6432f02609e3f2e748103b5be2a1749a81e
parent 35532 a6508c37eb412b22e4e3b53a376788f54c423b1f
child 35534 2a90f6882822b3d25bf13193fd43c96410266fba
push idunknown
push userunknown
push dateunknown
reviewersdbaron
bugs523294
milestone1.9.3a1pre
Bug 523294 part 1. Change the signature of HasAttributeDependentStyle. r=dbaron
layout/style/nsCSSRuleProcessor.cpp
layout/style/nsCSSRuleProcessor.h
layout/style/nsHTMLCSSStyleSheet.cpp
layout/style/nsHTMLStyleSheet.cpp
layout/style/nsHTMLStyleSheet.h
layout/style/nsIStyleRuleProcessor.h
layout/style/nsStyleSet.cpp
layout/style/nsTransitionManager.cpp
layout/style/nsTransitionManager.h
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -2196,19 +2196,18 @@ AttributeEnumFunc(nsCSSSelector* aSelect
   if ((possibleChange & ~(aData->change)) &&
       SelectorMatches(*data, aSelector, data->mStateMask, data->mAttribute,
                       PR_TRUE) &&
       SelectorMatchesTree(*data, aSelector->mNext, PR_TRUE)) {
     aData->change = nsReStyleHint(aData->change | possibleChange);
   }
 }
 
-NS_IMETHODIMP
-nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
-                                               nsReStyleHint* aResult)
+nsReStyleHint
+nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData)
 {
   NS_PRECONDITION(aData->mContent->IsNodeOfType(nsINode::eELEMENT),
                   "content must be element");
 
   AttributeEnumData data(aData);
 
   // Since we always have :-moz-any-link (and almost always have :link
   // and :visited rules from prefs), rather than hacking AddRule below
@@ -2272,18 +2271,17 @@ nsCSSRuleProcessor::HasAttributeDependen
       nsCSSSelector **iter = entry->mSelectors->Elements(),
                     **end = iter + entry->mSelectors->Length();
       for(; iter != end; ++iter) {
         AttributeEnumFunc(*iter, &data);
       }
     }
   }
 
-  *aResult = data.change;
-  return NS_OK;
+  return data.change;
 }
 
 NS_IMETHODIMP
 nsCSSRuleProcessor::MediumFeaturesChanged(nsPresContext* aPresContext,
                                           PRBool* aRulesChanged)
 {
   RuleCascadeData *old = mRuleCascades;
   // We don't want to do anything if there aren't any sets of rules
--- a/layout/style/nsCSSRuleProcessor.h
+++ b/layout/style/nsCSSRuleProcessor.h
@@ -91,18 +91,18 @@ public:
   // nsIStyleRuleProcessor
   NS_IMETHOD RulesMatching(ElementRuleProcessorData* aData);
 
   NS_IMETHOD RulesMatching(PseudoRuleProcessorData* aData);
 
   NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData,
                                     nsReStyleHint* aResult);
 
-  NS_IMETHOD HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
-                                        nsReStyleHint* aResult);
+  virtual nsReStyleHint
+    HasAttributeDependentStyle(AttributeRuleProcessorData* aData);
 
   NS_IMETHOD MediumFeaturesChanged(nsPresContext* aPresContext,
                                    PRBool* aRulesChanged);
 
   // Append all the currently-active font face rules to aArray.  Return
   // true for success and false for failure.
   PRBool AppendFontFaceRules(nsPresContext* aPresContext,
                              nsTArray<nsFontFaceRuleContainer>& aArray);
--- a/layout/style/nsHTMLCSSStyleSheet.cpp
+++ b/layout/style/nsHTMLCSSStyleSheet.cpp
@@ -89,18 +89,18 @@ public:
   // nsIStyleRuleProcessor api
   NS_IMETHOD RulesMatching(ElementRuleProcessorData* aData);
 
   NS_IMETHOD RulesMatching(PseudoRuleProcessorData* aData);
 
   NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData,
                                     nsReStyleHint* aResult);
 
-  NS_IMETHOD HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
-                                        nsReStyleHint* aResult);
+  virtual nsReStyleHint
+    HasAttributeDependentStyle(AttributeRuleProcessorData* aData);
   NS_IMETHOD MediumFeaturesChanged(nsPresContext* aPresContext,
                                   PRBool* aResult);
 
 #ifdef DEBUG
   virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
 #endif
 
 private: 
@@ -183,22 +183,20 @@ NS_IMETHODIMP
 HTMLCSSStyleSheetImpl::HasStateDependentStyle(StateRuleProcessorData* aData,
                                               nsReStyleHint* aResult)
 {
   *aResult = nsReStyleHint(0);
   return NS_OK;
 }
 
 // Test if style is dependent on attribute
-NS_IMETHODIMP
-HTMLCSSStyleSheetImpl::HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
-                                                  nsReStyleHint* aResult)
+nsReStyleHint
+HTMLCSSStyleSheetImpl::HasAttributeDependentStyle(AttributeRuleProcessorData* aData)
 {
-  *aResult = nsReStyleHint(0);
-  return NS_OK;
+  return nsReStyleHint(0);
 }
 
 NS_IMETHODIMP
 HTMLCSSStyleSheetImpl::MediumFeaturesChanged(nsPresContext* aPresContext,
                                              PRBool* aRulesChanged)
 {
   *aRulesChanged = PR_FALSE;
   return NS_OK;
--- a/layout/style/nsHTMLStyleSheet.cpp
+++ b/layout/style/nsHTMLStyleSheet.cpp
@@ -515,46 +515,42 @@ nsHTMLStyleSheet::HasStateDependentStyle
     *aResult = eReStyle_Self;
   }
   else
     *aResult = nsReStyleHint(0);
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsHTMLStyleSheet::HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
-                                             nsReStyleHint* aResult)
+nsReStyleHint
+nsHTMLStyleSheet::HasAttributeDependentStyle(AttributeRuleProcessorData* aData)
 {
   // Note: no need to worry about whether some states changed with this
   // attribute here, because we handle that under HasStateDependentStyle() as
   // needed.
 
   // Result is true for |href| changes on HTML links if we have link rules.
   nsIContent *content = aData->mContent;
   if (aData->mAttribute == nsGkAtoms::href &&
       (mLinkRule || mVisitedRule || mActiveRule) &&
       content &&
       content->IsHTML() &&
       aData->mContentTag == nsGkAtoms::a) {
-    *aResult = eReStyle_Self;
-    return NS_OK;
+    return eReStyle_Self;
   }
 
   // Don't worry about the mDocumentColorRule since it only applies
   // to descendants of body, when we're already reresolving.
 
   // Handle the content style rules.
   if (content && content->IsAttributeMapped(aData->mAttribute)) {
-    *aResult = eReStyle_Self;
-    return NS_OK;
+    return eReStyle_Self;
   }
 
-  *aResult = nsReStyleHint(0);
-  return NS_OK;
+  return nsReStyleHint(0);
 }
 
 NS_IMETHODIMP
 nsHTMLStyleSheet::MediumFeaturesChanged(nsPresContext* aPresContext,
                                         PRBool* aRulesChanged)
 {
   *aRulesChanged = PR_FALSE;
   return NS_OK;
--- a/layout/style/nsHTMLStyleSheet.h
+++ b/layout/style/nsHTMLStyleSheet.h
@@ -77,18 +77,18 @@ public:
   virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
 #endif
 
   // nsIStyleRuleProcessor API
   NS_IMETHOD RulesMatching(ElementRuleProcessorData* aData);
   NS_IMETHOD RulesMatching(PseudoRuleProcessorData* aData);
   NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData,
                                     nsReStyleHint* aResult);
-  NS_IMETHOD HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
-                                        nsReStyleHint* aResult);
+  virtual nsReStyleHint
+    HasAttributeDependentStyle(AttributeRuleProcessorData* aData);
   NS_IMETHOD MediumFeaturesChanged(nsPresContext* aPresContext,
                                    PRBool* aRulesChanged);
 
   nsresult Init(nsIURI* aURL, nsIDocument* aDocument);
   nsresult Reset(nsIURI* aURL);
   nsresult GetLinkColor(nscolor& aColor);
   nsresult GetActiveLinkColor(nscolor& aColor);
   nsresult GetVisitedLinkColor(nscolor& aColor);
--- a/layout/style/nsIStyleRuleProcessor.h
+++ b/layout/style/nsIStyleRuleProcessor.h
@@ -51,19 +51,20 @@
 
 struct RuleProcessorData;
 struct ElementRuleProcessorData;
 struct PseudoRuleProcessorData;
 struct StateRuleProcessorData;
 struct AttributeRuleProcessorData;
 class nsPresContext;
 
-// IID for the nsIStyleRuleProcessor interface {015575fe-7b6c-11d3-ba05-001083023c2b}
+// IID for the nsIStyleRuleProcessor interface {a4ec760e-6bfb-4b9f-bd08-9d1c23b700f6}
 #define NS_ISTYLE_RULE_PROCESSOR_IID     \
-{0x015575fe, 0x7b6c, 0x11d3, {0xba, 0x05, 0x00, 0x10, 0x83, 0x02, 0x3c, 0x2b}}
+{ 0xa4ec760e, 0x6bfb, 0x4b9f, \
+ { 0xbd, 0x08, 0x9d, 0x1c, 0x23, 0xb7, 0x00, 0xf6 } }
 
 /* The style rule processor interface is a mechanism to separate the matching
  * of style rules from style sheet instances.
  * Simple style sheets can and will act as their own processor. 
  * Sheets where rule ordering interlaces between multiple sheets, will need to 
  * share a single rule processor between them (CSS sheets do this for cascading order)
  *
  * @see nsIStyleRule (for significantly more detailed comments)
@@ -102,18 +103,18 @@ public:
                                     nsReStyleHint* aResult) = 0;
 
   /**
    * Return how (as described by nsReStyleHint) style can depend on the
    * presence or value of the given attribute for the given content
    * node.  This test is used for optimization only, and may err on the
    * side of reporting more dependencies than really exist.
    */
-  NS_IMETHOD HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
-                                        nsReStyleHint* aResult) = 0;
+  virtual nsReStyleHint
+    HasAttributeDependentStyle(AttributeRuleProcessorData* aData) = 0;
 
   /**
    * Do any processing that needs to happen as a result of a change in
    * the characteristics of the medium, and return whether this rule
    * processor's rules have changed (e.g., because of media queries).
    */
   NS_IMETHOD MediumFeaturesChanged(nsPresContext* aPresContext,
                                    PRBool* aRulesChanged) = 0;
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -1064,18 +1064,17 @@ struct AttributeData : public AttributeR
   {}
   nsReStyleHint   mHint;
 }; 
 
 static PRBool
 SheetHasAttributeStyle(nsIStyleRuleProcessor* aProcessor, void *aData)
 {
   AttributeData* data = (AttributeData*)aData;
-  nsReStyleHint hint;
-  aProcessor->HasAttributeDependentStyle(data, &hint);
+  nsReStyleHint hint = aProcessor->HasAttributeDependentStyle(data);
   data->mHint = nsReStyleHint(data->mHint | hint);
   return PR_TRUE; // continue
 }
 
 // Test if style is dependent on content state
 nsReStyleHint
 nsStyleSet::HasAttributeDependentStyle(nsPresContext* aPresContext,
                                        nsIContent*    aContent,
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -763,22 +763,20 @@ nsTransitionManager::RulesMatching(Pseud
 NS_IMETHODIMP
 nsTransitionManager::HasStateDependentStyle(StateRuleProcessorData* aData,
                                             nsReStyleHint* aResult)
 {
   *aResult = nsReStyleHint(0);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsTransitionManager::HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
-                                                nsReStyleHint* aResult)
+nsReStyleHint
+nsTransitionManager::HasAttributeDependentStyle(AttributeRuleProcessorData* aData)
 {
-  *aResult = nsReStyleHint(0);
-  return NS_OK;
+  return nsReStyleHint(0);
 }
 
 NS_IMETHODIMP
 nsTransitionManager::MediumFeaturesChanged(nsPresContext* aPresContext,
                                            PRBool* aRulesChanged)
 {
   *aRulesChanged = PR_FALSE;
   return NS_OK;
--- a/layout/style/nsTransitionManager.h
+++ b/layout/style/nsTransitionManager.h
@@ -83,18 +83,18 @@ public:
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIStyleRuleProcessor
   NS_IMETHOD RulesMatching(ElementRuleProcessorData* aData);
   NS_IMETHOD RulesMatching(PseudoRuleProcessorData* aData);
   NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData,
                                     nsReStyleHint* aResult);
-  NS_IMETHOD HasAttributeDependentStyle(AttributeRuleProcessorData* aData,
-                                        nsReStyleHint* aResult);
+  virtual nsReStyleHint
+    HasAttributeDependentStyle(AttributeRuleProcessorData* aData);
   NS_IMETHOD MediumFeaturesChanged(nsPresContext* aPresContext,
                                    PRBool* aRulesChanged);
 
   // nsARefreshObserver
   virtual void WillRefresh(mozilla::TimeStamp aTime);
 
 private:
   friend class ElementTransitions; // for TransitionsRemoved