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

Unified Diff: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp

Issue 2387393003: Revert of Refactor ScrollableArea::setScrollPosition. (Closed)
Patch Set: Created 4 years, 2 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/paint/PaintLayerScrollableArea.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
index 3f89d3f1e5672e1be5a266bccba3a61b653a58b0..32054fb3d7af13061465e7b559e9ec93b3931750 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
@@ -114,10 +114,9 @@
// We save and restore only the scrollOffset as the other scroll values are recalculated.
Element* element = toElement(node);
m_scrollOffset = element->savedLayerScrollOffset();
- if (!m_scrollOffset.isZero()) {
+ if (!m_scrollOffset.isZero())
scrollAnimator().setCurrentPosition(
FloatPoint(m_scrollOffset.width(), m_scrollOffset.height()));
- }
element->setSavedLayerScrollOffset(IntSize());
}
updateResizerAreaSet();
@@ -149,10 +148,9 @@
if (!box().documentBeingDestroyed()) {
Node* node = box().node();
// FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283.
- if (node && node->isElementNode()) {
+ if (node && node->isElementNode())
toElement(node)->setSavedLayerScrollOffset(
flooredIntSize(m_scrollOffset));
- }
}
if (LocalFrame* frame = box().frame()) {
@@ -500,9 +498,8 @@
: 0;
}
- // TODO(szager): Handle fractional scroll offsets correctly.
return IntRect(
- IntPoint(flooredIntSize(adjustedScrollOffset())),
+ IntPoint(scrollXOffset(), scrollYOffset()),
IntSize(max(0, layer()->size().width() - verticalScrollbarWidth),
max(0, layer()->size().height() - horizontalScrollbarHeight)));
}
@@ -638,11 +635,17 @@
updateScrollOrigin();
}
-void PaintLayerScrollableArea::setScrollPositionUnconditionally(
- const DoublePoint& position,
+void PaintLayerScrollableArea::scrollToPosition(
+ const DoublePoint& scrollPosition,
+ ScrollOffsetClamping clamp,
+ ScrollBehavior scrollBehavior,
ScrollType scrollType) {
- cancelScrollAnimation();
- scrollPositionChanged(position, scrollType);
+ DoublePoint newScrollPosition = clamp == ScrollOffsetClamped
+ ? clampScrollPosition(scrollPosition)
+ : scrollPosition;
+ if (newScrollPosition != scrollPositionDouble())
+ ScrollableArea::setScrollPosition(newScrollPosition, scrollType,
+ scrollBehavior);
}
void PaintLayerScrollableArea::updateAfterLayout() {
@@ -803,13 +806,9 @@
if (shouldPerformScrollAnchoring())
m_scrollAnchor.restore();
- if (scrollOriginChanged()) {
- setScrollPositionUnconditionally(
- clampScrollPosition(scrollPositionDouble()));
- } else {
- ScrollableArea::setScrollPosition(scrollPositionDouble(),
- ProgrammaticScroll);
- }
+ DoublePoint clamped = clampScrollPosition(scrollPositionDouble());
+ if (clamped != scrollPositionDouble() || scrollOriginChanged())
+ ScrollableArea::setScrollPosition(clamped, ProgrammaticScroll);
setNeedsScrollPositionClamp(false);
resetScrollOriginChanged();
@@ -1564,17 +1563,17 @@
DoublePoint clampedScrollPosition = clampScrollPosition(
scrollPositionDouble() + roundedIntSize(r.location()));
- if (clampedScrollPosition == scrollPositionDouble()) {
+ if (clampedScrollPosition == scrollPositionDouble())
return LayoutRect(
box()
.localToAbsoluteQuad(FloatQuad(FloatRect(intersection(
layerBounds, localExposeRect))),
UseTransforms)
.boundingBox());
- }
DoubleSize oldScrollOffset = adjustedScrollOffset();
- setScrollPosition(clampedScrollPosition, scrollType, ScrollBehaviorInstant);
+ scrollToPosition(clampedScrollPosition, ScrollOffsetUnclamped,
+ ScrollBehaviorInstant, scrollType);
DoubleSize scrollOffsetDifference = adjustedScrollOffset() - oldScrollOffset;
localExposeRect.move(-LayoutSize(scrollOffsetDifference));
return LayoutRect(

Powered by Google App Engine
This is Rietveld 408576698