Module: wine Branch: master Commit: 11d62d7fcbfbf0031957a0abb752406f02dedc23 URL: http://source.winehq.org/git/wine.git/?a=commit;h=11d62d7fcbfbf0031957a0abb7...
Author: Jacek Caban jacek@codeweavers.com Date: Fri Oct 19 15:14:35 2007 +0200
mshtml: Added IHTMLTxtRange::expand("TextEdit") implementation.
---
dlls/mshtml/tests/dom.c | 3 +++ dlls/mshtml/txtrange.c | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index d49e1f0..dd46b8a 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -43,6 +43,7 @@ static const char doc_str3[] = static const WCHAR noneW[] = {'N','o','n','e',0};
static WCHAR characterW[] = {'c','h','a','r','a','c','t','e','r',0}; +static WCHAR texteditW[] = {'t','e','x','t','e','d','i','t',0}; static WCHAR wordW[] = {'w','o','r','d',0};
typedef enum { @@ -873,6 +874,8 @@ static void test_txtrange(IHTMLDocument2 *doc) test_range_moveend(range, characterW, 3, 3); test_range_text(range, "wor"); test_range_parent(range, ET_BODY); + test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text"); + test_range_expand(range, texteditW, VARIANT_TRUE, "wordabc 123\r\nit's text");
IHTMLTxtRange_Release(range); } diff --git a/dlls/mshtml/txtrange.c b/dlls/mshtml/txtrange.c index 7156d9a..df37753 100644 --- a/dlls/mshtml/txtrange.c +++ b/dlls/mshtml/txtrange.c @@ -1073,12 +1073,12 @@ static HRESULT WINAPI HTMLTxtRange_expand(IHTMLTxtRange *iface, BSTR Unit, VARIA if(unit == RU_UNKNOWN) return E_INVALIDARG;
+ *Success = VARIANT_FALSE; + switch(unit) { case RU_WORD: { dompos_t end_pos, start_pos, new_pos;
- *Success = VARIANT_FALSE; - get_cur_pos(This, TRUE, &start_pos); get_cur_pos(This, FALSE, &end_pos); if(find_next_space(&end_pos, TRUE, &new_pos)) { @@ -1097,6 +1097,40 @@ static HRESULT WINAPI HTMLTxtRange_expand(IHTMLTxtRange *iface, BSTR Unit, VARIA
break; } + + case RU_TEXTEDIT: { + nsIDOMDocument *nsdoc; + nsIDOMHTMLDocument *nshtmldoc; + nsIDOMHTMLElement *nsbody = NULL; + nsresult nsres; + + nsres = nsIWebNavigation_GetDocument(This->doc->nscontainer->navigation, &nsdoc); + if(NS_FAILED(nsres) || !nsdoc) { + ERR("GetDocument failed: %08x\n", nsres); + break; + } + + nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc); + nsIDOMDocument_Release(nsdoc); + + nsres = nsIDOMHTMLDocument_GetBody(nshtmldoc, &nsbody); + nsIDOMHTMLDocument_Release(nshtmldoc); + if(NS_FAILED(nsres) || !nsbody) { + ERR("Could not get body: %08x\n", nsres); + break; + } + + nsres = nsIDOMRange_SelectNodeContents(This->nsrange, (nsIDOMNode*)nsbody); + nsIDOMHTMLElement_Release(nsbody); + if(NS_FAILED(nsres)) { + ERR("Collapse failed: %08x\n", nsres); + break; + } + + *Success = VARIANT_TRUE; + break; + } + default: FIXME("Unimplemented unit %s\n", debugstr_w(Unit)); }