Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(967)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutObject.cpp

Issue 2310223002: Disable scroll anchoring is an element within the scroll changes its in-flow state (Closed)
Patch Set: Fix presubmit Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutObject.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
index 37f163851d52e143dff84248748b9b67fc700f65..aec58916d2f20a8cd01cfc606bcba442100ffe5f 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
@@ -1712,6 +1712,24 @@ static inline bool areCursorsEqual(const ComputedStyle* a, const ComputedStyle*
return a->cursor() == b->cursor() && (a->cursors() == b->cursors() || areNonIdenticalCursorListsEqual(a, b));
}
+void LayoutObject::setScrollAnchorDisablingStyleChangedOnAncestor()
ojan 2016/09/06 23:36:36 It's not clear to me that this is sufficient for n
skobes 2016/09/07 00:23:06 I think the answer to this is "yes, but that's ok"
ymalik 2016/09/07 00:39:57 Yes, that case is covered, but another question is
skobes 2016/09/07 00:49:31 My gut feeling is we don't gain anything by suppre
ymalik 2016/09/07 18:13:22 Acknowledged.
+{
+ // Walk up the parent chain and find the first scrolling block to disable
+ // scroll anchoring on.
+ LayoutObject* object = this;
+ Element* viewportDefiningElement = document().viewportDefiningElement();
+ do {
+ object = object->parent();
+ if (LayoutBlock* block = toLayoutBlock(object)) {
+ bool hasScrollableOverflow = block->hasScrollableOverflowX() || block->hasScrollableOverflowY();
skobes 2016/09/07 00:02:11 I don't think we should use this since it depends
ymalik 2016/09/07 00:39:57 I agree that we shouldn't depend on layout during
ymalik 2016/09/07 18:13:22 Done.
+ if (hasScrollableOverflow || (block->node() == viewportDefiningElement && block->view()->frameView()->isScrollable())) {
+ block->setScrollAnchorDisablingStyleChanged(true);
+ return;
+ }
+ }
+ } while (object);
+}
+
void LayoutObject::styleDidChange(StyleDifference diff, const ComputedStyle* oldStyle)
{
if (s_affectsParentBlock)
@@ -1723,6 +1741,14 @@ void LayoutObject::styleDidChange(StyleDifference diff, const ComputedStyle* old
if (diff.needsFullLayout()) {
LayoutCounter::layoutObjectStyleChanged(*this, oldStyle, *m_style);
+ // If the in-flow state of an element is changed, disable scroll
+ // anchoring on the containing scroller.
+ if (oldStyle->position() != m_style->position()
+ && ((oldStyle->position() == StaticPosition || m_style->position() == StaticPosition)
ojan 2016/09/06 23:36:36 Why do you need to check for StaticPosition? That'
ymalik 2016/09/07 00:39:57 For reasons that I don't understand, StaticPositio
ojan 2016/09/07 00:56:44 Hmmm...I guess I'm misremembering how this code wo
ymalik 2016/09/07 18:13:22 You're totally right. This works.
+ || (oldStyle->hasInFlowPosition() && !m_style->hasInFlowPosition())
+ || (oldStyle->hasOutOfFlowPosition() && !m_style->hasOutOfFlowPosition())))
+ setScrollAnchorDisablingStyleChangedOnAncestor();
+
// If the object already needs layout, then setNeedsLayout won't do
// any work. But if the containing block has changed, then we may need
// to mark the new containing blocks for layout. The change that can
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.h ('k') | third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698