Chromium Code Reviews| Index: Source/core/frame/PinchViewport.cpp |
| diff --git a/Source/core/frame/PinchViewport.cpp b/Source/core/frame/PinchViewport.cpp |
| index 3c877332714d5e26b104395b96ea3ed1bfde8e5f..2f6a7d9068ca1e713aff7f31f6b7f78c880b60cf 100644 |
| --- a/Source/core/frame/PinchViewport.cpp |
| +++ b/Source/core/frame/PinchViewport.cpp |
| @@ -67,6 +67,7 @@ namespace blink { |
| PinchViewport::PinchViewport(FrameHost& owner) |
| : m_frameHost(owner) |
| , m_scale(1) |
| + , m_topControlsAdjustment(0) |
| { |
| reset(); |
| } |
| @@ -81,8 +82,6 @@ void PinchViewport::setSize(const IntSize& size) |
| TRACE_EVENT2("blink", "PinchViewport::setSize", "width", size.width(), "height", size.height()); |
| m_size = size; |
| - clampToBoundaries(); |
| - |
| if (m_innerViewportContainerLayer) { |
| m_innerViewportContainerLayer->setSize(m_size); |
| @@ -111,6 +110,7 @@ void PinchViewport::mainFrameDidChangeSize() |
| FloatRect PinchViewport::visibleRect() const |
| { |
| FloatSize scaledSize(m_size); |
| + scaledSize.expand(0, m_topControlsAdjustment); |
| scaledSize.scale(1 / m_scale); |
| return FloatRect(m_offset, scaledSize); |
| } |
| @@ -356,7 +356,24 @@ IntPoint PinchViewport::minimumScrollPosition() const |
| IntPoint PinchViewport::maximumScrollPosition() const |
| { |
| - return flooredIntPoint(FloatSize(contentsSize()) - visibleRect().size()); |
| + FloatSize frameViewSize(contentsSize()); |
|
Rick Byers
2014/10/10 00:06:09
not necessarily for this CL (if it's non-trivial t
bokan
2014/10/10 14:39:56
Yes, I've been following the discussion. I'll keep
|
| + |
| + // The adjustment should only be non-zero in the case of a top controls offset. |
| + // It is made to keep the aspect ratio of the two viewports the same. |
| + float aspectRatio = visibleRect().width() / visibleRect().height(); |
| + float adjustment = frameViewSize.width() / aspectRatio - frameViewSize.height(); |
| + frameViewSize.expand(0, adjustment); |
| + |
| + frameViewSize.scale(m_scale); |
| + frameViewSize = flooredIntSize(frameViewSize); |
| + |
| + FloatSize viewportSize(m_size); |
| + viewportSize.expand(0, m_topControlsAdjustment); |
| + |
| + FloatSize maxPosition = frameViewSize - viewportSize; |
| + maxPosition.scale(1 / m_scale); |
| + |
| + return flooredIntPoint(maxPosition); |
| } |
| IntPoint PinchViewport::clampDocumentOffsetAtScale(const IntPoint& offset, float scale) |
| @@ -379,6 +396,11 @@ IntPoint PinchViewport::clampDocumentOffsetAtScale(const IntPoint& offset, float |
| return clamped; |
| } |
| +void PinchViewport::setTopControlsAdjustment(float adjustment) |
| +{ |
| + m_topControlsAdjustment = adjustment; |
| +} |
| + |
| IntRect PinchViewport::scrollableAreaBoundingBox() const |
| { |
| // This method should return the bounding box in the parent view's coordinate |