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

Unified Diff: third_party/WebKit/Source/core/input/EventHandlerTest.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/EventHandlerTest.cpp
diff --git a/third_party/WebKit/Source/core/input/EventHandlerTest.cpp b/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
index f8618151f6be13253f4f4efeefa617b8fe13d3b2..aa40b9d50699a6d6daedb6ad30cfae2e7b76a9f2 100644
--- a/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
+++ b/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
@@ -16,6 +16,7 @@
#include "core/page/AutoscrollController.h"
#include "core/page/Page.h"
#include "core/testing/DummyPageHolder.h"
+#include "platform/testing/HistogramTester.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace blink {
@@ -79,6 +80,29 @@ class MousePressEventBuilder : public WebMouseEvent {
}
};
+class ScrollBeginEventBuilder : public WebGestureEvent {
+ public:
+ ScrollBeginEventBuilder(IntPoint position,
+ FloatPoint delta,
+ WebGestureDevice device)
+ : WebGestureEvent() {
+ m_type = WebInputEvent::GestureScrollBegin;
+ x = globalX = position.x();
+ y = globalY = position.y();
+ data.scrollBegin.deltaYHint = delta.y();
+ sourceDevice = device;
+ m_frameScale = 1;
+ }
+};
+
+class ScrollEndEventBuilder : public WebGestureEvent {
+ public:
+ ScrollEndEventBuilder() : WebGestureEvent() {
+ m_type = WebInputEvent::GestureScrollEnd;
+ m_frameScale = 1;
+ }
+};
+
void EventHandlerTest::SetUp() {
m_dummyPageHolder = DummyPageHolder::create(IntSize(300, 400));
}
@@ -461,6 +485,78 @@ TEST_F(EventHandlerTest, dragEndInNewDrag) {
// This test passes if it doesn't crash.
}
+TEST_F(EventHandlerTest, NonCompositedMainThreadScrollingReasonTest) {
+ setHtmlInnerHTML(
+ "<style>.box { width: 100px; height: 100px; overflow: scroll; }"
+ " .translucent { opacity: 0.5;}"
+ " .spacer { height: 1000px;} body {height: 1000px; }"
+ " .background_scroller { overflow: scroll; width: 250px; height: 250px;"
+ " position: absolute; z-index: -1;}"
+ " body { height: 2000px; width: 1000px;} "
+ "</style>"
+ "<div class='translucent box'><div class='spacer'></div></div>"
+ "<div id='under' class='background_scroller'><div "
+ "class='spacer'></div></div>"
+ "<div class='box' style='will-change:transform'><div "
+ "class='spacer'></div></div>");
+
+ page().settings().setAcceleratedCompositingEnabled(true);
+ document().view()->setParentVisible(true);
+ document().view()->setSelfVisible(true);
+ document().view()->updateAllLifecyclePhases();
+
+ HistogramTester histogramTester;
+ // Test wheel scroll.
+ ScrollBeginEventBuilder wheelScrollBegin(
+ IntPoint(50, 50), FloatPoint(0.f, 1.f), WebGestureDeviceTouchpad);
+ ScrollEndEventBuilder wheelScrollEnd;
+ document().frame()->eventHandler().handleGestureEvent(wheelScrollBegin);
+ document().frame()->eventHandler().handleGestureEvent(wheelScrollEnd);
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 17,
+ 1);
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 19,
+ 1);
+ histogramTester.expectTotalCount("Renderer4.MainThreadWheelScrollReason", 2);
+
+ // Composited scrolling doesn't add to the counts.
+ wheelScrollBegin.x = wheelScrollBegin.globalX = 450;
+ document().frame()->eventHandler().handleGestureEvent(wheelScrollBegin);
+ document().frame()->eventHandler().handleGestureEvent(wheelScrollEnd);
+ histogramTester.expectTotalCount("Renderer4.MainThreadWheelScrollReason", 2);
+
+ // Scroll a composited scroller A over a non-composited scroller B should
+ // cause the scroll events to go to the main thread because B is non fast
+ // scrollable region. If none of the scrollers from A's containing scroll
+ // chain has a reason, UnknownNonCompositedRegion should be added.
+ wheelScrollBegin.x = wheelScrollBegin.globalX = 50;
+ wheelScrollBegin.y = wheelScrollBegin.globalY = 150;
+ document().frame()->eventHandler().handleGestureEvent(wheelScrollBegin);
+ document().frame()->eventHandler().handleGestureEvent(wheelScrollEnd);
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 23,
+ 1);
+
+ // UnknownNonCompositedRegion is not added if the scroller underneath has a
+ // reason.
+ document().getElementById("under")->setAttribute("style", "position:fixed;");
+ document().frame()->eventHandler().handleGestureEvent(wheelScrollBegin);
+ document().frame()->eventHandler().handleGestureEvent(wheelScrollEnd);
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 23,
+ 1);
+ // Test touch scroll.
+ ScrollBeginEventBuilder touchScrollBegin(
+ IntPoint(50, 50), FloatPoint(0.f, 1.f), WebGestureDeviceTouchscreen);
+ ScrollEndEventBuilder touchScrollEnd;
+ document().frame()->eventHandler().handleGestureEvent(touchScrollBegin);
+ document().frame()->eventHandler().handleGestureEvent(touchScrollEnd);
+ histogramTester.expectBucketCount("Renderer4.MainThreadGestureScrollReason",
+ 17, 1);
+
+ document().frame()->eventHandler().handleGestureEvent(touchScrollBegin);
+ document().frame()->eventHandler().handleGestureEvent(touchScrollEnd);
+ histogramTester.expectBucketCount("Renderer4.MainThreadGestureScrollReason",
+ 17, 2);
+}
+
class TooltipCapturingChromeClient : public EmptyChromeClient {
public:
TooltipCapturingChromeClient() {}

Powered by Google App Engine
This is Rietveld 408576698