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

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

Issue 2644243002: Move ScrollableArea timer to TaskRunnerTimer. (Closed)
Patch Set: Created 3 years, 11 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
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 19 matching lines...) Expand all
30 */ 30 */
31 31
32 #include "platform/scroll/ScrollableArea.h" 32 #include "platform/scroll/ScrollableArea.h"
33 33
34 #include "platform/HostWindow.h" 34 #include "platform/HostWindow.h"
35 #include "platform/graphics/GraphicsLayer.h" 35 #include "platform/graphics/GraphicsLayer.h"
36 #include "platform/instrumentation/tracing/TraceEvent.h" 36 #include "platform/instrumentation/tracing/TraceEvent.h"
37 #include "platform/scroll/MainThreadScrollingReason.h" 37 #include "platform/scroll/MainThreadScrollingReason.h"
38 #include "platform/scroll/ProgrammaticScrollAnimator.h" 38 #include "platform/scroll/ProgrammaticScrollAnimator.h"
39 #include "platform/scroll/ScrollbarTheme.h" 39 #include "platform/scroll/ScrollbarTheme.h"
40 #include "public/platform/Platform.h"
41 #include "public/platform/WebScheduler.h"
42 #include "public/platform/WebThread.h"
40 43
41 static const int kPixelsPerLineStep = 40; 44 static const int kPixelsPerLineStep = 40;
42 static const float kMinFractionToStepWhenPaging = 0.875f; 45 static const float kMinFractionToStepWhenPaging = 0.875f;
43 46
44 namespace blink { 47 namespace blink {
45 48
46 int ScrollableArea::pixelsPerLineStep(HostWindow* host) { 49 int ScrollableArea::pixelsPerLineStep(HostWindow* host) {
47 if (!host) 50 if (!host)
48 return kPixelsPerLineStep; 51 return kPixelsPerLineStep;
49 return host->windowToViewportScalar(kPixelsPerLineStep); 52 return host->windowToViewportScalar(kPixelsPerLineStep);
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 ScrollbarTheme::theme().overlayScrollbarFadeOutDelaySeconds() + 573 ScrollbarTheme::theme().overlayScrollbarFadeOutDelaySeconds() +
571 ScrollbarTheme::theme().overlayScrollbarFadeOutDurationSeconds(); 574 ScrollbarTheme::theme().overlayScrollbarFadeOutDurationSeconds();
572 575
573 // If the overlay scrollbars don't fade out, don't do anything. This is the 576 // If the overlay scrollbars don't fade out, don't do anything. This is the
574 // case for the mock overlays used in tests and on Mac, where the fade-out is 577 // case for the mock overlays used in tests and on Mac, where the fade-out is
575 // animated in ScrollAnimatorMac. 578 // animated in ScrollAnimatorMac.
576 if (!timeUntilDisable) 579 if (!timeUntilDisable)
577 return; 580 return;
578 581
579 if (!m_fadeOverlayScrollbarsTimer) { 582 if (!m_fadeOverlayScrollbarsTimer) {
580 m_fadeOverlayScrollbarsTimer.reset(new Timer<ScrollableArea>( 583 m_fadeOverlayScrollbarsTimer.reset(new TaskRunnerTimer<ScrollableArea>(
581 this, &ScrollableArea::fadeOverlayScrollbarsTimerFired)); 584 getTimerTaskRunner(), this,
585 &ScrollableArea::fadeOverlayScrollbarsTimerFired));
582 } 586 }
583 587
584 if (!m_scrollbarCaptured && !m_mouseOverScrollbar) { 588 if (!m_scrollbarCaptured && !m_mouseOverScrollbar) {
585 m_fadeOverlayScrollbarsTimer->startOneShot(timeUntilDisable, 589 m_fadeOverlayScrollbarsTimer->startOneShot(timeUntilDisable,
586 BLINK_FROM_HERE); 590 BLINK_FROM_HERE);
587 } 591 }
588 } 592 }
589 593
590 IntRect ScrollableArea::visibleContentRect( 594 IntRect ScrollableArea::visibleContentRect(
591 IncludeScrollbarsInRect scrollbarInclusion) const { 595 IncludeScrollbarsInRect scrollbarInclusion) const {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 } 654 }
651 655
652 FloatQuad ScrollableArea::localToVisibleContentQuad(const FloatQuad& quad, 656 FloatQuad ScrollableArea::localToVisibleContentQuad(const FloatQuad& quad,
653 const LayoutObject*, 657 const LayoutObject*,
654 unsigned) const { 658 unsigned) const {
655 FloatQuad result(quad); 659 FloatQuad result(quad);
656 result.move(-getScrollOffset()); 660 result.move(-getScrollOffset());
657 return result; 661 return result;
658 } 662 }
659 663
664 RefPtr<WebTaskRunner> ScrollableArea::getTimerTaskRunner() const {
haraken 2017/01/20 05:45:51 I'd prefer making this a pure virtual method and o
jbroman 2017/01/20 15:55:17 Done.
665 WebThread* thread = Platform::current()->mainThread();
666 DCHECK(thread->isCurrentThread());
667 return thread->scheduler()->timerTaskRunner();
668 }
669
660 IntSize ScrollableArea::excludeScrollbars(const IntSize& size) const { 670 IntSize ScrollableArea::excludeScrollbars(const IntSize& size) const {
661 return IntSize(std::max(0, size.width() - verticalScrollbarWidth()), 671 return IntSize(std::max(0, size.width() - verticalScrollbarWidth()),
662 std::max(0, size.height() - horizontalScrollbarHeight())); 672 std::max(0, size.height() - horizontalScrollbarHeight()));
663 } 673 }
664 674
665 DEFINE_TRACE(ScrollableArea) { 675 DEFINE_TRACE(ScrollableArea) {
666 visitor->trace(m_scrollAnimator); 676 visitor->trace(m_scrollAnimator);
667 visitor->trace(m_programmaticScrollAnimator); 677 visitor->trace(m_programmaticScrollAnimator);
668 } 678 }
669 679
670 } // namespace blink 680 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698