1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 13:58:49 +00:00

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.
This commit is contained in:
FranklinDM
2023-02-27 12:56:07 +08:00
committed by roytam1
parent 6a26ce3455
commit b40c87a59a
+15 -7
View File
@@ -7395,7 +7395,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();
@@ -7727,10 +7729,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!");
@@ -7839,9 +7844,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
@@ -9025,8 +9030,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();