Commit bbce3cdc authored by Rakina Zata Amni's avatar Rakina Zata Amni Committed by Commit Bot

Change DCHECK in UpdateStyleAndLayoutTreeForNode to check !InStyleRecalc()

UpdateStyleAndLayoutTreeForNode should not be called from within a
normal lifecycle update because it also updates things in display locked
subtrees - it should only be called for forced style calculations.

However, scripts that do forced style calculations might actually run
from within a lifecycle update (for example, in a ResizeObserver callback),
hitting the DCHECK. As there's no easy way to differentiate the cases,
we're changing DCHECK in this CL to just check that we're not in style
recalc phase of the lifecycle update.

Bug: 963062
Change-Id: Ib3692960b008043057b27180f57447966e6127e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1614337Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarvmpstr <vmpstr@chromium.org>
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660729}
parent 8dde0a59
......@@ -2468,13 +2468,8 @@ void Document::UpdateStyleAndLayoutTreeForNode(const Node* node) {
DCHECK_EQ(node->ownerDocument(), this);
return;
}
DCHECK(node->GetDocument().GetPage());
DCHECK(!node->GetDocument()
.GetPage()
->Animator()
.UpdatingLayoutAndStyleForPainting())
<< "UpdateStyleAndLayoutTreeForNode called from within a lifecycle "
"update";
DCHECK(!InStyleRecalc())
<< "UpdateStyleAndLayoutTreeForNode called from within style recalc";
if (!NeedsLayoutTreeUpdateForNodeIncludingDisplayLocked(*node))
return;
......
......@@ -40,9 +40,6 @@ class CORE_EXPORT PageAnimator final : public GarbageCollected<PageAnimator> {
void UpdateAllLifecyclePhasesExceptPaint(LocalFrame& root_frame);
void UpdateLifecycleToLayoutClean(LocalFrame& root_frame);
AnimationClock& Clock() { return animation_clock_; }
bool UpdatingLayoutAndStyleForPainting() {
return updating_layout_and_style_for_painting_;
}
private:
Member<Page> page_;
......
<!doctype HTML>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<div id="sizeChangingDiv"></div>
<script>
test(() => {
document.body.offsetTop;
const resizeObserver = new ResizeObserver(() => assert_equals(getComputedStyle(document.body).height, "123px"));
resizeObserver.observe(sizeChangingDiv);
sizeChangingDiv.style.height = "123px";
}, "getComputedStyle gets up-to-date style when called from within a ResizeObserver callback");
</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