mshtml: Added IDOMEvent::stopImmediatePropagation implementaition.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2018-02-15 17:04:51 +01:00 committed by Alexandre Julliard
parent e95db4c590
commit ab210dd7a4
3 changed files with 29 additions and 3 deletions

View File

@ -1051,8 +1051,12 @@ static HRESULT WINAPI DOMEvent_stopPropagation(IDOMEvent *iface)
static HRESULT WINAPI DOMEvent_stopImmediatePropagation(IDOMEvent *iface) static HRESULT WINAPI DOMEvent_stopImmediatePropagation(IDOMEvent *iface)
{ {
DOMEvent *This = impl_from_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) 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) { if(listener->type != LISTENER_TYPE_ATTACHED) {
DISPID named_arg = DISPID_THIS; DISPID named_arg = DISPID_THIS;
VARIANTARG args[2]; VARIANTARG args[2];

View File

@ -79,6 +79,7 @@ typedef struct {
BOOL cancelable; BOOL cancelable;
BOOL prevent_default; BOOL prevent_default;
BOOL stop_propagation; BOOL stop_propagation;
BOOL stop_immediate_propagation;
DOM_EVENT_PHASE phase; DOM_EVENT_PHASE phase;
IHTMLEventObj *event_obj; IHTMLEventObj *event_obj;

View File

@ -251,9 +251,19 @@ function test_stop_propagation() {
ok(e.defaultPrevented === false, "defaultPrevented = " + e.defaultPrevented); 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", stop_propagation, true);
div1.addEventListener("click", record_call("div1.click(capture)"), 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", stop_propagation, true);
div2.addEventListener("click", record_call("div2.click(capture)"), 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", stop_propagation, false);
div2.addEventListener("click", record_call("div2.click(bubble)"), 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 = ""; calls = "";
div2.click(); div2.click();
ok(calls === "stop,div1.click(capture),", "calls = " + calls); ok(calls === "stop,div1.click(capture),", "calls = " + calls);
@ -270,6 +285,11 @@ function test_stop_propagation() {
div1.removeEventListener("click", stop_propagation, true); div1.removeEventListener("click", stop_propagation, true);
calls = ""; calls = "";
div2.click(); 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),", ok(calls === "div1.click(capture),stop,div2.click(capture),stop,div2.click(bubble),",
"calls = " + calls); "calls = " + calls);