mshtml: Store the nsIEditor interface in the NSContainer object for use in implementing editor commands.
This commit is contained in:
parent
97f389451d
commit
006d9f940d
|
@ -608,7 +608,7 @@ void handle_edit_event(HTMLDocument *This, nsIDOMEvent *event)
|
|||
|
||||
void handle_edit_load(HTMLDocument *This)
|
||||
{
|
||||
This->nscontainer->editor_controller = get_editor_controller(This->nscontainer);
|
||||
get_editor_controller(This->nscontainer);
|
||||
|
||||
if(This->ui_active) {
|
||||
OLECHAR wszHTMLDocument[30];
|
||||
|
|
|
@ -182,6 +182,7 @@ struct NSContainer {
|
|||
nsIBaseWindow *window;
|
||||
nsIWebBrowserFocus *focus;
|
||||
|
||||
nsIEditor *editor;
|
||||
nsIController *editor_controller;
|
||||
|
||||
LONG ref;
|
||||
|
@ -396,7 +397,7 @@ nsICommandParams *create_nscommand_params(void);
|
|||
nsIMutableArray *create_nsarray(void);
|
||||
nsIWritableVariant *create_nsvariant(void);
|
||||
void nsnode_to_nsstring(nsIDOMNode*,nsAString*);
|
||||
nsIController *get_editor_controller(NSContainer*);
|
||||
void get_editor_controller(NSContainer*);
|
||||
void init_nsevents(NSContainer*);
|
||||
|
||||
BSCallback *create_bscallback(IMoniker*);
|
||||
|
|
|
@ -629,20 +629,28 @@ void nsnode_to_nsstring(nsIDOMNode *nsdoc, nsAString *str)
|
|||
nsIContentSerializer_Release(serializer);
|
||||
}
|
||||
|
||||
nsIController *get_editor_controller(NSContainer *This)
|
||||
void get_editor_controller(NSContainer *This)
|
||||
{
|
||||
nsIController *ret = NULL;
|
||||
nsIEditingSession *editing_session = NULL;
|
||||
nsIInterfaceRequestor *iface_req;
|
||||
nsIControllerContext *ctrlctx;
|
||||
nsIEditor *editor = NULL;
|
||||
nsresult nsres;
|
||||
|
||||
if(This->editor) {
|
||||
nsIEditor_Release(This->editor);
|
||||
This->editor = NULL;
|
||||
}
|
||||
|
||||
if(This->editor_controller) {
|
||||
nsIController_Release(This->editor_controller);
|
||||
This->editor_controller = NULL;
|
||||
}
|
||||
|
||||
nsres = nsIWebBrowser_QueryInterface(This->webbrowser,
|
||||
&IID_nsIInterfaceRequestor, (void**)&iface_req);
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("Could not get nsIInterfaceRequestor: %08x\n", nsres);
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
nsres = nsIInterfaceRequestor_GetInterface(iface_req, &IID_nsIEditingSession,
|
||||
|
@ -650,35 +658,31 @@ nsIController *get_editor_controller(NSContainer *This)
|
|||
nsIInterfaceRequestor_Release(iface_req);
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("Could not get nsIEditingSession: %08x\n", nsres);
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
nsres = nsIEditingSession_GetEditorForWindow(editing_session,
|
||||
This->doc->window->nswindow, &editor);
|
||||
This->doc->window->nswindow, &This->editor);
|
||||
nsIEditingSession_Release(editing_session);
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("Could not get editor: %08x\n", nsres);
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr,
|
||||
NS_EDITORCONTROLLER_CONTRACTID, NULL, &IID_nsIControllerContext, (void**)&ctrlctx);
|
||||
if(NS_SUCCEEDED(nsres)) {
|
||||
nsres = nsIControllerContext_SetCommandContext(ctrlctx, editor);
|
||||
nsres = nsIControllerContext_SetCommandContext(ctrlctx, (nsISupports *)This->editor);
|
||||
if(NS_FAILED(nsres))
|
||||
ERR("SetCommandContext failed: %08x\n", nsres);
|
||||
nsres = nsIControllerContext_QueryInterface(ctrlctx, &IID_nsIController,
|
||||
(void**)&ret);
|
||||
(void**)&This->editor_controller);
|
||||
nsIControllerContext_Release(ctrlctx);
|
||||
if(NS_FAILED(nsres))
|
||||
ERR("Could not get nsIController interface: %08x\n", nsres);
|
||||
}else {
|
||||
ERR("Could not create edit controller: %08x\n", nsres);
|
||||
}
|
||||
|
||||
nsISupports_Release(editor);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void set_ns_editmode(NSContainer *This)
|
||||
|
@ -1513,6 +1517,7 @@ NSContainer *NSContainer_Create(HTMLDocument *doc, NSContainer *parent)
|
|||
ret->bscallback = NULL;
|
||||
ret->content_listener = NULL;
|
||||
ret->editor_controller = NULL;
|
||||
ret->editor = NULL;
|
||||
|
||||
if(parent)
|
||||
nsIWebBrowserChrome_AddRef(NSWBCHROME(parent));
|
||||
|
@ -1627,6 +1632,11 @@ void NSContainer_Release(NSContainer *This)
|
|||
This->editor_controller = NULL;
|
||||
}
|
||||
|
||||
if(This->editor) {
|
||||
nsIEditor_Release(This->editor);
|
||||
This->editor = NULL;
|
||||
}
|
||||
|
||||
if(This->content_listener) {
|
||||
nsIURIContentListener_Release(This->content_listener);
|
||||
This->content_listener = NULL;
|
||||
|
|
|
@ -72,6 +72,15 @@ interface nsILoadGroup;
|
|||
interface nsIDOMNode;
|
||||
interface nsIDOMDocument;
|
||||
interface nsIDOMEvent;
|
||||
interface nsIEditor;
|
||||
interface nsISelectionController;
|
||||
interface nsITransactionManager;
|
||||
interface nsITransaction;
|
||||
interface nsIInlineSpellChecker;
|
||||
interface nsIOutputStream;
|
||||
interface nsIEditorObserver;
|
||||
interface nsIEditActionListener;
|
||||
interface nsIDocumentStateListener;
|
||||
|
||||
interface IMoniker;
|
||||
|
||||
|
@ -105,7 +114,6 @@ typedef nsISupports nsIDOMEntityReference;
|
|||
typedef nsISupports nsIDOMHTMLFormElement;
|
||||
typedef nsISupports nsIDOMHTMLOptionsCollection;
|
||||
typedef nsISupports nsIDOMHTMLCollection;
|
||||
typedef nsISupports nsIEditor;
|
||||
typedef nsISupports nsIWebProgressListener;
|
||||
typedef nsISupports nsIDOMCSSValue;
|
||||
typedef nsISupports nsIDOMCSSRule;
|
||||
|
@ -113,6 +121,8 @@ typedef nsISupports nsIPrintSession;
|
|||
typedef nsISupports nsIControllerCommandTable;
|
||||
typedef nsISupports nsIPrincipal;
|
||||
typedef nsISupports nsIAtom;
|
||||
typedef nsISupports nsISupportsArray;
|
||||
typedef nsISupports nsIContentFilter;
|
||||
|
||||
[
|
||||
object,
|
||||
|
@ -1884,6 +1894,88 @@ interface nsIScriptContainer : nsISupports
|
|||
nsresult DropScriptObject(void *aObject);
|
||||
}
|
||||
|
||||
[
|
||||
object,
|
||||
uuid(D4882FFB-E927-408b-96BE-D4391B456FA9)
|
||||
]
|
||||
interface nsIEditor : nsISupports
|
||||
{
|
||||
typedef void *nsIPresShellPtr;
|
||||
typedef void *nsIContentPtr;
|
||||
|
||||
nsresult GetSelection([out] nsISelection *_retval);
|
||||
nsresult Init([in] nsIDOMDocument *doc, [in] nsIPresShellPtr shell, [in] nsIContentPtr aRoot, [in] nsISelectionController *aSelCon, [in] PRUint32 aFlags);
|
||||
nsresult SetAttributeOrEquivalent([in] nsIDOMElement *element, [in] const nsAString *sourceAttrName, [in] const nsAString *sourceAttrValue, [in] PRBool aSuppressTransaction);
|
||||
nsresult RemoveAttributeOrEquivalent([in] nsIDOMElement *element, [in] const nsAString *sourceAttrName, [in] PRBool aSuppressTransaction);
|
||||
nsresult PostCreate();
|
||||
nsresult PreDestroy();
|
||||
nsresult GetFlags([out] PRUint32 *_retval);
|
||||
nsresult SetFlags([in] PRUint32 val);
|
||||
nsresult GetContentsMIMEType([out] char **_retval);
|
||||
nsresult SetContentsMIMEType([in] const char *val);
|
||||
nsresult GetIsDocumentEditable([out] PRBool *_retval);
|
||||
nsresult GetDocument([out] nsIDOMDocument **_retval);
|
||||
nsresult GetRootElement([out] nsIDOMElement **_retval);
|
||||
nsresult GetSelectionController([out] nsISelectionController **_retval);
|
||||
nsresult DeleteSelection([in] PRInt16 action);
|
||||
nsresult GetDocumentIsEmpty([out] PRBool *_retval);
|
||||
nsresult GetDocumentModified([out] PRBool *_retval);
|
||||
nsresult GetDocumentCharacterSet([out] nsACString *_retval);
|
||||
nsresult SetDocumentCharacterSet([in] const nsACString *val);
|
||||
nsresult ResetModificationCount();
|
||||
nsresult GetModificationCount([out] PRInt32 *_retval);
|
||||
nsresult IncrementModificationCount([in] long aModCount);
|
||||
nsresult GetTransactionManager([out] nsITransactionManager **_retval);
|
||||
nsresult DoTransaction([in] nsITransaction *txn);
|
||||
nsresult EnableUndo([in] PRBool enable);
|
||||
nsresult Undo([in] PRUint32 count);
|
||||
nsresult CanUndo([out] PRBool *isEnabled, [out] PRBool *canUndo);
|
||||
nsresult Redo([in] PRUint32 count);
|
||||
nsresult CanRedo([out] PRBool *isEnabled, [out] PRBool *canRedo);
|
||||
nsresult BeginTransaction();
|
||||
nsresult EndTransaction();
|
||||
nsresult BeginPlaceHolderTransaction([in] nsIAtom *name);
|
||||
nsresult EndPlaceHolderTransaction();
|
||||
nsresult ShouldTxnSetSelection([out] PRBool *_retval);
|
||||
nsresult SetShouldTxnSetSelection([in] PRBool should);
|
||||
nsresult GetInlineSpellChecker([out] nsIInlineSpellChecker **_retval);
|
||||
nsresult Cut();
|
||||
nsresult CanCut([out] PRBool *_retval);
|
||||
nsresult Copy();
|
||||
nsresult CanCopy([out] PRBool *_retval);
|
||||
nsresult Paste([in] PRInt32 aSelectionType);
|
||||
nsresult CanPaste([in] PRInt32 aSelectionType, [out] PRBool *_retval);
|
||||
nsresult SelectAll();
|
||||
nsresult BeginningOfDocument();
|
||||
nsresult EndOfDocument();
|
||||
nsresult CanDrag([in] nsIDOMEvent *aEvent, [out] PRBool *_retval);
|
||||
nsresult DoDrag([in] nsIDOMEvent *aEvent);
|
||||
nsresult InsertFromDrop([in] nsIDOMEvent *aEvent);
|
||||
nsresult SetAttribute([in] nsIDOMElement *aElement, [in] const nsAString *attributestr, [in] const nsAString *attvalue);
|
||||
nsresult GetAttributeValue([in] nsIDOMElement *aElement, [in] const nsAString *attributestr, [out] nsAString *resultValue, PRBool *_retval);
|
||||
nsresult RemoveAttribute([in] nsIDOMElement *aElement, [in] const nsAString *aAttribute);
|
||||
nsresult CloneAttribute([in] const nsAString *aAttribute, [in] nsIDOMNode *aDestNode, [in] nsIDOMNode *aSourceNode);
|
||||
nsresult CloneAttributes([in] nsIDOMNode *destNode, [in] nsIDOMNode *sourceNode);
|
||||
nsresult CreateNode([in] const nsAString *tag, [in] nsIDOMNode parent, [in] PRInt32 position, [out] nsIDOMNode **_retval);
|
||||
nsresult InsertNode([in] nsIDOMNode *node, [in] nsIDOMNode *parent, [in] PRInt32 aPosition);
|
||||
nsresult SplitNode([in] nsIDOMNode *existingRightNode, [in] PRInt32 offset, [out] nsIDOMNode **newLeftNode);
|
||||
nsresult JoinNodes([in] nsIDOMNode *leftNode, [in] nsIDOMNode *rightNode, [in] nsIDOMNode *parent);
|
||||
nsresult DeleteNode([in] nsIDOMNode *child);
|
||||
nsresult MarkNodeDirty([in] nsIDOMNode *node);
|
||||
nsresult SwitchTextDirection();
|
||||
nsresult OutputToString([in] nsAString formatType, [in] PRUint32 flags, [out] nsAString *_retval);
|
||||
nsresult OutputToStream([in] nsIOutputStream *aStream, [in] nsAString *formatType, [in] nsACString *charsetOverride, [in] PRUint32 flags);
|
||||
nsresult AddEditorObserver([in] nsIEditorObserver *observer);
|
||||
nsresult RemoveEditorObserver([in] nsIEditorObserver *observer);
|
||||
nsresult AddEditActionListener([in] nsIEditActionListener *listener);
|
||||
nsresult RemoveEditActionListener([in] nsIEditActionListener *listener);
|
||||
nsresult AddDocumentStateListener([in] nsIDocumentStateListener *listener);
|
||||
nsresult RemoveDocumentStateListener([in] nsIDocumentStateListener *listener);
|
||||
nsresult DumpContentTree();
|
||||
nsresult DebugDumpContent();
|
||||
nsresult DebugUnitTests([out] PRInt32 *outNumTests, [out] PRInt32 *outNumTestsFailed);
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE:
|
||||
* This is a private Wine interface that is implemented by our implementation
|
||||
|
|
Loading…
Reference in New Issue