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

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

Issue 2387883002: Use float for scroll offset. (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/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index bf2bbdc558be98055fb006d193dae454530e77fe..a2e80ff831f5256b7102872a06a3e03908c9da29 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -256,20 +256,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
+ // new zoomed coordinate space. Note that the new 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 offsetFromOrigin(), because scrollPosition is the distance
+ // We use scrollOffset() rather than offsetFromOrigin(), because scrollOffset 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);
+ ScrollOffset oldOffset = scrollableArea->scrollOffset();
+ if (oldOffset.width() || oldOffset.height()) {
+ ScrollOffset newOffset = oldOffset.scaledBy(newStyle.effectiveZoom() /
+ oldStyle->effectiveZoom());
+ scrollableArea->setScrollOffsetUnconditionally(newOffset);
}
}
@@ -515,13 +515,13 @@ LayoutUnit LayoutBox::scrollHeight() const {
LayoutUnit LayoutBox::scrollLeft() const {
return hasOverflowClip()
- ? LayoutUnit(getScrollableArea()->offsetFromOrigin().width())
+ ? LayoutUnit(getScrollableArea()->absolutePosition().x())
: LayoutUnit();
}
LayoutUnit LayoutBox::scrollTop() const {
return hasOverflowClip()
- ? LayoutUnit(getScrollableArea()->offsetFromOrigin().height())
+ ? LayoutUnit(getScrollableArea()->absolutePosition().y())
: LayoutUnit();
}
@@ -547,8 +547,9 @@ void LayoutBox::setScrollLeft(LayoutUnit newLeft) {
return;
PaintLayerScrollableArea* scrollableArea = getScrollableArea();
- DoubleSize newOffset(newLeft, scrollableArea->offsetFromOrigin().height());
- scrollableArea->scrollToOffsetFromOrigin(newOffset, ScrollBehaviorAuto);
+ FloatPoint newPosition(newLeft.toFloat(),
+ scrollableArea->absolutePosition().y());
+ scrollableArea->scrollToAbsolutePosition(newPosition, ScrollBehaviorAuto);
}
void LayoutBox::setScrollTop(LayoutUnit newTop) {
@@ -559,12 +560,13 @@ void LayoutBox::setScrollTop(LayoutUnit newTop) {
return;
PaintLayerScrollableArea* scrollableArea = getScrollableArea();
- DoubleSize newOffset(scrollableArea->offsetFromOrigin().width(), newTop);
- scrollableArea->scrollToOffsetFromOrigin(newOffset, ScrollBehaviorAuto);
+ FloatPoint newPosition(scrollableArea->absolutePosition().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;
@@ -572,7 +574,7 @@ void LayoutBox::scrollToOffset(const DoubleSize& offset,
if (!hasOverflowClip())
return;
- getScrollableArea()->scrollToOffsetFromOrigin(offset, scrollBehavior);
+ getScrollableArea()->scrollToAbsolutePosition(position, scrollBehavior);
}
// Returns true iff we are attempting an autoscroll inside an iframe with scrolling="no".
@@ -1003,7 +1005,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 +1089,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 +1101,12 @@ void LayoutBox::scrollByRecursively(const DoubleSize& delta) {
PaintLayerScrollableArea* scrollableArea = this->getScrollableArea();
ASSERT(scrollableArea);
- DoubleSize newScrollOffset = scrollableArea->offsetFromOrigin() + delta;
- scrollableArea->scrollToOffsetFromOrigin(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->offsetFromOrigin();
+ ScrollOffset remainingScrollOffset =
+ newScrollOffset - scrollableArea->scrollOffset();
if (!remainingScrollOffset.isZero() && parent()) {
if (LayoutBox* scrollableBox = enclosingScrollableBox())
scrollableBox->scrollByRecursively(remainingScrollOffset);
@@ -1117,7 +1119,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 +1147,8 @@ IntSize LayoutBox::scrolledContentOffset() const {
ASSERT(hasLayer());
// FIXME: Return DoubleSize here. crbug.com/414283.
PaintLayerScrollableArea* scrollableArea = getScrollableArea();
- IntSize result = flooredIntSize(scrollableArea->scrollPosition()) +
- originAdjustmentForScrollbars();
+ IntSize result =
+ scrollableArea->scrollOffsetInt() + originAdjustmentForScrollbars();
if (isHorizontalWritingMode() &&
shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
result.expand(-verticalScrollbarWidth(), 0);
@@ -1733,9 +1735,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(

Powered by Google App Engine
This is Rietveld 408576698