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

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: bug fix 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..9423015b04b852c9a999eb510a86d68785e38fe2 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,81 @@ 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. 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
+ // reasons accordingly. If no such region is found or it doesn't have any main
+ // thread 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.
+ if (!m_scrollGestureHandlingNode->layoutObject() || !m_frame->view())
+ return 0;
+ uint32_t reasons = 0;
+ bool hasMainThreadScrollingReason = false;
+ bool usesCompositedScrolling = false;
+
+ for (auto* curBox =
+ m_scrollGestureHandlingNode->layoutObject()->enclosingBox();
+ curBox; curBox = curBox->containingBlock()) {
+ auto* scrollableArea = curBox->getScrollableArea();
+ if (!scrollableArea)
+ continue;
+
+ if (scrollableArea->usesCompositedScrolling()) {
+ usesCompositedScrolling = true;
+ hasMainThreadScrollingReason =
+ !!(m_frame->view()->mainThreadScrollingReasons());
bokan 2017/04/04 18:14:26 There's no need to use !!, the value will be impli
+ } else {
+ reasons = scrollableArea->getNonCompositedMainThreadScrollingReasons();
+ if (!reasons)
bokan 2017/04/04 18:14:26 This `if` violates the rule that a non-composited
+ continue;
+ break;
bokan 2017/04/04 18:14:26 hmm...I think it would be beneficial to keep walki
+ }
+ }
+
+ if (usesCompositedScrolling && !reasons && !hasMainThreadScrollingReason)
bokan 2017/04/04 18:14:26 I think this is still off. usesCompositedScrolling
+ return MainThreadScrollingReason::kUnknownNonCompositedRegion;
+
+ return reasons;
+}
+
+void ScrollManager::recordNonCompositedMainThreadScrollingReasons(
+ const WebGestureDevice device) {
+ if (device != WebGestureDeviceTouchpad &&
+ device != WebGestureDeviceTouchscreen) {
+ return;
+ }
+
+ uint32_t reasons = computeNonCompositedMainThreadScrollingReasons();
+ if (!reasons)
+ return;
+ DCHECK(MainThreadScrollingReason::NonCompositedScrollReasons(reasons));
+
+ uint32_t mainThreadScrollingReasonEnumMax =
+ 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 +297,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