Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
0c986f98
Commit
0c986f98
authored
Aug 07, 2015
by
Alex Henrie
Committed by
Alexandre Julliard
Aug 17, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mshtml: Use the same click event handler for anchor and area elements.
parent
36a39cea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
71 deletions
+108
-71
htmlanchor.c
dlls/mshtml/htmlanchor.c
+75
-70
htmlarea.c
dlls/mshtml/htmlarea.c
+32
-1
mshtml_private.h
dlls/mshtml/mshtml_private.h
+1
-0
No files found.
dlls/mshtml/htmlanchor.c
View file @
0c986f98
...
...
@@ -43,29 +43,18 @@ typedef struct {
nsIDOMHTMLAnchorElement
*
nsanchor
;
}
HTMLAnchorElement
;
static
HRESULT
navigate_
anchor_window
(
HTMLAnchorElement
*
This
,
const
WCHAR
*
target
)
static
HRESULT
navigate_
href_new_window
(
HTMLElement
*
element
,
nsAString
*
href_str
,
const
WCHAR
*
target
)
{
nsAString
href_str
;
const
PRUnichar
*
href
;
IUri
*
uri
;
nsresult
nsres
;
HRESULT
hres
;
nsAString_Init
(
&
href_str
,
NULL
);
nsres
=
nsIDOMHTMLAnchorElement_GetHref
(
This
->
nsanchor
,
&
href_str
);
if
(
NS_SUCCEEDED
(
nsres
))
{
const
PRUnichar
*
href
;
nsAString_GetData
(
&
href_str
,
&
href
);
hres
=
create_relative_uri
(
This
->
element
.
node
.
doc
->
basedoc
.
window
,
href
,
&
uri
);
}
else
{
ERR
(
"Could not get anchor href: %08x
\n
"
,
nsres
);
hres
=
E_FAIL
;
}
nsAString_Finish
(
&
href_str
);
nsAString_GetData
(
href_str
,
&
href
);
hres
=
create_relative_uri
(
element
->
node
.
doc
->
basedoc
.
window
,
href
,
&
uri
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
navigate_new_window
(
This
->
element
.
node
.
doc
->
basedoc
.
window
,
uri
,
target
,
NULL
,
NULL
);
hres
=
navigate_new_window
(
element
->
node
.
doc
->
basedoc
.
window
,
uri
,
target
,
NULL
,
NULL
);
IUri_Release
(
uri
);
return
hres
;
}
...
...
@@ -119,49 +108,69 @@ HTMLOuterWindow *get_target_window(HTMLOuterWindow *window, nsAString *target_st
return
ret_window
;
}
static
HRESULT
navigate_
anchor
(
HTMLAnchorElement
*
This
)
static
HRESULT
navigate_
href
(
HTMLElement
*
element
,
nsAString
*
href_str
,
nsAString
*
target_str
)
{
nsAString
href_str
,
target_str
;
HTMLOuterWindow
*
window
;
BOOL
use_new_window
;
nsresult
nsres
;
HRESULT
hres
=
E_FAIL
;
const
PRUnichar
*
href
;
HRESULT
hres
;
window
=
get_target_window
(
element
->
node
.
doc
->
basedoc
.
window
,
target_str
,
&
use_new_window
);
if
(
!
window
)
{
if
(
use_new_window
)
{
const
PRUnichar
*
target
;
nsAString_GetData
(
target_str
,
&
target
);
return
navigate_href_new_window
(
element
,
href_str
,
target
);
}
else
{
return
S_OK
;
}
}
nsAString_Init
(
&
target_str
,
NULL
);
nsres
=
nsIDOMHTMLAnchorElement_GetTarget
(
This
->
nsanchor
,
&
target_str
);
if
(
NS_FAILED
(
nsres
))
return
E_FAIL
;
nsAString_GetData
(
href_str
,
&
href
);
if
(
*
href
)
{
hres
=
navigate_url
(
window
,
href
,
window
->
uri_nofrag
,
BINDING_NAVIGATED
);
}
else
{
TRACE
(
"empty href
\n
"
);
hres
=
S_OK
;
}
IHTMLWindow2_Release
(
&
window
->
base
.
IHTMLWindow2_iface
);
return
hres
;
}
window
=
get_target_window
(
This
->
element
.
node
.
doc
->
basedoc
.
window
,
&
target_str
,
&
use_new_window
);
if
(
!
window
&&
use_new_window
)
{
const
PRUnichar
*
target
;
HRESULT
handle_link_click_event
(
HTMLElement
*
element
,
nsAString
*
href_str
,
nsAString
*
target_str
,
nsIDOMEvent
*
event
,
BOOL
*
prevent_default
)
{
nsIDOMMouseEvent
*
mouse_event
;
INT16
button
;
nsresult
nsres
;
HRESULT
hres
;
nsAString_GetData
(
&
target_str
,
&
target
);
hres
=
navigate_anchor_window
(
This
,
target
);
nsAString_Finish
(
&
target_str
);
return
hres
;
}
TRACE
(
"CLICK
\n
"
);
nsAString_Finish
(
&
target_str
);
if
(
!
window
)
return
S_OK
;
nsres
=
nsIDOMEvent_QueryInterface
(
event
,
&
IID_nsIDOMMouseEvent
,
(
void
**
)
&
mouse_event
);
assert
(
nsres
==
NS_OK
);
nsAString_Init
(
&
href_str
,
NULL
);
nsres
=
nsIDOMHTMLAnchorElement_GetHref
(
This
->
nsanchor
,
&
href_str
);
if
(
NS_SUCCEEDED
(
nsres
))
{
const
PRUnichar
*
href
;
nsres
=
nsIDOMMouseEvent_GetButton
(
mouse_event
,
&
button
);
assert
(
nsres
==
NS_OK
);
nsAString_GetData
(
&
href_str
,
&
href
);
if
(
*
href
)
{
hres
=
navigate_url
(
window
,
href
,
window
->
uri_nofrag
,
BINDING_NAVIGATED
);
}
else
{
TRACE
(
"empty href
\n
"
);
hres
=
S_OK
;
}
nsIDOMMouseEvent_Release
(
mouse_event
);
switch
(
button
)
{
case
0
:
*
prevent_default
=
TRUE
;
hres
=
navigate_href
(
element
,
href_str
,
target_str
);
break
;
case
1
:
*
prevent_default
=
TRUE
;
hres
=
navigate_href_new_window
(
element
,
href_str
,
NULL
);
break
;
default:
*
prevent_default
=
FALSE
;
hres
=
S_OK
;
}
nsAString_Finish
(
&
href_str
);
IHTMLWindow2_Release
(
&
window
->
base
.
IHTMLWindow2_iface
);
nsAString_Finish
(
href_str
);
nsAString_Finish
(
target_str
);
return
hres
;
}
...
...
@@ -721,33 +730,29 @@ static HRESULT HTMLAnchorElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
static
HRESULT
HTMLAnchorElement_handle_event
(
HTMLDOMNode
*
iface
,
eventid_t
eid
,
nsIDOMEvent
*
event
,
BOOL
*
prevent_default
)
{
HTMLAnchorElement
*
This
=
impl_from_HTMLDOMNode
(
iface
);
nsAString
href_str
,
target_str
;
nsresult
nsres
;
if
(
eid
==
EVENTID_CLICK
)
{
nsIDOMMouseEvent
*
mouse_event
;
INT16
button
;
nsresult
nsres
;
TRACE
(
"CLICK
\n
"
);
nsres
=
nsIDOMEvent_QueryInterface
(
event
,
&
IID_nsIDOMMouseEvent
,
(
void
**
)
&
mouse_event
);
assert
(
nsres
==
NS_OK
);
nsAString_Init
(
&
href_str
,
NULL
);
nsres
=
nsIDOMHTMLAnchorElement_GetHref
(
This
->
nsanchor
,
&
href_str
);
if
(
NS_FAILED
(
nsres
))
{
ERR
(
"Could not get anchor href: %08x
\n
"
,
nsres
);
goto
fallback
;
}
nsres
=
nsIDOMMouseEvent_GetButton
(
mouse_event
,
&
button
);
assert
(
nsres
==
NS_OK
);
nsAString_Init
(
&
target_str
,
NULL
);
nsres
=
nsIDOMHTMLAnchorElement_GetTarget
(
This
->
nsanchor
,
&
target_str
);
if
(
NS_FAILED
(
nsres
))
{
ERR
(
"Could not get anchor target: %08x
\n
"
,
nsres
);
goto
fallback
;
}
nsIDOMMouseEvent_Release
(
mouse_even
t
);
return
handle_link_click_event
(
&
This
->
element
,
&
href_str
,
&
target_str
,
event
,
prevent_defaul
t
);
switch
(
button
)
{
case
0
:
*
prevent_default
=
TRUE
;
return
navigate_anchor
(
This
);
case
1
:
*
prevent_default
=
TRUE
;
return
navigate_anchor_window
(
This
,
NULL
);
default:
*
prevent_default
=
FALSE
;
return
S_OK
;
}
fallback:
nsAString_Finish
(
&
href_str
);
nsAString_Finish
(
&
target_str
);
}
return
HTMLElement_handle_event
(
&
This
->
element
.
node
,
eid
,
event
,
prevent_default
);
...
...
dlls/mshtml/htmlarea.c
View file @
0c986f98
...
...
@@ -403,12 +403,43 @@ static HRESULT HTMLAreaElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
return
S_OK
;
}
static
HRESULT
HTMLAreaElement_handle_event
(
HTMLDOMNode
*
iface
,
eventid_t
eid
,
nsIDOMEvent
*
event
,
BOOL
*
prevent_default
)
{
HTMLAreaElement
*
This
=
impl_from_HTMLDOMNode
(
iface
);
nsAString
href_str
,
target_str
;
nsresult
nsres
;
if
(
eid
==
EVENTID_CLICK
)
{
nsAString_Init
(
&
href_str
,
NULL
);
nsres
=
nsIDOMHTMLAreaElement_GetHref
(
This
->
nsarea
,
&
href_str
);
if
(
NS_FAILED
(
nsres
))
{
ERR
(
"Could not get area href: %08x
\n
"
,
nsres
);
goto
fallback
;
}
nsAString_Init
(
&
target_str
,
NULL
);
nsres
=
nsIDOMHTMLAreaElement_GetTarget
(
This
->
nsarea
,
&
target_str
);
if
(
NS_FAILED
(
nsres
))
{
ERR
(
"Could not get area target: %08x
\n
"
,
nsres
);
goto
fallback
;
}
return
handle_link_click_event
(
&
This
->
element
,
&
href_str
,
&
target_str
,
event
,
prevent_default
);
fallback:
nsAString_Finish
(
&
href_str
);
nsAString_Finish
(
&
target_str
);
}
return
HTMLElement_handle_event
(
&
This
->
element
.
node
,
eid
,
event
,
prevent_default
);
}
static
const
NodeImplVtbl
HTMLAreaElementImplVtbl
=
{
HTMLAreaElement_QI
,
HTMLElement_destructor
,
HTMLElement_cpc
,
HTMLElement_clone
,
HTMLElement_handle_event
,
HTML
Area
Element_handle_event
,
HTMLElement_get_attr_col
};
...
...
dlls/mshtml/mshtml_private.h
View file @
0c986f98
...
...
@@ -996,6 +996,7 @@ HRESULT search_window_props(HTMLInnerWindow*,BSTR,DWORD,DISPID*) DECLSPEC_HIDDEN
HRESULT
get_frame_by_name
(
HTMLOuterWindow
*
,
const
WCHAR
*
,
BOOL
,
HTMLOuterWindow
**
)
DECLSPEC_HIDDEN
;
HRESULT
get_doc_elem_by_id
(
HTMLDocumentNode
*
,
const
WCHAR
*
,
HTMLElement
**
)
DECLSPEC_HIDDEN
;
HTMLOuterWindow
*
get_target_window
(
HTMLOuterWindow
*
,
nsAString
*
,
BOOL
*
)
DECLSPEC_HIDDEN
;
HRESULT
handle_link_click_event
(
HTMLElement
*
,
nsAString
*
,
nsAString
*
,
nsIDOMEvent
*
,
BOOL
*
)
DECLSPEC_HIDDEN
;
HRESULT
wrap_iface
(
IUnknown
*
,
IUnknown
*
,
IUnknown
**
)
DECLSPEC_HIDDEN
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment