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

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

Issue 2360833002: Only anchor along the block layout axis. (Closed)
Patch Set: 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/ScrollAnchor.cpp
diff --git a/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp b/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
index 9d2e8be33ef19e8f79183f4a864cb46a8ce643b5..a3b17b24fdb4b1fe468da31ef0c4e4aaa6e83f16 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
@@ -57,11 +57,10 @@ static LayoutBoxItem scrollerLayoutBoxItem(const ScrollableArea* scroller)
return LayoutBoxItem(scrollerLayoutBox(scroller));
}
-static Corner cornerFromCandidateRect(const LayoutObject* layoutObject)
+static Corner cornerToAnchor(const ScrollableArea* scroller)
{
- ASSERT(layoutObject);
- if (layoutObject->style()->isFlippedBlocksWritingMode()
- || !layoutObject->style()->isLeftToRightDirection())
+ const ComputedStyle* style = scrollerLayoutBox(scroller)->style();
+ if (style->isFlippedBlocksWritingMode() || !style->isLeftToRightDirection())
return Corner::TopRight;
return Corner::TopLeft;
}
@@ -160,7 +159,7 @@ ScrollAnchor::ExamineResult ScrollAnchor::examine(const LayoutObject* candidate)
if (occupiesSpace && visibleRect.intersects(candidateRect)) {
return ExamineResult(
visibleRect.contains(candidateRect) ? Return : Constrain,
- cornerFromCandidateRect(candidate));
+ cornerToAnchor(m_scroller));
} else {
return ExamineResult(Skip);
}
@@ -218,7 +217,10 @@ void ScrollAnchor::save()
return;
m_saved = true;
DCHECK(m_scroller);
- if (m_scroller->scrollPosition() == IntPoint::zero()) {
+
+ ScrollbarOrientation blockLayoutAxis =
+ scrollerLayoutBox(m_scroller)->isHorizontalWritingMode() ? VerticalScrollbar : HorizontalScrollbar;
+ if (m_scroller->scrollPosition(blockLayoutAxis) == 0) {
clear();
return;
}
@@ -248,8 +250,15 @@ IntSize ScrollAnchor::computeAdjustment() const
// (For example, anchor moving from 2.4px -> 2.6px is really 2px -> 3px, so we
// should scroll by 1px instead of 0.2px.) This is true regardless of whether
// the ScrollableArea actually uses fractional scroll positions.
- return roundedIntSize(computeRelativeOffset(m_anchorObject, m_scroller, m_corner)) -
+ IntSize delta = roundedIntSize(computeRelativeOffset(m_anchorObject, m_scroller, m_corner)) -
roundedIntSize(m_savedRelativeOffset);
+
+ // Only adjust on the block layout axis.
+ if (scrollerLayoutBox(m_scroller)->isHorizontalWritingMode())
+ delta.setWidth(0);
+ else
+ delta.setHeight(0);
+ return delta;
}
void ScrollAnchor::restore()

Powered by Google App Engine
This is Rietveld 408576698