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.
5 #include "cc/blink/web_scrollbar_layer_impl.h"
7 #include "cc/blink/scrollbar_impl.h"
8 #include "cc/blink/web_layer_impl.h"
9 #include "cc/layers/layer.h"
10 #include "cc/layers/painted_scrollbar_layer.h"
11 #include "cc/layers/scrollbar_layer_interface.h"
12 #include "cc/layers/solid_color_scrollbar_layer.h"
14 using cc::PaintedScrollbarLayer
;
15 using cc::SolidColorScrollbarLayer
;
19 cc::ScrollbarOrientation
ConvertOrientation(
20 blink::WebScrollbar::Orientation orientation
) {
21 return orientation
== blink::WebScrollbar::Horizontal
? cc::HORIZONTAL
29 WebScrollbarLayerImpl::WebScrollbarLayerImpl(
30 blink::WebScrollbar
* scrollbar
,
31 blink::WebScrollbarThemePainter painter
,
32 blink::WebScrollbarThemeGeometry
* geometry
)
33 : layer_(new WebLayerImpl(PaintedScrollbarLayer::Create(
34 WebLayerImpl::LayerSettings(),
35 scoped_ptr
<cc::Scrollbar
>(
36 new ScrollbarImpl(make_scoped_ptr(scrollbar
),
38 make_scoped_ptr(geometry
))).Pass(),
42 WebScrollbarLayerImpl::WebScrollbarLayerImpl(
43 blink::WebScrollbar::Orientation orientation
,
46 bool is_left_side_vertical_scrollbar
)
47 : layer_(new WebLayerImpl(
48 SolidColorScrollbarLayer::Create(WebLayerImpl::LayerSettings(),
49 ConvertOrientation(orientation
),
52 is_left_side_vertical_scrollbar
,
56 WebScrollbarLayerImpl::~WebScrollbarLayerImpl() {
59 blink::WebLayer
* WebScrollbarLayerImpl::layer() {
63 void WebScrollbarLayerImpl::setScrollLayer(blink::WebLayer
* layer
) {
64 cc::Layer
* scroll_layer
=
65 layer
? static_cast<WebLayerImpl
*>(layer
)->layer() : 0;
66 layer_
->layer()->ToScrollbarLayer()->SetScrollLayer(
67 scroll_layer
? scroll_layer
->id() : cc::Layer::INVALID_ID
);
70 void WebScrollbarLayerImpl::setClipLayer(blink::WebLayer
* layer
) {
71 cc::Layer
* clip_layer
=
72 layer
? static_cast<WebLayerImpl
*>(layer
)->layer() : 0;
73 layer_
->layer()->ToScrollbarLayer()->SetClipLayer(
74 clip_layer
? clip_layer
->id() : cc::Layer::INVALID_ID
);
77 } // namespace cc_blink