Commit Graph
19 Commits
Author SHA1 Message Date
Sylvestre Ledru 9f5cc05eee Bug 2023419 - Remove Emacs/Vim modelines from editor/ r=masayuki
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287844
2026-03-16 12:52:41 +00:00
Masayuki Nakano c248ec88bf Bug 1979561 - part 1-2: Create MoveSiblingsTransaction and make it use when removing or replacing a container element r=m_kato
We usually need to move consecutive siblings to move a line to another
block or unwrap children of a container element or replacing a container
element (with preserving the children of the old container element).

So, we need to create `MoveNodeTransaction` per node, but the number of
that is too many.  Therefore, we should coalesces some movements within
a transaction.

Moving consecutive siblings is the easiest way to do that because it
can manage the destinations of undo/redo for the all nodes which the
transaction moved.

Differential Revision: https://phabricator.services.mozilla.com/D259712
2025-08-08 23:42:30 +00:00
Masayuki Nakano 6c78ab21c3 Bug 1717155 - part 2: Make InsertTextTransaction, CompositionTransaction, DeleteTextTransaction and ReplaceTextTransaction not store Text node if it's for TextEditor r=m_kato
So, `Text` editor can access the `Text` node quickly and it's not needed to
be grabbed by a lot of transactions.  Additionally, when we support keeping
`TextEditor` instance even if the text control is reflowed (bug 1922141,
bug 1339052 and bug 1620050), transactions need to work with new anonymous
nodes.  Therefore, retrieving `Text` node of `TextEditor` each time does make
sense rather than storing the node.

Depends on D240419

Differential Revision: https://phabricator.services.mozilla.com/D240420
2025-03-13 05:25:46 +00:00
Masayuki Nakano 323a3d75ca Bug 1797247 - part 1: Add delete transaction classes to use build time type checks r=m_kato
First, `EditorBase::CreateTransactionForDeleteSelection` returns an instance of
`EditAggregateTransaction`. It's a base class of `PlaceholderTransaction` and
`DeleteRangeTransaction` but it's also a concrete class.  However, it's too
generic.  Therefore, this patch creates `DeleteMultipleRangesTransaction` which
is a simple sub-class of it, and makes `EditAggregateTransaction` be an abstract
class.  Then, add `AddChild` methods to each concrete class to restrict the
type of child transactions.

Next, `DeleteRangeTransaction` contains only `DeleteNodeTransaction` and
`DeleteTextTransaction`.  Therefore, once they have a common base class,
we can check the type easier.  Therefore, this patch also adds
`DeleteContentTransactionBase` and
`EditorBase::CreateTransactionForCollapsedRange` becomes clearer what it
returns.

With these changes, `DeleteRangeTransaction` obviously contains only
`DeleteContentTransactionBase`, `DeleteMultipleRangesTransaction` contains only
`DeleteRangeTransaction`, `DeleteNodeTransaction` and `DeleteTextTransaction`.
And they are guaranteed at build time (at least from outside the classes).
***
fix

Differential Revision: https://phabricator.services.mozilla.com/D169038
2023-02-15 22:17:17 +00:00
Andrew McCreight 3f5dddd6cd 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 4779f9e6d1 Bug 1766355 - part 1: Add MoveNodeTransaction to handle delete node and insert node in a transaction class instance r=m_kato
Creating both `DeleteNodeTransaction` and `InsertNodeTransaction` wastes
memory.  They should be done in an instance instead.

Fortunately, no edit action listener checks whether the deleted node is still
in the composed document or not, etc.  Therefore, we can simply notify them of
both deletion and insertion which were done in
`EditorBase::InsertNodeWithTransaction` and
`EditorBase::DeleteNodeWithTransaction`.  Note that previously, the range
updater needs to ignore the notifications from them while the node is being
moved.  However, it does not require anymore.  Therefore, this patch makes it
stop locking, and that would fix minor problem in the case of legacy mutation
event listeners run another edit action.

On the other hand, this changes some edge cases handling of
`MoveNodeWithTransaction` which are detected by the WPT.  According to the
previous result of applying this patch, `nsINode::InsertBefore` fails and that
leads some errors at updating the changed range.  I guess that the cause is
that there is some bugs at updating insertion point after deleting the node from
the DOM tree around here:
https://searchfox.org/mozilla-central/rev/0ffae75b690219858e5a45a39f8759a8aee7b9a2/editor/libeditor/HTMLEditor.cpp#5058-5071

However, it's safely fixed by the new code which does not remove the node from
the DOM tree explicitly.  So, I think that it's safe to accept this behavior
change for web apps in the wild.

Differential Revision: https://phabricator.services.mozilla.com/D146397
2022-05-20 08:28:08 +00:00
Masayuki Nakano 671549a2c1 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 cef03816dc 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 adf47de4ae Bug 1697876 - part 1: Add logging code to transaction classes for making easier to debug r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D110714
2021-04-05 11:35:48 +00:00
Masayuki Nakano 46ab2cf315 Bug 1639161 - part 1: Create ReplaceTextTransaction class r=m_kato
Currently, when `HTMLEditor` replaces text in a text node, `HTMLEditor`
creates a set of `DeleteTextTransaction` and `InsertTextTransaction`.
However, this has bad impact for footprint and causes the callers messy.

This patch creates `ReplaceTextTransaction` instead and
`HTMLEditor::ReplaceTextWithTransaction()` as its wrapper.  Unfortunately,
this becomes not calling `nsIEditActionListener::DidDeleteText()`, however,
this is not used by mozilla-central, comm-central nor BlueGriffon.  IIRC,
it was not removed for some legacy addons of Thunderbird.  Therefore, it
must be okay to remove it.

Differential Revision: https://phabricator.services.mozilla.com/D76078
2020-05-21 02:30:09 +00:00
Masayuki Nakano d329540d0a Bug 1632021 - part 2: Add nsITransaction::GetAsEditTransactionBase() r=m_kato
In a lot of places in libeditor, we do nothing if given transaction is not
our edit transaction classes' instance.  Therefore, it's better to have
casting virtual method in `nsITransaction` for performance because QI cost
may not be cheap.

Differential Revision: https://phabricator.services.mozilla.com/D71908
2020-04-23 07:02:16 +00:00
Masayuki Nakano 5127cc18f8 Bug 1632021 - part 1: Add GetAs*Transaction() methods to every subclasses of EditTransactionBase r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D71907
2020-04-23 05:46:43 +00:00
Masayuki Nakano 3ab8278d35 Bug 1620504 - part 23: Fix some inconsistent coding style in editor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D67132
2020-03-22 10:46:39 +00:00
Masayuki Nakano 6a2018d7e9 Bug 1620135 - Clean up trivial constructor and destructor under libeditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D65448
2020-03-06 04:38:25 +00:00
Sylvestre Ledru e5a134f73a Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset
2018-11-30 11:46:48 +01:00
Adrian Wielgosik 2043bf744f Bug 1379891 - remove nsPIEditorTransaction interface, GetTxnDescription methods. r=m_kato,masayuki
MozReview-Commit-ID: 4NLeMrrqIv5
2018-01-14 16:01:41 +01:00
Masayuki Nakano d18272d248 Bug 1425412 - part 12: Create factory methods for DeleteRangeTransaction, EditAggregateTransaction and PlaceholderTransaction for consistency with the other transaction classes r=m_kato
Although, we don't need factory methods for DeleteRangeTransaction,
EditAggregateTransaction nor PlaceholderTransaction, for consistency with the
other transaction classes, they should have factory methods for making easier
to write the code.

For not making the performance slow down, they should be inline methods.

MozReview-Commit-ID: 7jl5yZNFYmP
2017-12-18 18:08:43 +09:00
Masayuki Nakano 349d5d7916 Bug 1260651 part.60 editor/libeditor should export some headers which are required by other modules and other modules shouldn't use local include for them r=mccr8
MozReview-Commit-ID: FZSExwkHH2B
2016-07-08 14:03:31 +09:00
Masayuki Nakano d49c33f252 Bug 1260651 part.32 Rename EditTxn to mozilla::EditTransactionBase r=mccr8
This patch also renames NS_DECL_EDITTXN to NS_DECL_EDIT_TRANSACTION_BASE.

MozReview-Commit-ID: 29TQbKBBEhD
2016-07-08 09:48:34 +09:00