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
2dd15b59
Commit
2dd15b59
authored
Jul 19, 2016
by
Jacek Caban
Committed by
Alexandre Julliard
Jul 20, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mshtml: Moved getting text from ScriptBSC to separated function.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
339ebdb1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
52 deletions
+53
-52
script.c
dlls/mshtml/script.c
+53
-52
No files found.
dlls/mshtml/script.c
View file @
2dd15b59
...
...
@@ -810,6 +810,57 @@ typedef struct {
HRESULT
hres
;
}
ScriptBSC
;
static
HRESULT
get_binding_text
(
ScriptBSC
*
bsc
,
WCHAR
**
ret
)
{
UINT
cp
=
CP_UTF8
;
WCHAR
*
text
;
if
(
!
bsc
->
bsc
.
readed
)
{
text
=
heap_alloc
(
sizeof
(
WCHAR
));
if
(
!
text
)
return
E_OUTOFMEMORY
;
*
text
=
0
;
*
ret
=
text
;
return
S_OK
;
}
switch
(
bsc
->
bsc
.
bom
)
{
case
BOM_UTF16
:
if
(
bsc
->
bsc
.
readed
%
sizeof
(
WCHAR
))
{
FIXME
(
"The buffer is not a valid utf16 string
\n
"
);
return
E_FAIL
;
}
text
=
heap_alloc
(
bsc
->
bsc
.
readed
+
sizeof
(
WCHAR
));
if
(
!
text
)
return
E_OUTOFMEMORY
;
memcpy
(
text
,
bsc
->
buf
,
bsc
->
bsc
.
readed
);
text
[
bsc
->
bsc
.
readed
/
sizeof
(
WCHAR
)]
=
0
;
break
;
default:
/* FIXME: Try to use charset from HTTP headers first */
if
(
bsc
->
script_elem
)
cp
=
get_document_charset
(
bsc
->
script_elem
->
element
.
node
.
doc
);
/* fall through */
case
BOM_UTF8
:
{
DWORD
len
;
len
=
MultiByteToWideChar
(
cp
,
0
,
bsc
->
buf
,
bsc
->
bsc
.
readed
,
NULL
,
0
);
text
=
heap_alloc
((
len
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
text
)
return
E_OUTOFMEMORY
;
MultiByteToWideChar
(
cp
,
0
,
bsc
->
buf
,
bsc
->
bsc
.
readed
,
text
,
len
);
text
[
len
]
=
0
;
}
}
*
ret
=
text
;
return
S_OK
;
}
static
inline
ScriptBSC
*
impl_from_BSCallback
(
BSCallback
*
iface
)
{
return
CONTAINING_RECORD
(
iface
,
ScriptBSC
,
bsc
);
...
...
@@ -924,10 +975,8 @@ static const BSCallbackVtbl ScriptBSCVtbl = {
static
HRESULT
bind_script_to_text
(
HTMLInnerWindow
*
window
,
IUri
*
uri
,
HTMLScriptElement
*
script_elem
,
WCHAR
**
ret
)
{
UINT
cp
=
CP_UTF8
;
ScriptBSC
*
bsc
;
IMoniker
*
mon
;
WCHAR
*
text
;
HRESULT
hres
;
hres
=
CreateURLMonikerEx2
(
NULL
,
uri
,
&
mon
,
URL_MK_UNIFORM
);
...
...
@@ -954,59 +1003,11 @@ static HRESULT bind_script_to_text(HTMLInnerWindow *window, IUri *uri, HTMLScrip
hres
=
start_binding
(
window
,
&
bsc
->
bsc
,
NULL
);
if
(
SUCCEEDED
(
hres
))
hres
=
bsc
->
hres
;
if
(
FAILED
(
hres
))
{
IBindStatusCallback_Release
(
&
bsc
->
bsc
.
IBindStatusCallback_iface
);
return
hres
;
}
if
(
!
bsc
->
bsc
.
readed
)
{
*
ret
=
NULL
;
return
S_OK
;
}
switch
(
bsc
->
bsc
.
bom
)
{
case
BOM_UTF16
:
if
(
bsc
->
bsc
.
readed
%
sizeof
(
WCHAR
))
{
FIXME
(
"The buffer is not a valid utf16 string
\n
"
);
hres
=
E_FAIL
;
break
;
}
text
=
heap_alloc
(
bsc
->
bsc
.
readed
+
sizeof
(
WCHAR
));
if
(
!
text
)
{
hres
=
E_OUTOFMEMORY
;
break
;
}
memcpy
(
text
,
bsc
->
buf
,
bsc
->
bsc
.
readed
);
text
[
bsc
->
bsc
.
readed
/
sizeof
(
WCHAR
)]
=
0
;
break
;
default:
/* FIXME: Try to use charset from HTTP headers first */
cp
=
get_document_charset
(
window
->
doc
);
/* fall through */
case
BOM_UTF8
:
{
DWORD
len
;
len
=
MultiByteToWideChar
(
cp
,
0
,
bsc
->
buf
,
bsc
->
bsc
.
readed
,
NULL
,
0
);
text
=
heap_alloc
((
len
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
text
)
{
hres
=
E_OUTOFMEMORY
;
break
;
}
MultiByteToWideChar
(
cp
,
0
,
bsc
->
buf
,
bsc
->
bsc
.
readed
,
text
,
len
);
text
[
len
]
=
0
;
}
}
if
(
SUCCEEDED
(
hres
))
hres
=
get_binding_text
(
bsc
,
ret
);
IBindStatusCallback_Release
(
&
bsc
->
bsc
.
IBindStatusCallback_iface
);
if
(
FAILED
(
hres
))
return
hres
;
*
ret
=
text
;
return
S_OK
;
}
static
void
parse_extern_script
(
ScriptHost
*
script_host
,
HTMLScriptElement
*
script_elem
,
LPCWSTR
src
)
...
...
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