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

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

Issue 314583008: Refactor ScrollView::updateScrollbars() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: revised Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // Overridden by FrameView to create custom CSS scrollbars if applicable. 113 // Overridden by FrameView to create custom CSS scrollbars if applicable.
114 virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation); 114 virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation);
115 115
116 virtual bool shouldAttemptToScrollUsingFastPath() const; 116 virtual bool shouldAttemptToScrollUsingFastPath() const;
117 117
118 // The visible content rect has a location that is the scrolled offset of th e document. The width and height are the viewport width 118 // The visible content rect has a location that is the scrolled offset of th e document. The width and height are the viewport width
119 // and height. By default the scrollbars themselves are excluded from this r ectangle, but an optional boolean argument allows them to be 119 // and height. By default the scrollbars themselves are excluded from this r ectangle, but an optional boolean argument allows them to be
120 // included. 120 // included.
121 virtual IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollba rs) const OVERRIDE; 121 virtual IntRect visibleContentRect(IncludeScrollbarsInRect = ExcludeScrollba rs) const OVERRIDE;
122 IntSize visibleSize() const { return visibleContentRect().size(); } 122 IntSize visibleSize() const { return visibleContentRect().size(); }
123 virtual int visibleWidth() const OVERRIDE { return visibleContentRect().widt h(); } 123 virtual int visibleWidth() const OVERRIDE FINAL { return visibleContentRect( ).width(); }
124 virtual int visibleHeight() const OVERRIDE { return visibleContentRect().hei ght(); } 124 virtual int visibleHeight() const OVERRIDE FINAL { return visibleContentRect ().height(); }
125 125
126 // visibleContentRect().size() is computed from unscaledVisibleContentSize() divided by the value of visibleContentScaleFactor. 126 // visibleContentRect().size() is computed from unscaledVisibleContentSize() divided by the value of visibleContentScaleFactor.
127 // For the main frame, visibleContentScaleFactor is equal to the page's page ScaleFactor; it's 1 otherwise. 127 // For the main frame, visibleContentScaleFactor is equal to the page's page ScaleFactor; it's 1 otherwise.
128 IntSize unscaledVisibleContentSize(IncludeScrollbarsInRect = ExcludeScrollba rs) const; 128 IntSize unscaledVisibleContentSize(IncludeScrollbarsInRect = ExcludeScrollba rs) const;
129 virtual float visibleContentScaleFactor() const { return 1; } 129 virtual float visibleContentScaleFactor() const { return 1; }
130 130
131 // Offset used to convert incoming input events while emulating device metic s. 131 // Offset used to convert incoming input events while emulating device metic s.
132 virtual IntSize inputEventsOffsetForEmulation() const { return IntSize(); } 132 virtual IntSize inputEventsOffsetForEmulation() const { return IntSize(); }
133 133
134 // Scale used to convert incoming input events. Usually the same as visibleC ontentScaleFactor(), unless specifically changed. 134 // Scale used to convert incoming input events. Usually the same as visibleC ontentScaleFactor(), unless specifically changed.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRec t& rectToScroll, const IntRect& clipRect); 274 virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRec t& rectToScroll, const IntRect& clipRect);
275 // Scroll the content by invalidating everything. 275 // Scroll the content by invalidating everything.
276 virtual void scrollContentsSlowPath(const IntRect& updateRect); 276 virtual void scrollContentsSlowPath(const IntRect& updateRect);
277 277
278 void setScrollOrigin(const IntPoint&, bool updatePositionAtAll, bool updateP ositionSynchronously); 278 void setScrollOrigin(const IntPoint&, bool updatePositionAtAll, bool updateP ositionSynchronously);
279 279
280 // Subclassed by FrameView to check the writing-mode of the document. 280 // Subclassed by FrameView to check the writing-mode of the document.
281 virtual bool isVerticalDocument() const { return true; } 281 virtual bool isVerticalDocument() const { return true; }
282 virtual bool isFlippedDocument() const { return false; } 282 virtual bool isFlippedDocument() const { return false; }
283 283
284 enum ComputeScrollbarExistenceOption {
285 FirstPass,
286 Incremental
287 };
288 void computeScrollbarExistence(bool& newHasHorizontalScrollbar, bool& newHas VerticalScrollbar, ComputeScrollbarExistenceOption = FirstPass) const;
289 void updateScrollbarGeometry();
290
284 // Called to update the scrollbars to accurately reflect the state of the vi ew. 291 // Called to update the scrollbars to accurately reflect the state of the vi ew.
285 void updateScrollbars(const IntSize& desiredOffset); 292 void updateScrollbars(const IntSize& desiredOffset);
286 293
287 IntSize excludeScrollbars(const IntSize&) const; 294 IntSize excludeScrollbars(const IntSize&) const;
288 295
289 private: 296 private:
297 bool adjustScrollbarExistence(ComputeScrollbarExistenceOption = FirstPass);
298
290 RefPtr<Scrollbar> m_horizontalScrollbar; 299 RefPtr<Scrollbar> m_horizontalScrollbar;
291 RefPtr<Scrollbar> m_verticalScrollbar; 300 RefPtr<Scrollbar> m_verticalScrollbar;
292 ScrollbarMode m_horizontalScrollbarMode; 301 ScrollbarMode m_horizontalScrollbarMode;
293 ScrollbarMode m_verticalScrollbarMode; 302 ScrollbarMode m_verticalScrollbarMode;
294 303
295 bool m_horizontalScrollbarLock; 304 bool m_horizontalScrollbarLock;
296 bool m_verticalScrollbarLock; 305 bool m_verticalScrollbarLock;
297 306
298 HashSet<RefPtr<Widget> > m_children; 307 HashSet<RefPtr<Widget> > m_children;
299 308
300 IntSize m_pendingScrollDelta; 309 IntSize m_pendingScrollDelta;
301 IntSize m_scrollOffset; // FIXME: Would rather store this as a position, but we will wait to make this change until more code is shared. 310 IntSize m_scrollOffset; // FIXME: Would rather store this as a position, but we will wait to make this change until more code is shared.
302 IntPoint m_cachedScrollPosition; 311 IntPoint m_cachedScrollPosition;
303 IntSize m_contentsSize; 312 IntSize m_contentsSize;
304 313
305 int m_scrollbarsAvoidingResizer; 314 int m_scrollbarsAvoidingResizer;
306 bool m_scrollbarsSuppressed; 315 bool m_scrollbarsSuppressed;
307 316
308 bool m_inUpdateScrollbars; 317 bool m_inUpdateScrollbars;
309 unsigned m_updateScrollbarsPass;
310 318
311 IntPoint m_panScrollIconPoint; 319 IntPoint m_panScrollIconPoint;
312 bool m_drawPanScrollIcon; 320 bool m_drawPanScrollIcon;
313 321
314 bool m_paintsEntireContents; 322 bool m_paintsEntireContents;
315 bool m_clipsRepaints; 323 bool m_clipsRepaints;
316 324
317 void init(); 325 void init();
318 void destroy(); 326 void destroy();
319 327
320 IntRect rectToCopyOnScroll() const; 328 IntRect rectToCopyOnScroll() const;
321 329
322 void calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntR ect& verticalOverhangRect); 330 void calculateOverhangAreasForPainting(IntRect& horizontalOverhangRect, IntR ect& verticalOverhangRect);
323 void updateOverhangAreas(); 331 void updateOverhangAreas();
324 }; // class ScrollView 332 }; // class ScrollView
325 333
326 DEFINE_TYPE_CASTS(ScrollView, Widget, widget, widget->isScrollView(), widget.isS crollView()); 334 DEFINE_TYPE_CASTS(ScrollView, Widget, widget, widget->isScrollView(), widget.isS crollView());
327 335
328 } // namespace WebCore 336 } // namespace WebCore
329 337
330 #endif // ScrollView_h 338 #endif // ScrollView_h
OLDNEW
« no previous file with comments | « no previous file | Source/platform/scroll/ScrollView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698