From: Jacek Caban Subject: [PATCH 1/5] mshtml: Follow anchors only on left button click Message-Id: <4F22BAE5.7030702@codeweavers.com> Date: Fri, 27 Jan 2012 15:55:33 +0100 --- dlls/mshtml/htmlanchor.c | 26 +++++++++++++++++++++++--- dlls/mshtml/htmlevent.c | 2 +- dlls/mshtml/mshtml_private.h | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/dlls/mshtml/htmlanchor.c b/dlls/mshtml/htmlanchor.c index 13bd2a4..1424f1e 100644 --- a/dlls/mshtml/htmlanchor.c +++ b/dlls/mshtml/htmlanchor.c @@ -18,6 +18,7 @@ #include #include +#include #define COBJMACROS @@ -583,14 +584,33 @@ static void HTMLAnchorElement_destructor(HTMLDOMNode *iface) HTMLElement_destructor(&This->element.node); } -static HRESULT HTMLAnchorElement_handle_event(HTMLDOMNode *iface, eventid_t eid, BOOL *prevent_default) +static HRESULT HTMLAnchorElement_handle_event(HTMLDOMNode *iface, eventid_t eid, nsIDOMEvent *event, BOOL *prevent_default) { HTMLAnchorElement *This = impl_from_HTMLDOMNode(iface); if(eid == EVENTID_CLICK) { + nsIDOMMouseEvent *mouse_event; + PRUint16 button; + nsresult nsres; + TRACE("CLICK\n"); - *prevent_default = TRUE; - return navigate_anchor(This); + + nsres = nsIDOMEvent_QueryInterface(event, &IID_nsIDOMMouseEvent, (void**)&mouse_event); + assert(nsres == NS_OK); + + nsres = nsIDOMMouseEvent_GetButton(mouse_event, &button); + assert(nsres == NS_OK); + + nsIDOMMouseEvent_Release(mouse_event); + + switch(button) { + case 0: + *prevent_default = TRUE; + return navigate_anchor(This); + default: + *prevent_default = FALSE; + return S_OK; + } } return S_OK; diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index 74e8069..b2efeed 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -1065,7 +1065,7 @@ void fire_event(HTMLDocumentNode *doc, eventid_t eid, BOOL set_event, nsIDOMNode break; if(node && node->vtbl->handle_event) { - hres = node->vtbl->handle_event(node, eid, &prevent_default); + hres = node->vtbl->handle_event(node, eid, nsevent, &prevent_default); if(FAILED(hres) || prevent_default) break; } diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 7373e15..20923e9 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -518,7 +518,7 @@ typedef struct { HRESULT (*get_attr_col)(HTMLDOMNode*,HTMLAttributeCollection**); event_target_t **(*get_event_target)(HTMLDOMNode*); HRESULT (*fire_event)(HTMLDOMNode*,DWORD,BOOL*); - HRESULT (*handle_event)(HTMLDOMNode*,DWORD,BOOL*); + HRESULT (*handle_event)(HTMLDOMNode*,DWORD,nsIDOMEvent*,BOOL*); HRESULT (*put_disabled)(HTMLDOMNode*,VARIANT_BOOL); HRESULT (*get_disabled)(HTMLDOMNode*,VARIANT_BOOL*); HRESULT (*get_document)(HTMLDOMNode*,IDispatch**);