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