1 // Copyright 2013 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/layers/solid_color_scrollbar_layer.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "cc/layers/layer_impl.h"
9 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
13 scoped_ptr<LayerImpl> SolidColorScrollbarLayer::CreateLayerImpl(
14 LayerTreeImpl* tree_impl) {
15 const bool kIsOverlayScrollbar = true;
16 return SolidColorScrollbarLayerImpl::Create(tree_impl,
21 is_left_side_vertical_scrollbar_,
26 scoped_refptr<SolidColorScrollbarLayer> SolidColorScrollbarLayer::Create(
27 ScrollbarOrientation orientation,
30 bool is_left_side_vertical_scrollbar,
31 int scroll_layer_id) {
32 return make_scoped_refptr(
33 new SolidColorScrollbarLayer(orientation,
36 is_left_side_vertical_scrollbar,
40 SolidColorScrollbarLayer::SolidColorScrollbarLayer(
41 ScrollbarOrientation orientation,
44 bool is_left_side_vertical_scrollbar,
46 : scroll_layer_id_(Layer::INVALID_ID),
47 clip_layer_id_(scroll_layer_id),
48 orientation_(orientation),
49 thumb_thickness_(thumb_thickness),
50 track_start_(track_start),
51 is_left_side_vertical_scrollbar_(is_left_side_vertical_scrollbar) {}
53 SolidColorScrollbarLayer::~SolidColorScrollbarLayer() {}
55 ScrollbarLayerInterface* SolidColorScrollbarLayer::ToScrollbarLayer() {
59 void SolidColorScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
60 Layer::PushPropertiesTo(layer);
61 PushScrollClipPropertiesTo(layer);
64 void SolidColorScrollbarLayer::PushScrollClipPropertiesTo(LayerImpl* layer) {
65 SolidColorScrollbarLayerImpl* scrollbar_layer =
66 static_cast<SolidColorScrollbarLayerImpl*>(layer);
68 scrollbar_layer->SetScrollLayerById(scroll_layer_id_);
69 scrollbar_layer->SetClipLayerById(clip_layer_id_);
72 void SolidColorScrollbarLayer::SetNeedsDisplayRect(const gfx::RectF&) {
73 // Never needs repaint.
76 bool SolidColorScrollbarLayer::OpacityCanAnimateOnImplThread() const {
80 int SolidColorScrollbarLayer::ScrollLayerId() const {
81 return scroll_layer_id_;
84 void SolidColorScrollbarLayer::SetScrollLayer(int layer_id) {
85 if (layer_id == scroll_layer_id_)
88 scroll_layer_id_ = layer_id;
89 SetNeedsFullTreeSync();
92 void SolidColorScrollbarLayer::SetClipLayer(int layer_id) {
93 if (layer_id == clip_layer_id_)
96 clip_layer_id_ = layer_id;
97 SetNeedsFullTreeSync();
100 ScrollbarOrientation SolidColorScrollbarLayer::orientation() const {