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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBox.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/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 515cacad14698660e7c442b3bbd0d9c8a45405f9..196a2f1d2316777b0f2d53fe467703e35735e793 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -263,22 +263,18 @@
}
// 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
- // area, which is weird but OK, because the scrollable area will update its
- // min/max in updateAfterLayout().
+ // adjust that value into the new zoomed coordinate space.
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);
+ if (int left = scrollableArea->scrollXOffset()) {
+ left = (left / oldStyle->effectiveZoom()) * newStyle.effectiveZoom();
+ scrollableArea->scrollToXOffset(left);
+ }
+ if (int top = scrollableArea->scrollYOffset()) {
+ top = (top / oldStyle->effectiveZoom()) * newStyle.effectiveZoom();
+ scrollableArea->scrollToYOffset(top);
}
}
@@ -526,15 +522,13 @@
}
LayoutUnit LayoutBox::scrollLeft() const {
- return hasOverflowClip()
- ? LayoutUnit(getScrollableArea()->adjustedScrollOffset().width())
- : LayoutUnit();
+ return hasOverflowClip() ? LayoutUnit(getScrollableArea()->scrollXOffset())
+ : LayoutUnit();
}
LayoutUnit LayoutBox::scrollTop() const {
- return hasOverflowClip()
- ? LayoutUnit(getScrollableArea()->adjustedScrollOffset().height())
- : LayoutUnit();
+ return hasOverflowClip() ? LayoutUnit(getScrollableArea()->scrollYOffset())
+ : LayoutUnit();
}
int LayoutBox::pixelSnappedScrollWidth() const {
@@ -555,12 +549,9 @@
// setScrollTop does, presumably this code does as well.
DisableCompositingQueryAsserts disabler;
- if (hasOverflowClip()) {
- PaintLayerScrollableArea* scrollableArea = getScrollableArea();
- scrollableArea->scrollToOffset(
- DoubleSize(newLeft, scrollableArea->adjustedScrollOffset().height()),
- ScrollBehaviorAuto);
- }
+ if (hasOverflowClip())
+ getScrollableArea()->scrollToXOffset(newLeft, ScrollOffsetClamped,
+ ScrollBehaviorAuto);
}
void LayoutBox::setScrollTop(LayoutUnit newTop) {
@@ -568,12 +559,9 @@
// 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())
+ getScrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped,
+ ScrollBehaviorAuto);
}
void LayoutBox::scrollToOffset(const DoubleSize& offset,
@@ -583,7 +571,8 @@
DisableCompositingQueryAsserts disabler;
if (hasOverflowClip())
- getScrollableArea()->scrollToOffset(offset, scrollBehavior);
+ getScrollableArea()->scrollToOffset(offset, ScrollOffsetClamped,
+ scrollBehavior);
}
// Returns true iff we are attempting an autoscroll inside an iframe with
@@ -1104,7 +1093,8 @@
scroll(ScrollByPixel, FloatSize(adjustedScrollDelta(delta)));
}
-void LayoutBox::scrollByRecursively(const DoubleSize& delta) {
+void LayoutBox::scrollByRecursively(const DoubleSize& delta,
+ ScrollOffsetClamping clamp) {
if (delta.isZero())
return;
@@ -1117,7 +1107,7 @@
ASSERT(scrollableArea);
DoubleSize newScrollOffset = scrollableArea->adjustedScrollOffset() + delta;
- scrollableArea->scrollToOffset(newScrollOffset);
+ scrollableArea->scrollToOffset(newScrollOffset, clamp);
// If this layer can't do the scroll we ask the next layer up that can
// scroll to try.
@@ -1125,7 +1115,7 @@
newScrollOffset - scrollableArea->adjustedScrollOffset();
if (!remainingScrollOffset.isZero() && parent()) {
if (LayoutBox* scrollableBox = enclosingScrollableBox())
- scrollableBox->scrollByRecursively(remainingScrollOffset);
+ scrollableBox->scrollByRecursively(remainingScrollOffset, clamp);
LocalFrame* frame = this->frame();
if (frame && frame->page())
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698