Jacek Caban : mshtml: Expose IHTMLUIEvent to scripts.

Alexandre Julliard julliard at winehq.org
Tue Feb 6 15:55:49 CST 2018


Module: wine
Branch: master
Commit: 20159346c7403e22268be4386b7cd4e1229b482a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=20159346c7403e22268be4386b7cd4e1229b482a

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Feb  6 00:09:35 2018 +0100

mshtml: Expose IHTMLUIEvent to scripts.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mshtml/htmlevent.c      | 17 ++++++++++++++++-
 dlls/mshtml/mshtml_private.h |  2 ++
 dlls/mshtml/tests/events.js  | 38 ++++++++++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c
index a855b02..9ffce28 100644
--- a/dlls/mshtml/htmlevent.c
+++ b/dlls/mshtml/htmlevent.c
@@ -1647,8 +1647,21 @@ static dispex_static_data_t DOMEvent_dispex = {
     DOMEvent_iface_tids
 };
 
+static const tid_t DOMUIEvent_iface_tids[] = {
+    IDOMEvent_tid,
+    IDOMUIEvent_tid,
+    0
+};
+
+static dispex_static_data_t DOMUIEvent_dispex = {
+    NULL,
+    DispDOMUIEvent_tid,
+    DOMUIEvent_iface_tids
+};
+
 static const tid_t DOMMouseEvent_iface_tids[] = {
     IDOMEvent_tid,
+    IDOMUIEvent_tid,
     IDOMMouseEvent_tid,
     0
 };
@@ -1694,7 +1707,9 @@ static DOMEvent *alloc_event(nsIDOMEvent *nsevent, eventid_t event_id)
         - time_epoch;
 
     nsres = nsIDOMEvent_QueryInterface(nsevent, &IID_nsIDOMUIEvent, (void**)&event->ui_event);
-    if(NS_FAILED(nsres))
+    if(NS_SUCCEEDED(nsres))
+        dispex_data = &DOMUIEvent_dispex;
+    else
         event->ui_event = NULL;
 
     nsres = nsIDOMEvent_QueryInterface(nsevent, &IID_nsIDOMMouseEvent, (void**)&event->mouse_event);
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 83c30e6..79d0d6a 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -82,6 +82,7 @@ typedef struct EventTarget EventTarget;
     XDIID(DispDOMChildrenCollection) \
     XDIID(DispDOMEvent) \
     XDIID(DispDOMMouseEvent) \
+    XDIID(DispDOMUIEvent) \
     XDIID(DispHTMLAnchorElement) \
     XDIID(DispHTMLAreaElement) \
     XDIID(DispHTMLAttributeCollection) \
@@ -130,6 +131,7 @@ typedef struct EventTarget EventTarget;
     XDIID(HTMLElementEvents2) \
     XIID(IDOMEvent) \
     XIID(IDOMMouseEvent) \
+    XIID(IDOMUIEvent) \
     XIID(IDocumentEvent) \
     XIID(IDocumentSelector) \
     XIID(IElementSelector) \
diff --git a/dlls/mshtml/tests/events.js b/dlls/mshtml/tests/events.js
index fd7a268..7d88852 100644
--- a/dlls/mshtml/tests/events.js
+++ b/dlls/mshtml/tests/events.js
@@ -610,6 +610,7 @@ function test_mouse_event() {
     ok(e.type === "test", "type = " + e.type);
     ok(e.cancelable === true, "cancelable = " + e.cancelable);
     ok(e.bubbles === true, "bubbles = " + e.bubbles);
+    ok(e.detail === 1, "detail = " + e.detail);
     ok(e.screenX === 2, "screenX = " + e.screenX);
     ok(e.screenY === 3, "screenY = " + e.screenY);
     ok(e.clientX === 4, "clientX = " + e.clientX);
@@ -624,6 +625,7 @@ function test_mouse_event() {
     ok(e.type === "test", "type = " + e.type);
     ok(e.cancelable === false, "cancelable = " + e.cancelable);
     ok(e.bubbles === false, "bubbles = " + e.bubbles);
+    ok(e.detail === 9, "detail = " + e.detail);
     ok(e.screenX === 8, "screenX = " + e.screenX);
     ok(e.screenY === 7, "screenY = " + e.screenY);
     ok(e.clientX === 6, "clientX = " + e.clientX);
@@ -638,6 +640,7 @@ function test_mouse_event() {
     ok(e.type === "testevent", "type = " + e.type);
     ok(e.cancelable === true, "cancelable = " + e.cancelable);
     ok(e.bubbles === true, "bubbles = " + e.bubbles);
+    ok(e.detail === 9, "detail = " + e.detail);
     ok(e.screenX === 8, "screenX = " + e.screenX);
     ok(e.screenY === 7, "screenY = " + e.screenY);
     ok(e.clientX === 6, "clientX = " + e.clientX);
@@ -648,6 +651,36 @@ function test_mouse_event() {
     ok(e.metaKey === true, "metaKey = " + e.metaKey);
     ok(e.button === 127, "button = " + e.button);
 
+    e.initUIEvent("testevent", true, true, window, 6);
+    ok(e.type === "testevent", "type = " + e.type);
+    ok(e.cancelable === true, "cancelable = " + e.cancelable);
+    ok(e.bubbles === true, "bubbles = " + e.bubbles);
+    ok(e.detail === 6, "detail = " + e.detail);
+    ok(e.screenX === 8, "screenX = " + e.screenX);
+    ok(e.screenY === 7, "screenY = " + e.screenY);
+    ok(e.clientX === 6, "clientX = " + e.clientX);
+    ok(e.clientY === 5, "clientY = " + e.clientY);
+    ok(e.ctrlKey === true, "ctrlKey = " + e.ctrlKey);
+    ok(e.altKey === true, "altKey = " + e.altKey);
+    ok(e.shiftKey === true, "shiftKey = " + e.shiftKey);
+    ok(e.metaKey === true, "metaKey = " + e.metaKey);
+    ok(e.button === 127, "button = " + e.button);
+
+    next_test();
+}
+
+function test_ui_event() {
+    var e;
+
+    e = document.createEvent("UIEvent");
+    ok(e.detail === 0, "detail = " + e.detail);
+
+    e.initUIEvent("test", true, true, window, 3);
+    ok(e.type === "test", "type = " + e.type);
+    ok(e.cancelable === true, "cancelable = " + e.cancelable);
+    ok(e.bubbles === true, "bubbles = " + e.bubbles);
+    ok(e.detail === 3, "detail = " + e.detail);
+
     next_test();
 }
 
@@ -663,7 +696,8 @@ var tests = [
     test_current_target,
     test_dispatch_event,
     test_recursive_dispatch,
+    test_ui_event,
+    test_mouse_event,
     test_time_stamp,
-    test_listener_order,
-    test_mouse_event
+    test_listener_order
 ];




More information about the wine-cvs mailing list