Bug 1940377 - part 5: Make HTMLEditor::InsertElementAtSelectionAsAction normalize white-spaces around the insertion point if the new normalizer is enabled r=m_kato
Surprisingly, it has not normalize white-spaces around it. So, in some edge cases, it might cause changing visibility of surrounding white-spaces. Differential Revision: https://phabricator.services.mozilla.com/D239467
This commit is contained in:
@@ -2248,6 +2248,22 @@ nsresult HTMLEditor::InsertElementAtSelectionAsAction(
|
|||||||
NS_WARNING("HTMLEditUtils::GetBetterInsertionPointFor() failed");
|
NS_WARNING("HTMLEditUtils::GetBetterInsertionPointFor() failed");
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
if (StaticPrefs::editor_white_space_normalization_blink_compatible()) {
|
||||||
|
Result<EditorDOMPoint, nsresult> pointToInsertOrError =
|
||||||
|
WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesToSplitAt(
|
||||||
|
*this, pointToInsert,
|
||||||
|
{WhiteSpaceVisibilityKeeper::NormalizeOption::
|
||||||
|
StopIfFollowingWhiteSpacesStartsWithNBSP});
|
||||||
|
if (MOZ_UNLIKELY(pointToInsertOrError.isErr())) {
|
||||||
|
NS_WARNING(
|
||||||
|
"WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesToSplitAt() failed");
|
||||||
|
return pointToInsertOrError.propagateErr();
|
||||||
|
}
|
||||||
|
pointToInsert = pointToInsertOrError.unwrap();
|
||||||
|
if (NS_WARN_IF(!pointToInsert.IsSetAndValidInComposedDoc())) {
|
||||||
|
return Err(NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (aOptions.contains(InsertElementOption::SplitAncestorInlineElements)) {
|
if (aOptions.contains(InsertElementOption::SplitAncestorInlineElements)) {
|
||||||
if (const RefPtr<Element> topmostInlineElement = Element::FromNodeOrNull(
|
if (const RefPtr<Element> topmostInlineElement = Element::FromNodeOrNull(
|
||||||
|
|||||||
@@ -37,26 +37,5 @@
|
|||||||
|
|
||||||
|
|
||||||
[insert-or-paste-image.tentative.html?execCommand-insertImage]
|
[insert-or-paste-image.tentative.html?execCommand-insertImage]
|
||||||
[document.execCommand("insertImage") when "a [\] b"]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[document.execCommand("insertImage") when "a [\] b"]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[document.execCommand("insertImage") when "a [\] b"]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[document.execCommand("insertImage") when "a [\] b"]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[document.execCommand("insertImage") when "a [\] b"]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[document.execCommand("insertImage") when "a [\] b"]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[document.execCommand("insertImage") when "a [\]b"]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
||||||
[insert-or-paste-image.tentative.html?execCommand-insertHTML]
|
[insert-or-paste-image.tentative.html?execCommand-insertHTML]
|
||||||
|
|||||||
Reference in New Issue
Block a user