Home | History | Annotate | Download | only in compositor_bindings
      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.
      4 
      5 #include "webkit/renderer/compositor_bindings/web_scrollbar_layer_impl.h"
      6 
      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"
     12 
     13 using cc::PaintedScrollbarLayer;
     14 using cc::SolidColorScrollbarLayer;
     15 
     16 namespace {
     17 
     18 cc::ScrollbarOrientation ConvertOrientation(
     19     blink::WebScrollbar::Orientation orientation) {
     20   return orientation == blink::WebScrollbar::Horizontal ? cc::HORIZONTAL
     21     : cc::VERTICAL;
     22 }
     23 
     24 }  // namespace
     25 
     26 namespace webkit {
     27 
     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))) {}
     37 
     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))) {}
     48 
     49 WebScrollbarLayerImpl::~WebScrollbarLayerImpl() {}
     50 
     51 blink::WebLayer* WebScrollbarLayerImpl::layer() { return layer_.get(); }
     52 
     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);
     56 }
     57 
     58 }  // namespace webkit
     59