Commit ad58e1a7 authored by Kevin McNee's avatar Kevin McNee Committed by Commit Bot

Workaround DCHECK when propagating inertness to child frames.

When HTMLDialogElement::RemovedFrom updates inertness, we may
hit the !node.NeedsDistributionRecalc() DCHECK in FlatTreeTraversal.
Workaround this by calling UpdateDistributionForFlatTreeTraversal.

We shouldn't UpdateDistribution during DOM mutation, but Shadow DOM
v0 will be removed, at which point the UpdateDistribution can be
removed.

Bug: 895511
Change-Id: If8fb3a93acbfa54e819b36fd647e56357ab9fe6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1281223
Commit-Queue: Kevin McNee <mcnee@chromium.org>
Reviewed-by: default avatarHayato Ito <hayato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700255}
parent c9f4dac6
...@@ -180,6 +180,13 @@ void HTMLDialogElement::showModal(ExceptionState& exception_state) { ...@@ -180,6 +180,13 @@ void HTMLDialogElement::showModal(ExceptionState& exception_state) {
void HTMLDialogElement::RemovedFrom(ContainerNode& insertion_point) { void HTMLDialogElement::RemovedFrom(ContainerNode& insertion_point) {
HTMLElement::RemovedFrom(insertion_point); HTMLElement::RemovedFrom(insertion_point);
SetNotCentered(); SetNotCentered();
// TODO(671907): Calling UpdateDistributionForFlatTreeTraversal here is a
// workaround for https://crbug.com/895511. This shouldn't be done during DOM
// mutation. However, Shadow DOM v0 will be removed, at which point this call
// can be removed.
GetDocument().UpdateDistributionForFlatTreeTraversal();
InertSubtreesChanged(GetDocument()); InertSubtreesChanged(GetDocument());
} }
......
<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<!-- The presence of a frame causes the crash in https://crbug.com/895511 -->
<iframe></iframe>
<div id="dialog-host"></div>
<script>
test(function() {
var fragment = document.createDocumentFragment();
var dialog = document.createElement('dialog');
fragment.appendChild(dialog);
var dialogHost = document.getElementById('dialog-host');
var root = dialogHost.createShadowRoot();
root.appendChild(fragment);
// This test passes if it does not crash.
}, 'Append fragment with dialog to shadow root');
</script>
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