| Index: Source/core/frame/PinchViewport.cpp
|
| diff --git a/Source/core/frame/PinchViewport.cpp b/Source/core/frame/PinchViewport.cpp
|
| index 8cb90bdf3d23ebd7d6c687171dd226e4d2e48d8c..d8bea70e8458612fe2e1ad344e6de7978970eca0 100644
|
| --- a/Source/core/frame/PinchViewport.cpp
|
| +++ b/Source/core/frame/PinchViewport.cpp
|
| @@ -170,7 +170,7 @@ void PinchViewport::move(const FloatPoint& delta)
|
| setLocation(m_offset + delta);
|
| }
|
|
|
| -void PinchViewport::setScale(float scale)
|
| +void PinchViewport::setScaleWithoutClampingViewportOffset(float scale)
|
| {
|
| if (scale == m_scale)
|
| return;
|
| @@ -185,13 +185,18 @@ void PinchViewport::setScale(float scale)
|
| if (!m_innerViewportScrollLayer)
|
| return;
|
|
|
| - // Ensure we clamp so we remain within the bounds.
|
| - setLocation(visibleRect().location());
|
| -
|
| // TODO: We should probably be calling scaleDidChange type functions here.
|
| // see Page::setPageScaleFactor.
|
| }
|
|
|
| +void PinchViewport::setScale(float scale)
|
| +{
|
| + setScaleWithoutClampingViewportOffset(scale);
|
| +
|
| + // Ensure we clamp so we remain within the bounds.
|
| + setLocation(visibleRect().location());
|
| +}
|
| +
|
| // Modifies the top of the graphics layer tree to add layers needed to support
|
| // the inner/outer viewport fixed-position model for pinch zoom. When finished,
|
| // the tree will look like this (with * denoting added layers):
|
| @@ -351,6 +356,26 @@ IntPoint PinchViewport::maximumScrollPosition() const
|
| return flooredIntPoint(FloatSize(contentsSize()) - visibleRect().size());
|
| }
|
|
|
| +IntPoint PinchViewport::clampDocumentOffsetAtScale(const IntPoint& offset, float scale)
|
| +{
|
| + if (!mainFrame() || !mainFrame()->view())
|
| + return IntPoint();
|
| +
|
| + FrameView* view = mainFrame()->view();
|
| +
|
| + FloatSize scaledSize(m_size);
|
| + scaledSize.scale(1 / scale);
|
| +
|
| + IntPoint pinchViewportMax = flooredIntPoint(FloatSize(contentsSize()) - scaledSize);
|
| + IntPoint max = view->maximumScrollPosition() + pinchViewportMax;
|
| + IntPoint min = view->minimumScrollPosition(); // PinchViewportMin should be (0, 0)
|
| +
|
| + IntPoint clamped = offset;
|
| + clamped = clamped.shrunkTo(max);
|
| + clamped = clamped.expandedTo(min);
|
| + return clamped;
|
| +}
|
| +
|
| IntRect PinchViewport::scrollableAreaBoundingBox() const
|
| {
|
| // This method should return the bounding box in the parent view's coordinate
|
|
|