diff options
author | FranklinDM <mrmineshafter17@gmail.com> | 2023-02-27 12:56:07 +0800 |
---|---|---|
committer | FranklinDM <mrmineshafter17@gmail.com> | 2023-02-27 13:15:43 +0800 |
commit | 679e53697c49507510f238737f30658f4a008a89 (patch) | |
tree | 08d837145e68d056f678f189818bbd2735a12c82 | |
parent | 047e44d5c731b972b858160ee4f27020c60cfc62 (diff) | |
download | uxp-679e53697c49507510f238737f30658f4a008a89.tar.gz |
Issue #1375 - Follow-up: Get the insertion point right when reconstructing direct children of a shadow root
This should've been changed alongside bug 1404789 when it landed.
-rw-r--r-- | layout/base/nsCSSFrameConstructor.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 91fa4ec778..1545e1d331 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -7345,7 +7345,9 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer, GetAbsoluteContainingBlock(parentFrame, FIXED_POS), GetAbsoluteContainingBlock(parentFrame, ABS_POS), containingBlock); - state.mTreeMatchContext.InitAncestors(aContainer->AsElement()); + // We use GetParentElementCrossingShadowRoot to handle the case where + // aContainer is a ShadowRoot. + state.mTreeMatchContext.InitAncestors(aFirstNewContent->GetParentElementCrossingShadowRoot()); nsIAtom* frameType = parentFrame->GetType(); @@ -7672,10 +7674,13 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer, // The xbl:children element won't have a frame, but default content can have the children as // a parent. While its uncommon to change the structure of the default content itself, a label, // for example, can be reframed by having its value attribute set or removed. - if (!parentFrame && !aContainer->IsActiveChildrenElement()) { + if (!parentFrame && + !(aContainer->IsActiveChildrenElement() || ShadowRoot::FromNode(aContainer))) { return; } + MOZ_ASSERT_IF(ShadowRoot::FromNode(aContainer), !parentFrame); + // Otherwise, we've got parent content. Find its frame. NS_ASSERTION(!parentFrame || parentFrame->GetContent() == aContainer || GetDisplayContentsStyleFor(aContainer), "New XBL code is possibly wrong!"); @@ -7784,9 +7789,9 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer, GetAbsoluteContainingBlock(insertion.mParentFrame, ABS_POS), GetFloatContainingBlock(insertion.mParentFrame), do_AddRef(aFrameState)); - state.mTreeMatchContext.InitAncestors(aContainer ? - aContainer->AsElement() : - nullptr); + // We use GetParentElementCrossingShadowRoot to handle the case where + // aContainer is a ShadowRoot. + state.mTreeMatchContext.InitAncestors(aStartChild->GetParentElementCrossingShadowRoot()); // Recover state for the containing block - we need to know if // it has :first-letter or :first-line style applied to it. The @@ -8965,8 +8970,11 @@ nsCSSFrameConstructor::GetInsertionPoint(nsIContent* aContainer, return InsertionPoint(GetContentInsertionFrameFor(aContainer), aContainer); } - if (nsContentUtils::HasDistributedChildren(aContainer)) { - // The container distributes nodes, use the frame of the flattened tree parent. + if (nsContentUtils::HasDistributedChildren(aContainer) || + ShadowRoot::FromNode(aContainer)) { + // The container distributes nodes or is a shadow root, use the frame of + // the flattened tree parent. + // // It may be the case that the node is distributed but not matched to any // insertion points, so there is no flattened parent. nsIContent* flattenedParent = aChild->GetFlattenedTreeParent(); |