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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation); | 113 virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation); |
114 | 114 |
115 // Whether or not a scroll view will blit visible contents when it is scroll
ed. Blitting is disabled in situations | 115 // Whether or not a scroll view will blit visible contents when it is scroll
ed. Blitting is disabled in situations |
116 // where it would cause rendering glitches (such as with fixed backgrounds o
r when the view is partially transparent). | 116 // where it would cause rendering glitches (such as with fixed backgrounds o
r when the view is partially transparent). |
117 void setCanBlitOnScroll(bool); | 117 void setCanBlitOnScroll(bool); |
118 bool canBlitOnScroll() const; | 118 bool canBlitOnScroll() const; |
119 | 119 |
120 // The visible content rect has a location that is the scrolled offset of th
e document. The width and height are the viewport width | 120 // The visible content rect has a location that is the scrolled offset of th
e document. The width and height are the viewport width |
121 // and height. By default the scrollbars themselves are excluded from this r
ectangle, but an optional boolean argument allows them to be | 121 // and height. By default the scrollbars themselves are excluded from this r
ectangle, but an optional boolean argument allows them to be |
122 // included. | 122 // included. |
123 virtual IntRect visibleContentRect(VisibleContentRectIncludesScrollbars = Ex
cludeScrollbars) const OVERRIDE; | 123 virtual IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollba
rs) const OVERRIDE; |
124 IntSize visibleSize() const { return visibleContentRect().size(); } | 124 IntSize visibleSize() const { return visibleContentRect().size(); } |
125 virtual int visibleWidth() const OVERRIDE { return visibleContentRect().widt
h(); } | 125 virtual int visibleWidth() const OVERRIDE { return visibleContentRect().widt
h(); } |
126 virtual int visibleHeight() const OVERRIDE { return visibleContentRect().hei
ght(); } | 126 virtual int visibleHeight() const OVERRIDE { return visibleContentRect().hei
ght(); } |
127 | 127 |
128 // visibleContentRect().size() is computed from unscaledVisibleContentSize()
divided by the value of visibleContentScaleFactor. | 128 // visibleContentRect().size() is computed from unscaledVisibleContentSize()
divided by the value of visibleContentScaleFactor. |
129 // For the main frame, visibleContentScaleFactor is equal to the page's page
ScaleFactor; it's 1 otherwise. | 129 // For the main frame, visibleContentScaleFactor is equal to the page's page
ScaleFactor; it's 1 otherwise. |
130 IntSize unscaledVisibleContentSize(VisibleContentRectIncludesScrollbars = Ex
cludeScrollbars) const; | 130 IntSize unscaledVisibleContentSize(IncludeScrollbarsInRect = ExcludeScrollba
rs) const; |
131 virtual float visibleContentScaleFactor() const { return 1; } | 131 virtual float visibleContentScaleFactor() const { return 1; } |
132 | 132 |
133 // Functions for getting/setting the size webkit should use to layout the co
ntents. By default this is the same as the visible | |
134 // content size. Explicitly setting a layout size value will cause webkit to
layout the contents using this size instead. | |
135 IntSize layoutSize(VisibleContentRectIncludesScrollbars = ExcludeScrollbars)
const; | |
136 int layoutWidth(VisibleContentRectIncludesScrollbars scrollbarInclusion = Ex
cludeScrollbars) const { return layoutSize(scrollbarInclusion).width(); } | |
137 int layoutHeight(VisibleContentRectIncludesScrollbars scrollbarInclusion = E
xcludeScrollbars) const { return layoutSize(scrollbarInclusion).height(); } | |
138 IntSize fixedLayoutSize() const; | |
139 void setFixedLayoutSize(const IntSize&); | |
140 bool useFixedLayout() const; | |
141 void setUseFixedLayout(bool enable); | |
142 | |
143 // Functions for getting/setting the size of the document contained inside t
he ScrollView (as an IntSize or as individual width and height | 133 // Functions for getting/setting the size of the document contained inside t
he ScrollView (as an IntSize or as individual width and height |
144 // values). | 134 // values). |
145 virtual IntSize contentsSize() const OVERRIDE; // Always at least as big as
the visibleWidth()/visibleHeight(). | 135 virtual IntSize contentsSize() const OVERRIDE; // Always at least as big as
the visibleWidth()/visibleHeight(). |
146 int contentsWidth() const { return contentsSize().width(); } | 136 int contentsWidth() const { return contentsSize().width(); } |
147 int contentsHeight() const { return contentsSize().height(); } | 137 int contentsHeight() const { return contentsSize().height(); } |
148 virtual void setContentsSize(const IntSize&); | 138 virtual void setContentsSize(const IntSize&); |
149 | 139 |
150 // Functions for querying the current scrolled position (both as a point, a
size, or as individual X and Y values). | 140 // Functions for querying the current scrolled position (both as a point, a
size, or as individual X and Y values). |
151 virtual IntPoint scrollPosition() const OVERRIDE { return visibleContentRect
().location(); } | 141 virtual IntPoint scrollPosition() const OVERRIDE { return visibleContentRect
().location(); } |
152 IntSize scrollOffset() const { return toIntSize(visibleContentRect().locatio
n()); } // Gets the scrolled position as an IntSize. Convenient for adding to ot
her sizes. | 142 IntSize scrollOffset() const { return toIntSize(visibleContentRect().locatio
n()); } // Gets the scrolled position as an IntSize. Convenient for adding to ot
her sizes. |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 virtual bool isScrollView() const OVERRIDE { return true; } | 258 virtual bool isScrollView() const OVERRIDE { return true; } |
269 | 259 |
270 protected: | 260 protected: |
271 ScrollView(); | 261 ScrollView(); |
272 | 262 |
273 virtual void repaintContentRectangle(const IntRect&); | 263 virtual void repaintContentRectangle(const IntRect&); |
274 virtual void paintContents(GraphicsContext*, const IntRect& damageRect) = 0; | 264 virtual void paintContents(GraphicsContext*, const IntRect& damageRect) = 0; |
275 | 265 |
276 virtual void paintOverhangAreas(GraphicsContext*, const IntRect& horizontalO
verhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect); | 266 virtual void paintOverhangAreas(GraphicsContext*, const IntRect& horizontalO
verhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect); |
277 | 267 |
278 virtual void visibleContentsResized() = 0; | 268 virtual void scrollbarExistenceDidChange() = 0; |
279 // These functions are used to create/destroy scrollbars. | 269 // These functions are used to create/destroy scrollbars. |
280 void setHasHorizontalScrollbar(bool); | 270 void setHasHorizontalScrollbar(bool); |
281 void setHasVerticalScrollbar(bool); | 271 void setHasVerticalScrollbar(bool); |
282 | 272 |
283 virtual void updateScrollCorner(); | 273 virtual void updateScrollCorner(); |
284 virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE; | 274 virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE; |
285 | 275 |
286 // Scroll the content by blitting the pixels. | 276 // Scroll the content by blitting the pixels. |
287 virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRec
t& rectToScroll, const IntRect& clipRect); | 277 virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRec
t& rectToScroll, const IntRect& clipRect); |
288 // Scroll the content by invalidating everything. | 278 // Scroll the content by invalidating everything. |
289 virtual void scrollContentsSlowPath(const IntRect& updateRect); | 279 virtual void scrollContentsSlowPath(const IntRect& updateRect); |
290 | 280 |
291 void setScrollOrigin(const IntPoint&, bool updatePositionAtAll, bool updateP
ositionSynchronously); | 281 void setScrollOrigin(const IntPoint&, bool updatePositionAtAll, bool updateP
ositionSynchronously); |
292 | 282 |
293 // Subclassed by FrameView to check the writing-mode of the document. | 283 // Subclassed by FrameView to check the writing-mode of the document. |
294 virtual bool isVerticalDocument() const { return true; } | 284 virtual bool isVerticalDocument() const { return true; } |
295 virtual bool isFlippedDocument() const { return false; } | 285 virtual bool isFlippedDocument() const { return false; } |
296 | 286 |
297 // Called to update the scrollbars to accurately reflect the state of the vi
ew. | 287 // Called to update the scrollbars to accurately reflect the state of the vi
ew. |
298 void updateScrollbars(const IntSize& desiredOffset); | 288 void updateScrollbars(const IntSize& desiredOffset); |
299 | 289 |
| 290 IntSize excludeScrollbars(const IntSize&) const; |
| 291 |
300 private: | 292 private: |
301 RefPtr<Scrollbar> m_horizontalScrollbar; | 293 RefPtr<Scrollbar> m_horizontalScrollbar; |
302 RefPtr<Scrollbar> m_verticalScrollbar; | 294 RefPtr<Scrollbar> m_verticalScrollbar; |
303 ScrollbarMode m_horizontalScrollbarMode; | 295 ScrollbarMode m_horizontalScrollbarMode; |
304 ScrollbarMode m_verticalScrollbarMode; | 296 ScrollbarMode m_verticalScrollbarMode; |
305 | 297 |
306 bool m_horizontalScrollbarLock; | 298 bool m_horizontalScrollbarLock; |
307 bool m_verticalScrollbarLock; | 299 bool m_verticalScrollbarLock; |
308 | 300 |
309 HashSet<RefPtr<Widget> > m_children; | 301 HashSet<RefPtr<Widget> > m_children; |
310 | 302 |
311 // This bool is unused on Mac OS because we directly ask the platform widget | 303 // This bool is unused on Mac OS because we directly ask the platform widget |
312 // whether it is safe to blit on scroll. | 304 // whether it is safe to blit on scroll. |
313 bool m_canBlitOnScroll; | 305 bool m_canBlitOnScroll; |
314 | 306 |
315 IntSize m_scrollOffset; // FIXME: Would rather store this as a position, but
we will wait to make this change until more code is shared. | 307 IntSize m_scrollOffset; // FIXME: Would rather store this as a position, but
we will wait to make this change until more code is shared. |
316 IntPoint m_cachedScrollPosition; | 308 IntPoint m_cachedScrollPosition; |
317 IntSize m_fixedLayoutSize; | |
318 IntSize m_contentsSize; | 309 IntSize m_contentsSize; |
319 | 310 |
320 int m_scrollbarsAvoidingResizer; | 311 int m_scrollbarsAvoidingResizer; |
321 bool m_scrollbarsSuppressed; | 312 bool m_scrollbarsSuppressed; |
322 | 313 |
323 bool m_inUpdateScrollbars; | 314 bool m_inUpdateScrollbars; |
324 unsigned m_updateScrollbarsPass; | 315 unsigned m_updateScrollbarsPass; |
325 | 316 |
326 IntPoint m_panScrollIconPoint; | 317 IntPoint m_panScrollIconPoint; |
327 bool m_drawPanScrollIcon; | 318 bool m_drawPanScrollIcon; |
328 bool m_useFixedLayout; | |
329 | 319 |
330 bool m_paintsEntireContents; | 320 bool m_paintsEntireContents; |
331 bool m_clipsRepaints; | 321 bool m_clipsRepaints; |
332 | 322 |
333 void init(); | 323 void init(); |
334 void destroy(); | 324 void destroy(); |
335 | 325 |
336 IntRect rectToCopyOnScroll() const; | 326 IntRect rectToCopyOnScroll() const; |
337 | 327 |
338 // Called when the scroll position within this view changes. FrameView over
rides this to generate repaint invalidations. | 328 // Called when the scroll position within this view changes. FrameView over
rides this to generate repaint invalidations. |
(...skipping 17 matching lines...) Expand all Loading... |
356 ASSERT(!widget || widget->isScrollView()); | 346 ASSERT(!widget || widget->isScrollView()); |
357 return static_cast<const ScrollView*>(widget); | 347 return static_cast<const ScrollView*>(widget); |
358 } | 348 } |
359 | 349 |
360 // This will catch anyone doing an unnecessary cast. | 350 // This will catch anyone doing an unnecessary cast. |
361 void toScrollView(const ScrollView*); | 351 void toScrollView(const ScrollView*); |
362 | 352 |
363 } // namespace WebCore | 353 } // namespace WebCore |
364 | 354 |
365 #endif // ScrollView_h | 355 #endif // ScrollView_h |
OLD | NEW |