Module: wine Branch: master Commit: 3c4b2a0b43a13166711bfe26674550d79849b7db URL: http://source.winehq.org/git/wine.git/?a=commit;h=3c4b2a0b43a13166711bfe2667...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Oct 18 15:07:50 2011 +0200
mshtml: Added IHTMLDocument2::elementFromPoint implementation.
---
dlls/mshtml/htmldoc.c | 34 ++++++++++++++++++++++++++++++++-- dlls/mshtml/tests/htmldoc.c | 22 ++++++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 9af5c8f..9ab287d 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -1297,8 +1297,38 @@ static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG IHTMLElement **elementHit) { HTMLDocument *This = impl_from_IHTMLDocument2(iface); - FIXME("(%p)->(%d %d %p)\n", This, x, y, elementHit); - return E_NOTIMPL; + nsIDOMNSDocument *nsdoc; + nsIDOMElement *nselem; + HTMLDOMNode *node; + nsresult nsres; + HRESULT hres; + + TRACE("(%p)->(%d %d %p)\n", This, x, y, elementHit); + + nsres = nsIDOMHTMLDocument_QueryInterface(This->doc_node->nsdoc, &IID_nsIDOMNSDocument, (void**)&nsdoc); + if(NS_FAILED(nsres)) { + ERR("Could not get nsIDOMNSDocument iface: %08x\n", nsres); + return E_FAIL; + } + + nsres = nsIDOMNSDocument_ElementFromPoint(nsdoc, x, y, &nselem); + nsIDOMNSDocument_Release(nsdoc); + if(NS_FAILED(nsres)) { + ERR("ElementFromPoint failed: %08x\n", nsres); + return E_FAIL; + } + + if(!nselem) { + *elementHit = NULL; + return S_OK; + } + + hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node); + nsIDOMElement_Release(nselem); + if(FAILED(hres)) + return hres; + + return IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)elementHit); }
static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p) diff --git a/dlls/mshtml/tests/htmldoc.c b/dlls/mshtml/tests/htmldoc.c index f7aef38..02c9eab 100644 --- a/dlls/mshtml/tests/htmldoc.c +++ b/dlls/mshtml/tests/htmldoc.c @@ -213,10 +213,10 @@ static const char *nav_url; static const char html_page[] = "<html>" "<head><link rel="stylesheet" type="text/css" href="test.css"></head>" -"<body>test</body>" +"<body><div>test</div></body>" "</html>";
-static const char css_data[] = "body {color: red}"; +static const char css_data[] = "body {color: red; margin: 0}";
static const WCHAR http_urlW[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0}; @@ -4429,6 +4429,23 @@ static void test_open_window(IHTMLDocument2 *doc) IHTMLWindow2_Release(window); }
+static void test_elem_from_point(IHTMLDocument2 *doc) +{ + IHTMLElement *elem; + BSTR tag; + HRESULT hres; + + elem = NULL; + hres = IHTMLDocument2_elementFromPoint(doc, 3, 3, &elem); + ok(hres == S_OK, "elementFromPoint failed: %08x\n", hres); + ok(elem != NULL, "elem == NULL\n"); + + hres = IHTMLElement_get_tagName(elem, &tag); + IHTMLElement_Release(elem); + ok(hres == S_OK, "get_tagName failed: %08x\n", hres); + ok(!strcmp_wa(tag, "DIV"), "tag = %s\n", wine_dbgstr_w(tag)); +} + static void test_clear(IHTMLDocument2 *doc) { HRESULT hres; @@ -5526,6 +5543,7 @@ static void test_HTMLDocument(BOOL do_load) set_custom_uihandler(doc, &CustomDocHostUIHandler); test_download(DWL_CSS|DWL_TRYCSS); test_GetCurMoniker((IUnknown*)doc, &Moniker, NULL); + test_elem_from_point(doc); }
test_MSHTML_QueryStatus(doc, OLECMDF_SUPPORTED);