Commit 6a3ad3f0 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Make sure removed pseudo elements are not marked for reattachment.

We do not modify the DOM during style recalc, but we may remove pseudo
elements if they are no longer rendered after style recalc. The recalc
code marked the pseudo elements for reattachment before removing them
which meant the layout_tree_rebuild_root_ in StyleEngine pointed to a
disconnected pseudo element.

Avoid the marking if we are about to remove the pseudo element.

This is done as part of the preparation for flat tree style recalc.

Bug: 972752
Change-Id: Icb472bf8073e518a456c86bceb1a1ddbf48f9c99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1728653Reviewed-by: default avatarAnders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682665}
parent 6cde9a47
...@@ -11,6 +11,7 @@ namespace blink { ...@@ -11,6 +11,7 @@ namespace blink {
Element& LayoutTreeRebuildRoot::RootElement() const { Element& LayoutTreeRebuildRoot::RootElement() const {
Node* root_node = GetRootNode(); Node* root_node = GetRootNode();
DCHECK(root_node); DCHECK(root_node);
DCHECK(root_node->isConnected());
// We need to start from the closest non-dirty ancestor which has a // We need to start from the closest non-dirty ancestor which has a
// LayoutObject to make WhitespaceAttacher work correctly because text node // LayoutObject to make WhitespaceAttacher work correctly because text node
// siblings of nodes being re-attached needs to be traversed to re-evaluate // siblings of nodes being re-attached needs to be traversed to re-evaluate
......
...@@ -2661,7 +2661,8 @@ StyleRecalcChange Element::RecalcOwnStyle(const StyleRecalcChange change) { ...@@ -2661,7 +2661,8 @@ StyleRecalcChange Element::RecalcOwnStyle(const StyleRecalcChange change) {
} }
if (child_change.ReattachLayoutTree()) { if (child_change.ReattachLayoutTree()) {
if (old_style || new_style) // Don't mark pseudo element which is about to be removed for re-attachment.
if (new_style || (old_style && !IsPseudoElement()))
SetNeedsReattachLayoutTree(); SetNeedsReattachLayoutTree();
return child_change; return child_change;
} }
......
...@@ -1288,6 +1288,7 @@ void Node::SetNeedsReattachLayoutTree() { ...@@ -1288,6 +1288,7 @@ void Node::SetNeedsReattachLayoutTree() {
DCHECK(GetDocument().InStyleRecalc()); DCHECK(GetDocument().InStyleRecalc());
DCHECK(!GetDocument().ChildNeedsDistributionRecalc()); DCHECK(!GetDocument().ChildNeedsDistributionRecalc());
DCHECK(IsElementNode() || IsTextNode()); DCHECK(IsElementNode() || IsTextNode());
DCHECK(InActiveDocument());
SetFlag(kNeedsReattachLayoutTree); SetFlag(kNeedsReattachLayoutTree);
MarkAncestorsWithChildNeedsReattachLayoutTree(); MarkAncestorsWithChildNeedsReattachLayoutTree();
} }
......
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