Bug 1425440 - Get rid of GetChildAt_Deprecated in nsCSSRuleProcessor, r=catalinb
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 12 Jan 2018 22:24:14 +0100
changeset 453452 0fa20efa446906e82545076eb72c66a18ae1ed43
parent 453451 4ed959e7652263aa2a57d582aed2460b4bdaab7c
child 453453 4806f68141637e47411ad6d202b6ce9b8cd4d910
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscatalinb
bugs1425440
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1425440 - Get rid of GetChildAt_Deprecated in nsCSSRuleProcessor, r=catalinb
layout/style/nsCSSRuleProcessor.cpp
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -1347,26 +1347,25 @@ edgeOfTypeMatches(Element* aElement, Tre
 }
 
 static inline bool
 checkGenericEmptyMatches(Element* aElement,
                          TreeMatchContext& aTreeMatchContext,
                          bool isWhitespaceSignificant)
 {
   nsIContent *child = nullptr;
-  int32_t index = -1;
 
   if (aTreeMatchContext.mForStyling)
     aElement->SetFlags(NODE_HAS_EMPTY_SELECTOR);
 
-  do {
-    child = aElement->GetChildAt_Deprecated(++index);
-    // stop at first non-comment (and non-whitespace for
-    // :-moz-only-whitespace) node
-  } while (child && !IsSignificantChild(child, true, isWhitespaceSignificant));
+  // stop at first non-comment (and non-whitespace for :-moz-only-whitespace)
+  // node
+  for (child = aElement->GetFirstChild();
+       child && !IsSignificantChild(child, true, isWhitespaceSignificant);
+       child = child->GetNextSibling());
   return (child == nullptr);
 }
 
 static const EventStates sPseudoClassStates[] = {
 #define CSS_PSEUDO_CLASS(_name, _value, _flags, _pref) \
   EventStates(),
 #define CSS_STATE_PSEUDO_CLASS(_name, _value, _flags, _pref, _states) \
   _states,
@@ -1625,22 +1624,20 @@ static bool SelectorMatches(Element* aEl
     case CSSPseudoClassType::firstNode:
       {
         nsIContent *firstNode = nullptr;
         nsIContent *parent = aElement->GetParent();
         if (parent) {
           if (aTreeMatchContext.mForStyling)
             parent->SetFlags(NODE_HAS_EDGE_CHILD_SELECTOR);
 
-          int32_t index = -1;
-          do {
-            firstNode = parent->GetChildAt_Deprecated(++index);
-            // stop at first non-comment and non-whitespace node
-          } while (firstNode &&
-                    !IsSignificantChild(firstNode, true, false));
+          // stop at first non-comment and non-whitespace node
+          for (firstNode = parent->GetFirstChild();
+               firstNode && !IsSignificantChild(firstNode, true, false);
+               firstNode = firstNode->GetNextSibling());
         }
         if (aElement != firstNode) {
           return false;
         }
       }
       break;
 
     case CSSPseudoClassType::lastChild:
@@ -1652,22 +1649,20 @@ static bool SelectorMatches(Element* aEl
     case CSSPseudoClassType::lastNode:
       {
         nsIContent *lastNode = nullptr;
         nsIContent *parent = aElement->GetParent();
         if (parent) {
           if (aTreeMatchContext.mForStyling)
             parent->SetFlags(NODE_HAS_EDGE_CHILD_SELECTOR);
 
-          uint32_t index = parent->GetChildCount();
-          do {
-            lastNode = parent->GetChildAt_Deprecated(--index);
-            // stop at first non-comment and non-whitespace node
-          } while (lastNode &&
-                    !IsSignificantChild(lastNode, true, false));
+          // stop at first non-comment and non-whitespace node
+          for (lastNode = parent->GetLastChild();
+               lastNode && !IsSignificantChild(lastNode, true, false);
+               lastNode = lastNode->GetPreviousSibling());
         }
         if (aElement != lastNode) {
           return false;
         }
       }
       break;
 
     case CSSPseudoClassType::onlyChild: