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 54d58702ce7aba8c032085c93db3168a3dbf0e41..844ecb8454c83056836308441ef8dd78907f680b 100644 |
--- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
+++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
@@ -113,10 +113,11 @@ PaintLayerScrollableArea::PaintLayerScrollableArea(PaintLayer& layer) |
if (node && node->isElementNode()) { |
// 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()) |
+ m_scrollPosition = element->savedLayerScrollOffset(); |
+ if (!m_scrollPosition.isZero()) { |
scrollAnimator().setCurrentPosition( |
- FloatPoint(m_scrollOffset.width(), m_scrollOffset.height())); |
+ FloatPoint(m_scrollPosition.width(), m_scrollPosition.height())); |
+ } |
element->setSavedLayerScrollOffset(IntSize()); |
} |
updateResizerAreaSet(); |
@@ -148,9 +149,10 @@ void PaintLayerScrollableArea::dispose() { |
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)); |
+ flooredIntSize(m_scrollPosition)); |
+ } |
} |
if (LocalFrame* frame = box().frame()) { |
@@ -354,14 +356,14 @@ int PaintLayerScrollableArea::scrollSize( |
: scrollDimensions.height(); |
} |
-void PaintLayerScrollableArea::setScrollOffset( |
- const DoublePoint& newScrollOffset, |
+void PaintLayerScrollableArea::updateScrollPosition( |
+ const DoublePoint& newPosition, |
ScrollType scrollType) { |
- if (scrollOffset() == toDoubleSize(newScrollOffset)) |
+ if (scrollPositionDouble() == newPosition) |
return; |
- DoubleSize scrollDelta = scrollOffset() - toDoubleSize(newScrollOffset); |
- m_scrollOffset = toDoubleSize(newScrollOffset); |
+ DoubleSize scrollDelta = scrollPositionDouble() - newPosition; |
+ m_scrollPosition = toDoubleSize(newPosition); |
LocalFrame* frame = box().frame(); |
ASSERT(frame); |
@@ -455,11 +457,11 @@ void PaintLayerScrollableArea::setScrollOffset( |
} |
IntPoint PaintLayerScrollableArea::scrollPosition() const { |
- return IntPoint(flooredIntSize(m_scrollOffset)); |
+ return IntPoint(flooredIntSize(m_scrollPosition)); |
} |
DoublePoint PaintLayerScrollableArea::scrollPositionDouble() const { |
- return DoublePoint(m_scrollOffset); |
+ return DoublePoint(m_scrollPosition); |
} |
IntPoint PaintLayerScrollableArea::minimumScrollPosition() const { |
@@ -498,8 +500,9 @@ IntRect PaintLayerScrollableArea::visibleContentRect( |
: 0; |
} |
+ // TODO(szager): Handle fractional scroll offsets correctly. |
return IntRect( |
- IntPoint(scrollXOffset(), scrollYOffset()), |
+ IntPoint(flooredIntSize(offsetFromOrigin())), |
IntSize(max(0, layer()->size().width() - verticalScrollbarWidth), |
max(0, layer()->size().height() - horizontalScrollbarHeight))); |
} |
@@ -635,17 +638,11 @@ void PaintLayerScrollableArea::updateScrollDimensions() { |
updateScrollOrigin(); |
} |
-void PaintLayerScrollableArea::scrollToPosition( |
- const DoublePoint& scrollPosition, |
- ScrollOffsetClamping clamp, |
- ScrollBehavior scrollBehavior, |
+void PaintLayerScrollableArea::setScrollPositionUnconditionally( |
+ const DoublePoint& position, |
ScrollType scrollType) { |
- DoublePoint newScrollPosition = clamp == ScrollOffsetClamped |
- ? clampScrollPosition(scrollPosition) |
- : scrollPosition; |
- if (newScrollPosition != scrollPositionDouble()) |
- ScrollableArea::setScrollPosition(newScrollPosition, scrollType, |
- scrollBehavior); |
+ cancelScrollAnimation(); |
+ scrollPositionChanged(position, scrollType); |
} |
void PaintLayerScrollableArea::updateAfterLayout() { |
@@ -807,7 +804,9 @@ void PaintLayerScrollableArea::clampScrollPositionsAfterLayout() { |
m_scrollAnchor.restore(); |
DoublePoint clamped = clampScrollPosition(scrollPositionDouble()); |
- if (clamped != scrollPositionDouble() || scrollOriginChanged()) |
+ if (scrollOriginChanged()) |
+ setScrollPositionUnconditionally(clamped); |
+ else if (clamped != scrollPositionDouble()) |
ScrollableArea::setScrollPosition(clamped, ProgrammaticScroll); |
setNeedsScrollPositionClamp(false); |
@@ -1560,9 +1559,10 @@ LayoutRect PaintLayerScrollableArea::scrollIntoView( |
LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect, |
alignX, alignY); |
- DoublePoint clampedScrollPosition = clampScrollPosition( |
- scrollPositionDouble() + roundedIntSize(r.location())); |
- if (clampedScrollPosition == scrollPositionDouble()) |
+ DoublePoint oldScrollPosition = scrollPositionDouble(); |
+ DoublePoint newScrollPosition = |
+ clampScrollPosition(oldScrollPosition + roundedIntSize(r.location())); |
+ if (newScrollPosition == oldScrollPosition) |
return LayoutRect( |
box() |
.localToAbsoluteQuad(FloatQuad(FloatRect(intersection( |
@@ -1570,10 +1570,9 @@ LayoutRect PaintLayerScrollableArea::scrollIntoView( |
UseTransforms) |
.boundingBox()); |
- DoubleSize oldScrollOffset = adjustedScrollOffset(); |
- scrollToPosition(clampedScrollPosition, ScrollOffsetUnclamped, |
- ScrollBehaviorInstant, scrollType); |
- DoubleSize scrollOffsetDifference = adjustedScrollOffset() - oldScrollOffset; |
+ setScrollPosition(newScrollPosition, scrollType, ScrollBehaviorInstant); |
+ DoubleSize scrollOffsetDifference = |
+ scrollPositionDouble() - oldScrollPosition; |
localExposeRect.move(-LayoutSize(scrollOffsetDifference)); |
return LayoutRect( |
box() |