| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/blink/web_scrollbar_layer_impl.h" | 5 #include "cc/blink/web_scrollbar_layer_impl.h" |
| 6 | 6 |
| 7 #include "cc/blink/scrollbar_impl.h" | 7 #include "cc/blink/scrollbar_impl.h" |
| 8 #include "cc/blink/web_layer_impl.h" | 8 #include "cc/blink/web_layer_impl.h" |
| 9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
| 10 #include "cc/layers/layer_settings.h" | |
| 11 #include "cc/layers/painted_scrollbar_layer.h" | 10 #include "cc/layers/painted_scrollbar_layer.h" |
| 12 #include "cc/layers/scrollbar_layer_interface.h" | 11 #include "cc/layers/scrollbar_layer_interface.h" |
| 13 #include "cc/layers/solid_color_scrollbar_layer.h" | 12 #include "cc/layers/solid_color_scrollbar_layer.h" |
| 14 | 13 |
| 15 using cc::PaintedScrollbarLayer; | 14 using cc::PaintedScrollbarLayer; |
| 16 using cc::SolidColorScrollbarLayer; | 15 using cc::SolidColorScrollbarLayer; |
| 17 | 16 |
| 18 namespace { | 17 namespace { |
| 19 | 18 |
| 20 cc::ScrollbarOrientation ConvertOrientation( | 19 cc::ScrollbarOrientation ConvertOrientation( |
| 21 blink::WebScrollbar::Orientation orientation) { | 20 blink::WebScrollbar::Orientation orientation) { |
| 22 return orientation == blink::WebScrollbar::Horizontal ? cc::HORIZONTAL | 21 return orientation == blink::WebScrollbar::Horizontal ? cc::HORIZONTAL |
| 23 : cc::VERTICAL; | 22 : cc::VERTICAL; |
| 24 } | 23 } |
| 25 | 24 |
| 26 } // namespace | 25 } // namespace |
| 27 | 26 |
| 28 namespace cc_blink { | 27 namespace cc_blink { |
| 29 | 28 |
| 30 WebScrollbarLayerImpl::WebScrollbarLayerImpl( | 29 WebScrollbarLayerImpl::WebScrollbarLayerImpl( |
| 31 blink::WebScrollbar* scrollbar, | 30 blink::WebScrollbar* scrollbar, |
| 32 blink::WebScrollbarThemePainter painter, | 31 blink::WebScrollbarThemePainter painter, |
| 33 blink::WebScrollbarThemeGeometry* geometry) | 32 blink::WebScrollbarThemeGeometry* geometry) |
| 34 : layer_(new WebLayerImpl(PaintedScrollbarLayer::Create( | 33 : layer_(new WebLayerImpl(PaintedScrollbarLayer::Create( |
| 35 cc::LayerSettings(), | 34 |
| 36 scoped_ptr<cc::Scrollbar>( | 35 scoped_ptr<cc::Scrollbar>( |
| 37 new ScrollbarImpl(make_scoped_ptr(scrollbar), | 36 new ScrollbarImpl(make_scoped_ptr(scrollbar), |
| 38 painter, | 37 painter, |
| 39 make_scoped_ptr(geometry))), | 38 make_scoped_ptr(geometry))), |
| 40 0))) {} | 39 0))) {} |
| 41 | 40 |
| 42 WebScrollbarLayerImpl::WebScrollbarLayerImpl( | 41 WebScrollbarLayerImpl::WebScrollbarLayerImpl( |
| 43 blink::WebScrollbar::Orientation orientation, | 42 blink::WebScrollbar::Orientation orientation, |
| 44 int thumb_thickness, | 43 int thumb_thickness, |
| 45 int track_start, | 44 int track_start, |
| 46 bool is_left_side_vertical_scrollbar) | 45 bool is_left_side_vertical_scrollbar) |
| 47 : layer_(new WebLayerImpl( | 46 : layer_(new WebLayerImpl( |
| 48 SolidColorScrollbarLayer::Create(cc::LayerSettings(), | 47 SolidColorScrollbarLayer::Create(ConvertOrientation(orientation), |
| 49 ConvertOrientation(orientation), | |
| 50 thumb_thickness, | 48 thumb_thickness, |
| 51 track_start, | 49 track_start, |
| 52 is_left_side_vertical_scrollbar, | 50 is_left_side_vertical_scrollbar, |
| 53 0))) {} | 51 0))) {} |
| 54 | 52 |
| 55 WebScrollbarLayerImpl::~WebScrollbarLayerImpl() { | 53 WebScrollbarLayerImpl::~WebScrollbarLayerImpl() { |
| 56 } | 54 } |
| 57 | 55 |
| 58 blink::WebLayer* WebScrollbarLayerImpl::layer() { | 56 blink::WebLayer* WebScrollbarLayerImpl::layer() { |
| 59 return layer_.get(); | 57 return layer_.get(); |
| 60 } | 58 } |
| 61 | 59 |
| 62 void WebScrollbarLayerImpl::setScrollLayer(blink::WebLayer* layer) { | 60 void WebScrollbarLayerImpl::setScrollLayer(blink::WebLayer* layer) { |
| 63 cc::Layer* scroll_layer = | 61 cc::Layer* scroll_layer = |
| 64 layer ? static_cast<WebLayerImpl*>(layer)->layer() : 0; | 62 layer ? static_cast<WebLayerImpl*>(layer)->layer() : 0; |
| 65 layer_->layer()->ToScrollbarLayer()->SetScrollLayer( | 63 layer_->layer()->ToScrollbarLayer()->SetScrollLayer( |
| 66 scroll_layer ? scroll_layer->id() : cc::Layer::INVALID_ID); | 64 scroll_layer ? scroll_layer->id() : cc::Layer::INVALID_ID); |
| 67 } | 65 } |
| 68 | 66 |
| 69 } // namespace cc_blink | 67 } // namespace cc_blink |
| OLD | NEW |