| 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" |
| 10 #include "cc/layers/painted_scrollbar_layer.h" | 11 #include "cc/layers/painted_scrollbar_layer.h" |
| 11 #include "cc/layers/scrollbar_layer_interface.h" | 12 #include "cc/layers/scrollbar_layer_interface.h" |
| 12 #include "cc/layers/solid_color_scrollbar_layer.h" | 13 #include "cc/layers/solid_color_scrollbar_layer.h" |
| 13 | 14 |
| 14 using cc::PaintedScrollbarLayer; | 15 using cc::PaintedScrollbarLayer; |
| 15 using cc::SolidColorScrollbarLayer; | 16 using cc::SolidColorScrollbarLayer; |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 cc::ScrollbarOrientation ConvertOrientation( | 20 cc::ScrollbarOrientation ConvertOrientation( |
| 20 blink::WebScrollbar::Orientation orientation) { | 21 blink::WebScrollbar::Orientation orientation) { |
| 21 return orientation == blink::WebScrollbar::Horizontal ? cc::HORIZONTAL | 22 return orientation == blink::WebScrollbar::Horizontal ? cc::HORIZONTAL |
| 22 : cc::VERTICAL; | 23 : cc::VERTICAL; |
| 23 } | 24 } |
| 24 | 25 |
| 25 } // namespace | 26 } // namespace |
| 26 | 27 |
| 27 namespace cc_blink { | 28 namespace cc_blink { |
| 28 | 29 |
| 29 WebScrollbarLayerImpl::WebScrollbarLayerImpl( | 30 WebScrollbarLayerImpl::WebScrollbarLayerImpl( |
| 30 blink::WebScrollbar* scrollbar, | 31 blink::WebScrollbar* scrollbar, |
| 31 blink::WebScrollbarThemePainter painter, | 32 blink::WebScrollbarThemePainter painter, |
| 32 blink::WebScrollbarThemeGeometry* geometry) | 33 blink::WebScrollbarThemeGeometry* geometry) |
| 33 : layer_(new WebLayerImpl(PaintedScrollbarLayer::Create( | 34 : layer_(new WebLayerImpl(PaintedScrollbarLayer::Create( |
| 34 WebLayerImpl::LayerSettings(), | 35 cc::LayerSettings(), |
| 35 scoped_ptr<cc::Scrollbar>( | 36 scoped_ptr<cc::Scrollbar>( |
| 36 new ScrollbarImpl(make_scoped_ptr(scrollbar), | 37 new ScrollbarImpl(make_scoped_ptr(scrollbar), |
| 37 painter, | 38 painter, |
| 38 make_scoped_ptr(geometry))), | 39 make_scoped_ptr(geometry))), |
| 39 0))) {} | 40 0))) {} |
| 40 | 41 |
| 41 WebScrollbarLayerImpl::WebScrollbarLayerImpl( | 42 WebScrollbarLayerImpl::WebScrollbarLayerImpl( |
| 42 blink::WebScrollbar::Orientation orientation, | 43 blink::WebScrollbar::Orientation orientation, |
| 43 int thumb_thickness, | 44 int thumb_thickness, |
| 44 int track_start, | 45 int track_start, |
| 45 bool is_left_side_vertical_scrollbar) | 46 bool is_left_side_vertical_scrollbar) |
| 46 : layer_(new WebLayerImpl( | 47 : layer_(new WebLayerImpl( |
| 47 SolidColorScrollbarLayer::Create(WebLayerImpl::LayerSettings(), | 48 SolidColorScrollbarLayer::Create(cc::LayerSettings(), |
| 48 ConvertOrientation(orientation), | 49 ConvertOrientation(orientation), |
| 49 thumb_thickness, | 50 thumb_thickness, |
| 50 track_start, | 51 track_start, |
| 51 is_left_side_vertical_scrollbar, | 52 is_left_side_vertical_scrollbar, |
| 52 0))) { | 53 0))) {} |
| 53 } | |
| 54 | 54 |
| 55 WebScrollbarLayerImpl::~WebScrollbarLayerImpl() { | 55 WebScrollbarLayerImpl::~WebScrollbarLayerImpl() { |
| 56 } | 56 } |
| 57 | 57 |
| 58 blink::WebLayer* WebScrollbarLayerImpl::layer() { | 58 blink::WebLayer* WebScrollbarLayerImpl::layer() { |
| 59 return layer_.get(); | 59 return layer_.get(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void WebScrollbarLayerImpl::setScrollLayer(blink::WebLayer* layer) { | 62 void WebScrollbarLayerImpl::setScrollLayer(blink::WebLayer* layer) { |
| 63 cc::Layer* scroll_layer = | 63 cc::Layer* scroll_layer = |
| 64 layer ? static_cast<WebLayerImpl*>(layer)->layer() : 0; | 64 layer ? static_cast<WebLayerImpl*>(layer)->layer() : 0; |
| 65 layer_->layer()->ToScrollbarLayer()->SetScrollLayer( | 65 layer_->layer()->ToScrollbarLayer()->SetScrollLayer( |
| 66 scroll_layer ? scroll_layer->id() : cc::Layer::INVALID_ID); | 66 scroll_layer ? scroll_layer->id() : cc::Layer::INVALID_ID); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace cc_blink | 69 } // namespace cc_blink |
| OLD | NEW |