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

11226 Коммитов

Автор SHA1 Сообщение Дата
Masayuki Nakano 6e573a8e54 Bug 1794804 - Make `HTMLEditor::MergeFirstLineOfRightBlockElementIntoLeftBlockElement` stop referring ok type of `Result` when it's error r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D159234
2022-10-18 22:42:54 +00:00
Masayuki Nakano 5f62438afd Bug 1794800 - Make `HTMLEditor::MoveOneHardLineContentsWithTransaction` notify last move node result of ignoring caret point suggestion if new move node fails r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D159233
2022-10-18 22:37:01 +00:00
Masayuki Nakano 2da57e45a2 Bug 1794800 - Make `HTMLEditor::MoveChildrenWithTransaction` notify last move node result of ignoring caret point suggestion if new move node fails r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D159232
2022-10-18 22:37:01 +00:00
Sandor Molnar 8cd82824c1 Backed out 2 changesets (bug 1778565) for causing mochitest plain failures in editor/libeditor/tests/test_bug490879.html CLOSED TREE
Backed out changeset 5f6350cfab61 (bug 1778565)
Backed out changeset 420e02d37505 (bug 1778565)
2022-10-18 22:18:00 +03:00
Tom Schuster 50f59ff179 Bug 1778565 - Editor: Handle nsIFile transferable as blob. r=nika,masayuki
Differential Revision: https://phabricator.services.mozilla.com/D155753
2022-10-18 17:35:33 +00:00
Masayuki Nakano 7b5c93295e Bug 1793865 - Make `HTMLEditor::HandleOutdentAtSelectionInternal` not return caret point suggestion r=m_kato
It restores `Selection` with `AutoSelectionRestorer` instance created first.
Therefore it does not want the callers (currently, only
`HTMLEditor::HandleOutdentAtSelection` only) change `Selection` after doing it
without special reasons.  Therefore, it shouldn't return last caret point
suggestion which is not a good point to put caret actually.  Then, callers
do not need to handle it as they've never done.

Differential Revision: https://phabricator.services.mozilla.com/D159231
2022-10-18 06:48:45 +00:00
Andrew McCreight b1fa3e3b36 Bug 1794811, part 1 - Include nsISupports.h instead of nsISupportsBase.h. r=necko-reviewers,nika,valentin
nsISupports.h includes nsISupportsBase.h, so it should be equivalent.

In the next patch, I'm changing things so that nsISupports is defined in
nsISupports.h instead of nsISupportsBase.h, and deleting the latter, so
this change will be needed anyways. I'm guessing people were using IWYU
or something like that.

Differential Revision: https://phabricator.services.mozilla.com/D159169
2022-10-17 16:09:22 +00:00
Masayuki Nakano 555eef31f3 Bug 1793873 - Make `HTMLEditor::DoSplitNode` stop assuming that joining nodes are in same parent r=m_kato
Between splitting a node and undoing it, web apps can move split nodes anywhere.
Therefore, it shouldn't assume they are always in same parent node, and
`RangeUpdater::SelAdjJoinNodes` needs to handle it correctly.

Unfortunately, `RangeUpdater::SelAdjJoinNodes` cannot handle nested cases
correctly, e.g., right node was in `aRemovedContent` or right node was in
the container of `aStartOfRightContent.GetContainer()`.  However, it's not
a new regression, and such complicated situation breaks undoing anyway.
Therefore, I think that we don't need to care about it for now.

Differential Revision: https://phabricator.services.mozilla.com/D159230
2022-10-14 02:49:13 +00:00
Jan-Niklas Jaeschke 311f68ad19 Bug 1793485: Fixed memory issue in `NodeWillBeDestroyed()` for `MultiMutationObserver` classes. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D158671
2022-10-13 14:26:07 +00:00
Cristian Tuns 67ff6520de Backed out changeset 928edafe970f (bug 1793485) for causing leaks CLOSED TREE 2022-10-12 17:09:32 -04:00
Jan-Niklas Jaeschke e71ca074c5 Bug 1793485: Fixed memory issue in `NodeWillBeDestroyed()` for `MultiMutationObserver` classes. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D158671
2022-10-12 19:36:46 +00:00
Olli Pettay 3d62e10c4e Bug 1788321, try to wait for spellchecking to be repainted before doing reftest comparison r=dminor
Differential Revision: https://phabricator.services.mozilla.com/D159024
2022-10-12 07:15:03 +00:00
Masayuki Nakano ff05850ef8 Bug 1793694 - part 7: Stop exposting `CSSEditUtils.h` and `ChangeStyleTransaction.h` r=m_kato
Depends on D158636

Differential Revision: https://phabricator.services.mozilla.com/D158637
2022-10-12 02:44:20 +00:00
Masayuki Nakano d54f646831 Bug 1793694 - part 6: Stop exposting `EditorUtils.h` r=m_kato
Depends on D158635

Differential Revision: https://phabricator.services.mozilla.com/D158636
2022-10-12 02:44:20 +00:00
Masayuki Nakano 994759243f Bug 1793694 - part 5: Move `EditorUtils::MaskString` to `TextEditor` r=m_kato
It's the only method which is used outside of the editor module.  Therefore,
we can stop exposing `EditorUtils.h` later.

Depends on D158634

Differential Revision: https://phabricator.services.mozilla.com/D158635
2022-10-12 02:44:19 +00:00
Masayuki Nakano e2b2e03fb4 Bug 1793694 - part 4: Stop exposing `HTMLEditUtils.h` r=m_kato
It's currently referred from outside only by `TextServicesDocument.cpp`.
It's not under `libeditor` but in the editor module.  Therefore, let's allow
it to refer the header files under `libeditor` directly.  Then, we can stop
exposing `HTMLEditUtils.h`.

Depends on D158633

Differential Revision: https://phabricator.services.mozilla.com/D158634
2022-10-12 02:44:19 +00:00
Masayuki Nakano d2b4935d19 Bug 1793694 - part 3: Move definitions of `JoinNodesDirection` and `SplitNodeDirection` into a new exposed header file r=m_kato
They are used in public inline methods of `HTMLEditor`.  Therefore, they should
be defined in an exposed header file without other internal use things for the
editor module.  Then, we can stop exposing `HTMLEditHelpers.h`.

Depends on D158632

Differential Revision: https://phabricator.services.mozilla.com/D158633
2022-10-12 02:44:18 +00:00
Masayuki Nakano 020393179b Bug 1793694 - part 2: Move some protected inline method definitions of `HTMLEditor` to non-exposed header r=m_kato
Depends on D158631

Differential Revision: https://phabricator.services.mozilla.com/D158632
2022-10-12 02:44:18 +00:00
Masayuki Nakano fbe8ad2ec8 Bug 1793694 - part 1: Move some static inline methods of `HTMLEditor` to `HTMLEditUtils` r=m_kato
Depends on D158483

Differential Revision: https://phabricator.services.mozilla.com/D158631
2022-10-12 02:44:17 +00:00
Chengyu Sun d4e767473d Bug 1790224 - Convert browser/actors/ClickHandler* JSM modules to ESMs. r=mconley
Differential Revision: https://phabricator.services.mozilla.com/D158853
2022-10-11 14:12:33 +00:00
Masayuki Nakano 52fa7d578c Bug 1793381 - part 3: Drop `DeleteSelectedContent` argument from `HTMLEditor::InsertFromTransferable` r=m_kato
It's always called with `DeleteSelectedContent::Yes`.  Therefore, the argument
is not required.  Then, its name can be `InsertFromTransferableAtSelection`.

Differential Revision: https://phabricator.services.mozilla.com/D158483
2022-10-09 01:27:35 +00:00
Masayuki Nakano df28abd410 Bug 1793381 - part 2: Make `HTMLEditor::DoInsertHTMLWithContext` as a sub action handler r=m_kato
It just creates `HTMLWithContextInserter` and calls its `Run()`.  Then, `Run()`
works as a sub action handler.  Therefore, we can make `DoInsertHTMLWithContext`
(which sounds like a helper class of a handler method) a sub action handler.

Then, it can handle the optional insertion point in it and
`HTMLWithContextInserter::Run` does not need to handle it.

Differential Revision: https://phabricator.services.mozilla.com/D158482
2022-10-09 01:27:35 +00:00
Masayuki Nakano f9fd02e705 Bug 1793381 - part 1: Make `HTMLEditor::InsertObject` and related methods use `enum class` instead of `bool` r=m_kato
They use `bool` arguments a lot.  Therefore, some call-sites are hard to read.
They should be replaced with `enum class`es.  Note that this patch does not
make the raw value of new `enum class`es to `bool` unless they are used in the
heap.

Differential Revision: https://phabricator.services.mozilla.com/D158481
2022-10-09 01:27:34 +00:00
Masayuki Nakano 6f006e854a Bug 1792759 - part 4: Make all tests in mozilla-central stop using `nsIEditor.transactionManager` r=m_kato
Now, `nsIEditor` has all alternatives of remaining `nsITransactionManager`
usage in mozilla-central.

Differential Revision: https://phabricator.services.mozilla.com/D158339
2022-10-09 01:13:50 +00:00
Masayuki Nakano 221e6fe540 Bug 1792759 - part 3: Add `nsIEditor.undoAll` r=m_kato,Standard8
`nsIEditor.undo` and `nsIEditor.redo` are called with `1` except by the search
bar, and search bar wants to undo everything to reset the value.  Therefore,
search bar needs an API to undo all, and the others do not need the number of
undoing/redoing transactions.  Therefore, this patch adds `nsIEditor.undoAll`
for search bar, and remove the arguments from `nsIEditor.undo` and
`nsIEditor.redo`.

Differential Revision: https://phabricator.services.mozilla.com/D158338
2022-10-09 01:13:50 +00:00
Masayuki Nakano 85a314b8fd Bug 1792759 - part 2: Redesign `nsIEditor.canUndo` and `nsIEditor.canRedo` r=m_kato,NeilDeakin
They are methods to take 2 out params, and it's not convenient for light use.
I think that there should be 3 attributes, `undoRedoEnabled`, `canUndo` and
`canRedo`.  Then, the findbar does not need to check number of transactions
with `nsITransactionManager`.

Differential Revision: https://phabricator.services.mozilla.com/D158337
2022-10-09 01:13:49 +00:00
Masayuki Nakano 4ba9b4dd1c Bug 1792759 - part 1: Add `nsIEditor.clearUndoRedo()` to get rid of `nsIEditor.transactionManager` r=m_kato,NeilDeakin,Standard8
`nsIEditor.transactionManager` is used only for some simple purposes, however,
`nsIEditor` exposes the rich API.  That makes it harder to maintain internal
code around transactions.  Instead, `nsIEditor` exposes only simple and
necessary APIs.

This patch creates a new API to clear undo/redo history and make the users in
mozilla-central use it instead of using `nsITransactionManager.clear()`.

Differential Revision: https://phabricator.services.mozilla.com/D158336
2022-10-09 01:13:49 +00:00
Masayuki Nakano 4789a16aab Bug 1792654 - Make `CreateNodeResultBase`, `MoveNodeResult`, `SplitNodeResult` and `SplitRangeOffResult` handle caret point with a common base class r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D158335
2022-10-04 21:36:57 +00:00
Masayuki Nakano 86bd7e3f58 Bug 1792642 - Make `SplitNodeResult` treated as ok type of `Result` r=m_kato
Depends on D158333

Differential Revision: https://phabricator.services.mozilla.com/D158334
2022-10-04 07:28:10 +00:00
Masayuki Nakano 158095f12c Bug 1792641 - Make `JoinNodesResult` treated as ok type of `Result` r=m_kato
Depends on D158332

Differential Revision: https://phabricator.services.mozilla.com/D158333
2022-10-03 23:17:02 +00:00
Masayuki Nakano e93bfe5b05 Bug 1792639 - Make `SplitRangeOffFromNodeResult` treated as ok type of `Result` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D158332
2022-10-03 07:52:45 +00:00
Masayuki Nakano fa59d785e9 Bug 1792624 - Make `SplitRangeOffResult` treated as ok type of `Result` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D158243
2022-10-03 01:19:59 +00:00
Masayuki Nakano b56174de6b Bug 1792502 - Correct the emulation in crashtests for bug 1789967 r=m_kato
I misunderstood the traditional behavior before bug 1789967, that is,
`HTMLEditor` collapsed `Selection` to end of the deepest last child container
element **or text node** of the `<body>`, rather than to end of **only** the
deepest last child container element. This misunderstanding caused the backout
of the first landing, but I didn't realize this mistake.

Therefore, this patch makes the crashtests which are touched in bug 1789967 and
the collapsed point is at a text node (or failed to consider the collapsed
point) collapse `Selection` to end of the deepest last text node of their
`<body>` elements.

Differential Revision: https://phabricator.services.mozilla.com/D158177
2022-10-02 00:03:36 +00:00
Masayuki Nakano b671926fa5 Bug 1792387 - part 10: Make `editor/libeditor/tests/test_inline_style_cache.html` be aware of both split node directions r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D158108
2022-09-30 22:20:23 +00:00
Masayuki Nakano 405786efd0 Bug 1792387 - part 8: Make `HTMLEditor::InsertParagraphSeparatorAsSubAction` put caret into right paragraph r=m_kato
If splitting element is a list item element,
`HandleInsertParagraphInListItemElement` may just move it into a list element
if it's followed by the list element, or may create new paragraph element if
the list item element is empty and last list item element.

If splitting element is a heading element,
`HandleInsertParagraphInHeadingElement` may create new paragraph element if
splitting at end of the heading element and not followed by `<br>`.

Therefore, neither `SplitNodeResult` nor `CreateElementResult` is proper for
their result type, and the caller `InsertParagraphSeparatorAsSubAction`, just
wants to know the right handle element which should contain caret and a caret
point suggestion.

For solving these issues, this gives an alias to `CreateElementResult`, makes
them return the right paragraph even if it's not newly created nor split
element, and replaces `blockElementToPutCaret` with the returned element.

Differential Revision: https://phabricator.services.mozilla.com/D158106
2022-09-30 22:20:22 +00:00
Masayuki Nakano 6b4bdd204e Bug 1792387 - part 7: Make `editor/libeditor/test_bug449243.html` be aware of both split node directions r=m_kato
The test compares the node name of the split element and its previous sibling
element, so it should switch the scanning direction with the pref to switch
split node direction.

Note that the behavior is different from the other browsers in some cases.
Therefore, we cannot port this to WPT.

Differential Revision: https://phabricator.services.mozilla.com/D158105
2022-09-30 22:20:22 +00:00
Masayuki Nakano 5e5b106cf0 Bug 1792387 - part 6: Make `HTMLEditor::InsertElementWithSplittingAncestorsWithTransaction` check edge case with next node of the split point r=m_kato
The check assumes that the container of `aPointToInsert` is always right node.
However, its child is moved to new node if we switch the direction, so we should
make it check the edge case with `SplitNodeResult::GetNextContent()`.

Differential Revision: https://phabricator.services.mozilla.com/D158104
2022-09-30 22:20:22 +00:00
Masayuki Nakano 5cf34cef27 Bug 1792387 - part 5: Make `HTMLEditor::SplitRangeOffFromBlock` and its caller refer `SplitNodeResult` at their post-processing r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D158103
2022-09-30 22:20:21 +00:00
Masayuki Nakano 9301bc763b Bug 1792387 - part 4: Make `JoinNodesTransaction` and `SplitNodeTransaction` support both join/split node directions r=m_kato
The reason why the changes of `SplitNodeTransaction` is smaller than
`JoinNodesTransaction` is, `HTMLEditor::DoSplitNode` does almost all things
instead.

Differential Revision: https://phabricator.services.mozilla.com/D158102
2022-09-30 22:20:21 +00:00
Masayuki Nakano 6ba25b471e Bug 1792387 - part 3-2: Make `HTMLEditor::DoSplitNode()` handle both split node directions r=m_kato
This does not change the existing path's behavior.

Differential Revision: https://phabricator.services.mozilla.com/D158101
2022-09-30 22:20:20 +00:00
Masayuki Nakano 8fd837d307 Bug 1792387 - part 3-1: Make `HTMLEditor::DoSplitNode()` adjust selection for both split node directions r=m_kato
This patch adds new path to adjust selection for the new split node direction.
So this does not change any behavior of the existing path.

Differential Revision: https://phabricator.services.mozilla.com/D158100
2022-09-30 22:20:20 +00:00
Masayuki Nakano 68073f0bbf Bug 1792387 - part 2-2: Make `HTMLEditor::DoJoinNodes()` handle both join nodes directions r=m_kato
This changes the existing path's behavior a bit.  However, it should not affect
to web apps in the wild because it must be really rare case that web apps
inserting new nodes into the removing node while moving its children.

Differential Revision: https://phabricator.services.mozilla.com/D158099
2022-09-30 22:20:20 +00:00
Masayuki Nakano 53757982b2 Bug 1792387 - part 2-1: Make `HTMLEditor::DoJoinNodes()` adjust selection for both join nodes directions r=m_kato
This patch add new path to adjust selection for the new join nodes direction.
So this does not change any behavior of the existing path.

Differential Revision: https://phabricator.services.mozilla.com/D158098
2022-09-30 22:20:19 +00:00
Masayuki Nakano 656bb3ee88 Bug 1792387 - part 1: Make `HTMLEditor` join/split node direction switchable by a pref r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D158097
2022-09-30 22:20:19 +00:00
Andrew McCreight 2da84b8ac4 Bug 1792574, part 3 - Don't include nsMemory where it isn't needed. r=xpcom-reviewers,necko-reviewers,valentin,nika
There are only 3 places where nsMemory.h is still needed (image/RasterImage.cpp,
gfx/thebes/gfxFT2FontList.cpp, and nsMemory.cpp). Remove the rest.

Differential Revision: https://phabricator.services.mozilla.com/D158213
2022-09-28 15:17:46 +00:00
Masayuki Nakano bd1059c951 Bug 1791501 - Use `EditActionResult` as ok type of `mozilla::Result` r=m_kato
Any callers do not refer "ignored", "handled" and "cancel" state without
checking whether the method returns error or not.  Therefore, error state
can be (and should be) managed by `mozilla::Result`'s error state.

Perhaps, it should store a caret position later because deletion handlers
of `HTMLEditor` use it, but update `Selection` immediately.

Differential Revision: https://phabricator.services.mozilla.com/D158080
2022-09-28 07:21:37 +00:00
Masayuki Nakano b6c97f3d73 Bug 1791224 - Use `CreateNodeResultBase` as the ok type of `mozilla::Result` r=m_kato
Similar to the previous patch, this changes a lot of lines.  However, I think
that it's not so hard to investigate regression point in this patch because
`CreateNodeResultBase` is not used so many times at handling on edit action.

Differential Revision: https://phabricator.services.mozilla.com/D157575
2022-09-28 04:00:19 +00:00
Butkovits Atila 79b03a7594 Backed out changeset 865c5d292958 (bug 1791224) for causing build bustages at Result.h. CLOSED TREE 2022-09-27 11:55:04 +03:00
Masayuki Nakano 6513faf43f Bug 1791224 - Use `CreateNodeResultBase` as the ok type of `mozilla::Result` r=m_kato
Similar to the previous patch, this changes a lot of lines.  However, I think
that it's not so hard to investigate regression point in this patch because
`CreateNodeResultBase` is not used so many times at handling on edit action.

Differential Revision: https://phabricator.services.mozilla.com/D157575
2022-09-27 05:12:05 +00:00
Masayuki Nakano 69d7bf65c8 Bug 1791223 - Use `MoveNodeResult` as the ok type of `mozilla::Result` r=m_kato
Unfortunately, it's hard to split this (and similar) patch because we need to
touch `MoveNodeResult` itself for making it available as the ok type of
`Result`.  However, I guess that it's not so hard to investigate regression
point if something would be found later because `MoveNodeResult` is mainly
used by deletion which is the most complicated part of `HTMLEditor`, but
`MoveNodeResult` is used only in a few cases.

Differential Revision: https://phabricator.services.mozilla.com/D157574
2022-09-26 00:56:46 +00:00