1/*
2 * Copyright (C) 2004, 2006, 2007, 2008, 2013, 2014 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Holger Hans Peter Freyther
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
25 */
26
27#ifndef ScrollView_h
28#define ScrollView_h
29
30#include "FloatRect.h"
31#include "IntRect.h"
32#include "Scrollbar.h"
33#include "ScrollableArea.h"
34#include "ScrollTypes.h"
35#include "Widget.h"
36
37#include <wtf/HashSet.h>
38
39#if PLATFORM(IOS)
40#ifdef __OBJC__
41@class WAKScrollView;
42@class WAKView;
43#else
44class WAKScrollView;
45class WAKView;
46#endif
47
48#ifndef NSScrollView
49#define NSScrollView WAKScrollView
50#endif
51
52#ifndef NSView
53#define NSView WAKView
54#endif
55#endif // PLATFORM(IOS)
56
57#if PLATFORM(COCOA) && defined __OBJC__
58@protocol WebCoreFrameScrollView;
59#endif
60
61namespace WebCore {
62
63class HostWindow;
64class LegacyTileCache;
65class Scrollbar;
66
67class ScrollView : public Widget, public ScrollableArea {
68public:
69    virtual ~ScrollView();
70
71    // ScrollableArea functions.
72    virtual int scrollSize(ScrollbarOrientation) const override;
73    virtual int scrollPosition(Scrollbar*) const override;
74    virtual void setScrollOffset(const IntPoint&) override;
75    virtual bool isScrollCornerVisible() const override;
76    virtual void scrollbarStyleChanged(int newStyle, bool forceUpdate) override;
77
78    virtual void notifyPageThatContentAreaWillPaint() const;
79
80    // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea.
81    virtual void scrollTo(const IntSize& newOffset);
82
83    // The window thats hosts the ScrollView. The ScrollView will communicate scrolls and repaints to the
84    // host window in the window's coordinate space.
85    virtual HostWindow* hostWindow() const = 0;
86
87    // Returns a clip rect in host window coordinates. Used to clip the blit on a scroll.
88    virtual IntRect windowClipRect(bool clipToContents = true) const = 0;
89
90    // Functions for child manipulation and inspection.
91    const HashSet<RefPtr<Widget>>& children() const { return m_children; }
92    virtual void addChild(PassRefPtr<Widget>);
93    virtual void removeChild(Widget*);
94
95    // If the scroll view does not use a native widget, then it will have cross-platform Scrollbars. These functions
96    // can be used to obtain those scrollbars.
97    virtual Scrollbar* horizontalScrollbar() const override { return m_horizontalScrollbar.get(); }
98    virtual Scrollbar* verticalScrollbar() const override { return m_verticalScrollbar.get(); }
99    bool isScrollViewScrollbar(const Widget* child) const { return horizontalScrollbar() == child || verticalScrollbar() == child; }
100
101    void positionScrollbarLayers();
102
103    // Functions for setting and retrieving the scrolling mode in each axis (horizontal/vertical). The mode has values of
104    // AlwaysOff, AlwaysOn, and Auto. AlwaysOff means never show a scrollbar, AlwaysOn means always show a scrollbar.
105    // Auto means show a scrollbar only when one is needed.
106    // Note that for platforms with native widgets, these modes are considered advisory. In other words the underlying native
107    // widget may choose not to honor the requested modes.
108    void setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode verticalMode, bool horizontalLock = false, bool verticalLock = false);
109    void setHorizontalScrollbarMode(ScrollbarMode mode, bool lock = false) { setScrollbarModes(mode, verticalScrollbarMode(), lock, verticalScrollbarLock()); }
110    void setVerticalScrollbarMode(ScrollbarMode mode, bool lock = false) { setScrollbarModes(horizontalScrollbarMode(), mode, horizontalScrollbarLock(), lock); };
111    void scrollbarModes(ScrollbarMode& horizontalMode, ScrollbarMode& verticalMode) const;
112    ScrollbarMode horizontalScrollbarMode() const { ScrollbarMode horizontal, vertical; scrollbarModes(horizontal, vertical); return horizontal; }
113    ScrollbarMode verticalScrollbarMode() const { ScrollbarMode horizontal, vertical; scrollbarModes(horizontal, vertical); return vertical; }
114
115    void setHorizontalScrollbarLock(bool lock = true) { m_horizontalScrollbarLock = lock; }
116    bool horizontalScrollbarLock() const { return m_horizontalScrollbarLock; }
117    void setVerticalScrollbarLock(bool lock = true) { m_verticalScrollbarLock = lock; }
118    bool verticalScrollbarLock() const { return m_verticalScrollbarLock; }
119
120    void setScrollingModesLock(bool lock = true) { m_horizontalScrollbarLock = m_verticalScrollbarLock = lock; }
121
122    virtual void setCanHaveScrollbars(bool);
123    bool canHaveScrollbars() const { return horizontalScrollbarMode() != ScrollbarAlwaysOff || verticalScrollbarMode() != ScrollbarAlwaysOff; }
124
125    virtual bool avoidScrollbarCreation() const { return false; }
126
127    virtual void setScrollbarOverlayStyle(ScrollbarOverlayStyle) override;
128
129    // By default you only receive paint events for the area that is visible. In the case of using a
130    // tiled backing store, this function can be set, so that the view paints the entire contents.
131    bool paintsEntireContents() const { return m_paintsEntireContents; }
132    void setPaintsEntireContents(bool);
133
134    // By default, paint events are clipped to the visible area.  If set to
135    // false, paint events are no longer clipped.  paintsEntireContents() implies !clipsRepaints().
136    bool clipsRepaints() const { return m_clipsRepaints; }
137    void setClipsRepaints(bool);
138
139    // By default programmatic scrolling is handled by WebCore and not by the UI application.
140    // In the case of using a tiled backing store, this mode can be set, so that the scroll requests
141    // are delegated to the UI application.
142    bool delegatesScrolling() const { return m_delegatesScrolling; }
143    void setDelegatesScrolling(bool);
144
145    // Overridden by FrameView to create custom CSS scrollbars if applicable.
146    virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation);
147
148    void styleDidChange();
149
150    // If the prohibits scrolling flag is set, then all scrolling in the view (even programmatic scrolling) is turned off.
151    void setProhibitsScrolling(bool b) { m_prohibitsScrolling = b; }
152    bool prohibitsScrolling() const { return m_prohibitsScrolling; }
153
154    // Whether or not a scroll view will blit visible contents when it is scrolled. Blitting is disabled in situations
155    // where it would cause rendering glitches (such as with fixed backgrounds or when the view is partially transparent).
156    void setCanBlitOnScroll(bool);
157    bool canBlitOnScroll() const;
158
159    // There are at least three types of contentInset. Usually we just care about WebCoreContentInset, which is the inset
160    // that is set on a Page that requires WebCore to move its layers to accomodate the inset. However, there are platform
161    // concepts that are similar on both iOS and Mac when there is a platformWidget(). Sometimes we need the Mac platform value
162    // for topContentInset, so when the TopContentInsetType is WebCoreOrPlatformContentInset, platformTopContentInset()
163    // will be returned instead of the value set on Page.
164    enum class TopContentInsetType { WebCoreContentInset, WebCoreOrPlatformContentInset };
165    virtual float topContentInset(TopContentInsetType = TopContentInsetType::WebCoreContentInset) const { return 0; }
166
167    // The visible content rect has a location that is the scrolled offset of the document. The width and height are the unobscured viewport
168    // width and height. By default the scrollbars themselves are excluded from this rectangle, but an optional boolean argument allows them
169    // to be included.
170    // In the situation the client is responsible for the scrolling (ie. with a tiled backing store) it is possible to use
171    // the setFixedVisibleContentRect instead for the mainframe, though this must be updated manually, e.g just before resuming the page
172    // which usually will happen when panning, pinching and rotation ends, or when scale or position are changed manually.
173    virtual IntSize visibleSize() const override { return visibleContentRect(LegacyIOSDocumentVisibleRect).size(); }
174
175#if USE(TILED_BACKING_STORE)
176    virtual void setFixedVisibleContentRect(const IntRect& visibleContentRect) { m_fixedVisibleContentRect = visibleContentRect; }
177    IntRect fixedVisibleContentRect() const { return m_fixedVisibleContentRect; }
178#endif
179
180    // Parts of the document can be visible through transparent or blured UI widgets of the chrome. Those parts
181    // contribute to painting but not to the scrollable area.
182    // The unobscuredContentRect is the area that is not covered by UI elements.
183    IntRect unobscuredContentRect(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
184#if PLATFORM(IOS)
185    IntRect unobscuredContentRectIncludingScrollbars() const { return unobscuredContentRect(IncludeScrollbars); }
186#else
187    IntRect unobscuredContentRectIncludingScrollbars() const { return visibleContentRectIncludingScrollbars(); }
188#endif
189
190#if PLATFORM(IOS)
191    // This is the area that is partially or fully exposed, and may extend under overlapping UI elements.
192    FloatRect exposedContentRect() const;
193
194    // The given rects are only used if there is no platform widget.
195    void setExposedContentRect(const FloatRect&);
196    const FloatSize& unobscuredContentSize() const { return m_unobscuredContentSize; }
197    void setUnobscuredContentSize(const FloatSize&);
198
199    void setActualScrollPosition(const IntPoint&);
200    LegacyTileCache* legacyTileCache();
201#endif
202
203    virtual bool inProgrammaticScroll() const { return false; }
204
205    // visibleContentRect().size() is computed from unscaledUnobscuredVisibleContentSize() divided by the value of visibleContentScaleFactor.
206    // visibleContentScaleFactor is usually 1, except when the setting delegatesPageScaling is true and the
207    // ScrollView is the main frame; in that case, visibleContentScaleFactor is equal to the page's pageScaleFactor.
208    // Ports that don't use pageScaleFactor can treat unscaledUnobscuredVisibleContentSize and visibleContentRect().size() as equivalent.
209    // unscaledVisibleContentSizeIncludingObscuredArea() includes areas in the content that might be obscured by UI elements.
210    IntSize unscaledUnobscuredVisibleContentSize(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
211    IntSize unscaledVisibleContentSizeIncludingObscuredArea(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
212    virtual float visibleContentScaleFactor() const { return 1; }
213
214    // Functions for getting/setting the size webkit should use to layout the contents. By default this is the same as the visible
215    // content size. Explicitly setting a layout size value will cause webkit to layout the contents using this size instead.
216    IntSize layoutSize() const;
217    int layoutWidth() const { return layoutSize().width(); }
218    int layoutHeight() const { return layoutSize().height(); }
219    IntSize fixedLayoutSize() const;
220    void setFixedLayoutSize(const IntSize&);
221    bool useFixedLayout() const;
222    void setUseFixedLayout(bool enable);
223
224    // Functions for getting/setting the size of the document contained inside the ScrollView (as an IntSize or as individual width and height
225    // values).
226    virtual IntSize contentsSize() const override; // Always at least as big as the visibleWidth()/visibleHeight().
227    int contentsWidth() const { return contentsSize().width(); }
228    int contentsHeight() const { return contentsSize().height(); }
229    virtual void setContentsSize(const IntSize&);
230
231    // Functions for querying the current scrolled position (both as a point, a size, or as individual X and Y values).
232    virtual IntPoint scrollPosition() const override { return visibleContentRect(LegacyIOSDocumentVisibleRect).location(); }
233    IntSize scrollOffset() const { return toIntSize(visibleContentRect(LegacyIOSDocumentVisibleRect).location()); } // Gets the scrolled position as an IntSize. Convenient for adding to other sizes.
234    virtual IntPoint maximumScrollPosition() const override; // The maximum position we can be scrolled to.
235    virtual IntPoint minimumScrollPosition() const override; // The minimum position we can be scrolled to.
236    // Adjust the passed in scroll position to keep it between the minimum and maximum positions.
237    IntPoint adjustScrollPositionWithinRange(const IntPoint&) const;
238    int scrollX() const { return scrollPosition().x(); }
239    int scrollY() const { return scrollPosition().y(); }
240
241    // Scroll position used by web-exposed features (has legacy iOS behavior).
242    IntPoint contentsScrollPosition() const;
243    void setContentsScrollPosition(const IntPoint&);
244
245#if PLATFORM(IOS)
246    int actualScrollX() const { return unobscuredContentRect().x(); }
247    int actualScrollY() const { return unobscuredContentRect().y(); }
248    // FIXME: maybe fix scrollPosition() on iOS to return the actual scroll position.
249    IntPoint actualScrollPosition() const { return unobscuredContentRect().location(); }
250#endif
251
252    // scrollOffset() anchors its (0,0) point at the ScrollableArea's origin. When the Page has a
253    // header, the header is positioned at (0,0), ABOVE the start of the Document. So when a page with
254    // a header is pinned to the top, the scrollOffset() is (0,0), but the Document is actually at
255    // (0, -headerHeight()). documentScrollOffsetRelativeToScrollableAreaOrigin() will return this
256    // version of the offset, which tracks the top of Document relative to where scrolling was achored.
257    IntSize documentScrollOffsetRelativeToScrollableAreaOrigin() const;
258
259    // scrollOffset() anchors its (0,0) point at the ScrollableArea's origin. The top of the scrolling
260    // layer does not represent the top of the view when there is a topContentInset. Additionally, as
261    // detailed above, the origin of the scrolling layer also does not necessarily correspond with the
262    // top of the document anyway, since there could also be header. documentScrollOffsetRelativeToViewOrigin()
263    // will return a version of the current scroll offset which tracks the top of the Document
264    // relative to the very top of the view.
265    IntSize documentScrollOffsetRelativeToViewOrigin() const;
266    IntPoint documentScrollPositionRelativeToViewOrigin() const;
267
268    virtual IntSize overhangAmount() const override;
269
270    void cacheCurrentScrollPosition() { m_cachedScrollPosition = scrollPosition(); }
271    IntPoint cachedScrollPosition() const { return m_cachedScrollPosition; }
272
273    // Functions for scrolling the view.
274    virtual void setScrollPosition(const IntPoint&);
275    void scrollBy(const IntSize& s) { return setScrollPosition(scrollPosition() + s); }
276
277    // This function scrolls by lines, pages or pixels.
278    bool scroll(ScrollDirection, ScrollGranularity);
279
280    // A logical scroll that just ends up calling the corresponding physical scroll() based off the document's writing mode.
281    bool logicalScroll(ScrollLogicalDirection, ScrollGranularity);
282
283    // Scroll the actual contents of the view (either blitting or invalidating as needed).
284    void scrollContents(const IntSize& scrollDelta);
285
286    // This gives us a means of blocking painting on our scrollbars until the first layout has occurred.
287    void setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppress = false);
288    bool scrollbarsSuppressed() const { return m_scrollbarsSuppressed; }
289
290    IntPoint rootViewToContents(const IntPoint&) const;
291    IntPoint contentsToRootView(const IntPoint&) const;
292    IntRect rootViewToContents(const IntRect&) const;
293    IntRect contentsToRootView(const IntRect&) const;
294
295    IntPoint rootViewToTotalContents(const IntPoint&) const;
296
297    // Event coordinates are assumed to be in the coordinate space of a window that contains
298    // the entire widget hierarchy. It is up to the platform to decide what the precise definition
299    // of containing window is. (For example on Mac it is the containing NSWindow.)
300    IntPoint windowToContents(const IntPoint&) const;
301    IntPoint contentsToWindow(const IntPoint&) const;
302    IntRect windowToContents(const IntRect&) const;
303    IntRect contentsToWindow(const IntRect&) const;
304
305    // Functions for converting to and from screen coordinates.
306    IntRect contentsToScreen(const IntRect&) const;
307    IntPoint screenToContents(const IntPoint&) const;
308
309    // The purpose of this function is to answer whether or not the scroll view is currently visible. Animations and painting updates can be suspended if
310    // we know that we are either not in a window right now or if that window is not visible.
311    bool isOffscreen() const;
312
313    // These functions are used to enable scrollbars to avoid window resizer controls that overlap the scroll view. This happens on Mac
314    // for example.
315    virtual IntRect windowResizerRect() const { return IntRect(); }
316    bool containsScrollbarsAvoidingResizer() const;
317    void adjustScrollbarsAvoidingResizerCount(int overlapDelta);
318    void windowResizerRectChanged();
319
320    virtual void setParent(ScrollView*) override; // Overridden to update the overlapping scrollbar count.
321
322    // Called when our frame rect changes (or the rect/scroll position of an ancestor changes).
323    virtual void frameRectsChanged() override;
324
325    // Widget override to update our scrollbars and notify our contents of the resize.
326    virtual void setFrameRect(const IntRect&) override;
327
328    // Widget override to notify our contents of a cliprect change.
329    virtual void clipRectChanged() override;
330
331    // For platforms that need to hit test scrollbars from within the engine's event handlers (like Win32).
332    Scrollbar* scrollbarAtPoint(const IntPoint& windowPoint);
333
334    IntPoint convertChildToSelf(const Widget* child, const IntPoint& point) const
335    {
336        IntPoint newPoint = point;
337        if (!isScrollViewScrollbar(child))
338            newPoint = point - scrollOffset();
339        newPoint.moveBy(child->location());
340        return newPoint;
341    }
342
343    IntPoint convertSelfToChild(const Widget* child, const IntPoint& point) const
344    {
345        IntPoint newPoint = point;
346        if (!isScrollViewScrollbar(child))
347            newPoint = point + scrollOffset();
348        newPoint.moveBy(-child->location());
349        return newPoint;
350    }
351
352    // Widget override. Handles painting of the contents of the view as well as the scrollbars.
353    virtual void paint(GraphicsContext*, const IntRect&) override;
354    void paintScrollbars(GraphicsContext*, const IntRect&);
355
356    // Widget overrides to ensure that our children's visibility status is kept up to date when we get shown and hidden.
357    virtual void show() override;
358    virtual void hide() override;
359    virtual void setParentVisible(bool) override;
360
361    // Pan scrolling.
362    static const int noPanScrollRadius = 15;
363    void addPanScrollIcon(const IntPoint&);
364    void removePanScrollIcon();
365    void paintPanScrollIcon(GraphicsContext*);
366
367    virtual bool isPointInScrollbarCorner(const IntPoint&);
368    virtual bool scrollbarCornerPresent() const;
369    virtual IntRect scrollCornerRect() const override;
370    virtual void paintScrollCorner(GraphicsContext*, const IntRect& cornerRect);
371    virtual void paintScrollbar(GraphicsContext*, Scrollbar*, const IntRect&);
372
373    virtual IntRect convertFromScrollbarToContainingView(const Scrollbar*, const IntRect&) const override;
374    virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const IntRect&) const override;
375    virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, const IntPoint&) const override;
376    virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, const IntPoint&) const override;
377
378    void calculateAndPaintOverhangAreas(GraphicsContext*, const IntRect& dirtyRect);
379
380    virtual bool isScrollView() const override { return true; }
381
382protected:
383    ScrollView();
384
385    virtual void repaintContentRectangle(const IntRect&);
386    virtual void paintContents(GraphicsContext*, const IntRect& damageRect) = 0;
387
388    virtual void paintOverhangAreas(GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect);
389
390    virtual void visibleContentsResized() = 0;
391    virtual void addedOrRemovedScrollbar() = 0;
392    virtual void delegatesScrollingDidChange() { }
393    virtual void fixedLayoutSizeChanged();
394
395    // These functions are used to create/destroy scrollbars.
396    // They return true if the scrollbar was added or removed.
397    bool setHasHorizontalScrollbar(bool, bool* contentSizeAffected = 0);
398    bool setHasVerticalScrollbar(bool, bool* contentSizeAffected = 0);
399
400    virtual void updateScrollCorner();
401    virtual void invalidateScrollCornerRect(const IntRect&) override;
402
403    // Scroll the content by blitting the pixels.
404    virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
405    // Scroll the content by invalidating everything.
406    virtual void scrollContentsSlowPath(const IntRect& updateRect);
407
408    void setScrollOrigin(const IntPoint&, bool updatePositionAtAll, bool updatePositionSynchronously);
409
410    // Subclassed by FrameView to check the writing-mode of the document.
411    virtual bool isVerticalDocument() const { return true; }
412    virtual bool isFlippedDocument() const { return false; }
413
414    // Called to update the scrollbars to accurately reflect the state of the view.
415    void updateScrollbars(const IntSize& desiredOffset);
416
417    float platformTopContentInset() const;
418    void platformSetTopContentInset(float);
419
420private:
421    virtual IntRect visibleContentRectInternal(VisibleContentRectIncludesScrollbars, VisibleContentRectBehavior) const override;
422    IntRect unobscuredContentRectInternal(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
423
424    RefPtr<Scrollbar> m_horizontalScrollbar;
425    RefPtr<Scrollbar> m_verticalScrollbar;
426    ScrollbarMode m_horizontalScrollbarMode;
427    ScrollbarMode m_verticalScrollbarMode;
428
429    bool m_horizontalScrollbarLock;
430    bool m_verticalScrollbarLock;
431
432    bool m_prohibitsScrolling;
433
434    HashSet<RefPtr<Widget>> m_children;
435
436    // This bool is unused on Mac OS because we directly ask the platform widget
437    // whether it is safe to blit on scroll.
438    bool m_canBlitOnScroll;
439
440    // FIXME: exposedContentRect is a very similar concept to fixedVisibleContentRect except it does not differentiate
441    // between exposed and unobscured areas. The two attributes should eventually be merged.
442#if PLATFORM(IOS)
443    FloatRect m_exposedContentRect;
444    FloatSize m_unobscuredContentSize;
445#else
446    IntRect m_fixedVisibleContentRect;
447#endif
448    IntSize m_scrollOffset; // FIXME: Would rather store this as a position, but we will wait to make this change until more code is shared.
449    IntPoint m_cachedScrollPosition;
450    IntSize m_fixedLayoutSize;
451    IntSize m_contentsSize;
452
453    int m_scrollbarsAvoidingResizer;
454    bool m_scrollbarsSuppressed;
455
456    bool m_inUpdateScrollbars;
457    unsigned m_updateScrollbarsPass;
458
459    IntPoint m_panScrollIconPoint;
460    bool m_drawPanScrollIcon;
461    bool m_useFixedLayout;
462
463    bool m_paintsEntireContents;
464    bool m_clipsRepaints;
465    bool m_delegatesScrolling;
466
467    void init();
468    void destroy();
469
470    IntRect rectToCopyOnScroll() const;
471
472    // Called when the scroll position within this view changes.  FrameView overrides this to generate repaint invalidations.
473    virtual void updateLayerPositionsAfterScrolling() { }
474    virtual void updateCompositingLayersAfterScrolling() { }
475
476    void platformAddChild(Widget*);
477    void platformRemoveChild(Widget*);
478    void platformSetScrollbarModes();
479    void platformScrollbarModes(ScrollbarMode& horizontal, ScrollbarMode& vertical) const;
480    void platformSetCanBlitOnScroll(bool);
481    bool platformCanBlitOnScroll() const;
482    IntRect platformVisibleContentRect(bool includeScrollbars) const;
483    IntSize platformVisibleContentSize(bool includeScrollbars) const;
484    IntRect platformVisibleContentRectIncludingObscuredArea(bool includeScrollbars) const;
485    IntSize platformVisibleContentSizeIncludingObscuredArea(bool includeScrollbars) const;
486    void platformSetContentsSize();
487    IntRect platformContentsToScreen(const IntRect&) const;
488    IntPoint platformScreenToContents(const IntPoint&) const;
489    void platformSetScrollPosition(const IntPoint&);
490    bool platformScroll(ScrollDirection, ScrollGranularity);
491    void platformSetScrollbarsSuppressed(bool repaintOnUnsuppress);
492    void platformRepaintContentRectangle(const IntRect&);
493    bool platformIsOffscreen() const;
494    void platformSetScrollbarOverlayStyle(ScrollbarOverlayStyle);
495
496    void platformSetScrollOrigin(const IntPoint&, bool updatePositionAtAll, bool updatePositionSynchronously);
497
498    void calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntRect& verticalOverhangRect);
499    void updateOverhangAreas();
500
501#if PLATFORM(COCOA) && defined __OBJC__
502public:
503    NSView* documentView() const;
504
505private:
506    NSScrollView<WebCoreFrameScrollView>* scrollView() const;
507#endif
508}; // class ScrollView
509
510WIDGET_TYPE_CASTS(ScrollView, isScrollView());
511
512} // namespace WebCore
513
514#endif // ScrollView_h
515