| Index: cc/layer_tree_host.cc
|
| diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc
|
| index e22698635ed14a60b99a8d2eaeb5c276b6f260a1..ec272ce0a734a395a1992453ead2c51ac1a9aad8 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"
|
| @@ -328,6 +332,14 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
|
| sync_tree->ResetContentsTexturesPurged();
|
| }
|
|
|
| + sync_tree->SetPinchZoomHorizontalLayerId(
|
| + pinch_zoom_scrollbar_horizontal_ ?
|
| + pinch_zoom_scrollbar_horizontal_->id() : Layer::INVALID_ID);
|
| +
|
| + sync_tree->SetPinchZoomVerticalLayerId(
|
| + pinch_zoom_scrollbar_vertical_ ?
|
| + pinch_zoom_scrollbar_vertical_->id() : Layer::INVALID_ID);
|
| +
|
| if (!settings_.implSidePainting) {
|
| // If we're not in impl-side painting, the tree is immediately
|
| // considered active.
|
| @@ -340,8 +352,70 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
|
| commit_number_++;
|
| }
|
|
|
| +void LayerTreeHost::SetPinchZoomScrollbarsBoundsAndPosition()
|
| +{
|
| + if (!pinch_zoom_scrollbar_horizontal_ || !pinch_zoom_scrollbar_vertical_)
|
| + return;
|
| +
|
| + gfx::Size size = layout_viewport_size();
|
| + int track_width = PinchZoomScrollbarGeometry::kTrackWidth;
|
| +
|
| + pinch_zoom_scrollbar_horizontal_->SetBounds(
|
| + gfx::Size(size.width() - track_width, track_width));
|
| + pinch_zoom_scrollbar_horizontal_->SetPosition(
|
| + gfx::PointF(0, size.height() - track_width));
|
| +
|
| + pinch_zoom_scrollbar_vertical_->SetBounds(
|
| + gfx::Size(track_width, size.height() - track_width));
|
| + pinch_zoom_scrollbar_vertical_->SetPosition(
|
| + gfx::PointF(size.width() - track_width, 0));
|
| +}
|
| +
|
| +static scoped_refptr<ScrollbarLayer> CreatePinchZoomScrollbar(
|
| + WebKit::WebScrollbar::Orientation orientation, LayerTreeHost* owner)
|
| +{
|
| + scoped_refptr<ScrollbarLayer> scrollbar_layer = 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);
|
| + scrollbar_layer->SetIsDrawable(true);
|
| + scrollbar_layer->SetOpacity(0.f);
|
| + return scrollbar_layer;
|
| +}
|
| +
|
| +void LayerTreeHost::CreateAndAddPinchZoomScrollbars()
|
| +{
|
| + bool needs_properties_updated = false;
|
| +
|
| + if (!pinch_zoom_scrollbar_horizontal_ || !pinch_zoom_scrollbar_vertical_) {
|
| + pinch_zoom_scrollbar_horizontal_ =
|
| + CreatePinchZoomScrollbar(WebKit::WebScrollbar::Horizontal, this);
|
| + pinch_zoom_scrollbar_vertical_ =
|
| + CreatePinchZoomScrollbar( WebKit::WebScrollbar::Vertical, this);
|
| + needs_properties_updated = true;
|
| + }
|
| +
|
| + DCHECK(pinch_zoom_scrollbar_horizontal_ && pinch_zoom_scrollbar_vertical_);
|
| +
|
| + if (!pinch_zoom_scrollbar_horizontal_->parent())
|
| + root_layer_->AddChild(pinch_zoom_scrollbar_horizontal_);
|
| +
|
| + if (!pinch_zoom_scrollbar_vertical_->parent())
|
| + root_layer_->AddChild(pinch_zoom_scrollbar_vertical_);
|
| +
|
| + if (needs_properties_updated)
|
| + SetPinchZoomScrollbarsBoundsAndPosition();
|
| +}
|
| +
|
| void LayerTreeHost::WillCommit() {
|
| client_->willCommit();
|
| +
|
| + if (settings().usePinchZoomScrollbars)
|
| + CreateAndAddPinchZoomScrollbars();
|
| }
|
|
|
| void LayerTreeHost::UpdateHudLayer() {
|
| @@ -470,6 +544,12 @@ void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) {
|
| if (hud_layer_)
|
| hud_layer_->RemoveFromParent();
|
|
|
| + if (pinch_zoom_scrollbar_horizontal_)
|
| + pinch_zoom_scrollbar_horizontal_->RemoveFromParent();
|
| +
|
| + if (pinch_zoom_scrollbar_vertical_)
|
| + pinch_zoom_scrollbar_vertical_->RemoveFromParent();
|
| +
|
| SetNeedsFullTreeSync();
|
| }
|
|
|
| @@ -493,6 +573,7 @@ void LayerTreeHost::SetViewportSize(gfx::Size layout_viewport_size,
|
| layout_viewport_size_ = layout_viewport_size;
|
| device_viewport_size_ = device_viewport_size;
|
|
|
| + SetPinchZoomScrollbarsBoundsAndPosition();
|
| SetNeedsCommit();
|
| }
|
|
|
| @@ -584,6 +665,10 @@ static Layer* FindFirstScrollableLayer(Layer* layer) {
|
| return NULL;
|
| }
|
|
|
| +const Layer* LayerTreeHost::RootScrollLayer() const {
|
| + return FindFirstScrollableLayer(root_layer_.get());
|
| +}
|
| +
|
| void LayerTreeHost::UpdateLayers(Layer* root_layer,
|
| ResourceUpdateQueue* queue) {
|
| TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers");
|
|
|