| Index: cc/layer_tree_host.cc
|
| diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc
|
| index cc08d55e19ad9c6f76a6fd9ab24871d61bd3e94d..dfc909a605a395a2bc79139b5d696d6e7ef63c7d 100644
|
| --- a/cc/layer_tree_host.cc
|
| +++ b/cc/layer_tree_host.cc
|
| @@ -23,7 +23,10 @@
|
| #include "cc/math_util.h"
|
| #include "cc/occlusion_tracker.h"
|
| #include "cc/overdraw_metrics.h"
|
| +#include "cc/pinch_zoom_scrollbar.h"
|
| +#include "cc/pinch_zoom_scrollbar_painter.h"
|
| #include "cc/prioritized_resource_manager.h"
|
| +#include "cc/scrollbar_layer.h"
|
| #include "cc/single_thread_proxy.h"
|
| #include "cc/switches.h"
|
| #include "cc/thread.h"
|
| @@ -332,6 +335,30 @@ void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl)
|
| m_commitNumber++;
|
| }
|
|
|
| +void LayerTreeHost::setPinchZoomScrollbarPropertiesIfNeeded()
|
| +{
|
| + gfx::Size size = layoutViewportSize();
|
| + int trackWidth = PinchZoomScrollbar::kTrackWidth;
|
| + Layer* rootScrollLayer = this->rootScrollLayer();
|
| + int rootScrollLayerId = rootScrollLayer ? rootScrollLayer->id() : 0;
|
| + if (m_pinchZoomScrollbarHorizontal) {
|
| + m_pinchZoomScrollbarHorizontal->setBounds(gfx::Size(size.width() - trackWidth, trackWidth));
|
| + m_pinchZoomScrollbarHorizontal->setPosition(gfx::PointF(0, size.height() - trackWidth));
|
| + m_pinchZoomScrollbarHorizontal->setIsDrawable(true);
|
| + m_pinchZoomScrollbarHorizontal->setOpacity(0.5);
|
| + m_pinchZoomScrollbarHorizontal->setNeedsDisplay();
|
| + m_pinchZoomScrollbarHorizontal->setScrollLayerId(rootScrollLayerId);
|
| + }
|
| + if (m_pinchZoomScrollbarVertical) {
|
| + m_pinchZoomScrollbarVertical->setBounds(gfx::Size(10, size.height() - 10));
|
| + m_pinchZoomScrollbarVertical->setPosition(gfx::PointF(size.width() - 10, 0));
|
| + m_pinchZoomScrollbarVertical->setIsDrawable(true);
|
| + m_pinchZoomScrollbarVertical->setOpacity(0.5);
|
| + m_pinchZoomScrollbarVertical->setNeedsDisplay();
|
| + m_pinchZoomScrollbarVertical->setScrollLayerId(rootScrollLayerId);
|
| + }
|
| +}
|
| +
|
| void LayerTreeHost::willCommit()
|
| {
|
| m_client->willCommit();
|
| @@ -349,6 +376,36 @@ void LayerTreeHost::willCommit()
|
| m_hudLayer->removeFromParent();
|
| m_hudLayer = 0;
|
| }
|
| +
|
| + // Setup pinch-zoom scrollbars if required.
|
| + if (m_settings.pageScalePinchZoomEnabled && rootScrollLayer() &&
|
| + !ScrollbarLayer::defaultUsesOverlayScrollbars()) {
|
| + if (!m_pinchZoomScrollbarHorizontal)
|
| + m_pinchZoomScrollbarHorizontal = ScrollbarLayer::create(
|
| + make_scoped_ptr(
|
| + new PinchZoomScrollbar(
|
| + WebKit::WebScrollbar::Horizontal, this)).PassAs<WebKit::WebScrollbar>(),
|
| + make_scoped_ptr(new PinchZoomScrollbarPainter).PassAs<ScrollbarThemePainter>(),
|
| + 0);
|
| +
|
| + DCHECK(m_pinchZoomScrollbarHorizontal);
|
| + if (!m_pinchZoomScrollbarHorizontal->parent())
|
| + m_rootLayer->addChild(m_pinchZoomScrollbarHorizontal);
|
| +
|
| + if (!m_pinchZoomScrollbarVertical)
|
| + m_pinchZoomScrollbarVertical = ScrollbarLayer::create(
|
| + make_scoped_ptr(
|
| + new PinchZoomScrollbar(
|
| + WebKit::WebScrollbar::Vertical, this)).PassAs<WebKit::WebScrollbar>(),
|
| + make_scoped_ptr(new PinchZoomScrollbarPainter).PassAs<ScrollbarThemePainter>(),
|
| + 0);
|
| +
|
| + DCHECK(m_pinchZoomScrollbarVertical);
|
| + if (!m_pinchZoomScrollbarVertical->parent())
|
| + m_rootLayer->addChild(m_pinchZoomScrollbarVertical);
|
| +
|
| + setPinchZoomScrollbarPropertiesIfNeeded();
|
| + }
|
| }
|
|
|
| void LayerTreeHost::commitComplete()
|
| @@ -491,6 +548,7 @@ void LayerTreeHost::setViewportSize(const gfx::Size& layoutViewportSize, const g
|
| m_layoutViewportSize = layoutViewportSize;
|
| m_deviceViewportSize = deviceViewportSize;
|
|
|
| + setPinchZoomScrollbarPropertiesIfNeeded();
|
| setNeedsCommit();
|
| }
|
|
|
| @@ -584,6 +642,11 @@ static Layer* findFirstScrollableLayer(Layer* layer)
|
| return 0;
|
| }
|
|
|
| +Layer* LayerTreeHost::rootScrollLayer() const
|
| +{
|
| + return findFirstScrollableLayer(m_rootLayer.get());
|
| +}
|
| +
|
| void LayerTreeHost::updateLayers(Layer* rootLayer, ResourceUpdateQueue& queue)
|
| {
|
| TRACE_EVENT0("cc", "LayerTreeHost::updateLayers");
|
|
|