From 212f24a70911045d0927758b209664f2cc7e49ad Mon Sep 17 00:00:00 2001 From: "mjudge%netscape.com" Date: Wed, 15 Dec 1999 03:46:27 +0000 Subject: [PATCH] adding in nsEditorController to makesystem. adding in registration to allow someone to get an editorcontroller from the outside. also change editor shell to register a controller to handle keyboard navigation. git-svn-id: svn://10.0.0.236/trunk@56025 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/base/Makefile.in | 1 + mozilla/editor/base/makefile.win | 2 ++ mozilla/editor/base/nsEditorRegistration.cpp | 5 ++++ mozilla/editor/base/nsEditorShell.cpp | 28 +++++++++++++++++- mozilla/editor/composer/src/nsEditorShell.cpp | 28 +++++++++++++++++- .../libeditor/build/nsEditorRegistration.cpp | 5 ++++ mozilla/editor/macbuild/editor.mcp | Bin 98491 -> 101484 bytes mozilla/editor/public/Makefile.in | 1 + mozilla/editor/public/makefile.win | 1 + 9 files changed, 69 insertions(+), 2 deletions(-) diff --git a/mozilla/editor/base/Makefile.in b/mozilla/editor/base/Makefile.in index 20e39df6471..b682950032f 100644 --- a/mozilla/editor/base/Makefile.in +++ b/mozilla/editor/base/Makefile.in @@ -32,6 +32,7 @@ IS_COMPONENT = 1 CPPSRCS = \ nsEditor.cpp \ + nsEditorController.cpp \ nsEditorUtils.cpp \ nsEditorRegistration.cpp \ nsTextEditRules.cpp \ diff --git a/mozilla/editor/base/makefile.win b/mozilla/editor/base/makefile.win index 05173256c24..f171fe8461f 100644 --- a/mozilla/editor/base/makefile.win +++ b/mozilla/editor/base/makefile.win @@ -27,6 +27,7 @@ LIBRARY_NAME=ender CPPSRCS = \ nsEditor.cpp \ + nsEditorController.cpp \ nsEditorUtils.cpp \ nsEditorRegistration.cpp \ nsTextEditRules.cpp \ @@ -61,6 +62,7 @@ CPPSRCS = \ CPP_OBJS = \ .\$(OBJDIR)\nsEditor.obj \ + .\$(OBJDIR)\nsEditorController.obj \ .\$(OBJDIR)\nsEditorUtils.obj \ .\$(OBJDIR)\nsEditorRegistration.obj \ .\$(OBJDIR)\nsTextEditRules.obj \ diff --git a/mozilla/editor/base/nsEditorRegistration.cpp b/mozilla/editor/base/nsEditorRegistration.cpp index b98d3fa8c26..66d27717057 100644 --- a/mozilla/editor/base/nsEditorRegistration.cpp +++ b/mozilla/editor/base/nsEditorRegistration.cpp @@ -25,6 +25,8 @@ #include "nsEditorCID.h" #include "nsEditorShell.h" // for the CID #include "nsEditor.h" // for gInstanceCount +#include "nsEditorController.h" //CID + //////////////////////////////////////////////////////////////////////// // Define the contructor function for the objects @@ -33,6 +35,7 @@ // NS_GENERIC_FACTORY_CONSTRUCTOR(nsEditorShell) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsEditorController) #ifdef ENABLE_EDITOR_API_LOG #include "nsHTMLEditorLog.h" @@ -54,6 +57,8 @@ static nsModuleComponentInfo components[] = { { "HTML Editor", NS_HTMLEDITOR_CID, "component://netscape/editor/htmleditor", nsHTMLEditorConstructor, }, #endif + { "Editor Shell Controller", NS_EDITORCONTROLLER_CID, + "component://netscape/editor/editorcontroller", nsEditorControllerConstructor, }, { "Editor Shell Component", NS_EDITORSHELL_CID, "component://netscape/editor/editorshell", nsEditorShellConstructor, }, { "Editor Shell Spell Checker", NS_EDITORSHELL_CID, diff --git a/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp index 45261cede2c..9454f46e64f 100644 --- a/mozilla/editor/base/nsEditorShell.cpp +++ b/mozilla/editor/base/nsEditorShell.cpp @@ -75,6 +75,11 @@ #include "nsIPrompt.h" #include "nsICommonDialogs.h" +#include "nsIEditorController.h" +#include "nsEditorController.h" +#include "nsIControllers.h" + + /////////////////////////////////////// // Editor Includes /////////////////////////////////////// @@ -117,6 +122,8 @@ static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID); static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); static NS_DEFINE_CID(kCommonDialogsCID, NS_CommonDialog_CID ); static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID); +static NS_DEFINE_CID(kEditorControllerCID, NS_EDITORCONTROLLER_CID); + /* Define Interface IDs */ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -328,6 +335,26 @@ nsEditorShell::PrepareDocumentForEditing(nsIURI *aUrl) rv = editor->AddDocumentStateListener(mStateMaintainer); if (NS_FAILED(rv)) return rv; + + if (NS_SUCCEEDED(rv) && mContentWindow) + { + nsCOMPtr controller; + nsCOMPtr controllers; + rv = nsComponentManager::CreateInstance(kEditorControllerCID, nsnull, nsIController::GetIID(), getter_AddRefs(controller)); + if (NS_SUCCEEDED(rv) && controller) + { + rv = mContentWindow->GetControllers(getter_AddRefs(controllers)); + if (NS_SUCCEEDED(rv) && controllers) + { + nsCOMPtr ieditcontroller = do_QueryInterface(controller); + nsCOMPtr editor = do_QueryInterface(mEditor); + ieditcontroller->SetEditor(editor);//weak link + + rv = controllers->InsertControllerAt(0,controller); + } + } + } + // now all the listeners are set up, we can call PostCreate rv = editor->PostCreate(); if (NS_FAILED(rv)) return rv; @@ -3585,7 +3612,6 @@ nsEditorShell::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel* channel, res = PrepareDocumentForEditing(aUrl); SetChromeAttribute( mWebShell, "Editor:Throbber", "busy", "false" ); } - return res; } diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp index 45261cede2c..9454f46e64f 100644 --- a/mozilla/editor/composer/src/nsEditorShell.cpp +++ b/mozilla/editor/composer/src/nsEditorShell.cpp @@ -75,6 +75,11 @@ #include "nsIPrompt.h" #include "nsICommonDialogs.h" +#include "nsIEditorController.h" +#include "nsEditorController.h" +#include "nsIControllers.h" + + /////////////////////////////////////// // Editor Includes /////////////////////////////////////// @@ -117,6 +122,8 @@ static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID); static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); static NS_DEFINE_CID(kCommonDialogsCID, NS_CommonDialog_CID ); static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID); +static NS_DEFINE_CID(kEditorControllerCID, NS_EDITORCONTROLLER_CID); + /* Define Interface IDs */ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -328,6 +335,26 @@ nsEditorShell::PrepareDocumentForEditing(nsIURI *aUrl) rv = editor->AddDocumentStateListener(mStateMaintainer); if (NS_FAILED(rv)) return rv; + + if (NS_SUCCEEDED(rv) && mContentWindow) + { + nsCOMPtr controller; + nsCOMPtr controllers; + rv = nsComponentManager::CreateInstance(kEditorControllerCID, nsnull, nsIController::GetIID(), getter_AddRefs(controller)); + if (NS_SUCCEEDED(rv) && controller) + { + rv = mContentWindow->GetControllers(getter_AddRefs(controllers)); + if (NS_SUCCEEDED(rv) && controllers) + { + nsCOMPtr ieditcontroller = do_QueryInterface(controller); + nsCOMPtr editor = do_QueryInterface(mEditor); + ieditcontroller->SetEditor(editor);//weak link + + rv = controllers->InsertControllerAt(0,controller); + } + } + } + // now all the listeners are set up, we can call PostCreate rv = editor->PostCreate(); if (NS_FAILED(rv)) return rv; @@ -3585,7 +3612,6 @@ nsEditorShell::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel* channel, res = PrepareDocumentForEditing(aUrl); SetChromeAttribute( mWebShell, "Editor:Throbber", "busy", "false" ); } - return res; } diff --git a/mozilla/editor/libeditor/build/nsEditorRegistration.cpp b/mozilla/editor/libeditor/build/nsEditorRegistration.cpp index b98d3fa8c26..66d27717057 100644 --- a/mozilla/editor/libeditor/build/nsEditorRegistration.cpp +++ b/mozilla/editor/libeditor/build/nsEditorRegistration.cpp @@ -25,6 +25,8 @@ #include "nsEditorCID.h" #include "nsEditorShell.h" // for the CID #include "nsEditor.h" // for gInstanceCount +#include "nsEditorController.h" //CID + //////////////////////////////////////////////////////////////////////// // Define the contructor function for the objects @@ -33,6 +35,7 @@ // NS_GENERIC_FACTORY_CONSTRUCTOR(nsEditorShell) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsEditorController) #ifdef ENABLE_EDITOR_API_LOG #include "nsHTMLEditorLog.h" @@ -54,6 +57,8 @@ static nsModuleComponentInfo components[] = { { "HTML Editor", NS_HTMLEDITOR_CID, "component://netscape/editor/htmleditor", nsHTMLEditorConstructor, }, #endif + { "Editor Shell Controller", NS_EDITORCONTROLLER_CID, + "component://netscape/editor/editorcontroller", nsEditorControllerConstructor, }, { "Editor Shell Component", NS_EDITORSHELL_CID, "component://netscape/editor/editorshell", nsEditorShellConstructor, }, { "Editor Shell Spell Checker", NS_EDITORSHELL_CID, diff --git a/mozilla/editor/macbuild/editor.mcp b/mozilla/editor/macbuild/editor.mcp index 67160eea486bf5fcfcb43d0cba95988a2b1f3f50..fe27e9668cd29a9e02f45bf380a68be65e75013f 100644 GIT binary patch delta 2619 zcma);dr(zH9LIOhy%!Kr9?JW5Rk{+O;3GAe2^FNFNC*)!GraQfbuSm;@>T(}GE0#T zx}v5|i8?vSG^fdYG-jh^MKU?2W*RkPzLhk?N9FCiXLr0#f4P6`cYnXn@Ao@+5Cb7Jj?iXbLYIvp#Ctq^_KzbAXaED*N=Sl(kVH5sYn>FOUM&k( zOjNU0nW(DKX!Td+B`w8ZNl=xzASE+b{la4Q%(2?+xh3_gIWa`Ig473b9=_6T&asx2 zuz*mS-kOt-d@rpz=~Q5Rd@ml+hUcIq1Yo>Yjxi~^PL5v`)2LMcntYV5RrjUE&~@s` zv`VU~n{y&eukaFTUsi&)D*d$agQ`sL)*K@qVbspeuv6{+%pi&vNb;nJqlBuzD6wqC zP&zi)L`5SYoasVTpIJw}U@LG(woVGu?$5IIr&L>0??W|n>13+ywC}g+ z=F)rG#s(jg)>a#sNR8^2&SBcI9c%qH&%JdEK+e%U8=s(4&1^&ljopLp(`0I7zfGYr z+L|SP26QKsKx=uqEgntGh)+tL=ok{8mqpC;>}6Hxi*0k!*UT?NUs2>lUs_y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