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

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

Issue 246293006: Blink Support for Overlay Scrollbar Animation Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix unittest and move unittest to blink_platform_unittests Created 6 years, 3 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
« no previous file with comments | « Source/platform/scroll/ScrollableArea.h ('k') | Source/platform/scroll/Scrollbar.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 16 matching lines...) Expand all
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/HostWindow.h" 35 #include "platform/HostWindow.h"
36 #include "platform/Logging.h" 36 #include "platform/Logging.h"
37 #include "platform/TraceEvent.h"
37 #include "platform/graphics/GraphicsLayer.h" 38 #include "platform/graphics/GraphicsLayer.h"
38 #include "platform/geometry/FloatPoint.h" 39 #include "platform/geometry/FloatPoint.h"
39 #include "platform/scroll/ProgrammaticScrollAnimator.h" 40 #include "platform/scroll/ProgrammaticScrollAnimator.h"
41 #include "platform/scroll/ScrollbarStateTransitionAnimator.h"
40 #include "platform/scroll/ScrollbarTheme.h" 42 #include "platform/scroll/ScrollbarTheme.h"
41 #include "wtf/PassOwnPtr.h" 43 #include "wtf/PassOwnPtr.h"
42 44
43 #include "platform/TraceEvent.h"
44 45
45 static const int kPixelsPerLineStep = 40; 46 static const int kPixelsPerLineStep = 40;
46 static const float kMinFractionToStepWhenPaging = 0.875f; 47 static const float kMinFractionToStepWhenPaging = 0.875f;
47 48
48 namespace blink { 49 namespace blink {
49 50
50 struct SameSizeAsScrollableArea { 51 struct SameSizeAsScrollableArea {
51 virtual ~SameSizeAsScrollableArea(); 52 virtual ~SameSizeAsScrollableArea();
52 IntRect scrollbarDamage[2]; 53 IntRect scrollbarDamage[2];
53 void* pointer; 54 void* pointer;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 { 103 {
103 if (!m_animators) 104 if (!m_animators)
104 m_animators = adoptPtr(new ScrollableAreaAnimators); 105 m_animators = adoptPtr(new ScrollableAreaAnimators);
105 106
106 if (!m_animators->programmaticScrollAnimator) 107 if (!m_animators->programmaticScrollAnimator)
107 m_animators->programmaticScrollAnimator = ProgrammaticScrollAnimator::cr eate(const_cast<ScrollableArea*>(this)); 108 m_animators->programmaticScrollAnimator = ProgrammaticScrollAnimator::cr eate(const_cast<ScrollableArea*>(this));
108 109
109 return m_animators->programmaticScrollAnimator.get(); 110 return m_animators->programmaticScrollAnimator.get();
110 } 111 }
111 112
113 ScrollbarStateTransitionAnimator* ScrollableArea::scrollbarStateTransitionAnimat or() const
114 {
115 if (!m_animators)
116 m_animators = adoptPtr(new ScrollableAreaAnimators);
117
118 if (!m_animators->scrollbarStateTransitionAnimator)
119 m_animators->scrollbarStateTransitionAnimator = ScrollbarStateTransition Animator::create(const_cast<ScrollableArea*>(this));
120
121 return m_animators->scrollbarStateTransitionAnimator.get();
122 }
123
124 bool ScrollableArea::isDuringStateTransitionAnimation() const
125 {
126 return hasOverlayScrollbars() && existingScrollbarStateTransitionAnimator() && existingScrollbarStateTransitionAnimator()->isDuringStateTransitionAnimation( );
127 }
128
129 void ScrollableArea::stateTransitionInProgress()
130 {
131 if (isDuringStateTransitionAnimation()) {
132 double progress = existingScrollbarStateTransitionAnimator()->stateTrans itionProgress();
133 blink::WebThemeEngine::State startState = existingScrollbarStateTransiti onAnimator()->stateTransitionStartState();
134 blink::WebThemeEngine::State endState = existingScrollbarStateTransition Animator()->stateTransitionEndState();
135
136 if (Scrollbar* verticalScrollbar = this->verticalScrollbar()) {
137 verticalScrollbar->updateStateTransitionData(startState, endState, p rogress);
138 }
139
140 if (Scrollbar* horizontalScrollbar = this->horizontalScrollbar()) {
141 horizontalScrollbar->updateStateTransitionData(startState, endState, progress);
142 }
143 }
144 }
145
112 void ScrollableArea::setScrollOrigin(const IntPoint& origin) 146 void ScrollableArea::setScrollOrigin(const IntPoint& origin)
113 { 147 {
114 if (m_scrollOrigin != origin) { 148 if (m_scrollOrigin != origin) {
115 m_scrollOrigin = origin; 149 m_scrollOrigin = origin;
116 m_scrollOriginChanged = true; 150 m_scrollOriginChanged = true;
117 } 151 }
118 } 152 }
119 153
120 GraphicsLayer* ScrollableArea::layerForContainer() const 154 GraphicsLayer* ScrollableArea::layerForContainer() const
121 { 155 {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 328
295 void ScrollableArea::mouseMovedInContentArea() const 329 void ScrollableArea::mouseMovedInContentArea() const
296 { 330 {
297 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) 331 if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
298 scrollAnimator->mouseMovedInContentArea(); 332 scrollAnimator->mouseMovedInContentArea();
299 } 333 }
300 334
301 void ScrollableArea::mouseEnteredScrollbar(Scrollbar* scrollbar) const 335 void ScrollableArea::mouseEnteredScrollbar(Scrollbar* scrollbar) const
302 { 336 {
303 scrollAnimator()->mouseEnteredScrollbar(scrollbar); 337 scrollAnimator()->mouseEnteredScrollbar(scrollbar);
338 if (ScrollbarStateTransitionAnimator* animator = scrollbarStateTransitionAni mator())
339 animator->mouseEnteredScrollbar(scrollbar);
304 } 340 }
305 341
306 void ScrollableArea::mouseExitedScrollbar(Scrollbar* scrollbar) const 342 void ScrollableArea::mouseExitedScrollbar(Scrollbar* scrollbar) const
307 { 343 {
308 scrollAnimator()->mouseExitedScrollbar(scrollbar); 344 scrollAnimator()->mouseExitedScrollbar(scrollbar);
345 if (ScrollbarStateTransitionAnimator* animator = scrollbarStateTransitionAni mator())
346 animator->mouseExitedScrollbar(scrollbar);
309 } 347 }
310 348
311 void ScrollableArea::contentAreaDidShow() const 349 void ScrollableArea::contentAreaDidShow() const
312 { 350 {
313 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) 351 if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
314 scrollAnimator->contentAreaDidShow(); 352 scrollAnimator->contentAreaDidShow();
315 } 353 }
316 354
317 void ScrollableArea::contentAreaDidHide() const 355 void ScrollableArea::contentAreaDidHide() const
318 { 356 {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgram maticScrollAnimator()) 473 if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgram maticScrollAnimator())
436 programmaticScrollAnimator->tickAnimation(monotonicTime); 474 programmaticScrollAnimator->tickAnimation(monotonicTime);
437 } 475 }
438 476
439 void ScrollableArea::cancelProgrammaticScrollAnimation() 477 void ScrollableArea::cancelProgrammaticScrollAnimation()
440 { 478 {
441 if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgram maticScrollAnimator()) 479 if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgram maticScrollAnimator())
442 programmaticScrollAnimator->cancelAnimation(); 480 programmaticScrollAnimator->cancelAnimation();
443 } 481 }
444 482
483 void ScrollableArea::serviceScrollbarAnimations()
484 {
485 if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
486 scrollAnimator->serviceScrollAnimations();
487 if (ScrollbarStateTransitionAnimator* animator = existingScrollbarStateTrans itionAnimator())
488 animator->serviceAnimations();
489 }
490
445 IntRect ScrollableArea::visibleContentRect(IncludeScrollbarsInRect scrollbarIncl usion) const 491 IntRect ScrollableArea::visibleContentRect(IncludeScrollbarsInRect scrollbarIncl usion) const
446 { 492 {
447 int verticalScrollbarWidth = 0; 493 int verticalScrollbarWidth = 0;
448 int horizontalScrollbarHeight = 0; 494 int horizontalScrollbarHeight = 0;
449 495
450 if (scrollbarInclusion == IncludeScrollbars) { 496 if (scrollbarInclusion == IncludeScrollbars) {
451 if (Scrollbar* verticalBar = verticalScrollbar()) 497 if (Scrollbar* verticalBar = verticalScrollbar())
452 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? vertic alBar->width() : 0; 498 verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? vertic alBar->width() : 0;
453 if (Scrollbar* horizontalBar = horizontalScrollbar()) 499 if (Scrollbar* horizontalBar = horizontalScrollbar())
454 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? h orizontalBar->height() : 0; 500 horizontalScrollbarHeight = !horizontalBar->isOverlayScrollbar() ? h orizontalBar->height() : 0;
(...skipping 28 matching lines...) Expand all
483 { 529 {
484 return scrollSize(orientation); 530 return scrollSize(orientation);
485 } 531 }
486 532
487 float ScrollableArea::pixelStep(ScrollbarOrientation) const 533 float ScrollableArea::pixelStep(ScrollbarOrientation) const
488 { 534 {
489 return 1; 535 return 1;
490 } 536 }
491 537
492 } // namespace blink 538 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/scroll/ScrollableArea.h ('k') | Source/platform/scroll/Scrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698