Bug 1382568: Use range-based for loop instead of array indexing in IsOrHasAncestorWithDisplayNone. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 30 Jul 2017 04:13:48 +0200
changeset 420549 874935d5a813753c2c2a6358415e0d99d21fa953
parent 420548 6c55b6e879d3d2b89f4b1e5378dd5d93ca463340
child 420550 30e92e587ea6f23e779bc812cccacb377c8090b6
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1382568
milestone56.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 1382568: Use range-based for loop instead of array indexing in IsOrHasAncestorWithDisplayNone. r=heycam MozReview-Commit-ID: H8Gbh523eoO
dom/html/nsGenericHTMLElement.cpp
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -2987,24 +2987,23 @@ IsOrHasAncestorWithDisplayNone(Element* 
     }
     elementsToCheck.AppendElement(e);
   }
 
   if (elementsToCheck.IsEmpty()) {
     return false;
   }
 
-  // XXXbholley: This could be done more directly with Servo's style system.
   StyleSetHandle styleSet = aPresShell->StyleSet();
   RefPtr<nsStyleContext> sc;
-  for (int32_t i = elementsToCheck.Length() - 1; i >= 0; --i) {
+  for (auto* element : Reversed(elementsToCheck)) {
     if (sc) {
-      sc = styleSet->ResolveStyleFor(elementsToCheck[i], sc, LazyComputeBehavior::Assert);
+      sc = styleSet->ResolveStyleFor(element, sc, LazyComputeBehavior::Assert);
     } else {
-      sc = nsComputedDOMStyle::GetStyleContextNoFlush(elementsToCheck[i],
+      sc = nsComputedDOMStyle::GetStyleContextNoFlush(element,
                                                       nullptr, aPresShell);
     }
     if (sc->StyleDisplay()->mDisplay == StyleDisplay::None) {
       return true;
     }
   }
 
   return false;