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

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

Issue 640063002: Hide scrollbars when their dimensions are not scrollable. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/WebViewImpl.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 3c877332714d5e26b104395b96ea3ed1bfde8e5f..4129038aaab26cd72ad21f27d1e5d0a8168bcee9 100644
--- a/Source/core/frame/PinchViewport.cpp
+++ b/Source/core/frame/PinchViewport.cpp
@@ -67,6 +67,8 @@ namespace blink {
PinchViewport::PinchViewport(FrameHost& owner)
: m_frameHost(owner)
, m_scale(1)
+ , m_hasHorizontalScrollbar(false)
+ , m_hasVerticalScrollbar(false)
{
reset();
}
@@ -159,6 +161,7 @@ void PinchViewport::move(const FloatPoint& delta)
void PinchViewport::setScale(float scale)
{
setScaleAndLocation(scale, m_offset);
+ adjustScrollbarExistence();
bokan 2014/10/09 15:22:14 Should we also call this in setSize?
}
void PinchViewport::setScaleAndLocation(float scale, const FloatPoint& location)
@@ -314,6 +317,32 @@ void PinchViewport::setupScrollbar(WebScrollbar::Orientation orientation)
scrollbarGraphicsLayer->setContentsRect(IntRect(0, 0, width, height));
}
+void PinchViewport::adjustScrollbarExistence()
+{
+ IntSize visibleSize = enclosingIntRect(visibleRect()).size();
+
+ ASSERT(mainFrame());
+ ASSERT(mainFrame()->contentRenderer());
+ IntSize documentSize = mainFrame()->contentRenderer()->documentRect().size();
+
+ bool oldHasHorizontal = m_hasHorizontalScrollbar;
+ bool oldHasVertical = m_hasVerticalScrollbar;
+ m_hasHorizontalScrollbar = visibleSize.width() < documentSize.width();
+ m_hasVerticalScrollbar = visibleSize.height() < documentSize.height();
bokan 2014/10/09 15:22:14 Rather than comparing the sizes yourself here, jus
+
+ if (oldHasHorizontal != m_hasHorizontalScrollbar || oldHasVertical != m_hasVerticalScrollbar) {
+ GraphicsLayerVector children;
+ children.append(m_pageScaleLayer.get());
+
+ if (m_hasHorizontalScrollbar)
+ children.append(m_overlayScrollbarHorizontal.get());
+ if (m_hasVerticalScrollbar)
+ children.append(m_overlayScrollbarVertical.get());
+
+ m_innerViewportContainerLayer->setChildren(children);
bokan 2014/10/09 15:22:14 Hmm...I'm not sure what the implications of freque
+ }
+}
+
void PinchViewport::registerLayersWithTreeView(WebLayerTreeView* layerTreeView) const
{
TRACE_EVENT0("blink", "PinchViewport::registerLayersWithTreeView");
@@ -427,12 +456,12 @@ GraphicsLayer* PinchViewport::layerForScrolling() const
GraphicsLayer* PinchViewport::layerForHorizontalScrollbar() const
{
- return m_overlayScrollbarHorizontal.get();
+ return m_hasHorizontalScrollbar ? m_overlayScrollbarHorizontal.get() : nullptr;
}
GraphicsLayer* PinchViewport::layerForVerticalScrollbar() const
{
- return m_overlayScrollbarVertical.get();
+ return m_hasVerticalScrollbar ? m_overlayScrollbarVertical.get() : nullptr;
}
void PinchViewport::notifyAnimationStarted(const GraphicsLayer*, double monotonicTime)
« no previous file with comments | « Source/core/frame/PinchViewport.h ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698