Index: third_party/WebKit/Source/core/dom/Node.cpp |
diff --git a/third_party/WebKit/Source/core/dom/Node.cpp b/third_party/WebKit/Source/core/dom/Node.cpp |
index 7d8415f0b1a934c007004df3e9fc46dcb54354ce..75a14c126049e00ced0923749a439772f8c35f52 100644 |
--- a/third_party/WebKit/Source/core/dom/Node.cpp |
+++ b/third_party/WebKit/Source/core/dom/Node.cpp |
@@ -769,9 +769,27 @@ void Node::MarkAncestorsWithChildNeedsStyleRecalc() { |
GetDocument().ScheduleLayoutTreeUpdateIfNeeded(); |
} |
+static ContainerNode* GetReattachParent(Node& node) { |
+ if (node.IsPseudoElement()) |
+ return node.ParentOrShadowHostNode(); |
+ if (node.IsChildOfV1ShadowHost()) { |
+ if (HTMLSlotElement* slot = node.FinalDestinationSlot()) |
+ return slot; |
+ } |
+ if (node.IsInV0ShadowTree() || node.IsChildOfV0ShadowHost()) { |
+ if (ShadowWhereNodeCanBeDistributedForV0(node)) { |
+ if (InsertionPoint* insertion_point = |
+ const_cast<InsertionPoint*>(ResolveReprojection(&node))) { |
+ return insertion_point; |
+ } |
+ } |
+ } |
+ return node.ParentOrShadowHostNode(); |
+} |
+ |
void Node::MarkAncestorsWithChildNeedsReattachLayoutTree() { |
- for (ContainerNode* p = ParentOrShadowHostNode(); |
- p && !p->ChildNeedsReattachLayoutTree(); p = p->ParentOrShadowHostNode()) |
+ for (ContainerNode* p = GetReattachParent(*this); |
+ p && !p->ChildNeedsReattachLayoutTree(); p = GetReattachParent(*p)) |
p->SetChildNeedsReattachLayoutTree(); |
} |
@@ -2391,6 +2409,17 @@ HTMLSlotElement* Node::AssignedSlot() const { |
return nullptr; |
} |
+HTMLSlotElement* Node::FinalDestinationSlot() const { |
+ HTMLSlotElement* slot = AssignedSlot(); |
+ if (!slot) |
+ return nullptr; |
+ for (HTMLSlotElement* next = slot->AssignedSlot(); next; |
+ next = next->AssignedSlot()) { |
+ slot = next; |
+ } |
+ return slot; |
+} |
+ |
HTMLSlotElement* Node::assignedSlotForBinding() { |
// assignedSlot doesn't need to call updateDistribution(). |
if (ShadowRoot* root = V1ShadowRootOfParent()) { |