| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // values). | 127 // values). |
| 128 virtual IntSize contentsSize() const OVERRIDE; // Always at least as big as
the visibleWidth()/visibleHeight(). | 128 virtual IntSize contentsSize() const OVERRIDE; // Always at least as big as
the visibleWidth()/visibleHeight(). |
| 129 int contentsWidth() const { return contentsSize().width(); } | 129 int contentsWidth() const { return contentsSize().width(); } |
| 130 int contentsHeight() const { return contentsSize().height(); } | 130 int contentsHeight() const { return contentsSize().height(); } |
| 131 virtual void setContentsSize(const IntSize&); | 131 virtual void setContentsSize(const IntSize&); |
| 132 | 132 |
| 133 // Functions for querying the current scrolled position (both as a point, a
size, or as individual X and Y values). | 133 // Functions for querying the current scrolled position (both as a point, a
size, or as individual X and Y values). |
| 134 // FIXME: Remove the IntPoint version. crbug.com/414283. | 134 // FIXME: Remove the IntPoint version. crbug.com/414283. |
| 135 virtual IntPoint scrollPosition() const OVERRIDE { return visibleContentRect
().location(); } | 135 virtual IntPoint scrollPosition() const OVERRIDE { return visibleContentRect
().location(); } |
| 136 virtual DoublePoint scrollPositionDouble() const OVERRIDE { return m_scrollP
osition; } | 136 virtual DoublePoint scrollPositionDouble() const OVERRIDE { return m_scrollP
osition; } |
| 137 // FIXME: Remove scrollOffset(). crbug.com/414283. |
| 137 IntSize scrollOffset() const { return toIntSize(visibleContentRect().locatio
n()); } // Gets the scrolled position as an IntSize. Convenient for adding to ot
her sizes. | 138 IntSize scrollOffset() const { return toIntSize(visibleContentRect().locatio
n()); } // Gets the scrolled position as an IntSize. Convenient for adding to ot
her sizes. |
| 139 DoubleSize scrollOffsetDouble() const { return DoubleSize(m_scrollPosition.x
(), m_scrollPosition.y()); } |
| 138 DoubleSize pendingScrollDelta() const { return m_pendingScrollDelta; } | 140 DoubleSize pendingScrollDelta() const { return m_pendingScrollDelta; } |
| 139 virtual IntPoint maximumScrollPosition() const OVERRIDE; // The maximum posi
tion we can be scrolled to. | 141 virtual IntPoint maximumScrollPosition() const OVERRIDE; // The maximum posi
tion we can be scrolled to. |
| 140 virtual IntPoint minimumScrollPosition() const OVERRIDE; // The minimum posi
tion we can be scrolled to. | 142 virtual IntPoint minimumScrollPosition() const OVERRIDE; // The minimum posi
tion we can be scrolled to. |
| 141 // Adjust the passed in scroll position to keep it between the minimum and m
aximum positions. | 143 // Adjust the passed in scroll position to keep it between the minimum and m
aximum positions. |
| 142 IntPoint adjustScrollPositionWithinRange(const IntPoint&) const; | 144 IntPoint adjustScrollPositionWithinRange(const IntPoint&) const; |
| 143 DoublePoint adjustScrollPositionWithinRange(const DoublePoint&) const; | 145 DoublePoint adjustScrollPositionWithinRange(const DoublePoint&) const; |
| 144 double scrollX() const { return scrollPositionDouble().x(); } | 146 double scrollX() const { return scrollPositionDouble().x(); } |
| 145 double scrollY() const { return scrollPositionDouble().y(); } | 147 double scrollY() const { return scrollPositionDouble().y(); } |
| 146 | 148 |
| 147 virtual IntSize overhangAmount() const OVERRIDE; | 149 virtual IntSize overhangAmount() const OVERRIDE; |
| 148 | 150 |
| 149 void cacheCurrentScrollPosition() { m_cachedScrollPosition = scrollPositionD
ouble(); } | 151 void cacheCurrentScrollPosition() { m_cachedScrollPosition = scrollPositionD
ouble(); } |
| 150 DoublePoint cachedScrollPosition() const { return m_cachedScrollPosition; } | 152 DoublePoint cachedScrollPosition() const { return m_cachedScrollPosition; } |
| 151 | 153 |
| 152 // Functions for scrolling the view. | 154 // Functions for scrolling the view. |
| 153 virtual void setScrollPosition(const IntPoint&, ScrollBehavior = ScrollBehav
iorInstant); | 155 virtual void setScrollPosition(const DoublePoint&, ScrollBehavior = ScrollBe
haviorInstant); |
| 154 void scrollBy(const IntSize& s, ScrollBehavior behavior = ScrollBehaviorInst
ant) | 156 void scrollBy(const DoubleSize& s, ScrollBehavior behavior = ScrollBehaviorI
nstant) |
| 155 { | 157 { |
| 156 return setScrollPosition(scrollPosition() + s, behavior); | 158 return setScrollPosition(scrollPositionDouble() + s, behavior); |
| 157 } | 159 } |
| 158 | 160 |
| 159 bool scroll(ScrollDirection, ScrollGranularity); | 161 bool scroll(ScrollDirection, ScrollGranularity); |
| 160 | 162 |
| 161 // Scroll the actual contents of the view (either blitting or invalidating a
s needed). | 163 // Scroll the actual contents of the view (either blitting or invalidating a
s needed). |
| 162 void scrollContents(const IntSize& scrollDelta); | 164 void scrollContents(const IntSize& scrollDelta); |
| 163 | 165 |
| 164 // This gives us a means of blocking painting on our scrollbars until the fi
rst layout has occurred. | 166 // This gives us a means of blocking painting on our scrollbars until the fi
rst layout has occurred. |
| 165 void setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppress = fal
se); | 167 void setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppress = fal
se); |
| 166 bool scrollbarsSuppressed() const { return m_scrollbarsSuppressed; } | 168 bool scrollbarsSuppressed() const { return m_scrollbarsSuppressed; } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 virtual bool isFlippedDocument() const { return false; } | 284 virtual bool isFlippedDocument() const { return false; } |
| 283 | 285 |
| 284 enum ComputeScrollbarExistenceOption { | 286 enum ComputeScrollbarExistenceOption { |
| 285 FirstPass, | 287 FirstPass, |
| 286 Incremental | 288 Incremental |
| 287 }; | 289 }; |
| 288 void computeScrollbarExistence(bool& newHasHorizontalScrollbar, bool& newHas
VerticalScrollbar, const IntSize& docSize, ComputeScrollbarExistenceOption = Fir
stPass) const; | 290 void computeScrollbarExistence(bool& newHasHorizontalScrollbar, bool& newHas
VerticalScrollbar, const IntSize& docSize, ComputeScrollbarExistenceOption = Fir
stPass) const; |
| 289 void updateScrollbarGeometry(); | 291 void updateScrollbarGeometry(); |
| 290 | 292 |
| 291 // Called to update the scrollbars to accurately reflect the state of the vi
ew. | 293 // Called to update the scrollbars to accurately reflect the state of the vi
ew. |
| 292 void updateScrollbars(const IntSize& desiredOffset); | 294 void updateScrollbars(const DoubleSize& desiredOffset); |
| 293 | 295 |
| 294 IntSize excludeScrollbars(const IntSize&) const; | 296 IntSize excludeScrollbars(const IntSize&) const; |
| 295 | 297 |
| 296 class InUpdateScrollbarsScope { | 298 class InUpdateScrollbarsScope { |
| 297 public: | 299 public: |
| 298 explicit InUpdateScrollbarsScope(ScrollView* view) | 300 explicit InUpdateScrollbarsScope(ScrollView* view) |
| 299 : m_scope(view->m_inUpdateScrollbars, true) | 301 : m_scope(view->m_inUpdateScrollbars, true) |
| 300 { } | 302 { } |
| 301 private: | 303 private: |
| 302 TemporaryChange<bool> m_scope; | 304 TemporaryChange<bool> m_scope; |
| 303 }; | 305 }; |
| 304 | 306 |
| 305 virtual bool scrollbarsDisabled() const { return false; } | 307 virtual bool scrollbarsDisabled() const { return false; } |
| 306 | 308 |
| 307 private: | 309 private: |
| 308 bool adjustScrollbarExistence(ComputeScrollbarExistenceOption = FirstPass); | 310 bool adjustScrollbarExistence(ComputeScrollbarExistenceOption = FirstPass); |
| 309 void adjustScrollbarOpacity(); | 311 void adjustScrollbarOpacity(); |
| 310 // FIXME(bokan): setScrollOffset, setScrollPosition, scrollTo, scrollToOffse
tWithoutAnimation, | 312 // FIXME(bokan): setScrollOffset, setScrollPosition, scrollTo, scrollToOffse
tWithoutAnimation, |
| 311 // notifyScrollPositionChanged...there's too many ways to scroll this class.
This needs | 313 // notifyScrollPositionChanged...there's too many ways to scroll this class.
This needs |
| 312 // some cleanup. | 314 // some cleanup. |
| 313 void setScrollOffsetFromUpdateScrollbars(const IntSize&); | 315 void setScrollOffsetFromUpdateScrollbars(const DoubleSize&); |
| 314 | 316 |
| 315 RefPtr<Scrollbar> m_horizontalScrollbar; | 317 RefPtr<Scrollbar> m_horizontalScrollbar; |
| 316 RefPtr<Scrollbar> m_verticalScrollbar; | 318 RefPtr<Scrollbar> m_verticalScrollbar; |
| 317 ScrollbarMode m_horizontalScrollbarMode; | 319 ScrollbarMode m_horizontalScrollbarMode; |
| 318 ScrollbarMode m_verticalScrollbarMode; | 320 ScrollbarMode m_verticalScrollbarMode; |
| 319 | 321 |
| 320 bool m_horizontalScrollbarLock; | 322 bool m_horizontalScrollbarLock; |
| 321 bool m_verticalScrollbarLock; | 323 bool m_verticalScrollbarLock; |
| 322 | 324 |
| 323 HashSet<RefPtr<Widget> > m_children; | 325 HashSet<RefPtr<Widget> > m_children; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 344 | 346 |
| 345 void calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntR
ect& verticalOverhangRect); | 347 void calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntR
ect& verticalOverhangRect); |
| 346 void updateOverhangAreas(); | 348 void updateOverhangAreas(); |
| 347 }; // class ScrollView | 349 }; // class ScrollView |
| 348 | 350 |
| 349 DEFINE_TYPE_CASTS(ScrollView, Widget, widget, widget->isScrollView(), widget.isS
crollView()); | 351 DEFINE_TYPE_CASTS(ScrollView, Widget, widget, widget->isScrollView(), widget.isS
crollView()); |
| 350 | 352 |
| 351 } // namespace blink | 353 } // namespace blink |
| 352 | 354 |
| 353 #endif // ScrollView_h | 355 #endif // ScrollView_h |
| OLD | NEW |