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

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: Rebase to fix collision with solid colour scrollbars patch. 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
« no previous file with comments | « cc/pinch_zoom_scrollbar.h ('k') | cc/pinch_zoom_scrollbar_geometry.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.5f;
14 const float PinchZoomScrollbar::kFadeDurationInSeconds = 0.5f;
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->scroll_offset().x();
33 else
34 return root_scroll_layer->scroll_offset().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_->layout_viewport_size();
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 device_viewport_size = owner_->device_viewport_size();
62 gfx::Size root_scroll_bounds = root_scroll_layer->content_bounds();
63
64 if (orientation_ == WebKit::WebScrollbar::Horizontal)
65 return root_scroll_bounds.width() - device_viewport_size.width();
66 else
67 return root_scroll_bounds.height() - device_viewport_size.height();
68 }
69
70 int PinchZoomScrollbar::totalSize() const {
71 const Layer* root_scroll_layer = owner_->RootScrollLayer();
72 gfx::Size size;
73 if (root_scroll_layer)
74 size = root_scroll_layer->content_bounds();
75 else
76 size = gfx::Size();
77
78 if (orientation_ == WebKit::WebScrollbar::Horizontal)
79 return size.width();
80 else
81 return size.height();
82 }
83
84 bool PinchZoomScrollbar::isScrollViewScrollbar() const {
85 return false;
86 }
87
88 bool PinchZoomScrollbar::isScrollableAreaActive() const {
89 return true;
90 }
91
92 WebKit::WebScrollbar::ScrollbarControlSize PinchZoomScrollbar::controlSize()
93 const {
94 return WebKit::WebScrollbar::SmallScrollbar;
95 }
96
97 WebKit::WebScrollbar::ScrollbarPart PinchZoomScrollbar::pressedPart() const {
98 return WebKit::WebScrollbar::NoPart;
99 }
100
101 WebKit::WebScrollbar::ScrollbarPart PinchZoomScrollbar::hoveredPart() const {
102 return WebKit::WebScrollbar::NoPart;
103 }
104
105 WebKit::WebScrollbar::ScrollbarOverlayStyle
106 PinchZoomScrollbar::scrollbarOverlayStyle() const {
107 return WebKit::WebScrollbar::ScrollbarOverlayStyleDefault;
108 }
109 bool PinchZoomScrollbar::isCustomScrollbar() const {
110 return false;
111 }
112
113 WebKit::WebScrollbar::Orientation PinchZoomScrollbar::orientation() const {
114 return orientation_;
115 }
116
117 } // namespace cc
OLDNEW
« no previous file with comments | « cc/pinch_zoom_scrollbar.h ('k') | cc/pinch_zoom_scrollbar_geometry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698