Commit Graph

219 Commits

Author SHA1 Message Date
Masayuki Nakano
8b7dbfe141 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
b70c34fad4 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
57e39bc290 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
67e3cd1e1b 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
de0b3d64bf 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
856eca7a46 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
2927029a36 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
d44806526e 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
bf2814531c 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
8f22fb5a79 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
facc85ec3f 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
59a0d11277 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
Molnar Sandor
13ebce2a4b 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
a879a3a5b1 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
a5e4fd1706 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
a9171a4605 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
a8325c96c2 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
dd44ce1c11 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
d035d0bdc4 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
Masayuki Nakano
c74c282325 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-17 00:12:08 +00:00
Masayuki Nakano
0e1112df64 Bug 1768768 - part 3: Make CellData users create its instance with static factory method r=saschanaz
For avoiding updating `CellData` member(s) to make the static analysis work,
`CellData::Update` shouldn't be used.  Instead, it should be created for each
cell whose detail is required.

Differential Revision: https://phabricator.services.mozilla.com/D146137
2022-05-13 07:38:39 +00:00
Masayuki Nakano
afe09f9d08 Bug 1768768 - part 2: Make the table editing helper classes not taking ErrorResult r=saschanaz
The callers don't need the detail of the error, and the runtime cost of
`ErrorResult` may not be cheap because it sometimes appear in profiles.
Therefore, they should be removed.

Differential Revision: https://phabricator.services.mozilla.com/D146136
2022-05-13 07:38:38 +00:00
Masayuki Nakano
2225052a0f Bug 1768768 - part 1: Move method definitions of helper nested classes for table editing to top of HTMLTableEditor.cpp r=saschanaz
They will be changed to factory methods.  Therefore, they shouldn't be in
middle of the cpp file.

This patch just moves them without any changes.

Differential Revision: https://phabricator.services.mozilla.com/D146135
2022-05-13 07:38:38 +00:00
Bogdan Szekely
d355bd8c72 Backed out 3 changesets (bug 1768768) for causing build bustages on HTMLTableEditor.cpp. CLOSED TREE
Backed out changeset 2e76f36048fd (bug 1768768)
Backed out changeset 0cc9f684a021 (bug 1768768)
Backed out changeset 4ae39133d7ee (bug 1768768)
2022-05-13 08:50:43 +03:00
Masayuki Nakano
9e903826fa Bug 1768768 - part 3: Make CellData users create its instance with static factory method r=saschanaz
For avoiding updating `CellData` member(s) to make the static analysis work,
`CellData::Update` shouldn't be used.  Instead, it should be created for each
cell whose detail is required.

Differential Revision: https://phabricator.services.mozilla.com/D146137
2022-05-13 05:33:04 +00:00
Masayuki Nakano
4994ad695b Bug 1768768 - part 2: Make the table editing helper classes not taking ErrorResult r=saschanaz
The callers don't need the detail of the error, and the runtime cost of
`ErrorResult` may not be cheap because it sometimes appear in profiles.
Therefore, they should be removed.

Differential Revision: https://phabricator.services.mozilla.com/D146136
2022-05-13 05:33:04 +00:00
Masayuki Nakano
95384cd715 Bug 1768768 - part 1: Move method definitions of helper nested classes for table editing to top of HTMLTableEditor.cpp r=saschanaz
They will be changed to factory methods.  Therefore, they shouldn't be in
middle of the cpp file.

This patch just moves them without any changes.

Differential Revision: https://phabricator.services.mozilla.com/D146135
2022-05-13 05:33:03 +00:00
Masayuki Nakano
ed197035df Bug 1762115 - part 13: Make EditorBase::InsertNodeWithTransaction stop touching Selection directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D144656
2022-05-03 01:21:51 +00:00
Masayuki Nakano
a8350c4163 Bug 1764684 - part 3: Fix and improve warnings of the result of EditorBase::CollapseSelectionTo* r=m_kato
Some of them were `HTMLEditor` so that we need to fix it to `EditorBase`, and
also this patch fixes `NS_ERROR_EDITOR_DESTROYED` handling around them.

Differential Revision: https://phabricator.services.mozilla.com/D143815
2022-04-20 14:36:53 +00:00
Masayuki Nakano
22aa786ab3 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
61e9d3589d 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
daf79ccd1e 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
Chris Peterson
693305074b Bug 1732234 - Fix non-unified build errors in editor/. r=masayuki
Building with `ac_add_options --disable-unified-build` on macOS hits the following -Wunreachable-code-return warnings-as-errors:

editor/libeditor/HTMLEditor.cpp:4341:26 [-Wunreachable-code-return] 'return' will never be executed
editor/libeditor/HTMLTableEditor.cpp:1629:10: warning: 'return' will never be executed [-Wunreachable-code-return]

Differential Revision: https://phabricator.services.mozilla.com/D126441
2021-09-28 04:26:52 +00:00
Masayuki Nakano
351e9433cd Bug 1718815 - part 4: Move EditorBase::AppendNodeToSelectionAsRange() and EditorBase::ClearSelection() to HTMLEditor r=m_kato
Depends on D119003

Differential Revision: https://phabricator.services.mozilla.com/D119004
2021-07-02 08:23:46 +00:00
Masayuki Nakano
537ba14656 Bug 1627175 - part 23: Move HTMLEditor::IsEmptyNode() into HTMLEditUtils with making it take EnumSet instead of bool arguments r=m_kato
It's hard to understand each caller of `HTMLEditor::IsEmptyNode()` tries to
check with multiple `bool` arguments.  Therefore, they should be replaced
with an `EnumSet`.

Note that only the first argument is reverted the meaning.  Therefore, if
it's omitted or `false`, `EmptyCheckOption::TreatSingleBRElementAsVisible`
is specified explicitly.  Otherwise, i.e., `true`, nothing should be
specified.

Differential Revision: https://phabricator.services.mozilla.com/D112513
2021-04-20 12:02:17 +00:00
Masayuki Nakano
04ff975886 Bug 1703144 - Get rid of MOZ_KnownLive for EditorBase::SelectionRefPtr() r=m_kato
The lifetime of it is guaranteed by `AutoEditActionDataSetter` which grabs
`Selection` until it's destroyed, and it's a stack only class and created
at first step of all public method calls.  Therefore, we can mark it as
`MOZ_KNOWN_LIVE` and we can change it returning reference of `Selection`
instead of reference of `RefPtr<Selection>`.

Differential Revision: https://phabricator.services.mozilla.com/D110896
2021-04-08 01:31:54 +00:00
Kagami Sascha Rosylight
7057dbdc56 Bug 1671768 - Part 4: Use MOZ_CAN_RUN_SCRIPT for Selection::RemoveAllRanges r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D103780
2021-02-03 21:52:48 +00:00
Masayuki Nakano
76d37a8bfd Bug 1671556 - part 14: Get rid of HTMLEditor::GetFirstSelectedTableCellElement(), HTMLEditor::GetNextSelectedTableCellElement() and HTMLEditor::mSelectedCellIndex r=m_kato
Depends on D94240

Differential Revision: https://phabricator.services.mozilla.com/D94241
2020-10-26 05:53:58 +00:00
Masayuki Nakano
2494dc5b34 Bug 1671556 - part 13: Make HTMLEditor::GetFirstSelectedCellInTable() stop using CellAndIndexes which uses HTMLEditor::GetFirstSelectedTableCellElement() r=m_kato
The method is tested by `test_nsITableEditor_getFirstSelectedCellInTable.html`.

And now, nobody uses `CellAndIndexes` so that this patch removes it.

Depends on D94239

Differential Revision: https://phabricator.services.mozilla.com/D94240
2020-10-26 05:53:26 +00:00
Masayuki Nakano
20084eaf59 Bug 1671556 - part 12: Make HTMLEditor::GetSelectedOrParentTableElement() stop using HTMLEditor::GetFirstSelectedTableCellElement() r=m_kato
This is tested by `test_nsITableEditor_getSelectedOrParentTableElement.html`.

Depends on D94238

Differential Revision: https://phabricator.services.mozilla.com/D94239
2020-10-26 05:24:12 +00:00
Masayuki Nakano
e51e8fcaf4 Bug 1671556 - part 11: Make HTMLEditor::GetSelectedCellsType() stop using HTMLEditor::Get(First|Next)SelectedTableCellElement() r=m_kato
Depends on D94236

Differential Revision: https://phabricator.services.mozilla.com/D94238
2020-10-26 05:06:59 +00:00
Masayuki Nakano
793bd7ebf3 Bug 1671556 - part 10: Make HTMLEditor::JoinTableCells() stop using HTMLEditor::Get(First|Next)SelectedTableCellElement() r=m_kato
Unfortunately, there is no automated tests for `nsITableEditor.joinTableCells()`
and it'll take a couple of days to write its testcase because of too big
method.  And it's not so important for Firefox (although it's used in
comm-central).  Therefore, this patch skips to check it.

Note that `CellAndIndexes` uses `HTMLEditor::GetFirstSelectedTableCellElement()`
to retrieve first selected cell element and then, it retrieves its indexes.
https://searchfox.org/mozilla-central/rev/61728de8273c04fe2417c475fc0637e8b79210d7/editor/libeditor/HTMLTableEditor.cpp#4090,4098,4109
Therefore, this patch makes it stop using this simple structure too.

Depends on D94235

Differential Revision: https://phabricator.services.mozilla.com/D94236
2020-10-26 05:04:51 +00:00
Masayuki Nakano
7675cb01d8 Bug 1671556 - part 9: Make HTMLEditor::DeleteSelectedTableRowsWithTransaction() stop using HTMLEditor::Get(First|Next)SelectedTableCellElement() r=m_kato
This is tested by `test_nsITableEditor_deleteTableRow.html`.

Differential Revision: https://phabricator.services.mozilla.com/D94235
2020-10-24 04:14:03 +00:00
Masayuki Nakano
b4aa1ae97a Bug 1671556 - part 8: Make HTMLEditor::DeleteSelectedTableColumnWithTransaction() stop using HTMLEditor::Get(First|Next)SelectedTableCellElement() r=m_kato
This is tested by `test_nsITableEditor_deleteTableColumn.html`.

Differential Revision: https://phabricator.services.mozilla.com/D94234
2020-10-24 04:13:55 +00:00
Masayuki Nakano
af5053e498 Bug 1671556 - part 7: Make HTMLEditor::DeleteTableCellContentsWithTransaction() stop using HTMLEditor::Get(First|Next)SelectedTableCellElement() r=m_kato
This is tested by `test_nsITableEditor_deleteTableCellContents.html`.

Differential Revision: https://phabricator.services.mozilla.com/D94233
2020-10-24 04:13:43 +00:00
Masayuki Nakano
a12c4d62a5 Bug 1671556 - part 6: Make HTMLEditor::DeleteTableCellWithTransaction() stop using HTMLEditor::Get(First|Next)SelectedTableCellElement() r=m_kato
This method is tested by `test_nsITableEditor_deleteTableCell.html`.

Differential Revision: https://phabricator.services.mozilla.com/D94232
2020-10-24 04:13:30 +00:00
Masayuki Nakano
966eb165ce Bug 1671556 - part 2: Replace nsITableEditor.getFirstSelectedCell() and nsITableEditor.getNextSelectedCell() with nsITableEditor.getSelectedCells() r=m_kato
`nsITableEditor.getFirstSelectedCell()` and
`nsITableEditor.getNextSelectedCell()` use `HTMLEditor::mSelectedCellIndex`
via their internal methods.  That makes these API unstable if mutation happens
between the calls.  Therefore, it's really simpler and stabler that there is
an API to return selected table cell elements once.

Therefore this patch creates new API, `nsITableEditor.getSelectedCells()`,
which returns array of selected table cell elements.  And it stops taking
inconsistent behavior of the old API:
1. Even if there is no selection. it does not throw an exception.
https://searchfox.org/mozilla-central/rev/61728de8273c04fe2417c475fc0637e8b79210d7/editor/libeditor/HTMLTableEditor.cpp#3956-3961
2. Even if it meets selection range in a text node (i.e.,
`nsRange::GetChildAtStartOffset()` returns `nullptr`), this just ignores the
range.
https://searchfox.org/mozilla-central/rev/61728de8273c04fe2417c475fc0637e8b79210d7/editor/libeditor/HTMLTableEditor.cpp#4041-4047

The following patches will remove their internal methods too.

Differential Revision: https://phabricator.services.mozilla.com/D94228
2020-10-24 04:12:38 +00:00
Masayuki Nakano
4830b432a8 Bug 1671556 - part 1: Make nsITableEditor.getFirstSelectedCell() and nsITableEditor.getNextSelectedCell() stop returning selected range with out argument r=m_kato
These APIs are used only in comm-central (not in BlueGriffon) and nobody
refers the out argument which is selected range of the cell selection.
Therefore, we should drop them to make the APIs simpler.

Differential Revision: https://phabricator.services.mozilla.com/D94226
2020-10-24 04:12:15 +00:00
Mihai Alexandru Michis
d019be32de Backed out 4 changesets (bug 1671556, bug 1669479) for causing bustages in HTMLEditUtils.h
CLOSED TREE

Backed out changeset 17405d242d1b (bug 1671556)
Backed out changeset fe3735c5aac9 (bug 1671556)
Backed out changeset 585df60d18f9 (bug 1671556)
Backed out changeset e94d989b8cb4 (bug 1669479)
2020-10-23 15:10:04 +03:00
Masayuki Nakano
40b3dcb015 Bug 1671556 - part 2: Replace nsITableEditor.getFirstSelectedCell() and nsITableEditor.getNextSelectedCell() with nsITableEditor.getSelectedCells() r=m_kato
`nsITableEditor.getFirstSelectedCell()` and
`nsITableEditor.getNextSelectedCell()` use `HTMLEditor::mSelectedCellIndex`
via their internal methods.  That makes these API unstable if mutation happens
between the calls.  Therefore, it's really simpler and stabler that there is
an API to return selected table cell elements once.

Therefore this patch creates new API, `nsITableEditor.getSelectedCells()`,
which returns array of selected table cell elements.  And it stops taking
inconsistent behavior of the old API:
1. Even if there is no selection. it does not throw an exception.
https://searchfox.org/mozilla-central/rev/61728de8273c04fe2417c475fc0637e8b79210d7/editor/libeditor/HTMLTableEditor.cpp#3956-3961
2. Even if it meets selection range in a text node (i.e.,
`nsRange::GetChildAtStartOffset()` returns `nullptr`), this just ignores the
range.
https://searchfox.org/mozilla-central/rev/61728de8273c04fe2417c475fc0637e8b79210d7/editor/libeditor/HTMLTableEditor.cpp#4041-4047

The following patches will remove their internal methods too.

Differential Revision: https://phabricator.services.mozilla.com/D94228
2020-10-23 10:51:13 +00:00