Bug 562688 part 14. Eliminate eELEMENT usage in the rule processor; switch to Element as we can. r=dbaron
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 30 Apr 2010 09:12:06 -0400
changeset 41644 27aa022a527d272d181870e96db12fd0d4725905
parent 41643 1b7b064ee77a12a37b49fe3d598080696ce3c595
child 41645 5dba6e283a1b8680273b5fb1c2bac26ae65dc3c6
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs562688
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 562688 part 14. Eliminate eELEMENT usage in the rule processor; switch to Element as we can. r=dbaron
layout/style/nsCSSRuleProcessor.cpp
layout/style/nsHTMLCSSStyleSheet.cpp
layout/style/nsHTMLStyleSheet.cpp
layout/style/nsRuleProcessorData.h
layout/style/nsStyleSet.cpp
layout/style/nsTransitionManager.cpp
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -86,16 +86,19 @@
 #include "nsCSSRules.h"
 #include "nsIPrincipal.h"
 #include "nsStyleSet.h"
 #include "prlog.h"
 #include "nsIObserverService.h"
 #include "nsIPrivateBrowsingService.h"
 #include "nsNetCID.h"
 #include "mozilla/Services.h"
+#include "Element.h"
+
+using namespace mozilla::dom;
 
 #define VISITED_PSEUDO_PREF "layout.css.visited_links_enabled"
 
 static PRBool gSupportVisitedPseudo = PR_TRUE;
 
 static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
 static nsTArray< nsCOMPtr<nsIAtom> >* sSystemMetrics = 0;
 
@@ -974,73 +977,71 @@ nsCSSRuleProcessor::HasSystemMetric(nsIA
 {
   if (!sSystemMetrics && !InitSystemMetrics()) {
     return PR_FALSE;
   }
   return sSystemMetrics->IndexOf(aMetric) != sSystemMetrics->NoIndex;
 }
 
 RuleProcessorData::RuleProcessorData(nsPresContext* aPresContext,
-                                     nsIContent* aContent, 
+                                     Element* aElement, 
                                      nsRuleWalker* aRuleWalker,
                                      nsCompatibility* aCompat /*= nsnull*/)
   : mPresContext(aPresContext),
-    mContent(aContent),
+    mElement(aElement),
     mRuleWalker(aRuleWalker),
     mScopedRoot(nsnull),
     mPreviousSiblingData(nsnull),
     mParentData(nsnull),
     mLanguage(nsnull),
     mGotContentState(PR_FALSE)
 {
   MOZ_COUNT_CTOR(RuleProcessorData);
 
-  NS_ASSERTION(aContent && aContent->IsNodeOfType(nsINode::eELEMENT),
-               "non-element leaked into SelectorMatches");
+  NS_ASSERTION(aElement, "null element leaked into SelectorMatches");
 
   mNthIndices[0][0] = -2;
   mNthIndices[0][1] = -2;
   mNthIndices[1][0] = -2;
   mNthIndices[1][1] = -2;
 
   // get the compat. mode (unless it is provided)
   // XXXbz is passing in the compat mode really that much of an optimization?
   if (aCompat) {
     mCompatMode = *aCompat;
   } else if (NS_LIKELY(mPresContext)) {
     mCompatMode = mPresContext->CompatibilityMode();
   } else {
-    NS_ASSERTION(aContent, "Must have content");
-    NS_ASSERTION(aContent->GetOwnerDoc(), "Must have document");
-    mCompatMode = aContent->GetOwnerDoc()->GetCompatibilityMode();
+    NS_ASSERTION(aElement->GetOwnerDoc(), "Must have document");
+    mCompatMode = aElement->GetOwnerDoc()->GetCompatibilityMode();
   }
 
-  NS_ASSERTION(aContent->GetOwnerDoc(), "Document-less node here?");
+  NS_ASSERTION(aElement->GetOwnerDoc(), "Document-less node here?");
     
   // get the tag and parent
-  mContentTag = aContent->Tag();
-  mParentContent = aContent->GetParent();
+  mContentTag = aElement->Tag();
+  mParentContent = aElement->GetParent();
 
   // see if there are attributes for the content
-  mHasAttributes = aContent->GetAttrCount() > 0;
+  mHasAttributes = aElement->GetAttrCount() > 0;
   if (mHasAttributes) {
     // get the ID and classes for the content
-    mContentID = aContent->GetID();
-    mClasses = aContent->GetClasses();
+    mContentID = aElement->GetID();
+    mClasses = aElement->GetClasses();
   } else {
     mContentID = nsnull;
     mClasses = nsnull;
   }
 
   // get the namespace
-  mNameSpaceID = aContent->GetNameSpaceID();
+  mNameSpaceID = aElement->GetNameSpaceID();
 
   // check for HTMLContent status
   mIsHTMLContent = (mNameSpaceID == kNameSpaceID_XHTML);
-  mIsHTML = mIsHTMLContent && aContent->IsInHTMLDocument();
+  mIsHTML = mIsHTMLContent && aElement->IsInHTMLDocument();
 
   // No need to initialize mContentState; the ContentState() accessor will handle
   // that.
 }
 
 RuleProcessorData::~RuleProcessorData()
 {
   MOZ_COUNT_DTOR(RuleProcessorData);
@@ -1074,17 +1075,17 @@ RuleProcessorData::~RuleProcessorData()
 }
 
 const nsString* RuleProcessorData::GetLang()
 {
   if (!mLanguage) {
     mLanguage = new nsString();
     if (!mLanguage)
       return nsnull;
-    for (nsIContent* content = mContent; content;
+    for (nsIContent* content = mElement; content;
          content = content->GetParent()) {
       if (content->GetAttrCount() > 0) {
         // xml:lang has precedence over lang on HTML elements (see
         // XHTML1 section C.7).
         PRBool hasAttr = content->GetAttr(kNameSpaceID_XML, nsGkAtoms::lang,
                                           *mLanguage);
         if (!hasAttr && content->IsHTML()) {
           hasAttr = content->GetAttr(kNameSpaceID_None, nsGkAtoms::lang,
@@ -1103,20 +1104,20 @@ const nsString* RuleProcessorData::GetLa
 
 PRUint32
 RuleProcessorData::ContentState()
 {
   if (!mGotContentState) {
     mGotContentState = PR_TRUE;
     mContentState = 0;
     if (mPresContext) {
-      mPresContext->EventStateManager()->GetContentState(mContent,
+      mPresContext->EventStateManager()->GetContentState(mElement,
                                                          mContentState);
     } else {
-      mContentState = mContent->IntrinsicState();
+      mContentState = mElement->IntrinsicState();
     }
 
     // If we are not supposed to mark visited links as such, be sure to
     // flip the bits appropriately.  We want to do this here, rather
     // than in GetContentStateForVisitedHandling, so that we don't
     // expose that :visited support is disabled to the Web page.
     if ((!gSupportVisitedPseudo ||
         gPrivateBrowsingObserver->InPrivateBrowsing()) &&
@@ -1126,17 +1127,17 @@ RuleProcessorData::ContentState()
     }
   }
   return mContentState;
 }
 
 PRUint32
 RuleProcessorData::DocumentState()
 {
-  return mContent->GetOwnerDoc()->GetDocumentState();
+  return mElement->GetOwnerDoc()->GetDocumentState();
 }
 
 PRBool
 RuleProcessorData::IsLink()
 {
   PRUint32 state = ContentState();
   return (state & (NS_EVENT_STATE_VISITED | NS_EVENT_STATE_UNVISITED)) != 0;
 }
@@ -1170,19 +1171,16 @@ RuleProcessorData::GetContentStateForVis
   return contentState;
 }
 
 PRInt32
 RuleProcessorData::GetNthIndex(PRBool aIsOfType, PRBool aIsFromEnd,
                                PRBool aCheckEdgeOnly)
 {
   NS_ASSERTION(mParentContent, "caller should check mParentContent");
-  NS_ASSERTION(!mPreviousSiblingData ||
-               mPreviousSiblingData->mContent->IsNodeOfType(nsINode::eELEMENT),
-               "Unexpected previous sibling data");
 
   PRInt32 &slot = mNthIndices[aIsOfType][aIsFromEnd];
   if (slot != -2 && (slot != -1 || aCheckEdgeOnly))
     return slot;
 
   if (mPreviousSiblingData &&
       (!aIsOfType ||
        (mPreviousSiblingData->mNameSpaceID == mNameSpaceID &&
@@ -1218,19 +1216,19 @@ RuleProcessorData::GetNthIndex(PRBool aI
 
   for ( ; ; curChildPtr += increment) {
     if (curChildPtr == stopPtr) {
       // mContent is the root of an anonymous content subtree.
       result = 0; // special value to indicate that it is not at any index
       break;
     }
     nsIContent* child = *curChildPtr;
-    if (child == mContent)
+    if (child == mElement)
       break;
-    if (child->IsNodeOfType(nsINode::eELEMENT) &&
+    if (child->IsElement() &&
         (!aIsOfType ||
          (child->Tag() == mContentTag &&
           child->GetNameSpaceID() == mNameSpaceID))) {
       if (aCheckEdgeOnly) {
         // The caller only cares whether or not the result is 1, and we
         // now know it's not.
         result = -1;
         break;
@@ -1491,17 +1489,17 @@ edgeOfTypeMatches(RuleProcessorData& dat
 }
 
 static inline PRBool
 checkGenericEmptyMatches(RuleProcessorData& data,
                          TreeMatchContext& aTreeMatchContext,
                          PRBool isWhitespaceSignificant)
 {
   nsIContent *child = nsnull;
-  nsIContent *element = data.mContent;
+  Element *element = data.mElement;
   PRInt32 index = -1;
 
   if (aTreeMatchContext.mForStyling)
     element->SetFlags(NODE_HAS_EMPTY_SELECTOR);
 
   do {
     child = element->GetChildAt(++index);
     // stop at first non-comment (and non-whitespace for
@@ -1645,17 +1643,17 @@ static PRBool SelectorMatches(RuleProces
           return PR_FALSE;
         }
         break;
 
       case nsCSSPseudoClasses::ePseudoClass_mozEmptyExceptChildrenWithLocalname:
         {
           NS_ASSERTION(pseudoClass->u.mString, "Must have string!");
           nsIContent *child = nsnull;
-          nsIContent *element = data.mContent;
+          Element *element = data.mElement;
           PRInt32 index = -1;
 
           if (aTreeMatchContext.mForStyling)
             element->SetFlags(NODE_HAS_SLOW_SELECTOR);
           do {
             child = element->GetChildAt(++index);
           } while (child &&
                    (!IsSignificantChild(child, PR_TRUE, PR_FALSE) ||
@@ -1684,17 +1682,17 @@ static PRBool SelectorMatches(RuleProces
                                              nsDependentString(pseudoClass->u.mString),
                                              nsCaseInsensitiveStringComparator())) {
             return PR_FALSE;
           }
           // This pseudo-class matched; move on to the next thing
           break;
         }
 
-        nsIDocument* doc = data.mContent->GetDocument();
+        nsIDocument* doc = data.mElement->GetDocument();
         if (doc) {
           // Try to get the language from the HTTP header or if this
           // is missing as well from the preferences.
           // The content language can be a comma-separated list of
           // language codes.
           nsAutoString language;
           doc->GetContentLanguage(language);
 
@@ -1721,24 +1719,24 @@ static PRBool SelectorMatches(RuleProces
           }
         }
 
         return PR_FALSE;
       }
       break;
 
       case nsCSSPseudoClasses::ePseudoClass_mozBoundElement:
-        if (data.mScopedRoot != data.mContent) {
+        if (data.mScopedRoot != data.mElement) {
           return PR_FALSE;
         }
         break;
 
       case nsCSSPseudoClasses::ePseudoClass_root:
         if (data.mParentContent != nsnull ||
-            data.mContent != data.mContent->GetOwnerDoc()->GetRootElement()) {
+            data.mElement != data.mElement->GetOwnerDoc()->GetRootElement()) {
           return PR_FALSE;
         }
         break;
 
       case nsCSSPseudoClasses::ePseudoClass_any:
         {
           nsCSSSelectorList *l;
           for (l = pseudoClass->u.mSelectors; l; l = l->mNext) {
@@ -1771,17 +1769,17 @@ static PRBool SelectorMatches(RuleProces
 
             PRInt32 index = -1;
             do {
               firstNode = parent->GetChildAt(++index);
               // stop at first non-comment and non-whitespace node
             } while (firstNode &&
                      !IsSignificantChild(firstNode, PR_TRUE, PR_FALSE));
           }
-          if (data.mContent != firstNode) {
+          if (data.mElement != firstNode) {
             return PR_FALSE;
           }
         }
         break;
 
       case nsCSSPseudoClasses::ePseudoClass_lastChild:
         if (!edgeChildMatches(data, aTreeMatchContext, PR_FALSE, PR_TRUE)) {
           return PR_FALSE;
@@ -1798,17 +1796,17 @@ static PRBool SelectorMatches(RuleProces
             
             PRUint32 index = parent->GetChildCount();
             do {
               lastNode = parent->GetChildAt(--index);
               // stop at first non-comment and non-whitespace node
             } while (lastNode &&
                      !IsSignificantChild(lastNode, PR_TRUE, PR_FALSE));
           }
-          if (data.mContent != lastNode) {
+          if (data.mElement != lastNode) {
             return PR_FALSE;
           }
         }
         break;
 
       case nsCSSPseudoClasses::ePseudoClass_onlyChild:
         if (!edgeChildMatches(data, aTreeMatchContext, PR_TRUE, PR_TRUE)) {
           return PR_FALSE;
@@ -1859,17 +1857,17 @@ static PRBool SelectorMatches(RuleProces
                                     PR_TRUE, PR_TRUE)) {
           return PR_FALSE;
         }
         break;
 
       case nsCSSPseudoClasses::ePseudoClass_mozHasHandlerRef:
         {
           nsIContent *child = nsnull;
-          nsIContent *element = data.mContent;
+          Element *element = data.mElement;
           PRInt32 index = -1;
 
           do {
             child = element->GetChildAt(++index);
             if (child && child->IsHTML() &&
                 child->Tag() == nsGkAtoms::param &&
                 child->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
                                    NS_LITERAL_STRING("pluginurl"),
@@ -1911,37 +1909,37 @@ static PRBool SelectorMatches(RuleProces
           if (dirString.EqualsLiteral("rtl") != docIsRTL) {
             return PR_FALSE;
           }
         }
         break;
 
       case nsCSSPseudoClasses::ePseudoClass_mozLWTheme:
         {
-          nsIDocument* doc = data.mContent->GetOwnerDoc();
+          nsIDocument* doc = data.mElement->GetOwnerDoc();
           if (!doc ||
               doc->GetDocumentLWTheme() <= nsIDocument::Doc_Theme_None) {
             return PR_FALSE;
           }
         }
         break;
 
       case nsCSSPseudoClasses::ePseudoClass_mozLWThemeBrightText:
         {
-          nsIDocument* doc = data.mContent->GetOwnerDoc();
+          nsIDocument* doc = data.mElement->GetOwnerDoc();
           if (!doc ||
               doc->GetDocumentLWTheme() != nsIDocument::Doc_Theme_Bright) {
             return PR_FALSE;
           }
         }
         break;
 
       case nsCSSPseudoClasses::ePseudoClass_mozLWThemeDarkText:
         {
-          nsIDocument* doc = data.mContent->GetOwnerDoc();
+          nsIDocument* doc = data.mElement->GetOwnerDoc();
           if (!doc ||
               doc->GetDocumentLWTheme() != nsIDocument::Doc_Theme_Dark) {
             return PR_FALSE;
           }
         }
         break;
 
       case nsCSSPseudoClasses::ePseudoClass_mozWindowInactive:
@@ -2003,33 +2001,33 @@ static PRBool SelectorMatches(RuleProces
         if (attr->mNameSpace == kNameSpaceID_Unknown) {
           // Attr selector with a wildcard namespace.  We have to examine all
           // the attributes on our content node....  This sort of selector is
           // essentially a boolean OR, over all namespaces, of equivalent attr
           // selectors with those namespaces.  So to evaluate whether it
           // matches, evaluate for each namespace (the only namespaces that
           // have a chance at matching, of course, are ones that the element
           // actually has attributes in), short-circuiting if we ever match.
-          PRUint32 attrCount = data.mContent->GetAttrCount();
+          PRUint32 attrCount = data.mElement->GetAttrCount();
           result = PR_FALSE;
           for (PRUint32 i = 0; i < attrCount; ++i) {
             const nsAttrName* attrName =
-              data.mContent->GetAttrNameAt(i);
+              data.mElement->GetAttrNameAt(i);
             NS_ASSERTION(attrName, "GetAttrCount lied or GetAttrNameAt failed");
             if (attrName->LocalName() != matchAttribute) {
               continue;
             }
             if (attr->mFunction == NS_ATTR_FUNC_SET) {
               result = PR_TRUE;
             } else {
               nsAutoString value;
 #ifdef DEBUG
               PRBool hasAttr =
 #endif
-                data.mContent->GetAttr(attrName->NamespaceID(),
+                data.mElement->GetAttr(attrName->NamespaceID(),
                                        attrName->LocalName(), value);
               NS_ASSERTION(hasAttr, "GetAttrNameAt lied");
               result = AttrMatchesValue(attr, value, data.mIsHTML);
             }
 
             // At this point |result| has been set by us
             // explicitly in this loop.  If it's PR_FALSE, we may still match
             // -- the content may have another attribute with the same name but
@@ -2037,30 +2035,30 @@ static PRBool SelectorMatches(RuleProces
             // can short-circuit the boolean OR described above).
             if (result) {
               break;
             }
           }
         }
         else if (attr->mFunction == NS_ATTR_FUNC_EQUALS) {
           result =
-            data.mContent->
+            data.mElement->
               AttrValueIs(attr->mNameSpace, matchAttribute, attr->mValue,
                           (!data.mIsHTML || attr->mCaseSensitive) ? eCaseMatters
                                                                   : eIgnoreCase);
         }
-        else if (!data.mContent->HasAttr(attr->mNameSpace, matchAttribute)) {
+        else if (!data.mElement->HasAttr(attr->mNameSpace, matchAttribute)) {
           result = PR_FALSE;
         }
         else if (attr->mFunction != NS_ATTR_FUNC_SET) {
           nsAutoString value;
 #ifdef DEBUG
           PRBool hasAttr =
 #endif
-              data.mContent->GetAttr(attr->mNameSpace, matchAttribute, value);
+              data.mElement->GetAttr(attr->mNameSpace, matchAttribute, value);
           NS_ASSERTION(hasAttr, "HasAttr lied");
           result = AttrMatchesValue(attr, value, data.mIsHTML);
         }
         
         attr = attr->mNext;
       } while (attr && result);
     }
   }
@@ -2111,27 +2109,27 @@ static PRBool SelectorMatchesTree(RulePr
     // selector is the previous sibling *element*
     RuleProcessorData* data;
     if (PRUnichar('+') == selector->mOperator ||
         PRUnichar('~') == selector->mOperator) {
       // The relevant link must be an ancestor of the node being matched.
       aLookForRelevantLink = PR_FALSE;
       data = prevdata->mPreviousSiblingData;
       if (!data) {
-        nsIContent* content = prevdata->mContent;
         nsIContent* parent = prevdata->mParentContent;
         if (parent) {
           if (aTreeMatchContext.mForStyling)
             parent->SetFlags(NODE_HAS_SLOW_SELECTOR_NOAPPEND);
 
-          PRInt32 index = parent->IndexOf(content);
+          PRInt32 index = parent->IndexOf(prevdata->mElement);
           while (0 <= --index) {
-            content = parent->GetChildAt(index);
-            if (content->IsNodeOfType(nsINode::eELEMENT)) {
-              data = RuleProcessorData::Create(prevdata->mPresContext, content,
+            nsIContent* content = parent->GetChildAt(index);
+            if (content->IsElement()) {
+              data = RuleProcessorData::Create(prevdata->mPresContext,
+                                               content->AsElement(),
                                                prevdata->mRuleWalker,
                                                prevdata->mCompatMode);
               prevdata->mPreviousSiblingData = data;    
               break;
             }
           }
         }
       }
@@ -2139,18 +2137,19 @@ static PRBool SelectorMatchesTree(RulePr
     // for descendant combinators and child combinators, the content
     // to test against is the parent
     else {
       data = prevdata->mParentData;
       if (!data) {
         nsIContent *content = prevdata->mParentContent;
         // GetParent could return a document fragment; we only want
         // element parents.
-        if (content && content->IsNodeOfType(nsINode::eELEMENT)) {
-          data = RuleProcessorData::Create(prevdata->mPresContext, content,
+        if (content && content->IsElement()) {
+          data = RuleProcessorData::Create(prevdata->mPresContext,
+                                           content->AsElement(),
                                            prevdata->mRuleWalker,
                                            prevdata->mCompatMode);
           prevdata->mParentData = data;
         }
       }
     }
     if (! data) {
       return PR_FALSE;
@@ -2237,38 +2236,32 @@ static void ContentEnumFunc(nsICSSStyleR
   if (treeContext.mHaveRelevantLink) {
     data->mRuleWalker->SetHaveRelevantLink();
   }
 }
 
 NS_IMETHODIMP
 nsCSSRuleProcessor::RulesMatching(ElementRuleProcessorData *aData)
 {
-  NS_PRECONDITION(aData->mContent->IsNodeOfType(nsINode::eELEMENT),
-                  "content must be element");
-
   RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
 
   if (cascade) {
     cascade->mRuleHash.EnumerateAllRules(aData->mNameSpaceID,
                                          aData->mContentTag,
                                          aData->mContentID,
                                          aData->mClasses,
                                          ContentEnumFunc,
                                          aData);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCSSRuleProcessor::RulesMatching(PseudoElementRuleProcessorData* aData)
 {
-  NS_PRECONDITION(aData->mContent->IsNodeOfType(nsINode::eELEMENT),
-                  "content must be element");
-
   RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
 
   if (cascade) {
     RuleHash* ruleHash = cascade->mPseudoElementRuleHashes[aData->mPseudoType];
     if (ruleHash) {
       ruleHash->EnumerateAllRules(aData->mNameSpaceID,
                                   aData->mContentTag,
                                   aData->mContentID,
@@ -2306,19 +2299,16 @@ nsCSSRuleProcessor::RulesMatching(AnonBo
   }
   return NS_OK;
 }
 
 #ifdef MOZ_XUL
 NS_IMETHODIMP
 nsCSSRuleProcessor::RulesMatching(XULTreeRuleProcessorData* aData)
 {
-  NS_PRECONDITION(aData->mContent->IsNodeOfType(nsINode::eELEMENT),
-                  "content must be element");
-
   RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
 
   if (cascade && cascade->mXULTreeRules.entryCount) {
     RuleHashTagTableEntry* entry = static_cast<RuleHashTagTableEntry*>
       (PL_DHashTableOperate(&cascade->mXULTreeRules, aData->mPseudoTag,
                             PL_DHASH_LOOKUP));
     if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
       for (RuleValue *value = entry->mRules; value; value = value->mNext) {
@@ -2340,19 +2330,16 @@ inline PRBool
 IsSiblingOperator(PRUnichar oper)
 {
   return oper == PRUnichar('+') || oper == PRUnichar('~');
 }
 
 nsRestyleHint
 nsCSSRuleProcessor::HasStateDependentStyle(StateRuleProcessorData* aData)
 {
-  NS_PRECONDITION(aData->mContent->IsNodeOfType(nsINode::eELEMENT),
-                  "content must be element");
-
   RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
 
   // Look up the content node in the state rule list, which points to
   // any (CSS2 definition) simple selector (whether or not it is the
   // subject) that has a state pseudo-class on it.  This means that this
   // code will be matching selectors that aren't real selectors in any
   // stylesheet (e.g., if there is a selector "body > p:hover > a", then
   // "body > p:hover" will be in |cascade->mStateSelectors|).  Note that
@@ -2421,55 +2408,52 @@ AttributeEnumFunc(nsCSSSelector* aSelect
       SelectorMatchesTree(*data, aSelector->mNext, treeContext, PR_FALSE)) {
     aData->change = nsRestyleHint(aData->change | possibleChange);
   }
 }
 
 nsRestyleHint
 nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData)
 {
-  NS_PRECONDITION(aData->mContent->IsNodeOfType(nsINode::eELEMENT),
-                  "content must be element");
-
   //  We could try making use of aData->mModType, but :not rules make it a bit
   //  of a pain to do so...  So just ignore it for now.
 
   AttributeEnumData data(aData);
 
   // Don't do our special handling of certain attributes if the attr
   // hasn't changed yet.
   if (aData->mAttrHasChanged) {
     // check for the lwtheme and lwthemetextcolor attribute on root XUL elements
     if ((aData->mAttribute == nsGkAtoms::lwtheme ||
          aData->mAttribute == nsGkAtoms::lwthemetextcolor) &&
         aData->mNameSpaceID == kNameSpaceID_XUL &&
-        aData->mContent == aData->mContent->GetOwnerDoc()->GetRootElement())
+        aData->mElement == aData->mElement->GetOwnerDoc()->GetRootElement())
       {
         data.change = nsRestyleHint(data.change | eRestyle_Self);
       }
   }
 
   RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
 
   // Since we get both before and after notifications for attributes, we
   // don't have to ignore aData->mAttribute while matching.  Just check
   // whether we have selectors relevant to aData->mAttribute that we
   // match.  If this is the before change notification, that will catch
   // rules we might stop matching; if the after change notification, the
   // ones we might have started matching.
   if (cascade) {
-    if (aData->mAttribute == aData->mContent->GetIDAttributeName()) {
+    if (aData->mAttribute == aData->mElement->GetIDAttributeName()) {
       nsCSSSelector **iter = cascade->mIDSelectors.Elements(),
                     **end = iter + cascade->mIDSelectors.Length();
       for(; iter != end; ++iter) {
         AttributeEnumFunc(*iter, &data);
       }
     }
     
-    if (aData->mAttribute == aData->mContent->GetClassAttributeName()) {
+    if (aData->mAttribute == aData->mElement->GetClassAttributeName()) {
       nsCSSSelector **iter = cascade->mClassSelectors.Elements(),
                     **end = iter + cascade->mClassSelectors.Length();
       for(; iter != end; ++iter) {
         AttributeEnumFunc(*iter, &data);
       }
     }
 
     AttributeSelectorEntry *entry = static_cast<AttributeSelectorEntry*>
--- a/layout/style/nsHTMLCSSStyleSheet.cpp
+++ b/layout/style/nsHTMLCSSStyleSheet.cpp
@@ -50,16 +50,19 @@
 #include "nsICSSStyleRule.h"
 #include "nsIStyleRuleProcessor.h"
 #include "nsPresContext.h"
 #include "nsIDocument.h"
 #include "nsCOMPtr.h"
 #include "nsRuleWalker.h"
 #include "nsRuleData.h"
 #include "nsRuleProcessorData.h"
+#include "Element.h"
+
+using namespace mozilla::dom;
 
 nsHTMLCSSStyleSheet::nsHTMLCSSStyleSheet()
   : mRefCnt(0),
     mURL(nsnull),
     mDocument(nsnull)
 {
 }
 
@@ -70,34 +73,34 @@ nsHTMLCSSStyleSheet::~nsHTMLCSSStyleShee
 
 NS_IMPL_ISUPPORTS2(nsHTMLCSSStyleSheet,
                    nsIStyleSheet,
                    nsIStyleRuleProcessor)
 
 NS_IMETHODIMP
 nsHTMLCSSStyleSheet::RulesMatching(ElementRuleProcessorData* aData)
 {
-  nsIContent* content = aData->mContent;
+  Element* element = aData->mElement;
 
   // just get the one and only style rule from the content's STYLE attribute
-  nsICSSStyleRule* rule = content->GetInlineStyleRule();
+  nsICSSStyleRule* rule = element->GetInlineStyleRule();
   if (rule) {
     rule->RuleMatched();
     aData->mRuleWalker->Forward(rule);
   }
 
 #ifdef MOZ_SMIL
-  rule = content->GetSMILOverrideStyleRule();
+  rule = element->GetSMILOverrideStyleRule();
   if (rule) {
     if (aData->mPresContext->IsProcessingRestyles() &&
         !aData->mPresContext->IsProcessingAnimationStyleChange()) {
       // Non-animation restyle -- don't process SMIL override style, because we
       // don't want SMIL animation to trigger new CSS transitions. Instead,
       // request an Animation restyle, so we still get noticed.
-      aData->mPresContext->PresShell()->RestyleForAnimation(aData->mContent);
+      aData->mPresContext->PresShell()->RestyleForAnimation(element);
     } else {
       // Animation restyle (or non-restyle traversal of rules)
       // Now we can walk SMIL overrride style, without triggering transitions.
       rule->RuleMatched();
       aData->mRuleWalker->Forward(rule);
     }
   }
 #endif // MOZ_SMIL
--- a/layout/style/nsHTMLStyleSheet.cpp
+++ b/layout/style/nsHTMLStyleSheet.cpp
@@ -65,16 +65,19 @@
 #include "nsStyleConsts.h"
 #include "nsIHTMLDocument.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsRuleWalker.h"
 #include "nsRuleData.h"
 #include "nsContentErrors.h"
 #include "nsRuleProcessorData.h"
+#include "Element.h"
+
+using namespace mozilla::dom;
 
 NS_IMPL_ISUPPORTS1(nsHTMLStyleSheet::HTMLColorRule, nsIStyleRule)
 
 NS_IMETHODIMP
 nsHTMLStyleSheet::HTMLColorRule::MapRuleInfoInto(nsRuleData* aRuleData)
 {
   if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
     if (aRuleData->mColorData->mColor.GetUnit() == eCSSUnit_Null &&
@@ -223,75 +226,71 @@ static nsresult GetBodyColor(nsPresConte
     return NS_ERROR_FAILURE;
   *aColor = bodyFrame->GetStyleColor()->mColor;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLStyleSheet::RulesMatching(ElementRuleProcessorData* aData)
 {
-  nsIContent *content = aData->mContent;
-
-  if (content) {
-    nsRuleWalker *ruleWalker = aData->mRuleWalker;
-    if (aData->mIsHTMLContent) {
-      nsIAtom* tag = aData->mContentTag;
+  nsRuleWalker *ruleWalker = aData->mRuleWalker;
+  if (aData->mIsHTMLContent) {
+    nsIAtom* tag = aData->mContentTag;
 
-      // if we have anchor colors, check if this is an anchor with an href
-      if (tag == nsGkAtoms::a) {
-        if (mLinkRule || mVisitedRule || mActiveRule) {
-          PRUint32 state = aData->GetContentStateForVisitedHandling(
-                                    ruleWalker->VisitedHandling(),
-                                    // If the node being matched is a link,
-                                    // it's the relevant link.
-                                    aData->IsLink());
-          if (mLinkRule && (state & NS_EVENT_STATE_UNVISITED)) {
-            ruleWalker->Forward(mLinkRule);
-            ruleWalker->SetHaveRelevantLink();
-          }
-          else if (mVisitedRule && (state & NS_EVENT_STATE_VISITED)) {
-            ruleWalker->Forward(mVisitedRule);
-            ruleWalker->SetHaveRelevantLink();
-          }
+    // if we have anchor colors, check if this is an anchor with an href
+    if (tag == nsGkAtoms::a) {
+      if (mLinkRule || mVisitedRule || mActiveRule) {
+        PRUint32 state = aData->GetContentStateForVisitedHandling(
+                                  ruleWalker->VisitedHandling(),
+                                  // If the node being matched is a link,
+                                  // it's the relevant link.
+                                  aData->IsLink());
+        if (mLinkRule && (state & NS_EVENT_STATE_UNVISITED)) {
+          ruleWalker->Forward(mLinkRule);
+          ruleWalker->SetHaveRelevantLink();
+        }
+        else if (mVisitedRule && (state & NS_EVENT_STATE_VISITED)) {
+          ruleWalker->Forward(mVisitedRule);
+          ruleWalker->SetHaveRelevantLink();
+        }
 
-          // No need to add to the active rule if it's not a link
-          if (mActiveRule && aData->IsLink() &&
-              (state & NS_EVENT_STATE_ACTIVE)) {
-            ruleWalker->Forward(mActiveRule);
+        // No need to add to the active rule if it's not a link
+        if (mActiveRule && aData->IsLink() &&
+            (state & NS_EVENT_STATE_ACTIVE)) {
+          ruleWalker->Forward(mActiveRule);
+        }
+      } // end link/visited/active rules
+    } // end A tag
+    // add the rule to handle text-align for a <th>
+    else if (tag == nsGkAtoms::th) {
+      ruleWalker->Forward(mTableTHRule);
+    }
+    else if (tag == nsGkAtoms::table) {
+      if (aData->mCompatMode == eCompatibility_NavQuirks) {
+        nscolor bodyColor;
+        nsresult rv =
+          GetBodyColor(ruleWalker->CurrentNode()->GetPresContext(),
+                       &bodyColor);
+        if (NS_SUCCEEDED(rv) &&
+            (!mDocumentColorRule || bodyColor != mDocumentColorRule->mColor)) {
+          NS_IF_RELEASE(mDocumentColorRule);
+          mDocumentColorRule = new HTMLColorRule();
+          if (mDocumentColorRule) {
+            NS_ADDREF(mDocumentColorRule);
+            mDocumentColorRule->mColor = bodyColor;
           }
-        } // end link/visited/active rules
-      } // end A tag
-      // add the rule to handle text-align for a <th>
-      else if (tag == nsGkAtoms::th) {
-        ruleWalker->Forward(mTableTHRule);
+        }
+        if (mDocumentColorRule)
+          ruleWalker->Forward(mDocumentColorRule);
       }
-      else if (tag == nsGkAtoms::table) {
-        if (aData->mCompatMode == eCompatibility_NavQuirks) {
-          nscolor bodyColor;
-          nsresult rv =
-            GetBodyColor(ruleWalker->CurrentNode()->GetPresContext(),
-                         &bodyColor);
-          if (NS_SUCCEEDED(rv) &&
-              (!mDocumentColorRule || bodyColor != mDocumentColorRule->mColor)) {
-            NS_IF_RELEASE(mDocumentColorRule);
-            mDocumentColorRule = new HTMLColorRule();
-            if (mDocumentColorRule) {
-              NS_ADDREF(mDocumentColorRule);
-              mDocumentColorRule->mColor = bodyColor;
-            }
-          }
-          if (mDocumentColorRule)
-            ruleWalker->Forward(mDocumentColorRule);
-        }
-      }
-    } // end html element
+    }
+  } // end html element
 
     // just get the style rules from the content
-    content->WalkContentStyleRules(ruleWalker);
-  }
+  aData->mElement->WalkContentStyleRules(ruleWalker);
 
   return NS_OK;
 }
 
 // Test if style is dependent on content state
 nsRestyleHint
 nsHTMLStyleSheet::HasStateDependentStyle(StateRuleProcessorData* aData)
 {
@@ -321,30 +320,29 @@ nsHTMLStyleSheet::HasAttributeDependentS
     return nsRestyleHint(0);
   }
 
   // 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;
+  Element *element = aData->mElement;
   if (aData->mAttribute == nsGkAtoms::href &&
       (mLinkRule || mVisitedRule || mActiveRule) &&
-      content &&
-      content->IsHTML() &&
+      element->IsHTML() &&
       aData->mContentTag == nsGkAtoms::a) {
     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)) {
+  if (element->IsAttributeMapped(aData->mAttribute)) {
     return eRestyle_Self;
   }
 
   return nsRestyleHint(0);
 }
 
 NS_IMETHODIMP
 nsHTMLStyleSheet::MediumFeaturesChanged(nsPresContext* aPresContext,
--- a/layout/style/nsRuleProcessorData.h
+++ b/layout/style/nsRuleProcessorData.h
@@ -56,35 +56,35 @@ class nsIAtom;
 class nsICSSPseudoComparator;
 class nsAttrValue;
 
 // The implementation of the constructor and destructor are currently in
 // nsCSSRuleProcessor.cpp.
 
 struct RuleProcessorData {
   RuleProcessorData(nsPresContext* aPresContext,
-                    nsIContent* aContent, 
+                    mozilla::dom::Element* aElement, 
                     nsRuleWalker* aRuleWalker,
                     nsCompatibility* aCompat = nsnull);
   
   // NOTE: not |virtual|
   ~RuleProcessorData();
 
   // This should be used for all heap-allocation of RuleProcessorData
   static RuleProcessorData* Create(nsPresContext* aPresContext,
-                                   nsIContent* aContent, 
+                                   mozilla::dom::Element* aElement, 
                                    nsRuleWalker* aRuleWalker,
                                    nsCompatibility aCompat)
   {
     if (NS_LIKELY(aPresContext)) {
-      return new (aPresContext) RuleProcessorData(aPresContext, aContent,
+      return new (aPresContext) RuleProcessorData(aPresContext, aElement,
                                                   aRuleWalker, &aCompat);
     }
 
-    return new RuleProcessorData(aPresContext, aContent, aRuleWalker,
+    return new RuleProcessorData(aPresContext, aElement, aRuleWalker,
                                  &aCompat);
   }
   
   void Destroy() {
     nsPresContext * pc = mPresContext;
     if (NS_LIKELY(pc)) {
       this->~RuleProcessorData();
       pc->FreeToShell(sizeof(RuleProcessorData), this);
@@ -119,29 +119,29 @@ public:
   // returns 0.
   // If aCheckEdgeOnly is true, the function will return 1 if the result
   // is 1, and something other than 1 (maybe or maybe not a valid
   // result) otherwise.
   PRInt32 GetNthIndex(PRBool aIsOfType, PRBool aIsFromEnd,
                       PRBool aCheckEdgeOnly);
 
   nsPresContext*    mPresContext;
-  nsIContent*       mContent;       // weak ref, must not be null
-  nsIContent*       mParentContent; // mContent->GetParent(); weak ref
+  mozilla::dom::Element* mElement;       // weak ref, must not be null
+  nsIContent*       mParentContent; // mElement->GetParent(); weak ref
   nsRuleWalker*     mRuleWalker; // Used to add rules to our results.
   nsIContent*       mScopedRoot;    // Root of scoped stylesheet (set and unset by the supplier of the scoped stylesheet
   
-  nsIAtom*          mContentTag;    // mContent->GetTag()
-  nsIAtom*          mContentID;     // mContent->GetID()
-  PRPackedBool      mIsHTMLContent; // whether mContent it's IsHTML()
+  nsIAtom*          mContentTag;    // mElement->GetTag()
+  nsIAtom*          mContentID;     // mElement->GetID()
+  PRPackedBool      mIsHTMLContent; // whether mElement is IsHTML()
   PRPackedBool      mIsHTML;        // mIsHTMLContent && IsInHTMLDocument()
-  PRPackedBool      mHasAttributes; // mContent->GetAttrCount() > 0
+  PRPackedBool      mHasAttributes; // mElement->GetAttrCount() > 0
   nsCompatibility   mCompatMode;    // Possibly remove use of this in SelectorMatches?
-  PRInt32           mNameSpaceID;   // mContent->GetNameSapce()
-  const nsAttrValue* mClasses;      // mContent->GetClasses()
+  PRInt32           mNameSpaceID;   // mElement->GetNameSapce()
+  const nsAttrValue* mClasses;      // mElement->GetClasses()
   // mPreviousSiblingData and mParentData are always RuleProcessorData
   // and never a derived class.  They are allocated lazily, when
   // selectors require matching of prior siblings or ancestors.
   RuleProcessorData* mPreviousSiblingData;
   RuleProcessorData* mParentData;
 
 private:
   nsString *mLanguage; // NULL means we haven't found out the language yet
@@ -151,39 +151,39 @@ private:
   // If -1, needs to be computed but known not to be 1.
   // If 0, the node is not at any index in its parent.
   // The first subscript is 0 for -child and 1 for -of-type, the second
   // subscript is 0 for nth- and 1 for nth-last-.
   PRInt32 mNthIndices[2][2];
 
   // mContentState is initialized lazily.
   PRInt32 mContentState;  // eventStateMgr->GetContentState() or
-                          // mContent->IntrinsicState() if we have no ESM
+                          // mElement->IntrinsicState() if we have no ESM
                           // adjusted for not supporting :visited (but with
                           // visitedness information when we support it)
   PRPackedBool mGotContentState;
 };
 
 struct ElementRuleProcessorData : public RuleProcessorData {
   ElementRuleProcessorData(nsPresContext* aPresContext,
-                           nsIContent* aContent, 
+                           mozilla::dom::Element* aElement, 
                            nsRuleWalker* aRuleWalker)
-  : RuleProcessorData(aPresContext,aContent,aRuleWalker)
+  : RuleProcessorData(aPresContext, aElement, aRuleWalker)
   {
     NS_PRECONDITION(aPresContext, "null pointer");
     NS_PRECONDITION(aRuleWalker, "null pointer");
   }
 };
 
 struct PseudoElementRuleProcessorData : public RuleProcessorData {
   PseudoElementRuleProcessorData(nsPresContext* aPresContext,
-                                 nsIContent* aParentContent,
+                                 mozilla::dom::Element* aParentElement,
                                  nsRuleWalker* aRuleWalker,
                                  nsCSSPseudoElements::Type aPseudoType)
-    : RuleProcessorData(aPresContext, aParentContent, aRuleWalker),
+    : RuleProcessorData(aPresContext, aParentElement, aRuleWalker),
       mPseudoType(aPseudoType)
   {
     NS_PRECONDITION(aPresContext, "null pointer");
     NS_PRECONDITION(aPseudoType <
                       nsCSSPseudoElements::ePseudo_PseudoElementCount,
                     "null pointer");
     NS_PRECONDITION(aRuleWalker, "null pointer");
   }
@@ -207,55 +207,55 @@ struct AnonBoxRuleProcessorData {
   nsPresContext* mPresContext;
   nsIAtom* mPseudoTag;
   nsRuleWalker* mRuleWalker;
 };
 
 #ifdef MOZ_XUL
 struct XULTreeRuleProcessorData : public RuleProcessorData {
   XULTreeRuleProcessorData(nsPresContext* aPresContext,
-                           nsIContent* aParentContent,
+                           mozilla::dom::Element* aParentElement,
                            nsRuleWalker* aRuleWalker,
                            nsIAtom* aPseudoTag,
                            nsICSSPseudoComparator* aComparator)
-    : RuleProcessorData(aPresContext, aParentContent, aRuleWalker),
+    : RuleProcessorData(aPresContext, aParentElement, aRuleWalker),
       mPseudoTag(aPseudoTag),
       mComparator(aComparator)
   {
     NS_PRECONDITION(aPresContext, "null pointer");
     NS_PRECONDITION(aPseudoTag, "null pointer");
     NS_PRECONDITION(aRuleWalker, "null pointer");
     NS_PRECONDITION(aComparator, "must have a comparator");
   }
 
   nsIAtom*                 mPseudoTag;
   nsICSSPseudoComparator*  mComparator;
 };
 #endif
 
 struct StateRuleProcessorData : public RuleProcessorData {
   StateRuleProcessorData(nsPresContext* aPresContext,
-                         nsIContent* aContent,
+                         mozilla::dom::Element* aElement,
                          PRInt32 aStateMask)
-    : RuleProcessorData(aPresContext, aContent, nsnull),
+    : RuleProcessorData(aPresContext, aElement, nsnull),
       mStateMask(aStateMask)
   {
     NS_PRECONDITION(aPresContext, "null pointer");
   }
   const PRInt32 mStateMask; // |HasStateDependentStyle| for which state(s)?
                             //  Constants defined in nsIEventStateManager.h .
 };
 
 struct AttributeRuleProcessorData : public RuleProcessorData {
   AttributeRuleProcessorData(nsPresContext* aPresContext,
-                             nsIContent* aContent,
+                             mozilla::dom::Element* aElement,
                              nsIAtom* aAttribute,
                              PRInt32 aModType,
                              PRBool aAttrHasChanged)
-    : RuleProcessorData(aPresContext, aContent, nsnull),
+    : RuleProcessorData(aPresContext, aElement, nsnull),
       mAttribute(aAttribute),
       mModType(aModType),
       mAttrHasChanged(aAttrHasChanged)
   {
     NS_PRECONDITION(aPresContext, "null pointer");
   }
   nsIAtom* mAttribute; // |HasAttributeDependentStyle| for which attribute?
   PRInt32 mModType;    // The type of modification (see nsIDOMMutationEvent).
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -731,17 +731,17 @@ nsStyleSet::WalkRuleProcessors(nsIStyleR
                   SheetCount(eHTMLPresHintSheet) == 0,
                   "Can't have both types of preshint sheets at once!");
   
   if (mRuleProcessors[eAgentSheet])
     (*aFunc)(mRuleProcessors[eAgentSheet], aData);
   if (mRuleProcessors[ePresHintSheet])
     (*aFunc)(mRuleProcessors[ePresHintSheet], aData);
 
-  PRBool skipUserStyles = aData->mContent->IsInNativeAnonymousSubtree();
+  PRBool skipUserStyles = aData->mElement->IsInNativeAnonymousSubtree();
   if (!skipUserStyles && mRuleProcessors[eUserSheet]) // NOTE: different
     (*aFunc)(mRuleProcessors[eUserSheet], aData);
 
   if (mRuleProcessors[eHTMLPresHintSheet])
     (*aFunc)(mRuleProcessors[eHTMLPresHintSheet], aData);
   
   PRBool cutOffInheritance = PR_FALSE;
   if (mBindingManager) {
@@ -1176,18 +1176,18 @@ nsStyleSet::ReparentStyleContext(nsStyle
                     // bogus values for aIsLink and aIsVisitedLink that
                     // we know will make GetContext do the right thing.
                     PR_TRUE, aStyleContext->RelevantLinkVisited(),
                     pseudoTag, pseudoType);
 }
 
 struct StatefulData : public StateRuleProcessorData {
   StatefulData(nsPresContext* aPresContext,
-               nsIContent* aContent, PRInt32 aStateMask)
-    : StateRuleProcessorData(aPresContext, aContent, aStateMask),
+               Element* aElement, PRInt32 aStateMask)
+    : StateRuleProcessorData(aPresContext, aElement, aStateMask),
       mHint(nsRestyleHint(0))
   {}
   nsRestyleHint   mHint;
 };
 
 static PRBool SheetHasDocumentStateStyle(nsIStyleRuleProcessor* aProcessor,
                                          void *aData)
 {
@@ -1236,19 +1236,19 @@ nsStyleSet::HasStateDependentStyle(nsPre
     result = data.mHint;
   }
 
   return result;
 }
 
 struct AttributeData : public AttributeRuleProcessorData {
   AttributeData(nsPresContext* aPresContext,
-                nsIContent* aContent, nsIAtom* aAttribute, PRInt32 aModType,
+                Element* aElement, nsIAtom* aAttribute, PRInt32 aModType,
                 PRBool aAttrHasChanged)
-    : AttributeRuleProcessorData(aPresContext, aContent, aAttribute, aModType,
+    : AttributeRuleProcessorData(aPresContext, aElement, aAttribute, aModType,
                                  aAttrHasChanged),
       mHint(nsRestyleHint(0))
   {}
   nsRestyleHint   mHint;
 }; 
 
 static PRBool
 SheetHasAttributeStyle(nsIStyleRuleProcessor* aProcessor, void *aData)
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -811,36 +811,32 @@ NS_IMPL_ISUPPORTS1(nsTransitionManager, 
 /*
  * nsIStyleRuleProcessor implementation
  */
 
 nsresult
 nsTransitionManager::WalkTransitionRule(RuleProcessorData* aData,
                                         nsCSSPseudoElements::Type aPseudoType)
 {
-  if (!aData->mContent) {
-    return NS_OK;
-  }
-
   ElementTransitions *et =
-    GetElementTransitions(aData->mContent, aPseudoType, PR_FALSE);
+    GetElementTransitions(aData->mElement, aPseudoType, PR_FALSE);
   if (!et) {
     return NS_OK;
   }
 
   if (!aData->mPresContext->IsProcessingAnimationStyleChange()) {
     // If we're processing a normal style change rather than one from
     // animation, don't add the transition rule.  This allows us to
     // compute the new style value rather than having the transition
     // override it, so that we can start transitioning differently.
 
     // We need to immediately restyle with animation
     // after doing this.
     if (et) {
-      mPresContext->PresShell()->RestyleForAnimation(aData->mContent);
+      mPresContext->PresShell()->RestyleForAnimation(aData->mElement);
     }
     return NS_OK;
   }
 
   if (!et->EnsureStyleRuleFor(
         aData->mPresContext->RefreshDriver()->MostRecentRefresh())) {
     return NS_ERROR_OUT_OF_MEMORY;
   }