2006-07-05 22:37:39 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2006 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
|
|
|
typedef struct {
|
2014-11-11 10:55:53 +01:00
|
|
|
DispatchEx dispex;
|
2010-12-06 23:32:17 +01:00
|
|
|
IHTMLSelectionObject IHTMLSelectionObject_iface;
|
2015-03-20 16:00:17 +01:00
|
|
|
IHTMLSelectionObject2 IHTMLSelectionObject2_iface;
|
2006-07-05 22:37:39 +02:00
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
nsISelection *nsselection;
|
2009-09-16 22:09:42 +02:00
|
|
|
HTMLDocumentNode *doc;
|
2007-08-15 19:17:49 +02:00
|
|
|
|
|
|
|
struct list entry;
|
2006-07-05 22:37:39 +02:00
|
|
|
} HTMLSelectionObject;
|
|
|
|
|
2010-12-06 23:32:17 +01:00
|
|
|
static inline HTMLSelectionObject *impl_from_IHTMLSelectionObject(IHTMLSelectionObject *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLSelectionObject, IHTMLSelectionObject_iface);
|
|
|
|
}
|
2006-07-05 22:37:39 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject_QueryInterface(IHTMLSelectionObject *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-06 23:32:17 +01:00
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface);
|
2006-07-05 22:37:39 +02:00
|
|
|
|
2014-11-11 10:55:53 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
|
2006-07-05 22:37:39 +02:00
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
2010-12-06 23:32:17 +01:00
|
|
|
*ppv = &This->IHTMLSelectionObject_iface;
|
2006-07-05 22:37:39 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
|
2010-12-06 23:32:17 +01:00
|
|
|
*ppv = &This->IHTMLSelectionObject_iface;
|
2006-07-05 22:37:39 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLSelectionObject, riid)) {
|
2010-12-06 23:32:17 +01:00
|
|
|
*ppv = &This->IHTMLSelectionObject_iface;
|
2015-03-20 16:00:17 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLSelectionObject2, riid)) {
|
|
|
|
*ppv = &This->IHTMLSelectionObject2_iface;
|
2014-11-11 10:55:53 +01:00
|
|
|
}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;
|
2006-07-05 22:37:39 +02:00
|
|
|
}
|
|
|
|
|
2014-11-11 10:55:53 +01:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
2006-07-05 22:37:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLSelectionObject_AddRef(IHTMLSelectionObject *iface)
|
|
|
|
{
|
2010-12-06 23:32:17 +01:00
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface);
|
2006-07-05 22:37:39 +02:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2006-07-05 22:37:39 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLSelectionObject_Release(IHTMLSelectionObject *iface)
|
|
|
|
{
|
2010-12-06 23:32:17 +01:00
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface);
|
2006-07-05 22:37:39 +02:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2006-07-05 22:37:39 +02:00
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
if(This->nsselection)
|
|
|
|
nsISelection_Release(This->nsselection);
|
2007-08-15 19:17:49 +02:00
|
|
|
if(This->doc)
|
|
|
|
list_remove(&This->entry);
|
2014-11-11 10:55:53 +01:00
|
|
|
release_dispex(&This->dispex);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(This);
|
2006-07-05 22:37:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject_GetTypeInfoCount(IHTMLSelectionObject *iface, UINT *pctinfo)
|
|
|
|
{
|
2010-12-06 23:32:17 +01:00
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface);
|
2014-11-11 10:55:53 +01:00
|
|
|
|
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
|
2006-07-05 22:37:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject_GetTypeInfo(IHTMLSelectionObject *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
2010-12-06 23:32:17 +01:00
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface);
|
2014-11-11 10:55:53 +01:00
|
|
|
|
|
|
|
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
|
2006-07-05 22:37:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject_GetIDsOfNames(IHTMLSelectionObject *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames,
|
|
|
|
LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
2010-12-06 23:32:17 +01:00
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface);
|
2014-11-11 10:55:53 +01:00
|
|
|
|
|
|
|
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames,
|
|
|
|
cNames, lcid, rgDispId);
|
2006-07-05 22:37:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject_Invoke(IHTMLSelectionObject *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
2010-12-06 23:32:17 +01:00
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface);
|
2014-11-11 10:55:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid,
|
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2006-07-05 22:37:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject_createRange(IHTMLSelectionObject *iface, IDispatch **range)
|
|
|
|
{
|
2010-12-06 23:32:17 +01:00
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface);
|
2009-09-16 22:11:43 +02:00
|
|
|
IHTMLTxtRange *range_obj = NULL;
|
2007-05-10 00:32:48 +02:00
|
|
|
nsIDOMRange *nsrange = NULL;
|
2009-09-16 22:11:43 +02:00
|
|
|
HRESULT hres;
|
2006-07-05 22:38:15 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, range);
|
|
|
|
|
2007-05-10 00:32:48 +02:00
|
|
|
if(This->nsselection) {
|
2013-01-18 14:05:59 +01:00
|
|
|
LONG nsrange_cnt = 0;
|
2007-05-10 00:32:48 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsISelection_GetRangeCount(This->nsselection, &nsrange_cnt);
|
2007-10-18 14:54:42 +02:00
|
|
|
if(!nsrange_cnt) {
|
|
|
|
nsIDOMHTMLElement *nsbody = NULL;
|
|
|
|
|
|
|
|
TRACE("nsrange_cnt = 0\n");
|
|
|
|
|
2009-10-21 21:27:42 +02:00
|
|
|
if(!This->doc->nsdoc) {
|
2008-10-08 20:27:52 +02:00
|
|
|
WARN("nsdoc is NULL\n");
|
|
|
|
return E_UNEXPECTED;
|
2007-10-18 14:54:42 +02:00
|
|
|
}
|
|
|
|
|
2009-10-21 21:27:42 +02:00
|
|
|
nsres = nsIDOMHTMLDocument_GetBody(This->doc->nsdoc, &nsbody);
|
2007-10-18 14:54:42 +02:00
|
|
|
if(NS_FAILED(nsres) || !nsbody) {
|
|
|
|
ERR("Could not get body: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsISelection_Collapse(This->nsselection, (nsIDOMNode*)nsbody, 0);
|
|
|
|
nsIDOMHTMLElement_Release(nsbody);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("Collapse failed: %08x\n", nsres);
|
|
|
|
}else if(nsrange_cnt > 1) {
|
2007-05-10 00:32:48 +02:00
|
|
|
FIXME("range_cnt = %d\n", nsrange_cnt);
|
2007-10-18 14:54:42 +02:00
|
|
|
}
|
2007-05-10 00:32:48 +02:00
|
|
|
|
|
|
|
nsres = nsISelection_GetRangeAt(This->nsselection, 0, &nsrange);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("GetRangeAt failed: %08x\n", nsres);
|
|
|
|
}
|
|
|
|
|
2009-09-16 22:11:43 +02:00
|
|
|
hres = HTMLTxtRange_Create(This->doc, nsrange, &range_obj);
|
|
|
|
|
2009-09-20 18:43:24 +02:00
|
|
|
if (nsrange) nsIDOMRange_Release(nsrange);
|
2009-09-16 22:11:43 +02:00
|
|
|
*range = (IDispatch*)range_obj;
|
|
|
|
return hres;
|
2006-07-05 22:37:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject_empty(IHTMLSelectionObject *iface)
|
|
|
|
{
|
2010-12-06 23:32:17 +01:00
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface);
|
2006-07-05 22:37:39 +02:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject_clear(IHTMLSelectionObject *iface)
|
|
|
|
{
|
2010-12-06 23:32:17 +01:00
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface);
|
2006-07-05 22:37:39 +02:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject_get_type(IHTMLSelectionObject *iface, BSTR *p)
|
|
|
|
{
|
2010-12-06 23:32:17 +01:00
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface);
|
2012-03-15 11:55:01 +01:00
|
|
|
cpp_bool collapsed = TRUE;
|
2006-07-05 22:38:04 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
if(This->nsselection)
|
2007-08-12 17:40:36 +02:00
|
|
|
nsISelection_GetIsCollapsed(This->nsselection, &collapsed);
|
2006-07-05 22:38:04 +02:00
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
*p = SysAllocString(collapsed ? L"None" : L"Text"); /* FIXME: control */
|
2007-08-12 17:40:36 +02:00
|
|
|
TRACE("ret %s\n", debugstr_w(*p));
|
2006-07-05 22:38:04 +02:00
|
|
|
return S_OK;
|
2006-07-05 22:37:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IHTMLSelectionObjectVtbl HTMLSelectionObjectVtbl = {
|
|
|
|
HTMLSelectionObject_QueryInterface,
|
|
|
|
HTMLSelectionObject_AddRef,
|
|
|
|
HTMLSelectionObject_Release,
|
|
|
|
HTMLSelectionObject_GetTypeInfoCount,
|
|
|
|
HTMLSelectionObject_GetTypeInfo,
|
|
|
|
HTMLSelectionObject_GetIDsOfNames,
|
|
|
|
HTMLSelectionObject_Invoke,
|
|
|
|
HTMLSelectionObject_createRange,
|
|
|
|
HTMLSelectionObject_empty,
|
|
|
|
HTMLSelectionObject_clear,
|
|
|
|
HTMLSelectionObject_get_type
|
|
|
|
};
|
|
|
|
|
2015-03-20 16:00:17 +01:00
|
|
|
static inline HTMLSelectionObject *impl_from_IHTMLSelectionObject2(IHTMLSelectionObject2 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLSelectionObject, IHTMLSelectionObject2_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject2_QueryInterface(IHTMLSelectionObject2 *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject2(iface);
|
|
|
|
|
|
|
|
return IHTMLSelectionObject_QueryInterface(&This->IHTMLSelectionObject_iface, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLSelectionObject2_AddRef(IHTMLSelectionObject2 *iface)
|
|
|
|
{
|
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject2(iface);
|
|
|
|
|
|
|
|
return IHTMLSelectionObject_AddRef(&This->IHTMLSelectionObject_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLSelectionObject2_Release(IHTMLSelectionObject2 *iface)
|
|
|
|
{
|
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject2(iface);
|
|
|
|
|
|
|
|
return IHTMLSelectionObject_Release(&This->IHTMLSelectionObject_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject2_GetTypeInfoCount(IHTMLSelectionObject2 *iface, UINT *pctinfo)
|
|
|
|
{
|
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject2(iface);
|
|
|
|
|
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject2_GetTypeInfo(IHTMLSelectionObject2 *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject2(iface);
|
|
|
|
|
|
|
|
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject2_GetIDsOfNames(IHTMLSelectionObject2 *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject2(iface);
|
|
|
|
|
|
|
|
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames,
|
|
|
|
cNames, lcid, rgDispId);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject2_Invoke(IHTMLSelectionObject2 *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
|
|
|
|
EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject2(iface);
|
|
|
|
|
|
|
|
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid,
|
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject2_createRangeCollection(IHTMLSelectionObject2 *iface, IDispatch **rangeCollection)
|
|
|
|
{
|
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject2(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, rangeCollection);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectionObject2_get_typeDetail(IHTMLSelectionObject2 *iface, BSTR *p)
|
|
|
|
{
|
|
|
|
HTMLSelectionObject *This = impl_from_IHTMLSelectionObject2(iface);
|
2017-01-25 18:13:00 +01:00
|
|
|
|
|
|
|
FIXME("(%p)->(%p) semi-stub\n", This, p);
|
|
|
|
|
|
|
|
/* FIXME: We should try to use ISelectionServicesListener::GetTypeDetail here. */
|
2020-11-24 23:29:19 +01:00
|
|
|
*p = SysAllocString(L"undefined");
|
2017-01-25 18:13:00 +01:00
|
|
|
return *p ? S_OK : E_OUTOFMEMORY;
|
2015-03-20 16:00:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IHTMLSelectionObject2Vtbl HTMLSelectionObject2Vtbl = {
|
|
|
|
HTMLSelectionObject2_QueryInterface,
|
|
|
|
HTMLSelectionObject2_AddRef,
|
|
|
|
HTMLSelectionObject2_Release,
|
|
|
|
HTMLSelectionObject2_GetTypeInfoCount,
|
|
|
|
HTMLSelectionObject2_GetTypeInfo,
|
|
|
|
HTMLSelectionObject2_GetIDsOfNames,
|
|
|
|
HTMLSelectionObject2_Invoke,
|
|
|
|
HTMLSelectionObject2_createRangeCollection,
|
|
|
|
HTMLSelectionObject2_get_typeDetail
|
|
|
|
};
|
|
|
|
|
2014-11-11 10:55:53 +01:00
|
|
|
static const tid_t HTMLSelectionObject_iface_tids[] = {
|
|
|
|
IHTMLSelectionObject_tid,
|
2015-03-20 16:00:17 +01:00
|
|
|
IHTMLSelectionObject2_tid,
|
2014-11-11 10:55:53 +01:00
|
|
|
0
|
|
|
|
};
|
|
|
|
static dispex_static_data_t HTMLSelectionObject_dispex = {
|
|
|
|
NULL,
|
2015-03-20 16:00:17 +01:00
|
|
|
IHTMLSelectionObject_tid, /* FIXME: We have a test for that, but it doesn't expose IHTMLSelectionObject2 iface. */
|
2014-11-11 10:55:53 +01:00
|
|
|
HTMLSelectionObject_iface_tids
|
|
|
|
};
|
|
|
|
|
2009-09-16 22:09:42 +02:00
|
|
|
HRESULT HTMLSelectionObject_Create(HTMLDocumentNode *doc, nsISelection *nsselection, IHTMLSelectionObject **ret)
|
2006-07-05 22:37:39 +02:00
|
|
|
{
|
2009-09-16 22:09:42 +02:00
|
|
|
HTMLSelectionObject *selection;
|
2006-07-05 22:37:39 +02:00
|
|
|
|
2009-09-16 22:09:42 +02:00
|
|
|
selection = heap_alloc(sizeof(HTMLSelectionObject));
|
|
|
|
if(!selection)
|
|
|
|
return E_OUTOFMEMORY;
|
2006-07-05 22:37:39 +02:00
|
|
|
|
2021-03-16 19:57:45 +01:00
|
|
|
init_dispatch(&selection->dispex, (IUnknown*)&selection->IHTMLSelectionObject_iface,
|
|
|
|
&HTMLSelectionObject_dispex, dispex_compat_mode(&doc->node.event_target.dispex));
|
2014-11-11 10:55:53 +01:00
|
|
|
|
2010-12-06 23:32:17 +01:00
|
|
|
selection->IHTMLSelectionObject_iface.lpVtbl = &HTMLSelectionObjectVtbl;
|
2015-03-20 16:00:17 +01:00
|
|
|
selection->IHTMLSelectionObject2_iface.lpVtbl = &HTMLSelectionObject2Vtbl;
|
2009-09-16 22:09:42 +02:00
|
|
|
selection->ref = 1;
|
|
|
|
selection->nsselection = nsselection; /* We shouldn't call AddRef here */
|
2007-08-15 19:17:49 +02:00
|
|
|
|
2009-09-16 22:09:42 +02:00
|
|
|
selection->doc = doc;
|
|
|
|
list_add_head(&doc->selection_list, &selection->entry);
|
|
|
|
|
2010-12-06 23:32:17 +01:00
|
|
|
*ret = &selection->IHTMLSelectionObject_iface;
|
2009-09-16 22:09:42 +02:00
|
|
|
return S_OK;
|
2006-07-05 22:37:39 +02:00
|
|
|
}
|
2007-08-15 19:17:49 +02:00
|
|
|
|
2009-09-16 22:09:42 +02:00
|
|
|
void detach_selection(HTMLDocumentNode *This)
|
2007-08-15 19:17:49 +02:00
|
|
|
{
|
2019-03-21 14:40:44 +01:00
|
|
|
HTMLSelectionObject *iter, *next;
|
2007-08-15 19:17:49 +02:00
|
|
|
|
2019-03-21 14:40:44 +01:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(iter, next, &This->selection_list, HTMLSelectionObject, entry) {
|
2007-08-15 19:17:49 +02:00
|
|
|
iter->doc = NULL;
|
2019-03-21 14:40:44 +01:00
|
|
|
list_remove(&iter->entry);
|
2007-08-15 19:17:49 +02:00
|
|
|
}
|
|
|
|
}
|