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 14 matching lines...) Expand all Loading... | |
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 #include "config.h" | 32 #include "config.h" |
33 #include "platform/scroll/ScrollableArea.h" | 33 #include "platform/scroll/ScrollableArea.h" |
34 | 34 |
35 #include "platform/TraceEvent.h" | |
35 #include "platform/graphics/GraphicsLayer.h" | 36 #include "platform/graphics/GraphicsLayer.h" |
36 #include "platform/geometry/FloatPoint.h" | 37 #include "platform/geometry/FloatPoint.h" |
38 #include "platform/scroll/ScrollbarStateTransitionAnimator.h" | |
37 #include "platform/scroll/ScrollbarTheme.h" | 39 #include "platform/scroll/ScrollbarTheme.h" |
38 #include "wtf/PassOwnPtr.h" | 40 #include "wtf/PassOwnPtr.h" |
39 | 41 |
40 #include "platform/TraceEvent.h" | |
41 | 42 |
42 static const int kPixelsPerLineStep = 40; | 43 static const int kPixelsPerLineStep = 40; |
43 static const float kMinFractionToStepWhenPaging = 0.875f; | 44 static const float kMinFractionToStepWhenPaging = 0.875f; |
44 | 45 |
45 namespace WebCore { | 46 namespace WebCore { |
46 | 47 |
47 struct SameSizeAsScrollableArea { | 48 struct SameSizeAsScrollableArea { |
48 virtual ~SameSizeAsScrollableArea(); | 49 virtual ~SameSizeAsScrollableArea(); |
49 unsigned damageBits : 2; | 50 unsigned damageBits : 2; |
50 IntRect scrollbarDamage[2]; | 51 IntRect scrollbarDamage[2]; |
51 void* pointer; | 52 void* pointer; |
53 void* stateTranstionAnimatorPointer; | |
abarth-chromium
2014/06/16 22:47:04
The point of having this struct here is to keep th
| |
52 unsigned bitfields : 16; | 54 unsigned bitfields : 16; |
53 IntPoint origin; | 55 IntPoint origin; |
54 }; | 56 }; |
55 | 57 |
56 COMPILE_ASSERT(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea), Scrol lableArea_should_stay_small); | 58 COMPILE_ASSERT(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea), Scrol lableArea_should_stay_small); |
57 | 59 |
58 int ScrollableArea::pixelsPerLineStep() | 60 int ScrollableArea::pixelsPerLineStep() |
59 { | 61 { |
60 return kPixelsPerLineStep; | 62 return kPixelsPerLineStep; |
61 } | 63 } |
(...skipping 26 matching lines...) Expand all Loading... | |
88 } | 90 } |
89 | 91 |
90 ScrollAnimator* ScrollableArea::scrollAnimator() const | 92 ScrollAnimator* ScrollableArea::scrollAnimator() const |
91 { | 93 { |
92 if (!m_scrollAnimator) | 94 if (!m_scrollAnimator) |
93 m_scrollAnimator = ScrollAnimator::create(const_cast<ScrollableArea*>(th is)); | 95 m_scrollAnimator = ScrollAnimator::create(const_cast<ScrollableArea*>(th is)); |
94 | 96 |
95 return m_scrollAnimator.get(); | 97 return m_scrollAnimator.get(); |
96 } | 98 } |
97 | 99 |
100 ScrollbarStateTransitionAnimator* ScrollableArea::scrollbarStateTransitionAnimat or() const | |
101 { | |
102 if (hasOverlayScrollbars() && !m_scrollbarStateTransitionAnimator) | |
103 m_scrollbarStateTransitionAnimator = ScrollbarStateTransitionAnimator::c reate(const_cast<ScrollableArea*>(this)); | |
104 | |
105 return m_scrollbarStateTransitionAnimator.get(); | |
106 } | |
107 | |
108 bool ScrollableArea::isDuringStateTransitionAnimation() const | |
109 { | |
110 return hasOverlayScrollbars() && existingScrollbarStateTransitionAnimator() && existingScrollbarStateTransitionAnimator()->isDuringStateTransitionAnimation( ); | |
111 } | |
112 | |
113 void ScrollableArea::stateTransitionInProgress() | |
114 { | |
115 if (isDuringStateTransitionAnimation()) { | |
116 double progress = existingScrollbarStateTransitionAnimator()->stateTrans itionProgress(); | |
117 blink::WebThemeEngine::State startState = existingScrollbarStateTransiti onAnimator()->stateTransitionStartState(); | |
118 blink::WebThemeEngine::State endState = existingScrollbarStateTransition Animator()->stateTransitionEndState(); | |
119 | |
120 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) { | |
121 verticalScrollbar->updateStateTransitionData(startState, endState, p rogress); | |
122 } | |
123 | |
124 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) { | |
125 horizontalScrollbar->updateStateTransitionData(startState, endState, progress); | |
126 } | |
127 } | |
128 } | |
129 | |
98 void ScrollableArea::setScrollOrigin(const IntPoint& origin) | 130 void ScrollableArea::setScrollOrigin(const IntPoint& origin) |
99 { | 131 { |
100 if (m_scrollOrigin != origin) { | 132 if (m_scrollOrigin != origin) { |
101 m_scrollOrigin = origin; | 133 m_scrollOrigin = origin; |
102 m_scrollOriginChanged = true; | 134 m_scrollOriginChanged = true; |
103 } | 135 } |
104 } | 136 } |
105 | 137 |
106 GraphicsLayer* ScrollableArea::layerForContainer() const | 138 GraphicsLayer* ScrollableArea::layerForContainer() const |
107 { | 139 { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 | 301 |
270 void ScrollableArea::mouseMovedInContentArea() const | 302 void ScrollableArea::mouseMovedInContentArea() const |
271 { | 303 { |
272 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) | 304 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) |
273 scrollAnimator->mouseMovedInContentArea(); | 305 scrollAnimator->mouseMovedInContentArea(); |
274 } | 306 } |
275 | 307 |
276 void ScrollableArea::mouseEnteredScrollbar(Scrollbar* scrollbar) const | 308 void ScrollableArea::mouseEnteredScrollbar(Scrollbar* scrollbar) const |
277 { | 309 { |
278 scrollAnimator()->mouseEnteredScrollbar(scrollbar); | 310 scrollAnimator()->mouseEnteredScrollbar(scrollbar); |
311 if (ScrollbarStateTransitionAnimator* animator = scrollbarStateTransitionAni mator()) | |
312 animator->mouseEnteredScrollbar(scrollbar); | |
279 } | 313 } |
280 | 314 |
281 void ScrollableArea::mouseExitedScrollbar(Scrollbar* scrollbar) const | 315 void ScrollableArea::mouseExitedScrollbar(Scrollbar* scrollbar) const |
282 { | 316 { |
283 scrollAnimator()->mouseExitedScrollbar(scrollbar); | 317 scrollAnimator()->mouseExitedScrollbar(scrollbar); |
318 if (ScrollbarStateTransitionAnimator* animator = scrollbarStateTransitionAni mator()) | |
319 animator->mouseExitedScrollbar(scrollbar); | |
284 } | 320 } |
285 | 321 |
286 void ScrollableArea::contentAreaDidShow() const | 322 void ScrollableArea::contentAreaDidShow() const |
287 { | 323 { |
288 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) | 324 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) |
289 scrollAnimator->contentAreaDidShow(); | 325 scrollAnimator->contentAreaDidShow(); |
290 } | 326 } |
291 | 327 |
292 void ScrollableArea::contentAreaDidHide() const | 328 void ScrollableArea::contentAreaDidHide() const |
293 { | 329 { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 bool ScrollableArea::hasLayerForVerticalScrollbar() const | 421 bool ScrollableArea::hasLayerForVerticalScrollbar() const |
386 { | 422 { |
387 return layerForVerticalScrollbar(); | 423 return layerForVerticalScrollbar(); |
388 } | 424 } |
389 | 425 |
390 bool ScrollableArea::hasLayerForScrollCorner() const | 426 bool ScrollableArea::hasLayerForScrollCorner() const |
391 { | 427 { |
392 return layerForScrollCorner(); | 428 return layerForScrollCorner(); |
393 } | 429 } |
394 | 430 |
395 void ScrollableArea::serviceScrollAnimations() | 431 void ScrollableArea::serviceScrollbarAnimations() |
396 { | 432 { |
397 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) | 433 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) |
398 scrollAnimator->serviceScrollAnimations(); | 434 scrollAnimator->serviceScrollAnimations(); |
435 if (ScrollbarStateTransitionAnimator* animator = existingScrollbarStateTrans itionAnimator()) | |
436 animator->serviceAnimations(); | |
399 } | 437 } |
400 | 438 |
401 IntRect ScrollableArea::visibleContentRect(IncludeScrollbarsInRect scrollbarIncl usion) const | 439 IntRect ScrollableArea::visibleContentRect(IncludeScrollbarsInRect scrollbarIncl usion) const |
402 { | 440 { |
403 int verticalScrollbarWidth = 0; | 441 int verticalScrollbarWidth = 0; |
404 int horizontalScrollbarHeight = 0; | 442 int horizontalScrollbarHeight = 0; |
405 | 443 |
406 if (scrollbarInclusion == IncludeScrollbars) { | 444 if (scrollbarInclusion == IncludeScrollbars) { |
407 if (Scrollbar* verticalBar = verticalScrollbar()) | 445 if (Scrollbar* verticalBar = verticalScrollbar()) |
408 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? vertic alBar->width() : 0; | 446 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? vertic alBar->width() : 0; |
(...skipping 30 matching lines...) Expand all Loading... | |
439 { | 477 { |
440 return scrollSize(orientation); | 478 return scrollSize(orientation); |
441 } | 479 } |
442 | 480 |
443 float ScrollableArea::pixelStep(ScrollbarOrientation) const | 481 float ScrollableArea::pixelStep(ScrollbarOrientation) const |
444 { | 482 { |
445 return 1; | 483 return 1; |
446 } | 484 } |
447 | 485 |
448 } // namespace WebCore | 486 } // namespace WebCore |
OLD | NEW |