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