Bug 1940377 - part 3: Make "insert paragraph" handlers use the new normalizer if it's enabled r=m_kato

Unfortunately, this change does not make
`white-spaces-after-execCommand-insertparagraph.tentative.html` pass because
the insert paragraph handler inserts a temporary `<br>` element and that causes
normalizing the following white-spaces at the split point.  However, Chrome
does not normalize the following white-spaces if it begins with an NBSP.

Differential Revision: https://phabricator.services.mozilla.com/D239465
This commit is contained in:
Masayuki Nakano
2025-03-08 00:23:15 +00:00
parent cb5f775b5c
commit e14afee1c1
4 changed files with 93 additions and 23 deletions

View File

@@ -4394,7 +4394,9 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::PrepareToInsertLineBreak(
}
Result<EditorDOMPoint, nsresult> pointToInsertOrError =
WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesToSplitAt(
*this, aPointToInsert);
*this, aPointToInsert,
{WhiteSpaceVisibilityKeeper::NormalizeOption::
StopIfPrecedingWhiteSpacesEndsWithNBP});
if (NS_WARN_IF(pointToInsertOrError.isErr())) {
return pointToInsertOrError.propagateErr();
}
@@ -4413,7 +4415,9 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::PrepareToInsertLineBreak(
Result<EditorDOMPoint, nsresult> pointToInsertOrError =
StaticPrefs::editor_white_space_normalization_blink_compatible()
? WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesToSplitAt(
*this, aPointToInsert)
*this, aPointToInsert,
{WhiteSpaceVisibilityKeeper::NormalizeOption::
StopIfPrecedingWhiteSpacesEndsWithNBP})
: aPointToInsert;
if (NS_WARN_IF(pointToInsertOrError.isErr())) {
return pointToInsertOrError.propagateErr();