| 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 844ecb8454c83056836308441ef8dd78907f680b..2421b5e694db734f7df6bf6d86e68640047ca358 100644
|
| --- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
|
| +++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
|
| @@ -96,7 +96,7 @@ PaintLayerScrollableArea::PaintLayerScrollableArea(PaintLayer& layer)
|
| m_needsCompositedScrolling(false),
|
| m_rebuildHorizontalScrollbarLayer(false),
|
| m_rebuildVerticalScrollbarLayer(false),
|
| - m_needsScrollPositionClamp(false),
|
| + m_needsScrollOffsetClamp(false),
|
| m_needsRelayout(false),
|
| m_hadHorizontalScrollbarBeforeRelayout(false),
|
| m_hadVerticalScrollbarBeforeRelayout(false),
|
| @@ -113,12 +113,10 @@ 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_scrollPosition = element->savedLayerScrollOffset();
|
| - if (!m_scrollPosition.isZero()) {
|
| - scrollAnimator().setCurrentPosition(
|
| - FloatPoint(m_scrollPosition.width(), m_scrollPosition.height()));
|
| - }
|
| - element->setSavedLayerScrollOffset(IntSize());
|
| + m_scrollOffset = element->savedLayerScrollOffset();
|
| + if (!m_scrollOffset.isZero())
|
| + scrollAnimator().setCurrentOffset(m_scrollOffset);
|
| + element->setSavedLayerScrollOffset(ScrollOffset());
|
| }
|
| updateResizerAreaSet();
|
| }
|
| @@ -149,10 +147,8 @@ void PaintLayerScrollableArea::dispose() {
|
| if (!box().documentBeingDestroyed()) {
|
| Node* node = box().node();
|
| // FIXME: Make setSavedLayerScrollOffset take DoubleSize. crbug.com/414283.
|
| - if (node && node->isElementNode()) {
|
| - toElement(node)->setSavedLayerScrollOffset(
|
| - flooredIntSize(m_scrollPosition));
|
| - }
|
| + if (node && node->isElementNode())
|
| + toElement(node)->setSavedLayerScrollOffset(m_scrollOffset);
|
| }
|
|
|
| if (LocalFrame* frame = box().frame()) {
|
| @@ -351,19 +347,19 @@ IntPoint PaintLayerScrollableArea::convertFromContainingWidgetToScrollbar(
|
|
|
| int PaintLayerScrollableArea::scrollSize(
|
| ScrollbarOrientation orientation) const {
|
| - IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition();
|
| + IntSize scrollDimensions =
|
| + maximumScrollOffsetInt() - minimumScrollOffsetInt();
|
| return (orientation == HorizontalScrollbar) ? scrollDimensions.width()
|
| : scrollDimensions.height();
|
| }
|
|
|
| -void PaintLayerScrollableArea::updateScrollPosition(
|
| - const DoublePoint& newPosition,
|
| - ScrollType scrollType) {
|
| - if (scrollPositionDouble() == newPosition)
|
| +void PaintLayerScrollableArea::updateScrollOffset(const ScrollOffset& newOffset,
|
| + ScrollType scrollType) {
|
| + if (scrollOffset() == newOffset)
|
| return;
|
|
|
| - DoubleSize scrollDelta = scrollPositionDouble() - newPosition;
|
| - m_scrollPosition = toDoubleSize(newPosition);
|
| + ScrollOffset scrollDelta = scrollOffset() - newOffset;
|
| + m_scrollOffset = newOffset;
|
|
|
| LocalFrame* frame = box().frame();
|
| ASSERT(frame);
|
| @@ -441,7 +437,7 @@ void PaintLayerScrollableArea::updateScrollPosition(
|
| cache->handleScrollPositionChanged(&box());
|
| box().view()->clearHitTestCache();
|
|
|
| - // Inform the FrameLoader of the new scroll position, so it can be restored when navigating back.
|
| + // Inform the FrameLoader of the new scroll offset, so it can be restored when navigating back.
|
| if (layer()->isRootLayer()) {
|
| frameView->frame().loader().saveScrollState();
|
| frameView->didChangeScrollOffset();
|
| @@ -456,19 +452,19 @@ void PaintLayerScrollableArea::updateScrollPosition(
|
| scrollAnchor()->clear();
|
| }
|
|
|
| -IntPoint PaintLayerScrollableArea::scrollPosition() const {
|
| - return IntPoint(flooredIntSize(m_scrollPosition));
|
| +IntSize PaintLayerScrollableArea::scrollOffsetInt() const {
|
| + return flooredIntSize(m_scrollOffset);
|
| }
|
|
|
| -DoublePoint PaintLayerScrollableArea::scrollPositionDouble() const {
|
| - return DoublePoint(m_scrollPosition);
|
| +ScrollOffset PaintLayerScrollableArea::scrollOffset() const {
|
| + return m_scrollOffset;
|
| }
|
|
|
| -IntPoint PaintLayerScrollableArea::minimumScrollPosition() const {
|
| - return -scrollOrigin();
|
| +IntSize PaintLayerScrollableArea::minimumScrollOffsetInt() const {
|
| + return toIntSize(-scrollOrigin());
|
| }
|
|
|
| -IntPoint PaintLayerScrollableArea::maximumScrollPosition() const {
|
| +IntSize PaintLayerScrollableArea::maximumScrollOffsetInt() const {
|
| IntSize contentSize;
|
| IntSize visibleSize;
|
| if (box().hasOverflowClip()) {
|
| @@ -482,7 +478,7 @@ IntPoint PaintLayerScrollableArea::maximumScrollPosition() const {
|
| // based on stale layout overflow data (http://crbug.com/576933).
|
| contentSize = contentSize.expandedTo(visibleSize);
|
| }
|
| - return -scrollOrigin() + (contentSize - visibleSize);
|
| + return toIntSize(-scrollOrigin() + (contentSize - visibleSize));
|
| }
|
|
|
| IntRect PaintLayerScrollableArea::visibleContentRect(
|
| @@ -502,7 +498,7 @@ IntRect PaintLayerScrollableArea::visibleContentRect(
|
|
|
| // TODO(szager): Handle fractional scroll offsets correctly.
|
| return IntRect(
|
| - IntPoint(flooredIntSize(offsetFromOrigin())),
|
| + flooredIntPoint(absolutePosition()),
|
| IntSize(max(0, layer()->size().width() - verticalScrollbarWidth),
|
| max(0, layer()->size().height() - horizontalScrollbarHeight)));
|
| }
|
| @@ -638,11 +634,11 @@ void PaintLayerScrollableArea::updateScrollDimensions() {
|
| updateScrollOrigin();
|
| }
|
|
|
| -void PaintLayerScrollableArea::setScrollPositionUnconditionally(
|
| - const DoublePoint& position,
|
| +void PaintLayerScrollableArea::setScrollOffsetUnconditionally(
|
| + const ScrollOffset& offset,
|
| ScrollType scrollType) {
|
| cancelScrollAnimation();
|
| - scrollPositionChanged(position, scrollType);
|
| + scrollOffsetChanged(offset, scrollType);
|
| }
|
|
|
| void PaintLayerScrollableArea::updateAfterLayout() {
|
| @@ -776,7 +772,7 @@ void PaintLayerScrollableArea::updateAfterLayout() {
|
| setHasVerticalScrollbar(false);
|
| }
|
|
|
| - clampScrollPositionsAfterLayout();
|
| + clampScrollOffsetsAfterLayout();
|
|
|
| if (!scrollbarsAreFrozen) {
|
| bool hasOverflow =
|
| @@ -788,14 +784,14 @@ void PaintLayerScrollableArea::updateAfterLayout() {
|
| positionOverflowControls();
|
| }
|
|
|
| -void PaintLayerScrollableArea::clampScrollPositionsAfterLayout() {
|
| - // If a vertical scrollbar was removed, the min/max scroll positions may have changed,
|
| - // so the scroll positions needs to be clamped. If the scroll position did not change,
|
| +void PaintLayerScrollableArea::clampScrollOffsetsAfterLayout() {
|
| + // If a vertical scrollbar was removed, the min/max scroll offsets may have changed,
|
| + // so the scroll offsets needs to be clamped. If the scroll offset did not change,
|
| // but the scroll origin *did* change, we still need to notify the scrollbars to
|
| // update their dimensions.
|
|
|
| - if (DelayScrollPositionClampScope::clampingIsDelayed()) {
|
| - DelayScrollPositionClampScope::setNeedsClamp(this);
|
| + if (DelayScrollOffsetClampScope::clampingIsDelayed()) {
|
| + DelayScrollOffsetClampScope::setNeedsClamp(this);
|
| return;
|
| }
|
|
|
| @@ -803,13 +799,13 @@ void PaintLayerScrollableArea::clampScrollPositionsAfterLayout() {
|
| if (shouldPerformScrollAnchoring())
|
| m_scrollAnchor.restore();
|
|
|
| - DoublePoint clamped = clampScrollPosition(scrollPositionDouble());
|
| + ScrollOffset clamped = clampScrollOffset(scrollOffset());
|
| if (scrollOriginChanged())
|
| - setScrollPositionUnconditionally(clamped);
|
| - else if (clamped != scrollPositionDouble())
|
| - ScrollableArea::setScrollPosition(clamped, ProgrammaticScroll);
|
| + setScrollOffsetUnconditionally(clamped);
|
| + else if (clamped != scrollOffset())
|
| + ScrollableArea::setScrollOffset(clamped, ProgrammaticScroll);
|
|
|
| - setNeedsScrollPositionClamp(false);
|
| + setNeedsScrollOffsetClamp(false);
|
| resetScrollOriginChanged();
|
| m_scrollbarManager.destroyDetachedScrollbars();
|
| }
|
| @@ -1559,10 +1555,11 @@ LayoutRect PaintLayerScrollableArea::scrollIntoView(
|
| LayoutRect r = ScrollAlignment::getRectToExpose(layerBounds, localExposeRect,
|
| alignX, alignY);
|
|
|
| - DoublePoint oldScrollPosition = scrollPositionDouble();
|
| - DoublePoint newScrollPosition =
|
| - clampScrollPosition(oldScrollPosition + roundedIntSize(r.location()));
|
| - if (newScrollPosition == oldScrollPosition)
|
| + ScrollOffset oldScrollOffset = scrollOffset();
|
| + ScrollOffset newScrollOffset(clampScrollOffset(roundedIntSize(
|
| + toScrollOffset(FloatPoint(r.location()) + oldScrollOffset))));
|
| +
|
| + if (newScrollOffset == oldScrollOffset)
|
| return LayoutRect(
|
| box()
|
| .localToAbsoluteQuad(FloatQuad(FloatRect(intersection(
|
| @@ -1570,9 +1567,8 @@ LayoutRect PaintLayerScrollableArea::scrollIntoView(
|
| UseTransforms)
|
| .boundingBox());
|
|
|
| - setScrollPosition(newScrollPosition, scrollType, ScrollBehaviorInstant);
|
| - DoubleSize scrollOffsetDifference =
|
| - scrollPositionDouble() - oldScrollPosition;
|
| + setScrollOffset(newScrollOffset, scrollType, ScrollBehaviorInstant);
|
| + ScrollOffset scrollOffsetDifference = scrollOffset() - oldScrollOffset;
|
| localExposeRect.move(-LayoutSize(scrollOffsetDifference));
|
| return LayoutRect(
|
| box()
|
| @@ -1765,7 +1761,7 @@ void PaintLayerScrollableArea::ScrollbarManager::setHasHorizontalScrollbar(
|
| }
|
| } else {
|
| m_hBarIsAttached = 0;
|
| - if (!DelayScrollPositionClampScope::clampingIsDelayed())
|
| + if (!DelayScrollOffsetClampScope::clampingIsDelayed())
|
| destroyScrollbar(HorizontalScrollbar);
|
| }
|
| }
|
| @@ -1784,7 +1780,7 @@ void PaintLayerScrollableArea::ScrollbarManager::setHasVerticalScrollbar(
|
| }
|
| } else {
|
| m_vBarIsAttached = 0;
|
| - if (!DelayScrollPositionClampScope::clampingIsDelayed())
|
| + if (!DelayScrollOffsetClampScope::clampingIsDelayed())
|
| destroyScrollbar(VerticalScrollbar);
|
| }
|
| }
|
| @@ -1921,37 +1917,37 @@ void PaintLayerScrollableArea::PreventRelayoutScope::resetRelayoutNeeded() {
|
|
|
| int PaintLayerScrollableArea::FreezeScrollbarsScope::s_count = 0;
|
|
|
| -int PaintLayerScrollableArea::DelayScrollPositionClampScope::s_count = 0;
|
| +int PaintLayerScrollableArea::DelayScrollOffsetClampScope::s_count = 0;
|
| PersistentHeapVector<Member<PaintLayerScrollableArea>>*
|
| - PaintLayerScrollableArea::DelayScrollPositionClampScope::s_needsClamp =
|
| + PaintLayerScrollableArea::DelayScrollOffsetClampScope::s_needsClamp =
|
| nullptr;
|
|
|
| -PaintLayerScrollableArea::DelayScrollPositionClampScope::
|
| - DelayScrollPositionClampScope() {
|
| +PaintLayerScrollableArea::DelayScrollOffsetClampScope::
|
| + DelayScrollOffsetClampScope() {
|
| if (!s_needsClamp)
|
| s_needsClamp = new PersistentHeapVector<Member<PaintLayerScrollableArea>>();
|
| DCHECK(s_count > 0 || s_needsClamp->isEmpty());
|
| s_count++;
|
| }
|
|
|
| -PaintLayerScrollableArea::DelayScrollPositionClampScope::
|
| - ~DelayScrollPositionClampScope() {
|
| +PaintLayerScrollableArea::DelayScrollOffsetClampScope::
|
| + ~DelayScrollOffsetClampScope() {
|
| if (--s_count == 0)
|
| - DelayScrollPositionClampScope::clampScrollableAreas();
|
| + DelayScrollOffsetClampScope::clampScrollableAreas();
|
| }
|
|
|
| -void PaintLayerScrollableArea::DelayScrollPositionClampScope::setNeedsClamp(
|
| +void PaintLayerScrollableArea::DelayScrollOffsetClampScope::setNeedsClamp(
|
| PaintLayerScrollableArea* scrollableArea) {
|
| - if (!scrollableArea->needsScrollPositionClamp()) {
|
| - scrollableArea->setNeedsScrollPositionClamp(true);
|
| + if (!scrollableArea->needsScrollOffsetClamp()) {
|
| + scrollableArea->setNeedsScrollOffsetClamp(true);
|
| s_needsClamp->append(scrollableArea);
|
| }
|
| }
|
|
|
| -void PaintLayerScrollableArea::DelayScrollPositionClampScope::
|
| +void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
|
| clampScrollableAreas() {
|
| for (auto& scrollableArea : *s_needsClamp)
|
| - scrollableArea->clampScrollPositionsAfterLayout();
|
| + scrollableArea->clampScrollOffsetsAfterLayout();
|
| delete s_needsClamp;
|
| s_needsClamp = nullptr;
|
| }
|
|
|