Module: wine Branch: master Commit: 3e0fa120a867bff2b1c0040ff0f3c8666b0145c4 URL: http://source.winehq.org/git/wine.git/?a=commit;h=3e0fa120a867bff2b1c0040ff0...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Oct 13 00:41:28 2009 +0200
mshtml: Added IHTMLWindow2::get_length implementation.
---
dlls/mshtml/htmlwindow.c | 23 +++++++++++++++++++++-- dlls/mshtml/nsiface.idl | 15 ++++++++++++++- dlls/mshtml/tests/dom.c | 14 ++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index c5c2e78..40df40c 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -177,8 +177,27 @@ static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, LONG *p) { HTMLWindow *This = HTMLWINDOW2_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsIDOMWindowCollection *nscollection; + PRUint32 length; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + nsres = nsIDOMWindow_GetFrames(This->nswindow, &nscollection); + if(NS_FAILED(nsres)) { + ERR("GetFrames failed: %08x\n", nsres); + return E_FAIL; + } + + nsres = nsIDOMWindowCollection_GetLength(nscollection, &length); + nsIDOMWindowCollection_Release(nscollection); + if(NS_FAILED(nsres)) { + ERR("GetLength failed: %08x\n", nsres); + return E_FAIL; + } + + *p = length; + return S_OK; }
static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p) diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index 571c023..7429c60 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -89,6 +89,7 @@ interface nsIDocumentStateListener; interface nsIDOMCSSStyleSheet; interface nsIDOMDocumentView; interface nsIDocumentObserver; +interface nsIDOMWindow;
interface IMoniker;
@@ -109,7 +110,6 @@ typedef nsISupports nsISHistory; typedef nsISupports nsIWidget; typedef nsISupports nsIHttpHeaderVisitor; typedef nsISupports nsIDOMBarProp; -typedef nsISupports nsIDOMWindowCollection; typedef nsISupports nsIPrompt; typedef nsISupports nsIAuthPrompt; typedef nsISupports nsIDOMNamedNodeMap; @@ -1108,6 +1108,19 @@ interface nsISelection : nsISupports
[ object, + uuid(a6cf906f-15b3-11d2-932e-00805f8add32), + local + /* FROZEN */ +] +interface nsIDOMWindowCollection : nsISupports +{ + nsresult GetLength(PRUint32 *aLength); + nsresult Item(PRUint32 index, nsIDOMWindow **_retval); + nsresult NamedItem(const nsAString *name, nsIDOMWindow **_retval); +} + +[ + object, uuid(a6cf906b-15b3-11d2-932e-00805f8add32), local /* FROZEN */ diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index bb97429..f826a01 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -851,6 +851,16 @@ static void _set_window_name(unsigned line, IHTMLWindow2 *window, const char *na _test_window_name(line, window, name); }
+#define test_window_length(w,l) _test_window_length(__LINE__,w,l) +static void _test_window_length(unsigned line, IHTMLWindow2 *window, LONG exlen) +{ + LONG length = -1; + HRESULT hres; + + hres = IHTMLWindow2_get_length(window, &length); + ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres); + ok_(__FILE__,line)(length == exlen, "length = %d, expected %d\n", length, exlen); +}
static void test_get_set_attr(IHTMLDocument2 *doc) { @@ -4414,6 +4424,7 @@ static void test_window(IHTMLDocument2 *doc)
test_window_name(window, NULL); set_window_name(window, "test"); + test_window_length(window, 0);
IHTMLWindow2_Release(window); } @@ -4648,6 +4659,8 @@ static void test_iframe_elem(IHTMLElement *elem) ok(hres == S_OK, "get_contentWindow failed: %08x\n", hres); ok(content_window != NULL, "contentWindow = NULL\n");
+ test_window_length(content_window, 0); + content_doc = NULL; hres = IHTMLWindow2_get_document(content_window, &content_doc); IHTMLWindow2_Release(content_window); @@ -5202,6 +5215,7 @@ static void test_elems(IHTMLDocument2 *doc) window = get_doc_window(doc); test_window_name(window, NULL); set_window_name(window, "test name"); + test_window_length(window, 1); IHTMLWindow2_Release(window); }