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

Unified Diff: Source/core/frame/PinchViewport.cpp

Issue 643473002: Made top controls work with virtual viewport pinch-to-zoom. (Blink) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed mac breakage (UseMockScrollbars) Created 6 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
« no previous file with comments | « Source/core/frame/PinchViewport.h ('k') | Source/web/PageScaleConstraintsSet.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/PinchViewport.cpp
diff --git a/Source/core/frame/PinchViewport.cpp b/Source/core/frame/PinchViewport.cpp
index 2c1bc055f5171ea4af3b7277212afb360887dc45..95e9054d34a3fc81ebda13cab38c9815f57bf6e9 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();
}
@@ -88,8 +89,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);
@@ -118,6 +117,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);
}
@@ -365,7 +365,25 @@ IntPoint PinchViewport::minimumScrollPosition() const
IntPoint PinchViewport::maximumScrollPosition() const
{
- return flooredIntPoint(FloatSize(contentsSize()) - visibleRect().size());
+ // FIXME: We probably shouldn't be storing the bounds in a float. crbug.com/422331.
+ FloatSize frameViewSize(contentsSize());
+
+ if (m_topControlsAdjustment) {
+ 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)
@@ -388,6 +406,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
« no previous file with comments | « Source/core/frame/PinchViewport.h ('k') | Source/web/PageScaleConstraintsSet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698