diff options
Diffstat (limited to 'chromium/content/common/input')
12 files changed, 73 insertions, 261 deletions
diff --git a/chromium/content/common/input/event_with_latency_info.h b/chromium/content/common/input/event_with_latency_info.h index 7dc0e8113ce..0b97bdd35ad 100644 --- a/chromium/content/common/input/event_with_latency_info.h +++ b/chromium/content/common/input/event_with_latency_info.h @@ -30,9 +30,9 @@ class EventWithLatencyInfo { EventWithLatencyInfo(blink::WebInputEvent::Type type, int modifiers, - double timeStampSeconds, + base::TimeTicks time_stamp, const ui::LatencyInfo& l) - : event(type, modifiers, timeStampSeconds), latency(l) {} + : event(type, modifiers, time_stamp), latency(l) {} EventWithLatencyInfo() {} @@ -54,9 +54,9 @@ class EventWithLatencyInfo { // New events get coalesced into older events, and the newer timestamp // should always be preserved. - const double time_stamp_seconds = other.event.TimeStampSeconds(); + const base::TimeTicks time_stamp = other.event.TimeStamp(); ui::Coalesce(other.event, &event); - event.SetTimeStampSeconds(time_stamp_seconds); + event.SetTimeStamp(time_stamp); // When coalescing two input events, we keep the oldest LatencyInfo // for Telemetry latency tests, since it will represent the longest diff --git a/chromium/content/common/input/event_with_latency_info_unittest.cc b/chromium/content/common/input/event_with_latency_info_unittest.cc index 640e42e71fd..2c135593a3e 100644 --- a/chromium/content/common/input/event_with_latency_info_unittest.cc +++ b/chromium/content/common/input/event_with_latency_info_unittest.cc @@ -25,16 +25,20 @@ using EventWithLatencyInfoTest = testing::Test; TouchEventWithLatencyInfo CreateTouchEvent(WebInputEvent::Type type, double timestamp, unsigned touch_count = 1) { - TouchEventWithLatencyInfo touch(type, WebInputEvent::kNoModifiers, timestamp, - ui::LatencyInfo()); + TouchEventWithLatencyInfo touch( + type, WebInputEvent::kNoModifiers, + base::TimeTicks() + base::TimeDelta::FromSecondsD(timestamp), + ui::LatencyInfo()); touch.event.touches_length = touch_count; return touch; } MouseEventWithLatencyInfo CreateMouseEvent(WebInputEvent::Type type, double timestamp) { - return MouseEventWithLatencyInfo(type, WebInputEvent::kNoModifiers, timestamp, - ui::LatencyInfo()); + return MouseEventWithLatencyInfo( + type, WebInputEvent::kNoModifiers, + base::TimeTicks() + base::TimeDelta::FromSecondsD(timestamp), + ui::LatencyInfo()); } MouseWheelEventWithLatencyInfo CreateMouseWheelEvent( @@ -43,7 +47,9 @@ MouseWheelEventWithLatencyInfo CreateMouseWheelEvent( float deltaY = 0.0f, int modifiers = WebInputEvent::kNoModifiers) { MouseWheelEventWithLatencyInfo mouse_wheel( - WebInputEvent::kMouseWheel, modifiers, timestamp, ui::LatencyInfo()); + WebInputEvent::kMouseWheel, modifiers, + base::TimeTicks() + base::TimeDelta::FromSecondsD(timestamp), + ui::LatencyInfo()); mouse_wheel.event.delta_x = deltaX; mouse_wheel.event.delta_y = deltaY; return mouse_wheel; @@ -53,8 +59,10 @@ GestureEventWithLatencyInfo CreateGestureEvent(WebInputEvent::Type type, double timestamp, float x = 0.0f, float y = 0.0f) { - GestureEventWithLatencyInfo gesture(type, WebInputEvent::kNoModifiers, - timestamp, ui::LatencyInfo()); + GestureEventWithLatencyInfo gesture( + type, WebInputEvent::kNoModifiers, + base::TimeTicks() + base::TimeDelta::FromSecondsD(timestamp), + ui::LatencyInfo()); gesture.event.SetPositionInWidget(gfx::PointF(x, y)); return gesture; } @@ -68,7 +76,7 @@ TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForMouseEvent) { ASSERT_TRUE(mouse_0.CanCoalesceWith(mouse_1)); mouse_0.CoalesceWith(mouse_1); // Coalescing WebMouseEvent preserves newer timestamp. - EXPECT_EQ(10.0, mouse_0.event.TimeStampSeconds()); + EXPECT_EQ(10.0, mouse_0.event.TimeStamp().since_origin().InSecondsF()); } TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForMouseWheelEvent) { @@ -78,7 +86,7 @@ TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForMouseWheelEvent) { ASSERT_TRUE(mouse_wheel_0.CanCoalesceWith(mouse_wheel_1)); mouse_wheel_0.CoalesceWith(mouse_wheel_1); // Coalescing WebMouseWheelEvent preserves newer timestamp. - EXPECT_EQ(10.0, mouse_wheel_0.event.TimeStampSeconds()); + EXPECT_EQ(10.0, mouse_wheel_0.event.TimeStamp().since_origin().InSecondsF()); } TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForTouchEvent) { @@ -90,7 +98,7 @@ TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForTouchEvent) { ASSERT_TRUE(touch_0.CanCoalesceWith(touch_1)); touch_0.CoalesceWith(touch_1); // Coalescing WebTouchEvent preserves newer timestamp. - EXPECT_EQ(10.0, touch_0.event.TimeStampSeconds()); + EXPECT_EQ(10.0, touch_0.event.TimeStamp().since_origin().InSecondsF()); } TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForGestureEvent) { @@ -102,14 +110,14 @@ TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForGestureEvent) { ASSERT_TRUE(scroll_0.CanCoalesceWith(scroll_1)); scroll_0.CoalesceWith(scroll_1); // Coalescing WebGestureEvent preserves newer timestamp. - EXPECT_EQ(10.0, scroll_0.event.TimeStampSeconds()); + EXPECT_EQ(10.0, scroll_0.event.TimeStamp().since_origin().InSecondsF()); } TEST_F(EventWithLatencyInfoTest, LatencyInfoCoalescing) { MouseEventWithLatencyInfo mouse_0 = CreateMouseEvent(WebInputEvent::kMouseMove, 5.0); mouse_0.latency.AddLatencyNumberWithTimestamp( - ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, base::TimeTicks(), 1); + ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, base::TimeTicks(), 1); MouseEventWithLatencyInfo mouse_1 = CreateMouseEvent(WebInputEvent::kMouseMove, 10.0); @@ -360,7 +368,7 @@ TEST_F(EventWithLatencyInfoTest, TimestampCoalescing) { EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); Coalesce(mouse_wheel_1, &mouse_wheel_0); - EXPECT_EQ(10.0, mouse_wheel_0.event.TimeStampSeconds()); + EXPECT_EQ(10.0, mouse_wheel_0.event.TimeStamp().since_origin().InSecondsF()); } } // namespace diff --git a/chromium/content/common/input/input_event_struct_traits.cc b/chromium/content/common/input/input_event_struct_traits.cc index c1e18caff8c..afa97f2064f 100644 --- a/chromium/content/common/input/input_event_struct_traits.cc +++ b/chromium/content/common/input/input_event_struct_traits.cc @@ -6,6 +6,7 @@ #include "base/i18n/char_iterator.h" #include "content/common/input_messages.h" +#include "mojo/public/cpp/base/time_mojom_traits.h" #include "third_party/blink/public/platform/web_keyboard_event.h" #include "ui/latency/mojo/latency_info_struct_traits.h" @@ -88,13 +89,17 @@ bool StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::Read( if (!event.ReadType(&type)) return false; + base::TimeTicks timestamp; + if (!event.ReadTimestamp(×tamp)) + return false; + if (blink::WebInputEvent::IsKeyboardEventType(type)) { content::mojom::KeyDataPtr key_data; if (!event.ReadKeyData<content::mojom::KeyDataPtr>(&key_data)) return false; - (*out)->web_event.reset(new blink::WebKeyboardEvent( - type, event.modifiers(), event.timestamp_seconds())); + (*out)->web_event.reset( + new blink::WebKeyboardEvent(type, event.modifiers(), timestamp)); blink::WebKeyboardEvent* key_event = static_cast<blink::WebKeyboardEvent*>((*out)->web_event.get()); @@ -111,8 +116,7 @@ bool StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::Read( if (!event.ReadGestureData<content::mojom::GestureDataPtr>(&gesture_data)) return false; (*out)->web_event.reset(new blink::WebGestureEvent( - type, event.modifiers(), event.timestamp_seconds(), - gesture_data->source_device)); + type, event.modifiers(), timestamp, gesture_data->source_device)); blink::WebGestureEvent* gesture_event = static_cast<blink::WebGestureEvent*>((*out)->web_event.get()); @@ -258,8 +262,8 @@ bool StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::Read( if (!event.ReadTouchData<content::mojom::TouchDataPtr>(&touch_data)) return false; - (*out)->web_event.reset(new blink::WebTouchEvent( - type, event.modifiers(), event.timestamp_seconds())); + (*out)->web_event.reset( + new blink::WebTouchEvent(type, event.modifiers(), timestamp)); blink::WebTouchEvent* touch_event = static_cast<blink::WebTouchEvent*>((*out)->web_event.get()); @@ -287,11 +291,11 @@ bool StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::Read( return false; if (blink::WebInputEvent::IsMouseEventType(type)) { - (*out)->web_event.reset(new blink::WebMouseEvent( - type, event.modifiers(), event.timestamp_seconds())); + (*out)->web_event.reset( + new blink::WebMouseEvent(type, event.modifiers(), timestamp)); } else { - (*out)->web_event.reset(new blink::WebMouseWheelEvent( - type, event.modifiers(), event.timestamp_seconds())); + (*out)->web_event.reset( + new blink::WebMouseWheelEvent(type, event.modifiers(), timestamp)); } blink::WebMouseEvent* mouse_event = diff --git a/chromium/content/common/input/input_event_struct_traits.h b/chromium/content/common/input/input_event_struct_traits.h index d63ca68bea7..ca8ea062713 100644 --- a/chromium/content/common/input/input_event_struct_traits.h +++ b/chromium/content/common/input/input_event_struct_traits.h @@ -25,8 +25,8 @@ struct StructTraits<content::mojom::EventDataView, InputEventUniquePtr> { return event->web_event->GetModifiers(); } - static double timestamp_seconds(const InputEventUniquePtr& event) { - return event->web_event->TimeStampSeconds(); + static base::TimeTicks timestamp(const InputEventUniquePtr& event) { + return event->web_event->TimeStamp(); } static const ui::LatencyInfo& latency(const InputEventUniquePtr& event) { diff --git a/chromium/content/common/input/input_handler.mojom b/chromium/content/common/input/input_handler.mojom index b5725e1dbf9..9f8a63e8b72 100644 --- a/chromium/content/common/input/input_handler.mojom +++ b/chromium/content/common/input/input_handler.mojom @@ -7,6 +7,7 @@ module content.mojom; import "content/common/input/synchronous_compositor.mojom"; import "content/common/native_types.mojom"; import "mojo/public/mojom/base/string16.mojom"; +import "mojo/public/mojom/base/time.mojom"; import "services/ui/public/interfaces/ime/ime.mojom"; import "third_party/blink/public/web/selection_menu_behavior.mojom"; import "ui/events/mojo/event.mojom"; @@ -139,7 +140,7 @@ struct TouchData { struct Event { EventType type; int32 modifiers; - double timestamp_seconds; + mojo_base.mojom.TimeTicks timestamp; ui.mojom.LatencyInfo latency; KeyData? key_data; PointerData? pointer_data; @@ -187,6 +188,13 @@ interface WidgetInputHandlerHost { // to always have correct bound info. ImeCompositionRangeChanged(gfx.mojom.Range range, array<gfx.mojom.Rect> bounds); + + // Updates the mouse capture state of this widget. While capture is enabled, + // all mouse events, including those that don't hittest to this widget, will + // be targeted to this widget. This enables Blink to behave correctly when + // a scrollbar is being dragged, or text is being drag-highlighted, even + // when the mouse passes across different RenderWidget areas. + SetMouseCapture(bool capture); }; // Interface exposed by the renderer to the browser. This class represents @@ -234,7 +242,7 @@ interface WidgetInputHandler { RequestTextInputStateUpdate(); // Request from browser to update the cursor and composition information which - // will be sent through InputHostMsg_ImeCompositionRangeChanged. Setting + // will be sent through ImeCompositionRangeChanged. Setting // |immediate_request| to true will lead to an immediate update. If // |monitor_updates| is set to true then changes to text selection or regular // updates in each compositor frame (when there is a change in composition diff --git a/chromium/content/common/input/input_param_traits_unittest.cc b/chromium/content/common/input/input_param_traits_unittest.cc deleted file mode 100644 index 81d1d69cd85..00000000000 --- a/chromium/content/common/input/input_param_traits_unittest.cc +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/common/input/input_param_traits.h" - -#include <stddef.h> - -#include <memory> -#include <utility> -#include <vector> - -#include "content/common/input/input_event.h" -#include "content/common/input_messages.h" -#include "ipc/ipc_message.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/blink/public/platform/web_gesture_event.h" -#include "third_party/blink/public/platform/web_input_event.h" -#include "third_party/blink/public/platform/web_keyboard_event.h" -#include "third_party/blink/public/platform/web_mouse_wheel_event.h" -#include "third_party/blink/public/platform/web_touch_event.h" - -namespace content { -namespace { - -typedef std::vector<std::unique_ptr<InputEvent>> InputEvents; - -class InputParamTraitsTest : public testing::Test { - protected: - static void Compare(const InputEvent* a, const InputEvent* b) { - EXPECT_EQ(!!a->web_event, !!b->web_event); - if (a->web_event && b->web_event) { - const size_t a_size = a->web_event->size(); - ASSERT_EQ(a_size, b->web_event->size()); - EXPECT_EQ(0, memcmp(a->web_event.get(), b->web_event.get(), a_size)); - } - EXPECT_EQ(a->latency_info.latency_components().size(), - b->latency_info.latency_components().size()); - } - - static void Compare(const InputEvents* a, const InputEvents* b) { - for (size_t i = 0; i < a->size(); ++i) - Compare((*a)[i].get(), (*b)[i].get()); - } - - static void Verify(const InputEvents& events_in) { - IPC::Message msg; - IPC::ParamTraits<InputEvents>::Write(&msg, events_in); - - InputEvents events_out; - base::PickleIterator iter(msg); - EXPECT_TRUE(IPC::ParamTraits<InputEvents>::Read(&msg, &iter, &events_out)); - - Compare(&events_in, &events_out); - - // Perform a sanity check that logging doesn't explode. - std::string events_in_string; - IPC::ParamTraits<InputEvents>::Log(events_in, &events_in_string); - std::string events_out_string; - IPC::ParamTraits<InputEvents>::Log(events_out, &events_out_string); - ASSERT_FALSE(events_in_string.empty()); - EXPECT_EQ(events_in_string, events_out_string); - } -}; - -TEST_F(InputParamTraitsTest, UninitializedEvents) { - InputEvent event; - - IPC::Message msg; - IPC::WriteParam(&msg, event); - - InputEvent event_out; - base::PickleIterator iter(msg); - EXPECT_FALSE(IPC::ReadParam(&msg, &iter, &event_out)); -} - -TEST_F(InputParamTraitsTest, InitializedEvents) { - InputEvents events; - - ui::LatencyInfo latency; - latency.set_trace_id(5); - - blink::WebKeyboardEvent key_event( - blink::WebInputEvent::kRawKeyDown, blink::WebInputEvent::kNoModifiers, - blink::WebInputEvent::GetStaticTimeStampForTests()); - key_event.native_key_code = 5; - events.push_back(std::make_unique<InputEvent>(key_event, latency)); - - blink::WebMouseWheelEvent wheel_event( - blink::WebInputEvent::kMouseWheel, blink::WebInputEvent::kNoModifiers, - blink::WebInputEvent::GetStaticTimeStampForTests()); - wheel_event.delta_x = 10; - latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1, 1); - events.push_back(std::make_unique<InputEvent>(wheel_event, latency)); - - blink::WebMouseEvent mouse_event( - blink::WebInputEvent::kMouseDown, blink::WebInputEvent::kNoModifiers, - blink::WebInputEvent::GetStaticTimeStampForTests()); - mouse_event.SetPositionInWidget(10, 0); - latency.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 2, 2); - events.push_back(std::make_unique<InputEvent>(mouse_event, latency)); - - blink::WebGestureEvent gesture_event( - blink::WebInputEvent::kGestureScrollBegin, - blink::WebInputEvent::kNoModifiers, - blink::WebInputEvent::GetStaticTimeStampForTests()); - gesture_event.SetPositionInWidget(gfx::PointF(-1, 0)); - events.push_back(std::make_unique<InputEvent>(gesture_event, latency)); - - blink::WebTouchEvent touch_event( - blink::WebInputEvent::kTouchStart, blink::WebInputEvent::kNoModifiers, - blink::WebInputEvent::GetStaticTimeStampForTests()); - touch_event.touches_length = 1; - touch_event.touches[0].radius_x = 1; - events.push_back(std::make_unique<InputEvent>(touch_event, latency)); - - Verify(events); -} - -} // namespace -} // namespace content diff --git a/chromium/content/common/input/sync_compositor_messages.h b/chromium/content/common/input/sync_compositor_messages.h index fcfd89e58d0..a608f7eb160 100644 --- a/chromium/content/common/input/sync_compositor_messages.h +++ b/chromium/content/common/input/sync_compositor_messages.h @@ -8,14 +8,9 @@ #include <stddef.h> #include "base/memory/shared_memory_handle.h" -#include "base/optional.h" -#include "components/viz/common/frame_sinks/begin_frame_args.h" -#include "components/viz/common/quads/compositor_frame.h" #include "content/common/content_export.h" #include "content/common/content_param_traits.h" -#include "content/public/common/input_event_ack_state.h" #include "ipc/ipc_message_macros.h" -#include "third_party/blink/public/platform/web_input_event.h" #include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/scroll_offset.h" @@ -80,10 +75,6 @@ struct SyncCompositorCommonRendererParams { #endif // INTERNAL_CONTENT_COMMON_SYNC_COMPOSITOR_MESSAGES_H_ -#undef IPC_MESSAGE_EXPORT -#define IPC_MESSAGE_EXPORT CONTENT_EXPORT -#define IPC_MESSAGE_START SyncCompositorMsgStart - IPC_STRUCT_TRAITS_BEGIN(content::SyncCompositorDemandDrawHwParams) IPC_STRUCT_TRAITS_MEMBER(viewport_size) IPC_STRUCT_TRAITS_MEMBER(viewport_rect_for_tile_priority) @@ -114,77 +105,4 @@ IPC_STRUCT_TRAITS_BEGIN(content::SyncCompositorCommonRendererParams) IPC_STRUCT_TRAITS_MEMBER(did_activate_pending_tree_count) IPC_STRUCT_TRAITS_END() -// Messages sent from the browser to the renderer. -// Synchronous IPCs are allowed here to the renderer compositor thread. See -// design doc https://goo.gl/Tn81FW and https://crbug.com/526842 for details. - -IPC_MESSAGE_ROUTED1(SyncCompositorMsg_ComputeScroll, base::TimeTicks) - -IPC_MESSAGE_ROUTED1(SyncCompositorMsg_DemandDrawHwAsync, - content::SyncCompositorDemandDrawHwParams) - -IPC_SYNC_MESSAGE_ROUTED1_4(SyncCompositorMsg_DemandDrawHw, - content::SyncCompositorDemandDrawHwParams, - content::SyncCompositorCommonRendererParams, - uint32_t /* layer_tree_frame_sink_id */, - uint32_t /* metadata_version */, - base::Optional<viz::CompositorFrame>) - -IPC_SYNC_MESSAGE_ROUTED1_2(SyncCompositorMsg_SetSharedMemory, - content::SyncCompositorSetSharedMemoryParams, - bool /* success */, - content::SyncCompositorCommonRendererParams) - -IPC_MESSAGE_ROUTED0(SyncCompositorMsg_ZeroSharedMemory) - -IPC_SYNC_MESSAGE_ROUTED1_3(SyncCompositorMsg_DemandDrawSw, - content::SyncCompositorDemandDrawSwParams, - content::SyncCompositorCommonRendererParams, - uint32_t /* metadata_version */, - base::Optional<viz::CompositorFrameMetadata>) - -IPC_SYNC_MESSAGE_ROUTED2_1(SyncCompositorMsg_ZoomBy, - float /* delta */, - gfx::Point /* anchor */, - content::SyncCompositorCommonRendererParams) - -IPC_MESSAGE_ROUTED1(SyncCompositorMsg_SetMemoryPolicy, - uint32_t /* bytes_limit */) - -IPC_MESSAGE_ROUTED2(SyncCompositorMsg_ReclaimResources, - uint32_t /* layer_tree_frame_sink_id */, - std::vector<viz::ReturnedResource> /* resources */) - -IPC_MESSAGE_ROUTED1(SyncCompositorMsg_SetScroll, gfx::ScrollOffset) - -// Let renderer know begin frame messages won't be sent even if requested. -IPC_MESSAGE_ROUTED1(SyncCompositorMsg_SetBeginFramePaused, bool /* paused */) - -// Sent by the browser when the renderer should generate a new frame. -IPC_MESSAGE_ROUTED1(SyncCompositorMsg_BeginFrame, - viz::BeginFrameArgs /* args */) - -// ----------------------------------------------------------------------------- -// Messages sent from the renderer to the browser. - -IPC_MESSAGE_ROUTED0(SyncCompositorHostMsg_LayerTreeFrameSinkCreated) - -IPC_MESSAGE_ROUTED1(SyncCompositorHostMsg_UpdateState, - content::SyncCompositorCommonRendererParams) - -// Response to a begin frame request. -IPC_MESSAGE_ROUTED1(SyncCompositorHostMsg_BeginFrameResponse, - content::SyncCompositorCommonRendererParams) - -IPC_MESSAGE_ROUTED3(SyncCompositorHostMsg_ReturnFrame, - uint32_t /* layer_tree_frame_sink_id */, - uint32_t /* metadata_version */, - base::Optional<viz::CompositorFrame>) - -// Sent by renderer to request a SyncCompositorMsg_BeginFrame message for -// upcoming display events. If |enabled| is true, the BeginFrame message will -// continue to be be delivered until the notification is disabled. -IPC_MESSAGE_ROUTED1(SyncCompositorHostMsg_SetNeedsBeginFrames, - bool /* enabled */) - #endif // CONTENT_COMMON_SYNC_COMPOSITOR_MESSAGES_H_ diff --git a/chromium/content/common/input/synchronous_compositor.typemap b/chromium/content/common/input/synchronous_compositor.typemap index 6adbf1659d1..cb07fb33228 100644 --- a/chromium/content/common/input/synchronous_compositor.typemap +++ b/chromium/content/common/input/synchronous_compositor.typemap @@ -6,7 +6,6 @@ mojom = "//content/common/input/synchronous_compositor.mojom" public_headers = [ "//content/common/input/sync_compositor_messages.h" ] traits_headers = [ "//content/common/input/sync_compositor_messages.h" ] deps = [ - "//cc/ipc", "//ui/gfx/ipc", ] type_mappings = [ diff --git a/chromium/content/common/input/synthetic_web_input_event_builders.cc b/chromium/content/common/input/synthetic_web_input_event_builders.cc index 617d0ea12b5..5cf6591d784 100644 --- a/chromium/content/common/input/synthetic_web_input_event_builders.cc +++ b/chromium/content/common/input/synthetic_web_input_event_builders.cc @@ -23,7 +23,7 @@ using blink::WebTouchPoint; WebMouseEvent SyntheticWebMouseEventBuilder::Build( blink::WebInputEvent::Type type) { return WebMouseEvent(type, WebInputEvent::kNoModifiers, - ui::EventTimeStampToSeconds(ui::EventTimeForNow())); + ui::EventTimeForNow()); } WebMouseEvent SyntheticWebMouseEventBuilder::Build( @@ -33,9 +33,9 @@ WebMouseEvent SyntheticWebMouseEventBuilder::Build( int modifiers, blink::WebPointerProperties::PointerType pointer_type) { DCHECK(WebInputEvent::IsMouseEventType(type)); - WebMouseEvent result(type, modifiers, - ui::EventTimeStampToSeconds(ui::EventTimeForNow())); + WebMouseEvent result(type, modifiers, ui::EventTimeForNow()); result.SetPositionInWidget(window_x, window_y); + result.SetPositionInScreen(window_x, window_y); result.SetModifiers(modifiers); result.pointer_type = pointer_type; result.id = ui::MouseEvent::kMousePointerId; @@ -45,8 +45,7 @@ WebMouseEvent SyntheticWebMouseEventBuilder::Build( WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build( WebMouseWheelEvent::Phase phase) { WebMouseWheelEvent result(WebInputEvent::kMouseWheel, - WebInputEvent::kNoModifiers, - ui::EventTimeStampToSeconds(ui::EventTimeForNow())); + WebInputEvent::kNoModifiers, ui::EventTimeForNow()); result.phase = phase; return result; } @@ -69,7 +68,7 @@ WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build(float x, int modifiers, bool precise) { WebMouseWheelEvent result(WebInputEvent::kMouseWheel, modifiers, - ui::EventTimeStampToSeconds(ui::EventTimeForNow())); + ui::EventTimeForNow()); result.SetPositionInScreen(global_x, global_y); result.SetPositionInWidget(x, y); result.delta_x = dx; @@ -86,7 +85,7 @@ WebKeyboardEvent SyntheticWebKeyboardEventBuilder::Build( WebInputEvent::Type type) { DCHECK(WebInputEvent::IsKeyboardEventType(type)); WebKeyboardEvent result(type, WebInputEvent::kNoModifiers, - ui::EventTimeStampToSeconds(ui::EventTimeForNow())); + ui::EventTimeForNow()); result.windows_key_code = ui::VKEY_L; // non-null made up value. return result; } @@ -96,9 +95,7 @@ WebGestureEvent SyntheticWebGestureEventBuilder::Build( blink::WebGestureDevice source_device, int modifiers) { DCHECK(WebInputEvent::IsGestureEventType(type)); - WebGestureEvent result(type, modifiers, - ui::EventTimeStampToSeconds(ui::EventTimeForNow()), - source_device); + WebGestureEvent result(type, modifiers, ui::EventTimeForNow(), source_device); if (type == WebInputEvent::kGestureTap || type == WebInputEvent::kGestureTapUnconfirmed || type == WebInputEvent::kGestureDoubleTap) { @@ -202,9 +199,9 @@ int SyntheticWebTouchEvent::PressPoint(float x, float y) { point.rotation_angle = 1.f; point.force = 1.f; point.tilt_x = point.tilt_y = 0; + point.pointer_type = blink::WebPointerProperties::PointerType::kTouch; ++touches_length; - WebTouchEventTraits::ResetType(WebInputEvent::kTouchStart, TimeStampSeconds(), - this); + WebTouchEventTraits::ResetType(WebInputEvent::kTouchStart, TimeStamp(), this); return point.id; } @@ -218,8 +215,7 @@ void SyntheticWebTouchEvent::MovePoint(int index, float x, float y) { point.SetPositionInWidget(x, y); point.SetPositionInScreen(x, y); touches[index].state = WebTouchPoint::kStateMoved; - WebTouchEventTraits::ResetType(WebInputEvent::kTouchMove, TimeStampSeconds(), - this); + WebTouchEventTraits::ResetType(WebInputEvent::kTouchMove, TimeStamp(), this); } void SyntheticWebTouchEvent::ReleasePoint(int index) { @@ -227,20 +223,19 @@ void SyntheticWebTouchEvent::ReleasePoint(int index) { CHECK_LT(index, kTouchesLengthCap); touches[index].state = WebTouchPoint::kStateReleased; touches[index].force = 0.f; - WebTouchEventTraits::ResetType(WebInputEvent::kTouchEnd, TimeStampSeconds(), - this); + WebTouchEventTraits::ResetType(WebInputEvent::kTouchEnd, TimeStamp(), this); } void SyntheticWebTouchEvent::CancelPoint(int index) { CHECK_GE(index, 0); CHECK_LT(index, kTouchesLengthCap); touches[index].state = WebTouchPoint::kStateCancelled; - WebTouchEventTraits::ResetType(WebInputEvent::kTouchCancel, - TimeStampSeconds(), this); + WebTouchEventTraits::ResetType(WebInputEvent::kTouchCancel, TimeStamp(), + this); } void SyntheticWebTouchEvent::SetTimestamp(base::TimeTicks timestamp) { - SetTimeStampSeconds(ui::EventTimeStampToSeconds(timestamp)); + SetTimeStamp(timestamp); } int SyntheticWebTouchEvent::FirstFreeIndex() { diff --git a/chromium/content/common/input/touch_action_optional_struct_traits.cc b/chromium/content/common/input/touch_action_optional_struct_traits.cc index b2b4c33e638..3b57659bb1d 100644 --- a/chromium/content/common/input/touch_action_optional_struct_traits.cc +++ b/chromium/content/common/input/touch_action_optional_struct_traits.cc @@ -4,7 +4,7 @@ #include "content/common/input/touch_action_optional_struct_traits.h" -#include "content/common/input_messages.h" +#include "content/public/common/common_param_traits_macros.h" namespace mojo { bool StructTraits< diff --git a/chromium/content/common/input/web_touch_event_traits.cc b/chromium/content/common/input/web_touch_event_traits.cc index 897d78e5b58..06972d03654 100644 --- a/chromium/content/common/input/web_touch_event_traits.cc +++ b/chromium/content/common/input/web_touch_event_traits.cc @@ -50,7 +50,7 @@ bool WebTouchEventTraits::IsTouchSequenceEnd(const WebTouchEvent& event) { } void WebTouchEventTraits::ResetType(WebInputEvent::Type type, - double timestamp_sec, + base::TimeTicks timestamp, WebTouchEvent* event) { DCHECK(WebInputEvent::IsTouchEventType(type)); DCHECK(type != WebInputEvent::kTouchScrollStarted); @@ -59,13 +59,13 @@ void WebTouchEventTraits::ResetType(WebInputEvent::Type type, event->dispatch_type = type == WebInputEvent::kTouchCancel ? WebInputEvent::kEventNonBlocking : WebInputEvent::kBlocking; - event->SetTimeStampSeconds(timestamp_sec); + event->SetTimeStamp(timestamp); } void WebTouchEventTraits::ResetTypeAndTouchStates(WebInputEvent::Type type, - double timestamp_sec, + base::TimeTicks timestamp, WebTouchEvent* event) { - ResetType(type, timestamp_sec, event); + ResetType(type, timestamp, event); WebTouchPoint::State newState = WebTouchPoint::kStateUndefined; switch (event->GetType()) { diff --git a/chromium/content/common/input/web_touch_event_traits.h b/chromium/content/common/input/web_touch_event_traits.h index eac4718d4ff..ff27930e937 100644 --- a/chromium/content/common/input/web_touch_event_traits.h +++ b/chromium/content/common/input/web_touch_event_traits.h @@ -5,6 +5,7 @@ #ifndef CONTENT_COMMON_INPUT_WEB_TOUCH_EVENT_TRAITS_H_ #define CONTENT_COMMON_INPUT_WEB_TOUCH_EVENT_TRAITS_H_ +#include "base/time/time.h" #include "content/common/content_export.h" #include "third_party/blink/public/platform/web_input_event.h" @@ -32,14 +33,14 @@ class CONTENT_EXPORT WebTouchEventTraits { // Sets the type of |event| to |type|, resetting any other type-specific // properties and updating the timestamp. static void ResetType(blink::WebInputEvent::Type type, - double timestamp_sec, + base::TimeTicks timestamp, blink::WebTouchEvent* event); // Like ResetType but also resets the state of all active touches // to match the event type. This is particularly useful, for example, // in sending a touchcancel for all active touches. static void ResetTypeAndTouchStates(blink::WebInputEvent::Type type, - double timestamp_sec, + base::TimeTicks timestamp, blink::WebTouchEvent* event); }; |