Module: wine Branch: master Commit: f911e240d0ba98dd26b1f28b547ce818bcdb8b53 URL: http://source.winehq.org/git/wine.git/?a=commit;h=f911e240d0ba98dd26b1f28b54...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Jun 24 15:23:46 2008 -0500
mshtml: Added IHTMLElement::get_title implementation.
---
dlls/mshtml/htmlelem.c | 20 ++++++++++++++++++-- dlls/mshtml/tests/dom.c | 23 ++++++++++++++++++++++- 2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 91e4b6a..3ab3ac1 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -601,8 +601,24 @@ static HRESULT WINAPI HTMLElement_put_title(IHTMLElement *iface, BSTR v) static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p) { HTMLElement *This = HTMLELEM_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsAString title_str; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + nsAString_Init(&title_str, NULL); + nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str); + if(NS_SUCCEEDED(nsres)) { + const PRUnichar *title; + + nsAString_GetData(&title_str, &title); + *p = *title ? SysAllocString(title) : NULL; + }else { + ERR("GetTitle failed: %08x\n", nsres); + return E_FAIL; + } + + return S_OK; }
static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index f909c4f..e8f8468 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -42,7 +42,7 @@ static const char elem_test_str[] = "<html><head><title>test</title><style>.body { margin-right: 0px; }</style>" "<body>text test<!-- a comment -->" "<a href="http://test%5C" name="x">link</a>" - "<input id="in" class="testclass" tabIndex="2" />" + "<input id="in" class="testclass" tabIndex="2" title="test title" />" "<select id="s"><option id="x" value="val1">opt1</option><option id="y">opt2</option></select>" "<textarea id="X">text text</textarea>" "<table><tbody></tbody></table>" @@ -1090,6 +1090,24 @@ static void _test_elem_put_id(unsigned line, IUnknown *unk, const char *new_id) _test_elem_id(line, unk, new_id); }
+#define test_elem_title(u,t) _test_elem_title(__LINE__,u,t) +static void _test_elem_title(unsigned line, IUnknown *unk, const char *extitle) +{ + IHTMLElement *elem = _get_elem_iface(line, unk); + BSTR title; + HRESULT hres; + + hres = IHTMLElement_get_title(elem, &title); + IHTMLElement_Release(elem); + ok_(__FILE__,line) (hres == S_OK, "get_title failed: %08x\n", hres); + if(extitle) + ok_(__FILE__,line) (!strcmp_wa(title, extitle), "unexpected title %s\n", dbgstr_w(title)); + else + ok_(__FILE__,line) (!title, "title=%s, expected NULL\n", dbgstr_w(title)); + + SysFreeString(title); +} + #define test_node_get_value_str(u,e) _test_node_get_value_str(__LINE__,u,e) static void _test_node_get_value_str(unsigned line, IUnknown *unk, const char *exval) { @@ -1985,6 +2003,8 @@ static void test_elems(IHTMLDocument2 *doc)
test_select_elem(select);
+ test_elem_title((IUnknown*)select, NULL); + node = get_first_child((IUnknown*)select); ok(node != NULL, "node == NULL\n"); if(node) { @@ -2036,6 +2056,7 @@ static void test_elems(IHTMLDocument2 *doc) test_elem_class((IUnknown*)elem, "testclass"); test_elem_tabindex((IUnknown*)elem, 2); test_elem_set_tabindex((IUnknown*)elem, 3); + test_elem_title((IUnknown*)elem, "test title");
IHTMLInputElement_Release(input); IHTMLElement_Release(elem);