mshtml: Moved selection_list to HTMLDocumentNode object.

This commit is contained in:
Jacek Caban 2009-09-16 22:09:42 +02:00 committed by Alexandre Julliard
parent b827996515
commit 068489fb94
3 changed files with 26 additions and 20 deletions

View File

@ -428,8 +428,7 @@ static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSel
return E_FAIL;
}
*p = HTMLSelectionObject_Create(This, nsselection);
return S_OK;
return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
}
static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
@ -1741,7 +1740,6 @@ static void init_doc(HTMLDocument *doc, const htmldoc_vtbl_t *vtbl)
doc->readystate = READYSTATE_UNINITIALIZED;
list_init(&doc->bindings);
list_init(&doc->selection_list);
list_init(&doc->range_list);
HTMLDocument_HTMLDocument3_Init(doc);
@ -1787,7 +1785,6 @@ static void destroy_htmldoc(HTMLDocument *This)
release_event_target(This->event_target);
heap_free(This->mime);
detach_selection(This);
detach_ranges(This);
release_nodes(This);
release_dispex(&This->dispex);
@ -1825,6 +1822,7 @@ static ULONG HTMLDocumentNode_Release(HTMLDocument *base)
TRACE("(%p) ref = %u\n", This, ref);
if(!ref) {
detach_selection(This);
destroy_htmldoc(&This->basedoc);
heap_free(This);
}
@ -1859,6 +1857,8 @@ HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_ob
doc->basedoc.window = window;
list_init(&doc->selection_list);
*ret = doc;
return S_OK;
}

View File

@ -320,7 +320,6 @@ struct HTMLDocument {
ConnectionPoint cp_htmldocevents2;
ConnectionPoint cp_propnotif;
struct list selection_list;
struct list range_list;
HTMLDOMNode *nodes;
@ -345,6 +344,8 @@ struct HTMLDocumentNode {
HTMLDocument basedoc;
LONG ref;
struct list selection_list;
};
struct HTMLDocumentObj {
@ -635,13 +636,13 @@ HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
IMoniker *get_channelbsc_mon(nsChannelBSC*);
IHTMLSelectionObject *HTMLSelectionObject_Create(HTMLDocument*,nsISelection*);
HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**);
IHTMLTxtRange *HTMLTxtRange_Create(HTMLDocument*,nsIDOMRange*);
IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
void detach_selection(HTMLDocument*);
void detach_selection(HTMLDocumentNode*);
void detach_ranges(HTMLDocument*);
HRESULT get_node_text(HTMLDOMNode*,BSTR*);

View File

@ -38,7 +38,7 @@ typedef struct {
LONG ref;
nsISelection *nsselection;
HTMLDocument *doc;
HTMLDocumentNode *doc;
struct list entry;
} HTMLSelectionObject;
@ -154,12 +154,12 @@ static HRESULT WINAPI HTMLSelectionObject_createRange(IHTMLSelectionObject *ifac
TRACE("nsrange_cnt = 0\n");
if(!This->doc->nsdoc) {
if(!This->doc->basedoc.nsdoc) {
WARN("nsdoc is NULL\n");
return E_UNEXPECTED;
}
nsres = nsIDOMHTMLDocument_GetBody(This->doc->nsdoc, &nsbody);
nsres = nsIDOMHTMLDocument_GetBody(This->doc->basedoc.nsdoc, &nsbody);
if(NS_FAILED(nsres) || !nsbody) {
ERR("Could not get body: %08x\n", nsres);
return E_FAIL;
@ -178,7 +178,7 @@ static HRESULT WINAPI HTMLSelectionObject_createRange(IHTMLSelectionObject *ifac
ERR("GetRangeAt failed: %08x\n", nsres);
}
*range = (IDispatch*)HTMLTxtRange_Create(This->doc, nsrange);
*range = (IDispatch*)HTMLTxtRange_Create(&This->doc->basedoc, nsrange);
return S_OK;
}
@ -230,21 +230,26 @@ static const IHTMLSelectionObjectVtbl HTMLSelectionObjectVtbl = {
HTMLSelectionObject_get_type
};
IHTMLSelectionObject *HTMLSelectionObject_Create(HTMLDocument *doc, nsISelection *nsselection)
HRESULT HTMLSelectionObject_Create(HTMLDocumentNode *doc, nsISelection *nsselection, IHTMLSelectionObject **ret)
{
HTMLSelectionObject *ret = heap_alloc(sizeof(HTMLSelectionObject));
HTMLSelectionObject *selection;
ret->lpHTMLSelectionObjectVtbl = &HTMLSelectionObjectVtbl;
ret->ref = 1;
ret->nsselection = nsselection; /* We shouldn't call AddRef here */
selection = heap_alloc(sizeof(HTMLSelectionObject));
if(!selection)
return E_OUTOFMEMORY;
ret->doc = doc;
list_add_head(&doc->selection_list, &ret->entry);
selection->lpHTMLSelectionObjectVtbl = &HTMLSelectionObjectVtbl;
selection->ref = 1;
selection->nsselection = nsselection; /* We shouldn't call AddRef here */
return HTMLSELOBJ(ret);
selection->doc = doc;
list_add_head(&doc->selection_list, &selection->entry);
*ret = HTMLSELOBJ(selection);
return S_OK;
}
void detach_selection(HTMLDocument *This)
void detach_selection(HTMLDocumentNode *This)
{
HTMLSelectionObject *iter;