2008-12-30 06:48:59 +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 "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2013-04-29 10:47:19 +02:00
|
|
|
#include <assert.h>
|
2008-12-30 06:48:59 +01:00
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "ole2.h"
|
2009-11-08 15:40:11 +01:00
|
|
|
#include "shlguid.h"
|
2008-12-30 06:48:59 +01:00
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
2012-10-16 17:07:29 +02:00
|
|
|
#include "htmlscript.h"
|
2008-12-30 06:48:59 +01:00
|
|
|
#include "htmlevent.h"
|
2012-11-12 12:58:41 +01:00
|
|
|
#include "binding.h"
|
2008-12-30 06:48:59 +01:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
2008-12-30 21:20:57 +01:00
|
|
|
#define IE_MAJOR_VERSION 7
|
|
|
|
#define IE_MINOR_VERSION 0
|
|
|
|
|
2011-03-15 13:45:29 +01:00
|
|
|
static const IID NS_ICONTENTUTILS_CID =
|
|
|
|
{0x762C4AE7,0xB923,0x422F,{0xB9,0x7E,0xB9,0xBF,0xC1,0xEF,0x7B,0xF0}};
|
|
|
|
|
|
|
|
static nsIContentUtils *content_utils;
|
|
|
|
|
2011-06-17 16:18:05 +02:00
|
|
|
static PRUnichar *handle_insert_comment(HTMLDocumentNode *doc, const PRUnichar *comment)
|
2008-12-30 21:20:57 +01:00
|
|
|
{
|
|
|
|
int majorv = 0, minorv = 0;
|
|
|
|
const PRUnichar *ptr, *end;
|
|
|
|
PRUnichar *buf;
|
2011-06-17 16:18:05 +02:00
|
|
|
DWORD len;
|
2008-12-30 21:20:57 +01:00
|
|
|
|
|
|
|
enum {
|
|
|
|
CMP_EQ,
|
|
|
|
CMP_LT,
|
|
|
|
CMP_LTE,
|
|
|
|
CMP_GT,
|
|
|
|
CMP_GTE
|
|
|
|
} cmpt = CMP_EQ;
|
|
|
|
|
|
|
|
static const PRUnichar endifW[] = {'<','!','[','e','n','d','i','f',']'};
|
|
|
|
|
|
|
|
if(comment[0] != '[' || comment[1] != 'i' || comment[2] != 'f')
|
2011-06-17 16:18:05 +02:00
|
|
|
return NULL;
|
2008-12-30 21:20:57 +01:00
|
|
|
|
|
|
|
ptr = comment+3;
|
|
|
|
while(isspaceW(*ptr))
|
|
|
|
ptr++;
|
|
|
|
|
|
|
|
if(ptr[0] == 'l' && ptr[1] == 't') {
|
|
|
|
ptr += 2;
|
|
|
|
if(*ptr == 'e') {
|
|
|
|
cmpt = CMP_LTE;
|
|
|
|
ptr++;
|
|
|
|
}else {
|
|
|
|
cmpt = CMP_LT;
|
|
|
|
}
|
|
|
|
}else if(ptr[0] == 'g' && ptr[1] == 't') {
|
|
|
|
ptr += 2;
|
|
|
|
if(*ptr == 'e') {
|
|
|
|
cmpt = CMP_GTE;
|
|
|
|
ptr++;
|
|
|
|
}else {
|
|
|
|
cmpt = CMP_GT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!isspaceW(*ptr++))
|
2011-06-17 16:18:05 +02:00
|
|
|
return NULL;
|
2008-12-30 21:20:57 +01:00
|
|
|
while(isspaceW(*ptr))
|
|
|
|
ptr++;
|
|
|
|
|
|
|
|
if(ptr[0] != 'I' || ptr[1] != 'E')
|
2011-06-17 16:18:05 +02:00
|
|
|
return NULL;
|
2008-12-30 21:20:57 +01:00
|
|
|
|
|
|
|
ptr +=2;
|
|
|
|
if(!isspaceW(*ptr++))
|
2011-06-17 16:18:05 +02:00
|
|
|
return NULL;
|
2008-12-30 21:20:57 +01:00
|
|
|
while(isspaceW(*ptr))
|
|
|
|
ptr++;
|
|
|
|
|
|
|
|
if(!isdigitW(*ptr))
|
2011-06-17 16:18:05 +02:00
|
|
|
return NULL;
|
2008-12-30 21:20:57 +01:00
|
|
|
while(isdigitW(*ptr))
|
|
|
|
majorv = majorv*10 + (*ptr++ - '0');
|
|
|
|
|
|
|
|
if(*ptr == '.') {
|
2008-12-31 17:16:23 +01:00
|
|
|
ptr++;
|
2008-12-30 21:20:57 +01:00
|
|
|
if(!isdigitW(*ptr))
|
2011-06-17 16:18:05 +02:00
|
|
|
return NULL;
|
2008-12-30 21:20:57 +01:00
|
|
|
while(isdigitW(*ptr))
|
|
|
|
minorv = minorv*10 + (*ptr++ - '0');
|
|
|
|
}
|
|
|
|
|
|
|
|
while(isspaceW(*ptr))
|
|
|
|
ptr++;
|
|
|
|
if(ptr[0] != ']' || ptr[1] != '>')
|
2011-06-17 16:18:05 +02:00
|
|
|
return NULL;
|
2008-12-30 21:20:57 +01:00
|
|
|
ptr += 2;
|
|
|
|
|
|
|
|
len = strlenW(ptr);
|
|
|
|
if(len < sizeof(endifW)/sizeof(WCHAR))
|
2011-06-17 16:18:05 +02:00
|
|
|
return NULL;
|
2008-12-30 21:20:57 +01:00
|
|
|
|
|
|
|
end = ptr + len-sizeof(endifW)/sizeof(WCHAR);
|
|
|
|
if(memcmp(end, endifW, sizeof(endifW)))
|
2011-06-17 16:18:05 +02:00
|
|
|
return NULL;
|
2008-12-30 21:20:57 +01:00
|
|
|
|
|
|
|
switch(cmpt) {
|
|
|
|
case CMP_EQ:
|
|
|
|
if(majorv == IE_MAJOR_VERSION && minorv == IE_MINOR_VERSION)
|
|
|
|
break;
|
2011-06-17 16:18:05 +02:00
|
|
|
return NULL;
|
2008-12-30 21:20:57 +01:00
|
|
|
case CMP_LT:
|
|
|
|
if(majorv > IE_MAJOR_VERSION)
|
|
|
|
break;
|
|
|
|
if(majorv == IE_MAJOR_VERSION && minorv > IE_MINOR_VERSION)
|
|
|
|
break;
|
2011-06-17 16:18:05 +02:00
|
|
|
return NULL;
|
2008-12-30 21:20:57 +01:00
|
|
|
case CMP_LTE:
|
|
|
|
if(majorv > IE_MAJOR_VERSION)
|
|
|
|
break;
|
|
|
|
if(majorv == IE_MAJOR_VERSION && minorv >= IE_MINOR_VERSION)
|
|
|
|
break;
|
2011-06-17 16:18:05 +02:00
|
|
|
return NULL;
|
2008-12-30 21:20:57 +01:00
|
|
|
case CMP_GT:
|
|
|
|
if(majorv < IE_MAJOR_VERSION)
|
|
|
|
break;
|
|
|
|
if(majorv == IE_MAJOR_VERSION && minorv < IE_MINOR_VERSION)
|
|
|
|
break;
|
2011-06-17 16:18:05 +02:00
|
|
|
return NULL;
|
2008-12-30 21:20:57 +01:00
|
|
|
case CMP_GTE:
|
|
|
|
if(majorv < IE_MAJOR_VERSION)
|
|
|
|
break;
|
|
|
|
if(majorv == IE_MAJOR_VERSION && minorv <= IE_MINOR_VERSION)
|
|
|
|
break;
|
2011-06-17 16:18:05 +02:00
|
|
|
return NULL;
|
2008-12-30 21:20:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
buf = heap_alloc((end-ptr+1)*sizeof(WCHAR));
|
|
|
|
if(!buf)
|
2011-06-17 16:18:05 +02:00
|
|
|
return NULL;
|
2008-12-30 21:20:57 +01:00
|
|
|
|
|
|
|
memcpy(buf, ptr, (end-ptr)*sizeof(WCHAR));
|
|
|
|
buf[end-ptr] = 0;
|
|
|
|
|
2011-06-17 16:18:05 +02:00
|
|
|
return buf;
|
2008-12-30 21:20:57 +01:00
|
|
|
}
|
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
static nsresult run_insert_comment(HTMLDocumentNode *doc, nsISupports *comment_iface, nsISupports *arg2)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
2011-01-31 00:32:30 +01:00
|
|
|
const PRUnichar *comment;
|
|
|
|
nsIDOMComment *nscomment;
|
2011-06-17 16:18:05 +02:00
|
|
|
PRUnichar *replace_html;
|
2011-01-31 00:32:30 +01:00
|
|
|
nsAString comment_str;
|
2008-12-30 06:48:59 +01:00
|
|
|
nsresult nsres;
|
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
nsres = nsISupports_QueryInterface(comment_iface, &IID_nsIDOMComment, (void**)&nscomment);
|
2008-12-30 06:48:59 +01:00
|
|
|
if(NS_FAILED(nsres)) {
|
2011-01-31 00:32:30 +01:00
|
|
|
ERR("Could not get nsIDOMComment iface:%08x\n", nsres);
|
|
|
|
return nsres;
|
2008-12-30 06:48:59 +01:00
|
|
|
}
|
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
nsAString_Init(&comment_str, NULL);
|
|
|
|
nsres = nsIDOMComment_GetData(nscomment, &comment_str);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return nsres;
|
|
|
|
|
|
|
|
nsAString_GetData(&comment_str, &comment);
|
2011-06-17 16:18:05 +02:00
|
|
|
replace_html = handle_insert_comment(doc, comment);
|
2011-01-31 00:32:30 +01:00
|
|
|
nsAString_Finish(&comment_str);
|
|
|
|
|
2011-06-17 16:18:05 +02:00
|
|
|
if(replace_html) {
|
|
|
|
HRESULT hres;
|
2011-01-31 00:32:30 +01:00
|
|
|
|
2011-06-17 16:18:05 +02:00
|
|
|
hres = replace_node_by_html(doc->nsdoc, (nsIDOMNode*)nscomment, replace_html);
|
|
|
|
heap_free(replace_html);
|
|
|
|
if(FAILED(hres))
|
|
|
|
nsres = NS_ERROR_FAILURE;
|
2008-12-30 06:48:59 +01:00
|
|
|
}
|
|
|
|
|
2011-06-17 16:18:05 +02:00
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
nsIDOMComment_Release(nscomment);
|
2011-06-17 16:18:05 +02:00
|
|
|
return nsres;
|
2008-12-30 06:48:59 +01:00
|
|
|
}
|
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
static nsresult run_bind_to_tree(HTMLDocumentNode *doc, nsISupports *nsiface, nsISupports *arg2)
|
2009-10-27 21:17:08 +01:00
|
|
|
{
|
2009-12-03 01:12:12 +01:00
|
|
|
nsIDOMNode *nsnode;
|
|
|
|
HTMLDOMNode *node;
|
2009-10-21 21:30:20 +02:00
|
|
|
nsresult nsres;
|
2010-12-01 12:52:08 +01:00
|
|
|
HRESULT hres;
|
2009-10-21 21:30:20 +02:00
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
TRACE("(%p)->(%p)\n", doc, nsiface);
|
|
|
|
|
2009-12-03 01:12:12 +01:00
|
|
|
nsres = nsISupports_QueryInterface(nsiface, &IID_nsIDOMNode, (void**)&nsnode);
|
|
|
|
if(NS_FAILED(nsres))
|
2011-01-31 00:32:30 +01:00
|
|
|
return nsres;
|
2009-11-01 19:19:41 +01:00
|
|
|
|
2010-12-01 12:52:08 +01:00
|
|
|
hres = get_node(doc, nsnode, TRUE, &node);
|
2009-12-03 01:12:12 +01:00
|
|
|
nsIDOMNode_Release(nsnode);
|
2010-12-01 12:52:08 +01:00
|
|
|
if(FAILED(hres)) {
|
2009-12-03 01:12:12 +01:00
|
|
|
ERR("Could not get node\n");
|
2011-01-31 00:32:30 +01:00
|
|
|
return nsres;
|
2009-11-01 19:19:41 +01:00
|
|
|
}
|
2009-10-27 21:17:08 +01:00
|
|
|
|
2009-12-03 01:12:12 +01:00
|
|
|
if(node->vtbl->bind_to_tree)
|
|
|
|
node->vtbl->bind_to_tree(node);
|
2011-01-31 00:32:30 +01:00
|
|
|
|
2012-06-25 14:04:40 +02:00
|
|
|
node_release(node);
|
2011-01-31 00:32:30 +01:00
|
|
|
return nsres;
|
2009-10-21 21:30:20 +02:00
|
|
|
}
|
|
|
|
|
2009-11-08 15:40:11 +01:00
|
|
|
/* Calls undocumented 69 cmd of CGID_Explorer */
|
|
|
|
static void call_explorer_69(HTMLDocumentObj *doc)
|
2009-11-01 19:24:34 +01:00
|
|
|
{
|
2009-11-08 15:40:11 +01:00
|
|
|
IOleCommandTarget *olecmd;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!doc->client)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
VariantInit(&var);
|
|
|
|
hres = IOleCommandTarget_Exec(olecmd, &CGID_Explorer, 69, 0, NULL, &var);
|
|
|
|
IOleCommandTarget_Release(olecmd);
|
|
|
|
if(SUCCEEDED(hres) && V_VT(&var) != VT_NULL)
|
|
|
|
FIXME("handle result\n");
|
|
|
|
}
|
|
|
|
|
2010-08-18 13:39:29 +02:00
|
|
|
static void parse_complete(HTMLDocumentObj *doc)
|
2009-11-08 15:40:11 +01:00
|
|
|
{
|
|
|
|
TRACE("(%p)\n", doc);
|
|
|
|
|
|
|
|
if(doc->usermode == EDITMODE)
|
|
|
|
init_editor(&doc->basedoc);
|
|
|
|
|
|
|
|
call_explorer_69(doc);
|
2010-02-15 16:03:25 +01:00
|
|
|
if(doc->view_sink)
|
|
|
|
IAdviseSink_OnViewChange(doc->view_sink, DVASPECT_CONTENT, -1);
|
2013-03-15 15:01:53 +01:00
|
|
|
call_property_onchanged(&doc->basedoc.cp_container, 1005);
|
2009-11-08 15:40:11 +01:00
|
|
|
call_explorer_69(doc);
|
|
|
|
|
2013-04-15 17:40:43 +02:00
|
|
|
if(doc->webbrowser && doc->usermode != EDITMODE && !(doc->basedoc.window->load_flags & BINDING_REFRESH))
|
2012-06-25 14:04:59 +02:00
|
|
|
IDocObjectService_FireNavigateComplete2(doc->doc_object_service, &doc->basedoc.window->base.IHTMLWindow2_iface, 0);
|
2011-11-15 13:29:59 +01:00
|
|
|
|
2009-11-08 15:40:11 +01:00
|
|
|
/* FIXME: IE7 calls EnableModelless(TRUE), EnableModelless(FALSE) and sets interactive state here */
|
2009-11-01 19:24:34 +01:00
|
|
|
}
|
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
static nsresult run_end_load(HTMLDocumentNode *This, nsISupports *arg1, nsISupports *arg2)
|
2009-11-01 19:24:34 +01:00
|
|
|
{
|
2011-01-31 00:32:30 +01:00
|
|
|
TRACE("(%p)\n", This);
|
2009-11-01 19:24:34 +01:00
|
|
|
|
2010-03-13 16:42:45 +01:00
|
|
|
if(!This->basedoc.doc_obj)
|
2011-01-31 00:32:30 +01:00
|
|
|
return NS_OK;
|
2010-03-13 16:42:45 +01:00
|
|
|
|
2010-08-18 13:39:29 +02:00
|
|
|
if(This == This->basedoc.doc_obj->basedoc.doc_node) {
|
|
|
|
/*
|
|
|
|
* This should be done in the worker thread that parses HTML,
|
|
|
|
* but we don't have such thread (Gecko parses HTML for us).
|
|
|
|
*/
|
|
|
|
parse_complete(This->basedoc.doc_obj);
|
2009-11-01 19:24:55 +01:00
|
|
|
}
|
2009-11-01 19:24:34 +01:00
|
|
|
|
2012-10-02 15:46:20 +02:00
|
|
|
bind_event_scripts(This);
|
2010-08-18 13:39:29 +02:00
|
|
|
set_ready_state(This->basedoc.window, READYSTATE_INTERACTIVE);
|
2011-01-31 00:32:30 +01:00
|
|
|
return NS_OK;
|
2009-11-01 19:24:34 +01:00
|
|
|
}
|
|
|
|
|
2011-03-15 13:45:46 +01:00
|
|
|
static nsresult run_insert_script(HTMLDocumentNode *doc, nsISupports *script_iface, nsISupports *parser_iface)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
2011-01-31 00:32:30 +01:00
|
|
|
nsIDOMHTMLScriptElement *nsscript;
|
2012-10-02 15:45:40 +02:00
|
|
|
HTMLScriptElement *script_elem;
|
2011-03-15 13:45:46 +01:00
|
|
|
nsIParser *nsparser = NULL;
|
2012-10-16 17:08:25 +02:00
|
|
|
script_queue_entry_t *iter;
|
2012-10-16 17:07:48 +02:00
|
|
|
HTMLInnerWindow *window;
|
2008-12-30 06:48:59 +01:00
|
|
|
nsresult nsres;
|
2012-10-02 15:45:40 +02:00
|
|
|
HRESULT hres;
|
2008-12-30 06:48:59 +01:00
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
TRACE("(%p)->(%p)\n", doc, script_iface);
|
2008-12-30 06:48:59 +01:00
|
|
|
|
2012-10-16 17:07:48 +02:00
|
|
|
window = doc->window;
|
|
|
|
if(!window)
|
|
|
|
return NS_OK;
|
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
nsres = nsISupports_QueryInterface(script_iface, &IID_nsIDOMHTMLScriptElement, (void**)&nsscript);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("Could not get nsIDOMHTMLScriptElement: %08x\n", nsres);
|
|
|
|
return nsres;
|
|
|
|
}
|
2009-12-03 01:12:12 +01:00
|
|
|
|
2011-03-15 13:45:46 +01:00
|
|
|
if(parser_iface) {
|
|
|
|
nsres = nsISupports_QueryInterface(parser_iface, &IID_nsIParser, (void**)&nsparser);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("Could not get nsIParser iface: %08x\n", nsres);
|
|
|
|
nsparser = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-02 15:45:40 +02:00
|
|
|
hres = script_elem_from_nsscript(doc, nsscript, &script_elem);
|
|
|
|
nsIDOMHTMLScriptElement_Release(nsscript);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-10-16 17:07:48 +02:00
|
|
|
if(nsparser) {
|
2011-03-15 13:45:46 +01:00
|
|
|
nsIParser_BeginEvaluatingParserInsertedScript(nsparser);
|
2012-10-16 17:07:48 +02:00
|
|
|
window->parser_callback_cnt++;
|
|
|
|
}
|
2011-03-15 13:45:46 +01:00
|
|
|
|
2012-10-16 17:08:25 +02:00
|
|
|
IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
|
|
|
|
|
2012-10-16 17:07:48 +02:00
|
|
|
doc_insert_script(window, script_elem);
|
2011-03-15 13:45:46 +01:00
|
|
|
|
2012-10-16 17:08:25 +02:00
|
|
|
while(!list_empty(&window->script_queue)) {
|
|
|
|
iter = LIST_ENTRY(list_head(&window->script_queue), script_queue_entry_t, entry);
|
|
|
|
list_remove(&iter->entry);
|
2013-01-15 13:39:44 +01:00
|
|
|
if(!iter->script->parsed)
|
|
|
|
doc_insert_script(window, iter->script);
|
2012-10-16 17:08:25 +02:00
|
|
|
IHTMLScriptElement_Release(&iter->script->IHTMLScriptElement_iface);
|
|
|
|
heap_free(iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
|
|
|
|
|
2011-03-15 13:45:46 +01:00
|
|
|
if(nsparser) {
|
2012-10-16 17:07:48 +02:00
|
|
|
window->parser_callback_cnt--;
|
2011-03-15 13:45:46 +01:00
|
|
|
nsIParser_EndEvaluatingParserInsertedScript(nsparser);
|
|
|
|
nsIParser_Release(nsparser);
|
|
|
|
}
|
|
|
|
|
2012-10-02 15:45:40 +02:00
|
|
|
IHTMLScriptElement_Release(&script_elem->IHTMLScriptElement_iface);
|
2012-10-16 17:08:25 +02:00
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2008-12-30 06:48:59 +01:00
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
typedef struct nsRunnable nsRunnable;
|
2009-11-01 19:24:34 +01:00
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
typedef nsresult (*runnable_proc_t)(HTMLDocumentNode*,nsISupports*,nsISupports*);
|
2008-12-30 06:48:59 +01:00
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
struct nsRunnable {
|
|
|
|
nsIRunnable nsIRunnable_iface;
|
2008-12-30 06:48:59 +01:00
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
LONG ref;
|
2008-12-30 06:48:59 +01:00
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
runnable_proc_t proc;
|
|
|
|
|
|
|
|
HTMLDocumentNode *doc;
|
|
|
|
nsISupports *arg1;
|
|
|
|
nsISupports *arg2;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline nsRunnable *impl_from_nsIRunnable(nsIRunnable *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, nsRunnable, nsIRunnable_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsRunnable_QueryInterface(nsIRunnable *iface,
|
|
|
|
nsIIDRef riid, void **result)
|
|
|
|
{
|
|
|
|
nsRunnable *This = impl_from_nsIRunnable(iface);
|
|
|
|
|
|
|
|
if(IsEqualGUID(riid, &IID_nsISupports)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
|
|
|
|
*result = &This->nsIRunnable_iface;
|
|
|
|
}else if(IsEqualGUID(riid, &IID_nsIRunnable)) {
|
|
|
|
TRACE("(%p)->(IID_nsIRunnable %p)\n", This, result);
|
|
|
|
*result = &This->nsIRunnable_iface;
|
|
|
|
}else {
|
|
|
|
*result = NULL;
|
|
|
|
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISupports_AddRef((nsISupports*)*result);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2008-12-30 06:48:59 +01:00
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
static nsrefcnt NSAPI nsRunnable_AddRef(nsIRunnable *iface)
|
|
|
|
{
|
|
|
|
nsRunnable *This = impl_from_nsIRunnable(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsRunnable_Release(nsIRunnable *iface)
|
|
|
|
{
|
|
|
|
nsRunnable *This = impl_from_nsIRunnable(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
htmldoc_release(&This->doc->basedoc);
|
|
|
|
if(This->arg1)
|
|
|
|
nsISupports_Release(This->arg1);
|
|
|
|
if(This->arg2)
|
|
|
|
nsISupports_Release(This->arg2);
|
|
|
|
heap_free(This);
|
2008-12-30 06:48:59 +01:00
|
|
|
}
|
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsRunnable_Run(nsIRunnable *iface)
|
|
|
|
{
|
|
|
|
nsRunnable *This = impl_from_nsIRunnable(iface);
|
|
|
|
|
|
|
|
return This->proc(This->doc, This->arg1, This->arg2);
|
2008-12-30 06:48:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIRunnableVtbl nsRunnableVtbl = {
|
|
|
|
nsRunnable_QueryInterface,
|
|
|
|
nsRunnable_AddRef,
|
|
|
|
nsRunnable_Release,
|
|
|
|
nsRunnable_Run
|
|
|
|
};
|
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
static void add_script_runner(HTMLDocumentNode *This, runnable_proc_t proc, nsISupports *arg1, nsISupports *arg2)
|
|
|
|
{
|
|
|
|
nsRunnable *runnable;
|
|
|
|
|
|
|
|
runnable = heap_alloc_zero(sizeof(*runnable));
|
|
|
|
if(!runnable)
|
|
|
|
return;
|
|
|
|
|
|
|
|
runnable->nsIRunnable_iface.lpVtbl = &nsRunnableVtbl;
|
|
|
|
runnable->ref = 1;
|
|
|
|
|
|
|
|
htmldoc_addref(&This->basedoc);
|
|
|
|
runnable->doc = This;
|
|
|
|
runnable->proc = proc;
|
|
|
|
|
|
|
|
if(arg1)
|
|
|
|
nsISupports_AddRef(arg1);
|
|
|
|
runnable->arg1 = arg1;
|
|
|
|
|
|
|
|
if(arg2)
|
|
|
|
nsISupports_AddRef(arg2);
|
|
|
|
runnable->arg2 = arg2;
|
|
|
|
|
2011-03-15 13:45:29 +01:00
|
|
|
nsIContentUtils_AddScriptRunner(content_utils, &runnable->nsIRunnable_iface);
|
2011-01-31 00:32:30 +01:00
|
|
|
|
|
|
|
nsIRunnable_Release(&runnable->nsIRunnable_iface);
|
|
|
|
}
|
|
|
|
|
2011-01-03 01:01:38 +01:00
|
|
|
static inline HTMLDocumentNode *impl_from_nsIDocumentObserver(nsIDocumentObserver *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLDocumentNode, nsIDocumentObserver_iface);
|
|
|
|
}
|
2008-12-30 06:48:59 +01:00
|
|
|
|
|
|
|
static nsresult NSAPI nsDocumentObserver_QueryInterface(nsIDocumentObserver *iface,
|
2010-08-02 11:08:26 +02:00
|
|
|
nsIIDRef riid, void **result)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
2011-01-03 01:01:38 +01:00
|
|
|
HTMLDocumentNode *This = impl_from_nsIDocumentObserver(iface);
|
2008-12-30 06:48:59 +01:00
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports, %p)\n", This, result);
|
2011-01-03 01:01:38 +01:00
|
|
|
*result = &This->nsIDocumentObserver_iface;
|
2008-12-30 06:48:59 +01:00
|
|
|
}else if(IsEqualGUID(&IID_nsIMutationObserver, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIMutationObserver %p)\n", This, result);
|
2011-01-03 01:01:38 +01:00
|
|
|
*result = &This->nsIDocumentObserver_iface;
|
2008-12-30 06:48:59 +01:00
|
|
|
}else if(IsEqualGUID(&IID_nsIDocumentObserver, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIDocumentObserver %p)\n", This, result);
|
2011-01-03 01:01:38 +01:00
|
|
|
*result = &This->nsIDocumentObserver_iface;
|
2008-12-30 06:48:59 +01:00
|
|
|
}else {
|
|
|
|
*result = NULL;
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2009-10-21 21:28:09 +02:00
|
|
|
htmldoc_addref(&This->basedoc);
|
2008-12-30 06:48:59 +01:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsDocumentObserver_AddRef(nsIDocumentObserver *iface)
|
|
|
|
{
|
2011-01-03 01:01:38 +01:00
|
|
|
HTMLDocumentNode *This = impl_from_nsIDocumentObserver(iface);
|
2009-10-21 21:28:09 +02:00
|
|
|
return htmldoc_addref(&This->basedoc);
|
2008-12-30 06:48:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsDocumentObserver_Release(nsIDocumentObserver *iface)
|
|
|
|
{
|
2011-01-03 01:01:38 +01:00
|
|
|
HTMLDocumentNode *This = impl_from_nsIDocumentObserver(iface);
|
2009-10-21 21:28:09 +02:00
|
|
|
return htmldoc_release(&This->basedoc);
|
2008-12-30 06:48:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void NSAPI nsDocumentObserver_CharacterDataWillChange(nsIDocumentObserver *iface,
|
|
|
|
nsIDocument *aDocument, nsIContent *aContent, void /*CharacterDataChangeInfo*/ *aInfo)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void NSAPI nsDocumentObserver_CharacterDataChanged(nsIDocumentObserver *iface,
|
|
|
|
nsIDocument *aDocument, nsIContent *aContent, void /*CharacterDataChangeInfo*/ *aInfo)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-08-04 14:05:05 +02:00
|
|
|
static void NSAPI nsDocumentObserver_AttributeWillChange(nsIDocumentObserver *iface, nsIDocument *aDocument,
|
2016-01-30 16:50:52 +01:00
|
|
|
void *aElement, LONG aNameSpaceID, nsIAtom *aAttribute, LONG aModType, const nsAttrValue *aNewValue)
|
2009-08-04 14:05:05 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-12-30 06:48:59 +01:00
|
|
|
static void NSAPI nsDocumentObserver_AttributeChanged(nsIDocumentObserver *iface, nsIDocument *aDocument,
|
2016-01-30 16:50:52 +01:00
|
|
|
void *aElement, LONG aNameSpaceID, nsIAtom *aAttribute, LONG aModType, const nsAttrValue *aOldValue)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void NSAPI nsDocumentObserver_NativeAnonymousChildListChange(nsIDocumentObserver *iface, nsIDocument *aDocument,
|
|
|
|
nsIContent *aContent, cpp_bool aIsRemove)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-09 14:21:18 +01:00
|
|
|
static void NSAPI nsDocumentObserver_AttributeSetToCurrentValue(nsIDocumentObserver *iface, nsIDocument *aDocument,
|
2013-01-18 14:05:59 +01:00
|
|
|
void *aElement, LONG aNameSpaceID, nsIAtom *aAttribute)
|
2013-01-09 14:21:18 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-12-30 06:48:59 +01:00
|
|
|
static void NSAPI nsDocumentObserver_ContentAppended(nsIDocumentObserver *iface, nsIDocument *aDocument,
|
2013-01-18 14:05:59 +01:00
|
|
|
nsIContent *aContainer, nsIContent *aFirstNewContent, LONG aNewIndexInContainer)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void NSAPI nsDocumentObserver_ContentInserted(nsIDocumentObserver *iface, nsIDocument *aDocument,
|
2013-01-18 14:05:59 +01:00
|
|
|
nsIContent *aContainer, nsIContent *aChild, LONG aIndexInContainer)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void NSAPI nsDocumentObserver_ContentRemoved(nsIDocumentObserver *iface, nsIDocument *aDocument,
|
2013-01-18 14:05:59 +01:00
|
|
|
nsIContent *aContainer, nsIContent *aChild, LONG aIndexInContainer,
|
2010-08-25 14:22:25 +02:00
|
|
|
nsIContent *aProviousSibling)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void NSAPI nsDocumentObserver_NodeWillBeDestroyed(nsIDocumentObserver *iface, const nsINode *aNode)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void NSAPI nsDocumentObserver_ParentChainChanged(nsIDocumentObserver *iface, nsIContent *aContent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void NSAPI nsDocumentObserver_BeginUpdate(nsIDocumentObserver *iface, nsIDocument *aDocument,
|
|
|
|
nsUpdateType aUpdateType)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void NSAPI nsDocumentObserver_EndUpdate(nsIDocumentObserver *iface, nsIDocument *aDocument,
|
|
|
|
nsUpdateType aUpdateType)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void NSAPI nsDocumentObserver_BeginLoad(nsIDocumentObserver *iface, nsIDocument *aDocument)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void NSAPI nsDocumentObserver_EndLoad(nsIDocumentObserver *iface, nsIDocument *aDocument)
|
|
|
|
{
|
2011-01-03 01:01:38 +01:00
|
|
|
HTMLDocumentNode *This = impl_from_nsIDocumentObserver(iface);
|
2009-08-11 19:14:17 +02:00
|
|
|
|
2011-02-24 13:04:49 +01:00
|
|
|
TRACE("(%p)\n", This);
|
2009-08-11 19:14:17 +02:00
|
|
|
|
2010-08-18 13:39:04 +02:00
|
|
|
if(This->skip_mutation_notif)
|
|
|
|
return;
|
|
|
|
|
2009-10-21 21:28:09 +02:00
|
|
|
This->content_ready = TRUE;
|
2011-01-31 00:32:30 +01:00
|
|
|
add_script_runner(This, run_end_load, NULL, NULL);
|
2008-12-30 06:48:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void NSAPI nsDocumentObserver_ContentStatesChanged(nsIDocumentObserver *iface, nsIDocument *aDocument,
|
2014-11-03 12:39:59 +01:00
|
|
|
nsIContent *aContent, EventStates aStateMask)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-25 14:22:25 +02:00
|
|
|
static void NSAPI nsDocumentObserver_DocumentStatesChanged(nsIDocumentObserver *iface, nsIDocument *aDocument,
|
2014-11-03 12:39:59 +01:00
|
|
|
EventStates aStateMask)
|
2010-08-25 14:22:25 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-06-13 17:40:51 +02:00
|
|
|
static void NSAPI nsDocumentObserver_StyleSheetAdded(nsIDocumentObserver *iface, mozilla_StyleSheetHandle aStyleSheet,
|
|
|
|
cpp_bool aDocumentSheet)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-06-13 17:40:51 +02:00
|
|
|
static void NSAPI nsDocumentObserver_StyleSheetRemoved(nsIDocumentObserver *iface, mozilla_StyleSheetHandle aStyleSheet,
|
|
|
|
cpp_bool aDocumentSheet)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void NSAPI nsDocumentObserver_StyleSheetApplicableStateChanged(nsIDocumentObserver *iface,
|
2016-06-13 17:40:51 +02:00
|
|
|
mozilla_StyleSheetHandle aStyleSheet)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-06-13 17:40:51 +02:00
|
|
|
static void NSAPI nsDocumentObserver_StyleRuleChanged(nsIDocumentObserver *iface, mozilla_StyleSheetHandle aStyleSheet)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-06-13 17:40:51 +02:00
|
|
|
static void NSAPI nsDocumentObserver_StyleRuleAdded(nsIDocumentObserver *iface, mozilla_StyleSheetHandle aStyleSheet)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-06-13 17:40:51 +02:00
|
|
|
static void NSAPI nsDocumentObserver_StyleRuleRemoved(nsIDocumentObserver *iface, mozilla_StyleSheetHandle aStyleSheet)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface, nsIDocument *aDocument,
|
|
|
|
nsIContent *aContent)
|
|
|
|
{
|
2011-01-03 01:01:38 +01:00
|
|
|
HTMLDocumentNode *This = impl_from_nsIDocumentObserver(iface);
|
2009-10-21 21:30:20 +02:00
|
|
|
nsIDOMHTMLIFrameElement *nsiframe;
|
2009-10-27 21:17:08 +01:00
|
|
|
nsIDOMHTMLFrameElement *nsframe;
|
2012-10-16 17:09:52 +02:00
|
|
|
nsIDOMHTMLScriptElement *nsscript;
|
2014-05-27 11:29:37 +02:00
|
|
|
nsIDOMHTMLElement *nselem;
|
2008-12-30 06:48:59 +01:00
|
|
|
nsIDOMComment *nscomment;
|
|
|
|
nsresult nsres;
|
|
|
|
|
2014-01-10 16:27:58 +01:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, aDocument, aContent);
|
2008-12-30 06:48:59 +01:00
|
|
|
|
2014-05-27 11:29:37 +02:00
|
|
|
nsres = nsIContent_QueryInterface(aContent, &IID_nsIDOMHTMLElement, (void**)&nselem);
|
2008-12-30 06:48:59 +01:00
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
2009-10-21 21:28:09 +02:00
|
|
|
check_event_attr(This, nselem);
|
2014-05-27 11:29:37 +02:00
|
|
|
nsIDOMHTMLElement_Release(nselem);
|
2008-12-30 06:48:59 +01:00
|
|
|
}
|
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
nsres = nsIContent_QueryInterface(aContent, &IID_nsIDOMComment, (void**)&nscomment);
|
2008-12-30 06:48:59 +01:00
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
TRACE("comment node\n");
|
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
add_script_runner(This, run_insert_comment, (nsISupports*)nscomment, NULL);
|
2008-12-30 06:48:59 +01:00
|
|
|
nsIDOMComment_Release(nscomment);
|
2012-10-16 17:08:05 +02:00
|
|
|
return;
|
2008-12-30 06:48:59 +01:00
|
|
|
}
|
2009-10-21 21:30:20 +02:00
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
nsres = nsIContent_QueryInterface(aContent, &IID_nsIDOMHTMLIFrameElement, (void**)&nsiframe);
|
2009-10-21 21:30:20 +02:00
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
2009-10-22 23:35:51 +02:00
|
|
|
TRACE("iframe node\n");
|
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
add_script_runner(This, run_bind_to_tree, (nsISupports*)nsiframe, NULL);
|
2009-10-21 21:30:20 +02:00
|
|
|
nsIDOMHTMLIFrameElement_Release(nsiframe);
|
2012-10-16 17:08:05 +02:00
|
|
|
return;
|
2009-10-21 21:30:20 +02:00
|
|
|
}
|
2009-10-27 21:17:08 +01:00
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
nsres = nsIContent_QueryInterface(aContent, &IID_nsIDOMHTMLFrameElement, (void**)&nsframe);
|
2009-10-27 21:17:08 +01:00
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
TRACE("frame node\n");
|
|
|
|
|
2011-01-31 00:32:30 +01:00
|
|
|
add_script_runner(This, run_bind_to_tree, (nsISupports*)nsframe, NULL);
|
2009-10-27 21:17:08 +01:00
|
|
|
nsIDOMHTMLFrameElement_Release(nsframe);
|
2012-10-16 17:08:05 +02:00
|
|
|
return;
|
2009-10-27 21:17:08 +01:00
|
|
|
}
|
2012-10-16 17:09:52 +02:00
|
|
|
|
|
|
|
nsres = nsIContent_QueryInterface(aContent, &IID_nsIDOMHTMLScriptElement, (void**)&nsscript);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
HTMLScriptElement *script_elem;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("script element\n");
|
|
|
|
|
|
|
|
hres = script_elem_from_nsscript(This, nsscript, &script_elem);
|
|
|
|
nsIDOMHTMLScriptElement_Release(nsscript);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(script_elem->parse_on_bind)
|
|
|
|
add_script_runner(This, run_insert_script, (nsISupports*)nsscript, NULL);
|
|
|
|
|
|
|
|
IHTMLScriptElement_Release(&script_elem->IHTMLScriptElement_iface);
|
|
|
|
}
|
2008-12-30 06:48:59 +01:00
|
|
|
}
|
|
|
|
|
2012-03-14 14:45:32 +01:00
|
|
|
static void NSAPI nsDocumentObserver_AttemptToExecuteScript(nsIDocumentObserver *iface, nsIContent *aContent,
|
2012-03-15 11:55:01 +01:00
|
|
|
nsIParser *aParser, cpp_bool *aBlock)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
2011-01-03 01:01:38 +01:00
|
|
|
HTMLDocumentNode *This = impl_from_nsIDocumentObserver(iface);
|
2008-12-30 06:48:59 +01:00
|
|
|
nsIDOMHTMLScriptElement *nsscript;
|
|
|
|
nsresult nsres;
|
|
|
|
|
2012-03-14 14:45:32 +01:00
|
|
|
TRACE("(%p)->(%p %p %p)\n", This, aContent, aParser, aBlock);
|
2008-12-30 06:48:59 +01:00
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
nsres = nsIContent_QueryInterface(aContent, &IID_nsIDOMHTMLScriptElement, (void**)&nsscript);
|
2008-12-30 06:48:59 +01:00
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
2009-10-22 23:35:51 +02:00
|
|
|
TRACE("script node\n");
|
|
|
|
|
2011-03-15 13:45:46 +01:00
|
|
|
add_script_runner(This, run_insert_script, (nsISupports*)nsscript, (nsISupports*)aParser);
|
2008-12-30 06:48:59 +01:00
|
|
|
nsIDOMHTMLScriptElement_Release(nsscript);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIDocumentObserverVtbl nsDocumentObserverVtbl = {
|
|
|
|
nsDocumentObserver_QueryInterface,
|
|
|
|
nsDocumentObserver_AddRef,
|
|
|
|
nsDocumentObserver_Release,
|
|
|
|
nsDocumentObserver_CharacterDataWillChange,
|
|
|
|
nsDocumentObserver_CharacterDataChanged,
|
2009-08-04 14:05:05 +02:00
|
|
|
nsDocumentObserver_AttributeWillChange,
|
2008-12-30 06:48:59 +01:00
|
|
|
nsDocumentObserver_AttributeChanged,
|
2016-01-30 16:50:52 +01:00
|
|
|
nsDocumentObserver_NativeAnonymousChildListChange,
|
2013-01-09 14:21:18 +01:00
|
|
|
nsDocumentObserver_AttributeSetToCurrentValue,
|
2008-12-30 06:48:59 +01:00
|
|
|
nsDocumentObserver_ContentAppended,
|
|
|
|
nsDocumentObserver_ContentInserted,
|
|
|
|
nsDocumentObserver_ContentRemoved,
|
|
|
|
nsDocumentObserver_NodeWillBeDestroyed,
|
|
|
|
nsDocumentObserver_ParentChainChanged,
|
|
|
|
nsDocumentObserver_BeginUpdate,
|
|
|
|
nsDocumentObserver_EndUpdate,
|
|
|
|
nsDocumentObserver_BeginLoad,
|
|
|
|
nsDocumentObserver_EndLoad,
|
|
|
|
nsDocumentObserver_ContentStatesChanged,
|
2010-08-25 14:22:25 +02:00
|
|
|
nsDocumentObserver_DocumentStatesChanged,
|
2008-12-30 06:48:59 +01:00
|
|
|
nsDocumentObserver_StyleSheetAdded,
|
|
|
|
nsDocumentObserver_StyleSheetRemoved,
|
|
|
|
nsDocumentObserver_StyleSheetApplicableStateChanged,
|
|
|
|
nsDocumentObserver_StyleRuleChanged,
|
|
|
|
nsDocumentObserver_StyleRuleAdded,
|
|
|
|
nsDocumentObserver_StyleRuleRemoved,
|
|
|
|
nsDocumentObserver_BindToDocument,
|
2012-03-14 14:45:32 +01:00
|
|
|
nsDocumentObserver_AttemptToExecuteScript
|
2008-12-30 06:48:59 +01:00
|
|
|
};
|
|
|
|
|
2011-03-15 13:45:29 +01:00
|
|
|
void init_document_mutation(HTMLDocumentNode *doc)
|
2008-12-30 06:48:59 +01:00
|
|
|
{
|
2011-03-15 13:45:29 +01:00
|
|
|
nsIDocument *nsdoc;
|
2009-10-21 21:28:39 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
2011-01-03 01:01:38 +01:00
|
|
|
doc->nsIDocumentObserver_iface.lpVtbl = &nsDocumentObserverVtbl;
|
2009-10-21 21:28:39 +02:00
|
|
|
|
2011-03-15 13:45:29 +01:00
|
|
|
nsres = nsIDOMHTMLDocument_QueryInterface(doc->nsdoc, &IID_nsIDocument, (void**)&nsdoc);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("Could not get nsIDocument: %08x\n", nsres);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIContentUtils_AddDocumentObserver(content_utils, nsdoc, &doc->nsIDocumentObserver_iface);
|
|
|
|
nsIDocument_Release(nsdoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void release_document_mutation(HTMLDocumentNode *doc)
|
|
|
|
{
|
|
|
|
nsIDocument *nsdoc;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLDocument_QueryInterface(doc->nsdoc, &IID_nsIDocument, (void**)&nsdoc);
|
2009-10-21 21:28:39 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2011-03-15 13:45:29 +01:00
|
|
|
ERR("Could not get nsIDocument: %08x\n", nsres);
|
2009-10-21 21:28:39 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-15 13:45:29 +01:00
|
|
|
nsIContentUtils_RemoveDocumentObserver(content_utils, nsdoc, &doc->nsIDocumentObserver_iface);
|
|
|
|
nsIDocument_Release(nsdoc);
|
2009-10-21 21:28:39 +02:00
|
|
|
}
|
|
|
|
|
2013-04-29 10:47:19 +02:00
|
|
|
JSContext *get_context_from_document(nsIDOMHTMLDocument *nsdoc)
|
|
|
|
{
|
|
|
|
nsIDocument *doc;
|
|
|
|
JSContext *ctx;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLDocument_QueryInterface(nsdoc, &IID_nsIDocument, (void**)&doc);
|
|
|
|
assert(nsres == NS_OK);
|
|
|
|
|
|
|
|
ctx = nsIContentUtils_GetContextFromDocument(content_utils, doc);
|
|
|
|
nsIDocument_Release(doc);
|
|
|
|
|
|
|
|
TRACE("ret %p\n", ctx);
|
|
|
|
return ctx;
|
|
|
|
}
|
|
|
|
|
2011-03-15 13:45:29 +01:00
|
|
|
void init_mutation(nsIComponentManager *component_manager)
|
2009-10-21 21:28:39 +02:00
|
|
|
{
|
2011-03-15 13:45:29 +01:00
|
|
|
nsIFactory *factory;
|
2009-10-21 21:28:39 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
2011-03-15 13:45:29 +01:00
|
|
|
if(!component_manager) {
|
|
|
|
if(content_utils) {
|
|
|
|
nsIContentUtils_Release(content_utils);
|
|
|
|
content_utils = NULL;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIComponentManager_GetClassObject(component_manager, &NS_ICONTENTUTILS_CID,
|
|
|
|
&IID_nsIFactory, (void**)&factory);
|
2009-10-21 21:28:39 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2011-03-15 13:45:29 +01:00
|
|
|
ERR("Could not create nsIContentUtils service: %08x\n", nsres);
|
2009-10-21 21:28:39 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-15 13:45:29 +01:00
|
|
|
nsres = nsIFactory_CreateInstance(factory, NULL, &IID_nsIContentUtils, (void**)&content_utils);
|
|
|
|
nsIFactory_Release(factory);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("Could not create nsIContentUtils instance: %08x\n", nsres);
|
2008-12-30 06:48:59 +01:00
|
|
|
}
|