| Index: third_party/WebKit/Source/core/frame/VisualViewport.cpp
|
| diff --git a/third_party/WebKit/Source/core/frame/VisualViewport.cpp b/third_party/WebKit/Source/core/frame/VisualViewport.cpp
|
| index 3e14bd588ec7b3ac923f8257a070a891456d9f14..1f8e28f043936b060f8548ccd00db70ab3b2d977 100644
|
| --- a/third_party/WebKit/Source/core/frame/VisualViewport.cpp
|
| +++ b/third_party/WebKit/Source/core/frame/VisualViewport.cpp
|
| @@ -163,8 +163,8 @@ FloatRect VisualViewport::visibleRectInDocument() const {
|
| if (!mainFrame() || !mainFrame()->view())
|
| return FloatRect();
|
|
|
| - FloatPoint viewLocation = FloatPoint(
|
| - mainFrame()->view()->getScrollableArea()->scrollPositionDouble());
|
| + FloatPoint viewLocation =
|
| + FloatPoint(mainFrame()->view()->getScrollableArea()->scrollOffset());
|
| return FloatRect(viewLocation, visibleSize());
|
| }
|
|
|
| @@ -188,19 +188,15 @@ void VisualViewport::setLocation(const FloatPoint& newLocation) {
|
| setScaleAndLocation(m_scale, newLocation);
|
| }
|
|
|
| -void VisualViewport::move(const FloatPoint& delta) {
|
| - setLocation(m_offset + delta);
|
| -}
|
| -
|
| -void VisualViewport::move(const FloatSize& delta) {
|
| - setLocation(m_offset + delta);
|
| +void VisualViewport::move(const ScrollOffset& delta) {
|
| + setLocation(FloatPoint(m_offset + delta));
|
| }
|
|
|
| void VisualViewport::setScale(float scale) {
|
| - setScaleAndLocation(scale, m_offset);
|
| + setScaleAndLocation(scale, FloatPoint(m_offset));
|
| }
|
|
|
| -double VisualViewport::scrollLeft() {
|
| +float VisualViewport::scrollLeft() {
|
| if (!mainFrame())
|
| return 0;
|
|
|
| @@ -210,7 +206,7 @@ double VisualViewport::scrollLeft() {
|
| mainFrame()->pageZoomFactor());
|
| }
|
|
|
| -double VisualViewport::scrollTop() {
|
| +float VisualViewport::scrollTop() {
|
| if (!mainFrame())
|
| return 0;
|
|
|
| @@ -220,25 +216,25 @@ double VisualViewport::scrollTop() {
|
| mainFrame()->pageZoomFactor());
|
| }
|
|
|
| -double VisualViewport::clientWidth() {
|
| +float VisualViewport::clientWidth() {
|
| if (!mainFrame())
|
| return 0;
|
|
|
| updateStyleAndLayoutIgnorePendingStylesheets();
|
|
|
| - double width = adjustScrollForAbsoluteZoom(visibleSize().width(),
|
| - mainFrame()->pageZoomFactor());
|
| + float width = adjustScrollForAbsoluteZoom(visibleSize().width(),
|
| + mainFrame()->pageZoomFactor());
|
| return width - mainFrame()->view()->verticalScrollbarWidth() / m_scale;
|
| }
|
|
|
| -double VisualViewport::clientHeight() {
|
| +float VisualViewport::clientHeight() {
|
| if (!mainFrame())
|
| return 0;
|
|
|
| updateStyleAndLayoutIgnorePendingStylesheets();
|
|
|
| - double height = adjustScrollForAbsoluteZoom(visibleSize().height(),
|
| - mainFrame()->pageZoomFactor());
|
| + float height = adjustScrollForAbsoluteZoom(visibleSize().height(),
|
| + mainFrame()->pageZoomFactor());
|
| return height - mainFrame()->view()->horizontalScrollbarHeight() / m_scale;
|
| }
|
|
|
| @@ -268,11 +264,11 @@ bool VisualViewport::didSetScaleOrLocation(float scale,
|
| enqueueResizeEvent();
|
| }
|
|
|
| - FloatPoint clampedOffset(clampOffsetToBoundaries(location));
|
| + ScrollOffset clampedOffset = clampScrollOffset(toScrollOffset(location));
|
|
|
| if (clampedOffset != m_offset) {
|
| m_offset = clampedOffset;
|
| - scrollAnimator().setCurrentPosition(m_offset);
|
| + scrollAnimator().setCurrentOffset(m_offset);
|
|
|
| // SVG runs with accelerated compositing disabled so no ScrollingCoordinator.
|
| if (ScrollingCoordinator* coordinator =
|
| @@ -502,16 +498,6 @@ HostWindow* VisualViewport::getHostWindow() const {
|
| return &frameHost().chromeClient();
|
| }
|
|
|
| -DoubleRect VisualViewport::visibleContentRectDouble(
|
| - IncludeScrollbarsInRect) const {
|
| - return visibleRect();
|
| -}
|
| -
|
| -IntRect VisualViewport::visibleContentRect(
|
| - IncludeScrollbarsInRect scrollbarInclusion) const {
|
| - return enclosingIntRect(visibleContentRectDouble(scrollbarInclusion));
|
| -}
|
| -
|
| bool VisualViewport::shouldUseIntegerScrollOffset() const {
|
| LocalFrame* frame = mainFrame();
|
| if (frame && frame->settings() &&
|
| @@ -521,39 +507,39 @@ bool VisualViewport::shouldUseIntegerScrollOffset() const {
|
| return ScrollableArea::shouldUseIntegerScrollOffset();
|
| }
|
|
|
| -void VisualViewport::setScrollPosition(const DoublePoint& scrollPoint,
|
| - ScrollType scrollType,
|
| - ScrollBehavior scrollBehavior) {
|
| - // We clamp the position here, because the ScrollAnimator may otherwise be
|
| - // set to a non-clamped position by ScrollableArea::setScrollPosition,
|
| +void VisualViewport::setScrollOffset(const ScrollOffset& offset,
|
| + ScrollType scrollType,
|
| + ScrollBehavior scrollBehavior) {
|
| + // We clamp the offset here, because the ScrollAnimator may otherwise be
|
| + // set to a non-clamped offset by ScrollableArea::setScrollOffset,
|
| // which may lead to incorrect scrolling behavior in RootFrameViewport down
|
| // the line.
|
| // TODO(eseckler): Solve this instead by ensuring that ScrollableArea and
|
| // ScrollAnimator are kept in sync. This requires that ScrollableArea always
|
| // stores fractional offsets and that truncation happens elsewhere, see
|
| // crbug.com/626315.
|
| - DoublePoint newScrollPosition = clampScrollPosition(scrollPoint);
|
| - ScrollableArea::setScrollPosition(newScrollPosition, scrollType,
|
| - scrollBehavior);
|
| + ScrollOffset newScrollOffset = clampScrollOffset(offset);
|
| + ScrollableArea::setScrollOffset(newScrollOffset, scrollType, scrollBehavior);
|
| }
|
|
|
| int VisualViewport::scrollSize(ScrollbarOrientation orientation) const {
|
| - IntSize scrollDimensions = maximumScrollPosition() - minimumScrollPosition();
|
| + IntSize scrollDimensions =
|
| + maximumScrollOffsetInt() - minimumScrollOffsetInt();
|
| return (orientation == HorizontalScrollbar) ? scrollDimensions.width()
|
| : scrollDimensions.height();
|
| }
|
|
|
| -IntPoint VisualViewport::minimumScrollPosition() const {
|
| - return IntPoint();
|
| +IntSize VisualViewport::minimumScrollOffsetInt() const {
|
| + return IntSize();
|
| }
|
|
|
| -IntPoint VisualViewport::maximumScrollPosition() const {
|
| - return flooredIntPoint(maximumScrollPositionDouble());
|
| +IntSize VisualViewport::maximumScrollOffsetInt() const {
|
| + return flooredIntSize(maximumScrollOffset());
|
| }
|
|
|
| -DoublePoint VisualViewport::maximumScrollPositionDouble() const {
|
| +ScrollOffset VisualViewport::maximumScrollOffset() const {
|
| if (!mainFrame())
|
| - return IntPoint();
|
| + return ScrollOffset();
|
|
|
| // TODO(bokan): We probably shouldn't be storing the bounds in a float. crbug.com/470718.
|
| FloatSize frameViewSize(contentsSize());
|
| @@ -572,7 +558,7 @@ DoublePoint VisualViewport::maximumScrollPositionDouble() const {
|
|
|
| FloatSize maxPosition = frameViewSize - viewportSize;
|
| maxPosition.scale(1 / m_scale);
|
| - return DoublePoint(maxPosition);
|
| + return ScrollOffset(maxPosition);
|
| }
|
|
|
| IntPoint VisualViewport::clampDocumentOffsetAtScale(const IntPoint& offset,
|
| @@ -585,16 +571,16 @@ IntPoint VisualViewport::clampDocumentOffsetAtScale(const IntPoint& offset,
|
| FloatSize scaledSize(m_size);
|
| scaledSize.scale(1 / scale);
|
|
|
| - IntPoint visualViewportMax =
|
| - flooredIntPoint(FloatSize(contentsSize()) - scaledSize);
|
| - IntPoint max = view->maximumScrollPosition() + visualViewportMax;
|
| - IntPoint min =
|
| - view->minimumScrollPosition(); // VisualViewportMin should be (0, 0)
|
| + IntSize visualViewportMax =
|
| + flooredIntSize(FloatSize(contentsSize()) - scaledSize);
|
| + IntSize max = view->maximumScrollOffsetInt() + visualViewportMax;
|
| + IntSize min =
|
| + view->minimumScrollOffsetInt(); // VisualViewportMin should be (0, 0)
|
|
|
| - IntPoint clamped = offset;
|
| + IntSize clamped = toIntSize(offset);
|
| clamped = clamped.shrunkTo(max);
|
| clamped = clamped.expandedTo(min);
|
| - return clamped;
|
| + return IntPoint(clamped);
|
| }
|
|
|
| void VisualViewport::setTopControlsAdjustment(float adjustment) {
|
| @@ -623,9 +609,9 @@ IntSize VisualViewport::contentsSize() const {
|
| return frame->view()->visibleContentRect(IncludeScrollbars).size();
|
| }
|
|
|
| -void VisualViewport::updateScrollPosition(const DoublePoint& position,
|
| - ScrollType scrollType) {
|
| - if (didSetScaleOrLocation(m_scale, toFloatPoint(position)) &&
|
| +void VisualViewport::updateScrollOffset(const ScrollOffset& position,
|
| + ScrollType scrollType) {
|
| + if (didSetScaleOrLocation(m_scale, FloatPoint(position)) &&
|
| scrollType != AnchoringScroll)
|
| notifyRootFrameViewport();
|
| }
|
| @@ -667,17 +653,8 @@ Widget* VisualViewport::getWidget() {
|
| return mainFrame()->view();
|
| }
|
|
|
| -FloatPoint VisualViewport::clampOffsetToBoundaries(const FloatPoint& offset) {
|
| - FloatPoint clampedOffset(offset);
|
| - clampedOffset =
|
| - clampedOffset.shrunkTo(FloatPoint(maximumScrollPositionDouble()));
|
| - clampedOffset =
|
| - clampedOffset.expandedTo(FloatPoint(minimumScrollPositionDouble()));
|
| - return clampedOffset;
|
| -}
|
| -
|
| void VisualViewport::clampToBoundaries() {
|
| - setLocation(m_offset);
|
| + setLocation(FloatPoint(m_offset));
|
| }
|
|
|
| FloatRect VisualViewport::viewportToRootFrame(
|
|
|