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

Unified Diff: third_party/WebKit/Source/core/input/ScrollManager.cpp

Issue 2773593005: Move logic of recording main thread scrolling reasons from cc to blink::ScrollManager (Closed)
Patch Set: Update recording logic for non composited reasons Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
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..48d4b8b6d662f30ae2e0ee8c3487807dcce92d58 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,77 @@ void ScrollManager::customizedScroll(const Node& startNode,
scrollState.distributeToScrollChainDescendant();
}
+// When scrolling on the main thread, the scrollableArea may or may not be
+// composited.
bokan 2017/03/31 16:55:53 super-nit: No need for an early line break here, w
+// If it's composited and has the main thread scrolling reasons
+// stored in its layer, the reasons have been recorded on cc side. If it dosen't
+// have existing reasons but scrolls on main, we walk up its containing scroll
+// chain to find the first non composited region and record reaons accordingly.
bokan 2017/03/31 16:55:53 nit: reaons->reasons
+// If no such region is found or it doesn't have any main thread scorlling
bokan 2017/03/31 16:55:53 nit: scorlling->scrolling
+// reason, we record the reason kUnknownNonCompositedRegion.
+// If it's not composited, we have recorded "NonFastScrollableRegion" on
+// the cc side. Here we try to record additional reasons that prevent promotion.
+uint32_t ScrollManager::computeNonCompositedMainThreadScrollingReasons() {
+ if (!m_scrollGestureHandlingNode->layoutObject() || !m_frame->view())
+ return 0;
+ uint32_t reasons = 0;
+ LayoutBox* curBox =
+ m_scrollGestureHandlingNode->layoutObject()->enclosingBox();
+ bool compositedMainThreadScrollForUnknownReasons = false;
+
+ while (curBox) {
+ if (auto* scrollableArea = curBox->getScrollableArea()) {
bokan 2017/03/31 16:55:52 The repeated indents here make the code harder to
+ if (scrollableArea->usesCompositedScrolling()) {
+ if (m_frame->view()->mainThreadScrollingReasons()) {
+ return 0;
bokan 2017/03/31 16:55:53 I don't think you need this early return since it
+ }
+ compositedMainThreadScrollForUnknownReasons = true;
bokan 2017/03/31 16:55:53 We want to record "Unknown" if and only if we didn
+ } else {
+ reasons = scrollableArea->getNonCompositedMainThreadScrollingReasons();
bokan 2017/03/31 16:55:53 Add a DCHECK here that we have a reason.
+ break;
+ }
+ }
+ curBox = curBox->containingBlock();
+ }
+
+ if (!reasons && compositedMainThreadScrollForUnknownReasons)
+ return MainThreadScrollingReason::kUnknownNonCompositedRegion;
+
+ return reasons;
bokan 2017/03/31 16:55:53 Add a DCHECK here that reasons only contains NonCo
+}
+
+void ScrollManager::recordNonCompositedMainThreadScrollingReasons(
+ const WebGestureDevice device) {
+ if (device != WebGestureDeviceTouchpad &&
+ device != WebGestureDeviceTouchscreen) {
+ return;
+ }
+
+ uint32_t reasons = computeNonCompositedMainThreadScrollingReasons();
+ if (!reasons)
+ return;
+
+ uint32_t mainThreadScrollingReasonEnumMax =
+ MainThreadScrollingReason::kMainThreadScrollingReasonCount + 1;
+ for (uint32_t i = 0;
+ i < MainThreadScrollingReason::kMainThreadScrollingReasonCount; ++i) {
bokan 2017/03/31 16:55:52 You only need to loop over the NonCompositedScroll
+ 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 +293,8 @@ WebInputEventResult ScrollManager::handleGestureScrollBegin(
passScrollGestureEvent(gestureEvent,
m_scrollGestureHandlingNode->layoutObject());
+ recordNonCompositedMainThreadScrollingReasons(gestureEvent.sourceDevice);
+
m_currentScrollChain.clear();
std::unique_ptr<ScrollStateData> scrollStateData =
WTF::makeUnique<ScrollStateData>();

Powered by Google App Engine
This is Rietveld 408576698