Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: cc/layers/scrollbar_layer_impl_base.cc

Issue 135183016: Revert of Pinch/Zoom Infrastructure & Plumbing CL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layers/scrollbar_layer_impl_base.h ('k') | cc/layers/scrollbar_layer_interface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/scrollbar_layer_impl_base.h" 5 #include "cc/layers/scrollbar_layer_impl_base.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include "cc/trees/layer_tree_impl.h" 8 #include "cc/layers/layer.h"
9 #include "ui/gfx/rect_conversions.h" 9 #include "ui/gfx/rect_conversions.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 ScrollbarLayerImplBase::ScrollbarLayerImplBase( 13 ScrollbarLayerImplBase::ScrollbarLayerImplBase(
14 LayerTreeImpl* tree_impl, 14 LayerTreeImpl* tree_impl,
15 int id, 15 int id,
16 ScrollbarOrientation orientation, 16 ScrollbarOrientation orientation,
17 bool is_left_side_vertical_scrollbar, 17 bool is_left_side_vertical_scrollbar)
18 bool is_overlay)
19 : LayerImpl(tree_impl, id), 18 : LayerImpl(tree_impl, id),
20 scroll_layer_(NULL), 19 scroll_layer_id_(Layer::INVALID_ID),
21 clip_layer_(NULL), 20 is_overlay_scrollbar_(false),
22 is_overlay_scrollbar_(is_overlay),
23 thumb_thickness_scale_factor_(1.f), 21 thumb_thickness_scale_factor_(1.f),
24 current_pos_(0.f), 22 current_pos_(0.f),
25 maximum_(0), 23 maximum_(0),
26 orientation_(orientation), 24 orientation_(orientation),
27 is_left_side_vertical_scrollbar_(is_left_side_vertical_scrollbar), 25 is_left_side_vertical_scrollbar_(is_left_side_vertical_scrollbar),
28 vertical_adjust_(0.f), 26 vertical_adjust_(0.f),
29 visible_to_total_length_ratio_(1.f) {} 27 visible_to_total_length_ratio_(1.f) {}
30 28
31 ScrollbarLayerImplBase::~ScrollbarLayerImplBase() {
32 }
33
34 void ScrollbarLayerImplBase::PushPropertiesTo(LayerImpl* layer) { 29 void ScrollbarLayerImplBase::PushPropertiesTo(LayerImpl* layer) {
35 LayerImpl::PushPropertiesTo(layer); 30 LayerImpl::PushPropertiesTo(layer);
36 DCHECK(layer->ToScrollbarLayer());
37 layer->ToScrollbarLayer()->set_is_overlay_scrollbar(is_overlay_scrollbar_);
38 PushScrollClipPropertiesTo(layer);
39 }
40
41 void ScrollbarLayerImplBase::PushScrollClipPropertiesTo(LayerImpl* layer) {
42 DCHECK(layer->ToScrollbarLayer());
43 layer->ToScrollbarLayer()->SetScrollLayerById(ScrollLayerId());
44 layer->ToScrollbarLayer()->SetClipLayerById(ClipLayerId());
45 } 31 }
46 32
47 ScrollbarLayerImplBase* ScrollbarLayerImplBase::ToScrollbarLayer() { 33 ScrollbarLayerImplBase* ScrollbarLayerImplBase::ToScrollbarLayer() {
48 return this; 34 return this;
49 } 35 }
50 36
51 void ScrollbarLayerImplBase::SetScrollLayerById(int id) {
52 LayerImpl* scroll_layer = layer_tree_impl()->LayerById(id);
53 if (scroll_layer_ == scroll_layer)
54 return;
55
56 if (scroll_layer_)
57 scroll_layer_->RemoveScrollbar(this);
58 scroll_layer_ = scroll_layer;
59 if (scroll_layer_)
60 scroll_layer_->AddScrollbar(this);
61 }
62
63 void ScrollbarLayerImplBase::SetClipLayerById(int id) {
64 LayerImpl* clip_layer = layer_tree_impl()->LayerById(id);
65 if (clip_layer_ == clip_layer)
66 return;
67
68 if (clip_layer_)
69 clip_layer_->RemoveScrollbar(this);
70 clip_layer_ = clip_layer;
71 if (clip_layer_)
72 clip_layer_->AddScrollbar(this);
73 }
74
75 gfx::Rect ScrollbarLayerImplBase::ScrollbarLayerRectToContentRect( 37 gfx::Rect ScrollbarLayerImplBase::ScrollbarLayerRectToContentRect(
76 const gfx::RectF& layer_rect) const { 38 const gfx::RectF& layer_rect) const {
77 // Don't intersect with the bounds as in LayerRectToContentRect() because 39 // Don't intersect with the bounds as in LayerRectToContentRect() because
78 // layer_rect here might be in coordinates of the containing layer. 40 // layer_rect here might be in coordinates of the containing layer.
79 gfx::RectF content_rect = gfx::ScaleRect(layer_rect, 41 gfx::RectF content_rect = gfx::ScaleRect(layer_rect,
80 contents_scale_x(), 42 contents_scale_x(),
81 contents_scale_y()); 43 contents_scale_y());
82 return gfx::ToEnclosingRect(content_rect); 44 return gfx::ToEnclosingRect(content_rect);
83 } 45 }
84 46
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 ? bounds().width() - thumb_thickness 170 ? bounds().width() - thumb_thickness
209 : thumb_thickness_adjustment, 171 : thumb_thickness_adjustment,
210 thumb_offset, 172 thumb_offset,
211 thumb_thickness - thumb_thickness_adjustment, 173 thumb_thickness - thumb_thickness_adjustment,
212 thumb_length); 174 thumb_length);
213 } 175 }
214 176
215 return ScrollbarLayerRectToContentRect(thumb_rect); 177 return ScrollbarLayerRectToContentRect(thumb_rect);
216 } 178 }
217 179
218 void ScrollbarLayerImplBase::ScrollbarParametersDidChange() {
219 if (!clip_layer_ || !scroll_layer_)
220 return;
221
222 scroll_layer_->SetScrollbarPosition(this, clip_layer_);
223 }
224
225 } // namespace cc 180 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/scrollbar_layer_impl_base.h ('k') | cc/layers/scrollbar_layer_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698