| Index: cc/layer_tree_host.cc
|
| diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc
|
| index c4e8dd43c6925406fe7273923314edcd073609f1..658512e7b09ca05b6088a16c102a8e65d4166e1c 100644
|
| --- a/cc/layer_tree_host.cc
|
| +++ b/cc/layer_tree_host.cc
|
| @@ -23,7 +23,11 @@
|
| #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_geometry.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"
|
| @@ -327,6 +331,13 @@ void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl)
|
| syncTree->ResetContentsTexturesPurged();
|
| }
|
|
|
| + syncTree->SetPinchZoomHorizontalLayerId(
|
| + m_pinchZoomScrollbarHorizontal ? m_pinchZoomScrollbarHorizontal->id() :
|
| + Layer::INVALID_ID);
|
| + syncTree->SetPinchZoomVerticalLayerId(
|
| + m_pinchZoomScrollbarVertical ? m_pinchZoomScrollbarVertical->id() :
|
| + Layer::INVALID_ID);
|
| +
|
| if (!m_settings.implSidePainting) {
|
| // If we're not in impl-side painting, the tree is immediately
|
| // considered active.
|
| @@ -339,9 +350,64 @@ void LayerTreeHost::finishCommitOnImplThread(LayerTreeHostImpl* hostImpl)
|
| m_commitNumber++;
|
| }
|
|
|
| +void LayerTreeHost::setPinchZoomScrollbarsBoundsAndPosition()
|
| +{
|
| + if (!m_pinchZoomScrollbarHorizontal || !m_pinchZoomScrollbarVertical)
|
| + return;
|
| +
|
| + gfx::Size size = layoutViewportSize();
|
| + int trackWidth = PinchZoomScrollbarGeometry::kTrackWidth;
|
| +
|
| + m_pinchZoomScrollbarHorizontal->SetBounds(gfx::Size(size.width() - trackWidth, trackWidth));
|
| + m_pinchZoomScrollbarHorizontal->SetPosition(gfx::PointF(0, size.height() - trackWidth));
|
| +
|
| + m_pinchZoomScrollbarVertical->SetBounds(gfx::Size(trackWidth, size.height() - trackWidth));
|
| + m_pinchZoomScrollbarVertical->SetPosition(gfx::PointF(size.width() - trackWidth, 0));
|
| +}
|
| +
|
| +static scoped_refptr<ScrollbarLayer> CreatePinchZoomScrollbar(
|
| + WebKit::WebScrollbar::Orientation orientation, LayerTreeHost* owner)
|
| +{
|
| + scoped_refptr<ScrollbarLayer> scrollbarLayer = ScrollbarLayer::Create(
|
| + make_scoped_ptr(
|
| + new PinchZoomScrollbar(orientation, owner)).PassAs<WebKit::WebScrollbar>(),
|
| + scoped_ptr<ScrollbarThemePainter>(new PinchZoomScrollbarPainter).Pass(),
|
| + scoped_ptr<WebKit::WebScrollbarThemeGeometry>(
|
| + new PinchZoomScrollbarGeometry).Pass(),
|
| + Layer::PINCH_ZOOM_ROOT_SCROLL_LAYER_ID);
|
| + scrollbarLayer->SetIsDrawable(true);
|
| + scrollbarLayer->SetOpacity(0.f);
|
| + return scrollbarLayer;
|
| +}
|
| +
|
| +void LayerTreeHost::createAndAddPinchZoomScrollbars()
|
| +{
|
| + bool needsPropertiesUpdated = false;
|
| +
|
| + if (!m_pinchZoomScrollbarHorizontal || !m_pinchZoomScrollbarVertical) {
|
| + m_pinchZoomScrollbarHorizontal = CreatePinchZoomScrollbar(WebKit::WebScrollbar::Horizontal, this);
|
| + m_pinchZoomScrollbarVertical = CreatePinchZoomScrollbar( WebKit::WebScrollbar::Vertical, this);
|
| + needsPropertiesUpdated = true;
|
| + }
|
| +
|
| + DCHECK(m_pinchZoomScrollbarHorizontal && m_pinchZoomScrollbarVertical);
|
| +
|
| + if (!m_pinchZoomScrollbarHorizontal->parent())
|
| + m_rootLayer->AddChild(m_pinchZoomScrollbarHorizontal);
|
| +
|
| + if (!m_pinchZoomScrollbarVertical->parent())
|
| + m_rootLayer->AddChild(m_pinchZoomScrollbarVertical);
|
| +
|
| + if (needsPropertiesUpdated)
|
| + setPinchZoomScrollbarsBoundsAndPosition();
|
| +}
|
| +
|
| void LayerTreeHost::willCommit()
|
| {
|
| m_client->willCommit();
|
| +
|
| + if (m_settings.usePinchZoomScrollbars)
|
| + createAndAddPinchZoomScrollbars();
|
| }
|
|
|
| void LayerTreeHost::updateHudLayer()
|
| @@ -480,6 +546,12 @@ void LayerTreeHost::setRootLayer(scoped_refptr<Layer> rootLayer)
|
| if (m_hudLayer)
|
| m_hudLayer->RemoveFromParent();
|
|
|
| + if (m_pinchZoomScrollbarHorizontal)
|
| + m_pinchZoomScrollbarHorizontal->RemoveFromParent();
|
| +
|
| + if (m_pinchZoomScrollbarVertical)
|
| + m_pinchZoomScrollbarVertical->RemoveFromParent();
|
| +
|
| setNeedsFullTreeSync();
|
| }
|
|
|
| @@ -502,6 +574,7 @@ void LayerTreeHost::setViewportSize(const gfx::Size& layoutViewportSize, const g
|
| m_layoutViewportSize = layoutViewportSize;
|
| m_deviceViewportSize = deviceViewportSize;
|
|
|
| + setPinchZoomScrollbarsBoundsAndPosition();
|
| setNeedsCommit();
|
| }
|
|
|
| @@ -595,6 +668,11 @@ static Layer* findFirstScrollableLayer(Layer* layer)
|
| return 0;
|
| }
|
|
|
| +const Layer* LayerTreeHost::rootScrollLayer() const
|
| +{
|
| + return findFirstScrollableLayer(m_rootLayer.get());
|
| +}
|
| +
|
| void LayerTreeHost::updateLayers(Layer* rootLayer, ResourceUpdateQueue& queue)
|
| {
|
| TRACE_EVENT0("cc", "LayerTreeHost::updateLayers");
|
|
|