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

Side by Side Diff: Source/core/platform/ScrollView.cpp

Issue 16982005: Allow objects without scrollbars to be scrollable (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Mac Build Fix Created 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 25 matching lines...) Expand all
36 36
37 using namespace std; 37 using namespace std;
38 38
39 namespace WebCore { 39 namespace WebCore {
40 40
41 ScrollView::ScrollView() 41 ScrollView::ScrollView()
42 : m_horizontalScrollbarMode(ScrollbarAuto) 42 : m_horizontalScrollbarMode(ScrollbarAuto)
43 , m_verticalScrollbarMode(ScrollbarAuto) 43 , m_verticalScrollbarMode(ScrollbarAuto)
44 , m_horizontalScrollbarLock(false) 44 , m_horizontalScrollbarLock(false)
45 , m_verticalScrollbarLock(false) 45 , m_verticalScrollbarLock(false)
46 , m_prohibitsScrolling(false)
47 , m_canBlitOnScroll(true) 46 , m_canBlitOnScroll(true)
48 , m_scrollbarsAvoidingResizer(0) 47 , m_scrollbarsAvoidingResizer(0)
49 , m_scrollbarsSuppressed(false) 48 , m_scrollbarsSuppressed(false)
50 , m_inUpdateScrollbars(false) 49 , m_inUpdateScrollbars(false)
51 , m_updateScrollbarsPass(0) 50 , m_updateScrollbarsPass(0)
52 , m_drawPanScrollIcon(false) 51 , m_drawPanScrollIcon(false)
53 , m_useFixedLayout(false) 52 , m_useFixedLayout(false)
54 , m_paintsEntireContents(false) 53 , m_paintsEntireContents(false)
55 , m_clipsRepaints(true) 54 , m_clipsRepaints(true)
56 { 55 {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 if (!constrainsScrollingToContentEdge()) 276 if (!constrainsScrollingToContentEdge())
278 return scrollPoint; 277 return scrollPoint;
279 278
280 IntPoint newScrollPosition = scrollPoint.shrunkTo(maximumScrollPosition()); 279 IntPoint newScrollPosition = scrollPoint.shrunkTo(maximumScrollPosition());
281 newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition()); 280 newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition());
282 return newScrollPosition; 281 return newScrollPosition;
283 } 282 }
284 283
285 int ScrollView::scrollSize(ScrollbarOrientation orientation) const 284 int ScrollView::scrollSize(ScrollbarOrientation orientation) const
286 { 285 {
286 Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_horizontalS crollbar : m_verticalScrollbar).get();
287
287 // If no scrollbars are present, it does not indicate content is not be scro llable. 288 // If no scrollbars are present, it does not indicate content is not be scro llable.
288 if (!m_horizontalScrollbar && !m_verticalScrollbar && !prohibitsScrolling()) { 289 if (!scrollbar) {
289 IntSize scrollSize = m_contentsSize - visibleContentRect().size(); 290 IntSize scrollSize = m_contentsSize - visibleContentRect().size();
290 scrollSize.clampNegativeToZero(); 291 scrollSize.clampNegativeToZero();
291 return orientation == HorizontalScrollbar ? scrollSize.width() : scrollS ize.height(); 292 return orientation == HorizontalScrollbar ? scrollSize.width() : scrollS ize.height();
292 } 293 }
293 294
294 Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_horizontalS crollbar : m_verticalScrollbar).get(); 295 return scrollbar->totalSize() - scrollbar->visibleSize();
295 return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0;
296 } 296 }
297 297
298 void ScrollView::notifyPageThatContentAreaWillPaint() const 298 void ScrollView::notifyPageThatContentAreaWillPaint() const
299 { 299 {
300 } 300 }
301 301
302 void ScrollView::setScrollOffset(const IntPoint& offset) 302 void ScrollView::setScrollOffset(const IntPoint& offset)
303 { 303 {
304 scrollTo(toIntSize(adjustScrollPositionWithinRange(offset))); 304 scrollTo(toIntSize(adjustScrollPositionWithinRange(offset)));
305 } 305 }
(...skipping 17 matching lines...) Expand all
323 { 323 {
324 if (scrollbar->orientation() == HorizontalScrollbar) 324 if (scrollbar->orientation() == HorizontalScrollbar)
325 return scrollPosition().x() + scrollOrigin().x(); 325 return scrollPosition().x() + scrollOrigin().x();
326 if (scrollbar->orientation() == VerticalScrollbar) 326 if (scrollbar->orientation() == VerticalScrollbar)
327 return scrollPosition().y() + scrollOrigin().y(); 327 return scrollPosition().y() + scrollOrigin().y();
328 return 0; 328 return 0;
329 } 329 }
330 330
331 void ScrollView::setScrollPosition(const IntPoint& scrollPoint) 331 void ScrollView::setScrollPosition(const IntPoint& scrollPoint)
332 { 332 {
333 if (prohibitsScrolling())
334 return;
335
336 IntPoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint); 333 IntPoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint);
337 334
338 if (newScrollPosition == scrollPosition()) 335 if (newScrollPosition == scrollPosition())
339 return; 336 return;
340 337
341 updateScrollbars(IntSize(newScrollPosition.x(), newScrollPosition.y())); 338 updateScrollbars(IntSize(newScrollPosition.x(), newScrollPosition.y()));
342 } 339 }
343 340
344 bool ScrollView::logicalScroll(ScrollLogicalDirection direction, ScrollGranulari ty granularity) 341 bool ScrollView::logicalScroll(ScrollLogicalDirection direction, ScrollGranulari ty granularity)
345 { 342 {
(...skipping 21 matching lines...) Expand all
367 364
368 void ScrollView::windowResizerRectChanged() 365 void ScrollView::windowResizerRectChanged()
369 { 366 {
370 updateScrollbars(scrollOffset()); 367 updateScrollbars(scrollOffset());
371 } 368 }
372 369
373 static const unsigned cMaxUpdateScrollbarsPass = 2; 370 static const unsigned cMaxUpdateScrollbarsPass = 2;
374 371
375 void ScrollView::updateScrollbars(const IntSize& desiredOffset) 372 void ScrollView::updateScrollbars(const IntSize& desiredOffset)
376 { 373 {
377 if (m_inUpdateScrollbars || prohibitsScrolling()) 374 if (m_inUpdateScrollbars)
378 return; 375 return;
379 376
380 // If we came in here with the view already needing a layout, then go ahead and do that 377 // If we came in here with the view already needing a layout, then go ahead and do that
381 // first. (This will be the common case, e.g., when the page changes due to window resizing for example). 378 // first. (This will be the common case, e.g., when the page changes due to window resizing for example).
382 // This layout will not re-enter updateScrollbars and does not count towards our max layout pass total. 379 // This layout will not re-enter updateScrollbars and does not count towards our max layout pass total.
383 if (!m_scrollbarsSuppressed) { 380 if (!m_scrollbarsSuppressed) {
384 m_inUpdateScrollbars = true; 381 m_inUpdateScrollbars = true;
385 visibleContentsResized(); 382 visibleContentsResized();
386 m_inUpdateScrollbars = false; 383 m_inUpdateScrollbars = false;
387 } 384 }
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 graphicsLayer->setSize(cornerRect.size()); 812 graphicsLayer->setSize(cornerRect.size());
816 } 813 }
817 814
818 void ScrollView::positionScrollbarLayers() 815 void ScrollView::positionScrollbarLayers()
819 { 816 {
820 positionScrollbarLayer(layerForHorizontalScrollbar(), horizontalScrollbar()) ; 817 positionScrollbarLayer(layerForHorizontalScrollbar(), horizontalScrollbar()) ;
821 positionScrollbarLayer(layerForVerticalScrollbar(), verticalScrollbar()); 818 positionScrollbarLayer(layerForVerticalScrollbar(), verticalScrollbar());
822 positionScrollCornerLayer(layerForScrollCorner(), scrollCornerRect()); 819 positionScrollCornerLayer(layerForScrollCorner(), scrollCornerRect());
823 } 820 }
824 821
822 bool ScrollView::isHorizontallyScrollable() const
823 {
824 return m_horizontalScrollbarMode == ScrollbarAuto || m_horizontalScrollbarMo de == ScrollbarAlwaysOn;
825 }
826
827 bool ScrollView::isVerticallyScrollable() const
828 {
829 return m_verticalScrollbarMode == ScrollbarAuto || m_verticalScrollbarMode = = ScrollbarAlwaysOn;
830 }
831
825 void ScrollView::repaintContentRectangle(const IntRect& rect) 832 void ScrollView::repaintContentRectangle(const IntRect& rect)
826 { 833 {
827 IntRect paintRect = rect; 834 IntRect paintRect = rect;
828 if (clipsRepaints() && !paintsEntireContents()) 835 if (clipsRepaints() && !paintsEntireContents())
829 paintRect.intersect(visibleContentRect()); 836 paintRect.intersect(visibleContentRect());
830 if (paintRect.isEmpty()) 837 if (paintRect.isEmpty())
831 return; 838 return;
832 839
833 if (hostWindow()) 840 if (hostWindow())
834 hostWindow()->invalidateContentsAndRootView(contentsToWindow(paintRect)) ; 841 hostWindow()->invalidateContentsAndRootView(contentsToWindow(paintRect)) ;
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 { 1261 {
1255 } 1262 }
1256 1263
1257 bool ScrollView::platformIsOffscreen() const 1264 bool ScrollView::platformIsOffscreen() const
1258 { 1265 {
1259 return false; 1266 return false;
1260 } 1267 }
1261 1268
1262 1269
1263 } 1270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698