hyatt@apple.com | 30ed544 | 2008-09-13 18:39:58 +0000 | [diff] [blame] | 1 | /* |
weinig@apple.com | d7d77c3 | 2011-01-21 20:15:04 +0000 | [diff] [blame] | 2 | * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. |
hyatt@apple.com | 30ed544 | 2008-09-13 18:39:58 +0000 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
weinig@apple.com | d7d77c3 | 2011-01-21 20:15:04 +0000 | [diff] [blame] | 26 | #ifndef ScrollableArea_h |
| 27 | #define ScrollableArea_h |
hyatt@apple.com | 30ed544 | 2008-09-13 18:39:58 +0000 | [diff] [blame] | 28 | |
| 29 | #include "IntRect.h" |
hyatt@apple.com | 0819bcc | 2009-07-02 17:51:50 +0000 | [diff] [blame] | 30 | #include "Scrollbar.h" |
eric@webkit.org | e5cf2da | 2008-12-05 22:10:27 +0000 | [diff] [blame] | 31 | #include <wtf/Vector.h> |
hyatt@apple.com | 30ed544 | 2008-09-13 18:39:58 +0000 | [diff] [blame] | 32 | |
| 33 | namespace WebCore { |
| 34 | |
weinig@apple.com | 2a13aa8 | 2011-01-20 23:14:47 +0000 | [diff] [blame] | 35 | class FloatPoint; |
bdakin@apple.com | b38a635 | 2011-02-10 00:28:50 +0000 | [diff] [blame^] | 36 | class PlatformGestureEvent; |
weinig@apple.com | 2a13aa8 | 2011-01-20 23:14:47 +0000 | [diff] [blame] | 37 | class PlatformWheelEvent; |
commit-queue@webkit.org | 1bf3b4b | 2010-09-08 19:31:47 +0000 | [diff] [blame] | 38 | class ScrollAnimator; |
| 39 | |
weinig@apple.com | d7d77c3 | 2011-01-21 20:15:04 +0000 | [diff] [blame] | 40 | class ScrollableArea { |
hyatt@apple.com | 30ed544 | 2008-09-13 18:39:58 +0000 | [diff] [blame] | 41 | public: |
weinig@apple.com | d7d77c3 | 2011-01-21 20:15:04 +0000 | [diff] [blame] | 42 | ScrollableArea(); |
| 43 | virtual ~ScrollableArea(); |
commit-queue@webkit.org | 1bf3b4b | 2010-09-08 19:31:47 +0000 | [diff] [blame] | 44 | |
weinig@apple.com | 2a13aa8 | 2011-01-20 23:14:47 +0000 | [diff] [blame] | 45 | bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1); |
| 46 | void scrollToOffsetWithoutAnimation(const FloatPoint&); |
| 47 | void scrollToOffsetWithoutAnimation(ScrollbarOrientation, float offset); |
| 48 | void scrollToXOffsetWithoutAnimation(float x); |
| 49 | void scrollToYOffsetWithoutAnimation(float x); |
commit-queue@webkit.org | 1bf3b4b | 2010-09-08 19:31:47 +0000 | [diff] [blame] | 50 | |
weinig@apple.com | 10187a9 | 2011-01-27 05:12:24 +0000 | [diff] [blame] | 51 | void handleWheelEvent(PlatformWheelEvent&); |
weinig@apple.com | cc0f140 | 2011-01-28 19:05:43 +0000 | [diff] [blame] | 52 | #if ENABLE(GESTURE_EVENTS) |
| 53 | void handleGestureEvent(const PlatformGestureEvent&); |
| 54 | #endif |
| 55 | |
| 56 | // Functions for controlling if you can scroll past the end of the document. |
| 57 | bool constrainsScrollingToContentEdge() const { return m_constrainsScrollingToContentEdge; } |
| 58 | void setConstrainsScrollingToContentEdge(bool constrainsScrollingToContentEdge) { m_constrainsScrollingToContentEdge = constrainsScrollingToContentEdge; } |
weinig@apple.com | 10187a9 | 2011-01-27 05:12:24 +0000 | [diff] [blame] | 59 | |
weinig@apple.com | 3021524 | 2011-02-03 18:13:32 +0000 | [diff] [blame] | 60 | bool inLiveResize() const { return m_inLiveResize; } |
| 61 | void willStartLiveResize(); |
| 62 | void willEndLiveResize(); |
| 63 | |
weinig@apple.com | f17b93c | 2011-02-07 21:29:12 +0000 | [diff] [blame] | 64 | void didAddVerticalScrollbar(Scrollbar*); |
| 65 | void willRemoveVerticalScrollbar(Scrollbar*); |
| 66 | void didAddHorizontalScrollbar(Scrollbar*); |
| 67 | void willRemoveHorizontalScrollbar(Scrollbar*); |
| 68 | |
bdakin@apple.com | 3216752 | 2011-02-01 20:35:25 +0000 | [diff] [blame] | 69 | ScrollAnimator* scrollAnimator() const { return m_scrollAnimator.get(); } |
weinig@apple.com | 3021524 | 2011-02-03 18:13:32 +0000 | [diff] [blame] | 70 | |
weinig@apple.com | 2a13aa8 | 2011-01-20 23:14:47 +0000 | [diff] [blame] | 71 | virtual int scrollSize(ScrollbarOrientation) const = 0; |
| 72 | virtual int scrollPosition(Scrollbar*) const = 0; |
hyatt@apple.com | 6fa40c5 | 2008-10-03 07:06:28 +0000 | [diff] [blame] | 73 | virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0; |
hyatt@apple.com | 30ed544 | 2008-09-13 18:39:58 +0000 | [diff] [blame] | 74 | virtual bool isActive() const = 0; |
hyatt@apple.com | e2a30fd | 2008-10-13 21:23:21 +0000 | [diff] [blame] | 75 | virtual bool scrollbarCornerPresent() const = 0; |
eric@webkit.org | e5cf2da | 2008-12-05 22:10:27 +0000 | [diff] [blame] | 76 | virtual void getTickmarks(Vector<IntRect>&) const { } |
hyatt@apple.com | b327f5d | 2009-07-02 17:31:42 +0000 | [diff] [blame] | 77 | |
weinig@apple.com | 2a13aa8 | 2011-01-20 23:14:47 +0000 | [diff] [blame] | 78 | // This function should be overriden by subclasses to perform the actual |
| 79 | // scroll of the content. |
| 80 | virtual void setScrollOffset(const IntPoint&) = 0; |
| 81 | |
hyatt@apple.com | b327f5d | 2009-07-02 17:31:42 +0000 | [diff] [blame] | 82 | // Convert points and rects between the scrollbar and its containing view. |
| 83 | // The client needs to implement these in order to be aware of layout effects |
| 84 | // like CSS transforms. |
| 85 | virtual IntRect convertFromScrollbarToContainingView(const Scrollbar* scrollbar, const IntRect& scrollbarRect) const |
| 86 | { |
| 87 | return scrollbar->Widget::convertToContainingView(scrollbarRect); |
| 88 | } |
hyatt@apple.com | b327f5d | 2009-07-02 17:31:42 +0000 | [diff] [blame] | 89 | virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntRect& parentRect) const |
| 90 | { |
| 91 | return scrollbar->Widget::convertFromContainingView(parentRect); |
| 92 | } |
hyatt@apple.com | b327f5d | 2009-07-02 17:31:42 +0000 | [diff] [blame] | 93 | virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar* scrollbar, const IntPoint& scrollbarPoint) const |
| 94 | { |
| 95 | return scrollbar->Widget::convertToContainingView(scrollbarPoint); |
| 96 | } |
hyatt@apple.com | b327f5d | 2009-07-02 17:31:42 +0000 | [diff] [blame] | 97 | virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntPoint& parentPoint) const |
| 98 | { |
| 99 | return scrollbar->Widget::convertFromContainingView(parentPoint); |
| 100 | } |
commit-queue@webkit.org | 1bf3b4b | 2010-09-08 19:31:47 +0000 | [diff] [blame] | 101 | |
weinig@apple.com | 2a13aa8 | 2011-01-20 23:14:47 +0000 | [diff] [blame] | 102 | virtual Scrollbar* horizontalScrollbar() const { return 0; } |
| 103 | virtual Scrollbar* verticalScrollbar() const { return 0; } |
| 104 | |
weinig@apple.com | 10187a9 | 2011-01-27 05:12:24 +0000 | [diff] [blame] | 105 | virtual IntPoint scrollPosition() const { ASSERT_NOT_REACHED(); return IntPoint(); } |
| 106 | virtual IntPoint minimumScrollPosition() const { ASSERT_NOT_REACHED(); return IntPoint(); } |
| 107 | virtual IntPoint maximumScrollPosition() const { ASSERT_NOT_REACHED(); return IntPoint(); } |
weinig@apple.com | 10187a9 | 2011-01-27 05:12:24 +0000 | [diff] [blame] | 108 | virtual IntRect visibleContentRect(bool = false) const { ASSERT_NOT_REACHED(); return IntRect(); } |
| 109 | virtual int visibleHeight() const { ASSERT_NOT_REACHED(); return 0; } |
| 110 | virtual int visibleWidth() const { ASSERT_NOT_REACHED(); return 0; } |
weinig@apple.com | cc0f140 | 2011-01-28 19:05:43 +0000 | [diff] [blame] | 111 | virtual IntSize contentsSize() const { ASSERT_NOT_REACHED(); return IntSize(); } |
weinig@apple.com | cc0f140 | 2011-01-28 19:05:43 +0000 | [diff] [blame] | 112 | virtual IntSize overhangAmount() const { ASSERT_NOT_REACHED(); return IntSize(); } |
bdakin@apple.com | 3216752 | 2011-02-01 20:35:25 +0000 | [diff] [blame] | 113 | virtual IntPoint currentMousePosition() const { return IntPoint(); } |
weinig@apple.com | 3021524 | 2011-02-03 18:13:32 +0000 | [diff] [blame] | 114 | virtual void didCompleteRubberBand(const IntSize&) const { ASSERT_NOT_REACHED(); } |
bdakin@apple.com | 3216752 | 2011-02-01 20:35:25 +0000 | [diff] [blame] | 115 | |
bdakin@apple.com | b38a635 | 2011-02-10 00:28:50 +0000 | [diff] [blame^] | 116 | virtual bool scrollbarWillRenderIntoCompositingLayer() const { return false; } |
| 117 | |
commit-queue@webkit.org | 1bf3b4b | 2010-09-08 19:31:47 +0000 | [diff] [blame] | 118 | private: |
weinig@apple.com | 2a13aa8 | 2011-01-20 23:14:47 +0000 | [diff] [blame] | 119 | // NOTE: Only called from the ScrollAnimator. |
| 120 | friend class ScrollAnimator; |
| 121 | void setScrollOffsetFromAnimation(const IntPoint&); |
| 122 | |
commit-queue@webkit.org | 1bf3b4b | 2010-09-08 19:31:47 +0000 | [diff] [blame] | 123 | OwnPtr<ScrollAnimator> m_scrollAnimator; |
weinig@apple.com | cc0f140 | 2011-01-28 19:05:43 +0000 | [diff] [blame] | 124 | bool m_constrainsScrollingToContentEdge; |
bdakin@apple.com | 3216752 | 2011-02-01 20:35:25 +0000 | [diff] [blame] | 125 | |
| 126 | bool m_inLiveResize; |
hyatt@apple.com | 30ed544 | 2008-09-13 18:39:58 +0000 | [diff] [blame] | 127 | }; |
| 128 | |
weinig@apple.com | 2a13aa8 | 2011-01-20 23:14:47 +0000 | [diff] [blame] | 129 | } // namespace WebCore |
| 130 | |
weinig@apple.com | d7d77c3 | 2011-01-21 20:15:04 +0000 | [diff] [blame] | 131 | #endif // ScrollableArea_h |