Commit 3d685993 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added IHTMLElementCollection::tags implementation.

parent 78872852
...@@ -1096,8 +1096,52 @@ static HRESULT WINAPI HTMLElementCollection_tags(IHTMLElementCollection *iface, ...@@ -1096,8 +1096,52 @@ static HRESULT WINAPI HTMLElementCollection_tags(IHTMLElementCollection *iface,
VARIANT tagName, IDispatch **pdisp) VARIANT tagName, IDispatch **pdisp)
{ {
HTMLElementCollection *This = ELEMCOL_THIS(iface); HTMLElementCollection *This = ELEMCOL_THIS(iface);
FIXME("(%p)->(%s %p)\n", This, debugstr_w(V_BSTR(&tagName)), pdisp); DWORD size = 8, len = 0, i;
return E_NOTIMPL; HTMLElement **elem_list;
nsAString tag_str;
const PRUnichar *tag;
if(V_VT(&tagName) != VT_BSTR) {
WARN("Invalid arg\n");
return E_INVALIDARG;
}
TRACE("(%p)->(%s %p)\n", This, debugstr_w(V_BSTR(&tagName)), pdisp);
elem_list = HeapAlloc(GetProcessHeap(), 0, size*sizeof(HTMLElement*));
nsAString_Init(&tag_str, NULL);
for(i=0; i<This->len; i++) {
if(!This->elems[i]->nselem)
continue;
nsIDOMElement_GetTagName(This->elems[i]->nselem, &tag_str);
nsAString_GetData(&tag_str, &tag, NULL);
if(CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, tag, -1,
V_BSTR(&tagName), -1) == CSTR_EQUAL) {
if(len == size) {
size <<= 2;
elem_list = HeapReAlloc(GetProcessHeap(), 0, elem_list, size);
}
elem_list[len++] = This->elems[i];
}
}
nsAString_Finish(&tag_str);
TRACE("fount %ld tags\n", len);
if(!len) {
HeapFree(GetProcessHeap(), 0, elem_list);
elem_list = NULL;
}else if(size > len) {
HeapReAlloc(GetProcessHeap(), 0, elem_list, len);
}
return HTMLElementCollection_Create(This->ref_unk, elem_list, len, pdisp);
} }
#undef ELEMCOL_THIS #undef ELEMCOL_THIS
......
...@@ -203,6 +203,10 @@ PRUint32 nsACString_GetData(const nsACString*,const char**,PRBool*); ...@@ -203,6 +203,10 @@ PRUint32 nsACString_GetData(const nsACString*,const char**,PRBool*);
void nsACString_SetData(nsACString*,const char*); void nsACString_SetData(nsACString*,const char*);
void nsACString_Destroy(nsACString*); void nsACString_Destroy(nsACString*);
void nsAString_Init(nsAString*,const PRUnichar*);
PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**,PRBool*);
void nsAString_Finish(nsAString*);
nsIInputStream *create_nsstream(const char*,PRInt32); nsIInputStream *create_nsstream(const char*,PRInt32);
IHlink *Hlink_Create(void); IHlink *Hlink_Create(void);
......
...@@ -44,13 +44,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); ...@@ -44,13 +44,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
#define PR_UINT32_MAX 0xffffffff #define PR_UINT32_MAX 0xffffffff
struct nsStringContainer {
void *v;
void *d1;
PRUint32 d2;
void *d3;
};
struct nsCStringContainer { struct nsCStringContainer {
void *v; void *v;
void *d1; void *d1;
...@@ -68,6 +61,7 @@ static nsresult (*NS_CStringContainerFinish)(nsCStringContainer*); ...@@ -68,6 +61,7 @@ static nsresult (*NS_CStringContainerFinish)(nsCStringContainer*);
static nsresult (*NS_StringSetData)(nsAString*,const PRUnichar*,PRUint32); static nsresult (*NS_StringSetData)(nsAString*,const PRUnichar*,PRUint32);
static nsresult (*NS_CStringSetData)(nsACString*,const char*,PRUint32); static nsresult (*NS_CStringSetData)(nsACString*,const char*,PRUint32);
static nsresult (*NS_NewLocalFile)(const nsAString*,PRBool,nsIFile**); static nsresult (*NS_NewLocalFile)(const nsAString*,PRBool,nsIFile**);
static PRUint32 (*NS_StringGetData)(const nsAString*,const PRUnichar **,PRBool*);
static PRUint32 (*NS_CStringGetData)(const nsACString*,const char**,PRBool*); static PRUint32 (*NS_CStringGetData)(const nsACString*,const char**,PRBool*);
static HINSTANCE hXPCOM = NULL; static HINSTANCE hXPCOM = NULL;
...@@ -304,6 +298,7 @@ static BOOL load_gecko(void) ...@@ -304,6 +298,7 @@ static BOOL load_gecko(void)
NS_DLSYM(NS_StringSetData); NS_DLSYM(NS_StringSetData);
NS_DLSYM(NS_CStringSetData); NS_DLSYM(NS_CStringSetData);
NS_DLSYM(NS_NewLocalFile); NS_DLSYM(NS_NewLocalFile);
NS_DLSYM(NS_StringGetData);
NS_DLSYM(NS_CStringGetData); NS_DLSYM(NS_CStringGetData);
#undef NS_DLSYM #undef NS_DLSYM
...@@ -390,6 +385,23 @@ void nsACString_Destroy(nsACString *str) ...@@ -390,6 +385,23 @@ void nsACString_Destroy(nsACString *str)
HeapFree(GetProcessHeap(), 0, str); HeapFree(GetProcessHeap(), 0, str);
} }
void nsAString_Init(nsAString *str, const PRUnichar *data)
{
NS_StringContainerInit(str);
if(data)
NS_StringSetData(str, data, PR_UINT32_MAX);
}
PRUint32 nsAString_GetData(const nsAString *str, const PRUnichar **data, PRBool *termited)
{
return NS_StringGetData(str, data, termited);
}
void nsAString_Finish(nsAString *str)
{
NS_StringContainerFinish(str);
}
nsIInputStream *create_nsstream(const char *data, PRInt32 data_len) nsIInputStream *create_nsstream(const char *data, PRInt32 data_len)
{ {
nsIStringInputStream *ret; nsIStringInputStream *ret;
......
...@@ -47,8 +47,14 @@ typedef ULARGE_INTEGER PRUint64; ...@@ -47,8 +47,14 @@ typedef ULARGE_INTEGER PRUint64;
typedef PRUint64 DOMTimeStamp; typedef PRUint64 DOMTimeStamp;
typedef PRUint32 nsLoadFlags; typedef PRUint32 nsLoadFlags;
typedef struct {
void *v;
void *d1;
PRUint32 d2;
void *d3;
} nsStringContainer;
typedef struct nsCStringContainer nsCStringContainer; typedef struct nsCStringContainer nsCStringContainer;
typedef struct nsStringContainer nsStringContainer;
typedef nsCStringContainer nsACString; typedef nsCStringContainer nsACString;
typedef nsStringContainer nsAString; typedef nsStringContainer nsAString;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment