Chromium Code Reviews| Index: third_party/WebKit/Source/core/input/ScrollManager.cpp |
| diff --git a/third_party/WebKit/Source/core/input/ScrollManager.cpp b/third_party/WebKit/Source/core/input/ScrollManager.cpp |
| index 727c3e74e57525196f5f4abb1ec12c18a21ecc4c..b50e85310355506bba5da51275e924cc7bac6e77 100644 |
| --- a/third_party/WebKit/Source/core/input/ScrollManager.cpp |
| +++ b/third_party/WebKit/Source/core/input/ScrollManager.cpp |
| @@ -22,6 +22,7 @@ |
| #include "core/page/scrolling/RootScrollerController.h" |
| #include "core/page/scrolling/ScrollState.h" |
| #include "core/paint/PaintLayer.h" |
| +#include "platform/Histogram.h" |
| #include "platform/RuntimeEnabledFeatures.h" |
| #include "wtf/PtrUtil.h" |
| @@ -196,6 +197,67 @@ void ScrollManager::customizedScroll(const Node& startNode, |
| scrollState.distributeToScrollChainDescendant(); |
| } |
| +uint32_t ScrollManager::computeNonCompositedMainThreadScrollingReasons() { |
| + // When scrolling on the main thread, the scrollableArea may or may not be |
| + // composited. Either way, we have recorded either the reasons that |
|
bokan
2017/04/06 21:45:09
nit: "reasons that stored" -> "reasons stored"
yigu
2017/04/07 16:35:32
Done.
|
| + // stored in its layer or the reason NonFastScrollableRegion from the |
| + // compositor side. Here we record scrolls that occurred on main thread |
| + // due to a non-composited scroller. |
| + if (!m_scrollGestureHandlingNode->layoutObject() || !m_frame->view()) |
| + return 0; |
| + |
| + uint32_t nonCompositedMainThreadScrollingReasons = 0; |
| + |
| + for (auto* curBox = |
| + m_scrollGestureHandlingNode->layoutObject()->enclosingBox(); |
| + curBox; curBox = curBox->containingBlock()) { |
| + PaintLayerScrollableArea* scrollableArea = curBox->getScrollableArea(); |
| + |
| + if (!scrollableArea || !scrollableArea->scrollsOverflow()) |
| + continue; |
| + |
| + DCHECK(!scrollableArea->usesCompositedScrolling() || |
| + !nonCompositedMainThreadScrollingReasons); |
| + nonCompositedMainThreadScrollingReasons = |
|
bokan
2017/04/06 21:45:09
this should be |=, right?
yigu
2017/04/07 16:35:32
Done.
|
| + scrollableArea->getNonCompositedMainThreadScrollingReasons(); |
| + } |
| + |
| + return nonCompositedMainThreadScrollingReasons; |
| +} |
| + |
| +void ScrollManager::recordNonCompositedMainThreadScrollingReasons( |
| + const WebGestureDevice device) { |
| + if (device != WebGestureDeviceTouchpad && |
| + device != WebGestureDeviceTouchscreen) { |
| + return; |
| + } |
| + |
| + uint32_t reasons = computeNonCompositedMainThreadScrollingReasons(); |
| + if (!reasons) |
| + return; |
| + DCHECK(MainThreadScrollingReason::NonCompositedScrollReasons(reasons)); |
|
bokan
2017/04/06 21:45:09
It wouldn't hurt to DCHECK that we don't have any
yigu
2017/04/07 16:35:32
Current DCHECK guarantees that the reason doesn't
bokan
2017/04/07 17:39:03
Ah, my bad, I didn't pay close enough attention to
|
| + |
| + uint32_t mainThreadScrollingReasonEnumMax = |
|
bokan
2017/04/06 21:45:10
unused
yigu
2017/04/07 16:35:32
It's used in DEFINE_STATIC_LOCAL.
bokan
2017/04/07 17:39:03
Doh
|
| + MainThreadScrollingReason::kMainThreadScrollingReasonCount + 1; |
| + for (uint32_t i = MainThreadScrollingReason::kNonCompositedReasonsFirst; |
| + i <= MainThreadScrollingReason::kNonCompositedReasonsLast; ++i) { |
| + unsigned val = 1 << i; |
| + if (reasons & val) { |
| + if (device == WebGestureDeviceTouchscreen) { |
| + DEFINE_STATIC_LOCAL(EnumerationHistogram, touchHistogram, |
| + ("Renderer4.MainThreadGestureScrollReason", |
| + mainThreadScrollingReasonEnumMax)); |
| + touchHistogram.count(i + 1); |
| + } else { |
| + DEFINE_STATIC_LOCAL(EnumerationHistogram, wheelHistogram, |
| + ("Renderer4.MainThreadWheelScrollReason", |
| + mainThreadScrollingReasonEnumMax)); |
| + wheelHistogram.count(i + 1); |
| + } |
| + } |
| + } |
| +} |
| + |
| WebInputEventResult ScrollManager::handleGestureScrollBegin( |
| const WebGestureEvent& gestureEvent) { |
| Document* document = m_frame->document(); |
| @@ -221,6 +283,8 @@ WebInputEventResult ScrollManager::handleGestureScrollBegin( |
| passScrollGestureEvent(gestureEvent, |
| m_scrollGestureHandlingNode->layoutObject()); |
| + recordNonCompositedMainThreadScrollingReasons(gestureEvent.sourceDevice); |
| + |
| m_currentScrollChain.clear(); |
| std::unique_ptr<ScrollStateData> scrollStateData = |
| WTF::makeUnique<ScrollStateData>(); |