mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 00:05:36 +00:00
9d71742b36
Currently, HTMLEditor doesn't initialize caret position when it gets focus by itself in most cases. Only when it's in designMode, it may move caret to the first visible (not checking CSS actually). In most cases, caret position is adjusted when EditorBase::InitializeSelection() calls Selection::SetAncestorLimiter(). If selected range is outside of new limiter, it moves caret to start of the new limiter. However, this is really different behavior from the other browsers. The other browsers try to move caret to the first editable text node or before the first editable content such as <img>, <input>, etc. This difference causes a serious incompatible issue with Draft.js. It doesn't initialize caret position when it gets focus but it assumes that caret is always set to before <br> element if there is no other content. So, let's try to behave as what other browsers do as far as possible. This patch makes editor behave as: * if selection is already in the editing host except start of the editing host, does nothing. * if there is non-editable element before any editable node, move caret to start of the editing host. * if there is editable text node or element node which cannot have a text node, move its start or before it. * if there is no editable nodes which can contain text nodes, move caret to start of the editing host. Note that before applying this patch, in designMode, BeginningOfDocument() used document element instead of <body> element. Therefore, it may set odd position if <head> element has some text nodes with <script> or <style>. However, this doesn't make sense and for making more consistent behavior between designMode and contenteditable, this patch makes it use editing host (it's <body> element if it's in designMode). MozReview-Commit-ID: 5neYoTMq6Cc --HG-- extra : rebase_source : c4d06b6864a221d7cd2833a007d73f7d67821e95 |
||
---|---|---|
.. | ||
composer | ||
libeditor | ||
reftests | ||
spellchecker | ||
txmgr | ||
AsyncSpellCheckTestHelper.jsm | ||
moz.build | ||
nsEditorCID.h | ||
nsIDocumentStateListener.idl | ||
nsIEditActionListener.idl | ||
nsIEditor.idl | ||
nsIEditorMailSupport.idl | ||
nsIEditorObserver.idl | ||
nsIEditorSpellCheck.idl | ||
nsIEditorStyleSheets.idl | ||
nsIEditorUtils.idl | ||
nsIHTMLAbsPosEditor.idl | ||
nsIHTMLEditor.idl | ||
nsIHTMLInlineTableEditor.idl | ||
nsIHTMLObjectResizer.idl | ||
nsIPlaintextEditor.idl | ||
nsITableEditor.idl | ||
nsIURIRefObject.idl |