OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Holger Hans Peter Freyther | 3 * Copyright (C) 2009 Holger Hans Peter Freyther |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 12 matching lines...) Expand all Loading... |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #ifndef ScrollView_h | 27 #ifndef ScrollView_h |
28 #define ScrollView_h | 28 #define ScrollView_h |
29 | 29 |
30 #include "platform/PlatformExport.h" | 30 #include "platform/PlatformExport.h" |
31 #include "platform/Widget.h" | 31 #include "platform/Widget.h" |
32 #include "platform/geometry/IntRect.h" | 32 #include "platform/geometry/IntRect.h" |
| 33 #include "platform/heap/Handle.h" |
33 #include "platform/scroll/ScrollTypes.h" | 34 #include "platform/scroll/ScrollTypes.h" |
34 #include "platform/scroll/ScrollableArea.h" | 35 #include "platform/scroll/ScrollableArea.h" |
35 #include "platform/scroll/Scrollbar.h" | 36 #include "platform/scroll/Scrollbar.h" |
36 | 37 |
37 #include "wtf/HashSet.h" | 38 #include "wtf/HashSet.h" |
38 #include "wtf/TemporaryChange.h" | 39 #include "wtf/TemporaryChange.h" |
39 | 40 |
40 namespace blink { | 41 namespace blink { |
41 | 42 |
42 class Scrollbar; | 43 class Scrollbar; |
43 | 44 |
44 class PLATFORM_EXPORT ScrollView : public Widget, public ScrollableArea { | 45 class PLATFORM_EXPORT ScrollView : public Widget, public ScrollableArea { |
45 public: | 46 public: |
46 virtual ~ScrollView(); | 47 virtual ~ScrollView(); |
47 | 48 |
| 49 virtual void trace(Visitor*) OVERRIDE; |
| 50 |
48 // ScrollableArea functions. | 51 // ScrollableArea functions. |
49 virtual int scrollSize(ScrollbarOrientation) const OVERRIDE; | 52 virtual int scrollSize(ScrollbarOrientation) const OVERRIDE; |
50 virtual void setScrollOffset(const IntPoint&) OVERRIDE; | 53 virtual void setScrollOffset(const IntPoint&) OVERRIDE; |
51 virtual void setScrollOffset(const DoublePoint&) OVERRIDE; | 54 virtual void setScrollOffset(const DoublePoint&) OVERRIDE; |
52 virtual bool isScrollCornerVisible() const OVERRIDE; | 55 virtual bool isScrollCornerVisible() const OVERRIDE; |
53 virtual void scrollbarStyleChanged() OVERRIDE; | 56 virtual void scrollbarStyleChanged() OVERRIDE; |
54 virtual bool userInputScrollable(ScrollbarOrientation) const OVERRIDE; | 57 virtual bool userInputScrollable(ScrollbarOrientation) const OVERRIDE; |
55 virtual bool shouldPlaceVerticalScrollbarOnLeft() const OVERRIDE; | 58 virtual bool shouldPlaceVerticalScrollbarOnLeft() const OVERRIDE; |
56 | 59 |
57 virtual void notifyPageThatContentAreaWillPaint() const; | 60 virtual void notifyPageThatContentAreaWillPaint() const; |
58 | 61 |
59 // The window that hosts the ScrollView. The ScrollView will communicate scr
olls and repaints to the | 62 // The window that hosts the ScrollView. The ScrollView will communicate scr
olls and repaints to the |
60 // host window in the window's coordinate space. | 63 // host window in the window's coordinate space. |
61 virtual HostWindow* hostWindow() const = 0; | 64 virtual HostWindow* hostWindow() const = 0; |
62 | 65 |
63 // Returns a clip rect in host window coordinates. Used to clip the blit on
a scroll. | 66 // Returns a clip rect in host window coordinates. Used to clip the blit on
a scroll. |
64 virtual IntRect windowClipRect(IncludeScrollbarsInRect = ExcludeScrollbars)
const = 0; | 67 virtual IntRect windowClipRect(IncludeScrollbarsInRect = ExcludeScrollbars)
const = 0; |
65 | 68 |
| 69 typedef WillBeHeapHashSet<RefPtrWillBeMember<Widget> > ChildrenWidgetSet; |
| 70 |
66 // Functions for child manipulation and inspection. | 71 // Functions for child manipulation and inspection. |
67 const HashSet<RefPtr<Widget> >* children() const { return &m_children; } | 72 const ChildrenWidgetSet* children() const { return &m_children; } |
68 virtual void addChild(PassRefPtr<Widget>); | 73 virtual void addChild(PassRefPtrWillBeRawPtr<Widget>); |
69 virtual void removeChild(Widget*); | 74 virtual void removeChild(Widget*); |
70 | 75 |
71 // If the scroll view does not use a native widget, then it will have cross-
platform Scrollbars. These functions | 76 // If the scroll view does not use a native widget, then it will have cross-
platform Scrollbars. These functions |
72 // can be used to obtain those scrollbars. | 77 // can be used to obtain those scrollbars. |
73 virtual Scrollbar* horizontalScrollbar() const OVERRIDE { return m_horizonta
lScrollbar.get(); } | 78 virtual Scrollbar* horizontalScrollbar() const OVERRIDE { return m_horizonta
lScrollbar.get(); } |
74 virtual Scrollbar* verticalScrollbar() const OVERRIDE { return m_verticalScr
ollbar.get(); } | 79 virtual Scrollbar* verticalScrollbar() const OVERRIDE { return m_verticalScr
ollbar.get(); } |
75 bool isScrollViewScrollbar(const Widget* child) const { return horizontalScr
ollbar() == child || verticalScrollbar() == child; } | 80 bool isScrollViewScrollbar(const Widget* child) const { return horizontalScr
ollbar() == child || verticalScrollbar() == child; } |
76 | 81 |
77 void positionScrollbarLayers(); | 82 void positionScrollbarLayers(); |
78 | 83 |
(...skipping 18 matching lines...) Expand all Loading... |
97 | 102 |
98 virtual void setCanHaveScrollbars(bool); | 103 virtual void setCanHaveScrollbars(bool); |
99 bool canHaveScrollbars() const { return horizontalScrollbarMode() != Scrollb
arAlwaysOff || verticalScrollbarMode() != ScrollbarAlwaysOff; } | 104 bool canHaveScrollbars() const { return horizontalScrollbarMode() != Scrollb
arAlwaysOff || verticalScrollbarMode() != ScrollbarAlwaysOff; } |
100 | 105 |
101 // By default, paint events are clipped to the visible area. If set to | 106 // By default, paint events are clipped to the visible area. If set to |
102 // false, paint events are no longer clipped. | 107 // false, paint events are no longer clipped. |
103 bool clipsPaintInvalidations() const { return m_clipsRepaints; } | 108 bool clipsPaintInvalidations() const { return m_clipsRepaints; } |
104 void setClipsRepaints(bool); | 109 void setClipsRepaints(bool); |
105 | 110 |
106 // Overridden by FrameView to create custom CSS scrollbars if applicable. | 111 // Overridden by FrameView to create custom CSS scrollbars if applicable. |
107 virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation); | 112 virtual PassRefPtrWillBeRawPtr<Scrollbar> createScrollbar(ScrollbarOrientati
on); |
108 | 113 |
109 // The visible content rect has a location that is the scrolled offset of th
e document. The width and height are the viewport width | 114 // The visible content rect has a location that is the scrolled offset of th
e document. The width and height are the viewport width |
110 // and height. By default the scrollbars themselves are excluded from this r
ectangle, but an optional boolean argument allows them to be | 115 // and height. By default the scrollbars themselves are excluded from this r
ectangle, but an optional boolean argument allows them to be |
111 // included. | 116 // included. |
112 virtual IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollba
rs) const OVERRIDE; | 117 virtual IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollba
rs) const OVERRIDE; |
113 IntSize visibleSize() const { return visibleContentRect().size(); } | 118 IntSize visibleSize() const { return visibleContentRect().size(); } |
114 | 119 |
115 // visibleContentRect().size() is computed from unscaledVisibleContentSize()
divided by the value of visibleContentScaleFactor. | 120 // visibleContentRect().size() is computed from unscaledVisibleContentSize()
divided by the value of visibleContentScaleFactor. |
116 // For the main frame, visibleContentScaleFactor is equal to the page's page
ScaleFactor; it's 1 otherwise. | 121 // For the main frame, visibleContentScaleFactor is equal to the page's page
ScaleFactor; it's 1 otherwise. |
117 IntSize unscaledVisibleContentSize(IncludeScrollbarsInRect = ExcludeScrollba
rs) const; | 122 IntSize unscaledVisibleContentSize(IncludeScrollbarsInRect = ExcludeScrollba
rs) const; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 virtual bool scrollbarsDisabled() const { return false; } | 310 virtual bool scrollbarsDisabled() const { return false; } |
306 | 311 |
307 private: | 312 private: |
308 bool adjustScrollbarExistence(ComputeScrollbarExistenceOption = FirstPass); | 313 bool adjustScrollbarExistence(ComputeScrollbarExistenceOption = FirstPass); |
309 void adjustScrollbarOpacity(); | 314 void adjustScrollbarOpacity(); |
310 // FIXME(bokan): setScrollOffset, setScrollPosition, scrollTo, scrollToOffse
tWithoutAnimation, | 315 // FIXME(bokan): setScrollOffset, setScrollPosition, scrollTo, scrollToOffse
tWithoutAnimation, |
311 // notifyScrollPositionChanged...there's too many ways to scroll this class.
This needs | 316 // notifyScrollPositionChanged...there's too many ways to scroll this class.
This needs |
312 // some cleanup. | 317 // some cleanup. |
313 void setScrollOffsetFromUpdateScrollbars(const IntSize&); | 318 void setScrollOffsetFromUpdateScrollbars(const IntSize&); |
314 | 319 |
315 RefPtr<Scrollbar> m_horizontalScrollbar; | 320 RefPtrWillBeMember<Scrollbar> m_horizontalScrollbar; |
316 RefPtr<Scrollbar> m_verticalScrollbar; | 321 RefPtrWillBeMember<Scrollbar> m_verticalScrollbar; |
317 ScrollbarMode m_horizontalScrollbarMode; | 322 ScrollbarMode m_horizontalScrollbarMode; |
318 ScrollbarMode m_verticalScrollbarMode; | 323 ScrollbarMode m_verticalScrollbarMode; |
319 | 324 |
320 bool m_horizontalScrollbarLock; | 325 bool m_horizontalScrollbarLock; |
321 bool m_verticalScrollbarLock; | 326 bool m_verticalScrollbarLock; |
322 | 327 |
323 HashSet<RefPtr<Widget> > m_children; | 328 ChildrenWidgetSet m_children; |
324 | 329 |
325 DoubleSize m_pendingScrollDelta; | 330 DoubleSize m_pendingScrollDelta; |
326 DoublePoint m_scrollPosition; | 331 DoublePoint m_scrollPosition; |
327 DoublePoint m_cachedScrollPosition; | 332 DoublePoint m_cachedScrollPosition; |
328 IntSize m_contentsSize; | 333 IntSize m_contentsSize; |
329 | 334 |
330 int m_scrollbarsAvoidingResizer; | 335 int m_scrollbarsAvoidingResizer; |
331 bool m_scrollbarsSuppressed; | 336 bool m_scrollbarsSuppressed; |
332 | 337 |
333 bool m_inUpdateScrollbars; | 338 bool m_inUpdateScrollbars; |
(...skipping 10 matching lines...) Expand all Loading... |
344 | 349 |
345 void calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntR
ect& verticalOverhangRect); | 350 void calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntR
ect& verticalOverhangRect); |
346 void updateOverhangAreas(); | 351 void updateOverhangAreas(); |
347 }; // class ScrollView | 352 }; // class ScrollView |
348 | 353 |
349 DEFINE_TYPE_CASTS(ScrollView, Widget, widget, widget->isScrollView(), widget.isS
crollView()); | 354 DEFINE_TYPE_CASTS(ScrollView, Widget, widget, widget->isScrollView(), widget.isS
crollView()); |
350 | 355 |
351 } // namespace blink | 356 } // namespace blink |
352 | 357 |
353 #endif // ScrollView_h | 358 #endif // ScrollView_h |
OLD | NEW |