OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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; |
104 | |
aelias_OOO_until_Jul13
2013/06/19 22:25:12
nit: accidental newline
bokan
2013/06/19 23:50:58
Done.
| |
101 switch (granularity) { | 105 switch (granularity) { |
102 case ScrollByLine: | 106 case ScrollByLine: |
103 step = scrollbar->lineStep(); | 107 step = lineStep(orientation); |
104 break; | 108 break; |
105 case ScrollByPage: | 109 case ScrollByPage: |
106 step = scrollbar->pageStep(); | 110 step = pageStep(orientation); |
107 break; | 111 break; |
108 case ScrollByDocument: | 112 case ScrollByDocument: |
109 step = scrollbar->totalSize(); | 113 step = documentStep(orientation); |
110 break; | 114 break; |
111 case ScrollByPixel: | 115 case ScrollByPixel: |
112 case ScrollByPrecisePixel: | 116 case ScrollByPrecisePixel: |
113 step = scrollbar->pixelStep(); | 117 step = pixelStep(orientation); |
114 break; | 118 break; |
115 } | 119 } |
116 | 120 |
117 if (direction == ScrollUp || direction == ScrollLeft) | 121 if (direction == ScrollUp || direction == ScrollLeft) |
118 multiplier = -multiplier; | 122 multiplier = -multiplier; |
119 | 123 |
120 return scrollAnimator()->scroll(orientation, granularity, step, multiplier); | 124 return scrollAnimator()->scroll(orientation, granularity, step, multiplier); |
121 } | 125 } |
122 | 126 |
123 void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset) | 127 void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset) |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 { | 361 { |
358 return layerForScrollCorner(); | 362 return layerForScrollCorner(); |
359 } | 363 } |
360 | 364 |
361 void ScrollableArea::serviceScrollAnimations() | 365 void ScrollableArea::serviceScrollAnimations() |
362 { | 366 { |
363 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) | 367 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) |
364 scrollAnimator->serviceScrollAnimations(); | 368 scrollAnimator->serviceScrollAnimations(); |
365 } | 369 } |
366 | 370 |
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 | 371 IntPoint ScrollableArea::minimumScrollPosition() const |
375 { | 372 { |
376 return IntPoint(); | 373 return IntPoint(); |
377 } | 374 } |
378 | 375 |
379 IntPoint ScrollableArea::maximumScrollPosition() const | 376 IntPoint ScrollableArea::maximumScrollPosition() const |
380 { | 377 { |
381 return IntPoint(contentsSize().width() - visibleWidth(), contentsSize().heig ht() - visibleHeight()); | 378 return IntPoint(contentsSize().width() - visibleWidth(), contentsSize().heig ht() - visibleHeight()); |
382 } | 379 } |
383 | 380 |
(...skipping 19 matching lines...) Expand all Loading... | |
403 { | 400 { |
404 return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumSc rollPosition()); | 401 return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumSc rollPosition()); |
405 } | 402 } |
406 | 403 |
407 void ScrollableArea::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 404 void ScrollableArea::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
408 { | 405 { |
409 MemoryClassInfo info(memoryObjectInfo, this); | 406 MemoryClassInfo info(memoryObjectInfo, this); |
410 info.addMember(m_scrollAnimator, "scrollAnimator"); | 407 info.addMember(m_scrollAnimator, "scrollAnimator"); |
411 } | 408 } |
412 | 409 |
410 int ScrollableArea::lineStep(ScrollbarOrientation) const | |
411 { | |
412 return pixelsPerLineStep(); | |
413 } | |
414 | |
415 int ScrollableArea::pageStep(ScrollbarOrientation orientation) const | |
aelias_OOO_until_Jul13
2013/06/19 22:25:12
This code appears specific to ScrollView so I sugg
bokan
2013/06/19 23:50:58
Done.
| |
416 { | |
417 int length = (orientation == HorizontalScrollbar) ? visibleWidth() : visible Height(); | |
418 int minPageStep = static_cast<float>(length) * minFractionToStepWhenPaging() ; | |
419 int pageStep = std::max(minPageStep, length - maxOverlapBetweenPages()); | |
420 | |
421 return std::max(pageStep, 1); | |
422 } | |
423 | |
424 int ScrollableArea::documentStep(ScrollbarOrientation orientation) const | |
425 { | |
426 return scrollSize(orientation); | |
427 } | |
428 | |
429 float ScrollableArea::pixelStep(ScrollbarOrientation) const | |
430 { | |
431 return 1.0f; | |
432 } | |
433 | |
413 } // namespace WebCore | 434 } // namespace WebCore |
OLD | NEW |