From cb776f7d5bd221119bc785e240f1b56450a78ced Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 26 Sep 2007 20:44:14 +0200 Subject: [PATCH] mshtml: Added get_compatMode implementation. --- dlls/mshtml/htmldoc5.c | 30 ++++++++++++++++++++++++++-- dlls/mshtml/nsiface.idl | 44 +++++++++++++++++++++++++++++++++++++++++ dlls/mshtml/tests/dom.c | 19 ++++++++++++++++++ 3 files changed, 91 insertions(+), 2 deletions(-) diff --git a/dlls/mshtml/htmldoc5.c b/dlls/mshtml/htmldoc5.c index a91118ece52..95d76f37405 100644 --- a/dlls/mshtml/htmldoc5.c +++ b/dlls/mshtml/htmldoc5.c @@ -220,8 +220,34 @@ static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p) { HTMLDocument *This = HTMLDOC5_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsIDOMDocument *nsdoc; + nsIDOMNSHTMLDocument *nshtmldoc; + nsAString mode_str; + const PRUnichar *mode; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc); + if(NS_FAILED(nsres)) + ERR("GetDocument failed: %08x\n", nsres); + + nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMNSHTMLDocument, (void**)&nshtmldoc); + nsIDOMDocument_Release(nsdoc); + if(NS_FAILED(nsres)) { + ERR("Could not get nsIDOMNSHTMLDocument: %08x\n", nsres); + return S_OK; + } + + nsAString_Init(&mode_str, NULL); + nsIDOMNSHTMLDocument_GetCompatMode(nshtmldoc, &mode_str); + nsIDOMNSHTMLDocument_Release(nshtmldoc); + + nsAString_GetData(&mode_str, &mode, NULL); + *p = SysAllocString(mode); + nsAString_Finish(&mode_str); + + return S_OK; } #undef HTMLDOC5_THIS diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index c79b17e5270..1d36197ba65 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -834,6 +834,50 @@ interface nsIDOMHTMLDocument : nsIDOMDocument nsresult GetElementsByName(const nsAString *elementName, nsIDOMNodeList **_retval); } +[ + object, + uuid(79beb289-3644-4b54-9432-9fb993945629) + /* NOT_FROZEN */ +] +interface nsIDOMNSHTMLDocument : nsISupports +{ + nsresult GetWidth(PRInt32 *aWidth); + nsresult GetHeight(PRInt32 *aHeight); + nsresult GetAlinkColor(nsAString *aAlinkColor); + nsresult SetAlinkColor(const nsAString *aAlinkColor); + nsresult GetLinkColor(nsAString *aLinkColor); + nsresult SetLinkColor(const nsAString *aLinkColor); + nsresult GetVlinkColor(nsAString *aVlinkColor); + nsresult SetVlinkColor(const nsAString *aVlinkColor); + nsresult GetBgColor(nsAString *aBgColor); + nsresult SetBgColor(const nsAString *aBgColor); + nsresult GetFgColor(nsAString *aFgColor); + nsresult SetFgColor(const nsAString *aFgColor); + nsresult GetDomain(nsAString *aDomain); + nsresult SetDomain(const nsAString *aDomain); + nsresult GetEmbeds(nsIDOMHTMLCollection **aEmbeds); + nsresult GetSelection(nsAString *_retval); + nsresult Open(nsIDOMDocument **_retval); + nsresult Write(); + nsresult Writeln(); + nsresult Clear(); + nsresult CaptureEvents(PRInt32 eventFlags); + nsresult ReleaseEvents(PRInt32 eventFlags); + nsresult RouteEvent(nsIDOMEvent *evt); + nsresult GetCompatMode(nsAString *aCompatMode); + nsresult GetPlugins(nsIDOMHTMLCollection **aPlugins); + nsresult GetDesignMode(nsAString *aDesignMode); + nsresult SetDesignMode(const nsAString *aDesignMode); + nsresult ExecCommand(const nsAString *commandID, PRBool doShowUI, const nsAString *value, PRBool *_retval); + nsresult ExecCommandShowHelp(const nsAString *commandID, PRBool *_retval); + nsresult QueryCommandEnabled(const nsAString *commandID, PRBool *_retval); + nsresult QueryCommandIndeterm(const nsAString *commandID, PRBool *_retval); + nsresult QueryCommandState(const nsAString *commandID, PRBool *_retval); + nsresult QueryCommandSupported(const nsAString *commandID, PRBool *_retval); + nsresult QueryCommandText(const nsAString *commandID, nsAString *_retval); + nsresult QueryCommandValue(const nsAString *commandID, nsAString *_retval); +} + [ object, uuid(3d9f4973-dd2e-48f5-b5f7-2634e09eadd9) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 80675f54880..3c7a18a250c 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -347,6 +347,24 @@ static void test_txtrange(IHTMLDocument2 *doc) IHTMLTxtRange_Release(body_range); } +static void test_compatmode(IHTMLDocument2 *doc) +{ + IHTMLDocument5 *doc5; + BSTR mode; + HRESULT hres; + + hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5); + ok(hres == S_OK, "Could not get IHTMLDocument5 interface: %08x\n", hres); + if(FAILED(hres)) + return; + + hres = IHTMLDocument5_get_compatMode(doc5, &mode); + IHTMLDocument5_Release(doc5); + ok(hres == S_OK, "get_compatMode failed: %08x\n", hres); + ok(!strcmp_wa(mode, "BackCompat"), "compatMode=%s\n", dbgstr_w(mode)); + SysFreeString(mode); +} + static void test_default_style(IHTMLStyle *style) { VARIANT_BOOL b; @@ -431,6 +449,7 @@ static void test_defaults(IHTMLDocument2 *doc) ok(hres == S_OK, "get_style failed: %08x\n", hres); test_default_style(style); + test_compatmode(doc); IHTMLStyle_Release(style);