Chromium Code Reviews| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 ScrollbarOrientation orientation; | 87 ScrollbarOrientation orientation; |
| 88 Scrollbar* scrollbar; | 88 Scrollbar* scrollbar; |
| 89 if (direction == ScrollUp || direction == ScrollDown) { | 89 if (direction == ScrollUp || direction == ScrollDown) { |
| 90 orientation = VerticalScrollbar; | 90 orientation = VerticalScrollbar; |
| 91 scrollbar = verticalScrollbar(); | 91 scrollbar = verticalScrollbar(); |
| 92 } else { | 92 } else { |
| 93 orientation = HorizontalScrollbar; | 93 orientation = HorizontalScrollbar; |
| 94 scrollbar = horizontalScrollbar(); | 94 scrollbar = horizontalScrollbar(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 if (!scrollbar) | 97 if (!isScrollable(orientation)) |
| 98 return false; | 98 return false; |
| 99 | 99 |
| 100 float step = 0; | 100 float step = 0; |
| 101 switch (granularity) { | 101 |
| 102 case ScrollByLine: | 102 if (scrollbar) { |
| 103 step = scrollbar->lineStep(); | 103 switch (granularity) { |
| 104 break; | 104 case ScrollByLine: |
| 105 case ScrollByPage: | 105 step = scrollbar->lineStep(); |
| 106 step = scrollbar->pageStep(); | 106 break; |
| 107 break; | 107 case ScrollByPage: |
| 108 case ScrollByDocument: | 108 step = scrollbar->pageStep(); |
| 109 step = scrollbar->totalSize(); | 109 break; |
| 110 break; | 110 case ScrollByDocument: |
| 111 case ScrollByPixel: | 111 step = scrollbar->totalSize(); |
| 112 case ScrollByPrecisePixel: | 112 break; |
| 113 step = scrollbar->pixelStep(); | 113 case ScrollByPixel: |
| 114 break; | 114 case ScrollByPrecisePixel: |
| 115 step = scrollbar->pixelStep(); | |
| 116 break; | |
| 117 } | |
| 118 } else { | |
| 119 // TODO: Where should we get the step sizes here? | |
|
aelias_OOO_until_Jul13
2013/06/18 00:54:47
It looks like the step sizes should be moved out o
bokan
2013/06/18 23:03:27
Done, though ScrollableArea has a compile time ass
aelias_OOO_until_Jul13
2013/06/19 02:55:24
Ah, no, that's not okay, sorry about that suggesti
bokan
2013/06/19 18:57:00
Done.
| |
| 120 switch (granularity) { | |
| 121 case ScrollByLine: | |
| 122 case ScrollByPage: | |
| 123 case ScrollByDocument: | |
| 124 case ScrollByPixel: | |
| 125 case ScrollByPrecisePixel: | |
| 126 step = 1.0f; | |
| 127 break; | |
| 128 } | |
| 115 } | 129 } |
| 116 | 130 |
| 117 if (direction == ScrollUp || direction == ScrollLeft) | 131 if (direction == ScrollUp || direction == ScrollLeft) |
| 118 multiplier = -multiplier; | 132 multiplier = -multiplier; |
| 119 | 133 |
| 120 return scrollAnimator()->scroll(orientation, granularity, step, multiplier); | 134 return scrollAnimator()->scroll(orientation, granularity, step, multiplier); |
| 121 } | 135 } |
| 122 | 136 |
| 123 void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset) | 137 void ScrollableArea::scrollToOffsetWithoutAnimation(const FloatPoint& offset) |
| 124 { | 138 { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 { | 371 { |
| 358 return layerForScrollCorner(); | 372 return layerForScrollCorner(); |
| 359 } | 373 } |
| 360 | 374 |
| 361 void ScrollableArea::serviceScrollAnimations() | 375 void ScrollableArea::serviceScrollAnimations() |
| 362 { | 376 { |
| 363 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) | 377 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) |
| 364 scrollAnimator->serviceScrollAnimations(); | 378 scrollAnimator->serviceScrollAnimations(); |
| 365 } | 379 } |
| 366 | 380 |
| 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 | 381 IntPoint ScrollableArea::minimumScrollPosition() const |
| 375 { | 382 { |
| 376 return IntPoint(); | 383 return IntPoint(); |
| 377 } | 384 } |
| 378 | 385 |
| 379 IntPoint ScrollableArea::maximumScrollPosition() const | 386 IntPoint ScrollableArea::maximumScrollPosition() const |
| 380 { | 387 { |
| 381 return IntPoint(contentsSize().width() - visibleWidth(), contentsSize().heig ht() - visibleHeight()); | 388 return IntPoint(contentsSize().width() - visibleWidth(), contentsSize().heig ht() - visibleHeight()); |
| 382 } | 389 } |
| 383 | 390 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 404 return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumSc rollPosition()); | 411 return scrollPosition.shrunkTo(maximumScrollPosition()).expandedTo(minimumSc rollPosition()); |
| 405 } | 412 } |
| 406 | 413 |
| 407 void ScrollableArea::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 414 void ScrollableArea::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
| 408 { | 415 { |
| 409 MemoryClassInfo info(memoryObjectInfo, this); | 416 MemoryClassInfo info(memoryObjectInfo, this); |
| 410 info.addMember(m_scrollAnimator, "scrollAnimator"); | 417 info.addMember(m_scrollAnimator, "scrollAnimator"); |
| 411 } | 418 } |
| 412 | 419 |
| 413 } // namespace WebCore | 420 } // namespace WebCore |
| OLD | NEW |