From ab210dd7a4c1966c5586d07d00b845a0409fef1b Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 15 Feb 2018 17:04:51 +0100 Subject: [PATCH] mshtml: Added IDOMEvent::stopImmediatePropagation implementaition. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/mshtml/htmlevent.c | 11 ++++++++--- dlls/mshtml/htmlevent.h | 1 + dlls/mshtml/tests/events.js | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index d91de282655..c5ae7585f23 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -1051,8 +1051,12 @@ static HRESULT WINAPI DOMEvent_stopPropagation(IDOMEvent *iface) static HRESULT WINAPI DOMEvent_stopImmediatePropagation(IDOMEvent *iface) { DOMEvent *This = impl_from_IDOMEvent(iface); - FIXME("(%p)\n", This); - return E_NOTIMPL; + + TRACE("(%p)\n", This); + + This->stop_immediate_propagation = This->stop_propagation = TRUE; + nsIDOMEvent_StopImmediatePropagation(This->nsevent); + return S_OK; } static HRESULT WINAPI DOMEvent_get_isTrusted(IDOMEvent *iface, VARIANT_BOOL *p) @@ -2210,7 +2214,8 @@ static void call_event_handlers(EventTarget *event_target, DOMEvent *event, disp } } - for(listener = listeners; listener < listeners + listeners_cnt; listener++) { + for(listener = listeners; !event->stop_immediate_propagation + && listener < listeners + listeners_cnt; listener++) { if(listener->type != LISTENER_TYPE_ATTACHED) { DISPID named_arg = DISPID_THIS; VARIANTARG args[2]; diff --git a/dlls/mshtml/htmlevent.h b/dlls/mshtml/htmlevent.h index e78c78c88ed..182a36e552d 100644 --- a/dlls/mshtml/htmlevent.h +++ b/dlls/mshtml/htmlevent.h @@ -79,6 +79,7 @@ typedef struct { BOOL cancelable; BOOL prevent_default; BOOL stop_propagation; + BOOL stop_immediate_propagation; DOM_EVENT_PHASE phase; IHTMLEventObj *event_obj; diff --git a/dlls/mshtml/tests/events.js b/dlls/mshtml/tests/events.js index 4560d93056d..6051295dd0a 100644 --- a/dlls/mshtml/tests/events.js +++ b/dlls/mshtml/tests/events.js @@ -251,9 +251,19 @@ function test_stop_propagation() { ok(e.defaultPrevented === false, "defaultPrevented = " + e.defaultPrevented); } + function stop_immediate_propagation(e) { + calls += "immediateStop,"; + e.stopImmediatePropagation(); + ok(e.bubbles === true, "bubbles = " + e.bubbles); + ok(e.cancelable === true, "cancelable = " + e.cancelable); + ok(e.defaultPrevented === false, "defaultPrevented = " + e.defaultPrevented); + } + + div1.addEventListener("click", stop_immediate_propagation, true); div1.addEventListener("click", stop_propagation, true); div1.addEventListener("click", record_call("div1.click(capture)"), true); + div2.addEventListener("click", stop_immediate_propagation, true); div2.addEventListener("click", stop_propagation, true); div2.addEventListener("click", record_call("div2.click(capture)"), true); @@ -263,6 +273,11 @@ function test_stop_propagation() { div2.addEventListener("click", stop_propagation, false); div2.addEventListener("click", record_call("div2.click(bubble)"), false); + calls = ""; + div2.click(); + ok(calls === "immediateStop,", "calls = " + calls); + + div1.removeEventListener("click", stop_immediate_propagation, true); calls = ""; div2.click(); ok(calls === "stop,div1.click(capture),", "calls = " + calls); @@ -270,6 +285,11 @@ function test_stop_propagation() { div1.removeEventListener("click", stop_propagation, true); calls = ""; div2.click(); + ok(calls === "div1.click(capture),immediateStop,", "calls = " + calls); + + div2.removeEventListener("click", stop_immediate_propagation, true); + calls = ""; + div2.click(); ok(calls === "div1.click(capture),stop,div2.click(capture),stop,div2.click(bubble),", "calls = " + calls);