Chromium Code Reviews| Index: third_party/WebKit/public/platform/WebInputEvent.h |
| diff --git a/third_party/WebKit/public/platform/WebInputEvent.h b/third_party/WebKit/public/platform/WebInputEvent.h |
| index 2133aaea5b8fd2487290e608eb4a316a31d67035..a364830d6b0dcb8f6766f523e803c159e3931a2e 100644 |
| --- a/third_party/WebKit/public/platform/WebInputEvent.h |
| +++ b/third_party/WebKit/public/platform/WebInputEvent.h |
| @@ -194,6 +194,7 @@ class WebInputEvent { |
| // and don't indicate explicit depressed state. |
| KeyModifiers = |
| SymbolKey | FnKey | AltGrKey | MetaKey | AltKey | ControlKey | ShiftKey, |
| + NoModifiers = 0, |
|
majidvp
2016/12/19 20:09:52
nit: Can we just have None = 0 and put it at the t
dtapuska
2016/12/20 19:49:21
Done.
majidvp
2016/12/21 15:49:44
I prefer these bitset values to be defined as cons
|
| }; |
| // Indicates whether the browser needs to block on the ACK result for |
| @@ -224,6 +225,8 @@ class WebInputEvent { |
| static const int InputModifiers = ShiftKey | ControlKey | AltKey | MetaKey; |
| + static constexpr double TimeStampForTesting = 123.0; |
| + |
|
majidvp
2016/12/19 20:09:52
Great idea to have a constant for testing.
dtapuska
2016/12/20 19:49:21
Done.
|
| double timeStampSeconds; // Seconds since platform start with microsecond |
| // resolution. |
| unsigned size; // The size of this structure, for serialization. |
| @@ -264,13 +267,29 @@ class WebInputEvent { |
| BLINK_COMMON_EXPORT static const char* GetName(WebInputEvent::Type); |
| + void setType(Type typeParam) { type = typeParam; } |
| + |
| + void setModifiers(int modifiersParam) { modifiers = modifiersParam; } |
| + |
| + void setTimeStampSeconds(double seconds) { timeStampSeconds = seconds; } |
| + |
| protected: |
| + WebInputEvent(unsigned sizeParam, |
| + Type typeParam, |
| + int modifiersParam, |
| + double timeStampSecondsParam) { |
| + memset(this, 0, sizeParam); |
| + timeStampSeconds = timeStampSecondsParam; |
| + size = sizeParam; |
| + type = typeParam; |
| + modifiers = modifiersParam; |
| + } |
| + |
| explicit WebInputEvent(unsigned sizeParam) { |
| memset(this, 0, sizeParam); |
| timeStampSeconds = 0.0; |
| size = sizeParam; |
| type = Undefined; |
| - modifiers = 0; |
|
majidvp
2016/12/19 20:09:53
why do you no longer not need to initialize modifi
dtapuska
2016/12/20 19:49:21
yes it is an int and zeroed in the memset. I left
|
| } |
| }; |
| @@ -326,13 +345,13 @@ class WebKeyboardEvent : public WebInputEvent { |
| WebUChar text[textLengthCap]; |
| WebUChar unmodifiedText[textLengthCap]; |
| - WebKeyboardEvent() |
| - : WebInputEvent(sizeof(WebKeyboardEvent)), |
| - windowsKeyCode(0), |
| - nativeKeyCode(0), |
| - isSystemKey(false), |
| - isBrowserShortcut(false) { |
| - } |
| + WebKeyboardEvent(Type type, int modifiers, double timeStampSeconds) |
| + : WebInputEvent(sizeof(WebKeyboardEvent), |
| + type, |
| + modifiers, |
| + timeStampSeconds) {} |
| + |
| + WebKeyboardEvent() : WebInputEvent(sizeof(WebKeyboardEvent)) {} |
| // Please refer to bug http://b/issue?id=961192, which talks about Webkit |
| // keyboard event handling changes. It also mentions the list of keys |
| @@ -371,32 +390,23 @@ class WebMouseEvent : public WebInputEvent, public WebPointerProperties { |
| int movementY; |
| int clickCount; |
| + WebMouseEvent(Type type, int modifiers, double timeStampSeconds) |
| + : WebInputEvent(sizeof(WebMouseEvent), type, modifiers, timeStampSeconds), |
| + WebPointerProperties() {} |
| + |
| WebMouseEvent() |
| - : WebInputEvent(sizeof(WebMouseEvent)), |
| - WebPointerProperties(), |
| - x(0), |
| - y(0), |
| - windowX(0), |
| - windowY(0), |
| - globalX(0), |
| - globalY(0), |
| - movementX(0), |
| - movementY(0), |
| - clickCount(0) {} |
| + : WebInputEvent(sizeof(WebMouseEvent)), WebPointerProperties() {} |
| protected: |
| explicit WebMouseEvent(unsigned sizeParam) |
| - : WebInputEvent(sizeParam), |
| - WebPointerProperties(), |
| - x(0), |
| - y(0), |
| - windowX(0), |
| - windowY(0), |
| - globalX(0), |
| - globalY(0), |
| - movementX(0), |
| - movementY(0), |
| - clickCount(0) {} |
| + : WebInputEvent(sizeParam), WebPointerProperties() {} |
| + |
| + WebMouseEvent(unsigned sizeParam, |
| + Type type, |
| + int modifiers, |
| + double timeStampSeconds) |
| + : WebInputEvent(sizeParam, type, modifiers, timeStampSeconds), |
| + WebPointerProperties() {} |
| }; |
| // WebMouseWheelEvent --------------------------------------------------------- |
| @@ -440,6 +450,23 @@ class WebMouseWheelEvent : public WebMouseEvent { |
| // listeners were passive or was forced to be non-blocking. |
| DispatchType dispatchType; |
| + WebMouseWheelEvent(Type type, int modifiers, double timeStampSeconds) |
| + : WebMouseEvent(sizeof(WebMouseWheelEvent), |
| + type, |
| + modifiers, |
| + timeStampSeconds), |
| + deltaX(0.0f), |
| + deltaY(0.0f), |
| + wheelTicksX(0.0f), |
| + wheelTicksY(0.0f), |
| + accelerationRatioX(1.0f), |
| + accelerationRatioY(1.0f), |
| + resendingPluginId(-1), |
| + phase(PhaseNone), |
| + momentumPhase(PhaseNone), |
| + railsMode(RailsModeFree), |
| + dispatchType(Blocking) {} |
| + |
| WebMouseWheelEvent() |
| : WebMouseEvent(sizeof(WebMouseWheelEvent)), |
| deltaX(0.0f), |
| @@ -451,8 +478,6 @@ class WebMouseWheelEvent : public WebMouseEvent { |
| resendingPluginId(-1), |
| phase(PhaseNone), |
| momentumPhase(PhaseNone), |
| - scrollByPage(false), |
| - hasPreciseScrollingDeltas(false), |
| railsMode(RailsModeFree), |
| dispatchType(Blocking) {} |
| }; |
| @@ -489,12 +514,11 @@ class WebTouchEvent : public WebInputEvent { |
| uint32_t uniqueTouchEventId; |
| WebTouchEvent() |
| - : WebInputEvent(sizeof(WebTouchEvent)), |
| - touchesLength(0), |
| - dispatchType(Blocking), |
| - movedBeyondSlopRegion(false), |
| - touchStartOrFirstTouchMove(false), |
| - uniqueTouchEventId(0) {} |
| + : WebInputEvent(sizeof(WebTouchEvent)), dispatchType(Blocking) {} |
| + |
| + WebTouchEvent(Type type, int modifiers, double timeStampSeconds) |
| + : WebInputEvent(sizeof(WebTouchEvent), type, modifiers, timeStampSeconds), |
| + dispatchType(Blocking) {} |
| }; |
| #pragma pack(pop) |