Audit init*Event() method to make sure they reset internal data members
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Oct 2017 16:49:56 +0000 (16:49 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Oct 2017 16:49:56 +0000 (16:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178886

Reviewed by Ryosuke Niwa.

Audit init*Event() method to make sure they reset internal data members.

* dom/Event.cpp:
(WebCore::Event::initEvent):
* dom/KeyboardEvent.cpp:
(WebCore::KeyboardEvent::initKeyboardEvent):
* dom/MessageEvent.cpp:
(WebCore::MessageEvent::initMessageEvent):
* dom/MouseEvent.cpp:
(WebCore::MouseEvent::initMouseEvent):
* dom/MouseRelatedEvent.h:
(WebCore::MouseRelatedEvent::setIsSimulated):
* dom/TextEvent.cpp:
(WebCore::TextEvent::initTextEvent):
* dom/WheelEvent.cpp:
(WebCore::WheelEvent::initWheelEvent):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224115 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/Event.cpp
Source/WebCore/dom/KeyboardEvent.cpp
Source/WebCore/dom/MessageEvent.cpp
Source/WebCore/dom/MouseEvent.cpp
Source/WebCore/dom/MouseRelatedEvent.h
Source/WebCore/dom/TextEvent.cpp
Source/WebCore/dom/WheelEvent.cpp

index e1fc2ac..8632235 100644 (file)
@@ -1,5 +1,29 @@
 2017-10-27  Chris Dumez  <cdumez@apple.com>
 
+        Audit init*Event() method to make sure they reset internal data members
+        https://bugs.webkit.org/show_bug.cgi?id=178886
+
+        Reviewed by Ryosuke Niwa.
+
+        Audit init*Event() method to make sure they reset internal data members.
+
+        * dom/Event.cpp:
+        (WebCore::Event::initEvent):
+        * dom/KeyboardEvent.cpp:
+        (WebCore::KeyboardEvent::initKeyboardEvent):
+        * dom/MessageEvent.cpp:
+        (WebCore::MessageEvent::initMessageEvent):
+        * dom/MouseEvent.cpp:
+        (WebCore::MouseEvent::initMouseEvent):
+        * dom/MouseRelatedEvent.h:
+        (WebCore::MouseRelatedEvent::setIsSimulated):
+        * dom/TextEvent.cpp:
+        (WebCore::TextEvent::initTextEvent):
+        * dom/WheelEvent.cpp:
+        (WebCore::WheelEvent::initWheelEvent):
+
+2017-10-27  Chris Dumez  <cdumez@apple.com>
+
         Add initial support for serviceWorkerClient.postMessage()
         https://bugs.webkit.org/show_bug.cgi?id=178794
 
index d33cba6..14b5229 100644 (file)
@@ -89,6 +89,8 @@ void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool
     m_type = eventTypeArg;
     m_canBubble = canBubbleArg;
     m_cancelable = cancelableArg;
+
+    m_underlyingEvent = nullptr;
 }
 
 bool Event::composed() const
index 403afa9..a7e9253 100644 (file)
@@ -157,6 +157,7 @@ void KeyboardEvent::initKeyboardEvent(const AtomicString& type, bool canBubble,
 
     initUIEvent(type, canBubble, cancelable, view, 0);
 
+    m_keyEvent = nullptr;
     m_keyIdentifier = keyIdentifier;
     m_location = location;
     m_ctrlKey = ctrlKey;
@@ -164,6 +165,11 @@ void KeyboardEvent::initKeyboardEvent(const AtomicString& type, bool canBubble,
     m_altKey = altKey;
     m_metaKey = metaKey;
     m_altGraphKey = altGraphKey;
+
+#if PLATFORM(COCOA)
+    m_handledByInputMethod = false;
+    m_keypressCommands = { };
+#endif
 }
 
 bool KeyboardEvent::getModifierState(const String& keyIdentifier) const
index e9889e5..4b80dcf 100644 (file)
@@ -144,6 +144,9 @@ void MessageEvent::initMessageEvent(ExecState& state, const AtomicString& type,
     m_dataAsScriptValue = Deprecated::ScriptValue(state.vm(), data);
     m_dataAsSerializedScriptValue = nullptr;
     m_triedToSerialize = false;
+    m_dataAsString = { };
+    m_dataAsBlob = nullptr;
+    m_dataAsArrayBuffer = nullptr;
     m_origin = origin;
     m_lastEventId = lastEventId;
     m_source = WTFMove(source);
index 00d05de..c06dfab 100644 (file)
@@ -146,8 +146,8 @@ void MouseEvent::initMouseEvent(const AtomicString& type, bool canBubble, bool c
 
     initCoordinates(IntPoint(clientX, clientY));
 
-    // FIXME: m_isSimulated is not set to false here.
-    // FIXME: m_dataTransfer is not set to 0 here.
+    setIsSimulated(false);
+    m_dataTransfer = nullptr;
 }
 
 // FIXME: We need this quirk because iAd Producer is calling this function with a relatedTarget that is not an EventTarget (rdar://problem/30640101).
index e35d293..0d83c36 100644 (file)
@@ -55,6 +55,7 @@ public:
     WEBCORE_EXPORT int offsetX();
     WEBCORE_EXPORT int offsetY();
     bool isSimulated() const { return m_isSimulated; }
+    void setIsSimulated(bool value) { m_isSimulated = value; }
     int pageX() const final;
     int pageY() const final;
     WEBCORE_EXPORT FloatPoint locationInRootViewCoordinates() const;
index 3ed6685..bd024ea 100644 (file)
@@ -112,7 +112,15 @@ void TextEvent::initTextEvent(const AtomicString& type, bool canBubble, bool can
 
     initUIEvent(type, canBubble, cancelable, view, 0);
 
+    m_inputType = TextEventInputKeyboard;
+
     m_data = data;
+
+    m_pastingFragment = nullptr;
+    m_shouldSmartReplace = false;
+    m_shouldMatchStyle = false;
+    m_mailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote;
+    m_dictationAlternatives = { };
 }
 
 EventInterface TextEvent::eventInterface() const
index d1752bf..7934f89 100644 (file)
@@ -69,13 +69,7 @@ void WheelEvent::initWheelEvent(int rawDeltaX, int rawDeltaY, DOMWindow* view, i
     if (isBeingDispatched())
         return;
     
-    initUIEvent(eventNames().wheelEvent, true, true, view, 0);
-    
-    m_screenLocation = { screenX, screenY };
-    m_ctrlKey = ctrlKey;
-    m_altKey = altKey;
-    m_shiftKey = shiftKey;
-    m_metaKey = metaKey;
+    initMouseEvent(eventNames().wheelEvent, true, true, view, 0, screenX, screenY, pageX, pageY, ctrlKey, altKey, shiftKey, metaKey, 0, nullptr);
 
     // Normalize to 120 multiple for compatibility with IE.
     m_wheelDelta = { rawDeltaX * TickMultiplier, rawDeltaY * TickMultiplier };
@@ -84,7 +78,8 @@ void WheelEvent::initWheelEvent(int rawDeltaX, int rawDeltaY, DOMWindow* view, i
 
     m_deltaMode = DOM_DELTA_PIXEL;
 
-    initCoordinates({ pageX, pageY });
+    m_initializedWithPlatformWheelEvent = false;
+    m_wheelEvent = { };
 }
 
 EventInterface WheelEvent::eventInterface() const