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

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

Issue 2453553003: Disable overlay scrollbars in Blink when hidden by the compositor. (Closed)
Patch Set: Created 4 years, 1 month 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 static const float kMinFractionToStepWhenPaging = 0.875f; 43 static const float kMinFractionToStepWhenPaging = 0.875f;
44 44
45 namespace blink { 45 namespace blink {
46 46
47 struct SameSizeAsScrollableArea { 47 struct SameSizeAsScrollableArea {
48 virtual ~SameSizeAsScrollableArea(); 48 virtual ~SameSizeAsScrollableArea();
49 #if ENABLE(ASSERT) 49 #if ENABLE(ASSERT)
50 VerifyEagerFinalization verifyEager; 50 VerifyEagerFinalization verifyEager;
51 #endif 51 #endif
52 Member<void*> pointer[2]; 52 Member<void*> pointer[2];
53 unsigned bitfields : 16; 53 unsigned bitfields : 17;
54 IntPoint origin; 54 IntPoint origin;
55 }; 55 };
56 56
57 static_assert(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea), 57 static_assert(sizeof(ScrollableArea) == sizeof(SameSizeAsScrollableArea),
58 "ScrollableArea should stay small"); 58 "ScrollableArea should stay small");
59 59
60 int ScrollableArea::pixelsPerLineStep(HostWindow* host) { 60 int ScrollableArea::pixelsPerLineStep(HostWindow* host) {
61 if (!host) 61 if (!host)
62 return kPixelsPerLineStep; 62 return kPixelsPerLineStep;
63 return host->windowToViewportScalar(kPixelsPerLineStep); 63 return host->windowToViewportScalar(kPixelsPerLineStep);
64 } 64 }
65 65
66 float ScrollableArea::minFractionToStepWhenPaging() { 66 float ScrollableArea::minFractionToStepWhenPaging() {
67 return kMinFractionToStepWhenPaging; 67 return kMinFractionToStepWhenPaging;
68 } 68 }
69 69
70 int ScrollableArea::maxOverlapBetweenPages() { 70 int ScrollableArea::maxOverlapBetweenPages() {
71 static int maxOverlapBetweenPages = 71 static int maxOverlapBetweenPages =
72 ScrollbarTheme::theme().maxOverlapBetweenPages(); 72 ScrollbarTheme::theme().maxOverlapBetweenPages();
73 return maxOverlapBetweenPages; 73 return maxOverlapBetweenPages;
74 } 74 }
75 75
76 ScrollableArea::ScrollableArea() 76 ScrollableArea::ScrollableArea()
77 : m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault), 77 : m_scrollbarOverlayStyle(ScrollbarOverlayStyleDefault),
78 m_scrollOriginChanged(false), 78 m_scrollOriginChanged(false),
79 m_horizontalScrollbarNeedsPaintInvalidation(false), 79 m_horizontalScrollbarNeedsPaintInvalidation(false),
80 m_verticalScrollbarNeedsPaintInvalidation(false), 80 m_verticalScrollbarNeedsPaintInvalidation(false),
81 m_scrollCornerNeedsPaintInvalidation(false) {} 81 m_scrollCornerNeedsPaintInvalidation(false),
82 m_scrollbarsHidden(false) {}
82 83
83 ScrollableArea::~ScrollableArea() {} 84 ScrollableArea::~ScrollableArea() {}
84 85
85 void ScrollableArea::clearScrollAnimators() { 86 void ScrollableArea::clearScrollAnimators() {
86 #if OS(MACOSX) 87 #if OS(MACOSX)
87 if (m_scrollAnimator) 88 if (m_scrollAnimator)
88 m_scrollAnimator->dispose(); 89 m_scrollAnimator->dispose();
89 #endif 90 #endif
90 m_scrollAnimator.clear(); 91 m_scrollAnimator.clear();
91 m_programmaticScrollAnimator.clear(); 92 m_programmaticScrollAnimator.clear();
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 // scheduled on the compositor. 522 // scheduled on the compositor.
522 // TODO(ymalik): We have a non-transient "main thread scrolling reason" 523 // TODO(ymalik): We have a non-transient "main thread scrolling reason"
523 // that doesn't actually cause shouldScrollOnMainThread() to be true. 524 // that doesn't actually cause shouldScrollOnMainThread() to be true.
524 // This is confusing and should be cleaned up. 525 // This is confusing and should be cleaned up.
525 return !!(reasons & 526 return !!(reasons &
526 ~MainThreadScrollingReason::kHandlingScrollFromMainThread); 527 ~MainThreadScrollingReason::kHandlingScrollFromMainThread);
527 } 528 }
528 return true; 529 return true;
529 } 530 }
530 531
532 bool ScrollableArea::scrollbarsHidden() const {
533 return hasOverlayScrollbars() && m_scrollbarsHidden;
534 }
535
536 void ScrollableArea::setScrollbarsHidden(bool hidden) {
537 if (m_scrollbarsHidden == hidden)
538 return;
539 m_scrollbarsHidden = hidden;
540 didChangeScrollbarsHidden();
541 }
542
531 IntRect ScrollableArea::visibleContentRect( 543 IntRect ScrollableArea::visibleContentRect(
532 IncludeScrollbarsInRect scrollbarInclusion) const { 544 IncludeScrollbarsInRect scrollbarInclusion) const {
533 int scrollbarWidth = 545 int scrollbarWidth =
534 scrollbarInclusion == IncludeScrollbars ? verticalScrollbarWidth() : 0; 546 scrollbarInclusion == IncludeScrollbars ? verticalScrollbarWidth() : 0;
535 int scrollbarHeight = 547 int scrollbarHeight =
536 scrollbarInclusion == IncludeScrollbars ? horizontalScrollbarHeight() : 0; 548 scrollbarInclusion == IncludeScrollbars ? horizontalScrollbarHeight() : 0;
537 549
538 return enclosingIntRect( 550 return enclosingIntRect(
539 IntRect(scrollOffset().width(), scrollOffset().height(), 551 IntRect(scrollOffset().width(), scrollOffset().height(),
540 std::max(0, visibleWidth() + scrollbarWidth), 552 std::max(0, visibleWidth() + scrollbarWidth),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 return IntSize(std::max(0, size.width() - verticalScrollbarWidth()), 602 return IntSize(std::max(0, size.width() - verticalScrollbarWidth()),
591 std::max(0, size.height() - horizontalScrollbarHeight())); 603 std::max(0, size.height() - horizontalScrollbarHeight()));
592 } 604 }
593 605
594 DEFINE_TRACE(ScrollableArea) { 606 DEFINE_TRACE(ScrollableArea) {
595 visitor->trace(m_scrollAnimator); 607 visitor->trace(m_scrollAnimator);
596 visitor->trace(m_programmaticScrollAnimator); 608 visitor->trace(m_programmaticScrollAnimator);
597 } 609 }
598 610
599 } // namespace blink 611 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698