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::pixelsPerLineStep() | |
56 { | |
57 return 40; | |
58 } | |
59 | |
60 float ScrollableArea::minFractionToStepWhenPaging() | |
61 { | |
62 return 0.875f; | |
tdanderson
2013/07/15 23:17:44
I don't think the style guide explicitly mentions
bokan
2013/07/22 15:08:47
Done.
| |
63 } | |
64 | |
65 int ScrollableArea::maxOverlapBetweenPages() | |
66 { | |
67 static int maxOverlapBetweenPages = ScrollbarTheme::theme()->maxOverlapBetwe enPages(); | |
68 return maxOverlapBetweenPages; | |
69 } | |
70 | |
55 ScrollableArea::ScrollableArea() | 71 ScrollableArea::ScrollableArea() |
56 : m_constrainsScrollingToContentEdge(true) | 72 : m_constrainsScrollingToContentEdge(true) |
57 , m_inLiveResize(false) | 73 , m_inLiveResize(false) |
58 , m_verticalScrollElasticity(ScrollElasticityNone) | 74 , m_verticalScrollElasticity(ScrollElasticityNone) |
59 , m_horizontalScrollElasticity(ScrollElasticityNone) | 75 , m_horizontalScrollElasticity(ScrollElasticityNone) |
60 , m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault) | 76 , m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault) |
61 , m_scrollOriginChanged(false) | 77 , m_scrollOriginChanged(false) |
62 { | 78 { |
63 } | 79 } |
64 | 80 |
(...skipping 13 matching lines...) Expand all Loading... | |
78 { | 94 { |
79 if (m_scrollOrigin != origin) { | 95 if (m_scrollOrigin != origin) { |
80 m_scrollOrigin = origin; | 96 m_scrollOrigin = origin; |
81 m_scrollOriginChanged = true; | 97 m_scrollOriginChanged = true; |
82 } | 98 } |
83 } | 99 } |
84 | 100 |
85 bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granula rity, float multiplier) | 101 bool ScrollableArea::scroll(ScrollDirection direction, ScrollGranularity granula rity, float multiplier) |
86 { | 102 { |
87 ScrollbarOrientation orientation; | 103 ScrollbarOrientation orientation; |
88 Scrollbar* scrollbar; | 104 |
89 if (direction == ScrollUp || direction == ScrollDown) { | 105 if (direction == ScrollUp || direction == ScrollDown) |
90 orientation = VerticalScrollbar; | 106 orientation = VerticalScrollbar; |
91 scrollbar = verticalScrollbar(); | 107 else |
92 } else { | |
93 orientation = HorizontalScrollbar; | 108 orientation = HorizontalScrollbar; |
94 scrollbar = horizontalScrollbar(); | |
95 } | |
96 | 109 |
97 if (!scrollbar) | 110 if (!userInputScrollable(orientation)) |
98 return false; | 111 return false; |
99 | 112 |
100 float step = 0; | 113 float step = 0; |
101 switch (granularity) { | 114 switch (granularity) { |
102 case ScrollByLine: | 115 case ScrollByLine: |
103 step = scrollbar->lineStep(); | 116 step = lineStep(orientation); |
104 break; | 117 break; |
105 case ScrollByPage: | 118 case ScrollByPage: |
106 step = scrollbar->pageStep(); | 119 step = pageStep(orientation); |
107 break; | 120 break; |
108 case ScrollByDocument: | 121 case ScrollByDocument: |
109 step = scrollbar->totalSize(); | 122 step = documentStep(orientation); |
110 break; | 123 break; |
111 case ScrollByPixel: | 124 case ScrollByPixel: |
112 case ScrollByPrecisePixel: | 125 case ScrollByPrecisePixel: |
113 step = scrollbar->pixelStep(); | 126 step = pixelStep(orientation); |
114 break; | 127 break; |
115 } | 128 } |
116 | 129 |
117 if (direction == ScrollUp || direction == ScrollLeft) | 130 if (direction == ScrollUp || direction == ScrollLeft) |
118 multiplier = -multiplier; | 131 multiplier = -multiplier; |
119 | 132 |
120 return scrollAnimator()->scroll(orientation, granularity, step, multiplier); | 133 return scrollAnimator()->scroll(orientation, granularity, step, multiplier); |
121 } | 134 } |
122 | 135 |
123 void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset) | 136 void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset) |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 { | 370 { |
358 return layerForScrollCorner(); | 371 return layerForScrollCorner(); |
359 } | 372 } |
360 | 373 |
361 void ScrollableArea::serviceScrollAnimations() | 374 void ScrollableArea::serviceScrollAnimations() |
362 { | 375 { |
363 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) | 376 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) |
364 scrollAnimator->serviceScrollAnimations(); | 377 scrollAnimator->serviceScrollAnimations(); |
365 } | 378 } |
366 | 379 |
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 | |
375 { | |
376 return IntPoint(); | |
377 } | |
378 | |
379 IntPoint ScrollableArea::maximumScrollPosition() const | |
380 { | |
381 return IntPoint(contentsSize().width() - visibleWidth(), contentsSize().heig ht() - visibleHeight()); | |
382 } | |
383 | |
384 IntRect ScrollableArea::visibleContentRect(VisibleContentRectIncludesScrollbars scrollbarInclusion) const | 380 IntRect ScrollableArea::visibleContentRect(VisibleContentRectIncludesScrollbars scrollbarInclusion) const |
385 { | 381 { |
386 int verticalScrollbarWidth = 0; | 382 int verticalScrollbarWidth = 0; |
387 int horizontalScrollbarHeight = 0; | 383 int horizontalScrollbarHeight = 0; |
388 | 384 |
389 if (scrollbarInclusion == IncludeScrollbars) { | 385 if (scrollbarInclusion == IncludeScrollbars) { |
390 if (Scrollbar* verticalBar = verticalScrollbar()) | 386 if (Scrollbar* verticalBar = verticalScrollbar()) |
391 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? vertic alBar->width() : 0; | 387 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? vertic alBar->width() : 0; |
392 if (Scrollbar* horizontalBar = horizontalScrollbar()) | 388 if (Scrollbar* horizontalBar = horizontalScrollbar()) |
393 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? h orizontalBar->height() : 0; | 389 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? h orizontalBar->height() : 0; |
394 } | 390 } |
395 | 391 |
396 return IntRect(scrollPosition().x(), | 392 return IntRect(scrollPosition().x(), |
397 scrollPosition().y(), | 393 scrollPosition().y(), |
398 std::max(0, visibleWidth() + verticalScrollbarWidth), | 394 std::max(0, visibleWidth() + verticalScrollbarWidth), |
399 std::max(0, visibleHeight() + horizontalScrollbarHeight)); | 395 std::max(0, visibleHeight() + horizontalScrollbarHeight)); |
400 } | 396 } |
401 | 397 |
402 IntPoint ScrollableArea::clampScrollPosition(const IntPoint& scrollPosition) con st | 398 IntPoint ScrollableArea::clampScrollPosition(const IntPoint& scrollPosition) con st |
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; | |
tdanderson
2013/07/15 23:17:44
The style guide says to omit the .0f since you're
bokan
2013/07/22 15:08:47
Done.
| |
422 } | |
423 | |
413 } // namespace WebCore | 424 } // namespace WebCore |
OLD | NEW |