Bug 1428276 - Make ExpectedOwnerForChild deal with abs.pos. anon boxes. draft
authorKuoE0 <kuoe0.tw@gmail.com>
Fri, 05 Jan 2018 16:26:01 +0800
changeset 717061 3b45eac33cc071d2bd969baca3103ab369a30a65
parent 715543 7d81f423c7ff33c6be38b51e50bd8934e0b50dd9
child 745139 46b594c3f491e54240ba2b5822f794accd6ba5bb
push id94549
push userbmo:kuoe0@mozilla.com
push dateMon, 08 Jan 2018 06:33:51 +0000
bugs1428276
milestone59.0a1
Bug 1428276 - Make ExpectedOwnerForChild deal with abs.pos. anon boxes. For an OOF frame, the parent frame that's associated with our parent style context is the *placeholder's* parent -- not the OOF frame's parent. MozReview-Commit-ID: CUSBkWDqxWz
layout/base/ServoRestyleManager.cpp
layout/generic/nsIFrame.h
layout/generic/nsIFrameInlines.h
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -102,17 +102,19 @@ ExpectedOwnerForChild(const nsIFrame& aF
   while (parent && (IsAnonBox(*parent) || parent->IsLineFrame())) {
     auto* pseudo = parent->StyleContext()->GetPseudo();
     if (pseudo == nsCSSAnonBoxes::tableWrapper) {
       const nsIFrame* tableFrame = parent->PrincipalChildList().FirstChild();
       MOZ_ASSERT(tableFrame->IsTableFrame());
       // Handle :-moz-table and :-moz-inline-table.
       parent = IsAnonBox(*tableFrame) ? parent->GetParent() : tableFrame;
     } else {
-      parent = parent->GetParent();
+      // We get the in-flow parent here so that we can handle the OOF anonymous
+      // boxed to get the correct parent.
+      parent = parent->GetInFlowParent();
     }
     parent = FirstContinuationOrPartOfIBSplit(parent);
   }
 
   return parent;
 }
 
 void
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -883,17 +883,17 @@ public:
    * Accessor functions for geometric parent.
    */
   nsContainerFrame* GetParent() const { return mParent; }
 
   /**
    * Gets the parent of a frame, using the parent of the placeholder for
    * out-of-flow frames.
    */
-  inline nsContainerFrame* GetInFlowParent();
+  inline nsContainerFrame* GetInFlowParent() const;
 
   /**
    * Gets the primary frame of the Content's flattened tree
    * parent, if one exists.
    */
   nsIFrame* GetFlattenedTreeParentPrimaryFrame() const;
 
   /**
--- a/layout/generic/nsIFrameInlines.h
+++ b/layout/generic/nsIFrameInlines.h
@@ -165,17 +165,17 @@ nsIFrame::PropagateRootElementWritingMod
 {
   MOZ_ASSERT(IsCanvasFrame());
   for (auto f = this; f; f = f->GetParent()) {
     f->mWritingMode = aRootElemWM;
   }
 }
 
 nsContainerFrame*
-nsIFrame::GetInFlowParent()
+nsIFrame::GetInFlowParent() const
 {
   if (GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
     nsIFrame* ph = FirstContinuation()->GetProperty(nsIFrame::PlaceholderFrameProperty());
     return ph->GetParent();
   }
 
   return GetParent();
 }