Commit c5d3ff58 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mshtml: Add IHTMLDOMRange stub.

parent daf62df9
......@@ -55,13 +55,13 @@ C_SRCS = \
persist.c \
pluginhost.c \
protocol.c \
range.c \
script.c \
secmgr.c \
selection.c \
service.c \
svg.c \
task.c \
txtrange.c \
view.c \
xmlhttprequest.c
......
......@@ -5223,8 +5223,22 @@ static HRESULT WINAPI DocumentRange_Invoke(IDocumentRange *iface, DISPID dispIdM
static HRESULT WINAPI DocumentRange_createRange(IDocumentRange *iface, IHTMLDOMRange **p)
{
HTMLDocument *This = impl_from_IDocumentRange(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
nsIDOMRange *nsrange;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p);
if(!This->doc_node->nsdoc) {
WARN("NULL nsdoc\n");
return E_UNEXPECTED;
}
if(NS_FAILED(nsIDOMHTMLDocument_CreateRange(This->doc_node->nsdoc, &nsrange)))
return E_FAIL;
hres = HTMLDOMRange_Create(nsrange, p);
nsIDOMRange_Release(nsrange);
return hres;
}
static const IDocumentRangeVtbl DocumentRangeVtbl = {
......
......@@ -95,6 +95,7 @@ typedef struct EventTarget EventTarget;
XDIID(DispHTMLDocument) \
XDIID(DispHTMLDOMAttribute) \
XDIID(DispHTMLDOMImplementation) \
XDIID(DispHTMLDOMRange) \
XDIID(DispHTMLDOMTextNode) \
XDIID(DispHTMLElementCollection) \
XDIID(DispHTMLEmbed) \
......@@ -178,6 +179,7 @@ typedef struct EventTarget EventTarget;
XIID(IHTMLDOMNode) \
XIID(IHTMLDOMNode2) \
XIID(IHTMLDOMNode3) \
XIID(IHTMLDOMRange) \
XIID(IHTMLDOMTextNode) \
XIID(IHTMLDOMTextNode2) \
XIID(IHTMLElement) \
......@@ -1008,6 +1010,7 @@ HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectio
HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**) DECLSPEC_HIDDEN;
IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*) DECLSPEC_HIDDEN;
IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*) DECLSPEC_HIDDEN;
HRESULT HTMLDOMRange_Create(nsIDOMRange*,IHTMLDOMRange**) DECLSPEC_HIDDEN;
void detach_document_node(HTMLDocumentNode*) DECLSPEC_HIDDEN;
void detach_selection(HTMLDocumentNode*) DECLSPEC_HIDDEN;
......
......@@ -50,6 +50,15 @@ typedef struct {
} HTMLTxtRange;
typedef struct {
DispatchEx dispex;
IHTMLDOMRange IHTMLDOMRange_iface;
LONG ref;
nsIDOMRange *nsrange;
} HTMLDOMRange;
typedef struct {
WCHAR *buf;
DWORD len;
DWORD size;
......@@ -1758,6 +1767,346 @@ HRESULT HTMLTxtRange_Create(HTMLDocumentNode *doc, nsIDOMRange *nsrange, IHTMLTx
return S_OK;
}
static inline HTMLDOMRange *impl_from_IHTMLDOMRange(IHTMLDOMRange *iface)
{
return CONTAINING_RECORD(iface, HTMLDOMRange, IHTMLDOMRange_iface);
}
static HRESULT WINAPI HTMLDOMRange_QueryInterface(IHTMLDOMRange *iface, REFIID riid, void **ppv)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
if(IsEqualGUID(&IID_IUnknown, riid)) {
*ppv = &This->IHTMLDOMRange_iface;
}else if(IsEqualGUID(&IID_IHTMLDOMRange, riid)) {
*ppv = &This->IHTMLDOMRange_iface;
}else if(dispex_query_interface(&This->dispex, riid, ppv)) {
return *ppv ? S_OK : E_NOINTERFACE;
}else {
*ppv = NULL;
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI HTMLDOMRange_AddRef(IHTMLDOMRange *iface)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
}
static ULONG WINAPI HTMLDOMRange_Release(IHTMLDOMRange *iface)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
if(!ref) {
if(This->nsrange)
nsIDOMRange_Release(This->nsrange);
release_dispex(&This->dispex);
heap_free(This);
}
return ref;
}
static HRESULT WINAPI HTMLDOMRange_GetTypeInfoCount(IHTMLDOMRange *iface, UINT *pctinfo)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
}
static HRESULT WINAPI HTMLDOMRange_GetTypeInfo(IHTMLDOMRange *iface, UINT iTInfo,
LCID lcid, ITypeInfo **ppTInfo)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
}
static HRESULT WINAPI HTMLDOMRange_GetIDsOfNames(IHTMLDOMRange *iface, REFIID riid,
LPOLESTR *rgszNames, UINT cNames,
LCID lcid, DISPID *rgDispId)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames,
cNames, lcid, rgDispId);
}
static HRESULT WINAPI HTMLDOMRange_Invoke(IHTMLDOMRange *iface, DISPID dispIdMember,
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid,
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
}
static HRESULT WINAPI HTMLDOMRange_get_startContainer(IHTMLDOMRange *iface, IHTMLDOMNode **p)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_get_startOffset(IHTMLDOMRange *iface, LONG *p)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_get_endContainer(IHTMLDOMRange *iface, IHTMLDOMNode **p)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_get_endOffset(IHTMLDOMRange *iface, LONG *p)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_get_collapsed(IHTMLDOMRange *iface, VARIANT_BOOL *p)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_get_commonAncestorContainer(IHTMLDOMRange *iface, IHTMLDOMNode **p)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_setStart(IHTMLDOMRange *iface, IDispatch *node, LONG offset)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p, %d)\n", This, node, offset);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_setEnd(IHTMLDOMRange *iface, IDispatch *node, LONG offset)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p, %d)\n", This, node, offset);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_setStartBefore(IHTMLDOMRange *iface, IDispatch *node)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, node);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_setStartAfter(IHTMLDOMRange *iface, IDispatch *node)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, node);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_setEndBefore(IHTMLDOMRange *iface, IDispatch *node)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, node);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_setEndAfter(IHTMLDOMRange *iface, IDispatch *node)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, node);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_collapse(IHTMLDOMRange *iface, VARIANT_BOOL tostart)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%x)\n", This, tostart);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_selectNode(IHTMLDOMRange *iface, IDispatch *node)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, node);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_selectNodeContents(IHTMLDOMRange *iface, IDispatch *node)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, node);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_compareBoundaryPoints(IHTMLDOMRange *iface, short how,
IDispatch *src_range, LONG *result)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%x, %p, %p)\n", This, how, src_range, result);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_deleteContents(IHTMLDOMRange *iface)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_extractContents(IHTMLDOMRange *iface, IDispatch **p)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_cloneContents(IHTMLDOMRange *iface, IDispatch **p)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_insertNode(IHTMLDOMRange *iface, IDispatch *node)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, node);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_surroundContents(IHTMLDOMRange *iface, IDispatch *parent)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, parent);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_cloneRange(IHTMLDOMRange *iface, IHTMLDOMRange **p)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_toString(IHTMLDOMRange *iface, BSTR *p)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_detach(IHTMLDOMRange *iface)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_getClientRects(IHTMLDOMRange *iface, IHTMLRectCollection **p)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static HRESULT WINAPI HTMLDOMRange_getBoundingClientRect(IHTMLDOMRange *iface, IHTMLRect **p)
{
HTMLDOMRange *This = impl_from_IHTMLDOMRange(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
}
static const IHTMLDOMRangeVtbl HTMLDOMRangeVtbl = {
HTMLDOMRange_QueryInterface,
HTMLDOMRange_AddRef,
HTMLDOMRange_Release,
HTMLDOMRange_GetTypeInfoCount,
HTMLDOMRange_GetTypeInfo,
HTMLDOMRange_GetIDsOfNames,
HTMLDOMRange_Invoke,
HTMLDOMRange_get_startContainer,
HTMLDOMRange_get_startOffset,
HTMLDOMRange_get_endContainer,
HTMLDOMRange_get_endOffset,
HTMLDOMRange_get_collapsed,
HTMLDOMRange_get_commonAncestorContainer,
HTMLDOMRange_setStart,
HTMLDOMRange_setEnd,
HTMLDOMRange_setStartBefore,
HTMLDOMRange_setStartAfter,
HTMLDOMRange_setEndBefore,
HTMLDOMRange_setEndAfter,
HTMLDOMRange_collapse,
HTMLDOMRange_selectNode,
HTMLDOMRange_selectNodeContents,
HTMLDOMRange_compareBoundaryPoints,
HTMLDOMRange_deleteContents,
HTMLDOMRange_extractContents,
HTMLDOMRange_cloneContents,
HTMLDOMRange_insertNode,
HTMLDOMRange_surroundContents,
HTMLDOMRange_cloneRange,
HTMLDOMRange_toString,
HTMLDOMRange_detach,
HTMLDOMRange_getClientRects,
HTMLDOMRange_getBoundingClientRect,
};
static const tid_t HTMLDOMRange_iface_tids[] = {
IHTMLDOMRange_tid,
0
};
static dispex_static_data_t HTMLDOMRange_dispex = {
NULL,
DispHTMLDOMRange_tid,
HTMLDOMRange_iface_tids
};
HRESULT HTMLDOMRange_Create(nsIDOMRange *nsrange, IHTMLDOMRange **p)
{
HTMLDOMRange *ret;
ret = heap_alloc(sizeof(*ret));
if(!ret)
return E_OUTOFMEMORY;
init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLDOMRange_iface, &HTMLDOMRange_dispex);
ret->IHTMLDOMRange_iface.lpVtbl = &HTMLDOMRangeVtbl;
ret->ref = 1;
if(nsrange)
nsIDOMRange_AddRef(nsrange);
ret->nsrange = nsrange;
*p = &ret->IHTMLDOMRange_iface;
return S_OK;
}
void detach_ranges(HTMLDocumentNode *This)
{
HTMLTxtRange *iter, *next;
......
......@@ -5938,6 +5938,31 @@ static void test_txtrange(IHTMLDocument2 *doc)
IHTMLTxtRange_Release(range);
}
static void test_range(IHTMLDocument2 *doc)
{
if(is_ie9plus) {
IDocumentRange *doc_range;
IHTMLDOMRange *range;
HRESULT hres;
hres = IHTMLDocument2_QueryInterface(doc, &IID_IDocumentRange, (void **)&doc_range);
ok(hres == S_OK, "Failed to get IDocumentRange: %08x\n", hres);
if (FAILED(hres))
return;
hres = IDocumentRange_createRange(doc_range, &range);
ok(hres == S_OK, "Failed to create range, %08x\n", hres);
test_disp((IUnknown *)range, &DIID_DispHTMLDOMRange, NULL, NULL);
IHTMLDOMRange_Release(range);
IDocumentRange_Release(doc_range);
}
test_txtrange(doc);
}
#define test_compatmode(a,b) _test_compatmode(__LINE__,a,b)
static void _test_compatmode(unsigned line, IHTMLDocument2 *doc2, const char *excompat)
{
......@@ -11060,7 +11085,7 @@ START_TEST(dom)
run_domtest(doc_str1, test_doc_elem);
run_domtest(doc_str1, test_get_set_attr);
run_domtest(doc_blank, test_txtrange);
run_domtest(doc_blank, test_range);
if (winetest_interactive || ! is_ie_hardened()) {
run_domtest(elem_test_str, test_elems);
run_domtest(elem_test2_str, test_elems2);
......
......@@ -420,6 +420,7 @@ interface ILineInfo;
interface IMarkupPointer;
interface IMarkupContainer;
interface ISVGSVGElement;
interface IHTMLDOMRange;
/*****************************************************************************
* IHTMLCSSStyleDeclaration interface
......@@ -12205,6 +12206,93 @@ interface IHTMLTxtRange : IDispatch
[retval, out] VARIANT_BOOL *pfRet);
}
[
hidden,
uuid(3050f5a3-98b5-11cf-bb82-00aa00bdce0b)
]
dispinterface DispHTMLDOMRange
{
properties:
methods:
[propget, id(DISPID_IHTMLDOMRANGE_STARTCONTAINER)]
IHTMLDOMNode *startContainer();
[propget, id(DISPID_IHTMLDOMRANGE_STARTOFFSET)]
long startOffset();
[propget, id(DISPID_IHTMLDOMRANGE_ENDCONTAINER)]
IHTMLDOMNode *endContainer();
[propget, id(DISPID_IHTMLDOMRANGE_ENDOFFSET)]
long endOffset();
[propget, id(DISPID_IHTMLDOMRANGE_COLLAPSED)]
VARIANT_BOOL collapsed();
[propget, id(DISPID_IHTMLDOMRANGE_COMMONANCESTORCONTAINER)]
IHTMLDOMNode *commonAncestorContainer();
[id(DISPID_IHTMLDOMRANGE_SETSTART)]
void setStart([in] IDispatch *node ,[in] long offset);
[id(DISPID_IHTMLDOMRANGE_SETEND)]
void setEnd([in] IDispatch *node, [in] long offset);
[id(DISPID_IHTMLDOMRANGE_SETSTARTBEFORE)]
void setStartBefore([in] IDispatch *node);
[id(DISPID_IHTMLDOMRANGE_SETSTARTAFTER)]
void setStartAfter([in] IDispatch *node);
[id(DISPID_IHTMLDOMRANGE_SETENDBEFORE)]
void setEndBefore([in] IDispatch *node);
[id(DISPID_IHTMLDOMRANGE_SETENDAFTER)]
void setEndAfter([in] IDispatch *node);
[id(DISPID_IHTMLDOMRANGE_COLLAPSE)]
void collapse([in] VARIANT_BOOL tostart);
[id(DISPID_IHTMLDOMRANGE_SELECTNODE)]
void selectNode([in] IDispatch *node);
[id(DISPID_IHTMLDOMRANGE_SELECTNODECONTENTS)]
void selectNodeContents([in] IDispatch *node);
[id(DISPID_IHTMLDOMRANGE_COMPAREBOUNDARYPOINTS)]
long compareBoundaryPoints([in] short how, [in] IDispatch *src_range);
[id(DISPID_IHTMLDOMRANGE_DELETECONTENTS)]
void deleteContents();
[id(DISPID_IHTMLDOMRANGE_EXTRACTCONTENTS)]
IDispatch *extractContents();
[id(DISPID_IHTMLDOMRANGE_CLONECONTENTS)]
IDispatch *cloneContents();
[id(DISPID_IHTMLDOMRANGE_INSERTNODE)]
void insertNode([in] IDispatch *node);
[id(DISPID_IHTMLDOMRANGE_SURROUNDCONTENTS)]
void surroundContents([in] IDispatch *parent);
[id(DISPID_IHTMLDOMRANGE_CLONERANGE)]
IHTMLDOMRange *cloneRange();
[id(DISPID_IHTMLDOMRANGE_TOSTRING)]
BSTR toString();
[id(DISPID_IHTMLDOMRANGE_DETACH)]
void detach();
[id(DISPID_IHTMLDOMRANGE_GETCLIENTRECTS)]
IHTMLRectCollection *getClientRects();
[id(DISPID_IHTMLDOMRANGE_GETBOUNDINGCLIENTRECT)]
IHTMLRect *getBoundingClientRect();
}
/*****************************************************************************
* IHTMLDOMRange interface
*/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment