Bug 1427635: Fix DoCompareTreePosition frame tree version with null aCommonAncestor. r=xidorn
☠☠ backed out by 2b0691e2e31b ☠ ☠
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 22 Dec 2017 11:01:19 +0100
changeset 449317 9a95b205f3e8df9cd967c3f8a0fae52a54dac6a9
parent 449316 b8656e137157fb746b333a53db06def134d4b108
child 449318 fa855df2e888bb6edbed237d7a6b78ab6476c96b
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1427635
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 1427635: Fix DoCompareTreePosition frame tree version with null aCommonAncestor. r=xidorn It doesn't fill the ancestors of the first frame if aCommonAncestor is null, which means that we get garbage afterwards. MozReview-Commit-ID: G85dv7KM1Xd
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1908,18 +1908,21 @@ nsLayoutUtils::DoCompareTreePosition(nsI
 
   nsPresContext* presContext = aFrame1->PresContext();
   if (presContext != aFrame2->PresContext()) {
     NS_ERROR("no common ancestor at all, different documents");
     return 0;
   }
 
   AutoTArray<nsIFrame*,20> frame1Ancestors;
-  if (aCommonAncestor &&
-      !FillAncestors(aFrame1, aCommonAncestor, &frame1Ancestors)) {
+  // Note that the order of the condition is important. We need to fill the
+  // ancestors even if aCommonAncestor is null, otherwise the code below makes
+  // no sense.
+  if (!FillAncestors(aFrame1, aCommonAncestor, &frame1Ancestors) &&
+      aCommonAncestor) {
     // We reached the root of the frame tree ... if aCommonAncestor was set,
     // it is wrong
     return DoCompareTreePosition(aFrame1, aFrame2,
                                  aIf1Ancestor, aIf2Ancestor, nullptr);
   }
 
   int32_t last1 = int32_t(frame1Ancestors.Length()) - 1;
   int32_t last2 = int32_t(aFrame2Ancestors.Length()) - 1;