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

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: nit 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 6d05fe059f6f8a7ddb8b1370866f43cd5abda5ea..36869725211848db98d6b3e12d1c3be643e9cc90 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,75 @@ void ScrollManager::customizedScroll(const Node& startNode,
scrollState.distributeToScrollChainDescendant();
}
+uint32_t ScrollManager::computeMainThreadScrollingReasons(const Node& node) {
+ if (!m_frame || !m_frame->view())
+ return 0;
+ uint32_t reasons = m_frame->view()->mainThreadScrollingReasons();
+ LayoutBox* curBox = node.layoutObject()->enclosingBox();
+ Element* documentElement = m_frame->document()->documentElement();
+ while (curBox) {
+ Node* curNode = curBox->node();
+ Element* curElement = nullptr;
+ // FIXME: this should reject more elements, as part of crbug.com/410974.
+ if (curNode && curNode->isElementNode()) {
+ curElement = toElement(curNode);
+ } else if (curNode && curNode->isDocumentNode()) {
+ // In normal circumastances, the documentElement will be the root
+ // scroller but the documentElement itself isn't a containing block,
+ // that'll be the document node rather than the element.
+ curElement = documentElement;
bokan 2017/03/24 17:55:54 Document-scrolling is always composited so we don'
yigu 2017/03/27 21:02:07 Done.
+ } else {
+ curBox = curBox->containingBlock();
+ continue;
+ }
+ if (curElement) {
+ if (isViewportScrollingElement(*curElement) ||
+ curElement == documentElement)
+ break;
+ }
+ if (curNode->layoutBoxModelObject() &&
+ curNode->layoutBoxModelObject()->getScrollableArea()) {
+ reasons |= curNode->layoutBoxModelObject()
bokan 2017/03/24 17:55:54 Given that I think since we'll record the other ma
yigu 2017/03/27 21:02:07 Done.
+ ->getScrollableArea()
+ ->getStyleRelatedMainThreadScrollingReasons();
+ }
+ curBox = curBox->containingBlock();
+ }
+ return reasons;
+}
+
+void ScrollManager::recordMainThreadScrollingReasons(
+ const uint32_t reasons,
+ const WebGestureDevice device) {
+ uint32_t mainThreadScrollingReasonEnumMax =
+ MainThreadScrollingReason::kMainThreadScrollingReasonCount + 1;
+ for (uint32_t i = 0;
+ i < MainThreadScrollingReason::kMainThreadScrollingReasonCount; ++i) {
+ unsigned val = 1 << i;
+ if (reasons & val) {
+ if (val == MainThreadScrollingReason::kHandlingScrollFromMainThread) {
+ // We only want to record "Handling scroll from main thread" reason if
+ // it's the only reason. If it's not the only reason, the "real"
+ // reason for scrolling on main is something else, and we only want to
+ // pay attention to that reason.
+ if (reasons & ~val)
+ continue;
+ }
+ 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 +291,15 @@ WebInputEventResult ScrollManager::handleGestureScrollBegin(
passScrollGestureEvent(gestureEvent,
m_scrollGestureHandlingNode->layoutObject());
+ if (m_scrollGestureHandlingNode->layoutObject() &&
+ (gestureEvent.sourceDevice == WebGestureDeviceTouchpad ||
+ gestureEvent.sourceDevice == WebGestureDeviceTouchscreen)) {
+ uint32_t reasons =
+ computeMainThreadScrollingReasons(*m_scrollGestureHandlingNode);
+ if (reasons)
bokan 2017/03/24 17:55:54 Move all the additions above into recordMainThread
+ recordMainThreadScrollingReasons(reasons, gestureEvent.sourceDevice);
+ }
+
m_currentScrollChain.clear();
std::unique_ptr<ScrollStateData> scrollStateData =
WTF::makeUnique<ScrollStateData>();

Powered by Google App Engine
This is Rietveld 408576698