Jacek Caban : mshtml: Added IHTMLScriptElement:get_type implementation.
Alexandre Julliard
julliard at winehq.org
Mon Mar 10 07:16:52 CDT 2008
Module: wine
Branch: master
Commit: 134dad7ecdc2113c0e7d4f43ec7f52e6ef89f9b9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=134dad7ecdc2113c0e7d4f43ec7f52e6ef89f9b9
Author: Jacek Caban <jacek at codeweavers.com>
Date: Sat Mar 8 20:14:38 2008 +0100
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 fa7867d..5bf4a18 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 2f60cda..03115d9 100644
--- a/dlls/mshtml/nsiface.idl
+++ b/dlls/mshtml/nsiface.idl
@@ -1273,6 +1273,30 @@ interface nsIDOMHTMLTextAreaElement : nsIDOMHTMLElement
[
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),
local
/* FROZEN */
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index 60ddb6f..68a2130 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -43,7 +43,7 @@ static const char elem_test_str[] =
"<select id=\"s\"><option id=\"x\">opt1</option><option id=\"y\">opt2</option></select>"
"<textarea id=\"X\">text text</textarea>"
"<table><tbody></tbody></table>"
- "<script type=\"text/javascript\"></script>"
+ "<script id=\"sc\" type=\"text/javascript\"></script>"
"</body></html>";
static const char indent_test_str[] =
"<html><head><title>test</title></head><body>abc<br /><a href=\"about:blank\">123</a></body></html>";
@@ -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);
}
More information about the wine-cvs
mailing list