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

Side by Side Diff: cc/pinch_zoom_scrollbar.cc

Issue 11550035: Implement pinch-zoom scaling for main-frame scrollbars and pinch-zoom overlay scrollbars. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate device scale factor, default to 0 totalSize when no root scroll layer. Created 7 years, 9 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
OLDNEW
(Empty)
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.
4
5 #include "cc/pinch_zoom_scrollbar.h"
6
7 #include "cc/layer.h"
8 #include "cc/layer_tree_host.h"
9 #include "cc/pinch_zoom_scrollbar_geometry.h"
10
11 namespace cc {
12
13 const float PinchZoomScrollbar::kDefaultOpacity = 0.5;
enne (OOO) 2013/03/11 21:08:24 style nit: 0.5f
wjmaclean 2013/03/12 16:13:07 Done.
14 const float PinchZoomScrollbar::kFadeDurationInSeconds = 0.5;
enne (OOO) 2013/03/11 21:08:24 style nit: 0.5f
wjmaclean 2013/03/12 16:13:07 Done.
15
16 PinchZoomScrollbar::PinchZoomScrollbar(
17 WebKit::WebScrollbar::Orientation orientation, LayerTreeHost* owner)
18 : orientation_(orientation),
19 owner_(owner) {
20 DCHECK(owner_);
21 }
22
23
24 bool PinchZoomScrollbar::isOverlay() const { return true; }
25
26 int PinchZoomScrollbar::value() const {
27 const Layer* root_scroll_layer = owner_->rootScrollLayer();
28 if (!root_scroll_layer)
29 return 0;
30
31 if (orientation_ == WebKit::WebScrollbar::Horizontal)
32 return root_scroll_layer->scrollOffset().x();
33 else
34 return root_scroll_layer->scrollOffset().y();
35 }
36
37 WebKit::WebPoint PinchZoomScrollbar::location() const {
38 return WebKit::WebPoint();
39 }
40
41 WebKit::WebSize PinchZoomScrollbar::size() const {
42 gfx::Size viewport_size = owner_->layoutViewportSize();
43 gfx::Size size;
44 int track_width = PinchZoomScrollbarGeometry::kTrackWidth;
45 if (orientation_ == WebKit::WebScrollbar::Horizontal)
46 size = gfx::Size(viewport_size.width() - track_width, track_width);
47 else
48 size = gfx::Size(track_width, viewport_size.height() - track_width);
49 return WebKit::WebSize(size);
50 }
51
52 bool PinchZoomScrollbar::enabled() const {
53 return true;
54 }
55
56 int PinchZoomScrollbar::maximum() const {
57 const Layer* root_scroll_layer = owner_->rootScrollLayer();
58 if (!root_scroll_layer)
59 return 0;
60
61 gfx::Size viewport_size = owner_->layoutViewportSize();
62 gfx::Size root_scroll_bounds = root_scroll_layer->contentBounds();
63 float scale = owner_->deviceScaleFactor();
64
65 if (orientation_ == WebKit::WebScrollbar::Horizontal)
66 return root_scroll_bounds.width() /scale - viewport_size.width();
enne (OOO) 2013/03/11 21:08:24 Is there a reason not to just use deviceViewportSi
wjmaclean 2013/03/12 16:13:07 No, device viewport should work too. Done.
67 else
68 return root_scroll_bounds.height() / scale - viewport_size.height();
69 }
70
71 int PinchZoomScrollbar::totalSize() const {
72 const Layer* root_scroll_layer = owner_->rootScrollLayer();
73 gfx::Size size;
74 if (root_scroll_layer) {
75 size = root_scroll_layer->contentBounds();
76 float scale = owner_->deviceScaleFactor();
77 size = gfx::Size(size.width() / scale, size.height() / scale);
78 } else
79 size = gfx::Size();
80
81 if (orientation_ == WebKit::WebScrollbar::Horizontal)
82 return size.width();
83 else
84 return size.height();
85 }
86
87 bool PinchZoomScrollbar::isScrollViewScrollbar() const {
88 return false;
89 }
90
91 bool PinchZoomScrollbar::isScrollableAreaActive() const {
92 return true;
93 }
94
95 WebKit::WebScrollbar::ScrollbarControlSize PinchZoomScrollbar::controlSize() con st {
96 return WebKit::WebScrollbar::SmallScrollbar;
97 }
98
99 WebKit::WebScrollbar::ScrollbarPart PinchZoomScrollbar::pressedPart() const {
100 return WebKit::WebScrollbar::NoPart;
101 }
102
103 WebKit::WebScrollbar::ScrollbarPart PinchZoomScrollbar::hoveredPart() const {
104 return WebKit::WebScrollbar::NoPart;
105 }
106
107 WebKit::WebScrollbar::ScrollbarOverlayStyle PinchZoomScrollbar::scrollbarOverlay Style() const {
108 return WebKit::WebScrollbar::ScrollbarOverlayStyleDefault;
109 }
110 bool PinchZoomScrollbar::isCustomScrollbar() const {
111 return false;
112 }
113
114 WebKit::WebScrollbar::Orientation PinchZoomScrollbar::orientation() const {
115 return orientation_;
116 }
117
118 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698