Skip to content

Commit

Permalink
Corrected DCHECK for allowing marking style dirty
Browse files Browse the repository at this point in the history
As long as we have legacy layout in combination with container queries,
we may end up doing a resume of a skipped style recalc during layout
tree rebuild. Additionally, we have a scope allowing marking style dirty
from style recalc for a couple of exceptional cases. When these happen
at the same time we may mark style dirty from within layout tree
rebuild.

Adjust DCHECK to account for that.

Bug: 1362391
Change-Id: I30c507607938040a4fe8948e731bb71275b479c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3901994
Auto-Submit: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1048013}
  • Loading branch information
lilles authored and Chromium LUCI CQ committed Sep 16, 2022
1 parent 53bc1a0 commit 93e7ef7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions third_party/blink/renderer/core/css/style_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3056,6 +3056,13 @@ bool StyleEngine::MarkReattachAllowed() const {
allow_mark_for_reattach_from_rebuild_layout_tree_;
}

bool StyleEngine::MarkStyleDirtyAllowed() const {
if (GetDocument().InStyleRecalc() || InContainerQueryStyleRecalc()) {
return allow_mark_style_dirty_from_recalc_;
}
return !InRebuildLayoutTree();
}

bool StyleEngine::SupportsDarkColorScheme() {
return (page_color_schemes_ &
static_cast<ColorSchemeFlags>(ColorSchemeFlag::kDark)) &&
Expand Down
1 change: 1 addition & 0 deletions third_party/blink/renderer/core/css/style_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ class CORE_EXPORT StyleEngine final : public GarbageCollected<StyleEngine>,
AncestorAnalysis AnalyzeAncestors(const Node&);

bool MarkReattachAllowed() const;
bool MarkStyleDirtyAllowed() const;

CSSFontSelector* GetFontSelector() { return font_selector_; }

Expand Down
2 changes: 1 addition & 1 deletion third_party/blink/renderer/core/dom/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ void Node::SetNeedsReattachLayoutTree() {

void Node::SetNeedsStyleRecalc(StyleChangeType change_type,
const StyleChangeReasonForTracing& reason) {
DCHECK(!GetDocument().GetStyleEngine().InRebuildLayoutTree());
DCHECK(GetDocument().GetStyleEngine().MarkStyleDirtyAllowed());
DCHECK(!GetDocument().InPostLifecycleSteps());
DCHECK(change_type != kNoStyleChange);
DCHECK(IsElementNode() || IsTextNode());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!doctype html>
<title>DCHECK failure for style recalc from layout tree rebuild</title>
<link rel="help" href="https://crbug.com/1362391">
<div style="display:table-column-group">
<div style="container-type:size">
<image title="crash"></image>
</div>
</div>

0 comments on commit 93e7ef7

Please sign in to comment.