This checkin adds the implementations for encoding
HTML and plain text:
nsTextEncoder::EncodeToString(..)
nsHTMLEncoder::EncodeToStream(..)
Hooked these services into the nsHTMLEditor implemenation
We probably want to update the clipboard code to
use the same pattern as in nsHTMLEditor.cpp
* Added some code to restore selection after RemoveTextProperty.
* Made a tiny change to the way the editor holds onto the transaction manager, so client (like the ender text control) can
turn undo on and off effectively
* Fixed a bug in IsNodeInline that was causing GetBlockParent to return the wrong parent node (and who knows what
other mischief) where atom compares were being done on strings of different case, for <B>, "b" vs. "B". The DOM
method nsIDOMElement::GetTagName forced the returned tag name to upper case. I don't know how long that has
been true, but I assume it's a fairly recent change (or something on our side related to it changed recently) or this method
never would have worked. I also found a few cases of nsString::Equals that I changed to EqualsIgnoreCase
* Made some general improvements to the interaction between editors and rules, so that the aCancel out param is always
intialized, and all rules with Will... are matched with a Did... call. Added Will/DidSetTextProperty() and
Will/DidRemoveTextProperty(). This helps enable plain text mode. Added a skeleton for max length support in text editor.
* fixed some warnings.
* added focus listener. Doesn't do much yet, but when focus notifications start appearing, we'll be ready for them. The code is in
place to hide selection when we lose focus and paint selection when we get focus. That's probably not quite right, but it's a start.
We will need to be able to determine the distinction between losing focus to another control within our app, and losing focus to
another app.
* added support for disabled and readonly states in the editor. This is accomplished by having flags set by the client, and letting the
rules system deal with those flags. The flags I added are:
TEXT_EDITOR_FLAG_PLAINTEXT 0x01 // only plain text editing is allowed
TEXT_EDITOR_FLAG_SINGLELINE 0x02 // enter key and CR-LF handled specially
TEXT_EDITOR_FLAG_PASSWORD 0x04 // text is not entered into content, only a representative character
TEXT_EDITOR_FLAG_READONLY 0x08 // editing events are disabled. Editor may still accept focus.
TEXT_EDITOR_FLAG_DISALBED 0x10 // all events are disabled (like scrolling). Editor will not accept focus.
* added WillInsertBreak/DidInsertBreak into text rules, so flags could be checked. This gets us readonly, disabled, and single line
behavior.
* cleaned up the code that allocates, registers, and destroys event listeners. Thanks to Kin and Simon for cleaning up the
ownership model on the listeners, it was a big help.
* added support for a max text length. You can now tell the text editor, be no bigger than n characters.
features like set paragraph style, set list type, indent, etc. I'm sure there's holes in my
implementation that these high level features will make obvious.
2. I've factored a lot of utility methods from several modules into nsEditor as public static methods.
This makes them easily accessable to all, and will help Joe and I remove redundant methods.
3. I changed the HTML tags to lower case, and made all string compares case-insensitive. No, this
isn't quite the right thing to do, but we don't have atoms from layout yet. The Right Thing is for us
to reuse those atoms.
nsI*Editor::OutputText(nsString& aOutputString);
nsI*Editor::OutputHTML(nsString& aOutputString);
These methods always returns back a Unicode version of whatever is in the content model. It is the
responsibility of the caller then to call whatever converter is required to convert to the appropriate
charset.
Added:
nsI*Editor::OutputText(nsIOutputStream* aOutputStream, nsString* aCharsetOverride = nsnull)
nsI*Editor::OutputHTML(nsIOutputStream* aOutputStream, nsString* aCharsetOverride = nsnull)
These methods output the the current content model to aOutputStream. The document is encoded using the
document defined charset or if the user passes in a non-null value for aCharsetOverride then this
encoding overrides the encoding used by the document.
1. fix for bug 5796, crash on exit. This was a bad, bad memory smudge on my part, easily fixed by doing the right ref counting in the
right places.
2. some preliminary code for M6 block transformations has leaked into this checkin. It's safer than trying to re-code the fix above into
a fresh tree. Unless you're making calls to do block transformations, you won't see any difference.
* added TextEditorTest.cpp, a unit test module for nsTextEditor. It's use is actually commented out since my checkin is happening so late due
to all-day build bustage, and I don't have a Mac handy to verify. With someone's Mac help tomorrow, I can turn it on.
* some minor bug fixes to property handling