Bug 1940377 - part 4: Make HTMLEditor normalize white-spaces before inserting HTML fragment if the new normalizer is enabled r=m_kato
Unfortunately, this change does not make `white-spaces-after-insert-image.tentative.html?paste-image` pass because we paste the `<div>` at pasting the `<img>`, but Chrome pastes only the `<img>`. Differential Revision: https://phabricator.services.mozilla.com/D239466
This commit is contained in:
@@ -561,11 +561,10 @@ nsresult HTMLEditor::OnEndHandlingTopLevelEditSubActionInternal() {
|
||||
case EditSubAction::eInsertTextComingFromIME:
|
||||
case EditSubAction::eInsertLineBreak:
|
||||
case EditSubAction::eInsertParagraphSeparator:
|
||||
return !StaticPrefs::
|
||||
editor_white_space_normalization_blink_compatible();
|
||||
case EditSubAction::ePasteHTMLContent:
|
||||
case EditSubAction::eInsertHTMLSource:
|
||||
return true;
|
||||
return !StaticPrefs::
|
||||
editor_white_space_normalization_blink_compatible();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include "mozilla/OwningNonNull.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Result.h"
|
||||
#include "mozilla/StaticPrefs_editor.h"
|
||||
#include "mozilla/TextComposition.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
@@ -847,6 +848,22 @@ Result<EditActionResult, nsresult> HTMLEditor::HTMLWithContextInserter::Run(
|
||||
NS_WARNING("HTMLEditor::GetBetterInsertionPointFor() failed");
|
||||
return Err(NS_ERROR_FAILURE);
|
||||
}
|
||||
if (StaticPrefs::editor_white_space_normalization_blink_compatible()) {
|
||||
Result<EditorDOMPoint, nsresult> pointToInsertOrError =
|
||||
WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesToSplitAt(
|
||||
mHTMLEditor, 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);
|
||||
}
|
||||
}
|
||||
|
||||
const bool insertionPointWasInLink =
|
||||
!!HTMLEditor::GetLinkElement(pointToInsert.GetContainer());
|
||||
|
||||
@@ -60,32 +60,3 @@
|
||||
|
||||
|
||||
[insert-or-paste-image.tentative.html?execCommand-insertHTML]
|
||||
[document.execCommand("insertHTML") when "a[\] b"]
|
||||
expected: FAIL
|
||||
|
||||
[document.execCommand("insertHTML") when "a [\] b"]
|
||||
expected: FAIL
|
||||
|
||||
[document.execCommand("insertHTML") when "a [\] b"]
|
||||
expected: FAIL
|
||||
|
||||
[document.execCommand("insertHTML") when "a [\] b"]
|
||||
expected: FAIL
|
||||
|
||||
[document.execCommand("insertHTML") when "a [\] b"]
|
||||
expected: FAIL
|
||||
|
||||
[document.execCommand("insertHTML") when "a [\] b"]
|
||||
expected: FAIL
|
||||
|
||||
[document.execCommand("insertHTML") when "a [\] b"]
|
||||
expected: FAIL
|
||||
|
||||
[document.execCommand("insertHTML") when "a [\] b"]
|
||||
expected: FAIL
|
||||
|
||||
[document.execCommand("insertHTML") when "a [\] b"]
|
||||
expected: FAIL
|
||||
|
||||
[document.execCommand("insertHTML") when "a [\]b"]
|
||||
expected: FAIL
|
||||
|
||||
Reference in New Issue
Block a user