Skip to content

Commit

Permalink
Bug 1800043: Fixed condition to determine end of selected string. r=m…
Browse files Browse the repository at this point in the history
…asayuki

Differential Revision: https://phabricator.services.mozilla.com/D161881
  • Loading branch information
jnjaeschke committed Nov 11, 2022
1 parent 3f72adc commit c365257
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 4 additions & 5 deletions editor/libeditor/DeleteRangeTransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ DeleteRangeTransaction::MaybeExtendDeletingRangeWithSurroundingWhitespace(
EditorRawDOMPoint startPoint(aRange.StartRef());
EditorRawDOMPoint endPoint(aRange.EndRef());
const bool maybeRangeStartsAfterWhiteSpace =
!(startPoint.IsStartOfContainer() && !startPoint.IsEndOfContainer() &&
startPoint.IsInTextNode());
startPoint.IsInTextNode() &&
!(startPoint.IsStartOfContainer() && !startPoint.IsEndOfContainer());
const bool maybeRangeEndsAtWhiteSpace =
!((endPoint.IsEndOfContainer() && !endPoint.IsStartOfContainer() &&
endPoint.IsInTextNode()) ||
endPoint.IsBRElementAtEndOfContainer());
endPoint.IsInTextNode() &&
!(endPoint.IsEndOfContainer() && !endPoint.IsStartOfContainer());
if (!maybeRangeStartsAfterWhiteSpace && !maybeRangeEndsAtWhiteSpace) {
// no whitespace before or after word => nothing to do here.
return NS_OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,17 @@
}
return test_driver.send_keys(editableElement, deleteKey);
};

if (editableElement.tagName.toLowerCase() == "div") {
promise_test(async t => {
setValue("<p>abc def<span></span></p>");
await doubleClickAndDelete("abc de", "def");
await waitForRender();
assert_equals(
getValue(),
"<p>abc</p>",
"The <span> at the end of the string must be removed, as well as the whitespace in between words.");
}, `${editableElement.tagName}: An empty span at the end of the selection should be considered end of selection!`);
}
promise_test(async t => {
setValue("one two");
await doubleClickAndDelete("on", "one");
Expand Down

0 comments on commit c365257

Please sign in to comment.