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
3 // found in the LICENSE file.
5 #include "webkit/renderer/compositor_bindings/web_scrollbar_layer_impl.h"
7 #include "cc/layers/painted_scrollbar_layer.h"
8 #include "cc/layers/scrollbar_layer_interface.h"
9 #include "cc/layers/solid_color_scrollbar_layer.h"
10 #include "webkit/renderer/compositor_bindings/scrollbar_impl.h"
11 #include "webkit/renderer/compositor_bindings/web_layer_impl.h"
13 using cc::PaintedScrollbarLayer
;
14 using cc::SolidColorScrollbarLayer
;
18 cc::ScrollbarOrientation
ConvertOrientation(
19 blink::WebScrollbar::Orientation orientation
) {
20 return orientation
== blink::WebScrollbar::Horizontal
? cc::HORIZONTAL
28 WebScrollbarLayerImpl::WebScrollbarLayerImpl(
29 blink::WebScrollbar
* scrollbar
,
30 blink::WebScrollbarThemePainter painter
,
31 blink::WebScrollbarThemeGeometry
* geometry
)
32 : layer_(new WebLayerImpl(PaintedScrollbarLayer::Create(
33 scoped_ptr
<cc::Scrollbar
>(new ScrollbarImpl(
34 make_scoped_ptr(scrollbar
),
36 make_scoped_ptr(geometry
))).Pass(), 0))) {}
38 WebScrollbarLayerImpl::WebScrollbarLayerImpl(
39 blink::WebScrollbar::Orientation orientation
,
41 bool is_left_side_vertical_scrollbar
)
42 : layer_(new WebLayerImpl(
43 SolidColorScrollbarLayer::Create(
44 ConvertOrientation(orientation
),
46 is_left_side_vertical_scrollbar
,
49 WebScrollbarLayerImpl::~WebScrollbarLayerImpl() {}
51 blink::WebLayer
* WebScrollbarLayerImpl::layer() { return layer_
.get(); }
53 void WebScrollbarLayerImpl::setScrollLayer(blink::WebLayer
* layer
) {
54 int id
= layer
? static_cast<WebLayerImpl
*>(layer
)->layer()->id() : 0;
55 static_cast<PaintedScrollbarLayer
*>(layer_
->layer())->SetScrollLayerId(id
);