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/scrollbar_layer.h" | 7 #include "cc/layers/scrollbar_layer.h" |
8 #include "cc/layers/scrollbar_layer_base.h" | |
9 #include "cc/layers/solid_color_scrollbar_layer.h" | |
8 #include "third_party/WebKit/public/platform/WebScrollbar.h" | 10 #include "third_party/WebKit/public/platform/WebScrollbar.h" |
9 #include "webkit/renderer/compositor_bindings/scrollbar_impl.h" | 11 #include "webkit/renderer/compositor_bindings/scrollbar_impl.h" |
10 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" | 12 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" |
11 | 13 |
12 using cc::ScrollbarLayer; | 14 using cc::ScrollbarLayer; |
15 using cc::SolidColorScrollbarLayer; | |
16 | |
17 #if defined(OS_ANDROID) | |
18 namespace { | |
19 | |
20 cc::ScrollbarOrientation convertOrientation( | |
tfarina
2013/07/04 17:34:45
CamelCase
wjmaclean
2013/07/04 17:50:11
Done.
| |
21 WebKit::WebScrollbar::Orientation orientation) { | |
22 if (orientation == WebKit::WebScrollbar::Horizontal) | |
tfarina
2013/07/04 17:34:45
I know if/else is clear, but I'd just use the tern
wjmaclean
2013/07/04 17:50:11
Done.
| |
23 return cc::HORIZONTAL; | |
24 else | |
25 return cc::VERTICAL; | |
26 } | |
27 | |
28 const int solid_color_scrollbar_thumb_thickness = 3; | |
tfarina
2013/07/04 17:34:45
kFoo
wjmaclean
2013/07/04 17:50:11
Done.
| |
29 const SkColor solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); | |
tfarina
2013/07/04 17:34:45
kFoo
wjmaclean
2013/07/04 17:50:11
Done.
| |
30 | |
31 } // namespace | |
32 #endif | |
13 | 33 |
14 namespace webkit { | 34 namespace webkit { |
15 | 35 |
16 WebScrollbarLayerImpl::WebScrollbarLayerImpl( | 36 WebScrollbarLayerImpl::WebScrollbarLayerImpl( |
17 WebKit::WebScrollbar* scrollbar, | 37 WebKit::WebScrollbar* scrollbar, |
18 WebKit::WebScrollbarThemePainter painter, | 38 WebKit::WebScrollbarThemePainter painter, |
19 WebKit::WebScrollbarThemeGeometry* geometry) | 39 WebKit::WebScrollbarThemeGeometry* geometry) |
40 #if defined(OS_ANDROID) | |
41 : layer_(new WebLayerImpl(SolidColorScrollbarLayer::Create( | |
42 convertOrientation(scrollbar->orientation()), | |
43 solid_color_scrollbar_thumb_thickness, | |
44 solid_color_scrollbar_color, | |
45 0))) {} | |
46 #else | |
20 : layer_(new WebLayerImpl(ScrollbarLayer::Create( | 47 : layer_(new WebLayerImpl(ScrollbarLayer::Create( |
21 scoped_ptr<cc::Scrollbar>(new ScrollbarImpl( | 48 scoped_ptr<cc::Scrollbar>(new ScrollbarImpl( |
22 make_scoped_ptr(scrollbar), | 49 make_scoped_ptr(scrollbar), |
23 painter, | 50 painter, |
24 make_scoped_ptr(geometry))).Pass(), 0))) {} | 51 make_scoped_ptr(geometry))).Pass(), 0))) {} |
52 #endif | |
25 | 53 |
26 WebScrollbarLayerImpl::~WebScrollbarLayerImpl() {} | 54 WebScrollbarLayerImpl::~WebScrollbarLayerImpl() {} |
27 | 55 |
28 WebKit::WebLayer* WebScrollbarLayerImpl::layer() { return layer_.get(); } | 56 WebKit::WebLayer* WebScrollbarLayerImpl::layer() { return layer_.get(); } |
29 | 57 |
30 void WebScrollbarLayerImpl::setScrollLayer(WebKit::WebLayer* layer) { | 58 void WebScrollbarLayerImpl::setScrollLayer(WebKit::WebLayer* layer) { |
31 int id = layer ? static_cast<WebLayerImpl*>(layer)->layer()->id() : 0; | 59 int id = layer ? static_cast<WebLayerImpl*>(layer)->layer()->id() : 0; |
32 static_cast<ScrollbarLayer*>(layer_->layer())->SetScrollLayerId(id); | 60 layer_->layer()->ToScrollbarLayerBase()->SetScrollLayerId(id); |
33 } | 61 } |
34 | 62 |
35 } // namespace webkit | 63 } // namespace webkit |
OLD | NEW |