mshtml: Add IHTMLDOMImplementation2::createHTMLDocument implementation.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b574cd98bd
commit
7e0e55f76f
|
@ -2821,7 +2821,7 @@ static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IH
|
|||
if(!doc_node->dom_implementation) {
|
||||
HRESULT hres;
|
||||
|
||||
hres = create_dom_implementation(&doc_node->dom_implementation);
|
||||
hres = create_dom_implementation(doc_node, &doc_node->dom_implementation);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
}
|
||||
|
@ -4892,6 +4892,12 @@ void detach_document_node(HTMLDocumentNode *doc)
|
|||
while(!list_empty(&doc->plugin_hosts))
|
||||
detach_plugin_host(LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry));
|
||||
|
||||
if(doc->dom_implementation) {
|
||||
detach_dom_implementation(doc->dom_implementation);
|
||||
IHTMLDOMImplementation_Release(doc->dom_implementation);
|
||||
doc->dom_implementation = NULL;
|
||||
}
|
||||
|
||||
detach_events(doc);
|
||||
detach_selection(doc);
|
||||
detach_ranges(doc);
|
||||
|
@ -5154,7 +5160,7 @@ static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindo
|
|||
doc->ref = 1;
|
||||
doc->basedoc.doc_node = doc;
|
||||
doc->basedoc.doc_obj = doc_obj;
|
||||
doc->basedoc.window = window->base.outer_window;
|
||||
doc->basedoc.window = window ? window->base.outer_window : NULL;
|
||||
doc->window = window;
|
||||
|
||||
init_doc(&doc->basedoc, (IUnknown*)&doc->node.IHTMLDOMNode_iface,
|
||||
|
@ -5168,7 +5174,8 @@ static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindo
|
|||
return doc;
|
||||
}
|
||||
|
||||
HRESULT create_document_node(nsIDOMHTMLDocument *nsdoc, GeckoBrowser *browser, HTMLInnerWindow *window, HTMLDocumentNode **ret)
|
||||
HRESULT create_document_node(nsIDOMHTMLDocument *nsdoc, GeckoBrowser *browser, HTMLInnerWindow *window,
|
||||
compat_mode_t parent_mode, HTMLDocumentNode **ret)
|
||||
{
|
||||
HTMLDocumentObj *doc_obj = browser->doc;
|
||||
HTMLDocumentNode *doc;
|
||||
|
@ -5177,16 +5184,13 @@ HRESULT create_document_node(nsIDOMHTMLDocument *nsdoc, GeckoBrowser *browser, H
|
|||
if(!doc)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if(window->base.outer_window->parent) {
|
||||
compat_mode_t parent_mode = window->base.outer_window->parent->base.inner_window->doc->document_mode;
|
||||
TRACE("parent mode %u\n", parent_mode);
|
||||
if(parent_mode >= COMPAT_MODE_IE9) {
|
||||
doc->document_mode = parent_mode;
|
||||
lock_document_mode(doc);
|
||||
}
|
||||
if(parent_mode >= COMPAT_MODE_IE9) {
|
||||
TRACE("using parent mode %u\n", parent_mode);
|
||||
doc->document_mode = parent_mode;
|
||||
lock_document_mode(doc);
|
||||
}
|
||||
|
||||
if(!doc_obj->basedoc.window || window->base.outer_window == doc_obj->basedoc.window)
|
||||
if(!doc_obj->basedoc.window || (window && is_main_content_window(window->base.outer_window)))
|
||||
doc->basedoc.cp_container.forward_container = &doc_obj->basedoc.cp_container;
|
||||
|
||||
HTMLDOMNode_Init(doc, &doc->node, (nsIDOMNode*)nsdoc, &HTMLDocumentNode_dispex);
|
||||
|
|
|
@ -3613,6 +3613,7 @@ HRESULT create_pending_window(HTMLOuterWindow *outer_window, nsChannelBSC *chann
|
|||
HRESULT update_window_doc(HTMLInnerWindow *window)
|
||||
{
|
||||
HTMLOuterWindow *outer_window = window->base.outer_window;
|
||||
compat_mode_t parent_mode = COMPAT_MODE_QUIRKS;
|
||||
nsIDOMHTMLDocument *nshtmldoc;
|
||||
nsIDOMDocument *nsdoc;
|
||||
nsresult nsres;
|
||||
|
@ -3636,7 +3637,10 @@ HRESULT update_window_doc(HTMLInnerWindow *window)
|
|||
return E_FAIL;
|
||||
}
|
||||
|
||||
hres = create_document_node(nshtmldoc, outer_window->browser, window, &window->doc);
|
||||
if(outer_window->parent)
|
||||
parent_mode = outer_window->parent->base.inner_window->doc->document_mode;
|
||||
|
||||
hres = create_document_node(nshtmldoc, outer_window->browser, window, parent_mode, &window->doc);
|
||||
nsIDOMHTMLDocument_Release(nshtmldoc);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
|
|
@ -871,7 +871,8 @@ struct HTMLDocumentNode {
|
|||
HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
|
||||
HRESULT MHTMLDocument_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
|
||||
HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
|
||||
HRESULT create_document_node(nsIDOMHTMLDocument*,GeckoBrowser*,HTMLInnerWindow*,HTMLDocumentNode**) DECLSPEC_HIDDEN;
|
||||
HRESULT create_document_node(nsIDOMHTMLDocument*,GeckoBrowser*,HTMLInnerWindow*,
|
||||
compat_mode_t,HTMLDocumentNode**) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT create_outer_window(GeckoBrowser*,mozIDOMWindowProxy*,HTMLOuterWindow*,HTMLOuterWindow**) DECLSPEC_HIDDEN;
|
||||
HRESULT update_window_doc(HTMLInnerWindow*) DECLSPEC_HIDDEN;
|
||||
|
@ -885,7 +886,8 @@ IOmNavigator *OmNavigator_Create(void) DECLSPEC_HIDDEN;
|
|||
HRESULT HTMLScreen_Create(IHTMLScreen**) DECLSPEC_HIDDEN;
|
||||
HRESULT create_performance(IHTMLPerformance**) DECLSPEC_HIDDEN;
|
||||
HRESULT create_history(HTMLInnerWindow*,OmHistory**) DECLSPEC_HIDDEN;
|
||||
HRESULT create_dom_implementation(IHTMLDOMImplementation**) DECLSPEC_HIDDEN;
|
||||
HRESULT create_dom_implementation(HTMLDocumentNode*,IHTMLDOMImplementation**) DECLSPEC_HIDDEN;
|
||||
void detach_dom_implementation(IHTMLDOMImplementation*) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT create_storage(IHTMLStorage**) DECLSPEC_HIDDEN;
|
||||
|
||||
|
|
|
@ -134,7 +134,6 @@ typedef nsISupports nsISHistory;
|
|||
typedef nsISupports nsIWidget;
|
||||
typedef nsISupports nsIPrompt;
|
||||
typedef nsISupports nsIAuthPrompt;
|
||||
typedef nsISupports nsIDOMDOMImplementation;
|
||||
typedef nsISupports nsIDOMCDATASection;
|
||||
typedef nsISupports nsIDOMProcessingInstruction;
|
||||
typedef nsISupports nsIDOMEntityReference;
|
||||
|
@ -1221,6 +1220,21 @@ interface nsIDOMDocumentType : nsIDOMNode
|
|||
nsresult MozRemove();
|
||||
}
|
||||
|
||||
[
|
||||
object,
|
||||
uuid(03a6f574-99ec-42f8-9e6c-812a4a9bcbf7),
|
||||
local
|
||||
]
|
||||
interface nsIDOMDOMImplementation : nsISupports
|
||||
{
|
||||
nsresult HasFeature(const nsAString *feature, const nsAString *version, bool *_retval);
|
||||
nsresult CreateDocumentType(const nsAString *qualifiedName, const nsAString *publicId,
|
||||
const nsAString *systemId, nsIDOMDocumentType **_retval);
|
||||
nsresult CreateDocument(const nsAString *namespaceURI, const nsAString *qualifiedName,
|
||||
nsIDOMDocumentType *doctype, nsIDOMDocument **_retval);
|
||||
nsresult CreateHTMLDocument(const nsAString *title, nsIDOMDocument **_retval);
|
||||
}
|
||||
|
||||
[
|
||||
object,
|
||||
uuid(48eb8d72-95bb-402e-a8fc-f2b187abcbdb),
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
|
@ -50,6 +51,9 @@ typedef struct {
|
|||
IHTMLDOMImplementation2 IHTMLDOMImplementation2_iface;
|
||||
|
||||
LONG ref;
|
||||
|
||||
nsIDOMDOMImplementation *implementation;
|
||||
GeckoBrowser *browser;
|
||||
} HTMLDOMImplementation;
|
||||
|
||||
static inline HTMLDOMImplementation *impl_from_IHTMLDOMImplementation(IHTMLDOMImplementation *iface)
|
||||
|
@ -97,6 +101,9 @@ static ULONG WINAPI HTMLDOMImplementation_Release(IHTMLDOMImplementation *iface)
|
|||
TRACE("(%p) ref=%d\n", This, ref);
|
||||
|
||||
if(!ref) {
|
||||
assert(!This->browser);
|
||||
if(This->implementation)
|
||||
nsIDOMDOMImplementation_Release(This->implementation);
|
||||
release_dispex(&This->dispex);
|
||||
heap_free(This);
|
||||
}
|
||||
|
@ -235,8 +242,37 @@ static HRESULT WINAPI HTMLDOMImplementation2_createHTMLDocument(IHTMLDOMImplemen
|
|||
IHTMLDocument7 **new_document)
|
||||
{
|
||||
HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation2(iface);
|
||||
HTMLDocumentNode *new_document_node;
|
||||
nsIDOMHTMLDocument *html_doc;
|
||||
nsIDOMDocument *doc;
|
||||
nsAString title_str;
|
||||
nsresult nsres;
|
||||
HRESULT hres;
|
||||
|
||||
FIXME("(%p)->(%s %p)\n", This, debugstr_w(title), new_document);
|
||||
return E_NOTIMPL;
|
||||
|
||||
if(!This->browser)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
nsAString_InitDepend(&title_str, title);
|
||||
nsres = nsIDOMDOMImplementation_CreateHTMLDocument(This->implementation, &title_str, &doc);
|
||||
nsAString_Finish(&title_str);
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("CreateHTMLDocument failed: %08x\n", nsres);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
nsres = nsIDOMDocument_QueryInterface(doc, &IID_nsIDOMHTMLDocument, (void**)&html_doc);
|
||||
nsIDOMDocument_Release(doc);
|
||||
assert(nsres == NS_OK);
|
||||
|
||||
hres = create_document_node(html_doc, This->browser, NULL, dispex_compat_mode(&This->dispex), &new_document_node);
|
||||
nsIDOMHTMLDocument_Release(html_doc);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
*new_document = &new_document_node->basedoc.IHTMLDocument7_iface;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLDOMImplementation2_hasFeature(IHTMLDOMImplementation2 *iface, BSTR feature,
|
||||
|
@ -274,9 +310,13 @@ static dispex_static_data_t HTMLDOMImplementation_dispex = {
|
|||
HTMLDOMImplementation_iface_tids
|
||||
};
|
||||
|
||||
HRESULT create_dom_implementation(IHTMLDOMImplementation **ret)
|
||||
HRESULT create_dom_implementation(HTMLDocumentNode *doc_node, IHTMLDOMImplementation **ret)
|
||||
{
|
||||
HTMLDOMImplementation *dom_implementation;
|
||||
nsresult nsres;
|
||||
|
||||
if(!doc_node->browser)
|
||||
return E_UNEXPECTED;
|
||||
|
||||
dom_implementation = heap_alloc_zero(sizeof(*dom_implementation));
|
||||
if(!dom_implementation)
|
||||
|
@ -285,14 +325,28 @@ HRESULT create_dom_implementation(IHTMLDOMImplementation **ret)
|
|||
dom_implementation->IHTMLDOMImplementation_iface.lpVtbl = &HTMLDOMImplementationVtbl;
|
||||
dom_implementation->IHTMLDOMImplementation2_iface.lpVtbl = &HTMLDOMImplementation2Vtbl;
|
||||
dom_implementation->ref = 1;
|
||||
dom_implementation->browser = doc_node->browser;
|
||||
|
||||
init_dispex(&dom_implementation->dispex, (IUnknown*)&dom_implementation->IHTMLDOMImplementation_iface,
|
||||
&HTMLDOMImplementation_dispex);
|
||||
init_dispex_with_compat_mode(&dom_implementation->dispex, (IUnknown*)&dom_implementation->IHTMLDOMImplementation_iface,
|
||||
&HTMLDOMImplementation_dispex, doc_node->document_mode);
|
||||
|
||||
nsres = nsIDOMHTMLDocument_GetImplementation(doc_node->nsdoc, &dom_implementation->implementation);
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("GetDOMImplementation failed: %08x\n", nsres);
|
||||
IHTMLDOMImplementation_Release(&dom_implementation->IHTMLDOMImplementation_iface);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
*ret = &dom_implementation->IHTMLDOMImplementation_iface;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void detach_dom_implementation(IHTMLDOMImplementation *iface)
|
||||
{
|
||||
HTMLDOMImplementation *dom_implementation = impl_from_IHTMLDOMImplementation(iface);
|
||||
dom_implementation->browser = NULL;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
DispatchEx dispex;
|
||||
IHTMLScreen IHTMLScreen_iface;
|
||||
|
|
|
@ -6896,6 +6896,7 @@ static void test_window(IHTMLDocument2 *doc)
|
|||
static void test_dom_implementation(IHTMLDocument2 *doc)
|
||||
{
|
||||
IHTMLDocument5 *doc5 = get_htmldoc5_iface((IUnknown*)doc);
|
||||
IHTMLDOMImplementation2 *dom_implementation2;
|
||||
IHTMLDOMImplementation *dom_implementation;
|
||||
VARIANT_BOOL b;
|
||||
VARIANT v;
|
||||
|
@ -6917,6 +6918,24 @@ static void test_dom_implementation(IHTMLDocument2 *doc)
|
|||
ok(hres == S_OK, "hasFeature failed: %08x\n", hres);
|
||||
ok(!b, "hasFeature returned %x\n", b);
|
||||
|
||||
hres = IHTMLDOMImplementation_QueryInterface(dom_implementation, &IID_IHTMLDOMImplementation2,
|
||||
(void**)&dom_implementation2);
|
||||
if(SUCCEEDED(hres)) {
|
||||
IHTMLDocument7 *new_document;
|
||||
|
||||
str = a2bstr("test");
|
||||
hres = IHTMLDOMImplementation2_createHTMLDocument(dom_implementation2, str, &new_document);
|
||||
ok(hres == S_OK, "createHTMLDocument failed: %08x\n", hres);
|
||||
|
||||
test_disp((IUnknown*)new_document, &DIID_DispHTMLDocument, &CLSID_HTMLDocument, "[object]");
|
||||
test_ifaces((IUnknown*)new_document, doc_node_iids);
|
||||
|
||||
IHTMLDocument7_Release(new_document);
|
||||
IHTMLDOMImplementation2_Release(dom_implementation2);
|
||||
}else {
|
||||
win_skip("Missing IHTMLDOMImplementation implementation\n");
|
||||
}
|
||||
|
||||
IHTMLDOMImplementation_Release(dom_implementation);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue