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

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

Issue 1534813004: Run smooth scroll animations on the compositor when possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 5 years 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
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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 447
448 bool ScrollableArea::hasLayerForScrollCorner() const 448 bool ScrollableArea::hasLayerForScrollCorner() const
449 { 449 {
450 return layerForScrollCorner(); 450 return layerForScrollCorner();
451 } 451 }
452 452
453 void ScrollableArea::layerForScrollingDidChange(WebCompositorAnimationTimeline* timeline) 453 void ScrollableArea::layerForScrollingDidChange(WebCompositorAnimationTimeline* timeline)
454 { 454 {
455 if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgram maticScrollAnimator()) 455 if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgram maticScrollAnimator())
456 programmaticScrollAnimator->layerForCompositedScrollingDidChange(timelin e); 456 programmaticScrollAnimator->layerForCompositedScrollingDidChange(timelin e);
457 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator())
458 scrollAnimator->layerForCompositedScrollingDidChange(timeline);
457 } 459 }
458 460
459 bool ScrollableArea::scheduleAnimation() 461 bool ScrollableArea::scheduleAnimation()
460 { 462 {
461 if (HostWindow* window = hostWindow()) { 463 if (HostWindow* window = hostWindow()) {
462 window->scheduleAnimation(widget()); 464 window->scheduleAnimation(widget());
463 return true; 465 return true;
464 } 466 }
465 return false; 467 return false;
466 } 468 }
467 469
468 void ScrollableArea::serviceScrollAnimations(double monotonicTime) 470 void ScrollableArea::serviceScrollAnimations(double monotonicTime)
469 { 471 {
470 bool requiresAnimationService = false; 472 bool requiresAnimationService = false;
471 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) { 473 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) {
472 scrollAnimator->serviceScrollAnimations(); 474 scrollAnimator->tickAnimation(monotonicTime);
473 if (scrollAnimator->hasRunningAnimation()) 475 if (scrollAnimator->hasAnimationThatRequiresService())
474 requiresAnimationService = true; 476 requiresAnimationService = true;
475 } 477 }
476 if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgram maticScrollAnimator()) { 478 if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgram maticScrollAnimator()) {
477 programmaticScrollAnimator->tickAnimation(monotonicTime); 479 programmaticScrollAnimator->tickAnimation(monotonicTime);
478 if (programmaticScrollAnimator->hasAnimationThatRequiresService()) 480 if (programmaticScrollAnimator->hasAnimationThatRequiresService())
479 requiresAnimationService = true; 481 requiresAnimationService = true;
480 } 482 }
481 if (!requiresAnimationService) 483 if (!requiresAnimationService)
482 deregisterForAnimation(); 484 deregisterForAnimation();
483 } 485 }
484 486
485 void ScrollableArea::updateCompositorScrollAnimations() 487 void ScrollableArea::updateCompositorScrollAnimations()
486 { 488 {
487 if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgram maticScrollAnimator()) 489 if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgram maticScrollAnimator())
488 programmaticScrollAnimator->updateCompositorAnimations(); 490 programmaticScrollAnimator->updateCompositorAnimations();
491
492 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator())
493 scrollAnimator->updateCompositorAnimations();
489 } 494 }
490 495
491 void ScrollableArea::notifyCompositorAnimationFinished(int groupId) 496 void ScrollableArea::notifyCompositorAnimationFinished(int groupId)
492 { 497 {
493 if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgram maticScrollAnimator()) 498 if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgram maticScrollAnimator())
494 programmaticScrollAnimator->notifyCompositorAnimationFinished(groupId); 499 programmaticScrollAnimator->notifyCompositorAnimationFinished(groupId);
500
501 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator())
502 scrollAnimator->notifyCompositorAnimationFinished(groupId);
495 } 503 }
496 504
497 void ScrollableArea::cancelScrollAnimation() 505 void ScrollableArea::cancelScrollAnimation()
498 { 506 {
499 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) 507 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator())
500 scrollAnimator->cancelAnimations(); 508 scrollAnimator->cancelAnimation();
501 } 509 }
502 510
503 void ScrollableArea::cancelProgrammaticScrollAnimation() 511 void ScrollableArea::cancelProgrammaticScrollAnimation()
504 { 512 {
505 if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgram maticScrollAnimator()) 513 if (ProgrammaticScrollAnimator* programmaticScrollAnimator = existingProgram maticScrollAnimator())
506 programmaticScrollAnimator->cancelAnimation(); 514 programmaticScrollAnimator->cancelAnimation();
507 } 515 }
508 516
509 DoubleRect ScrollableArea::visibleContentRectDouble(IncludeScrollbarsInRect scro llbarInclusion) const 517 DoubleRect ScrollableArea::visibleContentRectDouble(IncludeScrollbarsInRect scro llbarInclusion) const
510 { 518 {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 std::max(0, size.height() - horizontalScrollbarHeight)); 586 std::max(0, size.height() - horizontalScrollbarHeight));
579 } 587 }
580 588
581 DEFINE_TRACE(ScrollableArea) 589 DEFINE_TRACE(ScrollableArea)
582 { 590 {
583 visitor->trace(m_scrollAnimator); 591 visitor->trace(m_scrollAnimator);
584 visitor->trace(m_programmaticScrollAnimator); 592 visitor->trace(m_programmaticScrollAnimator);
585 } 593 }
586 594
587 } // namespace blink 595 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698