Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1546)

Unified Diff: third_party/WebKit/Source/web/WebInputEventConversion.cpp

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/WebInputEventConversion.cpp
diff --git a/third_party/WebKit/Source/web/WebInputEventConversion.cpp b/third_party/WebKit/Source/web/WebInputEventConversion.cpp
index 8fb0a7e4020d757b35c12de850361604bbb929ab..f402f5be2e704dbb517d2d5e370bf9e81f05726b 100644
--- a/third_party/WebKit/Source/web/WebInputEventConversion.cpp
+++ b/third_party/WebKit/Source/web/WebInputEventConversion.cpp
@@ -201,14 +201,14 @@ PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget,
m_globalPosition = IntPoint(e.globalX, e.globalY);
m_movementDelta = IntPoint(scaleDeltaToWindow(widget, e.movementX),
scaleDeltaToWindow(widget, e.movementY));
- m_modifiers = e.modifiers;
+ m_modifiers = e.modifiers();
- m_timestamp = e.timeStampSeconds;
+ m_timestamp = e.timeStampSeconds();
m_clickCount = e.clickCount;
m_pointerProperties = static_cast<WebPointerProperties>(e);
- switch (e.type) {
+ switch (e.type()) {
case WebInputEvent::MouseMove:
case WebInputEvent::MouseEnter: // synthesize a move event
case WebInputEvent::MouseLeave: // synthesize a move event
@@ -251,8 +251,8 @@ PlatformWheelEventBuilder::PlatformWheelEventBuilder(
m_type = PlatformEvent::Wheel;
- m_timestamp = e.timeStampSeconds;
- m_modifiers = e.modifiers;
+ m_timestamp = e.timeStampSeconds();
+ m_modifiers = e.modifiers();
m_dispatchType = toPlatformDispatchType(e.dispatchType);
m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas;
@@ -269,7 +269,7 @@ PlatformWheelEventBuilder::PlatformWheelEventBuilder(
PlatformGestureEventBuilder::PlatformGestureEventBuilder(
Widget* widget,
const WebGestureEvent& e) {
- switch (e.type) {
+ switch (e.type()) {
case WebInputEvent::GestureScrollBegin:
m_type = PlatformEvent::GestureScrollBegin;
m_data.m_scroll.m_resendingPluginId = e.resendingPluginId;
@@ -375,8 +375,8 @@ PlatformGestureEventBuilder::PlatformGestureEventBuilder(
m_position = widget->convertFromRootFrame(flooredIntPoint(
convertHitPointToRootFrame(widget, FloatPoint(e.x, e.y))));
m_globalPosition = IntPoint(e.globalX, e.globalY);
- m_timestamp = e.timeStampSeconds;
- m_modifiers = e.modifiers;
+ m_timestamp = e.timeStampSeconds();
+ m_modifiers = e.modifiers();
switch (e.sourceDevice) {
case WebGestureDeviceTouchpad:
m_source = PlatformGestureSourceTouchpad;
@@ -461,9 +461,9 @@ PlatformTouchPointBuilder::PlatformTouchPointBuilder(
PlatformTouchEventBuilder::PlatformTouchEventBuilder(
Widget* widget,
const WebTouchEvent& event) {
- m_type = toPlatformTouchEventType(event.type);
- m_modifiers = event.modifiers;
- m_timestamp = event.timeStampSeconds;
+ m_type = toPlatformTouchEventType(event.type());
+ m_modifiers = event.modifiers();
+ m_timestamp = event.timeStampSeconds();
m_causesScrollingIfUncanceled = event.movedBeyondSlopRegion;
m_touchStartOrFirstTouchMove = event.touchStartOrFirstTouchMove;
@@ -494,9 +494,6 @@ static void updateWebMouseEventFromCoreMouseEvent(
const Widget* widget,
const LayoutItem layoutItem,
WebMouseEvent& webEvent) {
- webEvent.timeStampSeconds = event.platformTimeStamp();
- webEvent.modifiers = event.modifiers();
-
FrameView* view = widget ? toFrameView(widget->parent()) : 0;
// TODO(bokan): If view == nullptr, pointInRootFrame will really be
// pointInRootContent.
@@ -518,20 +515,22 @@ WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget,
const LayoutItem layoutItem,
const MouseEvent& event) {
if (event.type() == EventTypeNames::mousemove)
- type = WebInputEvent::MouseMove;
+ m_type = WebInputEvent::MouseMove;
else if (event.type() == EventTypeNames::mouseout)
- type = WebInputEvent::MouseLeave;
+ m_type = WebInputEvent::MouseLeave;
else if (event.type() == EventTypeNames::mouseover)
- type = WebInputEvent::MouseEnter;
+ m_type = WebInputEvent::MouseEnter;
else if (event.type() == EventTypeNames::mousedown)
- type = WebInputEvent::MouseDown;
+ m_type = WebInputEvent::MouseDown;
else if (event.type() == EventTypeNames::mouseup)
- type = WebInputEvent::MouseUp;
+ m_type = WebInputEvent::MouseUp;
else if (event.type() == EventTypeNames::contextmenu)
- type = WebInputEvent::ContextMenu;
+ m_type = WebInputEvent::ContextMenu;
else
return; // Skip all other mouse events.
+ m_timeStampSeconds = event.platformTimeStamp();
+ m_modifiers = event.modifiers();
updateWebMouseEventFromCoreMouseEvent(event, widget, layoutItem, *this);
switch (event.button()) {
@@ -548,13 +547,13 @@ WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget,
if (event.buttonDown()) {
switch (event.button()) {
case short(WebPointerProperties::Button::Left):
- modifiers |= WebInputEvent::LeftButtonDown;
+ m_modifiers |= WebInputEvent::LeftButtonDown;
break;
case short(WebPointerProperties::Button::Middle):
- modifiers |= WebInputEvent::MiddleButtonDown;
+ m_modifiers |= WebInputEvent::MiddleButtonDown;
break;
case short(WebPointerProperties::Button::Right):
- modifiers |= WebInputEvent::RightButtonDown;
+ m_modifiers |= WebInputEvent::RightButtonDown;
break;
}
} else {
@@ -589,16 +588,16 @@ WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget,
return;
if (event.type() == EventTypeNames::touchstart)
- type = MouseDown;
+ m_type = MouseDown;
else if (event.type() == EventTypeNames::touchmove)
- type = MouseMove;
+ m_type = MouseMove;
else if (event.type() == EventTypeNames::touchend)
- type = MouseUp;
+ m_type = MouseUp;
else
return;
- timeStampSeconds = event.platformTimeStamp();
- modifiers = event.modifiers();
+ m_timeStampSeconds = event.platformTimeStamp();
+ m_modifiers = event.modifiers();
// The mouse event co-ordinates should be generated from the co-ordinates of
// the touch point.
@@ -615,8 +614,8 @@ WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget,
windowY = pointInRootFrame.y();
button = WebMouseEvent::Button::Left;
- modifiers |= WebInputEvent::LeftButtonDown;
- clickCount = (type == MouseDown || type == MouseUp);
+ m_modifiers |= WebInputEvent::LeftButtonDown;
+ clickCount = (m_type == MouseDown || m_type == MouseUp);
IntPoint localPoint = convertAbsoluteLocationForLayoutObjectInt(
DoublePoint(touch->absoluteLocation()), layoutItem);
@@ -633,7 +632,9 @@ WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(
if (event.type() != EventTypeNames::wheel &&
event.type() != EventTypeNames::mousewheel)
return;
- type = WebInputEvent::MouseWheel;
+ m_type = WebInputEvent::MouseWheel;
+ m_timeStampSeconds = event.platformTimeStamp();
+ m_modifiers = event.modifiers();
updateWebMouseEventFromCoreMouseEvent(event, widget, layoutItem, *this);
deltaX = -event.deltaX();
deltaY = -event.deltaY();
@@ -657,22 +658,22 @@ WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event) {
// TODO(dtapuska): DOM KeyboardEvents converted back to WebInputEvents
// drop the Raw behaviour. Figure out if this is actually really needed.
- if (type == RawKeyDown)
- type = KeyDown;
+ if (m_type == RawKeyDown)
+ m_type = KeyDown;
return;
}
if (event.type() == EventTypeNames::keydown)
- type = KeyDown;
+ m_type = KeyDown;
else if (event.type() == EventTypeNames::keyup)
- type = WebInputEvent::KeyUp;
+ m_type = WebInputEvent::KeyUp;
else if (event.type() == EventTypeNames::keypress)
- type = WebInputEvent::Char;
+ m_type = WebInputEvent::Char;
else
return; // Skip all other keyboard events.
- modifiers = event.modifiers();
- timeStampSeconds = event.platformTimeStamp();
+ m_modifiers = event.modifiers();
+ m_timeStampSeconds = event.platformTimeStamp();
windowsKeyCode = event.keyCode();
}
@@ -733,21 +734,21 @@ static void addTouchPointsUpdateStateIfNecessary(
WebTouchEventBuilder::WebTouchEventBuilder(const LayoutItem layoutItem,
const TouchEvent& event) {
if (event.type() == EventTypeNames::touchstart)
- type = TouchStart;
+ m_type = TouchStart;
else if (event.type() == EventTypeNames::touchmove)
- type = TouchMove;
+ m_type = TouchMove;
else if (event.type() == EventTypeNames::touchend)
- type = TouchEnd;
+ m_type = TouchEnd;
else if (event.type() == EventTypeNames::touchcancel)
- type = TouchCancel;
+ m_type = TouchCancel;
else {
NOTREACHED();
- type = Undefined;
+ m_type = Undefined;
return;
}
- timeStampSeconds = event.platformTimeStamp();
- modifiers = event.modifiers();
+ m_timeStampSeconds = event.platformTimeStamp();
+ m_modifiers = event.modifiers();
dispatchType = event.cancelable() ? WebInputEvent::Blocking
: WebInputEvent::EventNonBlocking;
movedBeyondSlopRegion = event.causesScrollingIfUncanceled();
@@ -772,13 +773,13 @@ WebTouchEventBuilder::WebTouchEventBuilder(const LayoutItem layoutItem,
WebGestureEventBuilder::WebGestureEventBuilder(const LayoutItem layoutItem,
const GestureEvent& event) {
if (event.type() == EventTypeNames::gestureshowpress) {
- type = GestureShowPress;
+ m_type = GestureShowPress;
} else if (event.type() == EventTypeNames::gesturelongpress) {
- type = GestureLongPress;
+ m_type = GestureLongPress;
} else if (event.type() == EventTypeNames::gesturetapdown) {
- type = GestureTapDown;
+ m_type = GestureTapDown;
} else if (event.type() == EventTypeNames::gesturescrollstart) {
- type = GestureScrollBegin;
+ m_type = GestureScrollBegin;
resendingPluginId = event.resendingPluginId();
data.scrollBegin.deltaXHint = event.deltaX();
data.scrollBegin.deltaYHint = event.deltaY();
@@ -788,14 +789,14 @@ WebGestureEventBuilder::WebGestureEventBuilder(const LayoutItem layoutItem,
toWebGestureInertialPhaseState(event.inertialPhase());
data.scrollBegin.synthetic = event.synthetic();
} else if (event.type() == EventTypeNames::gesturescrollend) {
- type = GestureScrollEnd;
+ m_type = GestureScrollEnd;
resendingPluginId = event.resendingPluginId();
data.scrollEnd.deltaUnits = toWebGestureScrollUnits(event.deltaUnits());
data.scrollEnd.inertialPhase =
toWebGestureInertialPhaseState(event.inertialPhase());
data.scrollEnd.synthetic = event.synthetic();
} else if (event.type() == EventTypeNames::gesturescrollupdate) {
- type = GestureScrollUpdate;
+ m_type = GestureScrollUpdate;
data.scrollUpdate.deltaUnits = toWebGestureScrollUnits(event.deltaUnits());
data.scrollUpdate.deltaX = event.deltaX();
data.scrollUpdate.deltaY = event.deltaY();
@@ -803,16 +804,16 @@ WebGestureEventBuilder::WebGestureEventBuilder(const LayoutItem layoutItem,
toWebGestureInertialPhaseState(event.inertialPhase());
resendingPluginId = event.resendingPluginId();
} else if (event.type() == EventTypeNames::gestureflingstart) {
- type = GestureFlingStart;
+ m_type = GestureFlingStart;
data.flingStart.velocityX = event.velocityX();
data.flingStart.velocityY = event.velocityY();
} else if (event.type() == EventTypeNames::gesturetap) {
- type = GestureTap;
+ m_type = GestureTap;
data.tap.tapCount = 1;
}
- timeStampSeconds = event.platformTimeStamp();
- modifiers = event.modifiers();
+ m_timeStampSeconds = event.platformTimeStamp();
+ m_modifiers = event.modifiers();
globalX = event.screenX();
globalY = event.screenY();
@@ -838,7 +839,7 @@ Vector<PlatformMouseEvent> createPlatformMouseEventVector(
const std::vector<const WebInputEvent*>& coalescedEvents) {
Vector<PlatformMouseEvent> result;
for (const auto& event : coalescedEvents) {
- DCHECK(WebInputEvent::isMouseEventType(event->type));
+ DCHECK(WebInputEvent::isMouseEventType(event->type()));
result.append(PlatformMouseEventBuilder(
widget, static_cast<const WebMouseEvent&>(*event)));
}
@@ -850,7 +851,7 @@ Vector<PlatformTouchEvent> createPlatformTouchEventVector(
const std::vector<const WebInputEvent*>& coalescedEvents) {
Vector<PlatformTouchEvent> result;
for (const auto& event : coalescedEvents) {
- DCHECK(WebInputEvent::isTouchEventType(event->type));
+ DCHECK(WebInputEvent::isTouchEventType(event->type()));
result.append(PlatformTouchEventBuilder(
widget, static_cast<const WebTouchEvent&>(*event)));
}

Powered by Google App Engine
This is Rietveld 408576698