Commit Graph
66 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
serge-sans-paille d052064f2f Bug 1996523 - Remove unused mfbt inclusion in editor/** r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D270122
2025-10-27 11:42:04 +00:00
Masayuki Nakano 44159014a2 Bug 1859245 - part 3: Make JoinNodesTransaction and SplitNodeTransaction handle only the new direction mode r=m_kato
Depends on D191606

Differential Revision: https://phabricator.services.mozilla.com/D191607
2023-10-27 01:57:29 +00:00
Masayuki Nakano 27bdbb5436 Bug 1859245 - part 2: Make HTMLEditor::DoJoinNodes and HTMLEditor::DoSplitNode handle only the new direction mode r=m_kato
Depends on D191605

Differential Revision: https://phabricator.services.mozilla.com/D191606
2023-10-27 01:57:29 +00:00
Masayuki Nakano 6873ef16fd Bug 1795061 - Stop exposing JoinSplitNodeDirection.h r=m_kato
Including it in `HTMLEditor.h` causes creating static constructors for
the modules which include `HTMLEditor.h`.  And the public methods are used
only in the `libeditor`.  Therefore, we can make `HTMLEditor.h` stop including
it and stop exposing `JoinSplitNodeDirection.h`.

Differential Revision: https://phabricator.services.mozilla.com/D159363
2022-10-19 06:40:30 +00:00
Masayuki Nakano 0b074382f7 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 af5b2b3933 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 edf0546b90 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 23debc5658 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 7ac4877bb7 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 830bd376e2 Bug 1783402 - part 3: Make result of unsafe getter methods of EditorDOMPointBase templated r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D153842
2022-08-09 01:43:24 +00:00
Masayuki Nakano eb8aafe328 Bug 1783402 - part 2: Make result of safe getter methods of EditorDOMPointBase templated r=m_kato
Similar to the previous patch, and for consistency between editor helper
classes, we should make result of getter methods of `EditorDOMPointBase` too.

Differential Revision: https://phabricator.services.mozilla.com/D153841
2022-08-09 01:43:24 +00:00
Masayuki Nakano 96a5673280 Bug 1774114 - Make HTMLEditor and its helper classes get split/join node direction dynamically r=m_kato
Currently I'm think that the split/join node direction should be managed per
`HTMLEditor` instance because per transaction makes undo/redo handling
complicated and may require additional space to save it in each transaction
instance.  However, the direction should be changeable with new Gecko specific
`execCommand` to support both direction until creating first split/join node
transaction or anytime with clearing the transactions.

Differential Revision: https://phabricator.services.mozilla.com/D149192
2022-07-01 02:02:03 +00:00
Masayuki Nakano adea39d1ad Bug 1762115 - part 5: Make SplitNodeResult store and suggest new caret position r=m_kato
This patch allows methods which split some nodes to return new candidate
caret position and makes callers of them consider whether applying it to
the selection immediately or not.

Differential Revision: https://phabricator.services.mozilla.com/D144648
2022-05-03 00:06:16 +00:00
Masayuki Nakano 0ed912d4d2 Bug 1762115 - part 4: Make SplitNodeTransaction::DoTransaction() stop touching selection r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D144647
2022-05-02 23:44:00 +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 613c3e6874 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 9f1ed28e57 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 9eb26e98d4 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 a457578a3c 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 9492284581 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 9c34202758 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 bc371d672a 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 070d7477d0 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 294a274dcb 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 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 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
Kagami Sascha Rosylight a20339adb5 Bug 1623413 - Part 2: Rename Collapse() to CollapseInLimiter() r=masayuki
Depends on D88702

Differential Revision: https://phabricator.services.mozilla.com/D88920
2020-09-03 03:45:26 +00:00
Mihai Alexandru Michis d775b8dd6d Backed out 3 changesets (bug 1623413) for causing failures in Selection_collapse.html
CLOSED TREE

Backed out changeset d3d67293f115 (bug 1623413)
Backed out changeset 75ed1b8a5c67 (bug 1623413)
Backed out changeset 0eef32d6a454 (bug 1623413)
2020-09-03 05:37:49 +03:00
Kagami Sascha Rosylight 3eab64fd31 Bug 1623413 - Part 2: Rename Collapse() to CollapseInLimiter() r=masayuki
Depends on D88702

Differential Revision: https://phabricator.services.mozilla.com/D88920
2020-09-02 23:42:27 +00:00
Masayuki Nakano b7e95d5775 Bug 1644903 - Make nsINode::InsertBefore() callers call ErrorResult::WouldReportJSException() when inserting node may be in another document r=m_kato
`nsINode::InsertBefore()` removes inserting node from a document if it's in
a document including different document.  In this case, `UpdateReflectorGlobal`
in BindingUtils.cpp calls `ErrorResult::MightThrowJSException()`, but editor
never throws exception with `ErrorResult`.  Therefore, editor needs to call
`ErrorResult::WouldReportJSException()` explicitly if the inserting node may
be in another document.

As far as I checked, it can happen only when undoing or redoing a transaction.
Therefore, this patch touches only transaction classes.

Depends on D81683

Differential Revision: https://phabricator.services.mozilla.com/D81684
2020-07-01 13:13:13 +00:00
Masayuki Nakano 46a37854a9 Bug 1540037 - part 10: Move EditorBase::DoJoinNodes() to HTMLEditor r=m_kato
Then, we can make `JoinNodeTransaction` store `HTMLEditor` instead of
`EditorBase`.

Differential Revision: https://phabricator.services.mozilla.com/D72835
2020-04-30 15:26:09 +00:00
Masayuki Nakano 5254b34421 Bug 1540037 - part 9: Move EditorBase::DoSplitNode() to HTMLEditor r=m_kato
And then, `SplitNodeTransaction` needs to be store `HTMLEditor` instead of
`EditorBase`.

Differential Revision: https://phabricator.services.mozilla.com/D72833
2020-04-30 13:33:40 +00:00
Masayuki Nakano e951b45289 Bug 1627175 - part 5: Get rid of EditorBase::GetChildOffset() and EditorBase::GetNodeLocation() r=m_kato
Their users should use `EditorDOMPoint` or something instead.

This patch cleans up `EditorBase::DoJoinNodes()` too because of their heavy
user.  It requires only joined nodes because `aParent` is used only for
removing `aContentToJoin`, but we now have `nsINode::Remove()` which does
not require parent node and never fails.

Depends on D70877

Differential Revision: https://phabricator.services.mozilla.com/D70878
2020-04-16 01:21:17 +00:00
Masayuki Nakano 389c68b4c8 Bug 1619914 - part 2: Mark transaction class methods and their caller methods as `MOZ_CAN_RUN_SCRIPT r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D69303
2020-04-03 08:32:01 +00:00
Masayuki Nakano e2fd42da90 Bug 1619914 - part 1: Make each transaction class grab their members with local variable before touching the DOM tree r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D69302
2020-04-03 08:30:37 +00:00
Mihai Alexandru Michis 2f4e21ee38 Backed out 2 changesets (bug 1619914) for causing gtest failures regarding TransactionManager.
CLOSED TREE

Backed out changeset d3816f82c0b9 (bug 1619914)
Backed out changeset 876b1031a6ae (bug 1619914)
2020-04-03 07:57:06 +03:00
Masayuki Nakano 2ff2244878 Bug 1619914 - part 2: Mark transaction class methods and their caller methods as `MOZ_CAN_RUN_SCRIPT r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D69303
2020-04-03 01:39:36 +00:00
Masayuki Nakano c47ea28eea Bug 1619914 - part 1: Make each transaction class grab their members with local variable before touching the DOM tree r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D69302
2020-04-03 01:38:22 +00:00
Masayuki Nakano 6ccd126a6e Bug 1620504 - part 18: Clean up warnings in SplitNodeTransaction r=m_kato
Depends on D66179

Differential Revision: https://phabricator.services.mozilla.com/D66226
2020-03-11 06:13:26 +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
Masayuki Nakano 99847fa470 Bug 1610750 - Get rid of unused nsIEditor methods r=m_kato
* getAttributeValue
* cloneAttribute
* splitNode
* joinNodes
* markNodeDirty
* removeEditorObserver

are not used from script.  Therefore, we can get rid of them from `nsIEditor`.

However, `EditorBase::GetAttributeValue()` is referred by
`HTMLEditor::CopyCellBackgroundColor()` and it's just a wrapper of
`Element::GetAttr()`.  Therefore, this patch makes
`HTMLEditor::CopyCellBackgroundColor()` use `Element::GetAttr()` directly.

And also `EditorBase::MarkNodeDirty()` is used from some friend classes.
Therefore, this patch redesigns it as `MarkElementDirty()` and make all of
them check whether the method call destroys the editor.

Differential Revision: https://phabricator.services.mozilla.com/D60796
2020-01-23 12:27:00 +00:00
Masayuki Nakano cbc64af13d Bug 1548389 - part 0: Wrap modifying text node in editor with particular methods r=m_kato
In the next patch, we need to update unmasked range when anonymous text node
in `<input type="password">` is modified.  This patch makes editor manage it
easier to update the range.

Note that the next patch also handles text node creation and destruction.

Differential Revision: https://phabricator.services.mozilla.com/D38003
2019-07-22 03:53:29 +00:00
Masayuki Nakano ad34e89b46 Bug 1543315 - part 9: Mark nsIPresShell::FlushPendingNotifications() as MOZ_CAN_RUN_SCRIPT r=smaug
So, this patch makes all caller of it safe including its arguments unless
they come from other methods.

Differential Revision: https://phabricator.services.mozilla.com/D27225
2019-04-13 12:43:57 +00:00
Masayuki Nakano a4d40d8f8b Bug 1525481 - part 2: Make EditorBase::DoSplitNode() return error if split nodes are moved/removed unexpectedly r=m_kato
We should stop handling splitting nodes if mutation event listeners move or
remove the split nodes unexpectedly because the post processors may not be
able to keep handling the nodes.  For example, if a node is moved to outside
of editing host, we shouldn't touch it anymore due to non-editable.

This patch makes `EditorBase::DoSplitNode()` return new error for making
any parent callers stop their job, but note that the following patch makes
any public methods expose the new error as exception for compatibility with
Chrome.

Differential Revision: https://phabricator.services.mozilla.com/D20810
2019-02-25 08:29:38 +00:00
Masayuki Nakano 7979470dcc Bug 1525481 - part 1: Make SplitNodeTransaction::DoTransaction() always check the result of EditorBase::DoSplitNode() r=m_kato
Oddly, `SplitNodeTransaction::DoTransaction()` checks the result of
`EditorBase::DoSplitNode()` only when it's not allowed to change `Selection`.
We should make it always check the result.

Differential Revision: https://phabricator.services.mozilla.com/D20809
2019-02-25 05:00:27 +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
Masayuki Nakano 8fbb74045d Bug 1480055 - part 2: Rename EditorBase::GetShouldTxnSetSelection() to EditorBase::AllowsTransactionsToChangeSelection() r=m_kato
For explaining what it does clearer, we should rename it and corresponding
member.

MozReview-Commit-ID: 6U8FgfHBbCL
2018-08-01 20:53:57 +09:00
Boris Zbarsky fd021e28a2 Bug 1463981 part 3. Remove nsIDOMNode usage in editor. r=masayuki 2018-05-24 13:18:34 -04:00
Masayuki Nakano d6d0996c03 Bug 1451672 - part 6: Rename EditorBase::JoinNodesImpl() to EditorBase::DoJoinNodes() r=m_kato
MozReview-Commit-ID: 9fqa4fKkAF5
2018-04-10 03:56:46 +09:00