2008-03-03 01:20:27 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
2014-11-06 12:21:47 +01:00
|
|
|
#include "htmlevent.h"
|
2012-10-16 17:07:29 +02:00
|
|
|
#include "htmlscript.h"
|
2008-03-03 01:20:27 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
2010-12-06 23:31:50 +01:00
|
|
|
static inline HTMLScriptElement *impl_from_IHTMLScriptElement(IHTMLScriptElement *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLScriptElement, IHTMLScriptElement_iface);
|
|
|
|
}
|
2008-03-03 01:20:27 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_QueryInterface(IHTMLScriptElement *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2008-03-03 01:20:27 +01:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLScriptElement_AddRef(IHTMLScriptElement *iface)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2008-03-03 01:20:27 +01:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLScriptElement_Release(IHTMLScriptElement *iface)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2008-03-03 01:20:27 +01:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_GetTypeInfoCount(IHTMLScriptElement *iface, UINT *pctinfo)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_GetTypeInfo(IHTMLScriptElement *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
|
2010-12-31 11:07:33 +01:00
|
|
|
ppTInfo);
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_GetIDsOfNames(IHTMLScriptElement *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames,
|
|
|
|
LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
|
2010-12-31 11:07:33 +01:00
|
|
|
cNames, lcid, rgDispId);
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_Invoke(IHTMLScriptElement *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
|
2010-12-31 11:07:33 +01:00
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_put_src(IHTMLScriptElement *iface, BSTR v)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2012-10-16 17:07:48 +02:00
|
|
|
nsAString src_str;
|
|
|
|
nsresult nsres;
|
2016-07-19 18:40:36 +02:00
|
|
|
HRESULT hres;
|
2012-10-16 17:07:48 +02:00
|
|
|
|
2012-10-17 12:20:06 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
|
2012-10-16 17:07:48 +02:00
|
|
|
|
|
|
|
nsAString_InitDepend(&src_str, v);
|
|
|
|
nsres = nsIDOMHTMLScriptElement_SetSrc(This->nsscript, &src_str);
|
|
|
|
nsAString_Finish(&src_str);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("SetSrc failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(This->parsed) {
|
|
|
|
WARN("already parsed\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2016-07-19 18:42:06 +02:00
|
|
|
if(This->binding) {
|
|
|
|
FIXME("binding in progress\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2016-07-19 18:40:36 +02:00
|
|
|
nsAString_Init(&src_str, NULL);
|
|
|
|
nsres = nsIDOMHTMLScriptElement_GetSrc(This->nsscript, &src_str);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
const PRUnichar *src;
|
|
|
|
nsAString_GetData(&src_str, &src);
|
2016-07-19 18:42:06 +02:00
|
|
|
hres = load_script(This, src, TRUE);
|
2016-07-19 18:40:36 +02:00
|
|
|
}else {
|
|
|
|
ERR("SetSrc failed: %08x\n", nsres);
|
|
|
|
hres = E_FAIL;
|
2012-10-16 17:07:48 +02:00
|
|
|
}
|
2016-07-19 18:40:36 +02:00
|
|
|
nsAString_Finish(&src_str);
|
|
|
|
return hres;
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_get_src(IHTMLScriptElement *iface, BSTR *p)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2010-12-17 03:39:11 +01:00
|
|
|
nsAString src_str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&src_str, NULL);
|
|
|
|
nsres = nsIDOMHTMLScriptElement_GetSrc(This->nsscript, &src_str);
|
|
|
|
return return_nsstr(nsres, &src_str, p);
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_put_htmlFor(IHTMLScriptElement *iface, BSTR v)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2008-03-03 01:20:27 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_w(v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_get_htmlFor(IHTMLScriptElement *iface, BSTR *p)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2020-01-21 21:26:43 +01:00
|
|
|
nsAString html_str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&html_str, NULL);
|
|
|
|
nsres = nsIDOMHTMLScriptElement_GetHtmlFor(This->nsscript, &html_str);
|
|
|
|
return return_nsstr(nsres, &html_str, p);
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_put_event(IHTMLScriptElement *iface, BSTR v)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2008-03-03 01:20:27 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_w(v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_get_event(IHTMLScriptElement *iface, BSTR *p)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2008-03-03 01:20:27 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_put_text(IHTMLScriptElement *iface, BSTR v)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2013-01-15 13:39:54 +01:00
|
|
|
HTMLInnerWindow *window;
|
|
|
|
nsIDOMNode *parent;
|
|
|
|
nsAString text_str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
|
|
|
|
|
|
|
|
if(!This->element.node.doc || !This->element.node.doc->window) {
|
2021-06-08 18:15:42 +02:00
|
|
|
WARN("no window\n");
|
2013-01-15 13:39:54 +01:00
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
window = This->element.node.doc->window;
|
|
|
|
|
|
|
|
nsAString_InitDepend(&text_str, v);
|
|
|
|
nsres = nsIDOMHTMLScriptElement_SetText(This->nsscript, &text_str);
|
|
|
|
nsAString_Finish(&text_str);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("SetSrc failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2018-02-12 23:28:15 +01:00
|
|
|
nsres = nsIDOMElement_GetParentNode(This->element.dom_element, &parent);
|
2013-01-15 13:39:54 +01:00
|
|
|
if(NS_FAILED(nsres) || !parent) {
|
|
|
|
TRACE("No parent, not executing\n");
|
|
|
|
This->parse_on_bind = TRUE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIDOMNode_Release(parent);
|
2016-07-19 18:41:06 +02:00
|
|
|
doc_insert_script(window, This, FALSE);
|
2013-01-15 13:39:54 +01:00
|
|
|
return S_OK;
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_get_text(IHTMLScriptElement *iface, BSTR *p)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2012-11-13 13:35:49 +01:00
|
|
|
nsAString nsstr;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&nsstr, NULL);
|
|
|
|
nsres = nsIDOMHTMLScriptElement_GetText(This->nsscript, &nsstr);
|
|
|
|
return return_nsstr(nsres, &nsstr, p);
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_put_defer(IHTMLScriptElement *iface, VARIANT_BOOL v)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2008-12-12 10:14:17 +01:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%x)\n", This, v);
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLScriptElement_SetDefer(This->nsscript, v != VARIANT_FALSE);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
{
|
|
|
|
hr = E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_get_defer(IHTMLScriptElement *iface, VARIANT_BOOL *p)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2012-03-15 11:55:01 +01:00
|
|
|
cpp_bool defer = FALSE;
|
2008-12-12 10:14:17 +01:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
if(!p)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLScriptElement_GetDefer(This->nsscript, &defer);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("GetSrc failed: %08x\n", nsres);
|
|
|
|
}
|
|
|
|
|
2017-11-02 16:48:02 +01:00
|
|
|
*p = variant_bool(defer);
|
2008-12-12 10:14:17 +01:00
|
|
|
return S_OK;
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_get_readyState(IHTMLScriptElement *iface, BSTR *p)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2014-10-09 16:09:07 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
return get_readystate_string(This->readystate, p);
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_put_onerror(IHTMLScriptElement *iface, VARIANT v)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2014-11-06 12:21:47 +01:00
|
|
|
|
|
|
|
FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
|
|
|
|
|
|
|
|
return set_node_event(&This->element.node, EVENTID_ERROR, &v);
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_get_onerror(IHTMLScriptElement *iface, VARIANT *p)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2014-11-06 12:21:47 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
return get_node_event(&This->element.node, EVENTID_ERROR, p);
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR v)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2010-02-25 22:55:22 +01:00
|
|
|
nsAString nstype_str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
|
|
|
|
|
|
|
|
nsAString_Init(&nstype_str, v);
|
|
|
|
nsres = nsIDOMHTMLScriptElement_SetType(This->nsscript, &nstype_str);
|
|
|
|
if (NS_FAILED(nsres))
|
|
|
|
ERR("SetType failed: %08x\n", nsres);
|
|
|
|
nsAString_Finish (&nstype_str);
|
|
|
|
|
|
|
|
return S_OK;
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p)
|
|
|
|
{
|
2010-12-06 23:31:50 +01:00
|
|
|
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
|
2008-03-08 20:14:38 +01:00
|
|
|
nsAString nstype_str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&nstype_str, NULL);
|
|
|
|
nsres = nsIDOMHTMLScriptElement_GetType(This->nsscript, &nstype_str);
|
2012-04-13 12:20:25 +02:00
|
|
|
return return_nsstr(nsres, &nstype_str, p);
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IHTMLScriptElementVtbl HTMLScriptElementVtbl = {
|
|
|
|
HTMLScriptElement_QueryInterface,
|
|
|
|
HTMLScriptElement_AddRef,
|
|
|
|
HTMLScriptElement_Release,
|
|
|
|
HTMLScriptElement_GetTypeInfoCount,
|
|
|
|
HTMLScriptElement_GetTypeInfo,
|
|
|
|
HTMLScriptElement_GetIDsOfNames,
|
|
|
|
HTMLScriptElement_Invoke,
|
|
|
|
HTMLScriptElement_put_src,
|
|
|
|
HTMLScriptElement_get_src,
|
|
|
|
HTMLScriptElement_put_htmlFor,
|
|
|
|
HTMLScriptElement_get_htmlFor,
|
|
|
|
HTMLScriptElement_put_event,
|
|
|
|
HTMLScriptElement_get_event,
|
|
|
|
HTMLScriptElement_put_text,
|
|
|
|
HTMLScriptElement_get_text,
|
|
|
|
HTMLScriptElement_put_defer,
|
|
|
|
HTMLScriptElement_get_defer,
|
|
|
|
HTMLScriptElement_get_readyState,
|
|
|
|
HTMLScriptElement_put_onerror,
|
|
|
|
HTMLScriptElement_get_onerror,
|
|
|
|
HTMLScriptElement_put_type,
|
|
|
|
HTMLScriptElement_get_type
|
|
|
|
};
|
|
|
|
|
2010-12-27 20:13:09 +01:00
|
|
|
static inline HTMLScriptElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLScriptElement, element.node);
|
|
|
|
}
|
2008-03-03 01:20:27 +01:00
|
|
|
|
|
|
|
static HRESULT HTMLScriptElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-27 20:13:09 +01:00
|
|
|
HTMLScriptElement *This = impl_from_HTMLDOMNode(iface);
|
2008-03-03 01:20:27 +01:00
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
2010-12-06 23:31:50 +01:00
|
|
|
*ppv = &This->IHTMLScriptElement_iface;
|
2008-03-03 01:20:27 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
|
2010-12-06 23:31:50 +01:00
|
|
|
*ppv = &This->IHTMLScriptElement_iface;
|
2008-03-03 01:20:27 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLScriptElement, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHTMLScriptElement %p)\n", This, ppv);
|
2010-12-06 23:31:50 +01:00
|
|
|
*ppv = &This->IHTMLScriptElement_iface;
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return HTMLElement_QI(&This->element.node, riid, ppv);
|
|
|
|
}
|
|
|
|
|
2016-07-19 18:39:47 +02:00
|
|
|
static void HTMLScriptElement_destructor(HTMLDOMNode *iface)
|
|
|
|
{
|
|
|
|
HTMLScriptElement *This = impl_from_HTMLDOMNode(iface);
|
|
|
|
heap_free(This->src_text);
|
|
|
|
HTMLElement_destructor(&This->element.node);
|
|
|
|
}
|
|
|
|
|
2009-11-30 17:58:59 +01:00
|
|
|
static HRESULT HTMLScriptElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
|
|
|
|
{
|
2010-12-27 20:13:09 +01:00
|
|
|
HTMLScriptElement *This = impl_from_HTMLDOMNode(iface);
|
2009-11-30 17:58:59 +01:00
|
|
|
|
2010-12-06 23:31:50 +01:00
|
|
|
return IHTMLScriptElement_get_readyState(&This->IHTMLScriptElement_iface, p);
|
2009-11-30 17:58:59 +01:00
|
|
|
}
|
|
|
|
|
2016-07-19 18:36:27 +02:00
|
|
|
static HRESULT HTMLScriptElement_bind_to_tree(HTMLDOMNode *iface)
|
|
|
|
{
|
|
|
|
HTMLScriptElement *This = impl_from_HTMLDOMNode(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
if(!This->parse_on_bind)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
if(!This->element.node.doc || !This->element.node.doc->window) {
|
|
|
|
ERR("No window\n");
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->parse_on_bind = FALSE;
|
2016-07-19 18:41:06 +02:00
|
|
|
doc_insert_script(This->element.node.doc->window, This, FALSE);
|
2016-07-19 18:36:27 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-09-26 15:11:33 +02:00
|
|
|
static void HTMLScriptElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
|
|
|
|
{
|
|
|
|
HTMLScriptElement *This = impl_from_HTMLDOMNode(iface);
|
|
|
|
|
|
|
|
if(This->nsscript)
|
|
|
|
note_cc_edge((nsISupports*)This->nsscript, "This->nsscript", cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void HTMLScriptElement_unlink(HTMLDOMNode *iface)
|
|
|
|
{
|
|
|
|
HTMLScriptElement *This = impl_from_HTMLDOMNode(iface);
|
|
|
|
|
|
|
|
if(This->nsscript) {
|
|
|
|
nsIDOMHTMLScriptElement *nsscript = This->nsscript;
|
|
|
|
|
|
|
|
This->nsscript = NULL;
|
|
|
|
nsIDOMHTMLScriptElement_Release(nsscript);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-03 01:20:27 +01:00
|
|
|
static const NodeImplVtbl HTMLScriptElementImplVtbl = {
|
2017-04-21 13:50:49 +02:00
|
|
|
&CLSID_HTMLScriptElement,
|
2008-03-03 01:20:27 +01:00
|
|
|
HTMLScriptElement_QI,
|
2016-07-19 18:39:47 +02:00
|
|
|
HTMLScriptElement_destructor,
|
2013-03-15 15:01:53 +01:00
|
|
|
HTMLElement_cpc,
|
2010-11-14 14:41:39 +01:00
|
|
|
HTMLElement_clone,
|
2012-09-04 13:58:58 +02:00
|
|
|
HTMLElement_handle_event,
|
2011-08-25 15:23:35 +02:00
|
|
|
HTMLElement_get_attr_col,
|
2009-11-30 17:58:59 +01:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-09-26 15:11:33 +02:00
|
|
|
HTMLScriptElement_get_readystate,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2016-07-19 18:36:27 +02:00
|
|
|
HTMLScriptElement_bind_to_tree,
|
2014-09-26 15:11:33 +02:00
|
|
|
HTMLScriptElement_traverse,
|
|
|
|
HTMLScriptElement_unlink
|
2008-03-03 01:20:27 +01:00
|
|
|
};
|
|
|
|
|
2018-02-19 14:49:39 +01:00
|
|
|
HRESULT script_elem_from_nsscript(nsIDOMHTMLScriptElement *nsscript, HTMLScriptElement **ret)
|
2012-10-02 15:45:40 +02:00
|
|
|
{
|
2014-10-01 11:23:47 +02:00
|
|
|
nsIDOMNode *nsnode;
|
2012-10-02 15:45:40 +02:00
|
|
|
HTMLDOMNode *node;
|
2014-10-01 11:23:47 +02:00
|
|
|
nsresult nsres;
|
2012-10-02 15:45:40 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2014-10-01 11:23:47 +02:00
|
|
|
nsres = nsIDOMHTMLScriptElement_QueryInterface(nsscript, &IID_nsIDOMNode, (void**)&nsnode);
|
|
|
|
assert(nsres == NS_OK);
|
|
|
|
|
2018-02-19 14:49:07 +01:00
|
|
|
hres = get_node(nsnode, TRUE, &node);
|
2014-10-01 11:23:47 +02:00
|
|
|
nsIDOMNode_Release(nsnode);
|
2012-10-02 15:45:40 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
assert(node->vtbl == &HTMLScriptElementImplVtbl);
|
|
|
|
*ret = impl_from_HTMLDOMNode(node);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-01-28 02:10:24 +01:00
|
|
|
static const tid_t HTMLScriptElement_iface_tids[] = {
|
|
|
|
HTMLELEMENT_TIDS,
|
|
|
|
IHTMLScriptElement_tid,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
static dispex_static_data_t HTMLScriptElement_dispex = {
|
2021-10-06 17:11:31 +02:00
|
|
|
L"HTMLScriptElement",
|
2010-01-28 02:10:24 +01:00
|
|
|
NULL,
|
|
|
|
DispHTMLScriptElement_tid,
|
2016-07-07 12:50:18 +02:00
|
|
|
HTMLScriptElement_iface_tids,
|
|
|
|
HTMLElement_init_dispex_info
|
2010-01-28 02:10:24 +01:00
|
|
|
};
|
|
|
|
|
2018-02-12 01:29:41 +01:00
|
|
|
HRESULT HTMLScriptElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
|
2008-03-03 01:20:27 +01:00
|
|
|
{
|
2010-12-01 22:43:14 +01:00
|
|
|
HTMLScriptElement *ret;
|
2008-03-08 20:14:38 +01:00
|
|
|
nsresult nsres;
|
2008-03-03 01:20:27 +01:00
|
|
|
|
2010-12-01 22:43:14 +01:00
|
|
|
ret = heap_alloc_zero(sizeof(HTMLScriptElement));
|
|
|
|
if(!ret)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2010-12-06 23:31:50 +01:00
|
|
|
ret->IHTMLScriptElement_iface.lpVtbl = &HTMLScriptElementVtbl;
|
2008-03-03 01:20:27 +01:00
|
|
|
ret->element.node.vtbl = &HTMLScriptElementImplVtbl;
|
|
|
|
|
2012-06-27 10:58:11 +02:00
|
|
|
HTMLElement_Init(&ret->element, doc, nselem, &HTMLScriptElement_dispex);
|
|
|
|
|
2018-02-12 01:29:41 +01:00
|
|
|
nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLScriptElement, (void**)&ret->nsscript);
|
2014-09-26 15:11:33 +02:00
|
|
|
assert(nsres == NS_OK);
|
2008-03-08 20:14:38 +01:00
|
|
|
|
2010-12-01 22:43:14 +01:00
|
|
|
*elem = &ret->element;
|
|
|
|
return S_OK;
|
2008-03-03 01:20:27 +01:00
|
|
|
}
|