diff options
Diffstat (limited to 'chromium/content/common/input')
17 files changed, 12 insertions, 1947 deletions
diff --git a/chromium/content/common/input/event_with_latency_info.h b/chromium/content/common/input/event_with_latency_info.h index c90359968a6..edb31dbb8d1 100644 --- a/chromium/content/common/input/event_with_latency_info.h +++ b/chromium/content/common/input/event_with_latency_info.h @@ -5,8 +5,8 @@ #ifndef CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_ #define CONTENT_COMMON_INPUT_EVENT_WITH_LATENCY_INFO_H_ +#include "base/check_op.h" #include "base/compiler_specific.h" -#include "base/logging.h" #include "content/common/content_export.h" #include "third_party/blink/public/common/input/web_gesture_event.h" #include "third_party/blink/public/common/input/web_mouse_wheel_event.h" diff --git a/chromium/content/common/input/gesture_event_stream_validator_unittest.cc b/chromium/content/common/input/gesture_event_stream_validator_unittest.cc index 46c00da677a..238b31f7cd9 100644 --- a/chromium/content/common/input/gesture_event_stream_validator_unittest.cc +++ b/chromium/content/common/input/gesture_event_stream_validator_unittest.cc @@ -4,8 +4,8 @@ #include "content/common/input/gesture_event_stream_validator.h" -#include "content/common/input/synthetic_web_input_event_builders.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/public/common/input/synthetic_web_input_event_builders.h" using blink::WebInputEvent; using blink::WebGestureEvent; @@ -17,8 +17,8 @@ const blink::WebGestureDevice kDefaultGestureDevice = blink::WebGestureDevice::kTouchscreen; blink::WebGestureEvent Build(WebInputEvent::Type type) { - blink::WebGestureEvent event = - SyntheticWebGestureEventBuilder::Build(type, kDefaultGestureDevice); + blink::WebGestureEvent event = blink::SyntheticWebGestureEventBuilder::Build( + type, kDefaultGestureDevice); // Default to providing a (valid) non-zero fling velocity. if (type == WebInputEvent::Type::kGestureFlingStart) event.data.fling_start.velocity_x = 5; diff --git a/chromium/content/common/input/ime_text_span_conversions.cc b/chromium/content/common/input/ime_text_span_conversions.cc deleted file mode 100644 index e8ed1b511ad..00000000000 --- a/chromium/content/common/input/ime_text_span_conversions.cc +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright 2017 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/ime_text_span_conversions.h" - -#include "base/notreached.h" - -namespace content { - -blink::WebImeTextSpan::Type ConvertUiImeTextSpanTypeToWebType( - ui::ImeTextSpan::Type type) { - switch (type) { - case ui::ImeTextSpan::Type::kComposition: - return blink::WebImeTextSpan::Type::kComposition; - case ui::ImeTextSpan::Type::kSuggestion: - return blink::WebImeTextSpan::Type::kSuggestion; - case ui::ImeTextSpan::Type::kMisspellingSuggestion: - return blink::WebImeTextSpan::Type::kMisspellingSuggestion; - } - - NOTREACHED(); - return blink::WebImeTextSpan::Type::kComposition; -} - -ui::ImeTextSpan::Type ConvertWebImeTextSpanTypeToUiType( - blink::WebImeTextSpan::Type type) { - switch (type) { - case blink::WebImeTextSpan::Type::kComposition: - return ui::ImeTextSpan::Type::kComposition; - case blink::WebImeTextSpan::Type::kSuggestion: - return ui::ImeTextSpan::Type::kSuggestion; - case blink::WebImeTextSpan::Type::kMisspellingSuggestion: - return ui::ImeTextSpan::Type::kMisspellingSuggestion; - } - - NOTREACHED(); - return ui::ImeTextSpan::Type::kComposition; -} - -ui::mojom::ImeTextSpanThickness ConvertUiThicknessToUiImeTextSpanThickness( - ui::ImeTextSpan::Thickness thickness) { - switch (thickness) { - case ui::ImeTextSpan::Thickness::kNone: - return ui::mojom::ImeTextSpanThickness::kNone; - case ui::ImeTextSpan::Thickness::kThin: - return ui::mojom::ImeTextSpanThickness::kThin; - case ui::ImeTextSpan::Thickness::kThick: - return ui::mojom::ImeTextSpanThickness::kThick; - } - - NOTREACHED(); - return ui::mojom::ImeTextSpanThickness::kThin; -} - -ui::ImeTextSpan::Thickness ConvertUiImeTextSpanThicknessToUiThickness( - ui::mojom::ImeTextSpanThickness thickness) { - switch (thickness) { - case ui::mojom::ImeTextSpanThickness::kNone: - return ui::ImeTextSpan::Thickness::kNone; - case ui::mojom::ImeTextSpanThickness::kThin: - return ui::ImeTextSpan::Thickness::kThin; - case ui::mojom::ImeTextSpanThickness::kThick: - return ui::ImeTextSpan::Thickness::kThick; - } - - NOTREACHED(); - return ui::ImeTextSpan::Thickness::kThin; -} - -ui::mojom::ImeTextSpanUnderlineStyle -ConvertUiUnderlineStyleToUiImeTextSpanUnderlineStyle( - ui::ImeTextSpan::UnderlineStyle underline_style) { - switch (underline_style) { - case ui::ImeTextSpan::UnderlineStyle::kNone: - return ui::mojom::ImeTextSpanUnderlineStyle::kNone; - case ui::ImeTextSpan::UnderlineStyle::kSolid: - return ui::mojom::ImeTextSpanUnderlineStyle::kSolid; - case ui::ImeTextSpan::UnderlineStyle::kDot: - return ui::mojom::ImeTextSpanUnderlineStyle::kDot; - case ui::ImeTextSpan::UnderlineStyle::kDash: - return ui::mojom::ImeTextSpanUnderlineStyle::kDash; - case ui::ImeTextSpan::UnderlineStyle::kSquiggle: - return ui::mojom::ImeTextSpanUnderlineStyle::kSquiggle; - } - - NOTREACHED(); - return ui::mojom::ImeTextSpanUnderlineStyle::kSolid; -} - -ui::ImeTextSpan::UnderlineStyle -ConvertUiImeTextSpanUnderlineStyleToUiUnderlineStyle( - ui::mojom::ImeTextSpanUnderlineStyle underline_style) { - switch (underline_style) { - case ui::mojom::ImeTextSpanUnderlineStyle::kNone: - return ui::ImeTextSpan::UnderlineStyle::kNone; - case ui::mojom::ImeTextSpanUnderlineStyle::kSolid: - return ui::ImeTextSpan::UnderlineStyle::kSolid; - case ui::mojom::ImeTextSpanUnderlineStyle::kDot: - return ui::ImeTextSpan::UnderlineStyle::kDot; - case ui::mojom::ImeTextSpanUnderlineStyle::kDash: - return ui::ImeTextSpan::UnderlineStyle::kDash; - case ui::mojom::ImeTextSpanUnderlineStyle::kSquiggle: - return ui::ImeTextSpan::UnderlineStyle::kSquiggle; - } - - NOTREACHED(); - return ui::ImeTextSpan::UnderlineStyle::kSolid; -} - -blink::WebImeTextSpan ConvertUiImeTextSpanToBlinkImeTextSpan( - const ui::ImeTextSpan& ui_ime_text_span) { - blink::WebImeTextSpan blink_ime_text_span = blink::WebImeTextSpan( - ConvertUiImeTextSpanTypeToWebType(ui_ime_text_span.type), - ui_ime_text_span.start_offset, ui_ime_text_span.end_offset, - ConvertUiThicknessToUiImeTextSpanThickness(ui_ime_text_span.thickness), - ConvertUiUnderlineStyleToUiImeTextSpanUnderlineStyle( - ui_ime_text_span.underline_style), - ui_ime_text_span.background_color, - ui_ime_text_span.suggestion_highlight_color, - ui_ime_text_span.suggestions); - blink_ime_text_span.text_color = ui_ime_text_span.text_color; - blink_ime_text_span.underline_color = ui_ime_text_span.underline_color; - blink_ime_text_span.remove_on_finish_composing = - ui_ime_text_span.remove_on_finish_composing; - return blink_ime_text_span; -} - -std::vector<blink::WebImeTextSpan> ConvertUiImeTextSpansToBlinkImeTextSpans( - const std::vector<ui::ImeTextSpan>& ui_ime_text_spans) { - std::vector<blink::WebImeTextSpan> blink_ime_text_spans; - for (const auto& ui_ime_text_span : ui_ime_text_spans) { - blink_ime_text_spans.push_back( - ConvertUiImeTextSpanToBlinkImeTextSpan(ui_ime_text_span)); - } - return blink_ime_text_spans; -} - -ui::ImeTextSpan ConvertBlinkImeTextSpanToUiImeTextSpan( - const blink::WebImeTextSpan& blink_ime_text_span) { - ui::ImeTextSpan ui_ime_text_span = ui::ImeTextSpan( - ConvertWebImeTextSpanTypeToUiType(blink_ime_text_span.type), - blink_ime_text_span.start_offset, blink_ime_text_span.end_offset, - ConvertUiImeTextSpanThicknessToUiThickness(blink_ime_text_span.thickness), - ConvertUiImeTextSpanUnderlineStyleToUiUnderlineStyle( - blink_ime_text_span.underline_style), - blink_ime_text_span.background_color, - blink_ime_text_span.suggestion_highlight_color, - blink_ime_text_span.suggestions); - ui_ime_text_span.text_color = blink_ime_text_span.text_color; - ui_ime_text_span.underline_color = blink_ime_text_span.underline_color; - ui_ime_text_span.remove_on_finish_composing = - blink_ime_text_span.remove_on_finish_composing; - return ui_ime_text_span; -} - -std::vector<ui::ImeTextSpan> ConvertBlinkImeTextSpansToUiImeTextSpans( - const std::vector<blink::WebImeTextSpan>& blink_ime_text_spans) { - std::vector<ui::ImeTextSpan> ui_ime_text_spans; - for (const auto& blink_ime_text_span : blink_ime_text_spans) { - ui_ime_text_spans.push_back( - ConvertBlinkImeTextSpanToUiImeTextSpan(blink_ime_text_span)); - } - return ui_ime_text_spans; -} - -} // namespace content diff --git a/chromium/content/common/input/ime_text_span_conversions.h b/chromium/content/common/input/ime_text_span_conversions.h deleted file mode 100644 index e7dd4fbfc16..00000000000 --- a/chromium/content/common/input/ime_text_span_conversions.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017 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. - -#ifndef CONTENT_COMMON_INPUT_IME_TEXT_SPAN_CONVERSIONS_H_ -#define CONTENT_COMMON_INPUT_IME_TEXT_SPAN_CONVERSIONS_H_ - -#include "third_party/blink/public/web/web_ime_text_span.h" -#include "ui/base/ime/ime_text_span.h" - -namespace content { - -blink::WebImeTextSpan::Type ConvertUiImeTextSpanTypeToWebType( - ui::ImeTextSpan::Type type); -ui::ImeTextSpan::Type ConvertWebImeTextSpanTypeToUiType( - blink::WebImeTextSpan::Type type); -ui::mojom::ImeTextSpanThickness ConvertUiThicknessToUiImeTextSpanThickness( - ui::ImeTextSpan::Thickness thickness); -ui::ImeTextSpan::Thickness ConvertUiImeTextSpanThicknessToUiThickness( - ui::mojom::ImeTextSpanThickness thickness); -ui::mojom::ImeTextSpanUnderlineStyle -ConvertUiUnderlineStyleToUiImeTextSpanUnderlineStyle( - ui::ImeTextSpan::UnderlineStyle underline_style); -ui::ImeTextSpan::UnderlineStyle -ConvertUiImeTextSpanUnderlineStyleToUiUnderlineStyle( - ui::mojom::ImeTextSpanUnderlineStyle underline_style); -blink::WebImeTextSpan ConvertUiImeTextSpanToBlinkImeTextSpan( - const ui::ImeTextSpan&); -ui::ImeTextSpan ConvertBlinkImeTextSpanToUiImeTextSpan( - const blink::WebImeTextSpan&); -std::vector<blink::WebImeTextSpan> ConvertUiImeTextSpansToBlinkImeTextSpans( - const std::vector<ui::ImeTextSpan>&); -std::vector<ui::ImeTextSpan> ConvertBlinkImeTextSpansToUiImeTextSpans( - const std::vector<blink::WebImeTextSpan>&); - -} // namespace content - -#endif // CONTENT_COMMON_INPUT_IME_TEXT_SPAN_CONVERSIONS_H_ diff --git a/chromium/content/common/input/input_event.cc b/chromium/content/common/input/input_event.cc deleted file mode 100644 index 4e11e69a36a..00000000000 --- a/chromium/content/common/input/input_event.cc +++ /dev/null @@ -1,23 +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_event.h" - -#include "ui/events/blink/web_input_event_traits.h" - -namespace content { - -InputEvent::InputEvent() {} - -InputEvent::InputEvent(ui::WebScopedInputEvent event, - const ui::LatencyInfo& info) - : web_event(std::move(event)), latency_info(info) {} - -InputEvent::InputEvent(const blink::WebInputEvent& web_event, - const ui::LatencyInfo& latency_info) - : web_event(web_event.Clone()), latency_info(latency_info) {} - -InputEvent::~InputEvent() {} - -} // namespace content diff --git a/chromium/content/common/input/input_event.h b/chromium/content/common/input/input_event.h deleted file mode 100644 index 1345731677b..00000000000 --- a/chromium/content/common/input/input_event.h +++ /dev/null @@ -1,40 +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. - -#ifndef CONTENT_COMMON_INPUT_INPUT_EVENT_H_ -#define CONTENT_COMMON_INPUT_INPUT_EVENT_H_ - -#include <memory> - -#include "base/macros.h" -#include "content/common/content_export.h" -#include "ui/events/blink/web_input_event_traits.h" -#include "ui/latency/latency_info.h" - -namespace blink { -class WebInputEvent; -} - -namespace content { - -// An content-specific wrapper for WebInputEvents and associated metadata. -class CONTENT_EXPORT InputEvent { - public: - InputEvent(); - InputEvent(ui::WebScopedInputEvent web_event, - const ui::LatencyInfo& latency_info); - InputEvent(const blink::WebInputEvent& web_event, - const ui::LatencyInfo& latency_info); - ~InputEvent(); - - ui::WebScopedInputEvent web_event; - ui::LatencyInfo latency_info; - - private: - DISALLOW_COPY_AND_ASSIGN(InputEvent); -}; - -} // namespace content - -#endif // CONTENT_COMMON_INPUT_INPUT_EVENT_H_ diff --git a/chromium/content/common/input/input_event_mojom_traits.cc b/chromium/content/common/input/input_event_mojom_traits.cc deleted file mode 100644 index 9f19111f925..00000000000 --- a/chromium/content/common/input/input_event_mojom_traits.cc +++ /dev/null @@ -1,538 +0,0 @@ -// Copyright 2017 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_event_mojom_traits.h" - -#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/common/input/web_keyboard_event.h" -#include "third_party/blink/public/common/input/web_mouse_wheel_event.h" -#include "ui/latency/mojom/latency_info_mojom_traits.h" - -namespace mojo { -namespace { - -void CopyString(base::char16* dst, const base::string16& text) { - base::i18n::UTF16CharIterator iter(&text); - size_t pos = 0; - while (!iter.end() && pos < blink::WebKeyboardEvent::kTextLengthCap - 1) { - dst[pos++] = iter.get(); - iter.Advance(); - } - dst[pos] = '\0'; -} - -content::mojom::PointerDataPtr PointerDataFromPointerProperties( - const blink::WebPointerProperties& pointer, - content::mojom::MouseDataPtr mouse_data) { - return content::mojom::PointerData::New( - pointer.id, pointer.force, pointer.tilt_x, pointer.tilt_y, - pointer.tangential_pressure, pointer.twist, pointer.button, - pointer.pointer_type, pointer.movement_x, pointer.movement_y, - pointer.is_raw_movement_event, pointer.PositionInWidget(), - pointer.PositionInScreen(), std::move(mouse_data)); -} - -void PointerPropertiesFromPointerData( - const content::mojom::PointerDataPtr& pointer_data, - blink::WebPointerProperties* pointer_properties) { - pointer_properties->id = pointer_data->pointer_id; - pointer_properties->force = pointer_data->force; - pointer_properties->tilt_x = pointer_data->tilt_x; - pointer_properties->tilt_y = pointer_data->tilt_y; - pointer_properties->tangential_pressure = pointer_data->tangential_pressure; - pointer_properties->twist = pointer_data->twist; - pointer_properties->button = pointer_data->button; - pointer_properties->pointer_type = pointer_data->pointer_type; - pointer_properties->movement_x = pointer_data->movement_x; - pointer_properties->movement_y = pointer_data->movement_y; - pointer_properties->is_raw_movement_event = - pointer_data->is_raw_movement_event; -} - -void TouchPointPropertiesFromPointerData( - const content::mojom::TouchPointPtr& mojo_touch_point, - blink::WebTouchPoint* touch_point) { - PointerPropertiesFromPointerData(mojo_touch_point->pointer_data, touch_point); - touch_point->state = mojo_touch_point->state; - touch_point->radius_x = mojo_touch_point->radius_x; - touch_point->radius_y = mojo_touch_point->radius_y; - touch_point->rotation_angle = mojo_touch_point->rotation_angle; - touch_point->SetPositionInWidget( - mojo_touch_point->pointer_data->widget_position.x(), - mojo_touch_point->pointer_data->widget_position.y()); - touch_point->SetPositionInScreen( - mojo_touch_point->pointer_data->screen_position.x(), - mojo_touch_point->pointer_data->screen_position.y()); -} - -// TODO(dtapuska): Remove once SetPositionInXXX moves to WebPointerProperties. -void MouseEventPropertiesFromPointerData( - const content::mojom::PointerDataPtr& pointer_data, - blink::WebMouseEvent* mouse_event) { - PointerPropertiesFromPointerData(pointer_data, mouse_event); - mouse_event->SetPositionInWidget(pointer_data->widget_position.x(), - pointer_data->widget_position.y()); - mouse_event->SetPositionInScreen(pointer_data->screen_position.x(), - pointer_data->screen_position.y()); -} - -} // namespace - -bool StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::Read( - content::mojom::EventDataView event, - InputEventUniquePtr* out) { - DCHECK(!out->get()); - - out->reset(new content::InputEvent()); - - blink::WebInputEvent::Type type; - 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(), timestamp)); - - blink::WebKeyboardEvent* key_event = - static_cast<blink::WebKeyboardEvent*>((*out)->web_event.get()); - key_event->windows_key_code = key_data->windows_key_code; - key_event->native_key_code = key_data->native_key_code; - key_event->dom_code = key_data->dom_code; - key_event->dom_key = key_data->dom_key; - key_event->is_system_key = key_data->is_system_key; - key_event->is_browser_shortcut = key_data->is_browser_shortcut; - CopyString(key_event->text, key_data->text); - CopyString(key_event->unmodified_text, key_data->unmodified_text); - } else if (blink::WebInputEvent::IsGestureEventType(type)) { - content::mojom::GestureDataPtr gesture_data; - if (!event.ReadGestureData<content::mojom::GestureDataPtr>(&gesture_data)) - return false; - (*out)->web_event.reset(new blink::WebGestureEvent( - type, event.modifiers(), timestamp, gesture_data->source_device)); - - blink::WebGestureEvent* gesture_event = - static_cast<blink::WebGestureEvent*>((*out)->web_event.get()); - gesture_event->SetPositionInWidget(gesture_data->widget_position); - gesture_event->SetPositionInScreen(gesture_data->screen_position); - gesture_event->is_source_touch_event_set_non_blocking = - gesture_data->is_source_touch_event_set_non_blocking; - gesture_event->primary_pointer_type = gesture_data->primary_pointer_type; - gesture_event->SetSourceDevice(gesture_data->source_device); - gesture_event->unique_touch_event_id = gesture_data->unique_touch_event_id; - - if (gesture_data->contact_size) { - switch (type) { - default: - break; - case blink::WebInputEvent::Type::kGestureTapDown: - gesture_event->data.tap_down.width = - gesture_data->contact_size->width(); - gesture_event->data.tap_down.height = - gesture_data->contact_size->height(); - break; - case blink::WebInputEvent::Type::kGestureShowPress: - gesture_event->data.show_press.width = - gesture_data->contact_size->width(); - gesture_event->data.show_press.height = - gesture_data->contact_size->height(); - break; - case blink::WebInputEvent::Type::kGestureTap: - case blink::WebInputEvent::Type::kGestureTapUnconfirmed: - case blink::WebInputEvent::Type::kGestureDoubleTap: - gesture_event->data.tap.width = gesture_data->contact_size->width(); - gesture_event->data.tap.height = gesture_data->contact_size->height(); - break; - case blink::WebInputEvent::Type::kGestureLongPress: - case blink::WebInputEvent::Type::kGestureLongTap: - gesture_event->data.long_press.width = - gesture_data->contact_size->width(); - gesture_event->data.long_press.height = - gesture_data->contact_size->height(); - break; - case blink::WebInputEvent::Type::kGestureTwoFingerTap: - gesture_event->data.two_finger_tap.first_finger_width = - gesture_data->contact_size->width(); - gesture_event->data.two_finger_tap.first_finger_height = - gesture_data->contact_size->height(); - break; - } - } - - if (gesture_data->scroll_data) { - switch (type) { - default: - break; - case blink::WebInputEvent::Type::kGestureScrollBegin: - gesture_event->data.scroll_begin.delta_x_hint = - gesture_data->scroll_data->delta_x; - gesture_event->data.scroll_begin.delta_y_hint = - gesture_data->scroll_data->delta_y; - gesture_event->data.scroll_begin.delta_hint_units = - gesture_data->scroll_data->delta_units; - gesture_event->data.scroll_begin.target_viewport = - gesture_data->scroll_data->target_viewport; - gesture_event->data.scroll_begin.inertial_phase = - gesture_data->scroll_data->inertial_phase; - gesture_event->data.scroll_begin.synthetic = - gesture_data->scroll_data->synthetic; - gesture_event->data.scroll_begin.pointer_count = - gesture_data->scroll_data->pointer_count; - break; - case blink::WebInputEvent::Type::kGestureScrollEnd: - gesture_event->data.scroll_end.delta_units = - gesture_data->scroll_data->delta_units; - gesture_event->data.scroll_end.inertial_phase = - gesture_data->scroll_data->inertial_phase; - gesture_event->data.scroll_end.synthetic = - gesture_data->scroll_data->synthetic; - break; - case blink::WebInputEvent::Type::kGestureScrollUpdate: - gesture_event->data.scroll_update.delta_x = - gesture_data->scroll_data->delta_x; - gesture_event->data.scroll_update.delta_y = - gesture_data->scroll_data->delta_y; - gesture_event->data.scroll_update.delta_units = - gesture_data->scroll_data->delta_units; - gesture_event->data.scroll_update.inertial_phase = - gesture_data->scroll_data->inertial_phase; - if (gesture_data->scroll_data->update_details) { - gesture_event->data.scroll_update.velocity_x = - gesture_data->scroll_data->update_details->velocity_x; - gesture_event->data.scroll_update.velocity_y = - gesture_data->scroll_data->update_details->velocity_y; - } - break; - } - } - - if (gesture_data->pinch_begin_data && - type == blink::WebInputEvent::Type::kGesturePinchBegin) { - gesture_event->data.pinch_begin.needs_wheel_event = - gesture_data->pinch_begin_data->needs_wheel_event; - } - - if (gesture_data->pinch_update_data && - type == blink::WebInputEvent::Type::kGesturePinchUpdate) { - gesture_event->data.pinch_update.zoom_disabled = - gesture_data->pinch_update_data->zoom_disabled; - gesture_event->data.pinch_update.scale = - gesture_data->pinch_update_data->scale; - gesture_event->data.pinch_update.needs_wheel_event = - gesture_data->pinch_update_data->needs_wheel_event; - } - - if (gesture_data->pinch_end_data && - type == blink::WebInputEvent::Type::kGesturePinchEnd) { - gesture_event->data.pinch_end.needs_wheel_event = - gesture_data->pinch_end_data->needs_wheel_event; - } - - if (gesture_data->tap_data) { - switch (type) { - default: - break; - case blink::WebInputEvent::Type::kGestureTap: - case blink::WebInputEvent::Type::kGestureTapUnconfirmed: - case blink::WebInputEvent::Type::kGestureDoubleTap: - gesture_event->data.tap.tap_count = gesture_data->tap_data->tap_count; - gesture_event->data.tap.needs_wheel_event = - gesture_data->tap_data->needs_wheel_event; - break; - } - } - - if (gesture_data->fling_data) { - switch (type) { - default: - break; - case blink::WebInputEvent::Type::kGestureFlingStart: - gesture_event->data.fling_start.velocity_x = - gesture_data->fling_data->velocity_x; - gesture_event->data.fling_start.velocity_y = - gesture_data->fling_data->velocity_y; - gesture_event->data.fling_start.target_viewport = - gesture_data->fling_data->target_viewport; - break; - case blink::WebInputEvent::Type::kGestureFlingCancel: - gesture_event->data.fling_cancel.target_viewport = - gesture_data->fling_data->target_viewport; - gesture_event->data.fling_cancel.prevent_boosting = - gesture_data->fling_data->prevent_boosting; - break; - } - } - - } else if (blink::WebInputEvent::IsTouchEventType(type)) { - content::mojom::TouchDataPtr touch_data; - if (!event.ReadTouchData<content::mojom::TouchDataPtr>(&touch_data)) - return false; - - (*out)->web_event.reset( - new blink::WebTouchEvent(type, event.modifiers(), timestamp)); - - blink::WebTouchEvent* touch_event = - static_cast<blink::WebTouchEvent*>((*out)->web_event.get()); - std::vector<content::mojom::TouchPointPtr> touches; - unsigned i; - for (i = 0; i < touch_data->touches.size() && - i < blink::WebTouchEvent::kTouchesLengthCap; - ++i) { - blink::WebTouchPoint& touch_point = touch_event->touches[i]; - TouchPointPropertiesFromPointerData(touch_data->touches[i], &touch_point); - } - - touch_event->touches_length = i; - touch_event->dispatch_type = touch_data->cancelable; - touch_event->moved_beyond_slop_region = - touch_data->moved_beyond_slop_region; - touch_event->hovering = touch_data->hovering; - touch_event->touch_start_or_first_touch_move = - touch_data->touch_start_or_first_move; - touch_event->unique_touch_event_id = touch_data->unique_touch_event_id; - } else if (blink::WebInputEvent::IsMouseEventType(type) || - type == blink::WebInputEvent::Type::kMouseWheel) { - content::mojom::PointerDataPtr pointer_data; - if (!event.ReadPointerData<content::mojom::PointerDataPtr>(&pointer_data)) - return false; - - if (blink::WebInputEvent::IsMouseEventType(type)) { - (*out)->web_event.reset( - new blink::WebMouseEvent(type, event.modifiers(), timestamp)); - } else { - (*out)->web_event.reset( - new blink::WebMouseWheelEvent(type, event.modifiers(), timestamp)); - } - - blink::WebMouseEvent* mouse_event = - static_cast<blink::WebMouseEvent*>((*out)->web_event.get()); - - MouseEventPropertiesFromPointerData(pointer_data, mouse_event); - if (pointer_data->mouse_data) { - mouse_event->click_count = pointer_data->mouse_data->click_count; - - if (type == blink::WebInputEvent::Type::kMouseWheel && - pointer_data->mouse_data->wheel_data) { - blink::WebMouseWheelEvent* wheel_event = - static_cast<blink::WebMouseWheelEvent*>(mouse_event); - content::mojom::WheelDataPtr& wheel_data = - pointer_data->mouse_data->wheel_data; - wheel_event->delta_x = wheel_data->delta_x; - wheel_event->delta_y = wheel_data->delta_y; - wheel_event->wheel_ticks_x = wheel_data->wheel_ticks_x; - wheel_event->wheel_ticks_y = wheel_data->wheel_ticks_y; - wheel_event->acceleration_ratio_x = wheel_data->acceleration_ratio_x; - wheel_event->acceleration_ratio_y = wheel_data->acceleration_ratio_y; - wheel_event->phase = - static_cast<blink::WebMouseWheelEvent::Phase>(wheel_data->phase); - wheel_event->momentum_phase = - static_cast<blink::WebMouseWheelEvent::Phase>( - wheel_data->momentum_phase); - wheel_event->dispatch_type = wheel_data->cancelable; - wheel_event->event_action = - static_cast<blink::WebMouseWheelEvent::EventAction>( - wheel_data->event_action); - wheel_event->delta_units = - static_cast<ui::ScrollGranularity>(wheel_data->delta_units); - } - } - - } else { - return false; - } - - return event.ReadLatency(&((*out)->latency_info)); -} - -// static -content::mojom::KeyDataPtr -StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::key_data( - const InputEventUniquePtr& event) { - if (!event->web_event || - !blink::WebInputEvent::IsKeyboardEventType(event->web_event->GetType())) - return nullptr; - const blink::WebKeyboardEvent* key_event = - static_cast<const blink::WebKeyboardEvent*>(event->web_event.get()); - return content::mojom::KeyData::New( - key_event->dom_key, key_event->dom_code, key_event->windows_key_code, - key_event->native_key_code, key_event->is_system_key, - key_event->is_browser_shortcut, key_event->text, - key_event->unmodified_text); -} - -// static -content::mojom::PointerDataPtr -StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::pointer_data( - const InputEventUniquePtr& event) { - if (!event->web_event) - return nullptr; - bool is_wheel_event = - event->web_event->GetType() == blink::WebInputEvent::Type::kMouseWheel; - if (!blink::WebInputEvent::IsMouseEventType(event->web_event->GetType()) && - !is_wheel_event) { - return nullptr; - } - const blink::WebMouseEvent* mouse_event = - static_cast<const blink::WebMouseEvent*>(event->web_event.get()); - - content::mojom::WheelDataPtr wheel_data; - if (is_wheel_event) { - const blink::WebMouseWheelEvent* wheel_event = - static_cast<const blink::WebMouseWheelEvent*>(mouse_event); - wheel_data = content::mojom::WheelData::New( - wheel_event->delta_x, wheel_event->delta_y, wheel_event->wheel_ticks_x, - wheel_event->wheel_ticks_y, wheel_event->acceleration_ratio_x, - wheel_event->acceleration_ratio_y, wheel_event->phase, - wheel_event->momentum_phase, wheel_event->dispatch_type, - static_cast<uint8_t>(wheel_event->event_action), - static_cast<uint8_t>(wheel_event->delta_units)); - } - - return PointerDataFromPointerProperties( - *mouse_event, content::mojom::MouseData::New(mouse_event->click_count, - std::move(wheel_data))); -} - -// static -content::mojom::GestureDataPtr -StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::gesture_data( - const InputEventUniquePtr& event) { - if (!event->web_event || - !blink::WebInputEvent::IsGestureEventType(event->web_event->GetType())) - return nullptr; - const blink::WebGestureEvent* gesture_event = - static_cast<const blink::WebGestureEvent*>(event->web_event.get()); - auto gesture_data = content::mojom::GestureData::New(); - gesture_data->screen_position = gesture_event->PositionInScreen(); - gesture_data->widget_position = gesture_event->PositionInWidget(); - gesture_data->source_device = gesture_event->SourceDevice(); - gesture_data->is_source_touch_event_set_non_blocking = - gesture_event->is_source_touch_event_set_non_blocking; - gesture_data->primary_pointer_type = gesture_event->primary_pointer_type; - gesture_data->unique_touch_event_id = gesture_event->unique_touch_event_id; - switch (gesture_event->GetType()) { - default: - break; - case blink::WebInputEvent::Type::kGestureTapDown: - gesture_data->contact_size = - gfx::Size(gesture_event->data.tap_down.width, - gesture_event->data.tap_down.height); - break; - case blink::WebInputEvent::Type::kGestureShowPress: - gesture_data->contact_size = - gfx::Size(gesture_event->data.show_press.width, - gesture_event->data.show_press.height); - break; - case blink::WebInputEvent::Type::kGestureTap: - case blink::WebInputEvent::Type::kGestureTapUnconfirmed: - case blink::WebInputEvent::Type::kGestureDoubleTap: - gesture_data->contact_size = gfx::Size(gesture_event->data.tap.width, - gesture_event->data.tap.height); - gesture_data->tap_data = content::mojom::TapData::New( - gesture_event->data.tap.tap_count, - gesture_event->data.tap.needs_wheel_event); - break; - case blink::WebInputEvent::Type::kGestureLongPress: - case blink::WebInputEvent::Type::kGestureLongTap: - gesture_data->contact_size = - gfx::Size(gesture_event->data.long_press.width, - gesture_event->data.long_press.height); - break; - - case blink::WebInputEvent::Type::kGestureTwoFingerTap: - gesture_data->contact_size = - gfx::Size(gesture_event->data.two_finger_tap.first_finger_width, - gesture_event->data.two_finger_tap.first_finger_height); - break; - case blink::WebInputEvent::Type::kGestureScrollBegin: - gesture_data->scroll_data = content::mojom::ScrollData::New( - gesture_event->data.scroll_begin.delta_x_hint, - gesture_event->data.scroll_begin.delta_y_hint, - gesture_event->data.scroll_begin.delta_hint_units, - gesture_event->data.scroll_begin.target_viewport, - gesture_event->data.scroll_begin.inertial_phase, - gesture_event->data.scroll_begin.synthetic, - gesture_event->data.scroll_begin.pointer_count, nullptr); - break; - case blink::WebInputEvent::Type::kGestureScrollEnd: - gesture_data->scroll_data = content::mojom::ScrollData::New( - 0, 0, gesture_event->data.scroll_end.delta_units, false, - gesture_event->data.scroll_end.inertial_phase, - gesture_event->data.scroll_end.synthetic, 0, nullptr); - break; - case blink::WebInputEvent::Type::kGestureScrollUpdate: - gesture_data->scroll_data = content::mojom::ScrollData::New( - gesture_event->data.scroll_update.delta_x, - gesture_event->data.scroll_update.delta_y, - gesture_event->data.scroll_update.delta_units, false, - gesture_event->data.scroll_update.inertial_phase, false, 0, - content::mojom::ScrollUpdate::New( - gesture_event->data.scroll_update.velocity_x, - gesture_event->data.scroll_update.velocity_y)); - break; - case blink::WebInputEvent::Type::kGestureFlingStart: - gesture_data->fling_data = content::mojom::FlingData::New( - gesture_event->data.fling_start.velocity_x, - gesture_event->data.fling_start.velocity_y, - gesture_event->data.fling_start.target_viewport, false); - break; - case blink::WebInputEvent::Type::kGestureFlingCancel: - gesture_data->fling_data = content::mojom::FlingData::New( - 0, 0, gesture_event->data.fling_cancel.target_viewport, - gesture_event->data.fling_cancel.prevent_boosting); - break; - case blink::WebInputEvent::Type::kGesturePinchBegin: - gesture_data->pinch_begin_data = content::mojom::PinchBeginData::New( - gesture_event->data.pinch_begin.needs_wheel_event); - break; - case blink::WebInputEvent::Type::kGesturePinchUpdate: - gesture_data->pinch_update_data = content::mojom::PinchUpdateData::New( - gesture_event->data.pinch_update.scale, - gesture_event->data.pinch_update.zoom_disabled, - gesture_event->data.pinch_update.needs_wheel_event); - break; - case blink::WebInputEvent::Type::kGesturePinchEnd: - gesture_data->pinch_end_data = content::mojom::PinchEndData::New( - gesture_event->data.pinch_end.needs_wheel_event); - break; - } - return gesture_data; -} - -// static -content::mojom::TouchDataPtr -StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::touch_data( - const InputEventUniquePtr& event) { - if (!event->web_event || - !blink::WebInputEvent::IsTouchEventType(event->web_event->GetType())) - return nullptr; - - const blink::WebTouchEvent* touch_event = - static_cast<const blink::WebTouchEvent*>(event->web_event.get()); - auto touch_data = content::mojom::TouchData::New( - touch_event->dispatch_type, touch_event->moved_beyond_slop_region, - touch_event->touch_start_or_first_touch_move, touch_event->hovering, - touch_event->unique_touch_event_id, - std::vector<content::mojom::TouchPointPtr>()); - for (unsigned i = 0; i < touch_event->touches_length; ++i) { - content::mojom::PointerDataPtr pointer_data = - PointerDataFromPointerProperties(touch_event->touches[i], nullptr); - touch_data->touches.emplace_back(content::mojom::TouchPoint::New( - touch_event->touches[i].state, touch_event->touches[i].radius_x, - touch_event->touches[i].radius_y, - touch_event->touches[i].rotation_angle, std::move(pointer_data))); - } - return touch_data; -} - -} // namespace mojo diff --git a/chromium/content/common/input/input_event_mojom_traits.h b/chromium/content/common/input/input_event_mojom_traits.h deleted file mode 100644 index 6d453a672bd..00000000000 --- a/chromium/content/common/input/input_event_mojom_traits.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2017 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. - -#ifndef CONTENT_COMMON_INPUT_INPUT_EVENT_MOJOM_TRAITS_H_ -#define CONTENT_COMMON_INPUT_INPUT_EVENT_MOJOM_TRAITS_H_ - -#include "content/common/input/input_handler.mojom.h" - -namespace content { -class InputEvent; -} - -namespace mojo { - -using InputEventUniquePtr = std::unique_ptr<content::InputEvent>; - -template <> -struct StructTraits<content::mojom::EventDataView, InputEventUniquePtr> { - static blink::WebInputEvent::Type type(const InputEventUniquePtr& event) { - return event->web_event->GetType(); - } - - static int32_t modifiers(const InputEventUniquePtr& event) { - return event->web_event->GetModifiers(); - } - - static base::TimeTicks timestamp(const InputEventUniquePtr& event) { - return event->web_event->TimeStamp(); - } - - static const ui::LatencyInfo& latency(const InputEventUniquePtr& event) { - return event->latency_info; - } - - static content::mojom::KeyDataPtr key_data(const InputEventUniquePtr& event); - static content::mojom::PointerDataPtr pointer_data( - const InputEventUniquePtr& event); - static content::mojom::GestureDataPtr gesture_data( - const InputEventUniquePtr& event); - static content::mojom::TouchDataPtr touch_data( - const InputEventUniquePtr& event); - - static bool Read(content::mojom::EventDataView r, InputEventUniquePtr* out); -}; - -} // namespace mojo - -#endif // CONTENT_COMMON_INPUT_INPUT_EVENT_MOJOM_TRAITS_H_ diff --git a/chromium/content/common/input/input_handler.mojom b/chromium/content/common/input/input_handler.mojom deleted file mode 100644 index 6ae8d0bf969..00000000000 --- a/chromium/content/common/input/input_handler.mojom +++ /dev/null @@ -1,398 +0,0 @@ -// Copyright 2017 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. - -module content.mojom; - -import "cc/mojom/touch_action.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 "third_party/blink/public/mojom/input/gesture_event.mojom"; -import "third_party/blink/public/mojom/input/input_event.mojom"; -import "third_party/blink/public/mojom/input/input_handler.mojom"; -import "third_party/blink/public/mojom/input/input_event_result.mojom"; -import "third_party/blink/public/mojom/input/pointer_lock_result.mojom"; -import "third_party/blink/public/mojom/input/touch_event.mojom"; -import "third_party/blink/public/mojom/input/pointer_lock_context.mojom"; -import "third_party/blink/public/mojom/selection_menu/selection_menu_behavior.mojom"; -import "ui/base/ime/mojom/ime_types.mojom"; -import "ui/events/mojom/event.mojom"; -import "ui/events/mojom/event_constants.mojom"; -import "ui/events/mojom/scroll_granularity.mojom"; -import "ui/gfx/geometry/mojom/geometry.mojom"; -import "ui/gfx/range/mojom/range.mojom"; -import "ui/latency/mojom/latency_info.mojom"; - - -// These structs are purposely duplicated from ui/events/mojom/event.mojom. -// They map WebInputEvent <-> WebInputEvent across mojo. -// We have to work at unifying them. The current problem is that the browser -// uses WebInputEvents inside the render widget host and input router. Once -// we move these to ui::Event's then we can get rid of these duplicated -// mojom structs. Ideally the browser would use ui::Event up until we -// pass the events into the renderer and just use a StructTraits to perform -// conversion from ui::mojom::Event --> blink::WebInputEvent. -struct KeyData { - int32 dom_key; - int32 dom_code; - int32 windows_key_code; - int32 native_key_code; - bool is_system_key; - bool is_browser_shortcut; - mojo_base.mojom.String16 text; - mojo_base.mojom.String16 unmodified_text; -}; - -struct PointerData { - int32 pointer_id; - float force; - int32 tilt_x; - int32 tilt_y; - float tangential_pressure; - int32 twist; - blink.mojom.Button button; - ui.mojom.EventPointerType pointer_type; - int32 movement_x; - int32 movement_y; - bool is_raw_movement_event; - gfx.mojom.PointF widget_position; - gfx.mojom.PointF screen_position; - MouseData? mouse_data; -}; - -struct WheelData { - float delta_x; - float delta_y; - float wheel_ticks_x; - float wheel_ticks_y; - float acceleration_ratio_x; - float acceleration_ratio_y; - uint8 phase; - uint8 momentum_phase; - blink.mojom.DispatchType cancelable; - uint8 event_action; - uint8 delta_units; -}; - -struct MouseData { - int32 click_count; - WheelData? wheel_data; -}; - -struct ScrollUpdate { - float velocity_x; - float velocity_y; -}; - -struct ScrollData { - float delta_x; - float delta_y; - ui.mojom.ScrollGranularity delta_units; - bool target_viewport; - blink.mojom.InertialPhaseState inertial_phase; - bool synthetic; - int32 pointer_count; - ScrollUpdate? update_details; -}; - -struct PinchBeginData { - bool needs_wheel_event; -}; - -struct PinchUpdateData { - float scale; - bool zoom_disabled; - bool needs_wheel_event; -}; - -struct PinchEndData { - bool needs_wheel_event; -}; - -struct FlingData { - float velocity_x; - float velocity_y; - bool target_viewport; - bool prevent_boosting; -}; - -struct TapData { - int32 tap_count; - bool needs_wheel_event; -}; - -struct GestureData { - gfx.mojom.PointF screen_position; - gfx.mojom.PointF widget_position; - blink.mojom.GestureDevice source_device; - bool is_source_touch_event_set_non_blocking; - ui.mojom.EventPointerType primary_pointer_type; - int32 unique_touch_event_id; - gfx.mojom.Size? contact_size; - ScrollData? scroll_data; - PinchBeginData? pinch_begin_data; - PinchUpdateData? pinch_update_data; - PinchEndData? pinch_end_data; - TapData? tap_data; - FlingData? fling_data; -}; - -struct TouchPoint { - blink.mojom.TouchState state; - float radius_x; - float radius_y; - float rotation_angle; - PointerData pointer_data; -}; - -struct TouchData { - blink.mojom.DispatchType cancelable; - bool moved_beyond_slop_region; - bool touch_start_or_first_move; - bool hovering; - uint32 unique_touch_event_id; - array<TouchPoint> touches; -}; - -struct Event { - blink.mojom.EventType type; - int32 modifiers; - mojo_base.mojom.TimeTicks timestamp; - ui.mojom.LatencyInfo latency; - KeyData? key_data; - PointerData? pointer_data; - GestureData? gesture_data; - TouchData? touch_data; -}; - -// Interface exposed by the browser to the renderer. -interface WidgetInputHandlerHost { - // When the renderer's main thread computes the touch action, send this to the - // browser. - SetTouchActionFromMain(cc.mojom.TouchAction touch_action); - - // Sent by the compositor when input scroll events are dropped due to bounds - // restrictions on the root scroll offset. - DidOverscroll(blink.mojom.DidOverscrollParams params); - - // Sent by the compositor when a GSB has started scrolling the viewport. - DidStartScrollingViewport(); - - // Required for cancelling an ongoing input method composition. - ImeCancelComposition(); - - // Sends the character bounds after every composition change - // 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); - - // Requests locking the target of mouse events to a single element and - // removing the cursor from view. Mostly used by the Pointer Lock API. - // See https://www.w3.org/TR/pointerlock/ for more info. This call is - // also used by Pepper Flash. - // |from_user_gesture| indicates whether this request came from a user - // gesture or not. - // |privileged| is used by Pepper Flash. Privileged mouse lock is only - // allowed for fullscreen render widget, which is used to implement Pepper - // Flash fullscreen. If privileged is allowed and set to true, we - // won't pop up a bubble to ask for user permission or take mouse lock - // content into account. The mouse lock will be directly approved. - // |unadjusted_movement| indicates whether the request asked for raw mouse - // movement data or just what the operating system returns (often accelerated - // mouse movement). - // |result| kSuccess if the mouse has been locked or the appropriate error - // reason if not. - // |context| is one end of a mojo pipe that will stay connected as long as - // the mouse is locked. Is a NullRemote if |result| is not kSuccess. - RequestMouseLock(bool from_user_gesture, - bool privileged, - bool unadjusted_movement) - => (blink.mojom.PointerLockResult result, - pending_remote<blink.mojom.PointerLockContext>? context); -}; - -// Interface exposed by the renderer to the browser. This class represents -// an input interface for an associated Widget object. See FrameInputHandler -// for an interface at the frame level. -interface WidgetInputHandler { - // Tells widget focus has been changed. - SetFocus(bool focused); - - // Tells widget mouse capture has been lost. - MouseCaptureLost(); - - // This message notifies the renderer that the next key event is bound to one - // or more pre-defined edit commands. If the next key event is not handled - // by blink, the specified edit commands shall be executed against current - // focused frame. - // Parameters - // * edit_commands - // See t_p/b/renderer/core/editing/commands/editing_command_type.h - // Contains one or more edit commands. - // See t_p/b/renderer/core/editing/commands/editor_command.cc for - // detailed definition of webkit edit commands. - // - // This message must be sent just before sending a key event. - SetEditCommandsForNextKeyEvent(array<blink.mojom.EditCommand> edit_commands); - - // Sends the cursor visibility state to the render widget. - CursorVisibilityChanged(bool visible); - - // This message sends a string being composed with an input method. - ImeSetComposition(mojo_base.mojom.String16 text, - array<ui.mojom.ImeTextSpan> ime_text_spans, - gfx.mojom.Range range, int32 start, int32 end); - - // This message deletes the current composition, inserts specified text, and - // moves the cursor. - ImeCommitText(mojo_base.mojom.String16 text, - array<ui.mojom.ImeTextSpan> ime_text_spans, - gfx.mojom.Range range, int32 relative_cursor_position) => (); - - // This message inserts the ongoing composition. - ImeFinishComposingText(bool keep_selection); - - // Request from browser to update text input state. - RequestTextInputStateUpdate(); - - // Request from browser to update the cursor and composition information which - // 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 - // info) will lead to updates being sent to the browser. - RequestCompositionUpdates(bool immediate_request, bool monitor_request); - - // Sends an input event to the render widget. The browser should use this - // API if it wants to know about the result of the rendering handling - // the event. The callback may be delayed based on the event running on - // the main thread so DispatchNonBlockingEvent is always preferred if - // you don't require notification. - DispatchEvent(Event event) - => (blink.mojom.InputEventResultSource source, - ui.mojom.LatencyInfo updated_latency, - blink.mojom.InputEventResultState state, - blink.mojom.DidOverscrollParams? overscroll, - blink.mojom.TouchActionOptional? touch_action); - - // Sends a non-blocking input event to the render widget. The behaviour - // of this API is the same as DispatchEvent just that there is no callback - // after the event is processed. - DispatchNonBlockingEvent(Event event); - - // Forces input to be flushed and resolves the callback only once the input - // has been fully processed, meaning its effects are visible to the full - // system. In practice, this will force a redraw and wait until the new - // CompositorFrame (containing all changes caused by prior input) has been - // displayed. - WaitForInputProcessed() => (); - - // Attach the synchronous compositor interface. This method only - // should be called for Android WebView. - AttachSynchronousCompositor( - pending_remote<SynchronousCompositorControlHost> control_host, - pending_associated_remote<SynchronousCompositorHost> host, - pending_associated_receiver<SynchronousCompositor> compositor_request); -}; - -// This interface provides the input actions associated with the RenderFrame. -// Other input actions may also be dispatched via the WidgetInputHandler -// interface. If frame input actions are dispatched the WidgetInputHandler -// should be fetched via the associated interface request so that input calls -// remain in order. See https://goo.gl/x4ee8A for more details. -interface FrameInputHandler { - // Sets the text composition to be between the given start and end offsets in - // the currently focused editable field. - SetCompositionFromExistingText( - int32 start, int32 end, array<ui.mojom.ImeTextSpan> ime_text_spans); - - // Deletes the current selection plus the specified number of characters - // before and after the selection or caret. - ExtendSelectionAndDelete(int32 before, int32 after); - - // Deletes text before and after the current cursor position, excluding the - // selection. The lengths are supplied in Java chars (UTF-16 Code Unit), - // not in code points or in glyphs. - DeleteSurroundingText(int32 before, int32 after); - - // Deletes text before and after the current cursor position, excluding the - // selection. The lengths are supplied in code points, not in Java chars - // (UTF-16 Code Unit) or in glyphs. Does nothing if there are one or more - // invalid surrogate pairs in the requested range - DeleteSurroundingTextInCodePoints(int32 before, int32 after); - - // Selects between the given start and end offsets in the currently focused - // editable field. - SetEditableSelectionOffsets(int32 start, int32 end); - - // Message payload is the name/value of a WebCore edit command to execute. - ExecuteEditCommand(string command, mojo_base.mojom.String16? value); - - // These messages are typically generated from context menus and request the - // renderer to apply the specified operation to the current selection. - Undo(); - Redo(); - Cut(); - Copy(); - CopyToFindPboard(); - Paste(); - PasteAndMatchStyle(); - Delete(); - SelectAll(); - CollapseSelection(); - - // Replaces the selected region or a word around the cursor with the - // specified string. - Replace(mojo_base.mojom.String16 word); - - // Replaces the misspelling in the selected region with the specified string. - ReplaceMisspelling(mojo_base.mojom.String16 word); - - // Requests the renderer to select the region between two points. - // Expects a SelectRange_ACK message when finished. - SelectRange(gfx.mojom.Point base, gfx.mojom.Point extent); - - // Sent by the browser to ask the renderer to adjust the selection start and - // end points by the given amounts. A negative amount moves the selection - // towards the beginning of the document, a positive amount moves the - // selection towards the end of the document. Will send show selection menu - // event when needed. - AdjustSelectionByCharacterOffset( - int32 start, int32 end, blink.mojom.SelectionMenuBehavior behavior); - - // Requests the renderer to select word around caret. - // Expects ack with new selection information when finished. |start_adjust| - // and |end_adjust| are the start and end offset difference between the - // current selection and the previous selection (which is a caret). - [EnableIf=is_android] - SelectWordAroundCaret() - => (bool did_select, int32 start_adjust, int32 end_adjust); - - // Requests the renderer to move the selection extent point to a new position. - // Expects a MoveRangeSelectionExtent_ACK message when finished. - MoveRangeSelectionExtent(gfx.mojom.Point extent); - - // Tells the renderer to scroll the currently focused node into rect only if - // the currently focused node is a Text node (textfield, text area or content - // editable divs). - ScrollFocusedEditableNodeIntoRect(gfx.mojom.Rect rect); - - // Requests the renderer to move the caret selection toward the point. - MoveCaret(gfx.mojom.Point point); - - // Return an associated WidgetInputHandler interface so that input - // messages to the widget associated with this frame can be sent - // serially. - GetWidgetInputHandler( - pending_associated_receiver<WidgetInputHandler> interface_request, - pending_remote<WidgetInputHandlerHost> host); -}; diff --git a/chromium/content/common/input/synchronous_compositor.mojom b/chromium/content/common/input/synchronous_compositor.mojom deleted file mode 100644 index 7af71ab1812..00000000000 --- a/chromium/content/common/input/synchronous_compositor.mojom +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2017 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. - -module content.mojom; - -import "mojo/public/mojom/base/shared_memory.mojom"; -import "mojo/public/mojom/base/time.mojom"; -import "services/viz/public/mojom/compositing/begin_frame_args.mojom"; -import "services/viz/public/mojom/compositing/compositor_frame.mojom"; -import "services/viz/public/mojom/compositing/compositor_frame_metadata.mojom"; -import "services/viz/public/mojom/compositing/frame_timing_details.mojom"; -import "services/viz/public/mojom/compositing/returned_resource.mojom"; -import "services/viz/public/mojom/hit_test/hit_test_region_list.mojom"; -import "ui/gfx/geometry/mojom/geometry.mojom"; -import "ui/gfx/mojom/transform.mojom"; - -struct SyncCompositorDemandDrawHwParams { - gfx.mojom.Size viewport_size; - gfx.mojom.Rect viewport_rect_for_tile_priority; - gfx.mojom.Transform transform_for_tile_priority; -}; - -struct SyncCompositorDemandDrawSwParams { - gfx.mojom.Size size; - gfx.mojom.Rect clip; - gfx.mojom.Transform transform; -}; - -struct SyncCompositorCommonRendererParams { - uint32 version = 0; - gfx.mojom.ScrollOffset total_scroll_offset; - gfx.mojom.ScrollOffset max_scroll_offset; - gfx.mojom.SizeF scrollable_size; - float page_scale_factor = 0; - float min_page_scale_factor = 0; - float max_page_scale_factor = 0; - uint32 need_invalidate_count = 0; - bool invalidate_needs_draw = true; - uint32 did_activate_pending_tree_count = 0; -}; - -// The SynchronousCompositor is an interface that is used by Android Webview -// which must control the compositor synchronously. It does this so that -// java UI is drawn in lock step with content renderer by the webview. -// The SynchronousCompositor is an associated interface with WidgetInputHandler -// because input must be delivered in order with the compositing events. -interface SynchronousCompositor { - // Hardware draw asynchronously, ReturnFrame will return the result on - // the associated SynchronousCompositorControlHost. - DemandDrawHwAsync(SyncCompositorDemandDrawHwParams draw_params); - - // Synchronously hardware draws. - [Sync] - DemandDrawHw(SyncCompositorDemandDrawHwParams draw_params) => - (SyncCompositorCommonRendererParams result, - uint32 layer_tree_frame_sink_id, - uint32 metadata_version, - viz.mojom.CompositorFrame? frame, - viz.mojom.HitTestRegionList? hit_test_region_list); - - // Synchronously sets the shared memory used for resourceless software - // drawing. This mode just has the renderer send over a single bitmap of the - // final frame, rather than sending over individual tiles (ie. resources) - // that are then composited by the browser. - [Sync] - SetSharedMemory(mojo_base.mojom.WritableSharedMemoryRegion shm_region) => - (bool success, SyncCompositorCommonRendererParams result); - - // Synchronously does a software based draw. - [Sync] DemandDrawSw(SyncCompositorDemandDrawSwParams draw_params) => - (SyncCompositorCommonRendererParams result, - uint32 metadata_version, - viz.mojom.CompositorFrameMetadata? meta_data); - - // Instead of drawing, allow the compositor to finish the frame and update - // tiles if needed. - WillSkipDraw(); - - // Zero out the shared memory. This is necessary since most of the time, - // viewport size doesn't change between draws, it's cheaper to zero out - // and reuse the shared memory, instead of allocating and mapping a new - // one each frame. - ZeroSharedMemory(); - - // Synchronously zoom by adjusting the page scale factor by delta around - // the anchor point. - [Sync] ZoomBy(float delta, gfx.mojom.Point anchor) => - (SyncCompositorCommonRendererParams result); - - // Adjust the memory policy of the compositor. Explicitly how much the - // compositor can use without changing visibility. ie. The limit on - // amount of memory used for caching tiles. - SetMemoryPolicy(uint32 bytes_limit); - - // Attempt to reclaim resources. - ReclaimResources(uint32 layer_tree_frame_sink_id, - array<viz.mojom.ReturnedResource> resources); - - // Adjust the scroll to the given offset. - SetScroll(gfx.mojom.ScrollOffset offset); - - // BeginFrame, update will be pushed via SynchronousCompositorControlHost - // BeginFrameResponse. - // |timing_details| is a map from frame token to FrameTimingDetails. - // Frame token is an incrementing id generated by untrusted viz client - // (renderer) and sent to viz service (browser) in a frame (see - // CompositorFrameMetadata). FrameTimingDetails contains info of viz server - // displaying frames, such as time of display. The index of the map is the - // frame token of the previously submitted frame that has been displayed. - // Note that the viz server might choose to skip display some of the - // previously submitted frames; however, feedback about all previously - // submitted frames will be sent back once a new frame is displayed. - BeginFrame(viz.mojom.BeginFrameArgs args, - map<uint32, viz.mojom.FrameTimingDetails> timing_details); - - // Indicates BeginFrame messages are paused. - SetBeginFrameSourcePaused(bool paused); -}; - -// Interface that runs on the UI thread of the browser. To be used -// for responses to most messages. -interface SynchronousCompositorHost { - // Indicates the layer tree was created. - LayerTreeFrameSinkCreated(); - - // Notification of new compositor information. - UpdateState(SyncCompositorCommonRendererParams params); - - // Notifies the that a begin frame is needed or not. - SetNeedsBeginFrames(bool needs_begin_frames); -}; - -// Interface that runs on the IO thread of the browser. To be used for responses -// to messages that need to wait for the response to be available before -// execution continues. Typically the browser UI thread will dispatch some -// messages asynchronously via the SynchronousCompositor interface but then -// reach a point at which a response must be available. For example the -// BeginFrame is sent to all attached WebViews but before the Android VSync -// execution flow (from java) returns the responses from BeginFrames must be -// received. -interface SynchronousCompositorControlHost { - // Response from DrawHwAsync. - ReturnFrame(uint32 layer_tree_frame_sink_id, - uint32 metadata_version, - viz.mojom.CompositorFrame? frame, - viz.mojom.HitTestRegionList? hit_test_region_list); - - // Response from BeginFrame. - BeginFrameResponse(SyncCompositorCommonRendererParams params); -}; diff --git a/chromium/content/common/input/synthetic_pointer_action_params.h b/chromium/content/common/input/synthetic_pointer_action_params.h index 87586800850..936c80e1815 100644 --- a/chromium/content/common/input/synthetic_pointer_action_params.h +++ b/chromium/content/common/input/synthetic_pointer_action_params.h @@ -5,11 +5,11 @@ #ifndef CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ #define CONTENT_COMMON_INPUT_SYNTHETIC_POINTER_ACTION_PARAMS_H_ -#include "base/logging.h" +#include "base/check_op.h" #include "content/common/content_export.h" #include "content/common/content_param_traits_macros.h" #include "content/common/input/synthetic_gesture_params.h" -#include "content/common/input/synthetic_web_input_event_builders.h" +#include "third_party/blink/public/common/input/web_mouse_event.h" #include "third_party/blink/public/common/input/web_touch_event.h" #include "ui/gfx/geometry/point_f.h" diff --git a/chromium/content/common/input/synthetic_web_input_event_builders.cc b/chromium/content/common/input/synthetic_web_input_event_builders.cc deleted file mode 100644 index 785640f90b7..00000000000 --- a/chromium/content/common/input/synthetic_web_input_event_builders.cc +++ /dev/null @@ -1,282 +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/synthetic_web_input_event_builders.h" - -#include "base/check_op.h" -#include "content/common/input/web_mouse_wheel_event_traits.h" -#include "content/common/input/web_touch_event_traits.h" -#include "ui/events/base_event_utils.h" -#include "ui/events/event.h" -#include "ui/events/keycodes/keyboard_codes.h" - -namespace content { - -using blink::WebInputEvent; -using blink::WebKeyboardEvent; -using blink::WebGestureEvent; -using blink::WebMouseEvent; -using blink::WebMouseWheelEvent; -using blink::WebTouchEvent; -using blink::WebTouchPoint; - -WebMouseEvent SyntheticWebMouseEventBuilder::Build( - blink::WebInputEvent::Type type) { - return WebMouseEvent(type, WebInputEvent::kNoModifiers, - ui::EventTimeForNow()); -} - -WebMouseEvent SyntheticWebMouseEventBuilder::Build( - blink::WebInputEvent::Type type, - float window_x, - float window_y, - int modifiers, - blink::WebPointerProperties::PointerType pointer_type) { - DCHECK(WebInputEvent::IsMouseEventType(type)); - 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::kPointerIdMouse; - return result; -} - -WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build( - WebMouseWheelEvent::Phase phase) { - WebMouseWheelEvent result(WebInputEvent::Type::kMouseWheel, - WebInputEvent::kNoModifiers, ui::EventTimeForNow()); - result.phase = phase; - result.event_action = WebMouseWheelEventTraits::GetEventAction(result); - return result; -} - -WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build( - float x, - float y, - float dx, - float dy, - int modifiers, - ui::ScrollGranularity delta_units) { - return Build(x, y, 0, 0, dx, dy, modifiers, delta_units); -} - -WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build( - float x, - float y, - float global_x, - float global_y, - float dx, - float dy, - int modifiers, - ui::ScrollGranularity delta_units) { - WebMouseWheelEvent result(WebInputEvent::Type::kMouseWheel, modifiers, - ui::EventTimeForNow()); - result.SetPositionInScreen(global_x, global_y); - result.SetPositionInWidget(x, y); - result.delta_units = delta_units; - result.delta_x = dx; - result.delta_y = dy; - if (dx) - result.wheel_ticks_x = dx > 0.0f ? 1.0f : -1.0f; - if (dy) - result.wheel_ticks_y = dy > 0.0f ? 1.0f : -1.0f; - - result.event_action = WebMouseWheelEventTraits::GetEventAction(result); - return result; -} - -WebKeyboardEvent SyntheticWebKeyboardEventBuilder::Build( - WebInputEvent::Type type) { - DCHECK(WebInputEvent::IsKeyboardEventType(type)); - WebKeyboardEvent result(type, WebInputEvent::kNoModifiers, - ui::EventTimeForNow()); - result.windows_key_code = ui::VKEY_L; // non-null made up value. - return result; -} - -WebGestureEvent SyntheticWebGestureEventBuilder::Build( - WebInputEvent::Type type, - blink::WebGestureDevice source_device, - int modifiers) { - DCHECK(WebInputEvent::IsGestureEventType(type)); - WebGestureEvent result(type, modifiers, ui::EventTimeForNow(), source_device); - if (type == WebInputEvent::Type::kGestureTap || - type == WebInputEvent::Type::kGestureTapUnconfirmed || - type == WebInputEvent::Type::kGestureDoubleTap) { - result.data.tap.tap_count = 1; - result.data.tap.width = 10; - result.data.tap.height = 10; - } - - result.SetNeedsWheelEvent(result.IsTouchpadZoomEvent()); - - return result; -} - -WebGestureEvent SyntheticWebGestureEventBuilder::BuildScrollBegin( - float dx_hint, - float dy_hint, - blink::WebGestureDevice source_device, - int pointer_count) { - WebGestureEvent result = - Build(WebInputEvent::Type::kGestureScrollBegin, source_device); - result.data.scroll_begin.delta_x_hint = dx_hint; - result.data.scroll_begin.delta_y_hint = dy_hint; - result.data.scroll_begin.pointer_count = pointer_count; - return result; -} - -WebGestureEvent SyntheticWebGestureEventBuilder::BuildScrollUpdate( - float dx, - float dy, - int modifiers, - blink::WebGestureDevice source_device) { - WebGestureEvent result = Build(WebInputEvent::Type::kGestureScrollUpdate, - source_device, modifiers); - result.data.scroll_update.delta_x = dx; - result.data.scroll_update.delta_y = dy; - return result; -} - -WebGestureEvent SyntheticWebGestureEventBuilder::BuildPinchUpdate( - float scale, - float anchor_x, - float anchor_y, - int modifiers, - blink::WebGestureDevice source_device) { - WebGestureEvent result = - Build(WebInputEvent::Type::kGesturePinchUpdate, source_device, modifiers); - result.data.pinch_update.scale = scale; - result.SetPositionInWidget(gfx::PointF(anchor_x, anchor_y)); - result.SetPositionInScreen(gfx::PointF(anchor_x, anchor_y)); - return result; -} - -WebGestureEvent SyntheticWebGestureEventBuilder::BuildFling( - float velocity_x, - float velocity_y, - blink::WebGestureDevice source_device) { - WebGestureEvent result = - Build(WebInputEvent::Type::kGestureFlingStart, source_device); - result.data.fling_start.velocity_x = velocity_x; - result.data.fling_start.velocity_y = velocity_y; - return result; -} - -SyntheticWebTouchEvent::SyntheticWebTouchEvent() : WebTouchEvent() { - unique_touch_event_id = ui::GetNextTouchEventId(); - SetTimestamp(ui::EventTimeForNow()); - pointer_id_ = 0; -} - -void SyntheticWebTouchEvent::ResetPoints() { - int activePointCount = 0; - unsigned count = 0; - for (unsigned int i = 0; i < kTouchesLengthCap; ++i) { - switch (touches[i].state) { - case WebTouchPoint::State::kStatePressed: - case WebTouchPoint::State::kStateMoved: - case WebTouchPoint::State::kStateStationary: - touches[i].state = WebTouchPoint::State::kStateStationary; - ++activePointCount; - ++count; - break; - case WebTouchPoint::State::kStateReleased: - case WebTouchPoint::State::kStateCancelled: - touches[i] = WebTouchPoint(); - ++count; - break; - case WebTouchPoint::State::kStateUndefined: - break; - } - if (count >= touches_length) - break; - } - touches_length = activePointCount; - type_ = WebInputEvent::Type::kUndefined; - moved_beyond_slop_region = false; - unique_touch_event_id = ui::GetNextTouchEventId(); -} - -int SyntheticWebTouchEvent::PressPoint(float x, - float y, - float radius_x, - float radius_y, - float rotation_angle, - float force) { - int index = FirstFreeIndex(); - if (index == -1) - return -1; - WebTouchPoint& point = touches[index]; - point.id = pointer_id_++; - point.SetPositionInWidget(x, y); - point.SetPositionInScreen(x, y); - point.state = WebTouchPoint::State::kStatePressed; - point.radius_x = radius_x; - point.radius_y = radius_y; - point.rotation_angle = rotation_angle; - point.force = force; - point.tilt_x = point.tilt_y = 0; - point.pointer_type = blink::WebPointerProperties::PointerType::kTouch; - ++touches_length; - WebTouchEventTraits::ResetType(WebInputEvent::Type::kTouchStart, TimeStamp(), - this); - return index; -} - -void SyntheticWebTouchEvent::MovePoint(int index, - float x, - float y, - float radius_x, - float radius_y, - float rotation_angle, - float force) { - CHECK_GE(index, 0); - CHECK_LT(index, kTouchesLengthCap); - // Always set this bit to avoid otherwise unexpected touchmove suppression. - // The caller can opt-out explicitly, if necessary. - moved_beyond_slop_region = true; - WebTouchPoint& point = touches[index]; - point.SetPositionInWidget(x, y); - point.SetPositionInScreen(x, y); - point.state = WebTouchPoint::State::kStateMoved; - point.radius_x = radius_x; - point.radius_y = radius_y; - point.rotation_angle = rotation_angle; - point.force = force; - WebTouchEventTraits::ResetType(WebInputEvent::Type::kTouchMove, TimeStamp(), - this); -} - -void SyntheticWebTouchEvent::ReleasePoint(int index) { - CHECK_GE(index, 0); - CHECK_LT(index, kTouchesLengthCap); - touches[index].state = WebTouchPoint::State::kStateReleased; - touches[index].force = 0.f; - WebTouchEventTraits::ResetType(WebInputEvent::Type::kTouchEnd, TimeStamp(), - this); -} - -void SyntheticWebTouchEvent::CancelPoint(int index) { - CHECK_GE(index, 0); - CHECK_LT(index, kTouchesLengthCap); - touches[index].state = WebTouchPoint::State::kStateCancelled; - WebTouchEventTraits::ResetType(WebInputEvent::Type::kTouchCancel, TimeStamp(), - this); -} - -void SyntheticWebTouchEvent::SetTimestamp(base::TimeTicks timestamp) { - SetTimeStamp(timestamp); -} - -int SyntheticWebTouchEvent::FirstFreeIndex() { - for (size_t i = 0; i < kTouchesLengthCap; ++i) { - if (touches[i].state == WebTouchPoint::State::kStateUndefined) - return i; - } - return -1; -} - -} // namespace content diff --git a/chromium/content/common/input/synthetic_web_input_event_builders.h b/chromium/content/common/input/synthetic_web_input_event_builders.h deleted file mode 100644 index 42e46d3f4b2..00000000000 --- a/chromium/content/common/input/synthetic_web_input_event_builders.h +++ /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. - -#ifndef CONTENT_COMMON_INPUT_SYNTHETIC_WEB_INPUT_EVENT_BUILDERS_H_ -#define CONTENT_COMMON_INPUT_SYNTHETIC_WEB_INPUT_EVENT_BUILDERS_H_ - -#include "base/time/time.h" -#include "content/common/content_export.h" -#include "third_party/blink/public/common/input/web_gesture_event.h" -#include "third_party/blink/public/common/input/web_input_event.h" -#include "third_party/blink/public/common/input/web_keyboard_event.h" -#include "third_party/blink/public/common/input/web_mouse_wheel_event.h" -#include "third_party/blink/public/common/input/web_touch_event.h" -#include "ui/events/types/scroll_types.h" - -// Provides sensible creation of default WebInputEvents for testing purposes. - -namespace content { - -class CONTENT_EXPORT SyntheticWebMouseEventBuilder { - public: - static blink::WebMouseEvent Build(blink::WebInputEvent::Type type); - static blink::WebMouseEvent Build( - blink::WebInputEvent::Type type, - float window_x, - float window_y, - int modifiers, - blink::WebPointerProperties::PointerType pointer_type = - blink::WebPointerProperties::PointerType::kMouse); -}; - -class CONTENT_EXPORT SyntheticWebMouseWheelEventBuilder { - public: - static blink::WebMouseWheelEvent Build( - blink::WebMouseWheelEvent::Phase phase); - static blink::WebMouseWheelEvent Build(float x, - float y, - float dx, - float dy, - int modifiers, - ui::ScrollGranularity delta_units); - static blink::WebMouseWheelEvent Build(float x, - float y, - float global_x, - float global_y, - float dx, - float dy, - int modifiers, - ui::ScrollGranularity delta_units); -}; - -class CONTENT_EXPORT SyntheticWebKeyboardEventBuilder { - public: - static blink::WebKeyboardEvent Build(blink::WebInputEvent::Type type); -}; - -class CONTENT_EXPORT SyntheticWebGestureEventBuilder { - public: - static blink::WebGestureEvent Build(blink::WebInputEvent::Type type, - blink::WebGestureDevice source_device, - int modifiers = 0); - static blink::WebGestureEvent BuildScrollBegin( - float dx_hint, - float dy_hint, - blink::WebGestureDevice source_device, - int pointer_count = 1); - static blink::WebGestureEvent BuildScrollUpdate( - float dx, - float dy, - int modifiers, - blink::WebGestureDevice source_device); - static blink::WebGestureEvent BuildPinchUpdate( - float scale, - float anchor_x, - float anchor_y, - int modifiers, - blink::WebGestureDevice source_device); - static blink::WebGestureEvent BuildFling( - float velocity_x, - float velocity_y, - blink::WebGestureDevice source_device); -}; - -class CONTENT_EXPORT SyntheticWebTouchEvent : public blink::WebTouchEvent { - public: - SyntheticWebTouchEvent(); - - // Mark all the points as stationary, and remove any released points. - void ResetPoints(); - - // Adds an additional point to the touch list, returning the point's index. - int PressPoint(float x, - float y, - float radius_x = 20.f, - float radius_y = 20.f, - float rotation_angle = 0.f, - float force = 1.f); - void MovePoint(int index, - float x, - float y, - float radius_x = 20.f, - float radius_y = 20.f, - float rotation_angle = 0.f, - float force = 1.f); - void ReleasePoint(int index); - void CancelPoint(int index); - - void SetTimestamp(base::TimeTicks timestamp); - - int FirstFreeIndex(); - - private: - // A pointer id of each touch pointer. Every time when a pointer is pressed - // the screen, it will be assigned to a new pointer id. - unsigned pointer_id_; -}; - -} // namespace content - -#endif // CONTENT_COMMON_INPUT_SYNTHETIC_WEB_INPUT_EVENT_BUILDERS_H_ diff --git a/chromium/content/common/input/synthetic_web_input_event_builders_unittest.cc b/chromium/content/common/input/synthetic_web_input_event_builders_unittest.cc deleted file mode 100644 index 49a034c65e1..00000000000 --- a/chromium/content/common/input/synthetic_web_input_event_builders_unittest.cc +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2018 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/synthetic_web_input_event_builders.h" -#include "content/common/input/web_touch_event_traits.h" -#include "testing/gtest/include/gtest/gtest.h" - -using blink::WebInputEvent; -using blink::WebTouchEvent; -using blink::WebTouchPoint; - -namespace content { - -TEST(SyntheticWebInputEventBuilders, BuildWebTouchEvent) { - SyntheticWebTouchEvent event; - - event.PressPoint(1, 2); - EXPECT_EQ(1U, event.touches_length); - EXPECT_EQ(0, event.touches[0].id); - EXPECT_EQ(WebTouchPoint::State::kStatePressed, event.touches[0].state); - EXPECT_EQ(gfx::PointF(1, 2), event.touches[0].PositionInWidget()); - event.ResetPoints(); - - event.PressPoint(3, 4); - EXPECT_EQ(2U, event.touches_length); - EXPECT_EQ(1, event.touches[1].id); - EXPECT_EQ(WebTouchPoint::State::kStatePressed, event.touches[1].state); - EXPECT_EQ(gfx::PointF(3, 4), event.touches[1].PositionInWidget()); - event.ResetPoints(); - - event.MovePoint(1, 5, 6); - EXPECT_EQ(2U, event.touches_length); - EXPECT_EQ(1, event.touches[1].id); - EXPECT_EQ(WebTouchPoint::State::kStateMoved, event.touches[1].state); - EXPECT_EQ(gfx::PointF(5, 6), event.touches[1].PositionInWidget()); - event.ResetPoints(); - - event.ReleasePoint(0); - EXPECT_EQ(2U, event.touches_length); - EXPECT_EQ(0, event.touches[0].id); - EXPECT_EQ(WebTouchPoint::State::kStateReleased, event.touches[0].state); - event.ResetPoints(); - - event.MovePoint(1, 7, 8); - EXPECT_EQ(1U, event.touches_length); - EXPECT_EQ(1, event.touches[1].id); - EXPECT_EQ(WebTouchPoint::State::kStateMoved, event.touches[1].state); - EXPECT_EQ(gfx::PointF(7, 8), event.touches[1].PositionInWidget()); - EXPECT_EQ(WebTouchPoint::State::kStateUndefined, event.touches[0].state); - event.ResetPoints(); - - event.PressPoint(9, 10); - EXPECT_EQ(2U, event.touches_length); - EXPECT_EQ(2, event.touches[0].id); - EXPECT_EQ(WebTouchPoint::State::kStatePressed, event.touches[0].state); - EXPECT_EQ(gfx::PointF(9, 10), event.touches[0].PositionInWidget()); -} - -} // namespace content diff --git a/chromium/content/common/input/touch_event_stream_validator_unittest.cc b/chromium/content/common/input/touch_event_stream_validator_unittest.cc index d8ce67bd0b9..647aef72225 100644 --- a/chromium/content/common/input/touch_event_stream_validator_unittest.cc +++ b/chromium/content/common/input/touch_event_stream_validator_unittest.cc @@ -6,9 +6,9 @@ #include <stddef.h> -#include "content/common/input/synthetic_web_input_event_builders.h" #include "content/common/input/web_touch_event_traits.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/public/common/input/synthetic_web_input_event_builders.h" using blink::WebInputEvent; using blink::WebTouchEvent; @@ -18,7 +18,7 @@ namespace content { TEST(TouchEventStreamValidator, ValidTouchStream) { TouchEventStreamValidator validator; - SyntheticWebTouchEvent event; + blink::SyntheticWebTouchEvent event; std::string error_msg; event.PressPoint(0, 1); @@ -58,7 +58,7 @@ TEST(TouchEventStreamValidator, ValidTouchStream) { TEST(TouchEventStreamValidator, ResetOnNewTouchStream) { TouchEventStreamValidator validator; - SyntheticWebTouchEvent event; + blink::SyntheticWebTouchEvent event; std::string error_msg; event.PressPoint(0, 1); @@ -75,7 +75,7 @@ TEST(TouchEventStreamValidator, ResetOnNewTouchStream) { TEST(TouchEventStreamValidator, MissedTouchStart) { TouchEventStreamValidator validator; - SyntheticWebTouchEvent event; + blink::SyntheticWebTouchEvent event; std::string error_msg; event.PressPoint(0, 1); @@ -91,7 +91,7 @@ TEST(TouchEventStreamValidator, MissedTouchStart) { TEST(TouchEventStreamValidator, MissedTouchEnd) { TouchEventStreamValidator validator; - SyntheticWebTouchEvent event; + blink::SyntheticWebTouchEvent event; std::string error_msg; event.PressPoint(0, 1); @@ -152,7 +152,7 @@ TEST(TouchEventStreamValidator, InvalidPointStates) { WebTouchPoint::State::kStateCancelled, }; - SyntheticWebTouchEvent start; + blink::SyntheticWebTouchEvent start; start.PressPoint(0, 0); for (size_t i = 0; i < 4; ++i) { // Always start with a touchstart to reset the stream validation. diff --git a/chromium/content/common/input/web_mouse_wheel_event_traits.cc b/chromium/content/common/input/web_mouse_wheel_event_traits.cc deleted file mode 100644 index 73d1c4eb87a..00000000000 --- a/chromium/content/common/input/web_mouse_wheel_event_traits.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2018 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/web_mouse_wheel_event_traits.h" - -#include "third_party/blink/public/common/input/web_input_event.h" - -namespace content { - -using blink::WebInputEvent; - -// static -blink::WebMouseWheelEvent::EventAction WebMouseWheelEventTraits::GetEventAction( - const blink::WebMouseWheelEvent& event) { -#if defined(USE_AURA) - // Scroll events generated from the mouse wheel when the control key is held - // don't trigger scrolling. Instead, they may cause zooming. - if (event.delta_units != ui::ScrollGranularity::kScrollByPrecisePixel && - (event.GetModifiers() & WebInputEvent::kControlKey)) { - return blink::WebMouseWheelEvent::EventAction::kPageZoom; - } - - if (event.delta_x == 0 && (event.GetModifiers() & WebInputEvent::kShiftKey)) - return blink::WebMouseWheelEvent::EventAction::kScrollHorizontal; -#endif - if (event.rails_mode == WebInputEvent::kRailsModeHorizontal || - (event.delta_x != 0 && event.delta_y == 0)) { - return blink::WebMouseWheelEvent::EventAction::kScrollHorizontal; - } - - if (event.rails_mode == WebInputEvent::kRailsModeVertical || - (event.delta_x == 0 && event.delta_y != 0)) { - return blink::WebMouseWheelEvent::EventAction::kScrollVertical; - } - - return blink::WebMouseWheelEvent::EventAction::kScroll; -} - -} // namespace content diff --git a/chromium/content/common/input/web_mouse_wheel_event_traits.h b/chromium/content/common/input/web_mouse_wheel_event_traits.h deleted file mode 100644 index 45fe2a8e6ad..00000000000 --- a/chromium/content/common/input/web_mouse_wheel_event_traits.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2018 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. - -#ifndef CONTENT_COMMON_INPUT_WEB_MOUSE_WHEEL_EVENT_TRAITS_H_ -#define CONTENT_COMMON_INPUT_WEB_MOUSE_WHEEL_EVENT_TRAITS_H_ - -#include "base/macros.h" -#include "content/common/content_export.h" -#include "third_party/blink/public/common/input/web_mouse_wheel_event.h" - -namespace content { - -// Utility class for performing operations on and with WebMouseWheelEvent. -class CONTENT_EXPORT WebMouseWheelEventTraits { - public: - // Returns the *platform specific* event action corresponding with the wheel - // event. - static blink::WebMouseWheelEvent::EventAction GetEventAction( - const blink::WebMouseWheelEvent& event); - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(WebMouseWheelEventTraits); -}; - -} // namespace content - -#endif // CONTENT_COMMON_INPUT_WEB_MOUSE_WHEEL_EVENT_TRAITS_H_ |