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

Unified Diff: cc/pinch_zoom_scrollbar_layer_impl.h

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: Refactor for cleaner state/scrollbar split. Created 7 years, 11 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_layer_impl.h
diff --git a/cc/pinch_zoom_scrollbar_layer_impl.h b/cc/pinch_zoom_scrollbar_layer_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..7b7d102c9ea387854459c90a9e6f83a11304412d
--- /dev/null
+++ b/cc/pinch_zoom_scrollbar_layer_impl.h
@@ -0,0 +1,109 @@
+// 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.
+
+#ifndef PINCH_ZOOM_SCROLLBAR_LAYER_IMPL_H_
+#define PINCH_ZOOM_SCROLLBAR_LAYER_IMPL_H_
+
+#include "cc/cc_export.h"
+#include "cc/scoped_resource.h"
+#include "cc/scrollbar_layer_impl_base.h"
+#include "ui/gfx/rect.h"
+
+namespace cc {
+
+class PinchZoomViewport;
+
+// PinchZoomScrollbarState exists to store the state associated with a
+// PinchZoomScrollbarLayerImpl, so the latter can be treated as an inexpensive
+// wrapper that can be cheaply created and discarded.
Ian Vollick 2013/01/15 20:33:48 We should design a system that allows impl-only la
+class CC_EXPORT PinchZoomScrollbarState {
+ public:
+ PinchZoomScrollbarState(WebKit::WebScrollbar::Orientation,
+ PinchZoomViewport* owner);
+ ~PinchZoomScrollbarState();
+
+ WebKit::WebScrollbar::Orientation orientation() const {
+ return orientation_;
+ }
+
+ scoped_ptr<ScopedResource>& thumb_texture() {
+ return thumb_texture_;
+ }
+
+ gfx::Rect& thumb_rect() {
+ return thumb_rect_;
+ }
+
+ float& thumb_position() {
+ return thumb_position_;
+ }
+
+ int& track_length() {
+ return track_length_;
+ }
+
+ int& maximum_position() {
+ return maximum_position_;
+ }
+
+ gfx::SizeF layout_viewport_size() const;
+ gfx::Vector2dF zoomed_viewport_offset() const;
+ float total_page_scale_factor() const;
+ float device_scale_factor() const;
+ LayerImpl* root_scroll_layer();
+
+ // A separate function to trigger size & position changes while
+ // *not* in willDraw().
+ void RefreshSizeAndPosition(LayerImpl*);
+ bool ShouldDisplayPinchZoomScrollbars();
+
+ int track_width() const {
+ return kTrackWidth;
+ }
+
+ private:
+ static const int kTrackWidth = 10;
+ PinchZoomViewport* owner_;
+
+ WebKit::WebScrollbar::Orientation orientation_;
+
+ scoped_ptr<ScopedResource> thumb_texture_;
+ gfx::Rect thumb_rect_;
+ float thumb_position_;
+ int track_length_;
+ int maximum_position_;
+};
+
+class CC_EXPORT PinchZoomScrollbarLayerImpl : public ScrollbarLayerImplBase {
+ public:
+ static scoped_ptr<PinchZoomScrollbarLayerImpl> create(
+ LayerTreeImpl* treeImpl, int id, PinchZoomScrollbarState* state);
+ virtual ~PinchZoomScrollbarLayerImpl();
+
+ // ScrollbarLayerImplBase overrides.
+ virtual float currentPos() const OVERRIDE;
+ virtual int totalSize() const OVERRIDE;
+ virtual int maximum() const OVERRIDE;
+
+ virtual WebKit::WebScrollbar::Orientation orientation() const OVERRIDE;
+
+ // LayerImpl overrides.
+ virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE;
+ virtual void didLoseOutputSurface() OVERRIDE;
+ virtual void willDraw(ResourceProvider*) OVERRIDE;
+ // The pinch-zoom scrollbars should never have an implTransform applied to them.
+ virtual void setImplTransform(const gfx::Transform& transform) OVERRIDE { }
+
+ // Class-specific functions.
+
+ private:
+ PinchZoomScrollbarLayerImpl(
+ LayerTreeImpl* treeImpl, int id, PinchZoomScrollbarState* state);
+
+ PinchZoomScrollbarState* state_;
+
+};
+
+} // namespace cc
+#endif // PINCH_ZOOM_SCROLLBAR_LAYER_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698