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
dfa0b91f
Commit
dfa0b91f
authored
Oct 04, 2007
by
Jacek Caban
Committed by
Alexandre Julliard
Oct 04, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mshtml: IHTMLElementContainer::item rewrite.
parent
ae64937f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
40 deletions
+76
-40
htmlelem.c
dlls/mshtml/htmlelem.c
+76
-40
No files found.
dlls/mshtml/htmlelem.c
View file @
dfa0b91f
...
...
@@ -1469,6 +1469,35 @@ static HRESULT WINAPI HTMLElementCollection_get__newEnum(IHTMLElementCollection
return
E_NOTIMPL
;
}
static
BOOL
is_elem_name
(
HTMLElement
*
elem
,
LPCWSTR
name
)
{
const
PRUnichar
*
str
;
nsAString
nsstr
,
nsname
;
BOOL
ret
=
FALSE
;
nsresult
nsres
;
static
const
PRUnichar
nameW
[]
=
{
'n'
,
'a'
,
'm'
,
'e'
,
0
};
nsAString_Init
(
&
nsstr
,
NULL
);
nsIDOMHTMLElement_GetId
(
elem
->
nselem
,
&
nsstr
);
nsAString_GetData
(
&
nsstr
,
&
str
,
NULL
);
if
(
!
strcmpiW
(
str
,
name
))
{
nsAString_Finish
(
&
nsstr
);
return
TRUE
;
}
nsAString_Init
(
&
nsname
,
nameW
);
nsres
=
nsIDOMHTMLElement_GetAttribute
(
elem
->
nselem
,
&
nsname
,
&
nsstr
);
nsAString_Finish
(
&
nsname
);
if
(
NS_SUCCEEDED
(
nsres
))
{
nsAString_GetData
(
&
nsstr
,
&
str
,
NULL
);
ret
=
!
strcmpiW
(
str
,
name
);
}
nsAString_Finish
(
&
nsstr
);
return
ret
;
}
static
HRESULT
WINAPI
HTMLElementCollection_item
(
IHTMLElementCollection
*
iface
,
VARIANT
name
,
VARIANT
index
,
IDispatch
**
pdisp
)
{
...
...
@@ -1476,12 +1505,15 @@ static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface,
TRACE
(
"(%p)->(v(%d) v(%d) %p)
\n
"
,
This
,
V_VT
(
&
name
),
V_VT
(
&
index
),
pdisp
);
*
pdisp
=
NULL
;
if
(
V_VT
(
&
name
)
==
VT_I4
)
{
TRACE
(
"name is VT_I4: %d
\n
"
,
V_I4
(
&
name
));
if
(
V_I4
(
&
name
)
<
0
||
V_I4
(
&
name
)
>=
This
->
len
)
{
ERR
(
"Invalid name! name=%d
\n
"
,
V_I4
(
&
name
));
if
(
V_I4
(
&
name
)
<
0
)
return
E_INVALIDARG
;
}
if
(
V_I4
(
&
name
)
>=
This
->
len
)
return
S_OK
;
*
pdisp
=
(
IDispatch
*
)
This
->
elems
[
V_I4
(
&
name
)];
IDispatch_AddRef
(
*
pdisp
);
...
...
@@ -1491,48 +1523,52 @@ static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface,
if
(
V_VT
(
&
name
)
==
VT_BSTR
)
{
DWORD
i
;
nsAString
tag_str
;
const
PRUnichar
*
tag
;
elem_vector
buf
=
{
NULL
,
0
,
8
};
TRACE
(
"name is VT_BSTR: %s
\n
"
,
debugstr_w
(
V_BSTR
(
&
name
)));
nsAString_Init
(
&
tag_str
,
NULL
);
buf
.
buf
=
mshtml_alloc
(
buf
.
size
*
sizeof
(
HTMLElement
*
));
for
(
i
=
0
;
i
<
This
->
len
;
i
++
)
{
if
(
!
This
->
elems
[
i
]
->
nselem
)
continue
;
nsIDOMHTMLElement_GetId
(
This
->
elems
[
i
]
->
nselem
,
&
tag_str
);
nsAString_GetData
(
&
tag_str
,
&
tag
,
NULL
);
if
(
CompareStringW
(
LOCALE_SYSTEM_DEFAULT
,
NORM_IGNORECASE
,
tag
,
-
1
,
V_BSTR
(
&
name
),
-
1
)
==
CSTR_EQUAL
)
{
TRACE
(
"Found name. elem=%d
\n
"
,
i
);
if
(
V_VT
(
&
index
)
==
VT_I4
)
if
(
buf
.
len
==
V_I4
(
&
index
))
{
nsAString_Finish
(
&
tag_str
);
mshtml_free
(
buf
.
buf
);
buf
.
buf
=
NULL
;
*
pdisp
=
(
IDispatch
*
)
This
->
elems
[
i
];
TRACE
(
"Returning element %d pdisp=%p
\n
"
,
i
,
pdisp
);
IDispatch_AddRef
(
*
pdisp
);
return
S_OK
;
}
elem_vector_add
(
&
buf
,
This
->
elems
[
i
]);
if
(
V_VT
(
&
index
)
==
VT_I4
)
{
LONG
idx
=
V_I4
(
&
index
);
TRACE
(
"index = %d
\n
"
,
idx
);
if
(
idx
<
0
)
return
E_INVALIDARG
;
for
(
i
=
0
;
i
<
This
->
len
;
i
++
)
{
if
(
is_elem_name
(
This
->
elems
[
i
],
V_BSTR
(
&
name
))
&&
!
idx
--
)
break
;
}
if
(
i
!=
This
->
len
)
{
*
pdisp
=
(
IDispatch
*
)
HTMLELEM
(
This
->
elems
[
i
]);
IDispatch_AddRef
(
*
pdisp
);
}
return
S_OK
;
}
else
{
elem_vector
buf
=
{
NULL
,
0
,
8
};
buf
.
buf
=
mshtml_alloc
(
buf
.
size
*
sizeof
(
HTMLElement
*
));
for
(
i
=
0
;
i
<
This
->
len
;
i
++
)
{
if
(
is_elem_name
(
This
->
elems
[
i
],
V_BSTR
(
&
name
)))
elem_vector_add
(
&
buf
,
This
->
elems
[
i
]);
}
if
(
buf
.
len
>
1
)
{
elem_vector_normalize
(
&
buf
);
*
pdisp
=
(
IDispatch
*
)
HTMLElementCollection_Create
(
This
->
ref_unk
,
buf
.
buf
,
buf
.
len
);
}
else
{
if
(
buf
.
len
==
1
)
{
*
pdisp
=
(
IDispatch
*
)
HTMLELEM
(
buf
.
buf
[
0
]);
IDispatch_AddRef
(
*
pdisp
);
}
mshtml_free
(
buf
.
buf
);
}
return
S_OK
;
}
nsAString_Finish
(
&
tag_str
);
if
(
V_VT
(
&
index
)
==
VT_I4
)
{
mshtml_free
(
buf
.
buf
);
buf
.
buf
=
NULL
;
ERR
(
"Invalid index. index=%d >= buf.len=%d
\n
"
,
V_I4
(
&
index
),
buf
.
len
);
return
E_INVALIDARG
;
}
elem_vector_normalize
(
&
buf
);
TRACE
(
"Returning %d element(s).
\n
"
,
buf
.
len
);
*
pdisp
=
(
IDispatch
*
)
HTMLElementCollection_Create
(
This
->
ref_unk
,
buf
.
buf
,
buf
.
len
);
return
S_OK
;
}
FIXME
(
"unsupported arguments
\n
"
);
...
...
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