Index: cc/layer_tree_impl.cc |
diff --git a/cc/layer_tree_impl.cc b/cc/layer_tree_impl.cc |
index f16ec0035e93d2d3e7b66be833c00fdac28fa69e..c5a5035440157571d342cb867f9d25ae14e9cbb9 100644 |
--- a/cc/layer_tree_impl.cc |
+++ b/cc/layer_tree_impl.cc |
@@ -8,6 +8,7 @@ |
#include "cc/heads_up_display_layer_impl.h" |
#include "cc/layer_tree_host_common.h" |
#include "cc/layer_tree_host_impl.h" |
+#include "cc/scrollbar_layer_impl.h" |
#include "ui/gfx/vector2d_conversions.h" |
namespace cc { |
@@ -116,6 +117,9 @@ void LayerTreeImpl::pushPropertiesTo(LayerTreeImpl* target_tree) { |
target_tree->RootLayer(), hud_layer()->id()))); |
else |
target_tree->set_hud_layer(NULL); |
+ |
+ target_tree->SetPinchZoomHorizontalLayerId(pinch_zoom_scrollbar_horizontal_layer_id); |
+ target_tree->SetPinchZoomVerticalLayerId(pinch_zoom_scrollbar_vertical_layer_id); |
} |
LayerImpl* LayerTreeImpl::RootScrollLayer() { |
@@ -486,4 +490,54 @@ scoped_ptr<base::Value> LayerTreeImpl::AsValue() const { |
return state.PassAs<base::Value>(); |
} |
+void LayerTreeImpl::SetPinchZoomHorizontalLayerId(int layer_id) { |
+ pinch_zoom_scrollbar_horizontal_layer_id = layer_id; |
+} |
+ |
+ScrollbarLayerImpl* LayerTreeImpl::PinchZoomScrollbarHorizontal() { |
+ return static_cast<ScrollbarLayerImpl*>(LayerById( |
+ pinch_zoom_scrollbar_horizontal_layer_id)); |
+} |
+ |
+void LayerTreeImpl::SetPinchZoomVerticalLayerId(int layer_id) { |
+ pinch_zoom_scrollbar_vertical_layer_id = layer_id; |
+} |
+ |
+ScrollbarLayerImpl* LayerTreeImpl::PinchZoomScrollbarVertical() { |
+ return static_cast<ScrollbarLayerImpl*>(LayerById( |
+ pinch_zoom_scrollbar_vertical_layer_id)); |
+} |
+ |
+void LayerTreeImpl::UpdatePinchZoomScrollbarsIfNeeded() { |
+ LayerImpl* rootScrollLayer = RootScrollLayer(); |
+ if (!rootScrollLayer || (rootScrollLayer != CurrentlyScrollingLayer())) |
+ return; |
+ |
+ if (ScrollbarLayerImpl* scrollbar = PinchZoomScrollbarHorizontal()) { |
+ scrollbar->setCurrentPos(rootScrollLayer->scrollOffset().x()); |
+ scrollbar->setTotalSize(rootScrollLayer->bounds().width()); |
+ scrollbar->setMaximum(rootScrollLayer->maxScrollOffset().x()); |
+ } |
+ if (ScrollbarLayerImpl* scrollbar = PinchZoomScrollbarVertical()) { |
+ scrollbar->setCurrentPos(rootScrollLayer->scrollOffset().y()); |
+ scrollbar->setTotalSize(rootScrollLayer->bounds().height()); |
+ scrollbar->setMaximum(rootScrollLayer->maxScrollOffset().y()); |
+ } |
+} |
+ |
+void LayerTreeImpl::SetPinchZoomScrollbarsVisibility() { |
+ LayerImpl* rootScrollLayer = RootScrollLayer(); |
+ bool pinchZoomScrollbarShouldDraw = rootScrollLayer && |
+ rootScrollLayer == CurrentlyScrollingLayer() && |
+ total_page_scale_factor() > 1; |
+ |
+ float opacity = pinchZoomScrollbarShouldDraw ? 0.5 : 0; |
jamesr
2013/02/26 20:48:46
0.5 seems like another magical value - where does
wjmaclean
2013/03/01 15:30:32
Fixed.
|
+ |
+ if (ScrollbarLayerImpl* scrollbar = PinchZoomScrollbarHorizontal()) |
+ scrollbar->setOpacity(opacity); |
+ |
+ if (ScrollbarLayerImpl* scrollbar = PinchZoomScrollbarVertical()) |
+ scrollbar->setOpacity(opacity); |
+} |
+ |
} // namespace cc |