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

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

Issue 16982005: Allow objects without scrollbars to be scrollable (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: CR fixes 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) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google Inc. All rights reserved.
3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved. 3 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved.
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 are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 struct SameSizeAsScrollableArea { 46 struct SameSizeAsScrollableArea {
47 virtual ~SameSizeAsScrollableArea(); 47 virtual ~SameSizeAsScrollableArea();
48 void* pointer; 48 void* pointer;
49 unsigned bitfields : 16; 49 unsigned bitfields : 16;
50 IntPoint origin; 50 IntPoint origin;
51 }; 51 };
52 52
53 COMPILE_ASSERT(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea), Scrol lableArea_should_stay_small); 53 COMPILE_ASSERT(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea), Scrol lableArea_should_stay_small);
54 54
55 int ScrollableArea::maxOverlapBetweenPages()
56 {
57 static int maxOverlapBetweenPages = ScrollbarTheme::theme()->maxOverlapBetwe enPages();
58 return maxOverlapBetweenPages;
59 }
60
55 ScrollableArea::ScrollableArea() 61 ScrollableArea::ScrollableArea()
56 : m_constrainsScrollingToContentEdge(true) 62 : m_constrainsScrollingToContentEdge(true)
57 , m_inLiveResize(false) 63 , m_inLiveResize(false)
58 , m_verticalScrollElasticity(ScrollElasticityNone) 64 , m_verticalScrollElasticity(ScrollElasticityNone)
59 , m_horizontalScrollElasticity(ScrollElasticityNone) 65 , m_horizontalScrollElasticity(ScrollElasticityNone)
60 , m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault) 66 , m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault)
61 , m_scrollOriginChanged(false) 67 , m_scrollOriginChanged(false)
62 { 68 {
63 } 69 }
64 70
(...skipping 13 matching lines...) Expand all
78 { 84 {
79 if (m_scrollOrigin != origin) { 85 if (m_scrollOrigin != origin) {
80 m_scrollOrigin = origin; 86 m_scrollOrigin = origin;
81 m_scrollOriginChanged = true; 87 m_scrollOriginChanged = true;
82 } 88 }
83 } 89 }
84 90
85 bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granula rity, float multiplier) 91 bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granula rity, float multiplier)
86 { 92 {
87 ScrollbarOrientation orientation; 93 ScrollbarOrientation orientation;
88 Scrollbar* scrollbar; 94
89 if (direction == ScrollUp || direction == ScrollDown) { 95 if (direction == ScrollUp || direction == ScrollDown)
90 orientation = VerticalScrollbar; 96 orientation = VerticalScrollbar;
91 scrollbar = verticalScrollbar(); 97 else
92 } else {
93 orientation = HorizontalScrollbar; 98 orientation = HorizontalScrollbar;
94 scrollbar = horizontalScrollbar();
95 }
96 99
97 if (!scrollbar) 100 if (!userInputScrollable(orientation))
98 return false; 101 return false;
99 102
100 float step = 0; 103 float step = 0;
101 switch (granularity) { 104 switch (granularity) {
102 case ScrollByLine: 105 case ScrollByLine:
103 step = scrollbar->lineStep(); 106 step = lineStep(orientation);
104 break; 107 break;
105 case ScrollByPage: 108 case ScrollByPage:
106 step = scrollbar->pageStep(); 109 step = pageStep(orientation);
107 break; 110 break;
108 case ScrollByDocument: 111 case ScrollByDocument:
109 step = scrollbar->totalSize(); 112 step = documentStep(orientation);
110 break; 113 break;
111 case ScrollByPixel: 114 case ScrollByPixel:
112 case ScrollByPrecisePixel: 115 case ScrollByPrecisePixel:
113 step = scrollbar->pixelStep(); 116 step = pixelStep(orientation);
114 break; 117 break;
115 } 118 }
116 119
117 if (direction == ScrollUp || direction == ScrollLeft) 120 if (direction == ScrollUp || direction == ScrollLeft)
118 multiplier = -multiplier; 121 multiplier = -multiplier;
119 122
120 return scrollAnimator()->scroll(orientation, granularity, step, multiplier); 123 return scrollAnimator()->scroll(orientation, granularity, step, multiplier);
121 } 124 }
122 125
123 void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset) 126 void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 { 360 {
358 return layerForScrollCorner(); 361 return layerForScrollCorner();
359 } 362 }
360 363
361 void ScrollableArea::serviceScrollAnimations() 364 void ScrollableArea::serviceScrollAnimations()
362 { 365 {
363 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) 366 if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
364 scrollAnimator->serviceScrollAnimations(); 367 scrollAnimator->serviceScrollAnimations();
365 } 368 }
366 369
367 IntPoint ScrollableArea::scrollPosition() const
368 {
369 int x = horizontalScrollbar() ? horizontalScrollbar()->value() : 0;
370 int y = verticalScrollbar() ? verticalScrollbar()->value() : 0;
371 return IntPoint(x, y);
372 }
373
374 IntPoint ScrollableArea::minimumScrollPosition() const 370 IntPoint ScrollableArea::minimumScrollPosition() const
bokan 2013/06/20 19:00:16 Shouldn't the default min/maxScrollPositions here
trchen 2013/06/20 19:25:34 Yes. Better if we can make them pure virtual. ;)
375 { 371 {
376 return IntPoint(); 372 return IntPoint();
377 } 373 }
378 374
379 IntPoint ScrollableArea::maximumScrollPosition() const 375 IntPoint ScrollableArea::maximumScrollPosition() const
380 { 376 {
381 return IntPoint(contentsSize().width() - visibleWidth(), contentsSize().heig ht() - visibleHeight()); 377 return IntPoint(contentsSize().width() - visibleWidth(), contentsSize().heig ht() - visibleHeight());
382 } 378 }
383 379
384 IntRect ScrollableArea::visibleContentRect(VisibleContentRectIncludesScrollbars scrollbarInclusion) const 380 IntRect ScrollableArea::visibleContentRect(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
(...skipping 18 matching lines...) Expand all
403 { 399 {
404 return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumSc rollPosition()); 400 return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumSc rollPosition());
405 } 401 }
406 402
407 void ScrollableArea::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 403 void ScrollableArea::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
408 { 404 {
409 MemoryClassInfo info(memoryObjectInfo, this); 405 MemoryClassInfo info(memoryObjectInfo, this);
410 info.addMember(m_scrollAnimator, "scrollAnimator"); 406 info.addMember(m_scrollAnimator, "scrollAnimator");
411 } 407 }
412 408
409 int ScrollableArea::lineStep(ScrollbarOrientation) const
410 {
411 return pixelsPerLineStep();
412 }
413
414 int ScrollableArea::documentStep(ScrollbarOrientation orientation) const
415 {
416 return scrollSize(orientation);
417 }
418
419 float ScrollableArea::pixelStep(ScrollbarOrientation) const
420 {
421 return 1.0f;
422 }
423
413 } // namespace WebCore 424 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698