Skip to content

Commit

Permalink
Make HTMLEditor::ClearStyleAt stop forgetting removed line break
Browse files Browse the repository at this point in the history
It does tricky if the styled element contains a padding line break.

First, it splits the inline containers at the point.  E.g., if the DOM is
`<b>abc []<br></b>`, it's split as `<b>abc </b><b><br></b>`.

Next, it deletes the latter one if it has only a padding line break. Then,
previously, it didn't forget the disconnected `<br>`, but D231655 made it
forget [1].

However, the method needs to insert a padding line break temporarily, i.e.,
It needs to make it as `<b>abc </b><br>`, because `WhiteSpaceVisibilityKeeper`
will treat the collapsible white-space as an invisible trailing white-space
of the block.  Therefore, it does it only when it removes a padding line break
[2].

Therefore, this patch makes it forget the deleted padding line break.

1. https://searchfox.org/mozilla-central/rev/94c62970ba2f9c40efd5a4f83a538595425820d9/editor/libeditor/HTMLStyleEditor.cpp#2465-2467
2. https://searchfox.org/mozilla-central/rev/94c62970ba2f9c40efd5a4f83a538595425820d9/editor/libeditor/HTMLStyleEditor.cpp#2499-2502,2512-2514

Differential Revision: https://phabricator.services.mozilla.com/D233232

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1940014
gecko-commit: dd8b1488a379ee395592f636d084cf81117f3b4c
gecko-reviewers: m_kato
  • Loading branch information
masayuki-nakano authored and moz-wptsync-bot committed Jan 6, 2025
1 parent 4c29914 commit 783c2ab
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions editing/data/multitest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3250,4 +3250,11 @@ var browserTests = [
"<table><tbody><tr><th>a</th><th><br></th><th><br></th><th><b>B</b></th><th>e</th></tr></tbody></table>"],
[true,true],
{}],

// Preseve the collapsible white-space after the style is cleared.
["<p><b>abc[]</b></p>",
[["inserttext"," "],["bold",""],["inserttext","d"]],
"<p><b>abc </b>d</p>",
[true,true,true],
{}],
]

0 comments on commit 783c2ab

Please sign in to comment.