Commit 65eb6a29 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Clear scroll anchors on change of the overflow-anchor property.

In such cases, the chosen anchor may change arbitrarily.

Bug: 924256

Change-Id: I3f304450c59bc3e27b93089469d6fbee68a166e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2008617Reviewed-by: default avatarNick Burris <nburris@chromium.org>
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734586}
parent 7a00808f
...@@ -2382,6 +2382,22 @@ void LayoutObject::SetScrollAnchorDisablingStyleChangedOnAncestor() { ...@@ -2382,6 +2382,22 @@ void LayoutObject::SetScrollAnchorDisablingStyleChangedOnAncestor() {
} }
} }
static void ClearAncestorScrollAnchors(LayoutObject* layout_object) {
PaintLayer* layer = nullptr;
if (LayoutObject* parent = layout_object->Parent())
layer = parent->EnclosingLayer();
while (layer) {
if (PaintLayerScrollableArea* scrollable_area =
layer->GetScrollableArea()) {
ScrollAnchor* anchor = scrollable_area->GetScrollAnchor();
DCHECK(anchor);
anchor->Clear();
}
layer = layer->Parent();
}
}
void LayoutObject::StyleDidChange(StyleDifference diff, void LayoutObject::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) { const ComputedStyle* old_style) {
// First assume the outline will be affected. It may be updated when we know // First assume the outline will be affected. It may be updated when we know
...@@ -2449,6 +2465,10 @@ void LayoutObject::StyleDidChange(StyleDifference diff, ...@@ -2449,6 +2465,10 @@ void LayoutObject::StyleDidChange(StyleDifference diff,
AddSubtreePaintPropertyUpdateReason( AddSubtreePaintPropertyUpdateReason(
SubtreePaintPropertyUpdateReason::kTransformStyleChanged); SubtreePaintPropertyUpdateReason::kTransformStyleChanged);
} }
if (old_style && old_style->OverflowAnchor() != StyleRef().OverflowAnchor()) {
ClearAncestorScrollAnchors(this);
}
} }
void LayoutObject::ApplyPseudoElementStyleChanges( void LayoutObject::ApplyPseudoElementStyleChanges(
......
This is a testharness.js-based test.
FAIL Dynamically styling 'overflow-anchor: none' on the anchor node should prevent scroll anchoring assert_equals: expected 150 but got 200
Harness: the test ran to completion.
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