OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "webkit/renderer/compositor_bindings/web_scrollbar_layer_impl.h" | 5 #include "webkit/renderer/compositor_bindings/web_scrollbar_layer_impl.h" |
6 | 6 |
7 #include "cc/layers/painted_scrollbar_layer.h" | 7 #include "cc/layers/painted_scrollbar_layer.h" |
8 #include "third_party/WebKit/public/platform/WebScrollbar.h" | 8 #include "cc/layers/scrollbar_layer_interface.h" |
| 9 #include "cc/layers/solid_color_scrollbar_layer.h" |
9 #include "webkit/renderer/compositor_bindings/scrollbar_impl.h" | 10 #include "webkit/renderer/compositor_bindings/scrollbar_impl.h" |
10 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" | 11 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" |
11 | 12 |
12 using cc::PaintedScrollbarLayer; | 13 using cc::PaintedScrollbarLayer; |
| 14 using cc::SolidColorScrollbarLayer; |
| 15 |
| 16 namespace { |
| 17 |
| 18 cc::ScrollbarOrientation ConvertOrientation( |
| 19 WebKit::WebScrollbar::Orientation orientation) { |
| 20 return orientation == WebKit::WebScrollbar::Horizontal ? cc::HORIZONTAL |
| 21 : cc::VERTICAL; |
| 22 } |
| 23 |
| 24 } // namespace |
13 | 25 |
14 namespace webkit { | 26 namespace webkit { |
15 | 27 |
16 WebScrollbarLayerImpl::WebScrollbarLayerImpl( | 28 WebScrollbarLayerImpl::WebScrollbarLayerImpl( |
17 WebKit::WebScrollbar* scrollbar, | 29 WebKit::WebScrollbar* scrollbar, |
18 WebKit::WebScrollbarThemePainter painter, | 30 WebKit::WebScrollbarThemePainter painter, |
19 WebKit::WebScrollbarThemeGeometry* geometry) | 31 WebKit::WebScrollbarThemeGeometry* geometry) |
20 : layer_(new WebLayerImpl(PaintedScrollbarLayer::Create( | 32 : layer_(new WebLayerImpl(PaintedScrollbarLayer::Create( |
21 scoped_ptr<cc::Scrollbar>(new ScrollbarImpl( | 33 scoped_ptr<cc::Scrollbar>(new ScrollbarImpl( |
22 make_scoped_ptr(scrollbar), | 34 make_scoped_ptr(scrollbar), |
23 painter, | 35 painter, |
24 make_scoped_ptr(geometry))).Pass(), 0))) {} | 36 make_scoped_ptr(geometry))).Pass(), 0))) {} |
25 | 37 |
| 38 WebScrollbarLayerImpl::WebScrollbarLayerImpl( |
| 39 WebKit::WebScrollbar::Orientation orientation, |
| 40 int thumb_thickness) |
| 41 : layer_(new WebLayerImpl( |
| 42 SolidColorScrollbarLayer::Create(ConvertOrientation(orientation), |
| 43 thumb_thickness, |
| 44 0))) {} |
| 45 |
26 WebScrollbarLayerImpl::~WebScrollbarLayerImpl() {} | 46 WebScrollbarLayerImpl::~WebScrollbarLayerImpl() {} |
27 | 47 |
28 WebKit::WebLayer* WebScrollbarLayerImpl::layer() { return layer_.get(); } | 48 WebKit::WebLayer* WebScrollbarLayerImpl::layer() { return layer_.get(); } |
29 | 49 |
30 void WebScrollbarLayerImpl::setScrollLayer(WebKit::WebLayer* layer) { | 50 void WebScrollbarLayerImpl::setScrollLayer(WebKit::WebLayer* layer) { |
31 int id = layer ? static_cast<WebLayerImpl*>(layer)->layer()->id() : 0; | 51 int id = layer ? static_cast<WebLayerImpl*>(layer)->layer()->id() : 0; |
32 static_cast<PaintedScrollbarLayer*>(layer_->layer())->SetScrollLayerId(id); | 52 static_cast<PaintedScrollbarLayer*>(layer_->layer())->SetScrollLayerId(id); |
33 } | 53 } |
34 | 54 |
35 } // namespace webkit | 55 } // namespace webkit |
OLD | NEW |