Chromium Code Reviews| Index: cc/pinch_zoom_scrollbars_manager.h |
| diff --git a/cc/pinch_zoom_scrollbars_manager.h b/cc/pinch_zoom_scrollbars_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..169c25f4c6e182b7dd4ebf1b1bbc149f2caed449 |
| --- /dev/null |
| +++ b/cc/pinch_zoom_scrollbars_manager.h |
| @@ -0,0 +1,158 @@ |
| +// Copyright 2012 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 CC_PINCH_ZOOM_SCROLLBARS_MANAGER_H_ |
| +#define CC_PINCH_ZOOM_SCROLLBARS_MANAGER_H_ |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "cc/scoped_resource.h" |
| +#include "cc/scrollbar_geometry_fixed_thumb.h" |
| +#include "cc/scrollbar_layer_impl.h" |
| +#include <public/WebRect.h> |
| +#include <public/WebScrollbar.h> |
| + |
| +namespace cc { |
| + |
| +class PinchZoomScrollbarsManager { |
| +public: |
| + static scoped_ptr<PinchZoomScrollbarsManager> create(); |
| + ~PinchZoomScrollbarsManager(); |
| + |
| + void updateThumbTextures(ResourceProvider* resourceProvider); |
| + void setContentBounds(const gfx::Size&); |
| + void setPinchZoomViewportPosition(const gfx::Vector2dF&, float scale); |
| + void setPinchZoomViewportBounds(const gfx::Size&); |
| + void setRootScrollLayerOffset(const gfx::Vector2d& offset, const gfx::Vector2d& maxOffset); |
| + |
| + void setDeviceScaleFactor(float scale) { m_deviceScaleFactor = scale; } |
| + |
| + void setScrollbarVertical(ScrollbarLayerImpl* scrollbar); |
| + void setScrollbarHorizontal(ScrollbarLayerImpl* scrollbar); |
| + |
| + ScrollbarLayerImpl* scrollbarVertical() const { return m_pinchZoomScrollbarVertical; } |
| + ScrollbarLayerImpl* scrollbarHorizontal() const { return m_pinchZoomScrollbarHorizontal; } |
| + |
| + void setEnabled(bool enabled) { m_enabled = enabled; } |
| + |
| +private: |
| + PinchZoomScrollbarsManager(); |
| + |
| + class Scrollbar : public WebKit::WebScrollbar { |
| + public: |
| + Scrollbar(PinchZoomScrollbarsManager* owner, WebScrollbar::Orientation orientation) |
| + : m_owner(owner) |
| + , m_orientation(orientation) |
| + { } |
| + |
| + // WebScrollbar implementation |
| + virtual bool isOverlay() const; |
| + virtual int value() const; |
| + virtual WebKit::WebPoint location() const; |
| + virtual WebKit::WebSize size() const; |
| + virtual bool enabled() const; |
| + virtual int maximum() const; |
| + virtual int totalSize() const; |
| + virtual bool isScrollViewScrollbar() const; |
| + virtual bool isScrollableAreaActive() const; |
| + virtual void getTickmarks(WebKit::WebVector<WebKit::WebRect>& tickmarks) const; |
| + virtual WebScrollbar::ScrollbarControlSize controlSize() const; |
| + virtual WebScrollbar::ScrollbarPart pressedPart() const; |
| + virtual WebScrollbar::ScrollbarPart hoveredPart() const; |
| + virtual WebScrollbar::ScrollbarOverlayStyle scrollbarOverlayStyle() const; |
| + virtual WebScrollbar::Orientation orientation() const; |
| + virtual bool isCustomScrollbar() const; |
| + |
| + private: |
| + PinchZoomScrollbarsManager* m_owner; |
| + WebScrollbar::Orientation m_orientation; |
| + }; |
| + |
| + class ScrollbarThemeGeometry : public WebKit::WebScrollbarThemeGeometry { |
| + public: |
| + explicit ScrollbarThemeGeometry(PinchZoomScrollbarsManager* owner) : m_owner(owner) { } |
| + |
| + virtual WebKit::WebScrollbarThemeGeometry* clone() const OVERRIDE; |
| + virtual int thumbPosition(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual int thumbLength(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual int trackPosition(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual int trackLength(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual bool hasButtons(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual bool hasThumb(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual WebKit::WebRect trackRect(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual WebKit::WebRect thumbRect(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual int minimumThumbLength(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual int scrollbarThickness(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual WebKit::WebRect backButtonStartRect(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual WebKit::WebRect backButtonEndRect(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual WebKit::WebRect forwardButtonStartRect(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual WebKit::WebRect forwardButtonEndRect(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual WebKit::WebRect constrainTrackRectToTrackPieces(WebKit::WebScrollbar*, const WebKit::WebRect&) OVERRIDE; |
| + virtual void splitTrack(WebKit::WebScrollbar*, const WebKit::WebRect& track, WebKit::WebRect& startTrack, WebKit::WebRect& thumb, WebKit::WebRect& endTrack) OVERRIDE; |
| + |
| + private: |
| + PinchZoomScrollbarsManager* m_owner; |
| + }; |
| + |
| + // We need to override (at least) the splitTrack() function from ScrollbarGeometryFixedThumb, |
| + // so this interface exists to allow us to implement the required functions. |
| + class PZScrollbarGeometry : public ScrollbarGeometryFixedThumb { |
|
enne (OOO)
2012/12/13 17:43:38
Why are you using FixedThumb?
wjmaclean
2012/12/13 18:26:50
Primarily because ScrollbarLayerImpl requires this
enne (OOO)
2012/12/13 18:57:42
Ah, just curious. FixedThumb is there because Scr
|
| + public: |
| + static scoped_ptr<ScrollbarGeometryFixedThumb> create(scoped_ptr<WebKit::WebScrollbarThemeGeometry>, PinchZoomScrollbarsManager* owner); |
| + virtual ~PZScrollbarGeometry(); |
| + |
| + virtual WebKit::WebScrollbarThemeGeometry* clone() const OVERRIDE; |
| + virtual int thumbLength(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual int thumbPosition(WebKit::WebScrollbar*) OVERRIDE; |
| + virtual void splitTrack(WebKit::WebScrollbar*, const WebKit::WebRect& track, WebKit::WebRect& startTrack, WebKit::WebRect& thumb, WebKit::WebRect& endTrack) OVERRIDE; |
| + |
| + private: |
| + explicit PZScrollbarGeometry(scoped_ptr<WebKit::WebScrollbarThemeGeometry>, PinchZoomScrollbarsManager* owner); |
| + |
| + PinchZoomScrollbarsManager* m_owner; |
| + }; |
| + |
| + static const int kTrackWidth = 15; |
| + WebKit::WebRect thumbRect(const WebKit::WebScrollbar*) const; |
| + WebKit::WebRect trackRect(const WebKit::WebScrollbar*) const; |
| + int thumbLength(const WebKit::WebScrollbar*) const ; |
| + int trackLength(const WebKit::WebScrollbar*) const ; |
| + // The following function allows us to include device scale factor in the |
| + // track width at some later time, if we wish. |
| + int trackWidth() const { return kTrackWidth; } |
| + int position(const WebKit::WebScrollbar*) const; |
| + int maximum(const WebKit::WebScrollbar*) const; |
| + |
| + void updateOneThumb(ScrollbarLayerImpl* scrollbarImpl, |
| + Scrollbar& scrollbar, |
| + scoped_ptr<ScopedResource>& thumbTexture, |
| + scoped_ptr<SkCanvas>& thumbCanvas, |
| + ResourceProvider* resourceProvider); |
| + |
| + void updateScrollbarImpl(ScrollbarLayerImpl*, WebKit::WebScrollbar*); |
| + |
| + Scrollbar m_scrollbarVertical; |
| + Scrollbar m_scrollbarHorizontal; |
| + |
| + // The layer tree owns the scrollbar impl pointers. |
| + ScrollbarLayerImpl* m_pinchZoomScrollbarVertical; |
|
enne (OOO)
2012/12/13 17:43:38
This class is way too smart and the layers are way
wjmaclean
2012/12/13 18:26:50
OK, I'll create a derived class to do it.
|
| + ScrollbarLayerImpl* m_pinchZoomScrollbarHorizontal; |
| + |
| + scoped_ptr<ScopedResource> m_verticalThumbTexture; |
| + scoped_ptr<ScopedResource> m_horizontalThumbTexture; |
| + |
| + scoped_ptr<SkCanvas> m_verticalThumbCanvas; |
| + scoped_ptr<SkCanvas> m_horizontalThumbCanvas; |
| + |
| + gfx::Vector2dF m_layoutViewportPosition; |
| + gfx::Size m_layoutViewportSize; |
| + gfx::Size m_layoutDocumentSize; |
| + gfx::Vector2d m_rootScrollOffset; |
| + gfx::Vector2d m_rootMaxScrollOffset; |
| + float m_viewportScale; |
| + float m_deviceScaleFactor; |
| + |
| + bool m_enabled; |
| +}; |
| +} |
| +#endif // CC_PINCH_ZOOM_SCROLLBARS_MANAGER_H_ |