mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1840822, part 2: Add an invisible line break at the end of a contenteditable for InsertLineBreak
case. r=masayuki,dom-core
The logic behind this patch is similar to that of part 1, only that this covers the case where a user triggers a line break instead of a new paragraph (i.e. by pressing [Shift/cmd]+[Enter]). If the inserted BR element is followed by a block boundary, another BR element is added. Depends on D182339 Differential Revision: https://phabricator.services.mozilla.com/D182485
This commit is contained in:
parent
9a0cf05339
commit
df8b4a288b
@ -1565,23 +1565,43 @@ nsresult HTMLEditor::InsertLineBreakAsSubAction() {
|
||||
CreateElementResult unwrappedInsertBRElementResult =
|
||||
insertBRElementResult.unwrap();
|
||||
MOZ_ASSERT(unwrappedInsertBRElementResult.GetNewNode());
|
||||
// Next inserting text should be inserted into styled inline elements if
|
||||
// they have first visible thing in the new line.
|
||||
auto pointToPutCaret = [&]() -> EditorDOMPoint {
|
||||
WSScanResult forwardScanResult =
|
||||
WSRunScanner::ScanNextVisibleNodeOrBlockBoundary(
|
||||
editingHost, EditorRawDOMPoint::After(
|
||||
*unwrappedInsertBRElementResult.GetNewNode()));
|
||||
if (forwardScanResult.InVisibleOrCollapsibleCharacters()) {
|
||||
unwrappedInsertBRElementResult.IgnoreCaretPointSuggestion();
|
||||
return forwardScanResult.Point<EditorDOMPoint>();
|
||||
unwrappedInsertBRElementResult.IgnoreCaretPointSuggestion();
|
||||
|
||||
auto pointToPutCaret =
|
||||
EditorDOMPoint::After(*unwrappedInsertBRElementResult.GetNewNode());
|
||||
WSScanResult forwardScanFromAfterBRElementResult =
|
||||
WSRunScanner::ScanNextVisibleNodeOrBlockBoundary(editingHost,
|
||||
pointToPutCaret);
|
||||
if (MOZ_UNLIKELY(forwardScanFromAfterBRElementResult.Failed())) {
|
||||
NS_WARNING("WSRunScanner::ScanNextVisibleNodeOrBlockBoundary() failed");
|
||||
return Err(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
if (forwardScanFromAfterBRElementResult.ReachedBlockBoundary()) {
|
||||
// Empty last line is invisible if it's immediately before either parent
|
||||
// or another block's boundary so that we need to put invisible <br>
|
||||
// element here for making it visible.
|
||||
Result<CreateElementResult, nsresult> invisibleAdditionalBRElementResult =
|
||||
WhiteSpaceVisibilityKeeper::InsertBRElement(*this, pointToPutCaret,
|
||||
*editingHost);
|
||||
if (MOZ_UNLIKELY(invisibleAdditionalBRElementResult.isErr())) {
|
||||
NS_WARNING("WhiteSpaceVisibilityKeeper::InsertBRElement() failed");
|
||||
return invisibleAdditionalBRElementResult.unwrapErr();
|
||||
}
|
||||
if (forwardScanResult.ReachedSpecialContent()) {
|
||||
unwrappedInsertBRElementResult.IgnoreCaretPointSuggestion();
|
||||
return forwardScanResult.PointAtContent<EditorDOMPoint>();
|
||||
}
|
||||
return unwrappedInsertBRElementResult.UnwrapCaretPoint();
|
||||
}();
|
||||
CreateElementResult unwrappedInvisibleAdditionalBRElement =
|
||||
invisibleAdditionalBRElementResult.unwrap();
|
||||
pointToPutCaret.Set(unwrappedInvisibleAdditionalBRElement.GetNewNode());
|
||||
unwrappedInvisibleAdditionalBRElement.IgnoreCaretPointSuggestion();
|
||||
} else if (forwardScanFromAfterBRElementResult
|
||||
.InVisibleOrCollapsibleCharacters()) {
|
||||
pointToPutCaret =
|
||||
forwardScanFromAfterBRElementResult.Point<EditorDOMPoint>();
|
||||
} else if (forwardScanFromAfterBRElementResult.ReachedSpecialContent()) {
|
||||
// Next inserting text should be inserted into styled inline elements if
|
||||
// they have first visible thing in the new line.
|
||||
pointToPutCaret =
|
||||
forwardScanFromAfterBRElementResult.PointAtContent<EditorDOMPoint>();
|
||||
}
|
||||
|
||||
nsresult rv = CollapseSelectionTo(pointToPutCaret);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
|
@ -287,30 +287,8 @@
|
||||
[insertparagraph-in-inline-editing-host.tentative.html?white-space=pre-line&display=inline&method=enter]
|
||||
|
||||
[insertparagraph-in-inline-editing-host.tentative.html?white-space=normal&display=inline-block&method=shift-enter]
|
||||
[insertLineBreak in <span contenteditable style="display:inline-block;white-space:normal">{}</span> followed by a <br> (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:inline-block;white-space:normal">{}</span> followed by text (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:inline-block;white-space:normal">abcd[\]</span> followed by a <br> element (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:inline-block;white-space:normal">abcd[\]</span> followed by text (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:inline-block;white-space:normal">{}</span> followed by a <br> (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:inline-block;white-space:normal">{}</span> followed by text (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:inline-block;white-space:normal">abcd[\]</span> followed by a <br> element (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:inline-block;white-space:normal">abcd[\]</span> followed by text (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
expected:
|
||||
if (os == "android") and fission: [OK, TIMEOUT]
|
||||
|
||||
[insertparagraph-in-inline-editing-host.tentative.html?white-space=pre-wrap&display=list-item&method=enter]
|
||||
[insertParagraph in <span contenteditable style="display:list-item;white-space:pre-wrap">{}</span> (defaultParagraphSeparator=div)]
|
||||
@ -493,30 +471,8 @@
|
||||
[insertparagraph-in-inline-editing-host.tentative.html?white-space=normal&display=inline-block&method=enter]
|
||||
|
||||
[insertparagraph-in-inline-editing-host.tentative.html?white-space=normal&display=inline&method=shift-enter]
|
||||
[insertLineBreak in <span contenteditable style="display:inline;white-space:normal">{}</span> followed by a <br> (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:inline;white-space:normal">{}</span> followed by text (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:inline;white-space:normal">abcd[\]</span> followed by a <br> element (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:inline;white-space:normal">abcd[\]</span> followed by text (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:inline;white-space:normal">{}</span> followed by a <br> (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:inline;white-space:normal">{}</span> followed by text (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:inline;white-space:normal">abcd[\]</span> followed by a <br> element (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:inline;white-space:normal">abcd[\]</span> followed by text (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
expected:
|
||||
if (os == "android") and fission: [OK, TIMEOUT]
|
||||
|
||||
[insertparagraph-in-inline-editing-host.tentative.html?white-space=pre-line&display=list-item&method=enter]
|
||||
[insertParagraph in <span contenteditable style="display:list-item;white-space:pre-line">{}</span> (defaultParagraphSeparator=div)]
|
||||
@ -635,30 +591,6 @@
|
||||
|
||||
|
||||
[insertparagraph-in-inline-editing-host.tentative.html?white-space=normal&display=list-item&method=shift-enter]
|
||||
[insertLineBreak in <span contenteditable style="display:list-item;white-space:normal">{}</span> followed by a <br> (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:list-item;white-space:normal">{}</span> followed by text (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:list-item;white-space:normal">abcd[\]</span> followed by a <br> element (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:list-item;white-space:normal">abcd[\]</span> followed by text (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:list-item;white-space:normal">{}</span> followed by a <br> (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:list-item;white-space:normal">{}</span> followed by text (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:list-item;white-space:normal">abcd[\]</span> followed by a <br> element (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:list-item;white-space:normal">abcd[\]</span> followed by text (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[insertparagraph-in-inline-editing-host.tentative.html?white-space=pre-wrap&display=inline-block&method=enter]
|
||||
|
||||
@ -891,56 +823,10 @@
|
||||
|
||||
|
||||
[insertparagraph-in-inline-editing-host.tentative.html?white-space=normal&display=table-cell&method=shift-enter]
|
||||
[insertLineBreak in <span contenteditable style="display:table-cell;white-space:normal">{}</span> followed by a <br> (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:table-cell;white-space:normal">{}</span> followed by text (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:table-cell;white-space:normal">abcd[\]</span> followed by a <br> element (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:table-cell;white-space:normal">abcd[\]</span> followed by text (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:table-cell;white-space:normal">{}</span> followed by a <br> (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:table-cell;white-space:normal">{}</span> followed by text (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:table-cell;white-space:normal">abcd[\]</span> followed by a <br> element (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:table-cell;white-space:normal">abcd[\]</span> followed by text (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
expected:
|
||||
if (os == "android") and fission: [OK, TIMEOUT]
|
||||
|
||||
[insertparagraph-in-inline-editing-host.tentative.html?white-space=normal&display=block&method=shift-enter]
|
||||
[insertLineBreak in <span contenteditable style="display:block;white-space:normal">{}</span> followed by a <br> (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:block;white-space:normal">{}</span> followed by text (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:block;white-space:normal">abcd[\]</span> followed by a <br> element (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:block;white-space:normal">abcd[\]</span> followed by text (defaultParagraphSeparator=div)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:block;white-space:normal">{}</span> followed by a <br> (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:block;white-space:normal">{}</span> followed by text (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:block;white-space:normal">abcd[\]</span> followed by a <br> element (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
[insertLineBreak in <span contenteditable style="display:block;white-space:normal">abcd[\]</span> followed by text (defaultParagraphSeparator=p)]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[insertparagraph-in-inline-editing-host.tentative.html?white-space=normal&display=table-cell&method=enter]
|
||||
expected:
|
||||
|
@ -34,9 +34,6 @@
|
||||
[[["insertlinebreak",""\]\] "<table><tr><td>[foo<td>bar\]<tr><td>baz<td>quz</table>" compare innerHTML]
|
||||
expected: FAIL
|
||||
|
||||
[[["insertlinebreak",""\]\] "<div>abc[\] </div>" compare innerHTML]
|
||||
expected: FAIL
|
||||
|
||||
[[["insertlinebreak",""\]\] "<div>abc [\] </div>" compare innerHTML]
|
||||
expected: FAIL
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user