summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-18 20:06:05 +0000
committerjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-18 20:06:05 +0000
commitcbedd09e8ac8e3beedb9e2e6bcbf1e553a82f0e0 (patch)
tree425456c0c848f0eced78d892c1cb2036c7e9d5f3 /content
parent2aadf21d2ff4882cb94510e4107067a70a928850 (diff)
downloadchromium_src-cbedd09e8ac8e3beedb9e2e6bcbf1e553a82f0e0.zip
chromium_src-cbedd09e8ac8e3beedb9e2e6bcbf1e553a82f0e0.tar.gz
chromium_src-cbedd09e8ac8e3beedb9e2e6bcbf1e553a82f0e0.tar.bz2
Suppress ignored acks for various mouse event types
The only mouse event type that has a meaningful ack is MouseMove. Ignore all other mouse event acks, reducing unnecessary IPC traffic. BUG=302852 Review URL: https://codereview.chromium.org/105623004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241626 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/renderer_host/input/input_router_impl_unittest.cc52
-rw-r--r--content/common/input/web_input_event_traits.cc5
-rw-r--r--content/renderer/input/input_event_filter_unittest.cc29
3 files changed, 64 insertions, 22 deletions
diff --git a/content/browser/renderer_host/input/input_router_impl_unittest.cc b/content/browser/renderer_host/input/input_router_impl_unittest.cc
index f51264b..0dd38bc9 100644
--- a/content/browser/renderer_host/input/input_router_impl_unittest.cc
+++ b/content/browser/renderer_host/input/input_router_impl_unittest.cc
@@ -153,10 +153,9 @@ class InputRouterImplTest : public testing::Test {
ui::LatencyInfo()));
}
- void SimulateMouseMove(int x, int y, int modifiers) {
+ void SimulateMouseEvent(WebInputEvent::Type type, int x, int y) {
input_router_->SendMouseEvent(MouseEventWithLatencyInfo(
- SyntheticWebMouseEventBuilder::Build(
- WebInputEvent::MouseMove, x, y, modifiers),
+ SyntheticWebMouseEventBuilder::Build(type, x, y, 0),
ui::LatencyInfo()));
}
@@ -705,6 +704,7 @@ TEST_F(InputRouterImplTest, UnhandledWheelEvent) {
TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) {
int start_type = static_cast<int>(WebInputEvent::TouchStart);
int end_type = static_cast<int>(WebInputEvent::TouchCancel);
+ ASSERT_LT(start_type, end_type);
for (int i = start_type; i <= end_type; ++i) {
WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i);
if (!WebInputEventTraits::IgnoresAckDisposition(type))
@@ -734,6 +734,7 @@ TEST_F(InputRouterImplTest, TouchTypesIgnoringAck) {
TEST_F(InputRouterImplTest, GestureTypesIgnoringAck) {
int start_type = static_cast<int>(WebInputEvent::GestureScrollBegin);
int end_type = static_cast<int>(WebInputEvent::GesturePinchUpdate);
+ ASSERT_LT(start_type, end_type);
for (int i = start_type; i <= end_type; ++i) {
WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i);
if (!WebInputEventTraits::IgnoresAckDisposition(type))
@@ -749,6 +750,51 @@ TEST_F(InputRouterImplTest, GestureTypesIgnoringAck) {
}
}
+TEST_F(InputRouterImplTest, MouseTypesIgnoringAck) {
+ int start_type = static_cast<int>(WebInputEvent::MouseDown);
+ int end_type = static_cast<int>(WebInputEvent::ContextMenu);
+ ASSERT_LT(start_type, end_type);
+ for (int i = start_type; i <= end_type; ++i) {
+ WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i);
+ int expected_in_flight_event_count =
+ WebInputEventTraits::IgnoresAckDisposition(type) ? 0 : 1;
+
+ // Note: Mouse event acks are never forwarded to the ack handler, so the key
+ // result here is that ignored ack types don't affect the in-flight count.
+ SimulateMouseEvent(type, 0, 0);
+ EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+ EXPECT_EQ(expected_in_flight_event_count, client_->in_flight_event_count());
+ SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
+ EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
+ EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
+ EXPECT_EQ(0, client_->in_flight_event_count());
+ }
+}
+
+// Guard against breaking changes to the list of ignored event ack types in
+// |WebInputEventTraits::IgnoresAckDisposition|.
+TEST_F(InputRouterImplTest, RequiredEventAckTypes) {
+ const WebInputEvent::Type kRequiredEventAckTypes[] = {
+ WebInputEvent::MouseMove,
+ WebInputEvent::MouseWheel,
+ WebInputEvent::RawKeyDown,
+ WebInputEvent::KeyDown,
+ WebInputEvent::KeyUp,
+ WebInputEvent::Char,
+ WebInputEvent::GestureScrollUpdate,
+ WebInputEvent::GestureFlingStart,
+ WebInputEvent::GestureFlingCancel,
+ WebInputEvent::GesturePinchUpdate,
+ WebInputEvent::TouchStart,
+ WebInputEvent::TouchMove
+ };
+ for (size_t i = 0; i < arraysize(kRequiredEventAckTypes); ++i) {
+ const WebInputEvent::Type required_ack_type = kRequiredEventAckTypes[i];
+ EXPECT_FALSE(WebInputEventTraits::IgnoresAckDisposition(required_ack_type));
+ }
+}
+
// Test that GestureShowPress, GestureTapDown and GestureTapCancel events don't
// wait for ACKs.
TEST_F(InputRouterImplTest, GestureTypesIgnoringAckInterleaved) {
diff --git a/content/common/input/web_input_event_traits.cc b/content/common/input/web_input_event_traits.cc
index 5da4d9a..0dd2e76 100644
--- a/content/common/input/web_input_event_traits.cc
+++ b/content/common/input/web_input_event_traits.cc
@@ -294,6 +294,11 @@ bool WebInputEventTraits::IgnoresAckDisposition(
case WebInputEvent::GestureScrollBegin:
case WebInputEvent::GestureScrollEnd:
case WebInputEvent::TouchCancel:
+ case WebInputEvent::MouseDown:
+ case WebInputEvent::MouseUp:
+ case WebInputEvent::MouseEnter:
+ case WebInputEvent::MouseLeave:
+ case WebInputEvent::ContextMenu:
return true;
default:
break;
diff --git a/content/renderer/input/input_event_filter_unittest.cc b/content/renderer/input/input_event_filter_unittest.cc
index a131ceb..e0762e1 100644
--- a/content/renderer/input/input_event_filter_unittest.cc
+++ b/content/renderer/input/input_event_filter_unittest.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
+#include "content/common/input/synthetic_web_input_event_builders.h"
#include "content/common/input_messages.h"
#include "content/common/view_messages.h"
#include "content/renderer/input/input_event_filter.h"
@@ -96,17 +97,6 @@ class IPCMessageRecorder : public IPC::Listener {
std::vector<IPC::Message> messages_;
};
-void InitMouseEvent(WebMouseEvent* event, WebInputEvent::Type type,
- int x, int y) {
- // Avoid valgrind false positives by initializing memory completely.
- memset(event, 0, sizeof(*event));
-
- new (event) WebMouseEvent();
- event->type = type;
- event->x = x;
- event->y = y;
-}
-
void AddMessagesToFilter(IPC::ChannelProxy::MessageFilter* message_filter,
const std::vector<IPC::Message>& events) {
for (size_t i = 0; i < events.size(); ++i) {
@@ -163,10 +153,11 @@ class InputEventFilterTest : public testing::Test {
};
TEST_F(InputEventFilterTest, Basic) {
- WebMouseEvent kEvents[3];
- InitMouseEvent(&kEvents[0], WebInputEvent::MouseDown, 10, 10);
- InitMouseEvent(&kEvents[1], WebInputEvent::MouseMove, 20, 20);
- InitMouseEvent(&kEvents[2], WebInputEvent::MouseUp, 30, 30);
+ WebMouseEvent kEvents[3] = {
+ SyntheticWebMouseEventBuilder::Build(WebMouseEvent::MouseMove, 10, 10, 0),
+ SyntheticWebMouseEventBuilder::Build(WebMouseEvent::MouseMove, 20, 20, 0),
+ SyntheticWebMouseEventBuilder::Build(WebMouseEvent::MouseMove, 30, 30, 0)
+ };
AddEventsToFilter(filter_.get(), kEvents, arraysize(kEvents));
EXPECT_EQ(0U, ipc_sink_.message_count());
@@ -260,10 +251,10 @@ TEST_F(InputEventFilterTest, PreserveRelativeOrder) {
event_recorder_.set_send_to_widget(true);
- WebMouseEvent mouse_down;
- mouse_down.type = WebMouseEvent::MouseDown;
- WebMouseEvent mouse_up;
- mouse_up.type = WebMouseEvent::MouseUp;
+ WebMouseEvent mouse_down =
+ SyntheticWebMouseEventBuilder::Build(WebMouseEvent::MouseDown);
+ WebMouseEvent mouse_up =
+ SyntheticWebMouseEventBuilder::Build(WebMouseEvent::MouseUp);
std::vector<IPC::Message> messages;
messages.push_back(InputMsg_HandleInputEvent(kTestRoutingID,