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

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

Issue 610423004: Preserve fractional scroll offset for JS scrolling API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase 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
« no previous file with comments | « Source/platform/geometry/DoubleSize.h ('k') | Source/platform/scroll/ScrollView.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 IntRect adjustScrollbarRectForResizer(const IntRect&, Scrollbar*); 292 IntRect adjustScrollbarRectForResizer(const IntRect&, Scrollbar*);
291 293
292 // Called to update the scrollbars to accurately reflect the state of the vi ew. 294 // Called to update the scrollbars to accurately reflect the state of the vi ew.
293 void updateScrollbars(const IntSize& desiredOffset); 295 void updateScrollbars(const DoubleSize& desiredOffset);
294 296
295 IntSize excludeScrollbars(const IntSize&) const; 297 IntSize excludeScrollbars(const IntSize&) const;
296 298
297 class InUpdateScrollbarsScope { 299 class InUpdateScrollbarsScope {
298 public: 300 public:
299 explicit InUpdateScrollbarsScope(ScrollView* view) 301 explicit InUpdateScrollbarsScope(ScrollView* view)
300 : m_scope(view->m_inUpdateScrollbars, true) 302 : m_scope(view->m_inUpdateScrollbars, true)
301 { } 303 { }
302 private: 304 private:
303 TemporaryChange<bool> m_scope; 305 TemporaryChange<bool> m_scope;
304 }; 306 };
305 307
306 virtual bool scrollbarsDisabled() const { return false; } 308 virtual bool scrollbarsDisabled() const { return false; }
307 309
308 private: 310 private:
309 bool adjustScrollbarExistence(ComputeScrollbarExistenceOption = FirstPass); 311 bool adjustScrollbarExistence(ComputeScrollbarExistenceOption = FirstPass);
310 void adjustScrollbarOpacity(); 312 void adjustScrollbarOpacity();
311 // FIXME(bokan): setScrollOffset, setScrollPosition, scrollTo, scrollToOffse tWithoutAnimation, 313 // FIXME(bokan): setScrollOffset, setScrollPosition, scrollTo, scrollToOffse tWithoutAnimation,
312 // notifyScrollPositionChanged...there's too many ways to scroll this class. This needs 314 // notifyScrollPositionChanged...there's too many ways to scroll this class. This needs
313 // some cleanup. 315 // some cleanup.
314 void setScrollOffsetFromUpdateScrollbars(const IntSize&); 316 void setScrollOffsetFromUpdateScrollbars(const DoubleSize&);
315 317
316 RefPtr<Scrollbar> m_horizontalScrollbar; 318 RefPtr<Scrollbar> m_horizontalScrollbar;
317 RefPtr<Scrollbar> m_verticalScrollbar; 319 RefPtr<Scrollbar> m_verticalScrollbar;
318 ScrollbarMode m_horizontalScrollbarMode; 320 ScrollbarMode m_horizontalScrollbarMode;
319 ScrollbarMode m_verticalScrollbarMode; 321 ScrollbarMode m_verticalScrollbarMode;
320 322
321 bool m_horizontalScrollbarLock; 323 bool m_horizontalScrollbarLock;
322 bool m_verticalScrollbarLock; 324 bool m_verticalScrollbarLock;
323 325
324 HashSet<RefPtr<Widget> > m_children; 326 HashSet<RefPtr<Widget> > m_children;
(...skipping 20 matching lines...) Expand all
345 347
346 void calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntR ect& verticalOverhangRect); 348 void calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntR ect& verticalOverhangRect);
347 void updateOverhangAreas(); 349 void updateOverhangAreas();
348 }; // class ScrollView 350 }; // class ScrollView
349 351
350 DEFINE_TYPE_CASTS(ScrollView, Widget, widget, widget->isScrollView(), widget.isS crollView()); 352 DEFINE_TYPE_CASTS(ScrollView, Widget, widget, widget->isScrollView(), widget.isS crollView());
351 353
352 } // namespace blink 354 } // namespace blink
353 355
354 #endif // ScrollView_h 356 #endif // ScrollView_h
OLDNEW
« no previous file with comments | « Source/platform/geometry/DoubleSize.h ('k') | Source/platform/scroll/ScrollView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698