Index: third_party/WebKit/Source/core/layout/LayoutBox.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp |
index b3a3c7dfd6c891788c123937f4561f352c048c71..100d0b822eeae912e4f6daf37ef8465d4f97e85a 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp |
@@ -257,21 +257,20 @@ void LayoutBox::styleDidChange(StyleDifference diff, |
// If our zoom factor changes and we have a defined scrollLeft/Top, we need to |
// adjust that value into the new zoomed coordinate space. Note that the new |
- // scroll position may be outside the normal min/max range of the scrollable |
+ // scroll offset may be outside the normal min/max range of the scrollable |
// area, which is weird but OK, because the scrollable area will update its |
// min/max in updateAfterLayout(). |
if (hasOverflowClip() && oldStyle && |
oldStyle->effectiveZoom() != newStyle.effectiveZoom()) { |
PaintLayerScrollableArea* scrollableArea = this->getScrollableArea(); |
ASSERT(scrollableArea); |
- // We use scrollPosition() rather than adjustedScrollPosition(), because |
- // scrollPosition is the distance from the beginning of flow for the box, |
- // which is the dimension we want to preserve. |
- DoublePoint oldPosition = scrollableArea->scrollPositionDouble(); |
- if (oldPosition.x() || oldPosition.y()) { |
- DoublePoint newPosition = oldPosition.scaledBy(newStyle.effectiveZoom() / |
- oldStyle->effectiveZoom()); |
- scrollableArea->setScrollPositionUnconditionally(newPosition); |
+ // We use scrollOffset() rather than scrollPosition(), because scrollOffset is the distance |
+ // from the beginning of flow for the box, which is the dimension we want to preserve. |
+ ScrollOffset oldOffset = scrollableArea->scrollOffset(); |
+ if (oldOffset.width() || oldOffset.height()) { |
+ ScrollOffset newOffset = oldOffset.scaledBy(newStyle.effectiveZoom() / |
+ oldStyle->effectiveZoom()); |
+ scrollableArea->setScrollOffsetUnconditionally(newOffset); |
} |
} |
@@ -517,13 +516,13 @@ LayoutUnit LayoutBox::scrollHeight() const { |
LayoutUnit LayoutBox::scrollLeft() const { |
return hasOverflowClip() |
- ? LayoutUnit(getScrollableArea()->adjustedScrollOffset().width()) |
+ ? LayoutUnit(getScrollableArea()->scrollPosition().x()) |
: LayoutUnit(); |
} |
LayoutUnit LayoutBox::scrollTop() const { |
return hasOverflowClip() |
- ? LayoutUnit(getScrollableArea()->adjustedScrollOffset().height()) |
+ ? LayoutUnit(getScrollableArea()->scrollPosition().y()) |
: LayoutUnit(); |
} |
@@ -545,34 +544,38 @@ void LayoutBox::setScrollLeft(LayoutUnit newLeft) { |
// does, presumably this code does as well. |
DisableCompositingQueryAsserts disabler; |
- if (hasOverflowClip()) { |
- PaintLayerScrollableArea* scrollableArea = getScrollableArea(); |
- scrollableArea->scrollToOffset( |
- DoubleSize(newLeft, scrollableArea->adjustedScrollOffset().height()), |
- ScrollBehaviorAuto); |
- } |
+ if (!hasOverflowClip()) |
+ return; |
+ |
+ PaintLayerScrollableArea* scrollableArea = getScrollableArea(); |
+ FloatPoint newPosition(newLeft.toFloat(), |
+ scrollableArea->scrollPosition().y()); |
+ scrollableArea->scrollToAbsolutePosition(newPosition, ScrollBehaviorAuto); |
} |
void LayoutBox::setScrollTop(LayoutUnit newTop) { |
// Hits in compositing/overflow/do-not-assert-on-invisible-composited-layers.html |
DisableCompositingQueryAsserts disabler; |
- if (hasOverflowClip()) { |
- PaintLayerScrollableArea* scrollableArea = getScrollableArea(); |
- scrollableArea->scrollToOffset( |
- DoubleSize(scrollableArea->adjustedScrollOffset().width(), newTop), |
- ScrollBehaviorAuto); |
- } |
+ if (!hasOverflowClip()) |
+ return; |
+ |
+ PaintLayerScrollableArea* scrollableArea = getScrollableArea(); |
+ FloatPoint newPosition(scrollableArea->scrollPosition().x(), |
+ newTop.toFloat()); |
+ scrollableArea->scrollToAbsolutePosition(newPosition, ScrollBehaviorAuto); |
} |
-void LayoutBox::scrollToOffset(const DoubleSize& offset, |
- ScrollBehavior scrollBehavior) { |
+void LayoutBox::scrollToPosition(const FloatPoint& position, |
+ ScrollBehavior scrollBehavior) { |
// This doesn't hit in any tests, but since the equivalent code in setScrollTop |
// does, presumably this code does as well. |
DisableCompositingQueryAsserts disabler; |
- if (hasOverflowClip()) |
- getScrollableArea()->scrollToOffset(offset, scrollBehavior); |
+ if (!hasOverflowClip()) |
+ return; |
+ |
+ getScrollableArea()->scrollToAbsolutePosition(position, scrollBehavior); |
} |
// Returns true iff we are attempting an autoscroll inside an iframe with scrolling="no". |
@@ -1003,7 +1006,7 @@ IntSize LayoutBox::calculateAutoscrollDirection( |
return IntSize(); |
IntRect box(absoluteBoundingBoxRect()); |
- box.move(view()->frameView()->scrollOffset()); |
+ box.move(view()->frameView()->scrollOffsetInt()); |
IntRect windowBox = view()->frameView()->contentsToRootFrame(box); |
IntPoint windowAutoscrollPoint = pointInRootFrame; |
@@ -1087,7 +1090,7 @@ void LayoutBox::middleClickAutoscroll(const IntPoint& sourcePoint) { |
scroll(ScrollByPixel, FloatSize(adjustedScrollDelta(delta))); |
} |
-void LayoutBox::scrollByRecursively(const DoubleSize& delta) { |
+void LayoutBox::scrollByRecursively(const ScrollOffset& delta) { |
if (delta.isZero()) |
return; |
@@ -1099,12 +1102,13 @@ void LayoutBox::scrollByRecursively(const DoubleSize& delta) { |
PaintLayerScrollableArea* scrollableArea = this->getScrollableArea(); |
ASSERT(scrollableArea); |
- DoubleSize newScrollOffset = scrollableArea->adjustedScrollOffset() + delta; |
- scrollableArea->scrollToOffset(newScrollOffset); |
+ ScrollOffset newScrollOffset = scrollableArea->scrollOffset() + delta; |
+ scrollableArea->setScrollOffset(newScrollOffset, ProgrammaticScroll); |
- // If this layer can't do the scroll we ask the next layer up that can scroll to try |
- DoubleSize remainingScrollOffset = |
- newScrollOffset - scrollableArea->adjustedScrollOffset(); |
+ // If this layer can't do the scroll we ask the next layer up that can |
+ // scroll to try. |
+ ScrollOffset remainingScrollOffset = |
+ newScrollOffset - scrollableArea->scrollOffset(); |
if (!remainingScrollOffset.isZero() && parent()) { |
if (LayoutBox* scrollableBox = enclosingScrollableBox()) |
scrollableBox->scrollByRecursively(remainingScrollOffset); |
@@ -1117,7 +1121,7 @@ void LayoutBox::scrollByRecursively(const DoubleSize& delta) { |
// If we are here, we were called on a layoutObject that can be programmatically scrolled, but doesn't |
// have an overflow clip. Which means that it is a document node that can be scrolled. |
// FIXME: Pass in DoubleSize. crbug.com/414283. |
- view()->frameView()->scrollBy(flooredIntSize(delta), UserScroll); |
+ view()->frameView()->scrollBy(delta, UserScroll); |
// FIXME: If we didn't scroll the whole way, do we want to try looking at the frames ownerElement? |
// https://bugs.webkit.org/show_bug.cgi?id=28237 |
@@ -1145,8 +1149,8 @@ IntSize LayoutBox::scrolledContentOffset() const { |
ASSERT(hasLayer()); |
// FIXME: Return DoubleSize here. crbug.com/414283. |
PaintLayerScrollableArea* scrollableArea = getScrollableArea(); |
- IntSize result = flooredIntSize(scrollableArea->scrollOffset()) + |
- originAdjustmentForScrollbars(); |
+ IntSize result = |
+ scrollableArea->scrollOffsetInt() + originAdjustmentForScrollbars(); |
if (isHorizontalWritingMode() && |
shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
result.expand(-verticalScrollbarWidth(), 0); |
@@ -1733,9 +1737,8 @@ bool LayoutBox::intersectsVisibleViewport() const { |
LayoutAPIShim::layoutObjectFrom(layoutView->frame()->ownerLayoutItem()) |
->view(); |
mapToVisualRectInAncestorSpace(layoutView, rect); |
- return rect.intersects(LayoutRect(layoutView->frameView() |
- ->getScrollableArea() |
- ->visibleContentRectDouble())); |
+ return rect.intersects(LayoutRect( |
+ layoutView->frameView()->getScrollableArea()->visibleContentRect())); |
} |
PaintInvalidationReason LayoutBox::invalidatePaintIfNeeded( |