Commit e5234059 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[css-layout-api] Fix DCHECK with the custom layout and multicol.

There are probably larger changes that need to happen to ensure that
the custom-layout and multicol play nicely together, but this removes
a DCHECK crash for now.

Bug: 823074
Change-Id: I98f4a34bd0c35e8cd3d23501ca64f38b96be9e7d
Reviewed-on: https://chromium-review.googlesource.com/990780
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550148}
parent 7f657640
<!DOCTYPE html>
<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/">
<meta name="assert" content="This test checks that browser doesn't crash when the layout() function is used with multicol." />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/worklet-reftest.js"></script>
<style>
#test {
display: layout('test');
columns: 2;
}
</style>
<div id="test"></div>
<script>
promise_test(async function() {
await importWorklet(CSS.layoutWorklet, {url: 'support/layout-position-child-worklet.js'});
});
</script>
...@@ -52,20 +52,22 @@ void LayoutCustom::StyleDidChange(StyleDifference diff, ...@@ -52,20 +52,22 @@ void LayoutCustom::StyleDidChange(StyleDifference diff,
// We will also need to investigate reducing the properties which // We will also need to investigate reducing the properties which
// LayoutBlockFlow::StyleDidChange invalidates upon. (For example margins). // LayoutBlockFlow::StyleDidChange invalidates upon. (For example margins).
LayoutBlockFlow::StyleDidChange(diff, old_style);
LayoutWorklet* worklet = LayoutWorklet::From(*GetDocument().domWindow()); LayoutWorklet* worklet = LayoutWorklet::From(*GetDocument().domWindow());
const AtomicString& name = StyleRef().DisplayLayoutCustomName(); const AtomicString& name = StyleRef().DisplayLayoutCustomName();
state_ = state_ =
worklet->GetDocumentDefinitionMap()->Contains(name) ? kBlock : kUnloaded; worklet->GetDocumentDefinitionMap()->Contains(name) ? kBlock : kUnloaded;
// Make our children "block-level" before invoking StyleDidChange. As the
// current multi-col logic may invoke a call to AddChild, failing a DCHECK.
if (state_ != kUnloaded)
SetChildrenInline(false);
LayoutBlockFlow::StyleDidChange(diff, old_style);
// Register if we'll need to reattach the layout tree when a matching // Register if we'll need to reattach the layout tree when a matching
// "layout()" is registered. // "layout()" is registered.
if (state_ == kUnloaded) { if (state_ == kUnloaded)
worklet->AddPendingLayout(name, GetNode()); worklet->AddPendingLayout(name, GetNode());
} else {
SetChildrenInline(false);
}
} }
void LayoutCustom::UpdateBlockLayout(bool relayout_children) { void LayoutCustom::UpdateBlockLayout(bool relayout_children) {
......
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