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

7534 Коммитов

Автор SHA1 Сообщение Дата
Masayuki Nakano 6b77e7ceba Bug 1772022 - Make `EditorBase::DeleteNodeWithTransaction()` return `NS_ERROR_EDITOR_DESTROYED` if so r=m_kato
Its callers check `EditorBase::Destroyed()` with at least adding 4 lines, and
some callers do not check this important state.  So, we should make it check
`Destroyed()` at last and omit the additional error check in the caller sites.

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

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

Depends on D147723

Differential Revision: https://phabricator.services.mozilla.com/D147724
2022-06-01 05:52:15 +00:00
Masayuki Nakano c89a938de5 Bug 1771780 - Make `TextEditor::ReinitializeSelection` skip things which are necessary to be handled only at getting `focus` event r=m_kato
Currently, `TextEditor::OnFocus` does the things which were in
`EditorEventListener::OnFocus`, and they are not necessary at re-initializing
`Selection` in the anonymous subtree.  Therefore, we should make it call
`EditorBase::OnFocus` directly.

Depends on D147623

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

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

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

Differential Revision: https://phabricator.services.mozilla.com/D147504
2022-05-31 03:41:01 +00:00
Masayuki Nakano 3d7afa934d Bug 1771448 - part 3: Get rid of `EditorBase::GetEditorRoot` r=m_kato
It returns the anonymous `<div>` element if the instance is a `TextEditor`, and
compute editing host otherwise.  So it's unclear what it returns.  Additionally,
all users except `EditorBase::CreateTransactionForCollapsedRange` are the
methods of `HTMLEditor`.  Therefore, we should remove it and unwrap the code
which it's done.

Differential Revision: https://phabricator.services.mozilla.com/D147503
2022-05-31 03:41:01 +00:00
Masayuki Nakano bd948d52e9 Bug 1771448 - part 2: Get rid of `EditorBase::IsDescendantOfEditorRoot` r=m_kato
With this patch, there are some odd points.  We should investigate them later...

Differential Revision: https://phabricator.services.mozilla.com/D147502
2022-05-31 03:41:01 +00:00
Masayuki Nakano 2249e46d10 Bug 1771448 - part 1: Get rid of `EditorBase::IsEditorRoot` because of unused r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D147501
2022-05-31 03:41:00 +00:00
Emilio Cobos Álvarez 9c190fff4b Bug 1771564 - Constify ComputedStyle usage in nsComputedDOMStyle. r=dholbert
None of the consumer need to mutate styles, and this saves some ugly
const_casting on the next patch.

Doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D147555
2022-05-28 01:04:24 +00:00
Masayuki Nakano dd554016e6 Bug 1770874 - part 8: Make `EditorBase::OnBlur` temporarily a virtual method r=m_kato
Similar to the previous patch, we should split the method into `TextEditor`
and `HTMLEditor`.

Differential Revision: https://phabricator.services.mozilla.com/D147144
2022-05-27 04:09:19 +00:00
Masayuki Nakano 353a53ded7 Bug 1770874 - part 7: Make `EditorBase::OnFocus` temporarily a virtual method r=m_kato
I'd like to split it for `TextEditor` and `HTMLEditor`.  `HTMLEditor` does not
require flushing the layout because it's required by `TextEditor` if and only if
a preceding `focus` event listener or the `Element.focus` caller reframes
`<input>` or `<textarea>` element (bug 1755104).  So this would fix bug 1760045.

Differential Revision: https://phabricator.services.mozilla.com/D147143
2022-05-27 04:09:19 +00:00
Masayuki Nakano 32ec4ed2f4 Bug 1770874 - part 6: Move most part of `EditorEventListener::Blur` into `EditorBase` r=m_kato
Note that `EditorBase::OnBlur` will be simpler at the last patch.

Differential Revision: https://phabricator.services.mozilla.com/D147142
2022-05-27 04:02:30 +00:00
Masayuki Nakano f6c2fb109c Bug 1770874 - part 5: Move `EditorBase::ReinitializeSelection` into `TextEditor` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D147141
2022-05-27 04:02:30 +00:00
Masayuki Nakano b94daeeccf Bug 1770874 - part 4: Move most part of `EditorEventListener::Focus` into `EditorBase::OnFocus` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D147140
2022-05-27 04:02:29 +00:00
Masayuki Nakano a7cd7ebe85 Bug 1770874 - part 3: Move `EditorEventListener::SpellCheckIfNeeded` to `EditorBase` r=m_kato
This method also can be protected in a following patch.

Differential Revision: https://phabricator.services.mozilla.com/D147139
2022-05-27 03:47:34 +00:00
Masayuki Nakano cefc432a8b Bug 1770874 - part 2: Move the lambda in `EditorEventListener::Focus` to `EditorBase` r=m_kato
It's currently a public method, but it can be protected in a following patch.

Differential Revision: https://phabricator.services.mozilla.com/D147138
2022-05-27 03:47:34 +00:00
Masayuki Nakano a0a7f2ac76 Bug 1770874 - part 1: Make some clean ups around `EditorBase::OnFocus` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D147137
2022-05-27 03:47:33 +00:00
Masayuki Nakano f93d054430 Bug 1770133 - part 3: Make `EditorBase::GetFocusedContent()` return `Element*` instead of `nsIContent*` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D147134
2022-05-26 07:03:20 +00:00
Masayuki Nakano 6817b54c9d Bug 1770133 - part 2: Make `IMEStateManager::sFocusedContent` store it as `Element` r=m_kato
`nsFocusManager` defines that focused content is at least `dom::Element`.
So `IMEStateManager` can handle focused content with `dom::Element` too.

Additionally, this patch makes `IMEStateManager` methods take references instead
of pointers as far as possible if they just return error for `nullptr`.

Differential Revision: https://phabricator.services.mozilla.com/D147133
2022-05-26 07:03:19 +00:00
Masayuki Nakano 971efcf6d8 Bug 1770684 - Mark `IMEStateManager::SetIMEState` and its callers in `IMEStateManager` as `MOZ_CAN_RUN_SCRIPT` r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D147071
2022-05-26 04:37:21 +00:00
Masayuki Nakano cdfbc99cdf Bug 1680611 - part 6: Mark `nsFocusManager::MoveCaretToFocus()` and its callers in `nsFocusManager` as `MOZ_CAN_RUN_SCRIPT` r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D147065
2022-05-26 04:37:19 +00:00
Molnar Sandor 05e3775a6c Backed out 4 changesets (bug 1770727) for causing mochitest failures in test_bug1180105/test_access_control. CLOSED TREE
Backed out changeset 6323b526b0ac (bug 1770727)
Backed out changeset fc7ea80aa2ff (bug 1770727)
Backed out changeset 2a358ba86652 (bug 1770727)
Backed out changeset 464d1af6523b (bug 1770727)
2022-05-24 17:24:40 +03:00
Mark Banner 18b014551e Bug 1770727 - Fix failures of ESLint rule mozilla/use-includes-instead-of-indexOf in sjs files. r=Gijs
Depends on D147081

Differential Revision: https://phabricator.services.mozilla.com/D147082
2022-05-24 12:59:09 +00:00
Masayuki Nakano 1ca919ee58 Bug 1766355 - part 9: Make `HTMLEditor::ReplaceContainerWithTransactionInternal` and its callers use `MoveNodeTransaction` and return `CreateElementResult` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146405
2022-05-20 10:44:04 +00:00
Masayuki Nakano b62e2b0629 Bug 1766355 - part 8: Make `HTMLEditor::RemoveBlockContainerWithTransaction` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146404
2022-05-20 09:57:38 +00:00
Masayuki Nakano f5d4ddc057 Bug 1766355 - part 7: Rewrite `HTMLEditor::RemoveContainerWithTransaction` with `MoveNodeTransaction` and make it stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146403
2022-05-20 09:01:40 +00:00
Masayuki Nakano e0d3f2aa96 Bug 1766355 - part 6: Make `HTMLEditor::MoveOneHardLineContents` return `MoveNodeResult` with caret point suggestion r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146402
2022-05-20 08:51:41 +00:00
Masayuki Nakano ec1386e3eb Bug 1766355 - part 5: Make `HTMLEditor::MoveChildrenWithTransaction` and `HTMLEditor::MoveNodeOrChildrenWithTransaction` stop touching `Selection` directly r=m_kato
Unfortunately, they call each other.  Therefore, this patch updates these 2
methods once.

Differential Revision: https://phabricator.services.mozilla.com/D146401
2022-05-20 08:40:59 +00:00
Masayuki Nakano 51a4bc4fb8 Bug 1766355 - part 4: Make `HTMLEditor::MoveNodeWithTransaction` and `HTMLEditor::MoveNodeToEndWithTransaction` return `MoveNodeResult` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146400
2022-05-20 08:28:09 +00:00
Masayuki Nakano ca554ccd03 Bug 1766355 - part 3: Make `MoveNodeResult` store caret point suggestion r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146399
2022-05-20 08:28:09 +00:00
Masayuki Nakano a0180a0f22 Bug 1766355 - part 2: Make `MoveNodeResult` method names alinging to `Result` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146398
2022-05-20 08:28:08 +00:00
Masayuki Nakano c5b2a589bd 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 5a6a9a0045 Bug 1730442 - part 7: Rewrite `HTMLEditor::InsertTableRowsWithTransaction()` to collect any cell information before touching the DOM tree r=m_kato
This patch also makes it inserts table rows immediately after the previous
row element of the found reference row element to make it insert new table
rows immediately after there when inserting position is "after".  Typically,
it's the parent `<tr>` element of `aCellElement`.  Therefore, this approach
can preserve text nodes immediately after it which was intentionally inserted
by the web apps.

Differential Revision: https://phabricator.services.mozilla.com/D146365
2022-05-20 07:39:53 +00:00
Masayuki Nakano bc4493c724 Bug 1730442 - part 6: Make `HTMLEditor::InsertTableColumnsWithTransaction()` collect all necessary data before touching the DOM tree r=m_kato
It needs to work with the latest layout information to consider which cell
element is the insertion point due to rowspan and colspan.  Therefore,
this patch makes it collects all cell data before touching the DOM except
the case that it needs to normalize the table to make it rectanble.

Note that the case requiring the normalizer should be fixed in a later patch.

This method is corresponding to an XPCOM method.  Therefore, this is tested
by `test_nsITableEditor_insertTableColumn.html`.

And also it's used by the inline table editor, but we don't have automated tests
for this because of no API to get the buttons.  Therefore, I tested it by my
hand.

Note that the old code fails to put caret to newly inserted cell at the reftest
situation.  This fixes the bug too.  Therefore, this changes the reftest's
reference.

Differential Revision: https://phabricator.services.mozilla.com/D146364
2022-05-20 07:39:53 +00:00
Masayuki Nakano 7b7e50e829 Bug 1730442 - part 5: Rewrite `HTMLEditor::GetNextTableRowElement()` as returning `Result<RefPtr<Element>, nsresult>` r=m_kato
There is no direct test because of no corresponding XPCOM method, but this is
called only by `HTMLEditor::InsertTableColumnsWithTransaction()` which is
tested by `test_nsITableEditor_insertTableColumn.html`.  Anyway, the chagne is
really simple.

Differential Revision: https://phabricator.services.mozilla.com/D146363
2022-05-20 07:39:52 +00:00
Masayuki Nakano f8da7ad612 Bug 1730442 - part 4: Rewrite `HTMLEditor::GetFirstTableRowElement()` as returing `Result<RefPtr<Element>, nsresult>` r=m_kato
This change is tested by `test_nsITableEditor_getFirstRow.html` and
`test_nsITableEditor_insertTableColumn.html`.

Differential Revision: https://phabricator.services.mozilla.com/D146362
2022-05-20 07:39:52 +00:00
Masayuki Nakano 88c3133a0b Bug 1730442 - part 3: Make `HTMLEditor::InsertTableCellsWithTransaction()` work without layout information r=m_kato
It refers the layout information for getting row/column index of selected cell
element or a cell element which contains selection.  However, it can stop
referring it if all callers can specify insertion point of new cells, and it's
possible.  Therefore, we can make it free from layout information.

Note that this blocks legacy mutation events during inserting table cell
elements, but perhaps this does not cause problems in the wild.
`DOMNodeInserted` will be fired after all cell elements are inserted, so
from point of view of the event listeners, editor content is different from
traditional behavior, but this works only when user uses inline table editor
which is disabled by default.  I.e., in the wild, this path is rarely run.

Additionally, this patch makes it return `CreateElementResult` for the latter
changes which want to put caret to first inserted cell element.

Note that the changes are tested by `test_nsITableEditor_insertTableColumn.html`
and `test_nsITableEditor_insertTableCell.html`.

Differential Revision: https://phabricator.services.mozilla.com/D146361
2022-05-20 07:39:52 +00:00
Masayuki Nakano 91af804816 Bug 1730442 - part 2: Rewrite `HTMLEditor::GetSelectedOrParentTableElement()` as returing `Result<RefPtr<Element>, nsresult>` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146360
2022-05-20 07:39:51 +00:00
Masayuki Nakano 458bf2e95e Bug 1730442 - part 1: Make all `nsITableEditor` features flush pending layout at start to handle their jobs r=m_kato
Our table editor depends on layout information for getting raw/column position
of a cell, checking rawspan/colspan information and table size.  Therefore,
they require the latest information, but they don't flush pending layout by
themselves.  Therefore, this patch makes them do it by themselves and deleting
unnecessary hack from their tests.

Differential Revision: https://phabricator.services.mozilla.com/D146359
2022-05-20 07:39:51 +00:00
Kagami Sascha Rosylight f07b765323 Bug 1765832 - Part 3: Remove AutoSelectionSetterAfterTableEdit::CancelSetCaret r=masayuki
The comment is lying as nothing actually uses it.

Differential Revision: https://phabricator.services.mozilla.com/D146631
2022-05-18 18:07:01 +00:00
criss 441a887295 Backed out 3 changesets (bug 1765832) for causing build bustages on Transferable.cpp
Backed out changeset c7c5a5208d60 (bug 1765832)
Backed out changeset 05a53421e1d8 (bug 1765832)
Backed out changeset 87cf3ec70aab (bug 1765832)
2022-05-18 16:28:24 +03:00
Kagami Sascha Rosylight 84b7cbf6ca Bug 1765832 - Part 3: Remove AutoSelectionSetterAfterTableEdit::CancelSetCaret r=masayuki
The comment is lying as nothing actually uses it.

Differential Revision: https://phabricator.services.mozilla.com/D146631
2022-05-18 12:57:45 +00:00
Bogdan Szekely 4ef183d00f Merge autoland to mozilla-central. a=merge 2022-05-17 12:26:46 +03:00
Molnar Sandor 416e516586 Backed out 7 changesets (bug 1730442) for causing reftest failures in editor/reftests/inline-table-editor-position-after-updating-table-size-from-input-event-listener.html. CLOSED TREE
Backed out changeset f6d7f162e57a (bug 1730442)
Backed out changeset e5d1671b3bbc (bug 1730442)
Backed out changeset e60a5cd69184 (bug 1730442)
Backed out changeset 943d4e4b0770 (bug 1730442)
Backed out changeset bd3324b635f4 (bug 1730442)
Backed out changeset ada0dda5bcde (bug 1730442)
Backed out changeset b67c4035c12f (bug 1730442)
2022-05-17 04:23:36 +03:00
Masayuki Nakano 07fe22e0af Bug 1730442 - part 7: Rewrite `HTMLEditor::InsertTableRowsWithTransaction()` to collect any cell information before touching the DOM tree r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D146365
2022-05-17 00:12:11 +00:00
Masayuki Nakano 8e6525993d Bug 1730442 - part 6: Make `HTMLEditor::InsertTableColumnsWithTransaction()` collects all necessary data before touching the DOM tree r=m_kato
It needs to work with the latest layout information to consider which cell
element is the insertion point due to rowspan and colspan.  Therefore,
this patch makes it collects all cell data before touching the DOM except
the case that it needs to normalize the table to make it rectanble.

Note that the case requring the normalizer should be fixed in a later patch.

This method is corresponding to an XPCOM method.  Therefore, this is tested
by `test_nsITableEditor_insertTableColumn.html`.

And also it's used by the inline table editor, but we don't have automated tests
for this because of no API to get the buttons.  Therefore, I tested it by my
hand.

Depends on D146363

Differential Revision: https://phabricator.services.mozilla.com/D146364
2022-05-17 00:12:11 +00:00
Masayuki Nakano 34b66d7d35 Bug 1730442 - part 5: Rewrite `HTMLEditor::GetNextTableRowElement()` as returning `Result<RefPtr<Element>, nsresult>` r=m_kato
There is no direct test because of no corresponding XPCOM method, but this is
called only by `HTMLEditor::InsertTableColumnsWithTransaction()` which is
tested by `test_nsITableEditor_insertTableColumn.html`.  Anyway, the chagne is
really simple.

Depends on D146362

Differential Revision: https://phabricator.services.mozilla.com/D146363
2022-05-17 00:12:10 +00:00
Masayuki Nakano e220fdf55a Bug 1730442 - part 4: Rewrite `HTMLEditor::GetFirstTableRowElement()` as returing `Result<RefPtr<Element>, nsresult>` r=m_kato
This change is tested by `test_nsITableEditor_getFirstRow.html` and
`test_nsITableEditor_insertTableColumn.html`.

Depends on D146361

Differential Revision: https://phabricator.services.mozilla.com/D146362
2022-05-17 00:12:10 +00:00
Masayuki Nakano 757378b453 Bug 1730442 - part 3: Make `HTMLEditor::InsertTableCellsWithTransaction()` work without layout information r=m_kato
It refers the layout information for getting row/column index of selected cell
element or a cell element which contains selection.  However, it can stop
referring it if all callers can specify insertion point of new cells, and it's
possible.  Therefore, we can make it free from layout information.

Note that this blocks legacy mutation events during inserting table cell
elements, but perhaps this does not cause problems in the wild.
`DOMNodeInserted` will be fired after all cell elements are inserted, so
from point of view of the event listeners, editor content is different from
traditional behavior, but this works only when user uses inline table editor
which is disabled by default.  I.e., in the wild, this path is rarely run.

Note that the changes are tested by `test_nsITableEditor_insertTableColumn.html`
and `test_nsITableEditor_insertTableCell.html`.

Depends on D146360

Differential Revision: https://phabricator.services.mozilla.com/D146361
2022-05-17 00:12:09 +00:00
Masayuki Nakano 4db95885b9 Bug 1730442 - part 2: Rewrite `HTMLEditor::GetSelectedOrParentTableElement()` as returing `Result<RefPtr<Element>, nsresult>` r=m_kato
Depends on D146359

Differential Revision: https://phabricator.services.mozilla.com/D146360
2022-05-17 00:12:09 +00:00