Commit f4a59ec8 authored by Mustaq Ahmed's avatar Mustaq Ahmed Committed by Chromium LUCI CQ

[CodeHealth] Cleanup MouseEvent and PointerEvent code.

Remove unused parameters, enums, methods/destructors.

Change-Id: I4d42cb9be7f76586fa66ed13a5a2927307e11ca2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2598221Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842056}
parent 5c07f3fe
......@@ -60,14 +60,11 @@ Event* CreateEvent(const AtomicString& event_type,
SimulatedClickCreationScope creation_scope) {
DCHECK(event_type == event_type_names::kClick ||
event_type == event_type_names::kMousedown ||
event_type == event_type_names::kMouseup ||
event_type == event_type_names::kMouseover);
event_type == event_type_names::kMouseup);
if (RuntimeEnabledFeatures::ClickPointerEventEnabled() &&
event_type == event_type_names::kClick) {
// TODO (crbug.com/1150979) Figure out if we can fire pointer events
// instead of mousedown/mouseup/mouseover or if we need to fire both pointer
// events and mouse events at the same time. The mouse events are used for
// accessibility.
// TODO(crbug.com/1150979): Should we also fire pointer events for
// mousedown/mouseup events? These mouse events are used for accessibility.
return PointerEvent::Create(event_type_names::kClick,
node.GetDocument().domWindow(),
underlying_event, creation_scope);
......@@ -122,12 +119,6 @@ void EventDispatcher::DispatchSimulatedClick(
nodes_dispatching_simulated_clicks->insert(&node);
if (mouse_event_options == kSendMouseOverUpDownEvents) {
EventDispatcher(node, *CreateEvent(event_type_names::kMouseover, node,
underlying_event, creation_scope))
.Dispatch();
}
Element* element = DynamicTo<Element>(node);
if (mouse_event_options != kSendNoEvents) {
EventDispatcher(node, *CreateEvent(event_type_names::kMousedown, node,
......
......@@ -23,11 +23,7 @@
namespace blink {
enum SimulatedClickMouseEventOptions {
kSendNoEvents,
kSendMouseUpDownEvents,
kSendMouseOverUpDownEvents
};
enum SimulatedClickMouseEventOptions { kSendNoEvents, kSendMouseUpDownEvents };
enum class SimulatedClickCreationScope { kFromScript, kFromUserAgent };
......
......@@ -132,7 +132,6 @@ void MouseEvent::PopulateMouseEventInit(
const AtomicString& event_type,
AbstractView* view,
const Event* underlying_event,
SimulatedClickCreationScope creation_scope,
MouseEventInit* initializer) {
WebInputEvent::Modifiers modifiers = WebInputEvent::kNoModifiers;
if (const UIEventWithKeyState* key_state_event =
......@@ -163,7 +162,7 @@ MouseEvent* MouseEvent::Create(const AtomicString& event_type,
SimulatedClickCreationScope creation_scope) {
MouseEventInit* initializer = MouseEventInit::Create();
MouseEvent::PopulateMouseEventInit(event_type, view, underlying_event,
creation_scope, initializer);
initializer);
SyntheticEventType synthetic_type = kPositionless;
if (const auto* mouse_event = DynamicTo<MouseEvent>(underlying_event)) {
synthetic_type = kRealOrIndistinguishable;
......@@ -269,8 +268,6 @@ void MouseEvent::SetCoordinatesFromWebPointerProperties(
}
}
MouseEvent::~MouseEvent() = default;
uint16_t MouseEvent::WebInputEventModifiersToButtons(unsigned modifiers) {
uint16_t buttons = 0;
......
......@@ -75,18 +75,14 @@ class CORE_EXPORT MouseEvent : public UIEventWithKeyState {
static void PopulateMouseEventInit(const AtomicString& event_type,
AbstractView* view,
const Event* underlying_event,
SimulatedClickCreationScope creation_scope,
MouseEventInit* initializer);
MouseEvent(const AtomicString& type,
const MouseEventInit*,
base::TimeTicks platform_time_stamp,
base::TimeTicks platform_time_stamp = base::TimeTicks::Now(),
SyntheticEventType = kRealOrIndistinguishable,
WebMenuSourceType = kMenuSourceNone);
MouseEvent(const AtomicString& type, const MouseEventInit* init)
: MouseEvent(type, init, base::TimeTicks::Now()) {}
MouseEvent();
~MouseEvent() override;
static uint16_t WebInputEventModifiersToButtons(unsigned modifiers);
static void SetCoordinatesFromWebPointerProperties(
......
......@@ -19,7 +19,7 @@ PointerEvent* PointerEvent::Create(const AtomicString& event_type,
SimulatedClickCreationScope creation_scope) {
PointerEventInit* initializer = PointerEventInit::Create();
MouseEvent::PopulateMouseEventInit(event_type, view, underlying_event,
creation_scope, initializer);
initializer);
base::TimeTicks timestamp = underlying_event
? underlying_event->PlatformTimeStamp()
: base::TimeTicks::Now();
......@@ -28,11 +28,10 @@ PointerEvent* PointerEvent::Create(const AtomicString& event_type,
synthetic_type = kRealOrIndistinguishable;
}
PointerEvent* created_event = MakeGarbageCollected<PointerEvent>(
event_type, initializer, timestamp, synthetic_type, kMenuSourceNone);
event_type, initializer, timestamp, synthetic_type);
created_event->SetTrusted(creation_scope ==
SimulatedClickCreationScope::kFromUserAgent);
created_event->SetUnderlyingEvent(underlying_event);
if (synthetic_type == kRealOrIndistinguishable) {
auto* mouse_event = To<MouseEvent>(created_event->UnderlyingEvent());
created_event->InitCoordinates(mouse_event->client_location_.X(),
......
......@@ -21,7 +21,7 @@ class CORE_EXPORT PointerEvent final : public MouseEvent {
static PointerEvent* Create(
const AtomicString& type,
const PointerEventInit* initializer,
base::TimeTicks platform_time_stamp,
base::TimeTicks platform_time_stamp = base::TimeTicks::Now(),
MouseEvent::SyntheticEventType synthetic_event_type =
kRealOrIndistinguishable,
WebMenuSourceType menu_source_type = kMenuSourceNone) {
......@@ -29,11 +29,6 @@ class CORE_EXPORT PointerEvent final : public MouseEvent {
type, initializer, platform_time_stamp, synthetic_event_type,
menu_source_type);
}
static PointerEvent* Create(const AtomicString& type,
const PointerEventInit* initializer) {
return PointerEvent::Create(type, initializer, base::TimeTicks::Now());
}
static PointerEvent* Create(const AtomicString& event_type,
AbstractView*,
const Event* underlying_event,
......@@ -43,7 +38,7 @@ class CORE_EXPORT PointerEvent final : public MouseEvent {
const PointerEventInit*,
base::TimeTicks platform_time_stamp,
MouseEvent::SyntheticEventType synthetic_event_type,
WebMenuSourceType menu_source_type);
WebMenuSourceType menu_source_type = kMenuSourceNone);
PointerId pointerId() const { return pointer_id_; }
double width() const { return width_; }
......
......@@ -9,6 +9,7 @@
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
namespace blink {
class CORE_EXPORT PointerEventUtil {
public:
PointerEventUtil() = delete;
......@@ -31,6 +32,7 @@ class CORE_EXPORT PointerEventUtil {
// altitude = altitude_radians - k*PI/2
static double TransformToAltitudeInValidRange(double altitude_radians);
};
} // namespace blink
#endif
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_EVENTS_POINTER_EVENT_UTIL_H_
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