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
--- 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();
}