Roll leveldb to r78 / 1.15.
[chromium-blink-merge.git] / webkit / renderer / compositor_bindings / web_scrollbar_layer_impl.cc
blob265a97db41c55f70b9c424757b1f56624eba010c
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;
16 namespace {
18 cc::ScrollbarOrientation ConvertOrientation(
19 blink::WebScrollbar::Orientation orientation) {
20 return orientation == blink::WebScrollbar::Horizontal ? cc::HORIZONTAL
21 : cc::VERTICAL;
24 } // namespace
26 namespace webkit {
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),
35 painter,
36 make_scoped_ptr(geometry))).Pass(), 0))) {}
38 WebScrollbarLayerImpl::WebScrollbarLayerImpl(
39 blink::WebScrollbar::Orientation orientation,
40 int thumb_thickness,
41 bool is_left_side_vertical_scrollbar)
42 : layer_(new WebLayerImpl(
43 SolidColorScrollbarLayer::Create(
44 ConvertOrientation(orientation),
45 thumb_thickness,
46 is_left_side_vertical_scrollbar,
47 0))) {}
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);
58 } // namespace webkit