Commit 1e64afb4 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Mark shadow host, not root, for style recalc.

For subtree recalc when scheduling sibling invalidations as descendant
invalidations on the ancestor, mark the shadow host instead of the
shadow root for style recalc. In preparation for flat tree style recalc
where we only want to consider elements and text nodes for style recalc.

Bug: 972752, 990743
Change-Id: I00921e298d50be2667e7b26b3149f4f1b72a2d57
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1831761Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701460}
parent a5749ed2
......@@ -103,28 +103,32 @@ void PendingInvalidations::ScheduleSiblingInvalidationsAsDescendants(
scheduling_parent.SetNeedsStyleInvalidation();
ContainerNode* subtree_root = &scheduling_parent;
if (RuntimeEnabledFeatures::FlatTreeStyleRecalcEnabled()) {
subtree_root = DynamicTo<Element>(scheduling_parent);
if (!subtree_root)
subtree_root = &To<ShadowRoot>(scheduling_parent).host();
}
for (auto& invalidation_set : invalidation_lists.siblings) {
if (invalidation_set->WholeSubtreeInvalid()) {
scheduling_parent.SetNeedsStyleRecalc(
DescendantInvalidationSet* descendants =
To<SiblingInvalidationSet>(*invalidation_set).SiblingDescendants();
if (invalidation_set->WholeSubtreeInvalid() ||
(descendants && descendants->WholeSubtreeInvalid())) {
subtree_root->SetNeedsStyleRecalc(
kSubtreeStyleChange, StyleChangeReasonForTracing::Create(
style_change_reason::kStyleInvalidator));
return;
}
if (invalidation_set->InvalidatesSelf() &&
!pending_invalidations.Descendants().Contains(invalidation_set))
!pending_invalidations.Descendants().Contains(invalidation_set)) {
pending_invalidations.Descendants().push_back(invalidation_set);
}
if (DescendantInvalidationSet* descendants =
To<SiblingInvalidationSet>(*invalidation_set)
.SiblingDescendants()) {
if (descendants->WholeSubtreeInvalid()) {
scheduling_parent.SetNeedsStyleRecalc(
kSubtreeStyleChange, StyleChangeReasonForTracing::Create(
style_change_reason::kStyleInvalidator));
return;
}
if (!pending_invalidations.Descendants().Contains(descendants))
pending_invalidations.Descendants().push_back(descendants);
if (descendants &&
!pending_invalidations.Descendants().Contains(descendants)) {
pending_invalidations.Descendants().push_back(descendants);
}
}
}
......
......@@ -1308,7 +1308,9 @@ void Node::SetNeedsStyleRecalc(StyleChangeType change_type,
// RescheduleSiblingInvalidationsAsDescendants() for WholeSubtreeInvalid(). We
// should instead mark the shadow host for subtree recalc when we traverse the
// flat tree (and skip non-slotted host children).
DCHECK(IsElementNode() || IsTextNode() || IsShadowRoot());
DCHECK(IsElementNode() || IsTextNode() ||
(IsShadowRoot() &&
!RuntimeEnabledFeatures::FlatTreeStyleRecalcEnabled()));
if (!InActiveDocument())
return;
......
......@@ -141,6 +141,8 @@ void ShadowRoot::setInnerHTML(const StringOrTrustedHTML& stringOrHtml,
void ShadowRoot::RecalcStyle(const StyleRecalcChange change) {
// ShadowRoot doesn't support custom callbacks.
DCHECK(!HasCustomStyleCallbacks());
DCHECK(!NeedsStyleRecalc() ||
!RuntimeEnabledFeatures::FlatTreeStyleRecalcEnabled());
StyleRecalcChange child_change = change;
if (GetStyleChangeType() == kSubtreeStyleChange)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment