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

Unified Diff: cc/input/inner_viewport_scrollbar.cc

Issue 16679011: Add viewport scrollbar class to support overlay scrollbars for pinch zoom virtual viewport. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add scrollbars layers in compositor, plumb layer ids to LayerTreeImpl. Created 7 years, 6 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/input/inner_viewport_scrollbar.cc
diff --git a/cc/input/inner_viewport_scrollbar.cc b/cc/input/inner_viewport_scrollbar.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1178d09825729dd35b145f0b36ee485d2061325f
--- /dev/null
+++ b/cc/input/inner_viewport_scrollbar.cc
@@ -0,0 +1,70 @@
+// 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/input/inner_viewport_scrollbar.h"
+
+#include "cc/layers/layer.h"
+#include "third_party/skia/include/core/SkCanvas.h"
+
+namespace cc {
+
+InnerViewportScrollbar::InnerViewportScrollbar(
+ scoped_refptr<Layer> scroll_layer,
+ scoped_refptr<Layer> clip_layer,
+ ScrollbarOrientation orientation,
+ size_t thickness)
+ : scroll_layer_(scroll_layer),
+ clip_layer_(clip_layer),
+ orientation_(orientation),
+ thickness_(thickness) {}
+
+InnerViewportScrollbar::~InnerViewportScrollbar() {}
+
+ScrollbarOrientation InnerViewportScrollbar::Orientation() const {
+ return orientation_;
+}
+
+gfx::Point InnerViewportScrollbar::Location() const {
+ return gfx::Point();
+}
+
+bool InnerViewportScrollbar::IsOverlay() const {
+ return true;
+}
+
+bool InnerViewportScrollbar::HasThumb() const {
+ return true;
+}
+
+int InnerViewportScrollbar::ThumbThickness() const {
+ return thickness_;
+}
+
+int InnerViewportScrollbar::ThumbLength() const {
+ gfx::Rect track_rect = TrackRect();
jamesr 2013/07/03 21:12:14 this is dead code
+ if (orientation_ == HORIZONTAL) {
+ float ratio = static_cast<float>(track_rect.width()) /
+ clip_layer_->bounds().width();
+ return track_rect.width() - ratio * scroll_layer_->max_scroll_offset().x();
enne (OOO) 2013/06/19 23:38:28 (1) I think this math is not quite right. Can you
trchen 2013/06/20 01:16:08 Your relative layer space approach should work wit
wjmaclean 2013/06/21 18:20:53 We still need something that will work without a b
wjmaclean 2013/06/21 18:20:53 Yes, I'll add a unit test.
trchen 2013/06/24 21:38:04 I think we can do without dummy values. Most of th
+ } else {
+ float ratio = static_cast<float>(track_rect.height()) /
+ clip_layer_->bounds().height();
+ return track_rect.height() - ratio * scroll_layer_->max_scroll_offset().y();
+ }
+}
+
+gfx::Rect InnerViewportScrollbar::TrackRect() const {
+ if (orientation_ == HORIZONTAL)
enne (OOO) 2013/06/19 23:38:28 style nit: {}
wjmaclean 2013/06/21 18:20:53 Done.
jamesr 2013/07/03 21:12:14 I'm pretty sure this is completely dead code.
+ return gfx::Rect(
+ 0, 0, clip_layer_->bounds().width() - thickness_, thickness_);
+ else
+ return gfx::Rect(
+ 0, 0, thickness_, clip_layer_->bounds().height() - thickness_);
+}
+
+void InnerViewportScrollbar::PaintPart(SkCanvas* canvas,
+ ScrollbarPart part,
+ gfx::Rect content_rect) {}
+
+} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698