From 134dad7ecdc2113c0e7d4f43ec7f52e6ef89f9b9 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Sat, 8 Mar 2008 20:14:38 +0100 Subject: [PATCH] mshtml: Added IHTMLScriptElement:get_type implementation. --- dlls/mshtml/htmlscript.c | 25 +++++++++++++++++++++++-- dlls/mshtml/nsiface.idl | 24 ++++++++++++++++++++++++ dlls/mshtml/tests/dom.c | 19 ++++++++++++++++++- 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/dlls/mshtml/htmlscript.c b/dlls/mshtml/htmlscript.c index fa7867d699b..5bf4a180c5e 100644 --- a/dlls/mshtml/htmlscript.c +++ b/dlls/mshtml/htmlscript.c @@ -39,6 +39,8 @@ typedef struct { HTMLElement element; const IHTMLScriptElementVtbl *lpHTMLScriptElementVtbl; + + nsIDOMHTMLScriptElement *nsscript; } HTMLScriptElement; #define HTMLSCRIPT(x) ((IHTMLScriptElement*) &(x)->lpHTMLScriptElementVtbl) @@ -203,8 +205,22 @@ static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p) { HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + const PRUnichar *nstype; + nsAString nstype_str; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + nsAString_Init(&nstype_str, NULL); + nsres = nsIDOMHTMLScriptElement_GetType(This->nsscript, &nstype_str); + if(NS_FAILED(nsres)) + ERR("GetType failed: %08x\n", nsres); + + nsAString_GetData(&nstype_str, &nstype); + *p = *nstype ? SysAllocString(nstype) : NULL; + nsAString_Finish(&nstype_str); + + return S_OK; } static const IHTMLScriptElementVtbl HTMLScriptElementVtbl = { @@ -277,11 +293,16 @@ static const NodeImplVtbl HTMLScriptElementImplVtbl = { HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement *nselem) { HTMLScriptElement *ret = heap_alloc(sizeof(HTMLScriptElement)); + nsresult nsres; HTMLElement_Init(&ret->element); ret->lpHTMLScriptElementVtbl = &HTMLScriptElementVtbl; ret->element.node.vtbl = &HTMLScriptElementImplVtbl; + nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLScriptElement, (void**)&ret->nsscript); + if(NS_FAILED(nsres)) + ERR("Could not get nsIDOMHTMLScriptElement: %08x\n", nsres); + return &ret->element; } diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index 2f60cdaa852..03115d9a04e 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -1271,6 +1271,30 @@ interface nsIDOMHTMLTextAreaElement : nsIDOMHTMLElement nsresult Select(); } +[ + object, + uuid(a6cf90b1-15b3-11d2-932e-00805f8add32), + local + /* FROZEN */ +] +interface nsIDOMHTMLScriptElement : nsIDOMHTMLElement +{ + nsresult GetText(nsAString *aText); + nsresult SetText(const nsAString *aText); + nsresult GetHtmlFor(nsAString *aHtmlFor); + nsresult SetHtmlFor(const nsAString *aHtmlFor); + nsresult GetEvent(nsAString *aEvent); + nsresult SetEvent(const nsAString *aEvent); + nsresult GetCharset(nsAString *aCharset); + nsresult SetCharset(const nsAString *aCharset); + nsresult GetDefer(PRBool *aDefer); + nsresult SetDefer(PRBool aDefer); + nsresult GetSrc(nsAString *aSrc); + nsresult SetSrc(const nsAString *aSrc); + nsresult GetType(nsAString *aType); + nsresult SetType(const nsAString *aType); +} + [ object, uuid(94928ab3-8b63-11d3-989d-001083010e9b), diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 60ddb6fec59..68a213013b4 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -43,7 +43,7 @@ static const char elem_test_str[] = "" "" "
" - "" + "" ""; static const char indent_test_str[] = "testabc
123"; @@ -54,6 +54,8 @@ static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0}; static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0}; static WCHAR wordW[] = {'w','o','r','d',0}; +static const WCHAR text_javascriptW[] = {'t','e','x','t','/','j','a','v','a','s','c','r','i','p','t',0}; + typedef enum { ET_NONE, ET_HTML, @@ -1193,6 +1195,7 @@ static void test_elems(IHTMLDocument2 *doc) static const WCHAR xW[] = {'x',0}; static const WCHAR sW[] = {'s',0}; + static const WCHAR scW[] = {'s','c',0}; static const WCHAR xxxW[] = {'x','x','x',0}; static const elem_type_t all_types[] = { @@ -1250,6 +1253,20 @@ static void test_elems(IHTMLDocument2 *doc) IHTMLElement_Release(elem); } + elem = get_elem_by_id(doc, scW, TRUE); + if(elem) { + IHTMLScriptElement *script; + BSTR type; + + hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLScriptElement, (void**)&script); + ok(hres == S_OK, "Could not get IHTMLScriptElement interface: %08x\n", hres); + + hres = IHTMLScriptElement_get_type(script, &type); + ok(hres == S_OK, "get_type failed: %08x\n", hres); + ok(!lstrcmpW(type, text_javascriptW), "Unexpected type %s\n", dbgstr_w(type)); + SysFreeString(type); + } + test_stylesheets(doc); test_create_option_elem(doc); }