Граф коммитов

10933 Коммитов

Автор SHA1 Сообщение Дата
Masayuki Nakano be8f718db4 Bug 1742933 - part 7: Make `HTMLEditor::ChangeSelectedHardLinesToList()` insert list item into the new list element before connected to the DOM tree r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D140471
2022-03-11 07:43:06 +00:00
Masayuki Nakano 1d03bba6fd Bug 1742933 - part 6: Make `HTMLEditor::HandleInsertParagraphInListItemElement()` insert `<br>` element into the new paragraph before connecting to the DOM tree r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D140470
2022-03-11 07:26:03 +00:00
Masayuki Nakano c677c96b0a Bug 1742933 - part 5: Make `HTMLEditor::HandleInsertParagraphInHeadingElement()` insert `<br>` element into the new paragraph before connecting to the DOM tree r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D140469
2022-03-11 07:26:03 +00:00
Masayuki Nakano 5ffc15f39d 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 b17c5766d4 Bug 1742933 - part 3: Make `HTMLEditor::AlignBlockContentsWithDivElement` set `align` attribute or equivalent before inserting a new `<div>` into the DOM tree r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D140467
2022-03-11 07:11:59 +00:00
Masayuki Nakano 6ba81cec0c Bug 1742933 - part 2: Make `HTMLEditor::CopyLastEditableChildStylesWithTransaction` clone attributes to new elements before inserting them into the DOM tree r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D140466
2022-03-11 06:59:37 +00:00
Masayuki Nakano 6eaf1c971a Bug 1742933 - part 1: Make `HTMLEditor::CreateAndInsertElementWithTransaction()` take a callback function r=m_kato
For making initializing new element safer and faster, it's better to initialize
new element's attributes and appending children before inserting the new element
into the DOM tree.

Differential Revision: https://phabricator.services.mozilla.com/D140465
2022-03-11 06:28:36 +00:00
Masayuki Nakano 45ba6f356a Bug 1753508 - Add logger of selection batch r=smaug
This was required for debugging the bug.

Differential Revision: https://phabricator.services.mozilla.com/D139350
2022-03-11 02:24:24 +00:00
Masayuki Nakano 5ee6119ad5 Bug 1753508 - Make `EditorBase::AutoEditActionDataSetter::UpdateSelectionCache` clean up and restart selection batch which the editor started r=smaug
When `Selection` instance is updated, the old selection may be in batch.
In the case, `UpdateSelectionCache` should clean up the batch in the old
selection and start new one in the new selection instead.

Differential Revision: https://phabricator.services.mozilla.com/D139349
2022-03-11 02:24:24 +00:00
Masayuki Nakano cd0edef773 Bug 1757911 - part 4: Make `HTMLEditor::DoSplitNode` notify `RangeUpdater` r=m_kato
Similar to the previous patch, in the splitting a node case,
`SplitNodeWithTransaction` notifies `RangeUpdater`.  Currently, this must not
cause any trouble, but for consistency with `DoJoinNodes`, `DoSplitNode` does
it instead.

Different from the previous patch, `SelAdjSplitNode` is not called if splitting
the node fails.  Therefore, it's enough to do it at end of `DoSplitNode`.

Differential Revision: https://phabricator.services.mozilla.com/D140464
2022-03-10 10:33:06 +00:00
Masayuki Nakano 4d64d5b9c5 Bug 1757911 - part 3: Make `HTMLEditor::DoJoinNodes()` notify `RangeUpdater` r=m_kato
Currently, it's notified by `JoinNodesTransaction::DoTransactionInternal` so
that it's `SplitNodeTransaction::UndoTransaction` cannot track the DOM point
and this might cause odd editing result if `execCommand("undo")` is called
while `HTMLEditor` handles an edit action.

For avoiding to duplicate the code, it should be handled in
`HTMLEditor::DoJoinNodes`.

Differential Revision: https://phabricator.services.mozilla.com/D140463
2022-03-10 10:27:54 +00:00
Masayuki Nakano 3ea16616b3 Bug 1757911 - part 2: Make `SplitNodeTransaction::DoTransaction` and `RedoTransaction` share the code doing split r=m_kato
They have duplicated code so that they should be merged to a new internal
method.

Differential Revision: https://phabricator.services.mozilla.com/D140462
2022-03-10 10:19:07 +00:00
Masayuki Nakano b8aa50dce7 Bug 1757911 - part 1: Clean up `SplitNodeTransaction` r=m_kato
First, it should not store split point with `EditorDOMPoint` because it has
child node pointer and other flags but they are never used and they make
the footprint worse.  Therefore, this patch makes it exactly same structure
as `JoinNodesTransaction`.

Additionally, this patch removes "left" and "right" words especially from
the member names and variable names (preparation of bug 1735608).

Differential Revision: https://phabricator.services.mozilla.com/D140461
2022-03-10 10:09:44 +00:00
Iulian Moraru 75b7b365b1 Backed out 4 changesets (bug 1757911) for causing build bustages on HTMLEditor.cpp.
Backed out changeset 0a12415ff7cf (bug 1757911)
Backed out changeset 1edde90f24cc (bug 1757911)
Backed out changeset 64ae36546100 (bug 1757911)
Backed out changeset e0e951dc9594 (bug 1757911)
2022-03-10 06:24:41 +02:00
Masayuki Nakano 01a64471f8 Bug 1757911 - part 4: Make `HTMLEditor::DoSplitNode` notify `RangeUpdater` r=m_kato
Similar to the previous patch, in the splitting a node case,
`SplitNodeWithTransaction` notifies `RangeUpdater`.  Currently, this must not
cause any trouble, but for consistency with `DoJoinNodes`, `DoSplitNode` does
it instead.

Different from the previous patch, `SelAdjSplitNode` is not called if splitting
the node fails.  Therefore, it's enough to do it at end of `DoSplitNode`.

Depends on D140463

Differential Revision: https://phabricator.services.mozilla.com/D140464
2022-03-09 23:21:46 +00:00
Masayuki Nakano 90c5367987 Bug 1757911 - part 3: Make `HTMLEditor::DoJoinNodes()` notify `RangeUpdater` r=m_kato
Currently, it's notified by `JoinNodesTransaction::DoTransactionInternal` so
that it's `SplitNodeTransaction::UndoTransaction` cannot track the DOM point
and this might cause odd editing result if `execCommand("undo")` is called
while `HTMLEditor` handles an edit action.

For avoiding to duplicate the code, it should be handled in
`HTMLEditor::DoJoinNodes`.

Depends on D140462

Differential Revision: https://phabricator.services.mozilla.com/D140463
2022-03-09 23:14:37 +00:00
Masayuki Nakano 99b538b91e Bug 1757911 - part 2: Make `SplitNodeTransaction::DoTransaction` and `RedoTransaction` share the code doing split r=m_kato
They have duplicated code so that they should be merged to a new internal
method.

Depends on D140461

Differential Revision: https://phabricator.services.mozilla.com/D140462
2022-03-09 23:06:44 +00:00
Masayuki Nakano f090b297c5 Bug 1757911 - part 1: Clean up `SplitNodeTransaction` r=m_kato
First, it should not store split point with `EditorDOMPoint` because it has
child node pointer and other flags but they are never used and they make
the footprint worse.  Therefore, this patch makes it exactly same structure
as `JoinNodesTransaction`.

Additionally, this patch removes "left" and "right" words especially from
the member names and variable names (preparation of bug 1735608).

Differential Revision: https://phabricator.services.mozilla.com/D140461
2022-03-09 22:35:07 +00:00
Masayuki Nakano ef3106ee6b Bug 1757492 - part 2: Clean up `HTMLEditor::DoSplitNode` r=m_kato
This patch just cleans up the method code for making the changes for bug 1735608
simpler.  This does not change any behavior.

Depends on D140010

Differential Revision: https://phabricator.services.mozilla.com/D140011
2022-03-02 11:55:06 +00:00
Masayuki Nakano 5bbb9ea55a Bug 1757492 - part 1: Clean up `HTMLEditor::DoJoinNodes` r=m_kato
This patch just cleans up the method code for making the changes for bug 1735608
simpler.  This does not change any behavior.

Differential Revision: https://phabricator.services.mozilla.com/D140010
2022-03-02 11:55:05 +00:00
Masayuki Nakano ce7e13d87c Bug 1745877 - Get rid of `CreateElementTransaction` r=m_kato
It's already disabled since 96 and now is late 97 cycle in the release channel,
but I've not gotten regression reports about this.  Therefore, we should get
rid of it from the tree completely, then, we can make
`HTMLEditor::CreateAndInsertElementWithTransaction` greater for its callers.

Depends on D139717

Differential Revision: https://phabricator.services.mozilla.com/D139718
2022-02-28 23:27:58 +00:00
Masayuki Nakano b9c8d78864 Bug 1756933 - part 3: Clean up `HTMLEditor::JoinNodesWithTransaction()` r=m_kato
This push some post processing of joining nodes into `JoinNodesTransaction` and
`HTMLEditor::DidJoinNodes()` to make `HTMLEditor::JoinNodesTransaction()`
simpler and the new method does not use the "left"/"right" words at post
processing.

This changes the logic a bit so that it may change some behavior if web apps
uses some legacy mutation events, but it must be rare case because the other
browsers don't fire them synchronously.

Depends on D139716

Differential Revision: https://phabricator.services.mozilla.com/D139717
2022-02-28 23:22:25 +00:00
Masayuki Nakano 45b8401d88 Bug 1756933 - part 2: Clean up `JoinNodesTransaction` members and variables r=m_kato
This patch renames members and variables in it not to use "left" and "right"
words to preparing to support both direction joining.  So this patch does not
change any behavior.

Depends on D139715

Differential Revision: https://phabricator.services.mozilla.com/D139716
2022-02-28 23:03:51 +00:00
Masayuki Nakano 0dd96f96d3 Bug 1756933 - part 1: Rename `JoinNodeTransaction` to `JoinNodesTransaction` r=m_kato
For consistency with the other things in editor module, it should be "nodes"
rather than "node" since 2 nodes are joined by it.

Differential Revision: https://phabricator.services.mozilla.com/D139715
2022-02-28 23:03:51 +00:00
Masayuki Nakano 9874524dd5 Bug 1755104 - Make `EditorEventListener::Focus` check whether the event target still has focus even after flushing the pending things r=m_kato
When the `focus` event listener of editors which is in the system group runs,
a preceding `focus` event listener may have already blurred the focused element,
but it may have not been applied to the DOM tree yet.  In this case, checking
whether the editor still has focus or has already blurred without flushing the
pending things does not make sense.  Therefore, this patch makes the `Focus`
do it first.

Note that this patch adds 3 crash tests, but only the `<textarea>` case crashes
without this patch.  The others are only for detecting new regressions.

Differential Revision: https://phabricator.services.mozilla.com/D139089
2022-02-21 01:04:43 +00:00
Masayuki Nakano b5778bbaf4 Bug 1755614 - Clean up test_contenteditable_focus.html r=m_kato
It's not split to each chunk with IIFE nor the message explain what is the
expected result.  This just rewrites it without changing what's are tested
except adding a call of `testFocusMove` with `<button>` in the main editor
(i.e., editable button).

Depends on D138876

Differential Revision: https://phabricator.services.mozilla.com/D138877
2022-02-17 06:10:43 +00:00
Norisz Fay eef7d5c5ac Backed out changeset 00f6bd7aa727 (bug 1755481) for causing multiple clipboard related failures CLOSED TREE 2022-02-16 12:14:58 +02:00
Mirko Brodesser 8aa76ff1d7 Bug 1755481: rename `nsIClipboard::getData` to `nsIClipboard::getSomeData` and document it. r=mccr8
Before, it was confusing. One could have assumed that the method gets
the data for all flavors.

Differential Revision: https://phabricator.services.mozilla.com/D138776
2022-02-16 09:03:00 +00:00
Masayuki Nakano 4e5ab7b4f1 Bug 1191862 - part 2: Make `TextEventDispatcher` store writing mode at selection at receiving focus notification r=m_kato
Querying selection for getting writing mode may run script in the main process
if focus is in it.  For avoiding new users of writing mode at selection **only**
when the value is required during an editable content has focus,
`TextEventDispatcher` should always store writing mode at receiving focus
notification.

Differential Revision: https://phabricator.services.mozilla.com/D138008
2022-02-15 08:00:06 +00:00
Masayuki Nakano d450beac6f Bug 1191862 - part 1: Make `nsIWidget::NativeKeyBindingsType` independent from `nsIWidget` and defined in an independent header file r=smaug
I'd like to use it in `IMEData.h`.  However, adding new include into it may
cause bustage with MinGW, and it's included by `nsIWidget.h` because `nsIWidget`
requires some classes defined in `IMEData.h`.  Therefore, I'd like to make a
new header file for avoiding the include hell.

Differential Revision: https://phabricator.services.mozilla.com/D138007
2022-02-15 08:00:05 +00:00
Emilio Cobos Álvarez 5fed8de04b Bug 1754547 - Generalize moz-os-version into moz-platform. r=dao,preferences-reviewers,Gijs
Allow differentiating non-windows platforms on it.

Differential Revision: https://phabricator.services.mozilla.com/D138431
2022-02-10 15:50:31 +00:00
Masayuki Nakano d5ed5e0fc6 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 175d6b758f 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 9eb106ad73 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 8d88df10f6 Bug 1718825 - Treat strong pointers which are members of class/struct and marked as `MOZ_KNOWN_LIVE` as safe r=andi
`MOZ_KNOWN_LIVE RefPtr<Foo> mFoo` is not treated as safe because its raw pointer
is referred with operators but they are not checked at handling `MOZ_KNOWN_LIVE`
annotation.

Additionally, when members marked as `MOZ_KNOWN_LIVE` are in the stack, they
are also not treated as safe, but they should be safe in most cases.

With these changes, `HTMLTableEditor.cpp` can get rid of a lot of
`MOZ_KnownLive` method calls.

Differential Revision: https://phabricator.services.mozilla.com/D136122
2022-02-02 00:48:19 +00:00
Masayuki Nakano 6455ee48a9 Bug 787434 - part 2: Make `HTMLWithContextInserter::FragmentFromPasteCreator` delete incomplete list elements in the inserting fragment r=mbrodesser
With the change of the previous patch, `HTMLEditor` won't delete empty elements
in the inserted HTML content.  However, at bug 1123505, it intentionally tried
to delete empty list elements which have no list item elements since such
list elements won't be editable.  Therefore, the following patch makes some
tests in `test_copypaste.html` fail.
https://searchfox.org/mozilla-central/rev/3de56eb5f266f523340e739ae1b53258e0a95dfe/dom/base/test/copypaste.js#343,360
Unfortunately, the broken behavior is compatible with Chrome (Chrome accept
list elements which have no list item elements), but it does not make sense for
Gecko's builtin editor.  Therefore, I think that we should keep our traditional
behavior with deny-list.

This patch makes `FragmentFromPasteCreator` delete list elements which have no
list item elements and are empty from the inserting document fragment.

Differential Revision: https://phabricator.services.mozilla.com/D136211
2022-02-02 00:44:54 +00:00
Masayuki Nakano 717c987979 Bug 787434 - part 1: Make `HTMLEditor` stop removing empty elements of inserted content r=m_kato
This is same issue as bug 1747008, but the remover is different method, that is
`HTMLEditor::RemoveEmptyNodesIn` called by
`HTMLEditor::OnEndHandlingTopLevelEditSubActionInternal`.  It should be called
only when the flag which was added by bug 1747008 is **not** set to `false`.

Differential Revision: https://phabricator.services.mozilla.com/D136210
2022-02-02 00:44:53 +00:00
Masayuki Nakano 6d4e0eb4b8 Bug 1752462 - Make `HTMLEditor::ChangeSelectedHardLinesToList` refer result of inserting list item element rather than list element after inserting it r=m_kato
This is a simple mistake.  When it should refer inserting a list item element
result, it refers inserting a list element result instead.

Differential Revision: https://phabricator.services.mozilla.com/D137393
2022-02-01 08:12:00 +00:00
Masayuki Nakano ac9f764110 Bug 1752668 - Restore null-check in `HTMLEditor::ClearStyleAt` r=m_kato
I don't remember why I removed the null-check in
https://phabricator.services.mozilla.com/D131748#change-Q0aewmYc3vaK

Restoring the null-check should be fine.

Differential Revision: https://phabricator.services.mozilla.com/D137395
2022-01-31 17:15:35 +00:00
Masayuki Nakano 12906aa987 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
Joel Maher 643350a75a Bug 1751325 - Run mochitest-plain fission-xorig everywhere. r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D136628
2022-01-21 19:16:12 +00:00
Masayuki Nakano 72c7cef167 Bug 1749299 - Make `HTMLEditor::HandleInsertLinefeed()` stop handling it if insertion point cannot have text nodes r=m_kato
Ideally, it should not be called when the editor cannot insert new text node.
However, the callers are complicated.  Therefore, let's check in it for avoiding
making the callers more complicated.  Fortunately, this is not realistic path
for normal web apps.  Therefore, the compatibility of the behavior is not
matter.  That's the reason why this patch does not have a test comparing the
result.

Differential Revision: https://phabricator.services.mozilla.com/D135826
2022-01-16 06:21:17 +00:00
Masayuki Nakano e4e35dbacd Bug 1745862 - part 2: Make `IsSetAndValid` of `RangeBoundaryBase` and `EditorDOMPointBase` return `false` when it refers a node which is being removed from parent r=smaug,mbrodesser
`IsSetAndValid` method of `RangeBoundaryBase` and `EditorDOMPointBase` should
return `false` if points a removed node.  However, while a node is being
removed, the node still keeps referring the parent, but it has already removed
from the child node chain of the parent.  In this moment, returning `true` may
not be expected by the callers because the point becomes invalid soon with
the parent being cleared.

Differential Revision: https://phabricator.services.mozilla.com/D135190
2022-01-13 13:25:16 +00:00
Masayuki Nakano acff628112 Bug 1747008 - Make `HTMLEditor::OnEndHandlingTopLevelEditSubActionInternal` stop stripping empty inline elements if they may be inserted intentionally r=m_kato
Starting from bug 1730429, we strip empty inline elements at caret for
compatibility with Blink/WebKit.  However, we should not do it for the elements
which are intentionally inserted (from `inserthtml` command, paste and DnD).

All the cases are handled by `HTMLEditor::HTMLWithContextInserter` so that
it should prevent the new clean up with `TopLevelEditSubActionData`.

Note that `inserthtml` command handling of Blink is really odd.  It inserts
the empty inline elements of the adding testcases into different place so that
Chrome does not pass the new tests.  However, it does not make sense and I
believe that it's out of scope of this bug.

Differential Revision: https://phabricator.services.mozilla.com/D135195
2022-01-07 03:08:41 +00:00
Masayuki Nakano 0edb1a99b9 Bug 1748018 - Make `HTMLEditUtils::GetFirstListItemElement` scan only within the given list element r=m_kato
It calls `nsINode::GetNextNode()` to scan first descendant list item in the
list without specifying the root node to scan within.  Therefore, it may return
following list item element of the given list element if the list element does
not have children.

Differential Revision: https://phabricator.services.mozilla.com/D135110
2022-01-06 04:04:49 +00:00
Tom Schuster 0f3dd751e6 Bug 1666582 - Remove NeedsSubjectPrincipal/ from chrome-only DataTransfer APIs. r=annyG,emilio
Differential Revision: https://phabricator.services.mozilla.com/D134932
2022-01-05 12:48:23 +00:00
Masayuki Nakano b296d660ee Bug 1747132 - part 2: Make `HTMLEditor::GetActiveEditingHost()` return `nullptr` if selection is in a native anonymous subtree r=m_kato
This is a follow up fix for the previous patch.  Even if `IsSelectionEditable()`
is not used before starting to handle an edit action, it should be aborted by
failing to get editing host.

Depends on D134658

Differential Revision: https://phabricator.services.mozilla.com/D134659
2021-12-25 21:58:44 +00:00
Masayuki Nakano 380039601b Bug 1747132 - part 1: Make `EditorBase::IsSelectionEditable()` return `false` if selection is accidentally in a native anonymous subtree r=m_kato
Perhaps due to a bug Selection and/or Range API, selection may be in a native
anonymous subtree, and if the content is editable like in anonymous `<div>`
element in `<input>` or `<textarea>`, `HTMLEditor` may put unexpected element
into the anonymous `<div>` element.

For avoiding it, `EditorBase::IsSelectionEditable()` should return `false`
when it detects this odd situation.  Then, editing commands do not work in
the anonymous subtree.

Differential Revision: https://phabricator.services.mozilla.com/D134658
2021-12-25 21:58:43 +00:00
Masayuki Nakano 667224045f Bug 1745882 - Move all editor prefs in `all.js` to `StaticPrefList.yaml` r=m_kato
Depends on D133729

Differential Revision: https://phabricator.services.mozilla.com/D133730
2021-12-15 05:17:52 +00:00
Masayuki Nakano 3816ca9546 Bug 1741148 - part 3: Make users of `nsINode::ComputeIndexOf_Deprecated()` use `nsINode::ComputeIndexOf()` if the result is not set to `int32_t` nor return as `int32_t` r=smaug
This patch fixes only the cases if the result of `ComputeIndexOf_Deprecated()`
is used as unsigned integer with implicit or explicit cast.

Differential Revision: https://phabricator.services.mozilla.com/D131336
2021-12-09 11:55:36 +00:00
Masayuki Nakano fb2940808f Bug 1741148 - part 2: Re-implement `nsINode::ComputeIndexOf` as returning `Maybe<uint32_t>` rather than `int32_t` r=smaug
Offset in a node is declared as "unsigned long" by the standards and we don't
limit node can have less than `INT32_MAX`.  So it should return `uint32_t`, but
it also needs to represent the case of "not found".  For consistency with some
other APIs like `nsContentUtils::ComparePoints`, using `Maybe` must be a good
style rather than `Result<uint32_t, bool>`.

This patch fixes the callers in assertions for example.

Differential Revision: https://phabricator.services.mozilla.com/D131335
2021-12-09 09:21:52 +00:00
Masayuki Nakano f2baf0d9ab Bug 1741148 - part 1: Rename `nsINode::ComputeIndexOf` to `ComputeIndexOf_Deprecated` r=smaug
It's hard to fix some callers.  Therefore, in this bug, we should fix only
simple cases.  Therefore, we should rename existing API first.

Differential Revision: https://phabricator.services.mozilla.com/D131334
2021-12-09 08:32:30 +00:00
Masayuki Nakano c19aa5aaa5 Bug 1740853 - part 1: Make `nsContentUtils::ComparePoints` take `uint32_t` for offset in DOM nodes r=smaug
They are defined as "unsigned long" by the standards.  So we should use
`uint32_t` rather than `int32_t` with the methods.  However, layout code
uses `int32_t` a lot for representing the offset.  Therefore, this patch
adds `*_FixOffset1` etc for the cases which cannot fix easily in this patch.

Differential Revision: https://phabricator.services.mozilla.com/D131110
2021-12-09 07:51:45 +00:00
Masayuki Nakano 2214b0dc00 Bug 1735446 - part 5: Make `nsIInlineSpellChecker` use `unsigned long` as offset in node r=m_kato
It has two methods which take (signed) `long` argument to specify offset in a
DOM node, but it's declared as "unsigned long" in the standards.  And now,
they work with rewritten Selection API which take `uint32_t` so that they should
use `unsigned long` for making the handling simpler and safer.

Differential Revision: https://phabricator.services.mozilla.com/D131034
2021-12-09 07:44:09 +00:00
Masayuki Nakano 82e2013683 Bug 1735446 - part 4: Make `Selection::GetRangeAt()` take `uint32_t` instead of `int32_t` r=smaug
It's an internal API corresponding to `Selection.getRangeAt` DOM API.
I think that it should use `uint32_t` rather than `size_t` because of the
consistency with the DOM API and `Selection::RangeCount()`.

This patch fixes all callers of `GetRangeAt()`, and rewrites it with ranged-
loops unless original ones do not refer `RangeCount()` every time and may run
script in the loop.

Differential Revision: https://phabricator.services.mozilla.com/D128848
2021-12-09 07:35:09 +00:00
Masayuki Nakano 78430c342b Bug 1734507 - Make `TextEditor` guarantee that ranges to delete are in the text node r=saschanaz
Our internal code can touch internal `Selection` object of `<input>` and
`<textarea>`, thus, selection ranges in them may be not in the text node.
Therefore, we should make `TextEditor` instance try to shrink the deleting
ranges into the text node first.

In a followup bug (perhaps, bug 1734846), we should split the deletion code into
`TextEditor` and `HTMLEditor` for making the code simpler and never regressed.

Differential Revision: https://phabricator.services.mozilla.com/D133181
2021-12-08 21:37:22 +00:00
Chris Peterson f6fdbf028a Bug 1738401 - Remove -Wno-shadow warning suppressions. r=firefox-build-system-reviewers,glandium
-Wshadow warnings are not enabled globally, so these -Wno-shadow suppressions have no effect. I had intended to enable -Wshadow globally along with these suppressions in some directories (in bug 1272513), but that was blocked by other issues.

There are too many -Wshadow warnings (now over 2000) to realistically fix them all. We should remove all these unnecessary -Wno-shadow flags cluttering many moz.build files.

Differential Revision: https://phabricator.services.mozilla.com/D132289
2021-12-01 06:40:04 +00:00
Masayuki Nakano b8ea6dd142 Bug 1639287 - part 2: Make `SplitNodeTransaction::RedoTransaction()` use `HTMLEditor::DoSplitNode()` r=m_kato
Similarly, `SplitNodeTransaction::RedoTransaction()` has its own code, but it
does not work well.  Let's make it use `HTMLEditor::DoSplitNode()` instead.

This fixes bug 1740656.

Differential Revision: https://phabricator.services.mozilla.com/D132123
2021-11-29 10:17:21 +00:00
Masayuki Nakano 15605659bf Bug 1639287 - part 1: Make `JoinNodeTransaction::UndoTransaction()` use `HTMLEditor::DoSplitNode()` r=m_kato
`JoinNodeTransaction::UndoTransaction()` has its own splitting code.  However,
it has some bugs, it does not handle surrogate pairs correctly and it does not
care selections.  `HTMLEditor::DoSplitNode()` is used for splitting a DOM node
from `SplitNodeTransaction::DoTransaction()`.  So that we should make
`JoinNodeTransaction::UndoTransaction()` should use `HTMLEditor::DoSplitNode()`
for saving the maintenance cost.

Differential Revision: https://phabricator.services.mozilla.com/D132122
2021-11-29 10:17:21 +00:00
Masayuki Nakano 1eb9045821 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 66fc2510f3 Bug 1742744 - part 2: Make `HTMLEditor` stop using `CreateElementTransaction` by default r=m_kato
`CreateElementTransaction` is too similar to `InsertNodeTransaction`. Only the
difference is, CreateElementTransaction::DoTransaction() creates an element via
editor instance and marks it dirty before inserting the new element. E.g.,
selection management and whether inserting new node or not at "redo" are same.

So, for the maintenance cost reason, we should get rid of
`CreateElementTransaction`, but for now, we should just make `HTMLEditor` use
`InsertNodeTransaction` instead, with a new pref to make it possible to back it
out the new behavior even after shipping.

Differential Revision: https://phabricator.services.mozilla.com/D132119
2021-11-26 05:26:35 +00:00
Masayuki Nakano 0e593030cd Bug 1742744 - part 1: Make `CreateElementTransaction::InsertNode()` not return error if reference child is disconnected r=m_kato
This is a different point from `InsertNodeTransaction`.  If reference node has
been removed from the DOM tree, it tries to insert the given node to end of
the container instead of returning error.  This is an edge case of "redo", and
this is tested by WPT.  If we'd need to back it out with Normandy after shipping
this changes, we'd need to uplift WPT expectation change.  However, we should
avoid this situation.  Therefore, this patch fixes the bug of
`CreateElementTransaction` first.

Differential Revision: https://phabricator.services.mozilla.com/D132118
2021-11-26 05:26:35 +00:00
Masayuki Nakano ac63f96c0a Bug 1739935 - Make `HTMLEditor::SplitNodeWithTransaction()` return `SplitNodeResult` r=m_kato
With this patch, callers of it can handle left and right node logically instead
of assuming that one is split and the other is new one.

Depends on D131748

Differential Revision: https://phabricator.services.mozilla.com/D131749
2021-11-24 02:27:41 +00:00
Masayuki Nakano 5697db1a15 Bug 1740858 - Improve `SplitNodeResult` r=m_kato
First, left/right node accessors are not used so that we can get rid of them.
However, we should have similar methods which can retrieve original node and
new node.  Therefore, this adds `GetNewContent()` and `GetOriginalContent()`.

Next, `SplitPoint()` should return both `EditorDOMPoint` and `EditorRawDOMPoint`
for avoiding unnecessary conversion from `EditorRawDOMPoint` to
`EditorDOMPoint`.  Therefore, this patch makes it a template method too.

Finally, this patch adds helper methods to get point of each related content.
E.g., `AtNewContent()` corresponding to `GetNewContent()`.

Differential Revision: https://phabricator.services.mozilla.com/D131748
2021-11-24 00:56:33 +00:00
Richard Marti aa8c75b83f Bug 1376091 - For MOZ_WIDGET_GTK, change shortcut for `cmd_selectAll` from Alt+A to Ctrl+A. r=masayuki
With this patch, we stop registering `Alt+A` as a shortcut key for "Select All" on Linux and register `Ctrl+A` instead, which is the default shortcut for the command on other GTK applications, Chromium, and Windows. `Alt+A` was also causing a bug for menubar navigation because it hijacks `Alt+A` access key. This patch does not stop Linux environments from registering `Alt+A` as a shortcut key for "Select All"; it just drops Gecko's additional, non-standard shortcut key definition, and defaults to `Ctrl+A` instead.

Differential Revision: https://phabricator.services.mozilla.com/D131062
2021-11-23 18:37:41 +00:00
Dan Minor e12f42285c Bug 1733659 - Clean up naming style in Locale; r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D131511
2021-11-23 12:36:41 +00:00
Sandor Molnar 2594d2ac61 Backed out 2 changesets (bug 1733659) for causing build bustages. CLOSED TREE
Backed out changeset 9e23aa79fda9 (bug 1733659)
Backed out changeset e316768591c0 (bug 1733659)
2021-11-22 20:51:20 +02:00
Dan Minor bcbfdb6d73 Bug 1733659 - Clean up naming style in Locale; r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D131511
2021-11-22 18:32:41 +00:00
Masayuki Nakano dac29e99f8 Bug 1740872 - part 11: Make `HTMLEditor::AlignContentsAtSelectionWithEmptyDivElement()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Depends on D131207

Differential Revision: https://phabricator.services.mozilla.com/D131208
2021-11-17 11:32:32 +00:00
Masayuki Nakano 46279fe06e Bug 1740872 - part 10: Make `HTMLEditor::MoveSelectedContentsToDivElementToMakeItAbsolutePosition()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Depends on D131206

Differential Revision: https://phabricator.services.mozilla.com/D131207
2021-11-17 08:51:41 +00:00
Masayuki Nakano dd0da96bdf Bug 1740872 - part 9: Make `HTMLEditor::MoveNodesIntoNewBlockquoteElement()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Depends on D131205

Differential Revision: https://phabricator.services.mozilla.com/D131206
2021-11-17 08:41:19 +00:00
Masayuki Nakano 70d1503c98 Bug 1740872 - part 8: Make `HTMLEditor::AlignNodesAndDescendants()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Depends on D131204

Differential Revision: https://phabricator.services.mozilla.com/D131205
2021-11-17 08:34:20 +00:00
Masayuki Nakano bc98fa8c1b Bug 1740872 - part 7: Make `HTMLEditor::HandleHTMLIndentAtSelectionInternal()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Depends on D131203

Differential Revision: https://phabricator.services.mozilla.com/D131204
2021-11-17 08:28:31 +00:00
Masayuki Nakano 1e5b6b30d9 Bug 1740872 - part 6: Make `HTMLEditor::HandleCSSIndentAtSelectionInternal()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Depends on D131202

Differential Revision: https://phabricator.services.mozilla.com/D131203
2021-11-17 06:57:12 +00:00
Masayuki Nakano c7c026d1d5 Bug 1740872 - part 5: Make `HTMLEditor::IndentListChild()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Depends on D131201

Differential Revision: https://phabricator.services.mozilla.com/D131202
2021-11-17 05:56:37 +00:00
Masayuki Nakano 8ddcf70f8d Bug 1740872 - part 4: Make `HTMLEditor::FormatBlockContainerWithTransaction()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Depends on D131200

Differential Revision: https://phabricator.services.mozilla.com/D131201
2021-11-17 04:49:48 +00:00
Masayuki Nakano 9285df8aea Bug 1740872 - part 3: Make `HTMLEditor::ChangeSelectedHardLinesToList()` use `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` r=m_kato
Depends on D131199

Differential Revision: https://phabricator.services.mozilla.com/D131200
2021-11-17 04:08:47 +00:00
Masayuki Nakano f4e651e520 Bug 1740872 - part 2: Create `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction()` to wrap to call a pair of `MaybeSplitAncestorsForInsertWithTransaction()` and `CreateAndInsertElementWithTransaction()` r=m_kato
There are a lot of places which calls
`HTMLEditor::MaybeSplitAncestorsForInsertWithTransaction()` and then calls
`HTMLEditor::CreateAndInsertElementWithTransaction()` with split point of the
preceding result.  It's better to wrap them in a method for reducing the
maintenance cost.

`HTMLEditor::CreateOrChangeBlockContainerElement()` handles to calling them
safer than the others so that let's use this code for the new method.  The
additional change won't change the most web apps which don't touch the DOM
tree from legacy mutation event listeners.

Depends on D131198

Differential Revision: https://phabricator.services.mozilla.com/D131199
2021-11-17 04:08:47 +00:00
Masayuki Nakano 44969eec1c Bug 1740872 - part 1: Move `EditorBase::CreateElementWithTransaction()` into `HTMLEditor` r=m_kato
I realized that it's now used only by `HTMLEditor` so that we can move it
into `HTMLEditor` and we can make `CreateElementTransaction` treat `HTMLEditor`
directly rather than via `EditorBase`.

Differential Revision: https://phabricator.services.mozilla.com/D131198
2021-11-17 04:08:46 +00:00
Greg Tatum ec908112f4 Bug 1738057 - Split out BidiEmbeddingLevel into its own file; r=platform-i18n-reviewers,dminor
This should speed up re-compile times, as mozilla/intl/Bidi.h will only
be included in a few places.

Differential Revision: https://phabricator.services.mozilla.com/D129662
2021-11-16 15:11:58 +00:00
Masayuki Nakano 859a7e84a5 Bug 1740859 - part 2: Make `HTMLEditor::SplitNodeDeepWithTransaction()` callers omit checking whether the editor is destroyed r=m_kato
It touches the DOM tree only with `SplitNodeTransaction()` and it now returns
`NS_ERROR_EDITOR_DESTROYED` so that the callers don't need to check whether
the editor is destroyed or alive by themselves.

Depends on D131043

Differential Revision: https://phabricator.services.mozilla.com/D131044
2021-11-15 02:29:48 +00:00
Masayuki Nakano c3d57d415e Bug 1740859 - part 1: Make `HTMLEditor::SplitNodeWithTransaction()` return `NS_ERROR_EDITOR_DESTROYED` if it happens r=m_kato
For making the code simpler, this patch makes it returns
`Result<nsCOMPtr<nsIContent>, nsresult>` instead of using `ErrorResult`.
This must make the construction faster and callers simpler.

Depends on D130950

Differential Revision: https://phabricator.services.mozilla.com/D131043
2021-11-15 02:23:33 +00:00
Masayuki Nakano 334e34f0a9 Bug 1740416 - Make `HTMLEditor::HandleInsertParagraphInParagraph()` call `WhiteSpaceVisibilityKeeper::PrepareToSplitBlockElement()` before splitting a text node r=m_kato,smaug
It does the following things when caret is collapsed in a text node in a `<p>`
or `<div>` element.

1. Split the text node containing caret to insert `<br>` element
2. Insert `<br>` element after it
3. Split ancestor elements which inclusive descendants of the `<p>` or `<div>`
4. Delete the `<br>` element if unnecessary from the left paragraph

#3 and #4 are performed by `HTMLEditor::SplitParagraph()` and it calls
`WhiteSpaceVisibilityKeeper::PrepareToSplitBlockElement()` correctly before
splitting the block.  However, in the case (caret is at middle of a text node),
the text has already been split to 2 nodes because of #1.  Therefore, it fails
to handle to keep the white-space visibility.

So that I believe that the root cause of this bug is, the method does much
complicated things which are required, and doing the redundant things will
eat memory space due to undo transactions.  However, for now, I'd like to fix
this with a simple patch which just call the preparation method before splitting
the text node because I'd like to uplift this if it'd be approved (Note that
this is not a recent regression, the root cause was created by bug 92686 which
was fixed in 17 years ago:
<https://searchfox.org/mozilla-central/commit/2e66280faef73e9be218e00758d4eb738395ac83>,
but must be annoying bug for users who see this frequently).

The new WPTs are pass in Chrome.

Differential Revision: https://phabricator.services.mozilla.com/D130950
2021-11-12 22:13:51 +00:00
Masayuki Nakano 0dcfd11fa8 Bug 1740847 - part 3: Make `WhiteSpaceVisibilityKeeper::ReplaceText()` track insert position in smaller block r=m_kato
Similar to the previous patch, this patch also make it track invisible
white-space ranges and clear outdated things.

And this makes it cache some information instead of tracking some changes
because of performance reason.

Depends on D131037

Differential Revision: https://phabricator.services.mozilla.com/D131038
2021-11-12 08:31:22 +00:00
Masayuki Nakano 052b897b21 Bug 1740847 - part 2: Make `WhiteSpaceVisibilityKeeper::InsertBRElement()` track insert position in smaller block r=m_kato
And also invisible white-space range and replacing white-space position should
also be tracked too.

Depends on D131036

Differential Revision: https://phabricator.services.mozilla.com/D131037
2021-11-12 08:04:37 +00:00
Masayuki Nakano 2c2f8ab1c6 Bug 1740847 - part 1: Track split point at replacing collapsible white-spaces r=m_kato
It `pointToSplit` should be tracked at replacing text, but I have no idea how
to test this because it replaces the text after the split point.

Differential Revision: https://phabricator.services.mozilla.com/D131036
2021-11-12 07:20:31 +00:00
Masayuki Nakano 925fc15324 Bug 1739933 - Make `TopLevelEditSubActionData::DidSplitNode()` handle both cases that either left or right node is a new node r=m_kato
Currently, it assumes that new node is the left node and split node is the
right node.  However, we need to make it possible to handle the case that
right node is new one for fixing bug 1735608.

Depends on D130458

Differential Revision: https://phabricator.services.mozilla.com/D130624
2021-11-09 07:11:23 +00:00
Ting-Yu Lin f32eaad379 Bug 1722484 Part 2 - Replace LineBreaker::Next() and WordBreaker::Next() with the new iterators. r=m_kato
With the rewrite, we reduce the dependency of lwbrk LineBreaker::Next(),
WordBreaker::Next(), and their `int32_t` sentinel values
NS_LINEBREAKER_NEED_MORE_TEXT and NS_WORDBREAKER_NEED_MORE_TEXT.

Differential Revision: https://phabricator.services.mozilla.com/D130392
2021-11-09 01:14:15 +00:00
Masayuki Nakano dfa4091f3b Bug 1739545 - part 2: Redesign `TextServicesDocument::DidJoinNodes()` methods r=m_kato
There is 2 overloads.  One is `TextServicesDocument`'s method, and the latter is
for `nsIEditActionListener`.  The latter could occur if `TextServicesDocument`
is added to the editor when there is no inline spellchecker, `EditorSpellCheck`
or `mozSpellChecker`.
https://searchfox.org/mozilla-central/rev/d2f8488b6a704443a5c5bfc6d2878171b5f0d393/editor/libeditor/EditorBase.cpp#2388,2391,2393,2396,2398

I don't know whether this is possible case, but unfortunately,
`nsIEditActionListener::DidJoinNodes()` is not implemented by JS and implemented
only by `TextServicesDocument`.  Therefore, we can make it "noscript" and use
non-scriptable classes as arguments.

This patch makes them get jointed point and removed content node and the joining
direction for fixing bug 1735608.  Unfortunately, there is no test framework
to check the result in `TextServicesDocument` nor the new path.  The latter
should be tested when we fix bug 1735608 later.

Differential Revision: https://phabricator.services.mozilla.com/D130458
2021-11-09 01:09:20 +00:00
Masayuki Nakano 1034b36c49 Bug 1739545 - part 1: Get rid of `mozInlineSpellChecker::DidJoinNodes()` and `mozInlineSpellChecker::DidSplitNode()` r=m_kato
Currently, they do nothing because they specify empty range to
`SpellCheckBetweenNodes()`, and it makes the method does nothing.  This is
filed as bug 1581714.  However, they are not required because `HTMLEditor`
notifies `mozInlineSpellChecker` at ending handling the top level edit sub
action.
https://searchfox.org/mozilla-central/rev/a12c2c2e59c92d8f969d8f3f290ab16919449c9d/editor/libeditor/HTMLEditSubActionHandler.cpp#675

Therefore, these methods are not necessary anymore.

Differential Revision: https://phabricator.services.mozilla.com/D130457
2021-11-09 01:09:20 +00:00
Iulian Moraru 36283a9a3b Backed out 2 changesets (bug 1722484) for causing multiple build bustages. CLOSED TREE
Backed out changeset bef547b588ff (bug 1722484)
Backed out changeset e676fa1a0cb7 (bug 1722484)
2021-11-09 01:42:20 +02:00
Ting-Yu Lin 7310c93473 Bug 1722484 Part 2 - Replace LineBreaker::Next() and WordBreaker::Next() with the new iterators. r=m_kato
With the rewrite, we reduce the dependency of lwbrk LineBreaker::Next(),
WordBreaker::Next(), and their `int32_t` sentinel values
NS_LINEBREAKER_NEED_MORE_TEXT and NS_WORDBREAKER_NEED_MORE_TEXT.

Differential Revision: https://phabricator.services.mozilla.com/D130392
2021-11-08 22:24:19 +00:00
Masayuki Nakano f3ce4ebc2d Bug 1739524 - part 2: Make `RangeUpdater::SelAdjSplitNode()` handle both cases that right/left node is a new node r=m_kato
Currently, it assumes that `aLeftNode` is new node and the other is the original
one.  However, we need the opposite case when we fix bug 1735608.

Unfortunately, we cannot test the new path until we fix bug 1735608.  Therefore,
the new path may contain some bugs.

Differential Revision: https://phabricator.services.mozilla.com/D130427
2021-11-08 09:49:33 +00:00
Masayuki Nakano b4cbc8db19 Bug 1739524 - part 1: Make `RangeUpdater::SelAdjJoinNodes()` handle both cases that right/left node is joined into the other r=m_kato
Currently, it assumes that all children or text data of `aRightContent` is
moved into `aLeftContent`.  However, we need the opposite case when we fix
bug 1735608.

Unfortunately, we cannot test the new path until we fix bug 1735608.  Therefore,
the new path may contain some bugs.

Differential Revision: https://phabricator.services.mozilla.com/D130426
2021-11-08 09:49:33 +00:00
ssummar e519897f5a Bug 1738837 - Replaced usages of mozilla::Tuple with std::tuple in editor/ r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D130146
2021-11-06 13:25:27 +00:00
Masayuki Nakano 635539b0e5 Bug 1706266 - part 2: Disable some Gecko specific edit commands in release and beta channel, and all of them in nightly channel r=smaug
The telemetry result is written in bug 1706266 comment 1:
https://bugzilla.mozilla.org/show_bug.cgi?id=1706266#c1

`increasefontsize`, `decreasefontsize`, `gethtml`, `heading` and `readonly` are
obviously not used by web apps in the wild.  Therefore, they can be disabled
in all channels.

`contentReadOnly` and `insertBrOnReturn` are odd.  The usage is really low (less
than 1% of beta users).  However, the number of documents which used the command
is about 1k samples.  The result of the commands are not tiny (making the editor
not editable or changing the behavior at typing `Enter` key in `<div>`, `<p>`,
etc).  Therefore, it's hard to use them in web apps which supports not only
Gecko.  So I guess that they are collected the number of used by automated
tests of somebody because of the constant number in other beta versions.
Perhaps, we should disable it only in Nightly channel for now, and after a
couple of releases, we should try to disable those commands too later.

Depends on D130328

Differential Revision: https://phabricator.services.mozilla.com/D130329
2021-11-05 14:29:25 +00:00
Masayuki Nakano 524a98b4f2 Bug 1739526 - Move some trivial classes defined in `EditorUtils.h` but used only by `HTMEditor` or its helper classes to `HTMLEditHelpers.h" r=m_kato
I'd like to split utilities for all editors and only for `HTMLEditor`.

This moves some trivial classes into new `HTMLEditHelpers.h`.  Perhaps, it's
better if we can move them into `HTMLEditUtils.h`, but it has too many inline
method definitions so that adding new classes into it makes it much bigger.

Depends on D130349

Differential Revision: https://phabricator.services.mozilla.com/D130425
2021-11-05 14:10:49 +00:00
Masayuki Nakano 354375158b 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 94cfff6b9a Bug 1739315 - part 1: Make `HTMLEditor::JoinNodesWithTransaction()` directly notify `TopLevelEditSubActionData::DidJoinNodes()` of joined position r=m_kato
`TopLevelEditSubActionData::WillJoinNodes()` and
`TopLevelEditSubActionData::DidJoinNodes()` are called only by
`HTMLEditor::JoinNodesWithTransaction()`.  `WillJoinNodes()` assumes that
all children or text data in `aLeftContent` is moved to head of `aRightContent`.
Therefore, it just stores length of `aLeftContent` and `DidJoinNodes()` lets
`AddPointToChangedRange()` know the joined point.

Same value is stored by `HTMLEditor::JoinNodesWithTransaction()`.  Therefore,
it can create same DOM point at calling `DidJoinNodes()` so that we can get
rid of `WillJoinNodes()`.

Differential Revision: https://phabricator.services.mozilla.com/D130348
2021-11-05 10:14:35 +00:00
Cristian Tuns bdf50d3542 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