Make `HTMLEditor::AutoInsertParagraphHandler::HandleInParagraph` stop inserting maybe unnecessary `<br>` element before splitting the paragraph
Categories
(Core :: DOM: Editor, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox143 | --- | fixed |
People
(Reporter: masayuki, Assigned: masayuki)
References
(Blocks 2 open bugs)
Details
Attachments
(6 files)
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
Details | Review |
| Assignee | ||
Comment 1•2 years ago
|
||
So, it can be checked before inserting a <br> with whether the <br> is:
- not followed by a block boundary
- and, not follows a collapsible white-space
| Assignee | ||
Updated•1 year ago
|
| Assignee | ||
Updated•1 year ago
|
| Assignee | ||
Comment 2•1 year ago
|
||
In the IE/Netscape era, we inserted a <br> in specific cases even if
insertParagraph command is being handled. Although this patch makes
the legacy mode slower because of increasing the number of <br>
element scanning, we should split it off to make HandleInParagraph
simpler to optimize its logic later.
| Assignee | ||
Comment 3•1 year ago
|
||
The method does not check invisible white-spaces nor Comment nodes.
Therefore, it may work differently from the user's point of view in
some edge cases.
Additionally, for making the following patch simpler and safer, the
split point should be outside a non-splittable element like <img>.
| Assignee | ||
Comment 4•1 year ago
|
||
Unfortunately, I don't have any ideas to separate this change because
the current behavior is broken, it assumes only simple cases. However,
with rewriting the code simpler, we'll get the unexpected passes.
Therefore, this patch has a big change.
The strategy of the new behavior is, first, put a padding <br> to next
to the split point if and only if it's immediately before a block
boundary and delete unnecessary existing invisible <br> element if
it puts a new <br>. Next, put a <br> to end of the left paragraph
if and only if the paragraph ends with a block boundary or a line break
or the split occurred at end of the deepest inline element.
| Assignee | ||
Comment 5•1 year ago
|
||
SplitParagraphWithTransaction() does a lot of additional works to
split a paragraph. This should be done when insertParagraph is
performed in an list item.
Then, we can drop the following code in HandleInListItemElement():
- Inserting a padding
<br>into empty left list item - Copying styles at end of the left
<li>to the right empty one - Considering the caret position with scanning the right list item
| Assignee | ||
Comment 6•1 year ago
|
||
If the right <dt>/<dd> is empty, the method replaces it with
opposite type element without copying the style. So, we can consider
whether we can just insert an opposite list item before splitting the
given list item.
Note that new failures were passed by a bug of current code. That is,
the method treats invisible <br> as visible. So, the cases cause
different result whether there is an invisible <br> at end of the
list item even though it does not cause different look for the users.
Inserting opposite type of list item is a Gecko specific behavior.
I think we should stop doing that in Firefox for the compatibility with
the other browsers in a follow up bug.
| Assignee | ||
Comment 7•1 year ago
|
||
This make AutoInsertParagraphHandler::HandleInHeadingElement:
- stop splitting the heading element if split at end
- use
SplitParagraphWithTransactionif splitting the heading element
Then, this also cases the failures because not touching the invisible
<br> element in the heading element. Failing with this reason does
not make sense because not touching the heading element saves the
footprint for undo transactions. Therefore, this patch makes the tests
allow the <br>s to stay there.
| Assignee | ||
Updated•11 months ago
|
Comment 10•11 months ago
|
||
Comment 11•11 months ago
|
||
Comment 12•11 months ago
|
||
Comment 13•11 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/401f1f9d1b45
https://hg.mozilla.org/mozilla-central/rev/b0887987f495
https://hg.mozilla.org/mozilla-central/rev/cf0d99adfd16
https://hg.mozilla.org/mozilla-central/rev/5c38af816f1d
https://hg.mozilla.org/mozilla-central/rev/8d66b04b16dd
https://hg.mozilla.org/mozilla-central/rev/8f561bffb2ac
| Assignee | ||
Updated•11 months ago
|
Updated•10 months ago
|
Description
•