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

Side by Side Diff: Source/platform/scroll/ScrollView.h

Issue 603193005: Move the Widget hierarchy to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add ~Scrollbar assert Created 6 years, 2 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 unified diff | Download patch
OLDNEW
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
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 bool isScrollCornerVisible() const OVERRIDE; 54 virtual bool isScrollCornerVisible() const OVERRIDE;
52 virtual void scrollbarStyleChanged() OVERRIDE; 55 virtual void scrollbarStyleChanged() OVERRIDE;
53 virtual bool userInputScrollable(ScrollbarOrientation) const OVERRIDE; 56 virtual bool userInputScrollable(ScrollbarOrientation) const OVERRIDE;
54 virtual bool shouldPlaceVerticalScrollbarOnLeft() const OVERRIDE; 57 virtual bool shouldPlaceVerticalScrollbarOnLeft() const OVERRIDE;
55 58
56 virtual void notifyPageThatContentAreaWillPaint() const; 59 virtual void notifyPageThatContentAreaWillPaint() const;
57 60
58 // The window that hosts the ScrollView. The ScrollView will communicate scr olls and repaints to the 61 // The window that hosts the ScrollView. The ScrollView will communicate scr olls and repaints to the
59 // host window in the window's coordinate space. 62 // host window in the window's coordinate space.
60 virtual HostWindow* hostWindow() const = 0; 63 virtual HostWindow* hostWindow() const = 0;
61 64
62 // Returns a clip rect in host window coordinates. Used to clip the blit on a scroll. 65 // Returns a clip rect in host window coordinates. Used to clip the blit on a scroll.
63 virtual IntRect windowClipRect(IncludeScrollbarsInRect = ExcludeScrollbars) const = 0; 66 virtual IntRect windowClipRect(IncludeScrollbarsInRect = ExcludeScrollbars) const = 0;
64 67
68 typedef WillBeHeapHashSet<RefPtrWillBeMember<Widget> > ChildrenWidgetSet;
69
65 // Functions for child manipulation and inspection. 70 // Functions for child manipulation and inspection.
66 const HashSet<RefPtr<Widget> >* children() const { return &m_children; } 71 const ChildrenWidgetSet* children() const { return &m_children; }
67 virtual void addChild(PassRefPtr<Widget>); 72 virtual void addChild(PassRefPtrWillBeRawPtr<Widget>);
68 virtual void removeChild(Widget*); 73 virtual void removeChild(Widget*);
69 74
70 // If the scroll view does not use a native widget, then it will have cross- platform Scrollbars. These functions 75 // If the scroll view does not use a native widget, then it will have cross- platform Scrollbars. These functions
71 // can be used to obtain those scrollbars. 76 // can be used to obtain those scrollbars.
72 virtual Scrollbar* horizontalScrollbar() const OVERRIDE { return m_horizonta lScrollbar.get(); } 77 virtual Scrollbar* horizontalScrollbar() const OVERRIDE { return m_horizonta lScrollbar.get(); }
73 virtual Scrollbar* verticalScrollbar() const OVERRIDE { return m_verticalScr ollbar.get(); } 78 virtual Scrollbar* verticalScrollbar() const OVERRIDE { return m_verticalScr ollbar.get(); }
74 bool isScrollViewScrollbar(const Widget* child) const { return horizontalScr ollbar() == child || verticalScrollbar() == child; } 79 bool isScrollViewScrollbar(const Widget* child) const { return horizontalScr ollbar() == child || verticalScrollbar() == child; }
75 80
76 void positionScrollbarLayers(); 81 void positionScrollbarLayers();
77 82
(...skipping 18 matching lines...) Expand all
96 101
97 virtual void setCanHaveScrollbars(bool); 102 virtual void setCanHaveScrollbars(bool);
98 bool canHaveScrollbars() const { return horizontalScrollbarMode() != Scrollb arAlwaysOff || verticalScrollbarMode() != ScrollbarAlwaysOff; } 103 bool canHaveScrollbars() const { return horizontalScrollbarMode() != Scrollb arAlwaysOff || verticalScrollbarMode() != ScrollbarAlwaysOff; }
99 104
100 // By default, paint events are clipped to the visible area. If set to 105 // By default, paint events are clipped to the visible area. If set to
101 // false, paint events are no longer clipped. 106 // false, paint events are no longer clipped.
102 bool clipsPaintInvalidations() const { return m_clipsRepaints; } 107 bool clipsPaintInvalidations() const { return m_clipsRepaints; }
103 void setClipsRepaints(bool); 108 void setClipsRepaints(bool);
104 109
105 // Overridden by FrameView to create custom CSS scrollbars if applicable. 110 // Overridden by FrameView to create custom CSS scrollbars if applicable.
106 virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation); 111 virtual PassRefPtrWillBeRawPtr<Scrollbar> createScrollbar(ScrollbarOrientati on);
107 112
108 // The visible content rect has a location that is the scrolled offset of th e document. The width and height are the viewport width 113 // The visible content rect has a location that is the scrolled offset of th e document. The width and height are the viewport width
109 // and height. By default the scrollbars themselves are excluded from this r ectangle, but an optional boolean argument allows them to be 114 // and height. By default the scrollbars themselves are excluded from this r ectangle, but an optional boolean argument allows them to be
110 // included. 115 // included.
111 virtual IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollba rs) const OVERRIDE; 116 virtual IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollba rs) const OVERRIDE;
112 IntSize visibleSize() const { return visibleContentRect().size(); } 117 IntSize visibleSize() const { return visibleContentRect().size(); }
113 118
114 // visibleContentRect().size() is computed from unscaledVisibleContentSize() divided by the value of visibleContentScaleFactor. 119 // visibleContentRect().size() is computed from unscaledVisibleContentSize() divided by the value of visibleContentScaleFactor.
115 // For the main frame, visibleContentScaleFactor is equal to the page's page ScaleFactor; it's 1 otherwise. 120 // For the main frame, visibleContentScaleFactor is equal to the page's page ScaleFactor; it's 1 otherwise.
116 IntSize unscaledVisibleContentSize(IncludeScrollbarsInRect = ExcludeScrollba rs) const; 121 IntSize unscaledVisibleContentSize(IncludeScrollbarsInRect = ExcludeScrollba rs) const;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 virtual bool scrollbarsDisabled() const { return false; } 306 virtual bool scrollbarsDisabled() const { return false; }
302 307
303 private: 308 private:
304 bool adjustScrollbarExistence(ComputeScrollbarExistenceOption = FirstPass); 309 bool adjustScrollbarExistence(ComputeScrollbarExistenceOption = FirstPass);
305 void adjustScrollbarOpacity(); 310 void adjustScrollbarOpacity();
306 // FIXME(bokan): setScrollOffset, setScrollPosition, scrollTo, scrollToOffse tWithoutAnimation, 311 // FIXME(bokan): setScrollOffset, setScrollPosition, scrollTo, scrollToOffse tWithoutAnimation,
307 // notifyScrollPositionChanged...there's too many ways to scroll this class. This needs 312 // notifyScrollPositionChanged...there's too many ways to scroll this class. This needs
308 // some cleanup. 313 // some cleanup.
309 void setScrollOffsetFromUpdateScrollbars(const IntSize&); 314 void setScrollOffsetFromUpdateScrollbars(const IntSize&);
310 315
311 RefPtr<Scrollbar> m_horizontalScrollbar; 316 RefPtrWillBeMember<Scrollbar> m_horizontalScrollbar;
312 RefPtr<Scrollbar> m_verticalScrollbar; 317 RefPtrWillBeMember<Scrollbar> m_verticalScrollbar;
313 ScrollbarMode m_horizontalScrollbarMode; 318 ScrollbarMode m_horizontalScrollbarMode;
314 ScrollbarMode m_verticalScrollbarMode; 319 ScrollbarMode m_verticalScrollbarMode;
315 320
316 bool m_horizontalScrollbarLock; 321 bool m_horizontalScrollbarLock;
317 bool m_verticalScrollbarLock; 322 bool m_verticalScrollbarLock;
318 323
319 HashSet<RefPtr<Widget> > m_children; 324 ChildrenWidgetSet m_children;
320 325
321 IntSize m_pendingScrollDelta; 326 IntSize m_pendingScrollDelta;
322 IntSize m_scrollOffset; // FIXME: Would rather store this as a position, but we will wait to make this change until more code is shared. 327 IntSize m_scrollOffset; // FIXME: Would rather store this as a position, but we will wait to make this change until more code is shared.
323 IntPoint m_cachedScrollPosition; 328 IntPoint m_cachedScrollPosition;
324 IntSize m_contentsSize; 329 IntSize m_contentsSize;
325 330
326 int m_scrollbarsAvoidingResizer; 331 int m_scrollbarsAvoidingResizer;
327 bool m_scrollbarsSuppressed; 332 bool m_scrollbarsSuppressed;
328 333
329 bool m_inUpdateScrollbars; 334 bool m_inUpdateScrollbars;
(...skipping 10 matching lines...) Expand all
340 345
341 void calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntR ect& verticalOverhangRect); 346 void calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntR ect& verticalOverhangRect);
342 void updateOverhangAreas(); 347 void updateOverhangAreas();
343 }; // class ScrollView 348 }; // class ScrollView
344 349
345 DEFINE_TYPE_CASTS(ScrollView, Widget, widget, widget->isScrollView(), widget.isS crollView()); 350 DEFINE_TYPE_CASTS(ScrollView, Widget, widget, widget->isScrollView(), widget.isS crollView());
346 351
347 } // namespace blink 352 } // namespace blink
348 353
349 #endif // ScrollView_h 354 #endif // ScrollView_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698