Commit f13f9711 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Move definition of WebInputEvent enums into mojo.

Define GestureDevice, InertialPhaseState, Button, DispatchType
in mojom. This allows the removal of the typemappings.
TBR=avi@chromium.org

Change-Id: Iefe74aebbb49d3155c8cc2f36282575d0b879276
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2152777
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760204}
parent 5706dec1
......@@ -570,14 +570,6 @@ mojom("mojo_bindings") {
},
{
types = [
{
mojom = "content.mojom.Button"
cpp = "::blink::WebPointerProperties::Button"
},
{
mojom = "content.mojom.Cancelability"
cpp = "::blink::WebInputEvent::DispatchType"
},
{
mojom = "content.mojom.ContentSecurityPolicy"
cpp = "::content::ContentSecurityPolicy"
......@@ -603,14 +595,6 @@ mojom("mojo_bindings") {
mojom = "content.mojom.FrameReplicationState"
cpp = "::content::FrameReplicationState"
},
{
mojom = "content.mojom.GestureDevice"
cpp = "::blink::WebGestureDevice"
},
{
mojom = "content.mojom.InertialPhaseState"
cpp = "::blink::WebGestureEvent::InertialPhaseState"
},
{
mojom = "content.mojom.InputEventAckSource"
cpp = "::content::InputEventAckSource"
......@@ -693,8 +677,6 @@ mojom("mojo_bindings") {
"//content/public/common/input_event_ack_state.h",
"//content/public/common/web_preferences.h",
"//net/base/network_change_notifier.h",
"//third_party/blink/public/common/input/web_gesture_device.h",
"//third_party/blink/public/common/input/web_gesture_event.h",
"//third_party/blink/public/common/input/web_input_event.h",
"//third_party/blink/public/common/input/web_mouse_wheel_event.h",
"//third_party/blink/public/common/input/web_pointer_properties.h",
......
......@@ -9,6 +9,8 @@ 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/pointer_lock_result.mojom";
import "third_party/blink/public/mojom/selection_menu/selection_menu_behavior.mojom";
import "ui/base/ime/mojom/ime_types.mojom";
......@@ -46,7 +48,7 @@ struct PointerData {
int32 tilt_y;
float tangential_pressure;
int32 twist;
Button button;
blink.mojom.Button button;
PointerType pointer_type;
int32 movement_x;
int32 movement_y;
......@@ -65,7 +67,7 @@ struct WheelData {
float acceleration_ratio_y;
uint8 phase;
uint8 momentum_phase;
Cancelability cancelable;
blink.mojom.DispatchType cancelable;
uint8 event_action;
uint8 delta_units;
};
......@@ -85,7 +87,7 @@ struct ScrollData {
float delta_y;
ui.mojom.ScrollGranularity delta_units;
bool target_viewport;
InertialPhaseState inertial_phase;
blink.mojom.InertialPhaseState inertial_phase;
bool synthetic;
int32 pointer_count;
ScrollUpdate? update_details;
......@@ -120,7 +122,7 @@ struct TapData {
struct GestureData {
gfx.mojom.PointF screen_position;
gfx.mojom.PointF widget_position;
GestureDevice source_device;
blink.mojom.GestureDevice source_device;
bool is_source_touch_event_set_non_blocking;
PointerType primary_pointer_type;
int32 unique_touch_event_id;
......@@ -142,7 +144,7 @@ struct TouchPoint {
};
struct TouchData {
Cancelability cancelable;
blink.mojom.DispatchType cancelable;
bool moved_beyond_slop_region;
bool touch_start_or_first_move;
bool hovering;
......
......@@ -59,17 +59,8 @@ IPC_ENUM_TRAITS_MAX_VALUE(
content::SyntheticPointerActionParams::Button::BUTTON_MAX)
IPC_ENUM_TRAITS_MAX_VALUE(content::InputEventDispatchType,
content::InputEventDispatchType::DISPATCH_TYPE_MAX)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::WebPointerProperties::Button,
blink::WebPointerProperties::Button::kNoButton,
blink::WebPointerProperties::Button::kMaxValue)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebPointerProperties::PointerType,
blink::WebPointerProperties::PointerType::kMaxValue)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebGestureDevice,
blink::WebGestureDevice::kMaxValue)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebInputEvent::DispatchType,
blink::WebInputEvent::DispatchType::kLastDispatchType)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebGestureEvent::InertialPhaseState,
blink::WebGestureEvent::InertialPhaseState::kMaxValue)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebTouchPoint::State,
blink::WebTouchPoint::State::kStateMax)
IPC_ENUM_TRAITS_MAX_VALUE(
......
......@@ -40,9 +40,6 @@ enum NetworkConnectionType;
[Native]
struct WebCursor;
[Native]
enum Button;
[Native]
enum PointerType;
......@@ -58,15 +55,6 @@ enum InputEventAckSource;
[Native]
enum EventType;
[Native]
enum Cancelability;
[Native]
enum GestureDevice;
[Native]
enum InertialPhaseState;
[Native]
enum TouchState;
......
......@@ -26,23 +26,13 @@
#ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_INPUT_WEB_GESTURE_DEVICE_H_
#define THIRD_PARTY_BLINK_PUBLIC_COMMON_INPUT_WEB_GESTURE_DEVICE_H_
namespace blink {
enum class WebGestureDevice {
kUninitialized,
kTouchpad,
kTouchscreen,
kSyntheticAutoscroll,
#include "third_party/blink/public/mojom/input/gesture_event.mojom-shared.h"
// This is the device type used when generating synthetic gesture scrolls for
// compositor thread scrollbar scrolling. Please refer to
// ui::InputHandlerProxy::InjectScrollbarGestureScroll to see how this is
// consumed. Explainer:
// https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/master/Scrolling/ImplScrollbars/dev-diagram.md
kScrollbar,
namespace blink {
kMaxValue = kScrollbar,
};
// TODO(dtapuska): Eventually remove all usage of this file.
// Just alias this for now to minimize changes to other files.
using WebGestureDevice = mojom::GestureDevice;
} // namespace blink
......
......@@ -9,6 +9,7 @@
#include "third_party/blink/public/common/input/web_gesture_device.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/common/input/web_pointer_properties.h"
#include "third_party/blink/public/mojom/input/gesture_event.mojom-shared.h"
#include "ui/events/types/scroll_types.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/size_f.h"
......@@ -19,12 +20,7 @@ namespace blink {
class BLINK_COMMON_EXPORT WebGestureEvent : public WebInputEvent {
public:
enum class InertialPhaseState : uint8_t {
kUnknownMomentum = 0, // No phase information.
kNonMomentum, // Regular scrolling phase.
kMomentum, // Momentum phase.
kMaxValue = kMomentum,
};
using InertialPhaseState = mojom::InertialPhaseState;
bool is_source_touch_event_set_non_blocking = false;
......@@ -32,12 +28,13 @@ class BLINK_COMMON_EXPORT WebGestureEvent : public WebInputEvent {
WebPointerProperties::PointerType primary_pointer_type =
WebPointerProperties::PointerType::kUnknown;
// If the WebGestureEvent has source_device == WebGestureDevice::kTouchscreen,
// this field contains the unique identifier for the touch event that released
// this event at TouchDispositionGestureFilter. If the WebGestureEvents was
// not released through a touch event (e.g. timer-released gesture events or
// gesture events with source_device != WebGestureDevice::kTouchscreen), the
// field contains 0. See crbug.com/618738.
// If the WebGestureEvent has source_device ==
// mojom::GestureDevice::kTouchscreen, this field contains the unique
// identifier for the touch event that released this event at
// TouchDispositionGestureFilter. If the WebGestureEvents was not released
// through a touch event (e.g. timer-released gesture events or gesture events
// with source_device != mojom::GestureDevice::kTouchscreen), the field
// contains 0. See crbug.com/618738.
uint32_t unique_touch_event_id = 0;
union {
......@@ -180,13 +177,14 @@ class BLINK_COMMON_EXPORT WebGestureEvent : public WebInputEvent {
// Screen coordinate
gfx::PointF position_in_screen_;
WebGestureDevice source_device_ = WebGestureDevice::kUninitialized;
mojom::GestureDevice source_device_ = mojom::GestureDevice::kUninitialized;
public:
WebGestureEvent(Type type,
int modifiers,
base::TimeTicks time_stamp,
WebGestureDevice device = WebGestureDevice::kUninitialized)
WebGestureEvent(
Type type,
int modifiers,
base::TimeTicks time_stamp,
mojom::GestureDevice device = mojom::GestureDevice::kUninitialized)
: WebInputEvent(type, modifiers, time_stamp), source_device_(device) {
memset(&data, 0, sizeof(data));
}
......@@ -206,8 +204,8 @@ class BLINK_COMMON_EXPORT WebGestureEvent : public WebInputEvent {
position_in_screen_ = point;
}
WebGestureDevice SourceDevice() const { return source_device_; }
void SetSourceDevice(WebGestureDevice device) { source_device_ = device; }
mojom::GestureDevice SourceDevice() const { return source_device_; }
void SetSourceDevice(mojom::GestureDevice device) { source_device_ = device; }
float DeltaXInRootFrame() const;
float DeltaYInRootFrame() const;
......@@ -270,7 +268,7 @@ class BLINK_COMMON_EXPORT WebGestureEvent : public WebInputEvent {
bool IsTouchpadZoomEvent() const {
// Touchpad GestureDoubleTap also causes a page scale change like a touchpad
// pinch gesture.
return source_device_ == WebGestureDevice::kTouchpad &&
return source_device_ == mojom::GestureDevice::kTouchpad &&
(WebInputEvent::IsPinchGestureEventType(type_) ||
type_ == kGestureDoubleTap);
}
......
......@@ -37,6 +37,7 @@
#include "base/time/time.h"
#include "third_party/blink/public/common/common_export.h"
#include "third_party/blink/public/mojom/input/input_event.mojom-shared.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/vector2d_f.h"
......@@ -265,23 +266,7 @@ class BLINK_COMMON_EXPORT WebInputEvent {
kNoModifiers = 0,
};
// Indicates whether the browser needs to block on the ACK result for
// this event, and if not, why (for metrics/diagnostics purposes).
// These values are direct mappings of the values in PlatformEvent
// so the values can be cast between the enumerations. static_asserts
// checking this are in web/WebInputEventConversion.cpp.
enum DispatchType {
// Event can be canceled.
kBlocking,
// Event can not be canceled.
kEventNonBlocking,
// All listeners are passive; not cancelable.
kListenersNonBlockingPassive,
// This value represents a state which would have normally blocking
// but was forced to be non-blocking during fling; not cancelable.
kListenersForcedNonBlockingDueToFling,
kLastDispatchType = kListenersForcedNonBlockingDueToFling,
};
using DispatchType = mojom::DispatchType;
// The rail mode for a wheel event specifies the axis on which scrolling is
// expected to stick. If this axis is set to Free, then scrolling is not
......
......@@ -7,6 +7,7 @@
#include "third_party/blink/public/common/common_export.h"
#include "third_party/blink/public/common/input/pointer_id.h"
#include "third_party/blink/public/mojom/input/input_event.mojom-shared.h"
#include "ui/gfx/geometry/point_f.h"
#include <limits>
......@@ -20,17 +21,7 @@ namespace blink {
// crbug.com/508283
class WebPointerProperties {
public:
enum class Button {
kNoButton = -1,
kLeft,
kMiddle,
kRight,
kBarrel = kRight, // Barrel is aliased per pointer event spec
kBack,
kForward,
kEraser,
kMaxValue = kEraser // Must be the last entry in the list
};
using Button = mojom::Button;
enum class Buttons : unsigned {
kNoButton = 0,
......
......@@ -72,6 +72,8 @@ mojom("mojom_platform") {
"idle/idle_manager.mojom",
"image_downloader/image_downloader.mojom",
"input/focus_type.mojom",
"input/gesture_event.mojom",
"input/input_event.mojom",
"input/pointer_lock_result.mojom",
"input/scroll_direction.mojom",
"insecure_input/insecure_input_service.mojom",
......
// Copyright 2020 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 blink.mojom;
// The type of gesture device generating the event.
enum GestureDevice {
kUninitialized,
kTouchpad,
kTouchscreen,
kSyntheticAutoscroll,
// This is the device type used when generating synthetic gesture scrolls for
// compositor thread scrollbar scrolling. Please refer to
// ui::InputHandlerProxy::InjectScrollbarGestureScroll to see how this is
// consumed. Explainer:
// https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/master/Scrolling/ImplScrollbars/dev-diagram.md
kScrollbar,
};
// The phase at which the current scrolling gesture is in.
enum InertialPhaseState {
kUnknownMomentum, // No phase information.
kNonMomentum, // Regular scrolling phase.
kMomentum, // Momentum phase.
};
// Copyright 2020 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 blink.mojom;
// Enumerates the different buttons on a pointing device.
enum Button {
kNoButton = -1,
kLeft,
kMiddle,
kRight,
kBarrel = kRight, // Barrel is aliased per pointer event spec
kBack,
kForward,
kEraser,
};
// Indicates whether the browser needs to block on the ACK result for
// this event, and if not, why (for metrics/diagnostics purposes).
enum DispatchType {
// Event can be canceled.
kBlocking,
// Event can not be canceled.
kEventNonBlocking,
// All listeners are passive; not cancelable.
kListenersNonBlockingPassive,
// This value represents a state which would have normally blocking
// but was forced to be non-blocking during fling; not cancelable.
kListenersForcedNonBlockingDueToFling,
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment