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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: cc/pinch_zoom_scrollbar.cc
diff --git a/cc/pinch_zoom_scrollbar.cc b/cc/pinch_zoom_scrollbar.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3ee15af79fe025c2d8b5fb9919e90c0027a4749e
--- /dev/null
+++ b/cc/pinch_zoom_scrollbar.cc
@@ -0,0 +1,118 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/pinch_zoom_scrollbar.h"
+
+#include "cc/layer.h"
+#include "cc/layer_tree_host.h"
+#include "cc/pinch_zoom_scrollbar_geometry.h"
+
+namespace cc {
+
+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.
+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.
+
+PinchZoomScrollbar::PinchZoomScrollbar(
+ WebKit::WebScrollbar::Orientation orientation, LayerTreeHost* owner)
+ : orientation_(orientation),
+ owner_(owner) {
+ DCHECK(owner_);
+}
+
+
+bool PinchZoomScrollbar::isOverlay() const { return true; }
+
+int PinchZoomScrollbar::value() const {
+ const Layer* root_scroll_layer = owner_->rootScrollLayer();
+ if (!root_scroll_layer)
+ return 0;
+
+ if (orientation_ == WebKit::WebScrollbar::Horizontal)
+ return root_scroll_layer->scrollOffset().x();
+ else
+ return root_scroll_layer->scrollOffset().y();
+}
+
+WebKit::WebPoint PinchZoomScrollbar::location() const {
+ return WebKit::WebPoint();
+}
+
+WebKit::WebSize PinchZoomScrollbar::size() const {
+ gfx::Size viewport_size = owner_->layoutViewportSize();
+ gfx::Size size;
+ int track_width = PinchZoomScrollbarGeometry::kTrackWidth;
+ if (orientation_ == WebKit::WebScrollbar::Horizontal)
+ size = gfx::Size(viewport_size.width() - track_width, track_width);
+ else
+ size = gfx::Size(track_width, viewport_size.height() - track_width);
+ return WebKit::WebSize(size);
+}
+
+bool PinchZoomScrollbar::enabled() const {
+ return true;
+}
+
+int PinchZoomScrollbar::maximum() const {
+ const Layer* root_scroll_layer = owner_->rootScrollLayer();
+ if (!root_scroll_layer)
+ return 0;
+
+ gfx::Size viewport_size = owner_->layoutViewportSize();
+ gfx::Size root_scroll_bounds = root_scroll_layer->contentBounds();
+ float scale = owner_->deviceScaleFactor();
+
+ if (orientation_ == WebKit::WebScrollbar::Horizontal)
+ 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.
+ else
+ return root_scroll_bounds.height() / scale - viewport_size.height();
+}
+
+int PinchZoomScrollbar::totalSize() const {
+ const Layer* root_scroll_layer = owner_->rootScrollLayer();
+ gfx::Size size;
+ if (root_scroll_layer) {
+ size = root_scroll_layer->contentBounds();
+ float scale = owner_->deviceScaleFactor();
+ size = gfx::Size(size.width() / scale, size.height() / scale);
+ } else
+ size = gfx::Size();
+
+ if (orientation_ == WebKit::WebScrollbar::Horizontal)
+ return size.width();
+ else
+ return size.height();
+}
+
+bool PinchZoomScrollbar::isScrollViewScrollbar() const {
+ return false;
+}
+
+bool PinchZoomScrollbar::isScrollableAreaActive() const {
+ return true;
+}
+
+WebKit::WebScrollbar::ScrollbarControlSize PinchZoomScrollbar::controlSize() const {
+ return WebKit::WebScrollbar::SmallScrollbar;
+}
+
+WebKit::WebScrollbar::ScrollbarPart PinchZoomScrollbar::pressedPart() const {
+ return WebKit::WebScrollbar::NoPart;
+}
+
+WebKit::WebScrollbar::ScrollbarPart PinchZoomScrollbar::hoveredPart() const {
+ return WebKit::WebScrollbar::NoPart;
+}
+
+WebKit::WebScrollbar::ScrollbarOverlayStyle PinchZoomScrollbar::scrollbarOverlayStyle() const {
+ return WebKit::WebScrollbar::ScrollbarOverlayStyleDefault;
+}
+bool PinchZoomScrollbar::isCustomScrollbar() const {
+ return false;
+}
+
+WebKit::WebScrollbar::Orientation PinchZoomScrollbar::orientation() const {
+ return orientation_;
+}
+
+} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698