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

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

Issue 2002623003: Exclude position:absolute elements when picking an anchor for ScrollAnchoring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: exclude only for non-zero top/left/bottom/right Created 4 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
diff --git a/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp b/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
index 63b69a4cdaa949962a24bf21fab031e9f84fe681..5ee004053fc454e3d4c96a34293a58db3d95846a 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
@@ -104,10 +104,25 @@ static LayoutPoint computeRelativeOffset(const LayoutObject* layoutObject, const
return cornerPointOfRect(relativeBounds(layoutObject, scroller), corner);
}
-static bool candidateMovesWithScroller(const LayoutObject* candidate, const ScrollableArea* scroller)
+static bool candidateMayMoveWithScroller(const LayoutObject* candidate, const ScrollableArea* scroller)
{
- if (candidate->style() && candidate->style()->hasViewportConstrainedPosition())
- return false;
+ if (const ComputedStyle* style = candidate->style()) {
+ if (style->hasViewportConstrainedPosition())
+ return false;
+
+ if (style->hasOutOfFlowPosition()) {
+ // Absolute positioned elements with non-zero scrollTop/Left/Bottom/
+ // Right can stick to the viewport.
+ if (!style->top().isZero())
skobes 2016/06/01 04:38:55 nit: this would be more concise with ||
+ return false;
+ if (!style->left().isZero())
+ return false;
+ if (!style->bottom().isZero())
+ return false;
+ if (!style->right().isZero())
+ return false;
+ }
+ }
bool skippedByContainerLookup = false;
candidate->container(scrollerLayoutBox(scroller), &skippedByContainerLookup);
@@ -122,7 +137,7 @@ ScrollAnchor::ExamineResult ScrollAnchor::examine(const LayoutObject* candidate)
if (!candidate->isText() && !candidate->isBox())
return ExamineResult(Skip);
- if (!candidateMovesWithScroller(candidate, m_scroller))
+ if (!candidateMayMoveWithScroller(candidate, m_scroller))
return ExamineResult(Skip);
LayoutRect candidateRect = relativeBounds(candidate, m_scroller);
@@ -188,7 +203,7 @@ void ScrollAnchor::save()
// We need to update m_lastAdjusted.m_savedRelativeOffset, since it is
// relative to the visible rect and the user may have scrolled since the
// last adjustment.
- if (!candidateMovesWithScroller(m_lastAdjusted.m_anchorObject, m_scroller)) {
+ if (!candidateMayMoveWithScroller(m_lastAdjusted.m_anchorObject, m_scroller)) {
m_lastAdjusted.clear();
} else if (m_lastAdjusted.m_anchorObject == m_current.m_anchorObject
&& m_lastAdjusted.m_corner == m_current.m_corner) {
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698