2 * Copyright 2006-2007 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
37 IHTMLTxtRange IHTMLTxtRange_iface
;
38 IOleCommandTarget IOleCommandTarget_iface
;
43 HTMLDocumentNode
*doc
;
50 IHTMLDOMRange IHTMLDOMRange_iface
;
77 static HTMLTxtRange
*get_range_object(HTMLDocumentNode
*doc
, IHTMLTxtRange
*iface
)
81 LIST_FOR_EACH_ENTRY(iter
, &doc
->range_list
, HTMLTxtRange
, entry
) {
82 if(&iter
->IHTMLTxtRange_iface
== iface
)
86 ERR("Could not find range in document\n");
90 static range_unit_t
string_to_unit(LPCWSTR str
)
92 if(!wcsicmp(str
, L
"character")) return RU_CHAR
;
93 if(!wcsicmp(str
, L
"word")) return RU_WORD
;
94 if(!wcsicmp(str
, L
"sentence")) return RU_SENTENCE
;
95 if(!wcsicmp(str
, L
"textedit")) return RU_TEXTEDIT
;
100 static int string_to_nscmptype(LPCWSTR str
)
102 if(!wcsicmp(str
, L
"StartToEnd")) return NS_START_TO_END
;
103 if(!wcsicmp(str
, L
"StartToStart")) return NS_START_TO_START
;
104 if(!wcsicmp(str
, L
"EndToStart")) return NS_END_TO_START
;
105 if(!wcsicmp(str
, L
"EndToEnd")) return NS_END_TO_END
;
110 static UINT16
get_node_type(nsIDOMNode
*node
)
115 nsIDOMNode_GetNodeType(node
, &type
);
120 static void get_text_node_data(nsIDOMNode
*node
, nsAString
*nsstr
, const PRUnichar
**str
)
125 nsres
= nsIDOMNode_QueryInterface(node
, &IID_nsIDOMText
, (void**)&nstext
);
126 assert(nsres
== NS_OK
);
128 nsAString_Init(nsstr
, NULL
);
129 nsres
= nsIDOMText_GetData(nstext
, nsstr
);
130 nsIDOMText_Release(nstext
);
132 ERR("GetData failed: %08lx\n", nsres
);
134 nsAString_GetData(nsstr
, str
);
137 static nsIDOMNode
*get_child_node(nsIDOMNode
*node
, UINT32 off
)
139 nsIDOMNodeList
*node_list
;
140 nsIDOMNode
*ret
= NULL
;
142 nsIDOMNode_GetChildNodes(node
, &node_list
);
143 nsIDOMNodeList_Item(node_list
, off
, &ret
);
144 nsIDOMNodeList_Release(node_list
);
149 /* This is very inefficient, but there is no faster way to compute index in
150 * child node list using public API. Gecko has internal nsINode::IndexOf
151 * function that we could consider exporting and use instead. */
152 static int get_child_index(nsIDOMNode
*parent
, nsIDOMNode
*child
)
154 nsIDOMNodeList
*node_list
;
159 nsres
= nsIDOMNode_GetChildNodes(parent
, &node_list
);
160 assert(nsres
== NS_OK
);
163 nsres
= nsIDOMNodeList_Item(node_list
, ret
, &node
);
164 assert(nsres
== NS_OK
&& node
);
166 nsIDOMNode_Release(node
);
169 nsIDOMNode_Release(node
);
173 nsIDOMNodeList_Release(node_list
);
177 static void init_rangepoint(rangepoint_t
*rangepoint
, nsIDOMNode
*node
, UINT32 off
)
179 nsIDOMNode_AddRef(node
);
181 rangepoint
->type
= get_node_type(node
);
182 rangepoint
->node
= node
;
183 rangepoint
->off
= off
;
186 static inline void free_rangepoint(rangepoint_t
*rangepoint
)
188 nsIDOMNode_Release(rangepoint
->node
);
191 static inline BOOL
rangepoint_cmp(const rangepoint_t
*point1
, const rangepoint_t
*point2
)
193 return point1
->node
== point2
->node
&& point1
->off
== point2
->off
;
196 static BOOL
rangepoint_next_node(rangepoint_t
*iter
)
202 /* Try to move to the child node. */
203 node
= get_child_node(iter
->node
, iter
->off
);
205 free_rangepoint(iter
);
206 init_rangepoint(iter
, node
, 0);
207 nsIDOMNode_Release(node
);
211 /* There are no more children in the node. Move to parent. */
212 nsres
= nsIDOMNode_GetParentNode(iter
->node
, &node
);
213 assert(nsres
== NS_OK
);
217 off
= get_child_index(node
, iter
->node
)+1;
218 free_rangepoint(iter
);
219 init_rangepoint(iter
, node
, off
);
220 nsIDOMNode_Release(node
);
224 static UINT32
get_child_count(nsIDOMNode
*node
)
226 nsIDOMNodeList
*node_list
;
230 nsres
= nsIDOMNode_GetChildNodes(node
, &node_list
);
231 assert(nsres
== NS_OK
);
233 nsres
= nsIDOMNodeList_GetLength(node_list
, &ret
);
234 nsIDOMNodeList_Release(node_list
);
235 assert(nsres
== NS_OK
);
240 static UINT32
get_text_length(nsIDOMNode
*node
)
246 nsres
= nsIDOMNode_QueryInterface(node
, &IID_nsIDOMText
, (void**)&nstext
);
247 assert(nsres
== NS_OK
);
249 nsres
= nsIDOMText_GetLength(nstext
, &ret
);
250 nsIDOMText_Release(nstext
);
251 assert(nsres
== NS_OK
);
256 static BOOL
rangepoint_prev_node(rangepoint_t
*iter
)
262 /* Try to move to the child node. */
264 node
= get_child_node(iter
->node
, iter
->off
-1);
265 assert(node
!= NULL
);
267 off
= get_node_type(node
) == TEXT_NODE
? get_text_length(node
) : get_child_count(node
);
268 free_rangepoint(iter
);
269 init_rangepoint(iter
, node
, off
);
270 nsIDOMNode_Release(node
);
274 /* There are no more children in the node. Move to parent. */
275 nsres
= nsIDOMNode_GetParentNode(iter
->node
, &node
);
276 assert(nsres
== NS_OK
);
280 off
= get_child_index(node
, iter
->node
);
281 free_rangepoint(iter
);
282 init_rangepoint(iter
, node
, off
);
286 static void get_start_point(HTMLTxtRange
*This
, rangepoint_t
*ret
)
291 nsIDOMRange_GetStartContainer(This
->nsrange
, &node
);
292 nsIDOMRange_GetStartOffset(This
->nsrange
, &off
);
294 init_rangepoint(ret
, node
, off
);
296 nsIDOMNode_Release(node
);
299 static void get_end_point(HTMLTxtRange
*This
, rangepoint_t
*ret
)
304 nsIDOMRange_GetEndContainer(This
->nsrange
, &node
);
305 nsIDOMRange_GetEndOffset(This
->nsrange
, &off
);
307 init_rangepoint(ret
, node
, off
);
309 nsIDOMNode_Release(node
);
312 static void set_start_point(HTMLTxtRange
*This
, const rangepoint_t
*start
)
314 nsresult nsres
= nsIDOMRange_SetStart(This
->nsrange
, start
->node
, start
->off
);
316 ERR("failed: %08lx\n", nsres
);
319 static void set_end_point(HTMLTxtRange
*This
, const rangepoint_t
*end
)
321 nsresult nsres
= nsIDOMRange_SetEnd(This
->nsrange
, end
->node
, end
->off
);
323 ERR("failed: %08lx\n", nsres
);
326 static BOOL
is_elem_tag(nsIDOMNode
*node
, LPCWSTR istag
)
330 const PRUnichar
*tag
;
334 nsres
= nsIDOMNode_QueryInterface(node
, &IID_nsIDOMElement
, (void**)&elem
);
338 nsAString_Init(&tag_str
, NULL
);
339 nsIDOMElement_GetTagName(elem
, &tag_str
);
340 nsIDOMElement_Release(elem
);
341 nsAString_GetData(&tag_str
, &tag
);
343 ret
= !wcsicmp(tag
, istag
);
345 nsAString_Finish(&tag_str
);
350 static inline BOOL
wstrbuf_init(wstrbuf_t
*buf
)
354 buf
->buf
= heap_alloc(buf
->size
* sizeof(WCHAR
));
355 if (!buf
->buf
) return FALSE
;
360 static inline void wstrbuf_finish(wstrbuf_t
*buf
)
365 static void wstrbuf_append_len(wstrbuf_t
*buf
, LPCWSTR str
, int len
)
367 if(buf
->len
+len
>= buf
->size
) {
368 buf
->size
= 2*buf
->size
+len
;
369 buf
->buf
= heap_realloc(buf
->buf
, buf
->size
* sizeof(WCHAR
));
372 memcpy(buf
->buf
+buf
->len
, str
, len
*sizeof(WCHAR
));
374 buf
->buf
[buf
->len
] = 0;
377 static void wstrbuf_append_nodetxt(wstrbuf_t
*buf
, LPCWSTR str
, int len
)
379 const WCHAR
*s
= str
;
382 TRACE("%s\n", debugstr_wn(str
, len
));
384 if(buf
->len
+len
>= buf
->size
) {
385 buf
->size
= 2*buf
->size
+len
;
386 buf
->buf
= heap_realloc(buf
->buf
, buf
->size
* sizeof(WCHAR
));
389 if(buf
->len
&& iswspace(buf
->buf
[buf
->len
-1])) {
390 while(s
< str
+len
&& iswspace(*s
))
394 d
= buf
->buf
+buf
->len
;
399 while(s
< str
+len
&& iswspace(*s
))
406 buf
->len
= d
- buf
->buf
;
410 static void wstrbuf_append_node(wstrbuf_t
*buf
, nsIDOMNode
*node
, BOOL ignore_text
)
413 switch(get_node_type(node
)) {
417 const PRUnichar
*data
;
422 nsIDOMNode_QueryInterface(node
, &IID_nsIDOMText
, (void**)&nstext
);
424 nsAString_Init(&data_str
, NULL
);
425 nsIDOMText_GetData(nstext
, &data_str
);
426 nsAString_GetData(&data_str
, &data
);
427 wstrbuf_append_nodetxt(buf
, data
, lstrlenW(data
));
428 nsAString_Finish(&data_str
);
430 nsIDOMText_Release(nstext
);
435 if(is_elem_tag(node
, L
"br")) {
436 static const WCHAR endlW
[] = {'\r','\n'};
437 wstrbuf_append_len(buf
, endlW
, 2);
438 }else if(is_elem_tag(node
, L
"hr")) {
439 static const WCHAR endl2W
[] = {'\r','\n','\r','\n'};
440 wstrbuf_append_len(buf
, endl2W
, 4);
445 static void wstrbuf_append_node_rec(wstrbuf_t
*buf
, nsIDOMNode
*node
)
447 nsIDOMNode
*iter
, *tmp
;
449 wstrbuf_append_node(buf
, node
, FALSE
);
451 nsIDOMNode_GetFirstChild(node
, &iter
);
453 wstrbuf_append_node_rec(buf
, iter
);
454 nsIDOMNode_GetNextSibling(iter
, &tmp
);
455 nsIDOMNode_Release(iter
);
460 static void range_to_string(HTMLTxtRange
*This
, wstrbuf_t
*buf
)
462 rangepoint_t end_pos
, iter
;
465 nsIDOMRange_GetCollapsed(This
->nsrange
, &collapsed
);
473 get_end_point(This
, &end_pos
);
474 get_start_point(This
, &iter
);
477 if(iter
.type
== TEXT_NODE
) {
478 const PRUnichar
*str
;
481 get_text_node_data(iter
.node
, &nsstr
, &str
);
483 if(iter
.node
== end_pos
.node
) {
484 wstrbuf_append_nodetxt(buf
, str
+iter
.off
, end_pos
.off
-iter
.off
);
485 nsAString_Finish(&nsstr
);
489 wstrbuf_append_nodetxt(buf
, str
+iter
.off
, lstrlenW(str
+iter
.off
));
490 nsAString_Finish(&nsstr
);
494 node
= get_child_node(iter
.node
, iter
.off
);
496 wstrbuf_append_node(buf
, node
, TRUE
);
497 nsIDOMNode_Release(node
);
501 if(!rangepoint_next_node(&iter
)) {
502 ERR("End of document?\n");
505 }while(!rangepoint_cmp(&iter
, &end_pos
));
507 free_rangepoint(&iter
);
508 free_rangepoint(&end_pos
);
513 for(p
= buf
->buf
+buf
->len
-1; p
>= buf
->buf
&& iswspace(*p
); p
--);
521 HRESULT
get_node_text(HTMLDOMNode
*node
, BSTR
*ret
)
526 if (!wstrbuf_init(&buf
))
527 return E_OUTOFMEMORY
;
528 wstrbuf_append_node_rec(&buf
, node
->nsnode
);
529 if(buf
.buf
&& *buf
.buf
) {
530 *ret
= SysAllocString(buf
.buf
);
532 hres
= E_OUTOFMEMORY
;
536 wstrbuf_finish(&buf
);
539 TRACE("ret %s\n", debugstr_w(*ret
));
543 static WCHAR
move_next_char(rangepoint_t
*iter
)
545 rangepoint_t last_space
;
553 const PRUnichar
*str
;
557 get_text_node_data(iter
->node
, &nsstr
, &str
);
560 nsAString_Finish(&nsstr
);
570 free_rangepoint(&last_space
);
576 nsAString_Finish(&nsstr
);
577 if(!c
) { /* continue to skip spaces */
578 init_rangepoint(&last_space
, iter
->node
, iter
->off
);
584 nsAString_Finish(&nsstr
);
587 /* If we have a non-space char and we're skipping spaces, stop and return the last found space. */
589 free_rangepoint(iter
);
598 node
= get_child_node(iter
->node
, iter
->off
);
602 if(is_elem_tag(node
, L
"br")) {
604 nsIDOMNode_Release(node
);
605 free_rangepoint(iter
);
611 init_rangepoint(&last_space
, iter
->node
, iter
->off
+1);
612 }else if(is_elem_tag(node
, L
"hr")) {
613 nsIDOMNode_Release(node
);
615 free_rangepoint(iter
);
624 nsIDOMNode_Release(node
);
626 }while(rangepoint_next_node(iter
));
631 static WCHAR
move_prev_char(rangepoint_t
*iter
)
633 rangepoint_t last_space
;
641 const PRUnichar
*str
;
648 get_text_node_data(iter
->node
, &nsstr
, &str
);
654 while(p
> str
&& iswspace(*(p
-1)))
658 free_rangepoint(&last_space
);
663 nsAString_Finish(&nsstr
);
664 if(p
== str
) { /* continue to skip spaces */
665 init_rangepoint(&last_space
, iter
->node
, iter
->off
);
671 nsAString_Finish(&nsstr
);
674 /* If we have a non-space char and we're skipping spaces, stop and return the last found space. */
676 free_rangepoint(iter
);
688 node
= get_child_node(iter
->node
, iter
->off
-1);
692 if(is_elem_tag(node
, L
"br")) {
694 free_rangepoint(&last_space
);
696 init_rangepoint(&last_space
, iter
->node
, iter
->off
-1);
697 }else if(is_elem_tag(node
, L
"hr")) {
698 nsIDOMNode_Release(node
);
700 free_rangepoint(iter
);
709 nsIDOMNode_Release(node
);
711 }while(rangepoint_prev_node(iter
));
714 free_rangepoint(iter
);
722 static LONG
move_by_chars(rangepoint_t
*iter
, LONG cnt
)
727 while(ret
< cnt
&& move_next_char(iter
))
730 while(ret
> cnt
&& move_prev_char(iter
))
737 static LONG
find_prev_space(rangepoint_t
*iter
, BOOL first_space
)
742 init_rangepoint(&prev
, iter
->node
, iter
->off
);
743 c
= move_prev_char(&prev
);
744 if(!c
|| (first_space
&& iswspace(c
)))
748 free_rangepoint(iter
);
749 init_rangepoint(iter
, prev
.node
, prev
.off
);
750 c
= move_prev_char(&prev
);
751 }while(c
&& !iswspace(c
));
753 free_rangepoint(&prev
);
757 static BOOL
find_word_end(rangepoint_t
*iter
, BOOL is_collapsed
)
759 rangepoint_t prev_iter
;
764 init_rangepoint(&prev_iter
, iter
->node
, iter
->off
);
765 c
= move_prev_char(&prev_iter
);
766 free_rangepoint(&prev_iter
);
772 init_rangepoint(&prev_iter
, iter
->node
, iter
->off
);
773 c
= move_next_char(iter
);
775 free_rangepoint(iter
);
781 ret
= !rangepoint_cmp(iter
, &prev_iter
);
785 free_rangepoint(&prev_iter
);
786 }while(c
&& !iswspace(c
));
791 static LONG
move_by_words(rangepoint_t
*iter
, LONG cnt
)
798 while(ret
< cnt
&& (c
= move_next_char(iter
))) {
803 while(ret
> cnt
&& find_prev_space(iter
, FALSE
))
810 static inline HTMLTxtRange
*impl_from_IHTMLTxtRange(IHTMLTxtRange
*iface
)
812 return CONTAINING_RECORD(iface
, HTMLTxtRange
, IHTMLTxtRange_iface
);
815 static HRESULT WINAPI
HTMLTxtRange_QueryInterface(IHTMLTxtRange
*iface
, REFIID riid
, void **ppv
)
817 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
819 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
821 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
822 *ppv
= &This
->IHTMLTxtRange_iface
;
823 }else if(IsEqualGUID(&IID_IHTMLTxtRange
, riid
)) {
824 *ppv
= &This
->IHTMLTxtRange_iface
;
825 }else if(IsEqualGUID(&IID_IOleCommandTarget
, riid
)) {
826 *ppv
= &This
->IOleCommandTarget_iface
;
827 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
828 return *ppv
? S_OK
: E_NOINTERFACE
;
831 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
832 return E_NOINTERFACE
;
835 IUnknown_AddRef((IUnknown
*)*ppv
);
839 static ULONG WINAPI
HTMLTxtRange_AddRef(IHTMLTxtRange
*iface
)
841 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
842 LONG ref
= InterlockedIncrement(&This
->ref
);
844 TRACE("(%p) ref=%ld\n", This
, ref
);
849 static ULONG WINAPI
HTMLTxtRange_Release(IHTMLTxtRange
*iface
)
851 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
852 LONG ref
= InterlockedDecrement(&This
->ref
);
854 TRACE("(%p) ref=%ld\n", This
, ref
);
858 nsIDOMRange_Release(This
->nsrange
);
860 list_remove(&This
->entry
);
861 release_dispex(&This
->dispex
);
868 static HRESULT WINAPI
HTMLTxtRange_GetTypeInfoCount(IHTMLTxtRange
*iface
, UINT
*pctinfo
)
870 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
872 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
875 static HRESULT WINAPI
HTMLTxtRange_GetTypeInfo(IHTMLTxtRange
*iface
, UINT iTInfo
,
876 LCID lcid
, ITypeInfo
**ppTInfo
)
878 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
880 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
883 static HRESULT WINAPI
HTMLTxtRange_GetIDsOfNames(IHTMLTxtRange
*iface
, REFIID riid
,
884 LPOLESTR
*rgszNames
, UINT cNames
,
885 LCID lcid
, DISPID
*rgDispId
)
887 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
889 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
,
890 cNames
, lcid
, rgDispId
);
893 static HRESULT WINAPI
HTMLTxtRange_Invoke(IHTMLTxtRange
*iface
, DISPID dispIdMember
,
894 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
895 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
897 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
899 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
900 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
903 static HRESULT WINAPI
HTMLTxtRange_get_htmlText(IHTMLTxtRange
*iface
, BSTR
*p
)
905 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
907 TRACE("(%p)->(%p)\n", This
, p
);
912 nsIDOMDocumentFragment
*fragment
;
915 nsres
= nsIDOMRange_CloneContents(This
->nsrange
, &fragment
);
916 if(NS_SUCCEEDED(nsres
)) {
917 const PRUnichar
*nstext
;
920 nsAString_Init(&nsstr
, NULL
);
921 nsnode_to_nsstring((nsIDOMNode
*)fragment
, &nsstr
);
922 nsIDOMDocumentFragment_Release(fragment
);
924 nsAString_GetData(&nsstr
, &nstext
);
925 *p
= SysAllocString(nstext
);
927 nsAString_Finish(&nsstr
);
932 *p
= SysAllocString(L
"");
935 TRACE("return %s\n", debugstr_w(*p
));
939 static HRESULT WINAPI
HTMLTxtRange_put_text(IHTMLTxtRange
*iface
, BSTR v
)
941 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
942 nsIDOMText
*text_node
;
946 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
949 return MSHTML_E_NODOC
;
951 nsAString_InitDepend(&text_str
, v
);
952 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->doc
->nsdoc
, &text_str
, &text_node
);
953 nsAString_Finish(&text_str
);
954 if(NS_FAILED(nsres
)) {
955 ERR("CreateTextNode failed: %08lx\n", nsres
);
958 nsres
= nsIDOMRange_DeleteContents(This
->nsrange
);
960 ERR("DeleteContents failed: %08lx\n", nsres
);
962 nsres
= nsIDOMRange_InsertNode(This
->nsrange
, (nsIDOMNode
*)text_node
);
964 ERR("InsertNode failed: %08lx\n", nsres
);
966 nsres
= nsIDOMRange_SetEndAfter(This
->nsrange
, (nsIDOMNode
*)text_node
);
968 ERR("SetEndAfter failed: %08lx\n", nsres
);
970 return IHTMLTxtRange_collapse(&This
->IHTMLTxtRange_iface
, VARIANT_FALSE
);
973 static HRESULT WINAPI
HTMLTxtRange_get_text(IHTMLTxtRange
*iface
, BSTR
*p
)
975 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
978 TRACE("(%p)->(%p)\n", This
, p
);
984 if (!wstrbuf_init(&buf
))
985 return E_OUTOFMEMORY
;
986 range_to_string(This
, &buf
);
988 *p
= SysAllocString(buf
.buf
);
989 wstrbuf_finish(&buf
);
991 TRACE("ret %s\n", debugstr_w(*p
));
995 static HRESULT WINAPI
HTMLTxtRange_parentElement(IHTMLTxtRange
*iface
, IHTMLElement
**parent
)
997 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
998 nsIDOMNode
*nsnode
, *tmp
;
1002 TRACE("(%p)->(%p)\n", This
, parent
);
1004 nsIDOMRange_GetCommonAncestorContainer(This
->nsrange
, &nsnode
);
1005 while(nsnode
&& get_node_type(nsnode
) != ELEMENT_NODE
) {
1006 nsIDOMNode_GetParentNode(nsnode
, &tmp
);
1007 nsIDOMNode_Release(nsnode
);
1016 hres
= get_node(nsnode
, TRUE
, &node
);
1017 nsIDOMNode_Release(nsnode
);
1021 hres
= IHTMLDOMNode_QueryInterface(&node
->IHTMLDOMNode_iface
, &IID_IHTMLElement
, (void**)parent
);
1026 static HRESULT WINAPI
HTMLTxtRange_duplicate(IHTMLTxtRange
*iface
, IHTMLTxtRange
**Duplicate
)
1028 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1029 nsIDOMRange
*nsrange
= NULL
;
1032 TRACE("(%p)->(%p)\n", This
, Duplicate
);
1034 nsIDOMRange_CloneRange(This
->nsrange
, &nsrange
);
1035 hres
= HTMLTxtRange_Create(This
->doc
, nsrange
, Duplicate
);
1036 nsIDOMRange_Release(nsrange
);
1041 static HRESULT WINAPI
HTMLTxtRange_inRange(IHTMLTxtRange
*iface
, IHTMLTxtRange
*Range
,
1042 VARIANT_BOOL
*InRange
)
1044 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1045 HTMLTxtRange
*src_range
;
1049 TRACE("(%p)->(%p %p)\n", This
, Range
, InRange
);
1051 *InRange
= VARIANT_FALSE
;
1053 src_range
= get_range_object(This
->doc
, Range
);
1057 nsres
= nsIDOMRange_CompareBoundaryPoints(This
->nsrange
, NS_START_TO_START
,
1058 src_range
->nsrange
, &nsret
);
1059 if(NS_SUCCEEDED(nsres
) && nsret
<= 0) {
1060 nsres
= nsIDOMRange_CompareBoundaryPoints(This
->nsrange
, NS_END_TO_END
,
1061 src_range
->nsrange
, &nsret
);
1062 if(NS_SUCCEEDED(nsres
) && nsret
>= 0)
1063 *InRange
= VARIANT_TRUE
;
1066 if(NS_FAILED(nsres
))
1067 ERR("CompareBoundaryPoints failed: %08lx\n", nsres
);
1072 static HRESULT WINAPI
HTMLTxtRange_isEqual(IHTMLTxtRange
*iface
, IHTMLTxtRange
*Range
,
1073 VARIANT_BOOL
*IsEqual
)
1075 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1076 HTMLTxtRange
*src_range
;
1080 TRACE("(%p)->(%p %p)\n", This
, Range
, IsEqual
);
1082 *IsEqual
= VARIANT_FALSE
;
1084 src_range
= get_range_object(This
->doc
, Range
);
1088 nsres
= nsIDOMRange_CompareBoundaryPoints(This
->nsrange
, NS_START_TO_START
,
1089 src_range
->nsrange
, &nsret
);
1090 if(NS_SUCCEEDED(nsres
) && !nsret
) {
1091 nsres
= nsIDOMRange_CompareBoundaryPoints(This
->nsrange
, NS_END_TO_END
,
1092 src_range
->nsrange
, &nsret
);
1093 if(NS_SUCCEEDED(nsres
) && !nsret
)
1094 *IsEqual
= VARIANT_TRUE
;
1097 if(NS_FAILED(nsres
))
1098 ERR("CompareBoundaryPoints failed: %08lx\n", nsres
);
1103 static HRESULT WINAPI
HTMLTxtRange_scrollIntoView(IHTMLTxtRange
*iface
, VARIANT_BOOL fStart
)
1105 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1106 FIXME("(%p)->(%x)\n", This
, fStart
);
1110 static HRESULT WINAPI
HTMLTxtRange_collapse(IHTMLTxtRange
*iface
, VARIANT_BOOL Start
)
1112 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1114 TRACE("(%p)->(%x)\n", This
, Start
);
1116 nsIDOMRange_Collapse(This
->nsrange
, Start
!= VARIANT_FALSE
);
1120 static HRESULT WINAPI
HTMLTxtRange_expand(IHTMLTxtRange
*iface
, BSTR Unit
, VARIANT_BOOL
*Success
)
1122 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1125 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(Unit
), Success
);
1127 unit
= string_to_unit(Unit
);
1128 if(unit
== RU_UNKNOWN
)
1129 return E_INVALIDARG
;
1131 *Success
= VARIANT_FALSE
;
1135 rangepoint_t end
, start
;
1136 cpp_bool is_collapsed
;
1138 get_start_point(This
, &start
);
1139 get_end_point(This
, &end
);
1141 nsIDOMRange_GetCollapsed(This
->nsrange
, &is_collapsed
);
1143 if(find_word_end(&end
, is_collapsed
)) {
1144 set_end_point(This
, &end
);
1145 *Success
= VARIANT_TRUE
;
1148 if(find_prev_space(&start
, TRUE
)) {
1149 set_start_point(This
, &start
);
1150 *Success
= VARIANT_TRUE
;
1153 free_rangepoint(&end
);
1154 free_rangepoint(&start
);
1159 nsIDOMHTMLElement
*nsbody
= NULL
;
1162 nsres
= nsIDOMHTMLDocument_GetBody(This
->doc
->nsdoc
, &nsbody
);
1163 if(NS_FAILED(nsres
) || !nsbody
) {
1164 ERR("Could not get body: %08lx\n", nsres
);
1168 nsres
= nsIDOMRange_SelectNodeContents(This
->nsrange
, (nsIDOMNode
*)nsbody
);
1169 nsIDOMHTMLElement_Release(nsbody
);
1170 if(NS_FAILED(nsres
)) {
1171 ERR("Collapse failed: %08lx\n", nsres
);
1175 *Success
= VARIANT_TRUE
;
1180 FIXME("Unimplemented unit %s\n", debugstr_w(Unit
));
1186 static HRESULT WINAPI
HTMLTxtRange_move(IHTMLTxtRange
*iface
, BSTR Unit
,
1187 LONG Count
, LONG
*ActualCount
)
1189 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1192 TRACE("(%p)->(%s %ld %p)\n", This
, debugstr_w(Unit
), Count
, ActualCount
);
1194 unit
= string_to_unit(Unit
);
1195 if(unit
== RU_UNKNOWN
)
1196 return E_INVALIDARG
;
1200 return IHTMLTxtRange_collapse(&This
->IHTMLTxtRange_iface
, VARIANT_TRUE
);
1207 get_start_point(This
, &start
);
1209 *ActualCount
= move_by_chars(&start
, Count
);
1211 set_start_point(This
, &start
);
1212 IHTMLTxtRange_collapse(&This
->IHTMLTxtRange_iface
, VARIANT_TRUE
);
1213 free_rangepoint(&start
);
1220 get_start_point(This
, &start
);
1222 *ActualCount
= move_by_words(&start
, Count
);
1224 set_start_point(This
, &start
);
1225 IHTMLTxtRange_collapse(&This
->IHTMLTxtRange_iface
, VARIANT_TRUE
);
1226 free_rangepoint(&start
);
1231 FIXME("unimplemented unit %s\n", debugstr_w(Unit
));
1234 TRACE("ret %ld\n", *ActualCount
);
1238 static HRESULT WINAPI
HTMLTxtRange_moveStart(IHTMLTxtRange
*iface
, BSTR Unit
,
1239 LONG Count
, LONG
*ActualCount
)
1241 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1244 TRACE("(%p)->(%s %ld %p)\n", This
, debugstr_w(Unit
), Count
, ActualCount
);
1246 unit
= string_to_unit(Unit
);
1247 if(unit
== RU_UNKNOWN
)
1248 return E_INVALIDARG
;
1259 get_start_point(This
, &start
);
1261 *ActualCount
= move_by_chars(&start
, Count
);
1263 set_start_point(This
, &start
);
1264 free_rangepoint(&start
);
1269 FIXME("unimplemented unit %s\n", debugstr_w(Unit
));
1276 static HRESULT WINAPI
HTMLTxtRange_moveEnd(IHTMLTxtRange
*iface
, BSTR Unit
,
1277 LONG Count
, LONG
*ActualCount
)
1279 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1282 TRACE("(%p)->(%s %ld %p)\n", This
, debugstr_w(Unit
), Count
, ActualCount
);
1284 unit
= string_to_unit(Unit
);
1285 if(unit
== RU_UNKNOWN
)
1286 return E_INVALIDARG
;
1297 get_end_point(This
, &end
);
1299 *ActualCount
= move_by_chars(&end
, Count
);
1301 set_end_point(This
, &end
);
1302 free_rangepoint(&end
);
1307 FIXME("unimplemented unit %s\n", debugstr_w(Unit
));
1313 static HRESULT WINAPI
HTMLTxtRange_select(IHTMLTxtRange
*iface
)
1315 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1316 nsISelection
*nsselection
;
1319 TRACE("(%p)\n", This
);
1321 nsres
= nsIDOMWindow_GetSelection(This
->doc
->basedoc
.window
->nswindow
, &nsselection
);
1322 if(NS_FAILED(nsres
)) {
1323 ERR("GetSelection failed: %08lx\n", nsres
);
1327 nsISelection_RemoveAllRanges(nsselection
);
1328 nsISelection_AddRange(nsselection
, This
->nsrange
);
1329 nsISelection_Release(nsselection
);
1333 static HRESULT WINAPI
HTMLTxtRange_pasteHTML(IHTMLTxtRange
*iface
, BSTR html
)
1335 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1336 nsIDOMDocumentFragment
*doc_frag
;
1340 TRACE("(%p)->(%s)\n", This
, debugstr_w(html
));
1342 nsres
= nsIDOMRange_Collapse(This
->nsrange
, TRUE
);
1343 assert(nsres
== NS_OK
);
1345 nsAString_InitDepend(&nsstr
, html
);
1346 nsres
= nsIDOMRange_CreateContextualFragment(This
->nsrange
, &nsstr
, &doc_frag
);
1347 nsAString_Finish(&nsstr
);
1348 if(NS_FAILED(nsres
)) {
1349 ERR("CreateContextualFragment failed: %08lx\n", nsres
);
1353 nsres
= nsIDOMRange_InsertNode(This
->nsrange
, (nsIDOMNode
*)doc_frag
);
1354 nsIDOMDocumentFragment_Release(doc_frag
);
1355 if(NS_FAILED(nsres
)) {
1356 ERR("InsertNode failed: %08lx\n", nsres
);
1360 nsres
= nsIDOMRange_Collapse(This
->nsrange
, FALSE
);
1361 assert(nsres
== NS_OK
);
1365 static HRESULT WINAPI
HTMLTxtRange_moveToElementText(IHTMLTxtRange
*iface
, IHTMLElement
*element
)
1367 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1371 TRACE("(%p)->(%p)\n", This
, element
);
1373 elem
= unsafe_impl_from_IHTMLElement(element
);
1375 return E_INVALIDARG
;
1377 nsres
= nsIDOMRange_SelectNodeContents(This
->nsrange
, elem
->node
.nsnode
);
1378 if(NS_FAILED(nsres
)) {
1379 ERR("SelectNodeContents failed: %08lx\n", nsres
);
1386 static HRESULT WINAPI
HTMLTxtRange_setEndPoint(IHTMLTxtRange
*iface
, BSTR how
,
1387 IHTMLTxtRange
*SourceRange
)
1389 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1390 HTMLTxtRange
*src_range
;
1391 nsIDOMNode
*ref_node
;
1398 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(how
), SourceRange
);
1400 how_type
= string_to_nscmptype(how
);
1402 return E_INVALIDARG
;
1404 src_range
= get_range_object(This
->doc
, SourceRange
);
1409 case NS_START_TO_START
:
1410 case NS_END_TO_START
:
1411 nsres
= nsIDOMRange_GetStartContainer(src_range
->nsrange
, &ref_node
);
1412 assert(nsres
== NS_OK
);
1414 nsres
= nsIDOMRange_GetStartOffset(src_range
->nsrange
, &ref_offset
);
1415 assert(nsres
== NS_OK
);
1417 set_start
= how_type
== NS_START_TO_START
;
1420 case NS_START_TO_END
:
1421 nsres
= nsIDOMRange_GetEndContainer(src_range
->nsrange
, &ref_node
);
1422 assert(nsres
== NS_OK
);
1424 nsres
= nsIDOMRange_GetEndOffset(src_range
->nsrange
, &ref_offset
);
1425 assert(nsres
== NS_OK
);
1427 set_start
= how_type
== NS_START_TO_END
;
1429 DEFAULT_UNREACHABLE
;
1432 nsres
= nsIDOMRange_ComparePoint(This
->nsrange
, ref_node
, ref_offset
, &cmp
);
1433 assert(nsres
== NS_OK
);
1437 nsres
= nsIDOMRange_SetStart(This
->nsrange
, ref_node
, ref_offset
);
1439 nsres
= nsIDOMRange_Collapse(This
->nsrange
, FALSE
);
1440 assert(nsres
== NS_OK
);
1442 nsres
= nsIDOMRange_SetEnd(This
->nsrange
, ref_node
, ref_offset
);
1446 nsres
= nsIDOMRange_SetEnd(This
->nsrange
, ref_node
, ref_offset
);
1448 nsres
= nsIDOMRange_Collapse(This
->nsrange
, TRUE
);
1449 assert(nsres
== NS_OK
);
1451 nsres
= nsIDOMRange_SetStart(This
->nsrange
, ref_node
, ref_offset
);
1454 assert(nsres
== NS_OK
);
1456 nsIDOMNode_Release(ref_node
);
1460 static HRESULT WINAPI
HTMLTxtRange_compareEndPoints(IHTMLTxtRange
*iface
, BSTR how
,
1461 IHTMLTxtRange
*SourceRange
, LONG
*ret
)
1463 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1464 HTMLTxtRange
*src_range
;
1469 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_w(how
), SourceRange
, ret
);
1471 nscmpt
= string_to_nscmptype(how
);
1473 return E_INVALIDARG
;
1475 src_range
= get_range_object(This
->doc
, SourceRange
);
1479 nsres
= nsIDOMRange_CompareBoundaryPoints(This
->nsrange
, nscmpt
, src_range
->nsrange
, &nsret
);
1480 if(NS_FAILED(nsres
))
1481 ERR("CompareBoundaryPoints failed: %08lx\n", nsres
);
1487 static HRESULT WINAPI
HTMLTxtRange_findText(IHTMLTxtRange
*iface
, BSTR String
,
1488 LONG count
, LONG Flags
, VARIANT_BOOL
*Success
)
1490 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1491 FIXME("(%p)->(%s %ld %08lx %p)\n", This
, debugstr_w(String
), count
, Flags
, Success
);
1495 static HRESULT WINAPI
HTMLTxtRange_moveToPoint(IHTMLTxtRange
*iface
, LONG x
, LONG y
)
1497 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1498 FIXME("(%p)->(%ld %ld)\n", This
, x
, y
);
1502 static HRESULT WINAPI
HTMLTxtRange_getBookmark(IHTMLTxtRange
*iface
, BSTR
*Bookmark
)
1504 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1505 FIXME("(%p)->(%p)\n", This
, Bookmark
);
1509 static HRESULT WINAPI
HTMLTxtRange_moveToBookmark(IHTMLTxtRange
*iface
, BSTR Bookmark
,
1510 VARIANT_BOOL
*Success
)
1512 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1513 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(Bookmark
), Success
);
1517 static HRESULT WINAPI
HTMLTxtRange_queryCommandSupported(IHTMLTxtRange
*iface
, BSTR cmdID
,
1518 VARIANT_BOOL
*pfRet
)
1520 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1521 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
1525 static HRESULT WINAPI
HTMLTxtRange_queryCommandEnabled(IHTMLTxtRange
*iface
, BSTR cmdID
,
1526 VARIANT_BOOL
*pfRet
)
1528 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1529 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
1533 static HRESULT WINAPI
HTMLTxtRange_queryCommandState(IHTMLTxtRange
*iface
, BSTR cmdID
,
1534 VARIANT_BOOL
*pfRet
)
1536 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1537 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
1541 static HRESULT WINAPI
HTMLTxtRange_queryCommandIndeterm(IHTMLTxtRange
*iface
, BSTR cmdID
,
1542 VARIANT_BOOL
*pfRet
)
1544 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1545 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
1549 static HRESULT WINAPI
HTMLTxtRange_queryCommandText(IHTMLTxtRange
*iface
, BSTR cmdID
,
1552 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1553 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pcmdText
);
1557 static HRESULT WINAPI
HTMLTxtRange_queryCommandValue(IHTMLTxtRange
*iface
, BSTR cmdID
,
1560 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1561 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pcmdValue
);
1565 static HRESULT WINAPI
HTMLTxtRange_execCommand(IHTMLTxtRange
*iface
, BSTR cmdID
,
1566 VARIANT_BOOL showUI
, VARIANT value
, VARIANT_BOOL
*pfRet
)
1568 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1569 FIXME("(%p)->(%s %x v %p)\n", This
, debugstr_w(cmdID
), showUI
, pfRet
);
1573 static HRESULT WINAPI
HTMLTxtRange_execCommandShowHelp(IHTMLTxtRange
*iface
, BSTR cmdID
,
1574 VARIANT_BOOL
*pfRet
)
1576 HTMLTxtRange
*This
= impl_from_IHTMLTxtRange(iface
);
1577 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(cmdID
), pfRet
);
1581 static const IHTMLTxtRangeVtbl HTMLTxtRangeVtbl
= {
1582 HTMLTxtRange_QueryInterface
,
1583 HTMLTxtRange_AddRef
,
1584 HTMLTxtRange_Release
,
1585 HTMLTxtRange_GetTypeInfoCount
,
1586 HTMLTxtRange_GetTypeInfo
,
1587 HTMLTxtRange_GetIDsOfNames
,
1588 HTMLTxtRange_Invoke
,
1589 HTMLTxtRange_get_htmlText
,
1590 HTMLTxtRange_put_text
,
1591 HTMLTxtRange_get_text
,
1592 HTMLTxtRange_parentElement
,
1593 HTMLTxtRange_duplicate
,
1594 HTMLTxtRange_inRange
,
1595 HTMLTxtRange_isEqual
,
1596 HTMLTxtRange_scrollIntoView
,
1597 HTMLTxtRange_collapse
,
1598 HTMLTxtRange_expand
,
1600 HTMLTxtRange_moveStart
,
1601 HTMLTxtRange_moveEnd
,
1602 HTMLTxtRange_select
,
1603 HTMLTxtRange_pasteHTML
,
1604 HTMLTxtRange_moveToElementText
,
1605 HTMLTxtRange_setEndPoint
,
1606 HTMLTxtRange_compareEndPoints
,
1607 HTMLTxtRange_findText
,
1608 HTMLTxtRange_moveToPoint
,
1609 HTMLTxtRange_getBookmark
,
1610 HTMLTxtRange_moveToBookmark
,
1611 HTMLTxtRange_queryCommandSupported
,
1612 HTMLTxtRange_queryCommandEnabled
,
1613 HTMLTxtRange_queryCommandState
,
1614 HTMLTxtRange_queryCommandIndeterm
,
1615 HTMLTxtRange_queryCommandText
,
1616 HTMLTxtRange_queryCommandValue
,
1617 HTMLTxtRange_execCommand
,
1618 HTMLTxtRange_execCommandShowHelp
1621 static inline HTMLTxtRange
*impl_from_IOleCommandTarget(IOleCommandTarget
*iface
)
1623 return CONTAINING_RECORD(iface
, HTMLTxtRange
, IOleCommandTarget_iface
);
1626 static HRESULT WINAPI
RangeCommandTarget_QueryInterface(IOleCommandTarget
*iface
, REFIID riid
, void **ppv
)
1628 HTMLTxtRange
*This
= impl_from_IOleCommandTarget(iface
);
1629 return IHTMLTxtRange_QueryInterface(&This
->IHTMLTxtRange_iface
, riid
, ppv
);
1632 static ULONG WINAPI
RangeCommandTarget_AddRef(IOleCommandTarget
*iface
)
1634 HTMLTxtRange
*This
= impl_from_IOleCommandTarget(iface
);
1635 return IHTMLTxtRange_AddRef(&This
->IHTMLTxtRange_iface
);
1638 static ULONG WINAPI
RangeCommandTarget_Release(IOleCommandTarget
*iface
)
1640 HTMLTxtRange
*This
= impl_from_IOleCommandTarget(iface
);
1641 return IHTMLTxtRange_Release(&This
->IHTMLTxtRange_iface
);
1644 static HRESULT WINAPI
RangeCommandTarget_QueryStatus(IOleCommandTarget
*iface
, const GUID
*pguidCmdGroup
,
1645 ULONG cCmds
, OLECMD prgCmds
[], OLECMDTEXT
*pCmdText
)
1647 HTMLTxtRange
*This
= impl_from_IOleCommandTarget(iface
);
1648 FIXME("(%p)->(%s %ld %p %p)\n", This
, debugstr_guid(pguidCmdGroup
), cCmds
, prgCmds
, pCmdText
);
1652 static HRESULT
exec_indent(HTMLTxtRange
*This
, VARIANT
*in
, VARIANT
*out
)
1654 nsIDOMElement
*blockquote_elem
, *p_elem
;
1655 nsIDOMDocumentFragment
*fragment
;
1658 TRACE("(%p)->(%p %p)\n", This
, in
, out
);
1660 if(!This
->doc
->nsdoc
) {
1661 WARN("NULL nsdoc\n");
1665 create_nselem(This
->doc
, L
"BLOCKQUOTE", &blockquote_elem
);
1666 create_nselem(This
->doc
, L
"P", &p_elem
);
1668 nsIDOMRange_ExtractContents(This
->nsrange
, &fragment
);
1669 nsIDOMElement_AppendChild(p_elem
, (nsIDOMNode
*)fragment
, &tmp
);
1670 nsIDOMDocumentFragment_Release(fragment
);
1671 nsIDOMNode_Release(tmp
);
1673 nsIDOMElement_AppendChild(blockquote_elem
, (nsIDOMNode
*)p_elem
, &tmp
);
1674 nsIDOMElement_Release(p_elem
);
1675 nsIDOMNode_Release(tmp
);
1677 nsIDOMRange_InsertNode(This
->nsrange
, (nsIDOMNode
*)blockquote_elem
);
1678 nsIDOMElement_Release(blockquote_elem
);
1683 static HRESULT WINAPI
RangeCommandTarget_Exec(IOleCommandTarget
*iface
, const GUID
*pguidCmdGroup
,
1684 DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
1686 HTMLTxtRange
*This
= impl_from_IOleCommandTarget(iface
);
1688 TRACE("(%p)->(%s %ld %lx %p %p)\n", This
, debugstr_guid(pguidCmdGroup
), nCmdID
,
1689 nCmdexecopt
, pvaIn
, pvaOut
);
1691 if(pguidCmdGroup
&& IsEqualGUID(&CGID_MSHTML
, pguidCmdGroup
)) {
1694 return exec_indent(This
, pvaIn
, pvaOut
);
1696 FIXME("Unsupported cmdid %ld of CGID_MSHTML\n", nCmdID
);
1699 FIXME("Unsupported cmd %ld of group %s\n", nCmdID
, debugstr_guid(pguidCmdGroup
));
1705 static const IOleCommandTargetVtbl OleCommandTargetVtbl
= {
1706 RangeCommandTarget_QueryInterface
,
1707 RangeCommandTarget_AddRef
,
1708 RangeCommandTarget_Release
,
1709 RangeCommandTarget_QueryStatus
,
1710 RangeCommandTarget_Exec
1713 static const tid_t HTMLTxtRange_iface_tids
[] = {
1717 static dispex_static_data_t HTMLTxtRange_dispex
= {
1721 HTMLTxtRange_iface_tids
1724 HRESULT
HTMLTxtRange_Create(HTMLDocumentNode
*doc
, nsIDOMRange
*nsrange
, IHTMLTxtRange
**p
)
1728 ret
= heap_alloc(sizeof(HTMLTxtRange
));
1730 return E_OUTOFMEMORY
;
1732 init_dispatch(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLTxtRange_iface
, &HTMLTxtRange_dispex
,
1733 dispex_compat_mode(&doc
->node
.event_target
.dispex
));
1735 ret
->IHTMLTxtRange_iface
.lpVtbl
= &HTMLTxtRangeVtbl
;
1736 ret
->IOleCommandTarget_iface
.lpVtbl
= &OleCommandTargetVtbl
;
1740 nsIDOMRange_AddRef(nsrange
);
1741 ret
->nsrange
= nsrange
;
1744 list_add_head(&doc
->range_list
, &ret
->entry
);
1746 *p
= &ret
->IHTMLTxtRange_iface
;
1750 static inline HTMLDOMRange
*impl_from_IHTMLDOMRange(IHTMLDOMRange
*iface
)
1752 return CONTAINING_RECORD(iface
, HTMLDOMRange
, IHTMLDOMRange_iface
);
1755 static HRESULT WINAPI
HTMLDOMRange_QueryInterface(IHTMLDOMRange
*iface
, REFIID riid
, void **ppv
)
1757 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1759 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
1761 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1762 *ppv
= &This
->IHTMLDOMRange_iface
;
1763 }else if(IsEqualGUID(&IID_IHTMLDOMRange
, riid
)) {
1764 *ppv
= &This
->IHTMLDOMRange_iface
;
1765 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
1766 return *ppv
? S_OK
: E_NOINTERFACE
;
1769 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
1770 return E_NOINTERFACE
;
1773 IUnknown_AddRef((IUnknown
*)*ppv
);
1777 static ULONG WINAPI
HTMLDOMRange_AddRef(IHTMLDOMRange
*iface
)
1779 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1780 LONG ref
= InterlockedIncrement(&This
->ref
);
1782 TRACE("(%p) ref=%ld\n", This
, ref
);
1787 static ULONG WINAPI
HTMLDOMRange_Release(IHTMLDOMRange
*iface
)
1789 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1790 LONG ref
= InterlockedDecrement(&This
->ref
);
1792 TRACE("(%p) ref=%ld\n", This
, ref
);
1796 nsIDOMRange_Release(This
->nsrange
);
1797 release_dispex(&This
->dispex
);
1804 static HRESULT WINAPI
HTMLDOMRange_GetTypeInfoCount(IHTMLDOMRange
*iface
, UINT
*pctinfo
)
1806 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1808 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
1811 static HRESULT WINAPI
HTMLDOMRange_GetTypeInfo(IHTMLDOMRange
*iface
, UINT iTInfo
,
1812 LCID lcid
, ITypeInfo
**ppTInfo
)
1814 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1816 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1819 static HRESULT WINAPI
HTMLDOMRange_GetIDsOfNames(IHTMLDOMRange
*iface
, REFIID riid
,
1820 LPOLESTR
*rgszNames
, UINT cNames
,
1821 LCID lcid
, DISPID
*rgDispId
)
1823 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1825 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
,
1826 cNames
, lcid
, rgDispId
);
1829 static HRESULT WINAPI
HTMLDOMRange_Invoke(IHTMLDOMRange
*iface
, DISPID dispIdMember
,
1830 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1831 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1833 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1835 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
1836 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1839 static HRESULT WINAPI
HTMLDOMRange_get_startContainer(IHTMLDOMRange
*iface
, IHTMLDOMNode
**p
)
1841 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1842 FIXME("(%p)->(%p)\n", This
, p
);
1846 static HRESULT WINAPI
HTMLDOMRange_get_startOffset(IHTMLDOMRange
*iface
, LONG
*p
)
1848 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1849 FIXME("(%p)->(%p)\n", This
, p
);
1853 static HRESULT WINAPI
HTMLDOMRange_get_endContainer(IHTMLDOMRange
*iface
, IHTMLDOMNode
**p
)
1855 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1856 FIXME("(%p)->(%p)\n", This
, p
);
1860 static HRESULT WINAPI
HTMLDOMRange_get_endOffset(IHTMLDOMRange
*iface
, LONG
*p
)
1862 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1863 FIXME("(%p)->(%p)\n", This
, p
);
1867 static HRESULT WINAPI
HTMLDOMRange_get_collapsed(IHTMLDOMRange
*iface
, VARIANT_BOOL
*p
)
1869 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1870 FIXME("(%p)->(%p)\n", This
, p
);
1874 static HRESULT WINAPI
HTMLDOMRange_get_commonAncestorContainer(IHTMLDOMRange
*iface
, IHTMLDOMNode
**p
)
1876 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1877 FIXME("(%p)->(%p)\n", This
, p
);
1881 static HRESULT WINAPI
HTMLDOMRange_setStart(IHTMLDOMRange
*iface
, IDispatch
*node
, LONG offset
)
1883 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1884 FIXME("(%p)->(%p, %ld)\n", This
, node
, offset
);
1888 static HRESULT WINAPI
HTMLDOMRange_setEnd(IHTMLDOMRange
*iface
, IDispatch
*node
, LONG offset
)
1890 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1891 FIXME("(%p)->(%p, %ld)\n", This
, node
, offset
);
1895 static HRESULT WINAPI
HTMLDOMRange_setStartBefore(IHTMLDOMRange
*iface
, IDispatch
*node
)
1897 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1898 FIXME("(%p)->(%p)\n", This
, node
);
1902 static HRESULT WINAPI
HTMLDOMRange_setStartAfter(IHTMLDOMRange
*iface
, IDispatch
*node
)
1904 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1905 FIXME("(%p)->(%p)\n", This
, node
);
1909 static HRESULT WINAPI
HTMLDOMRange_setEndBefore(IHTMLDOMRange
*iface
, IDispatch
*node
)
1911 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1912 FIXME("(%p)->(%p)\n", This
, node
);
1916 static HRESULT WINAPI
HTMLDOMRange_setEndAfter(IHTMLDOMRange
*iface
, IDispatch
*node
)
1918 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1919 FIXME("(%p)->(%p)\n", This
, node
);
1923 static HRESULT WINAPI
HTMLDOMRange_collapse(IHTMLDOMRange
*iface
, VARIANT_BOOL tostart
)
1925 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1926 FIXME("(%p)->(%x)\n", This
, tostart
);
1930 static HRESULT WINAPI
HTMLDOMRange_selectNode(IHTMLDOMRange
*iface
, IDispatch
*node
)
1932 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1933 FIXME("(%p)->(%p)\n", This
, node
);
1937 static HRESULT WINAPI
HTMLDOMRange_selectNodeContents(IHTMLDOMRange
*iface
, IDispatch
*node
)
1939 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1940 FIXME("(%p)->(%p)\n", This
, node
);
1944 static HRESULT WINAPI
HTMLDOMRange_compareBoundaryPoints(IHTMLDOMRange
*iface
, short how
,
1945 IDispatch
*src_range
, LONG
*result
)
1947 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1948 FIXME("(%p)->(%x, %p, %p)\n", This
, how
, src_range
, result
);
1952 static HRESULT WINAPI
HTMLDOMRange_deleteContents(IHTMLDOMRange
*iface
)
1954 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1955 FIXME("(%p)\n", This
);
1959 static HRESULT WINAPI
HTMLDOMRange_extractContents(IHTMLDOMRange
*iface
, IDispatch
**p
)
1961 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1962 FIXME("(%p)->(%p)\n", This
, p
);
1966 static HRESULT WINAPI
HTMLDOMRange_cloneContents(IHTMLDOMRange
*iface
, IDispatch
**p
)
1968 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1969 FIXME("(%p)->(%p)\n", This
, p
);
1973 static HRESULT WINAPI
HTMLDOMRange_insertNode(IHTMLDOMRange
*iface
, IDispatch
*node
)
1975 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1976 FIXME("(%p)->(%p)\n", This
, node
);
1980 static HRESULT WINAPI
HTMLDOMRange_surroundContents(IHTMLDOMRange
*iface
, IDispatch
*parent
)
1982 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1983 FIXME("(%p)->(%p)\n", This
, parent
);
1987 static HRESULT WINAPI
HTMLDOMRange_cloneRange(IHTMLDOMRange
*iface
, IHTMLDOMRange
**p
)
1989 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1990 FIXME("(%p)->(%p)\n", This
, p
);
1994 static HRESULT WINAPI
HTMLDOMRange_toString(IHTMLDOMRange
*iface
, BSTR
*p
)
1996 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
1997 FIXME("(%p)->(%p)\n", This
, p
);
2001 static HRESULT WINAPI
HTMLDOMRange_detach(IHTMLDOMRange
*iface
)
2003 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
2004 FIXME("(%p)\n", This
);
2008 static HRESULT WINAPI
HTMLDOMRange_getClientRects(IHTMLDOMRange
*iface
, IHTMLRectCollection
**p
)
2010 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
2011 FIXME("(%p)->(%p)\n", This
, p
);
2015 static HRESULT WINAPI
HTMLDOMRange_getBoundingClientRect(IHTMLDOMRange
*iface
, IHTMLRect
**p
)
2017 HTMLDOMRange
*This
= impl_from_IHTMLDOMRange(iface
);
2018 FIXME("(%p)->(%p)\n", This
, p
);
2022 static const IHTMLDOMRangeVtbl HTMLDOMRangeVtbl
= {
2023 HTMLDOMRange_QueryInterface
,
2024 HTMLDOMRange_AddRef
,
2025 HTMLDOMRange_Release
,
2026 HTMLDOMRange_GetTypeInfoCount
,
2027 HTMLDOMRange_GetTypeInfo
,
2028 HTMLDOMRange_GetIDsOfNames
,
2029 HTMLDOMRange_Invoke
,
2030 HTMLDOMRange_get_startContainer
,
2031 HTMLDOMRange_get_startOffset
,
2032 HTMLDOMRange_get_endContainer
,
2033 HTMLDOMRange_get_endOffset
,
2034 HTMLDOMRange_get_collapsed
,
2035 HTMLDOMRange_get_commonAncestorContainer
,
2036 HTMLDOMRange_setStart
,
2037 HTMLDOMRange_setEnd
,
2038 HTMLDOMRange_setStartBefore
,
2039 HTMLDOMRange_setStartAfter
,
2040 HTMLDOMRange_setEndBefore
,
2041 HTMLDOMRange_setEndAfter
,
2042 HTMLDOMRange_collapse
,
2043 HTMLDOMRange_selectNode
,
2044 HTMLDOMRange_selectNodeContents
,
2045 HTMLDOMRange_compareBoundaryPoints
,
2046 HTMLDOMRange_deleteContents
,
2047 HTMLDOMRange_extractContents
,
2048 HTMLDOMRange_cloneContents
,
2049 HTMLDOMRange_insertNode
,
2050 HTMLDOMRange_surroundContents
,
2051 HTMLDOMRange_cloneRange
,
2052 HTMLDOMRange_toString
,
2053 HTMLDOMRange_detach
,
2054 HTMLDOMRange_getClientRects
,
2055 HTMLDOMRange_getBoundingClientRect
,
2058 static const tid_t HTMLDOMRange_iface_tids
[] = {
2063 static dispex_static_data_t HTMLDOMRange_dispex
= {
2066 DispHTMLDOMRange_tid
,
2067 HTMLDOMRange_iface_tids
2070 HRESULT
create_dom_range(nsIDOMRange
*nsrange
, compat_mode_t compat_mode
, IHTMLDOMRange
**p
)
2074 ret
= heap_alloc(sizeof(*ret
));
2076 return E_OUTOFMEMORY
;
2078 init_dispatch(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLDOMRange_iface
, &HTMLDOMRange_dispex
, compat_mode
);
2080 ret
->IHTMLDOMRange_iface
.lpVtbl
= &HTMLDOMRangeVtbl
;
2084 nsIDOMRange_AddRef(nsrange
);
2085 ret
->nsrange
= nsrange
;
2087 *p
= &ret
->IHTMLDOMRange_iface
;
2091 void detach_ranges(HTMLDocumentNode
*This
)
2093 HTMLTxtRange
*iter
, *next
;
2095 LIST_FOR_EACH_ENTRY_SAFE(iter
, next
, &This
->range_list
, HTMLTxtRange
, entry
) {
2097 list_remove(&iter
->entry
);
2102 IMarkupPointer2 IMarkupPointer2_iface
;
2106 static inline MarkupPointer
*impl_from_IMarkupPointer2(IMarkupPointer2
*iface
)
2108 return CONTAINING_RECORD(iface
, MarkupPointer
, IMarkupPointer2_iface
);
2111 static HRESULT WINAPI
MarkupPointer2_QueryInterface(IMarkupPointer2
*iface
, REFIID riid
, void **ppv
)
2113 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2115 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
2117 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
2118 *ppv
= &This
->IMarkupPointer2_iface
;
2119 }else if(IsEqualGUID(&IID_IMarkupPointer
, riid
)) {
2120 *ppv
= &This
->IMarkupPointer2_iface
;
2121 }else if(IsEqualGUID(&IID_IMarkupPointer2
, riid
)) {
2122 *ppv
= &This
->IMarkupPointer2_iface
;
2125 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
2126 return E_NOINTERFACE
;
2129 IUnknown_AddRef((IUnknown
*)*ppv
);
2133 static ULONG WINAPI
MarkupPointer2_AddRef(IMarkupPointer2
*iface
)
2135 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2136 LONG ref
= InterlockedIncrement(&This
->ref
);
2138 TRACE("(%p) ref=%ld\n", This
, ref
);
2143 static ULONG WINAPI
MarkupPointer2_Release(IMarkupPointer2
*iface
)
2145 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2146 LONG ref
= InterlockedDecrement(&This
->ref
);
2148 TRACE("(%p) ref=%ld\n", This
, ref
);
2156 static HRESULT WINAPI
MarkupPointer2_OwningDoc(IMarkupPointer2
*iface
, IHTMLDocument2
**p
)
2158 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2159 FIXME("(%p)->(%p)\n", This
, p
);
2163 static HRESULT WINAPI
MarkupPointer2_Gravity(IMarkupPointer2
*iface
, POINTER_GRAVITY
*p
)
2165 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2166 FIXME("(%p)->(%p)\n", This
, p
);
2170 static HRESULT WINAPI
MarkupPointer2_SetGravity(IMarkupPointer2
*iface
, POINTER_GRAVITY gravity
)
2172 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2173 FIXME("(%p)->(%u)\n", This
, gravity
);
2177 static HRESULT WINAPI
MarkupPointer2_Cling(IMarkupPointer2
*iface
, BOOL
*p
)
2179 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2180 FIXME("(%p)->(%p)\n", This
, p
);
2184 static HRESULT WINAPI
MarkupPointer2_SetCling(IMarkupPointer2
*iface
, BOOL cling
)
2186 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2187 FIXME("(%p)->(%x)\n", This
, cling
);
2191 static HRESULT WINAPI
MarkupPointer2_Unposition(IMarkupPointer2
*iface
)
2193 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2194 FIXME("(%p)\n", This
);
2198 static HRESULT WINAPI
MarkupPointer2_IsPositioned(IMarkupPointer2
*iface
, BOOL
*p
)
2200 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2201 FIXME("(%p)->(%p)\n", This
, p
);
2205 static HRESULT WINAPI
MarkupPointer2_GetContainer(IMarkupPointer2
*iface
, IMarkupContainer
**p
)
2207 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2208 FIXME("(%p)->(%p)\n", This
, p
);
2212 static HRESULT WINAPI
MarkupPointer2_MoveAdjacentToElement(IMarkupPointer2
*iface
, IHTMLElement
*element
, ELEMENT_ADJACENCY adj
)
2214 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2215 FIXME("(%p)->(%p %u)\n", This
, element
, adj
);
2219 static HRESULT WINAPI
MarkupPointer2_MoveToPointer(IMarkupPointer2
*iface
, IMarkupPointer
*pointer
)
2221 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2222 FIXME("(%p)->(%p)\n", This
, pointer
);
2226 static HRESULT WINAPI
MarkupPointer2_MoveToContainer(IMarkupPointer2
*iface
, IMarkupContainer
*container
, BOOL at_start
)
2228 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2229 FIXME("(%p)->(%p %x)\n", This
, container
, at_start
);
2233 static HRESULT WINAPI
MarkupPointer2_Left(IMarkupPointer2
*iface
, BOOL move
, MARKUP_CONTEXT_TYPE
*context
,
2234 IHTMLElement
**element
, LONG
*len
, OLECHAR
*text
)
2236 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2237 FIXME("(%p)->(%x %p %p %p %p)\n", This
, move
, context
, element
, len
, text
);
2241 static HRESULT WINAPI
MarkupPointer2_Right(IMarkupPointer2
*iface
, BOOL move
, MARKUP_CONTEXT_TYPE
*context
,
2242 IHTMLElement
**element
, LONG
*len
, OLECHAR
*text
)
2244 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2245 FIXME("(%p)->(%x %p %p %p %p)\n", This
, move
, context
, element
, len
, text
);
2249 static HRESULT WINAPI
MarkupPointer2_CurrentScope(IMarkupPointer2
*iface
, IHTMLElement
**p
)
2251 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2252 FIXME("(%p)->(%p)\n", This
, p
);
2256 static HRESULT WINAPI
MarkupPointer2_IsLeftOf(IMarkupPointer2
*iface
, IMarkupPointer
*that_pointer
, BOOL
*p
)
2258 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2259 FIXME("(%p)->(%p %p)\n", This
, that_pointer
, p
);
2263 static HRESULT WINAPI
MarkupPointer2_IsLeftOfOrEqualTo(IMarkupPointer2
*iface
, IMarkupPointer
*that_pointer
, BOOL
*p
)
2265 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2266 FIXME("(%p)->(%p %p)\n", This
, that_pointer
, p
);
2270 static HRESULT WINAPI
MarkupPointer2_IsRightOf(IMarkupPointer2
*iface
, IMarkupPointer
*that_pointer
, BOOL
*p
)
2272 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2273 FIXME("(%p)->(%p %p)\n", This
, that_pointer
, p
);
2277 static HRESULT WINAPI
MarkupPointer2_IsRightOfOrEqualTo(IMarkupPointer2
*iface
, IMarkupPointer
*that_pointer
, BOOL
*p
)
2279 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2280 FIXME("(%p)->(%p %p)\n", This
, that_pointer
, p
);
2284 static HRESULT WINAPI
MarkupPointer2_IsEqualTo(IMarkupPointer2
*iface
, IMarkupPointer
*that_pointer
, BOOL
*p
)
2286 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2287 FIXME("(%p)->(%p %p)\n", This
, that_pointer
, p
);
2291 static HRESULT WINAPI
MarkupPointer2_MoveUnit(IMarkupPointer2
*iface
, MOVEUNIT_ACTION action
)
2293 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2294 FIXME("(%p)->(%u)\n", This
, action
);
2298 static HRESULT WINAPI
MarkupPointer2_FindText(IMarkupPointer2
*iface
, OLECHAR
*text
, DWORD flags
,
2299 IMarkupPointer
*end_match
, IMarkupPointer
*end_search
)
2301 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2302 FIXME("(%p)->(%s %lx %p %p)\n", This
, debugstr_w(text
), flags
, end_match
, end_search
);
2306 static HRESULT WINAPI
MarkupPointer2_IsAtWordBreak(IMarkupPointer2
*iface
, BOOL
*p
)
2308 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2309 FIXME("(%p)->(%p)\n", This
, p
);
2313 static HRESULT WINAPI
MarkupPointer2_GetMarkupPosition(IMarkupPointer2
*iface
, LONG
*p
)
2315 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2316 FIXME("(%p)->(%p)\n", This
, p
);
2320 static HRESULT WINAPI
MarkupPointer2_MoveToMarkupPosition(IMarkupPointer2
*iface
, IMarkupContainer
*container
, LONG mp
)
2322 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2323 FIXME("(%p)->(%p %ld)\n", This
, container
, mp
);
2327 static HRESULT WINAPI
MarkupPointer2_MoveUnitBounded(IMarkupPointer2
*iface
, MOVEUNIT_ACTION action
, IMarkupPointer
*boundary
)
2329 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2330 FIXME("(%p)->(%u %p)\n", This
, action
, boundary
);
2334 static HRESULT WINAPI
MarkupPointer2_IsInsideURL(IMarkupPointer2
*iface
, IMarkupPointer
*right
, BOOL
*p
)
2336 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2337 FIXME("(%p)->(%p %p)\n", This
, right
, p
);
2341 static HRESULT WINAPI
MarkupPointer2_MoveToContent(IMarkupPointer2
*iface
, IHTMLElement
*element
, BOOL at_start
)
2343 MarkupPointer
*This
= impl_from_IMarkupPointer2(iface
);
2344 FIXME("(%p)->(%p %x)\n", This
, element
, at_start
);
2348 static const IMarkupPointer2Vtbl MarkupPointer2Vtbl
= {
2349 MarkupPointer2_QueryInterface
,
2350 MarkupPointer2_AddRef
,
2351 MarkupPointer2_Release
,
2352 MarkupPointer2_OwningDoc
,
2353 MarkupPointer2_Gravity
,
2354 MarkupPointer2_SetGravity
,
2355 MarkupPointer2_Cling
,
2356 MarkupPointer2_SetCling
,
2357 MarkupPointer2_Unposition
,
2358 MarkupPointer2_IsPositioned
,
2359 MarkupPointer2_GetContainer
,
2360 MarkupPointer2_MoveAdjacentToElement
,
2361 MarkupPointer2_MoveToPointer
,
2362 MarkupPointer2_MoveToContainer
,
2363 MarkupPointer2_Left
,
2364 MarkupPointer2_Right
,
2365 MarkupPointer2_CurrentScope
,
2366 MarkupPointer2_IsLeftOf
,
2367 MarkupPointer2_IsLeftOfOrEqualTo
,
2368 MarkupPointer2_IsRightOf
,
2369 MarkupPointer2_IsRightOfOrEqualTo
,
2370 MarkupPointer2_IsEqualTo
,
2371 MarkupPointer2_MoveUnit
,
2372 MarkupPointer2_FindText
,
2373 MarkupPointer2_IsAtWordBreak
,
2374 MarkupPointer2_GetMarkupPosition
,
2375 MarkupPointer2_MoveToMarkupPosition
,
2376 MarkupPointer2_MoveUnitBounded
,
2377 MarkupPointer2_IsInsideURL
,
2378 MarkupPointer2_MoveToContent
2381 HRESULT
create_markup_pointer(IMarkupPointer
**ret
)
2383 MarkupPointer
*markup_pointer
;
2385 if(!(markup_pointer
= heap_alloc(sizeof(*markup_pointer
))))
2386 return E_OUTOFMEMORY
;
2388 markup_pointer
->IMarkupPointer2_iface
.lpVtbl
= &MarkupPointer2Vtbl
;
2389 markup_pointer
->ref
= 1;
2391 *ret
= (IMarkupPointer
*)&markup_pointer
->IMarkupPointer2_iface
;