Commit Graph

91 Commits

Author SHA1 Message Date
Masayuki Nakano
66b0ffb0f3 Bug 1770877 - part 23: Clean up callers of AutoRangeArray::SplitTextNodesAtEndBoundariesAndParentInlineElementsAtBoundaries r=m_kato
They at most twice updates the `Selection` right now.  We can make them update
`Selection` once.  And this patch makes the scope of `AutoRangeArray` clearer.

Differential Revision: https://phabricator.services.mozilla.com/D149087
2022-06-21 01:26:20 +00:00
Masayuki Nakano
fe2186dd7f Bug 1770877 - part 22: Move HTMLEditor::CollectEditTargetNodes into AutoRangeArray r=m_kato
And also this moves `HTMLEditor::CollectChildren` to `HTMLEditUtils`.

Differential Revision: https://phabricator.services.mozilla.com/D149086
2022-06-21 01:19:25 +00:00
Masayuki Nakano
989e00f9e6 Bug 1770877 - part 21: Get rid of HTMLEditor::SplitInlinesAndCollectEditTargetNodes r=m_kato
It's callers become messy with this patch.  The following patches try to make
them smaller.

Differential Revision: https://phabricator.services.mozilla.com/D149085
2022-06-21 01:07:10 +00:00
Masayuki Nakano
b788c06be9 Bug 1770877 - part 20: Move HTMLEditor::SplitTextNodesAtRangeEnd and HTMLEditor::SplitParentInlineElementsAtRangeEdges into AutoRangeArray r=m_kato
Although they update the DOM tree with transactions, but for making `HTMLEditor`
smaller, and the following patches makes the related code simpler, we need to
move them into `AutoRangeArray`.

Differential Revision: https://phabricator.services.mozilla.com/D149084
2022-06-20 23:45:02 +00:00
Masayuki Nakano
4aff9ebb83 Bug 1770877 - part 16: Make AutoRangeArray can be initialized with an EditorDOMRangeBase or EditorDOMPointBase r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D149080
2022-06-18 09:53:41 +00:00
Masayuki Nakano
fbef891380 Bug 1770877 - part 13: Move HTMLEditor::CreateRangeExtendedToHardLineStartAndEnd into AutoRangeArray r=m_kato
This patch makes them take `const Element& aEditingHost` so that this patch
becomes bigger than what this patch does.

Differential Revision: https://phabricator.services.mozilla.com/D149077
2022-06-17 08:23:20 +00:00
Masayuki Nakano
5058c3606f Bug 1770877 - part 12: Make HTMLEditor treat array of nsRange with OwningNonNull rather than RefPtr r=m_kato
`AutoRangeArran` uses `OwningNonNull`.  So making the following patch simpler
and smaller, all places should use array of `OwningNonNull<nsRange>` instead of
`RefPtr<nsRange>`.

Differential Revision: https://phabricator.services.mozilla.com/D149076
2022-06-17 07:40:37 +00:00
Masayuki Nakano
85bb52a638 Bug 1770877 - part 10: Move HTMLEditor::SelectBRElementIfCollapsedInEmptyBlock to AutoRangeArray r=m_kato
This must make you feel odd. However, this is a separate patch for making easier
to review the following patches.  This will be a private member of
`AutoRangeArray`.

Differential Revision: https://phabricator.services.mozilla.com/D149074
2022-06-17 05:43:02 +00:00
Masayuki Nakano
d24ff63742 Bug 1770877 - part 6: Get rid of HTMLEditor::SplitInlinesAndCollectEditTargetNodesInOneHardLine r=m_kato
It's used only by `HTMLEditor::MoveOneHardLineContentsWithTransaction` and
it just calls 2 methods with some simple additional error handlings.

I'd like to make `SplitInlinesAndCollectEditTargetNodes` work with
`AutoRangeArray`.  Therefore, I'd like to do this for avoiding to use
`AutoRangeArray` in `HTMLEditor.h`.

Differential Revision: https://phabricator.services.mozilla.com/D149070
2022-06-17 00:50:28 +00:00
Masayuki Nakano
8b7dbfe141 Bug 1772022 - Make EditorBase::DeleteNodeWithTransaction() return NS_ERROR_EDITOR_DESTROYED if so r=m_kato
Its callers check `EditorBase::Destroyed()` with at least adding 4 lines, and
some callers do not check this important state.  So, we should make it check
`Destroyed()` at last and omit the additional error check in the caller sites.

Note that it's a virtual method, but `HTMLEditor` checks whether it's a
removable node or not.  So, we should can merge it into `EditorBase`.  This
patch does it too.

Differential Revision: https://phabricator.services.mozilla.com/D148084
2022-06-03 02:03:47 +00:00
Masayuki Nakano
28cad0d918 Bug 1771809 - Make HTMLEditor::AutoDeleteRangesHandler::HandleDeleteNonCollapsedRanges check if handling range is still editable r=m_kato
In the testcase, editing host is removed when first node removing, but
`HTMLEditor::Destroyed()` still returns `false`.  So, ideally, we should add
a check of editing host validity in `Destroyed()`, but for now, we should make
the method check whether the handling range is still editable after running
each transaction.

Depends on D147723

Differential Revision: https://phabricator.services.mozilla.com/D147724
2022-06-01 05:52:15 +00:00
Masayuki Nakano
5e1c19d493 Bug 1771570 - Make HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::JoinBlockElementsInSameParent check if the joining nodes are expected positions r=m_kato
The reported testcase causes an incompatible behavior with the other browsers,
that is, `selectAll` command without focus in document whose body ends with
editable nodes selects the nodes in the selection root for the focused node (end
of the range in the normal direction).  Therefore, `HTMLEditor` handles deletion
in odd state (without focus handling).  So the root cause is a bug in selection,
but this bug as of the editor module should avoid the try of joining nodes which
are moved by a DOM mutation event listener at the initial deletion.

Differential Revision: https://phabricator.services.mozilla.com/D147623
2022-05-31 23:20:33 +00:00
Masayuki Nakano
71411e3fb4 Bug 1771448 - part 4: Rename HTMLEditor::GetActiveEditingHost to ComputeEditingHost r=m_kato
It's currently computes the corresponding editing host from the focus node of
`Selection` with climbing up the DOM tree.  So, it does not just return a stored
element.  Therefore, some callers use it multiple times.  For avoiding it, we
should rename it to explain that it computes the editing host.

Note that I think that we should make it takes a node to compute editing host
without `Selection` for solving the case of no selection ranges.  Therefore,
I don't like to include more information into the name.

Differential Revision: https://phabricator.services.mozilla.com/D147504
2022-05-31 03:41:01 +00:00
Masayuki Nakano
5e962c88c5 Bug 1770874 - part 1: Make some clean ups around EditorBase::OnFocus r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D147137
2022-05-27 03:47:33 +00:00
Masayuki Nakano
b634d8169d Bug 1766355 - part 6: Make HTMLEditor::MoveOneHardLineContents return MoveNodeResult with caret point suggestion r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146402
2022-05-20 08:51:41 +00:00
Masayuki Nakano
fda3a43b66 Bug 1766355 - part 5: Make HTMLEditor::MoveChildrenWithTransaction and HTMLEditor::MoveNodeOrChildrenWithTransaction stop touching Selection directly r=m_kato
Unfortunately, they call each other.  Therefore, this patch updates these 2
methods once.

Differential Revision: https://phabricator.services.mozilla.com/D146401
2022-05-20 08:40:59 +00:00
Masayuki Nakano
7bfa21cc89 Bug 1766355 - part 4: Make HTMLEditor::MoveNodeWithTransaction and HTMLEditor::MoveNodeToEndWithTransaction return MoveNodeResult r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146400
2022-05-20 08:28:09 +00:00
Masayuki Nakano
c1a368b6a5 Bug 1766355 - part 3: Make MoveNodeResult store caret point suggestion r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146399
2022-05-20 08:28:09 +00:00
Masayuki Nakano
bfaa50661a Bug 1766355 - part 2: Make MoveNodeResult method names alinging to Result r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146398
2022-05-20 08:28:08 +00:00
Kagami Sascha Rosylight
2b3baf8dfe Bug 1767998 - Apply readability-make-member-function-const on editor/libeditor r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D145626
2022-05-13 05:35:25 +00:00
Masayuki Nakano
dfde4fb973 Bug 1762115 - part 10: Make HTMLEditor::InsertBRElement stop touching Selection directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D144653
2022-05-03 01:03:05 +00:00
Masayuki Nakano
54bb966fad Bug 1765018 - part 7: Make some methods which return an instance (not reference) of EditorDOMPointBase be template methods r=m_kato
For avoiding to use `To<EditorDOMPoint>()` etc from temporary object, such
methods should be templated.

Differential Revision: https://phabricator.services.mozilla.com/D143884
2022-04-20 23:58:04 +00:00
Masayuki Nakano
083c6837d0 Bug 1765018 - part 2: Make EditorBase::Get(Start|End)Point return EditorDOMPoint or EditorRawDOMPoint r=m_kato
This avoids unnecessary conversion at the callers' side, although they should be
omitted by the complier.

Differential Revision: https://phabricator.services.mozilla.com/D143879
2022-04-20 23:35:18 +00:00
Masayuki Nakano
cd80bdce17 Bug 1765018 - part 1: Get rid of implicit conversion between EditorDOMPointBase instances r=m_kato
The implicit copy constructors and `operator=` makes it harder to realize
that implicit conversion wastes the runtime cost.  Therefore, this patch
replaces them with a template method to convert the `EditorDOMPointBase` type.

Differential Revision: https://phabricator.services.mozilla.com/D143878
2022-04-20 22:41:02 +00:00
Masayuki Nakano
a8350c4163 Bug 1764684 - part 3: Fix and improve warnings of the result of EditorBase::CollapseSelectionTo* r=m_kato
Some of them were `HTMLEditor` so that we need to fix it to `EditorBase`, and
also this patch fixes `NS_ERROR_EDITOR_DESTROYED` handling around them.

Differential Revision: https://phabricator.services.mozilla.com/D143815
2022-04-20 14:36:53 +00:00
Masayuki Nakano
57ba857907 Bug 1764684 - part 2: Make editor use methods of EditorBase to collapse Selection r=m_kato
First, move methods of `HTMLEditor` which collapse `Selection` to `EditorBase`.
Then, make editor stop accessing `Selection::CollapseInLimiter` directly.

Differential Revision: https://phabricator.services.mozilla.com/D143814
2022-04-20 14:36:52 +00:00
Masayuki Nakano
320035af5a Bug 1764679 - Make GetInterlinePosition and SetInterlinePosition work with new enum class r=smaug
It's hard to remember what the `bool` value of them means.  Therefore, there
are a lot of comment around the API users to explain what they do.  For making
it clearer and reducing the risk of specifying opposite value, they should work
with an `enum class`.

Differential Revision: https://phabricator.services.mozilla.com/D143812
2022-04-20 14:24:55 +00:00
Masayuki Nakano
30a421d031 Bug 1761395 - part 4: Rewrite HTMLEditor::SplitMailCiteElements r=m_kato
This patch renames it to `HandleInsertParagraphInMailCiteElement` to explain
what it does clearer.  And make it takes most-distant ancestor mail-cite
element to avoid the situation that it does nothing.

Then, this is rewritten to just return new caret position where is new
`<br>` element which is inserted at the split point.

Then, only the last block is changed to refer the split node result to
avoid deleting same node in the case of new split direction.

Differential Revision: https://phabricator.services.mozilla.com/D142415
2022-04-05 06:53:23 +00:00
Masayuki Nakano
0a637c3bb8 Bug 1742933 - part 4: Make HTMLEditor::CreateAndInsertElementWithTransaction() and HTMLEditor::InsertBRElementWithTransaction() work without transactions r=m_kato
At initializing new element which has not been connected, undo transactions
are not necessary because just removing the new element gets same result for
users.  Therefore, they should be able to work without transactions.

Differential Revision: https://phabricator.services.mozilla.com/D140468
2022-03-11 07:18:48 +00:00
Masayuki Nakano
25e9c8e84e Bug 1751679 - Make WhiteSpaceVisibilityKeeper::MergeFirstLineOfRightBlockElementIntoAncestorLeftBlockElement track DOM points while the DOM tree is being changed r=m_kato
The method caches a DOM point, but it is not tracked correctly.

This patch adds some validations into it and one of its callee,
`HTMLEditor::MoveOneHardLineContents`.  Additionally, making
`EditorDOMPointBase::Offset` avoid accessing `Maybe`'s storage when it's
`Nothing` in release builds as the last resort.

Differential Revision: https://phabricator.services.mozilla.com/D136994
2022-02-09 00:45:33 +00:00
Masayuki Nakano
c5f1db7b0e Bug 1752914 - part 2: Make HTMLEditor sanitize selection ranges in native anonymous subtrees before handling them r=m_kato
Due to a Selection API's bug, `Selection::Modify` may move selection into
native anonymous subtree.  Although it should be fixed in the side, but
`HTMLEditor` should make range boundaries climb up to outside native anonymous
subtrees.

Depends on D137526

Differential Revision: https://phabricator.services.mozilla.com/D137527
2022-02-04 13:21:04 +00:00
Masayuki Nakano
673b50d4b1 Bug 1752914 - part 1: Clean up some methods which consider where are a line r=m_kato
Those methods use `RangeBoundary` or `RangeBoundaryBase`, and it makes reading
the code harder because of poor API comparing from `EditorDOMPointBase`, and
anyway they are converted to `EditorDOMPointBase`.

Therefore, they should take `EditorDOMPointBase` or `EditorDOMRangeBase`
instead.

Differential Revision: https://phabricator.services.mozilla.com/D137526
2022-02-04 13:21:04 +00:00
Masayuki Nakano
f9aa26eee1 Bug 1750588 - Make AutoBlockElementsJoiner handle deletion even when there is no ancestor block element of start or end range boundary r=m_kato
`HTMLEditor` assumes that inline elements cannot have block elements.  However,
it's not so if it's created by DOM APIs like `Node.appendChild` or making a
custom element an editing host.

Therefore, it's not unexpected case that only start or end of a range does not
have a block ancestor element.  So this patch makes `AutoBlockElementsJoiner`
not stop handling the deletion in the case.

Differential Revision: https://phabricator.services.mozilla.com/D136698
2022-01-25 02:37:50 +00:00
Masayuki Nakano
05d0e158a9 Bug 1742748 - Make HTMLEditor::JoinNodesWithTransaction() return JoinNodesResult r=m_kato
This patch implements `JoinNodesResult` class which callers of
`JoinNodesWithTransaction()` can access removed node, existing (joined) node and
joined point with logical named accessors, and makes
`JoinNodesWithTransaction()` return it.

Then, the callers don't need to change at fixing bug 1735608.

Differential Revision: https://phabricator.services.mozilla.com/D132120
2021-11-27 00:05:54 +00:00
Masayuki Nakano
a0cf8d6695 Bug 1739315 - part 2: Make HTMLEditor::JoinNodesWithTransaction() return error if failed r=m_kato
Now, it does not notify nobody before joining the nodes.  Therefore, it can
return error immediately if it fails to create a transaction to join the given
nodes.

Additionally, this patch makes it return `NS_ERROR_EDITOR_DESTROYED` if the
editor is destroyed while it handles to join nodes.  Therefore, we can get rid
of the check by the callers.

Differential Revision: https://phabricator.services.mozilla.com/D130349
2021-11-05 10:14:35 +00:00
Cristian Tuns
c405d2246e Backed out 2 changesets (bug 1739315) for causing android wpt failures.
Backed out changeset cef70047defb (bug 1739315)
Backed out changeset c50c8ac11ff7 (bug 1739315)
2021-11-05 07:18:22 -04:00
Masayuki Nakano
f7e7696a42 Bug 1739315 - part 2: Make HTMLEditor::JoinNodesWithTransaction() return error if failed r=m_kato
Now, it does not notify nobody before joining the nodes.  Therefore, it can
return error immediately if it fails to create a transaction to join the given
nodes.

Additionally, this patch makes it return `NS_ERROR_EDITOR_DESTROYED` if the
editor is destroyed while it handles to join nodes.  Therefore, we can get rid
of the check by the callers.

Differential Revision: https://phabricator.services.mozilla.com/D130349
2021-11-05 10:14:35 +00:00
Masayuki Nakano
1f4011043d Bug 1737540 - Make AutoBlockElementsJoiner::PrepareToDeleteNonCollapsedRanges() consider to delete given range when there is no editable block parent r=m_kato
Currently, it assumes that first range is always in editable block parent,
but if the range is in an inline editing host, it's not true.

The given ranges should always be in same editing host at this time because of:
* https://searchfox.org/mozilla-central/rev/011ed92913b38e950977ab3fc56ae68a8f3bca12/editor/libeditor/HTMLEditorDeleteHandler.cpp#1031,1064
* https://searchfox.org/mozilla-central/rev/011ed92913b38e950977ab3fc56ae68a8f3bca12/editor/libeditor/HTMLEditorDeleteHandler.cpp#1080,1117

Therefore, it's enough to check whether the range crosses or not editing host
boundaries only with `MOZ_ASSERT(_IF)`.

Differential Revision: https://phabricator.services.mozilla.com/D130153
2021-11-04 08:05:02 +00:00
Masayuki Nakano
11f4aec3e5 Bug 1672900 - part 3: Make ExtendOrShrinkRangeToDelete() selects all contents in all list items if a list element is selected or all list items in a list element is selected r=m_kato
When a list element has non-empty list item element, even if the list element is
selected, deleting operation should make the list element empty first (i.e.,
making the list element has only one empty list item element).  Then, another
deleting operation/command can delete it completely.  This is Blink compat
behavior in most cases except when the list has non-editable list item element
as first and/or last child of it.

Note that the new failures of the browserscpe are not compatible with the
new behavior, that is, it wants a list element is deleted when the last
list item is deleted.
https://searchfox.org/mozilla-central/rev/08c493902519265d570250c8e7ce575c8cd6f5b5/editor/libeditor/tests/browserscope/lib/richtext2/richtext2/tests/delete.py#161-164
https://searchfox.org/mozilla-central/rev/08c493902519265d570250c8e7ce575c8cd6f5b5/editor/libeditor/tests/browserscope/lib/richtext2/richtext2/tests/forwarddelete.py#146-149

Here is same test in the WPT:
https://searchfox.org/mozilla-central/rev/08c493902519265d570250c8e7ce575c8cd6f5b5/testing/web-platform/tests/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html#386-402
And only Gecko failed in this case:
https://searchfox.org/mozilla-central/rev/08c493902519265d570250c8e7ce575c8cd6f5b5/testing/web-platform/meta/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html.ini#1449-1450
https://searchfox.org/mozilla-central/rev/08c493902519265d570250c8e7ce575c8cd6f5b5/testing/web-platform/meta/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html.ini#1937-1938
https://searchfox.org/mozilla-central/rev/08c493902519265d570250c8e7ce575c8cd6f5b5/testing/web-platform/meta/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html.ini#425-426
https://searchfox.org/mozilla-central/rev/08c493902519265d570250c8e7ce575c8cd6f5b5/testing/web-platform/meta/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html.ini#787-788

https://wpt.fyi/results/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html%3FDelete,ol?run_id=5734231113203712&run_id=6263979761467392&run_id=5750388243300352&run_id=5090688355008512
https://wpt.fyi/results/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html%3FDelete,ul?run_id=5734231113203712&run_id=6263979761467392&run_id=5750388243300352&run_id=5090688355008512
https://wpt.fyi/results/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html%3FBackspace,ol?run_id=5734231113203712&run_id=6263979761467392&run_id=5750388243300352&run_id=5090688355008512
https://wpt.fyi/results/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html%3FBackspace,ul?run_id=5734231113203712&run_id=6263979761467392&run_id=5750388243300352&run_id=5090688355008512

Therefore, the new failures are expected result.

Depends on D125029

Differential Revision: https://phabricator.services.mozilla.com/D125030
2021-09-11 07:17:38 +00:00
Masayuki Nakano
9fb5315fbe Bug 1672900 - part 2: Rewrite HTMLEditor::AutoDeleteRangesHandler::ExtendRangeToIncludeInvisibleNodes() with modern helper classes r=m_kato
And this renames the method to `ExtendOrShrinkRangeToDelete` for alining to
new behavior changed by the following patch.

Depends on D125028

Differential Revision: https://phabricator.services.mozilla.com/D125029
2021-09-11 07:17:37 +00:00
Masayuki Nakano
250f1ae5fb Bug 1724650 - part 5: Make delete text handler aware of white-space: pre-line r=m_kato
If caret is put at preformatted linefeed, we need to handle adjacent
collapsible white-spaces too if the style is `white-space: pre-line`.
Therefore, this patch makes the delete handler aware of the case only
linefeed characters are preformatted and `AutoDeleteRangesHandler` call it
when caret is around a preformatted line break.

Differential Revision: https://phabricator.services.mozilla.com/D124559
2021-09-10 04:04:29 +00:00
Masayuki Nakano
a7b84516b4 Bug 1729111 - part 3: Rewrite HTMLEditUtils::IsVisibleTextNode() without WSRunScanner r=m_kato
`WSRunScanner` is designed for scanning editable nodes, but
`IsVisibleTextNode()` should not check editable state.  Therefore, it should
check it without `WSRunScanner` like `IsVisibleBRElement()`.

Differential Revision: https://phabricator.services.mozilla.com/D124554
2021-09-07 07:24:50 +00:00
Masayuki Nakano
b5682cf833 Bug 1727868 - Make HTMLEditUtils::IsVisibleBRElement() stop using WSRunScanner r=m_kato
The method may be used for checking a `<br>` element visibility in non-editable
content too.  Therefore, using `WSRunScanner` which is designed for scanning
editable content hits assertions.

The visibility of `<br>` element is considered only with the following
visible thing.  If it's followed only by another or current block boundary,
the `<br>` element is invisible.  But otherwise, it's visible.  So, it needs
to scan following contents to look for first visible thing until reaching
a block boundary.  And it does not need to check its previous content.

Differential Revision: https://phabricator.services.mozilla.com/D123876
2021-09-06 22:31:22 +00:00
Masayuki Nakano
5d2f328ac7 Bug 1727844 - part 5: Rename some scan result related members in WSRunObject.h r=m_kato
Currently, it uses "normal text" and "normal white-spaces" for naming
`enum class` members and their accessors.  However, this is unclear what
does the normal mean since the word depends on context.

Therefore, this patch replaces the former with "non-collapsible characters" and
the latter is "collapsible white-spaces".

Differential Revision: https://phabricator.services.mozilla.com/D123872
2021-08-31 17:37:41 +00:00
Masayuki Nakano
f09046d90e Bug 1727185 - Add MOZ_DIAGNOSTIC_ASSERT to the constructors of DeleteNodeTransaction and SplitNodeTransaction and make their users return error before hitting it r=m_kato
On Thunderbird, we still have a bug to delete `<html>` and `<body>` elements
(bug 1727201).  However, it's hard to know where deletes the unexpected elements
from warning messages in the log.  Additionally, it's really serious bug
because editor and layout code rely on the basic structure of HTML document.
Therefore, we should block the worst scenario before deleting such nodes.

Differential Revision: https://phabricator.services.mozilla.com/D123418
2021-08-25 00:39:41 +00:00
Masayuki Nakano
204c7599a5 Bug 1727008 - HTMLEditor shouldn't strip <html> element nor <body> elements r=m_kato
The new editor utility method does not stop scanning editable elements even if
it reaches the document root nor the (primary) `<body>` element.  Of course,
they should stop there if scanning editable block.  And
`ScanEmptyBlockInclusiveAncestor()` shouldn't store the removable empty block
element to them.

Differential Revision: https://phabricator.services.mozilla.com/D123316
2021-08-23 10:05:32 +00:00
Masayuki Nakano
bc5ee41c80 Bug 1726064 - part 14: Make AutoDeleteRangesHandler::ExtendRangeToIncludeInvisibleNodes() use HTMLEditUtils::GetInclusiveAncestorElement() r=m_kato
I have no idea how to test this without making unrealistic cases with legacy
mutation event listeners because now, Gecko ignores selection ranges which
crosses editing host boundaries when it tries to delete selection.
* https://searchfox.org/mozilla-central/rev/d3683dbb252506400c71256ef3994cdbdfb71ada/editor/libeditor/HTMLEditorDeleteHandler.cpp#1120
* https://searchfox.org/mozilla-central/rev/d3683dbb252506400c71256ef3994cdbdfb71ada/editor/libeditor/EditorUtils.cpp#137
* https://searchfox.org/mozilla-central/rev/d3683dbb252506400c71256ef3994cdbdfb71ada/editor/libeditor/EditorUtils.cpp#119-125

And invisible white-spaces appear end of a block or start of a block, i.e.,
both block parents in the range boundaries are always editable in normal cases.
So, such range should be ignored first.

Depends on D123067

Differential Revision: https://phabricator.services.mozilla.com/D123068
2021-08-22 21:32:21 +00:00
Masayuki Nakano
432e08d5f2 Bug 1726064 - part 13: Make AutoEmptyBlockAncestorDeleter::ScanEmptyBlockInclusiveAncestor() use HTMLEditUtils::Get(Inclusive)AncestorElement() r=m_kato
Additionally, the given content may be in a nested editing host.  Then, this
method may delete a nested-block editing host if it's empty.  Therefore,
this patch get rid of `aEditingHost` and check same thing with
`HTMLEditUtils::IsRemovableFromParentNode()`.

Depends on D123066

Differential Revision: https://phabricator.services.mozilla.com/D123067
2021-08-21 21:28:52 +00:00
Masayuki Nakano
a745f2faa2 Bug 1726064 - part 12: Make HTMLEditor::CanMoveOrDeleteSomethingInHardLine() use HTMLEditUtils::GetInclusiveAncestorElement() r=m_kato
I have no idea how to test this, but I believe that checking non-editable
block element must be correct here because it checks whether the block is
empty or not for merging lines.

Depends on D123029

Differential Revision: https://phabricator.services.mozilla.com/D123066
2021-08-21 21:28:52 +00:00
Masayuki Nakano
4f5c0ee32a Bug 1726064 - part 11: Make AutoBlockElementsJoiner::PrepareToDeleteNonCollapsedRanges() use HTMLEditUtils::GetInclusiveAncestorElement() r=m_kato
I have no idea how to test this without making unrealistic cases with legacy
mutation event listeners because now, Gecko ignores selection ranges which
crosses editing host boundaries when it tries to delete selection.
* https://searchfox.org/mozilla-central/rev/d3683dbb252506400c71256ef3994cdbdfb71ada/editor/libeditor/HTMLEditorDeleteHandler.cpp#1120
* https://searchfox.org/mozilla-central/rev/d3683dbb252506400c71256ef3994cdbdfb71ada/editor/libeditor/EditorUtils.cpp#137
* https://searchfox.org/mozilla-central/rev/d3683dbb252506400c71256ef3994cdbdfb71ada/editor/libeditor/EditorUtils.cpp#119-125

So, `aRangesToDelete.FirstRangeRef()` shouldn't be in different editing host.

Depends on D122948

Differential Revision: https://phabricator.services.mozilla.com/D123029
2021-08-21 06:55:16 +00:00