gecko-dev/editor/libeditor
Masayuki Nakano 398b556e90 Bug 1877513 - Make `HTMLEditor` deletes only preceding lines of right child block if the range starts from start of a line r=m_kato
Currently, the editor of Gecko always unwraps first line of the right child
block after deleting selected range when the range starts in a parent block
and ends in a child block.  This behavior is almost same as the other browsers,
but the other browsers deletes only preceding lines of the right child block
(i.e., without unwrapping the first line of the right child block) if the range
starts from start of a preceding line, for example, when deleting
`<div>abc<br>[def<p>g]hi<br>jkl`, Gecko moves "hi" to the parent `<div>`,
but the other browsers keeps it in the child `<p>`.

For emulating this special handling, we need to touch 2 paths.

One is `Backspace` when selection is collapsed at start of the child block.  In
this case, only when the preceding line is empty, i.e., there are 2 line breaks
(either `<br>` or `\n` in `white-space: pre-*`), the following break should
be deleted, but the child block should not be touched.

The other is, deleting when selection is not collapsed or `Delete` when
selection is collapsed at immediately before the child block.  In the latter
case, `HTMLEditor::HandleDeleteSelection` extends `Selection` using
`nsFrameSelection`.  Then, handle it with same path as deleting non-collapsed
range.

The former is handled with `HandleDeleteLineBreak` and
`ComputeRangeToDeleteLineBreak`.  The latter is handled with
`HandleDeleteNonCollapsedRange` and `ComputeRangeToDeleteNonCollapsedRange`.
The new handlers use the `ComputeRangeToDelete*`.  Therefore, `beforeinput`
reports exactly same range from `getTargetRanges`.  However, existing paths
do not use same approach and this patch makes `HandleDeleteNonCollapsedRange`
fall it back to `HandleDeleteNonCollapsedRange`.  Therefore, some `if` checks
in `HandleDeleteNonCollapsedRange` are ugly, but I have no better idea to
implement this smarter.

Differential Revision: https://phabricator.services.mozilla.com/D207690
2024-04-27 00:36:26 +00:00
..
crashtests Bug 1843794 - Rewrite editor/AsyncSpellCheckTestHelper.sys.mjs consumers in html/xhtml to use ChromeUtils.importESModule. r=masayuki 2023-07-19 00:43:33 +00:00
tests Bug 1705440 - remove old modal prompt implementation, r=mconley,webdriver-reviewers,extension-reviewers,desktop-theme-reviewers,tabbrowser-reviewers,whimboo,rpl 2024-03-20 17:47:47 +00:00
AutoRangeArray.cpp Bug 1883562 - part 1: Make `AutoBlockElementsJoiner` work with one range r=m_kato 2024-03-11 08:01:50 +00:00
AutoRangeArray.h Bug 1883562 - part 1: Make `AutoBlockElementsJoiner` work with one range r=m_kato 2024-03-11 08:01:50 +00:00
CSSEditUtils.cpp Bug 1839950 - CSSStyleDeclaration.getPropertyValue doesn't throw. r=peterv 2023-06-27 08:21:46 +00:00
CSSEditUtils.h
ChangeAttributeTransaction.cpp
ChangeAttributeTransaction.h
ChangeStyleTransaction.cpp Bug 1856795 - Remove redundant member init r=emilio 2023-10-15 15:29:02 +00:00
ChangeStyleTransaction.h
CompositionTransaction.cpp
CompositionTransaction.h
DeleteContentTransactionBase.cpp
DeleteContentTransactionBase.h
DeleteMultipleRangesTransaction.cpp
DeleteMultipleRangesTransaction.h
DeleteNodeTransaction.cpp
DeleteNodeTransaction.h
DeleteRangeTransaction.cpp
DeleteRangeTransaction.h
DeleteTextTransaction.cpp
DeleteTextTransaction.h
EditAction.h Bug 1877513 - Make `HTMLEditor` deletes only preceding lines of right child block if the range starts from start of a line r=m_kato 2024-04-27 00:36:26 +00:00
EditAggregateTransaction.cpp
EditAggregateTransaction.h
EditTransactionBase.cpp
EditTransactionBase.h
EditorBase.cpp Bug 1892376 - Make `EditorBase` and `HTMLEditor` not use `nsDOMAttributeMap` r=peterv,dom-core 2024-04-25 03:49:01 +00:00
EditorBase.h Bug 903746 - part 2: Add `textInput` event and make `EditorBase` dispatch it as a default action of `beforeinput` r=smaug 2024-04-08 12:30:00 +00:00
EditorCommands.cpp Bug 1883367 - Disable editor commands for read-only editors. r=masayuki 2024-03-08 17:55:57 +00:00
EditorCommands.h Bug 1244437 - part 1: Make `HTMLEditUtils::IsFormatNode` check same tags as Chromium does r=m_kato 2023-10-26 03:45:17 +00:00
EditorController.cpp
EditorController.h
EditorDOMPoint.h Bug 1865729 - part 0: Add logging code of `AutoMoveOneLineHandler` r=m_kato 2023-11-27 01:46:42 +00:00
EditorEventListener.cpp Bug 1870960 - Make `IMEStateManager` stop using `nsPresContext::GetTextInputHandlingWidget()` as far as possible r=smaug 2024-01-16 00:09:35 +00:00
EditorEventListener.h
EditorForwards.h Bug 1859245 - part 4: Make `HTMLEditor` handle only the new direction mode r=m_kato 2023-10-27 01:57:29 +00:00
EditorUtils.cpp Bug 1852478 - Convert CSS `white-space` into a shorthand that expands to `white-space-collapse` and `text-wrap-mode` longhands. r=firefox-style-system-reviewers,emilio 2024-01-26 09:40:02 +00:00
EditorUtils.h Bug 1852478 - Convert CSS `white-space` into a shorthand that expands to `white-space-collapse` and `text-wrap-mode` longhands. r=firefox-style-system-reviewers,emilio 2024-01-26 09:40:02 +00:00
HTMLAbsPositionEditor.cpp
HTMLAnonymousNodeEditor.cpp Bug 1861231 - Make editor handle user input with original target instead of target r=sefeng,dom-core 2023-11-21 03:58:01 +00:00
HTMLEditHelpers.cpp Bug 1856795 - Remove redundant member init r=emilio 2023-10-15 15:29:02 +00:00
HTMLEditHelpers.h Bug 1859245 - part 1: Make `JoinNodesResult` and `SplitNodeResult` handle only the new direction mode r=m_kato 2023-10-27 01:57:28 +00:00
HTMLEditSubActionHandler.cpp Bug 1891408 - part 3: Make some callers of `WSScanResult::Point_Deprecated()` use new methods r=m_kato 2024-04-24 06:12:10 +00:00
HTMLEditUtils.cpp Bug 1891408 - part 2: Make `WSScanResult::PointAtContent()` return a point in a text node r=m_kato 2024-04-24 06:12:09 +00:00
HTMLEditUtils.h Bug 1891656 - Make `HTMLEditUtils::GetMostDistantAncestorEditableEmptyInlineElement()` use `Element::FromNode()` r=m_kato 2024-04-25 03:47:41 +00:00
HTMLEditor.cpp Bug 1892376 - Make `EditorBase` and `HTMLEditor` not use `nsDOMAttributeMap` r=peterv,dom-core 2024-04-25 03:49:01 +00:00
HTMLEditor.h Bug 1892376 - Make `EditorBase` and `HTMLEditor` not use `nsDOMAttributeMap` r=peterv,dom-core 2024-04-25 03:49:01 +00:00
HTMLEditorCommands.cpp Bug 1883367 - Disable editor commands for read-only editors. r=masayuki 2024-03-08 17:55:57 +00:00
HTMLEditorController.cpp Bug 1244437 - part 1: Make `HTMLEditUtils::IsFormatNode` check same tags as Chromium does r=m_kato 2023-10-26 03:45:17 +00:00
HTMLEditorController.h
HTMLEditorDataTransfer.cpp Bug 1891408 - part 3: Make some callers of `WSScanResult::Point_Deprecated()` use new methods r=m_kato 2024-04-24 06:12:10 +00:00
HTMLEditorDeleteHandler.cpp Bug 1877513 - Make `HTMLEditor` deletes only preceding lines of right child block if the range starts from start of a line r=m_kato 2024-04-27 00:36:26 +00:00
HTMLEditorDocumentCommands.cpp Bug 1859245 - part 4: Make `HTMLEditor` handle only the new direction mode r=m_kato 2023-10-27 01:57:29 +00:00
HTMLEditorEventListener.cpp Bug 1861231 - Make editor handle user input with original target instead of target r=sefeng,dom-core 2023-11-21 03:58:01 +00:00
HTMLEditorEventListener.h Bug 1856795 - Remove redundant member init r=emilio 2023-10-15 15:29:02 +00:00
HTMLEditorInlines.h Bug 1865729 - part 0: Add logging code of `AutoMoveOneLineHandler` r=m_kato 2023-11-27 01:46:42 +00:00
HTMLEditorNestedClasses.h
HTMLEditorObjectResizer.cpp
HTMLEditorState.cpp Bug 1865729 - part 1: Make `AutoMoveOneLineHandler` make `AutoRangeArray` work with `BlockInlineCheck::UseComputedDisplayOutsideStyle` r=m_kato 2023-11-27 01:46:42 +00:00
HTMLInlineTableEditor.cpp
HTMLStyleEditor.cpp Bug 1891408 - part 2: Make `WSScanResult::PointAtContent()` return a point in a text node r=m_kato 2024-04-24 06:12:09 +00:00
HTMLTableEditor.cpp Bug 1870222 - part 1: Rename `HTMLEditUtils::EmptyCheckOption::IgnoreEditableState` with inverting the meaning r=m_kato 2023-12-25 12:54:06 +00:00
InsertNodeTransaction.cpp
InsertNodeTransaction.h
InsertTextTransaction.cpp
InsertTextTransaction.h
InternetCiter.cpp
InternetCiter.h
JoinNodesTransaction.cpp Bug 1859245 - part 3: Make `JoinNodesTransaction` and `SplitNodeTransaction` handle only the new direction mode r=m_kato 2023-10-27 01:57:29 +00:00
JoinNodesTransaction.h Bug 1859245 - part 3: Make `JoinNodesTransaction` and `SplitNodeTransaction` handle only the new direction mode r=m_kato 2023-10-27 01:57:29 +00:00
ManualNAC.h
MoveNodeTransaction.cpp
MoveNodeTransaction.h
PendingStyles.cpp
PendingStyles.h
PlaceholderTransaction.cpp
PlaceholderTransaction.h
ReplaceTextTransaction.cpp
ReplaceTextTransaction.h
SelectionState.cpp Bug 1859245 - part 4: Make `HTMLEditor` handle only the new direction mode r=m_kato 2023-10-27 01:57:29 +00:00
SelectionState.h Bug 1859245 - part 2: Make `HTMLEditor::DoJoinNodes` and `HTMLEditor::DoSplitNode` handle only the new direction mode r=m_kato 2023-10-27 01:57:29 +00:00
SplitNodeTransaction.cpp Bug 1859245 - part 3: Make `JoinNodesTransaction` and `SplitNodeTransaction` handle only the new direction mode r=m_kato 2023-10-27 01:57:29 +00:00
SplitNodeTransaction.h Bug 1859245 - part 3: Make `JoinNodesTransaction` and `SplitNodeTransaction` handle only the new direction mode r=m_kato 2023-10-27 01:57:29 +00:00
TextEditSubActionHandler.cpp Bug 1858590 - Make `TextEditor::HandleInsertText` stop handling the command for empty string after deleting selection r=m_kato 2023-10-19 03:16:08 +00:00
TextEditor.cpp Bug 1881845 - Remove nsContentCID.h r=smaug,media-playback-reviewers,karlt 2024-03-04 23:41:05 +00:00
TextEditor.h Bug 1839814 - Move `nsIEditor.wrapWidth` to `nsIEditorMailSupport` r=m_kato 2023-06-27 05:47:55 +00:00
TextEditorDataTransfer.cpp Bug 1871135 - Add content analysis support to clipboard operations r=edgar,nika,masayuki,devtools-reviewers 2024-02-13 11:26:48 +00:00
WSRunObject.cpp Bug 1891408 - part 2: Make `WSScanResult::PointAtContent()` return a point in a text node r=m_kato 2024-04-24 06:12:09 +00:00
WSRunObject.h Bug 1891408 - part 2: Make `WSScanResult::PointAtContent()` return a point in a text node r=m_kato 2024-04-24 06:12:09 +00:00
moz.build Bug 1855300 - convert .ini manifests to .toml: batch 11 remaining **/mochitest.ini r=jmaher,geckoview-reviewers,extension-reviewers,valentin,credential-management-reviewers,cookie-reviewers,sgalich,m_kato,robwu 2023-10-13 02:32:24 +00:00