[Also posted on the embedding newsgroup. Follows there, please.]
As we have discussed in the past, for editor to work in the
embedded world, and when editing framesets, iframes etc, we need to
hang editors off of docShells. In addition, the root docShell for
the content area needs to have some kind of 'editor session' to
manage UI interaction among the various contained editors.
The way I have implemented this so far (and I have it working to
the extent that I can edit, and apply styles to documents in a
frameset, and in iframes) is to subclass webShell:
nsDocShell
^
|
nsWebShell
^
|
nsEditorDocShell -- adds nsCOMPtr<nsIEditor> member
^
|
nsEditingShell -- adds nsCOMPtr<nsIEditingSession> member
When bringing up a frameset doc in editor, I then instantiate an
nsEditorDocShell for each subframe that is editable, and an
nsEditingShell for the root frame. Thus, each editable frame as an
nsIEditor for it, and the parent has an nsIEditingSession (as well
as an nsIEditor).
So the first strong reason to have subclasses of nsWebShell for
this is to have a place to hang editor-related members.
The second strong reason is that editor needs to both listen to
both document and page loads, and sometimes override the normal
behaviour that happens. For example, editor probably does not want
the keyword expansion that happens in nsWebShell's end load method.
Subclassing allows me to write override methods that give me the
hooks I need to make and tear down editors, and to turn off some of
the webshell processing that editor does not want. Doing all this
with outside notifications would require much more work, and lots
of hacky observer stuff.
I've been careful to put as little code in the nsEditorDocShell/
nsEditingShell classes as possible. Like docShell, they are mainly
just glue to give me a chance to call into editor code. In
addition, for non-editing situations, these subclasses will never
be instantiated, so there is no additional overhead using this
technique.
I understand the reluctance to accept docShell subclasses. However,
that seems like the right thing to do in this situation.
Comments are welcome.
Simon
--
Simon Fraser Entomologist
[EMAIL PROTECTED] http://people.netscape.com/sfraser/