Fix DoCompareTreePosition frame tree version with null aCommonAncestor. draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 22 Dec 2017 11:01:19 +0100
changeset 715215 626482dbde596a24362612914cb7e13410ea4aef
parent 715214 4fea89670796e374a026a96f0a4ea80780705739
child 715216 98b7e598feafa0938ef262463d86f9aa01ec9c2d
push id94095
push userbmo:emilio@crisal.io
push dateWed, 03 Jan 2018 05:45:02 +0000
milestone59.0a1
Fix DoCompareTreePosition frame tree version with null aCommonAncestor. It doesn't fill the ancestors of the first frame if aCommonAncestor is null, which is wrong. MozReview-Commit-ID: G85dv7KM1Xd
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1908,18 +1908,18 @@ 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)) {
+  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;