Get rid of `EditorBase::mPaddingBRElementForEmptyEditor`
Categories
(Core :: DOM: Editor, enhancement, P3)
Tracking
()
People
(Reporter: masayuki, Unassigned)
References
(Blocks 2 open bugs)
Details
I think that we don't need to keep using mPaddingBRElementForEmptyEditor
for both TextEditor
and HTMLEditor
because:
- If
TextEditor
allows empty text node to be a child of anonymous<div>
, the padding<br>
element is not required (IIRC, the caret position issue has gone). - If
HTMLEditor
, it's created only for empty<br>
element, and never created forcontenteditable
. This causes some different behaviors betweendesignMode
andcontenteditable
. - Even if we create the padding
<br>
element, it can be managed with checking first child of the editing host and flag of the<br>
element.
Updated•3 years ago
|
Comment 1•3 years ago
|
||
It turns out designMode=on
still needs a padding <br>
or data:text/html,<script>document.designMode="on"</script>
does not show the caret at all. So I'd like to remove mPaddingBRElementForEmptyEditor
only from TextEditor
first, what do you think? (Probably in a different bug.)
Note that doing so won't affect <textarea>
since currently EnsurePaddingBRElementInMultilineEditor()
still want to insert <br>
regardless of emptiness. A check could be added but it could cause inconsistency since nothing removes this type of <br>
after insertion. (A textarea would be initialized without <br>
but then get a permanent one that never disappears even when it becomes empty.)
Reporter | ||
Comment 2•3 years ago
|
||
(In reply to Kagami :saschanaz from comment #1)
It turns out
designMode=on
still needs a padding<br>
ordata:text/html,<script>document.designMode="on"</script>
does not show the caret at all. So I'd like to removemPaddingBRElementForEmptyEditor
only fromTextEditor
first, what do you think? (Probably in a different bug.)
Sounds reasonable.
Note that doing so won't affect
<textarea>
since currentlyEnsurePaddingBRElementInMultilineEditor()
still want to insert<br>
regardless of emptiness. A check could be added but it could cause inconsistency since nothing removes this type of<br>
after insertion. (A textarea would be initialized without<br>
but then get a permanent one that never disappears even when it becomes empty.)
Yeah, unfortunately, we need a <br>
element at least when there is a last line which is empty. So, I don't think that we can stop using <br>
element, but stopping managing the mPaddingBRelementForEmptyEditor
as a member may make the code simpler and more stateless since like HTMLEditor
, once we failed to handle it, checking the member breaks something.
Updated•3 years ago
|
Description
•