gecko-dev/editor
Masayuki Nakano 9d71742b36 Bug 662591 - HTMLEditor should set caret to start of first editable text node or before first editable inline node r=m_kato
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
2018-03-02 14:20:25 +09:00
..
composer Bug 1442500 - Part 3. Move spellchecker tests to editor/spellchecker. r=masayuki 2018-03-02 12:57:54 +09:00
libeditor Bug 662591 - HTMLEditor should set caret to start of first editable text node or before first editable inline node r=m_kato 2018-03-02 14:20:25 +09:00
reftests Bug 1429573 - Use input[type=number] in textbox[type=number] implementation. r=Paolo,surkov 2018-02-09 21:54:36 +00:00
spellchecker Bug 1442500 - Part 3. Move spellchecker tests to editor/spellchecker. r=masayuki 2018-03-02 12:57:54 +09:00
txmgr Bug 1428535 - Add missing override specifiers to overridden virtual functions. r=froydnj 2017-11-05 19:37:28 -08:00
AsyncSpellCheckTestHelper.jsm Bug 1440284 - change this.EXPORTED_SYMBOLS back to var EXPORTED_SYMBOLS in JS modules, r=mccr8. 2018-02-23 20:50:01 +01:00
moz.build Bug 1442500 - Part 1. Rename editor/txtsvc to editor/spellchecker. r=masayuki 2018-03-02 12:55:26 +09:00
nsEditorCID.h
nsIDocumentStateListener.idl
nsIEditActionListener.idl Bug 1430319 - Get rid of nsIEditActionListener::Will*() which are not used by anybody r=m_kato 2018-01-13 10:10:05 +09:00
nsIEditor.idl Bug 662591 - HTMLEditor should set caret to start of first editable text node or before first editable inline node r=m_kato 2018-03-02 14:20:25 +09:00
nsIEditorMailSupport.idl Bug 1060051 - Make editor related interfaces builtin classes if it's possible r=Ehsan,smaug 2017-08-04 13:57:56 +09:00
nsIEditorObserver.idl Bug 1432528 - part 4: Remove nsIEditorObserver::BeforeEditAction() and nsIEditorObserver::CancelEditAction() because nobody implements them r=m_kato 2018-01-24 14:31:29 +09:00
nsIEditorSpellCheck.idl Bug 1424677 - Don't use wstring for nsIEditorSpellCheck. r=masayuki 2017-12-13 04:14:27 -06:00
nsIEditorStyleSheets.idl Bug 1060051 - Make editor related interfaces builtin classes if it's possible r=Ehsan,smaug 2017-08-04 13:57:56 +09:00
nsIEditorUtils.idl Bug 1060051 - Make editor related interfaces builtin classes if it's possible r=Ehsan,smaug 2017-08-04 13:57:56 +09:00
nsIHTMLAbsPosEditor.idl Bug 1433849 - Remove unused methods in nsIHTMLAbsPosEditor. r=masayuki 2018-02-01 10:55:25 +09:00
nsIHTMLEditor.idl Bug 1432944 part 2. Make nsIHTMLEditor.getSelectedElement return nsISupports. r=m_kato 2018-01-29 23:27:59 -05:00
nsIHTMLInlineTableEditor.idl Bug 1425547 - Remove unused methods from nsIHTMLInlineTableEditor. r=masayuki 2018-01-19 16:41:41 +09:00
nsIHTMLObjectResizer.idl Bug 1425652 - mosueDown, mouseUp and mouseMove should be removed from nsIHTMLObjectResizer. r=masayuki 2018-01-10 12:47:16 +09:00
nsIPlaintextEditor.idl Bug 1439812 - Move noscript methods of nsIPlainTextEditor to TextEditor. r=masayuki 2018-02-21 13:21:57 +09:00
nsITableEditor.idl Bug 1387317 - part1: Make AutoSelectionSetterAfterTableEdit use HTMLEditor instead of nsITableEditor r=m_kato 2017-08-08 10:57:19 +09:00
nsIURIRefObject.idl