Commit d01ff4b4 authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

Counters: Only update ancestors if style boundary is crossed.

This patch is an optimization patch that ensures that we only update
ancestor counters if we have crossed a style containment boundary.

The update is required since otherwise counters and content fields
that are separated by a style boundary don't behave correctly (we
elide updating counters if there is no content present; and then we
stop updates when they cross a style boundary). However, this update
is only needed on the other side of the containment boundary (and indeed
if there is a style containment boundary).

R=chrishtr@chromium.org, futhark@chromium.org

Bug: 1112978
Change-Id: I19e2e2c6132f1203c90a1e86a32a748a81066bd2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2363252Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: vmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799231}
parent fd6ef652
......@@ -746,11 +746,16 @@ void LayoutCounter::LayoutObjectSubtreeAttached(LayoutObject* layout_object) {
for (LayoutObject* descendant = layout_object; descendant;
descendant = descendant->NextInPreOrder(layout_object))
UpdateCounters(*descendant);
bool crossed_boundary = false;
// Since we skipped counter updates if there were no counters, we might need
// to update parent counters that lie beyond the style containment boundary.
for (LayoutObject* parent = layout_object->Parent(); parent;
parent = parent->Parent())
UpdateCounters(*parent);
parent = parent->Parent()) {
crossed_boundary |= parent->ShouldApplyStyleContainment();
if (crossed_boundary)
UpdateCounters(*parent);
}
}
void LayoutCounter::LayoutObjectStyleChanged(LayoutObject& layout_object,
......
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