Redesign `nsITableEditor.getFirstSelectedCell()` and relatives
Categories
(Core :: DOM: Editor, enhancement, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox84 | --- | fixed |
People
(Reporter: masayuki, Assigned: masayuki)
References
(Blocks 3 open bugs)
Details
Attachments
(14 files)
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review | |
|
47 bytes,
text/x-phabricator-request
|
Details | Review |
For fixing bug 1669479 easier, I'd like to redesign nsITableEditor.getFirstSelectedCell() and relatives.
Currently, they are designed as iterator methods to retrieve selected table cells one by one, and returns the selected range for the cell element.
So, they are stateful and they may behave odd if selection or the DOM tree changed during the calls.
Additionally, nobody users the returned range.
- https://searchfox.org/comm-central/rev/10eba65ee28fe96fc58eb49eeb2b3af80a45c5bc/editor/ui/dialogs/content/EdTableProps.js#1320-1321,1323,1354
- https://searchfox.org/comm-central/rev/10eba65ee28fe96fc58eb49eeb2b3af80a45c5bc/mail/components/compose/content/dialogs/EdTableProps.js#1317,1320,1351
- https://searchfox.org/comm-central/rev/10eba65ee28fe96fc58eb49eeb2b3af80a45c5bc/editor/ui/composer/content/editor.js#2947
- https://searchfox.org/comm-central/rev/10eba65ee28fe96fc58eb49eeb2b3af80a45c5bc/editor/ui/composer/content/editor.js#2982
- https://searchfox.org/comm-central/rev/10eba65ee28fe96fc58eb49eeb2b3af80a45c5bc/mail/components/compose/content/editor.js#2308
- https://searchfox.org/comm-central/rev/10eba65ee28fe96fc58eb49eeb2b3af80a45c5bc/mail/components/compose/content/editor.js#2343
And surprisingly, these callers always causes an exception for due to few arguments.
- https://searchfox.org/comm-central/rev/10eba65ee28fe96fc58eb49eeb2b3af80a45c5bc/editor/ui/dialogs/content/EdInsertTable.js#221
- https://searchfox.org/comm-central/rev/10eba65ee28fe96fc58eb49eeb2b3af80a45c5bc/mail/components/compose/content/dialogs/EdInsertTable.js#221
So, we can make the API return array of selected cell elements instead.
| Assignee | ||
Updated•5 years ago
|
| Assignee | ||
Updated•5 years ago
|
| Assignee | ||
Updated•5 years ago
|
| Assignee | ||
Comment 1•5 years ago
|
||
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.
Depends on D94225
| Assignee | ||
Comment 2•5 years ago
|
||
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:
- 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 - Even if it meets selection range in a text node (i.e.,
nsRange::GetChildAtStartOffset()returnsnullptr), 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.
Depends on D94226
| Assignee | ||
Comment 3•5 years ago
|
||
Depends on D94228
| Assignee | ||
Comment 4•5 years ago
|
||
Although it's not tested yet, but I have no idea how to test it.
https://coverage.moz.tools/#revision=latest&path=editor%2Flibeditor%2FHTMLEditorDataTransfer.cpp&view=file&line=545
Depends on D94229
| Assignee | ||
Comment 5•5 years ago
|
||
Depends on D94230
| Assignee | ||
Comment 6•5 years ago
|
||
This method is tested by test_nsITableEditor_deleteTableCell.html.
Depends on D94231
| Assignee | ||
Comment 7•5 years ago
|
||
This is tested by test_nsITableEditor_deleteTableCellContents.html.
Depends on D94232
| Assignee | ||
Comment 8•5 years ago
|
||
This is tested by test_nsITableEditor_deleteTableColumn.html.
Depends on D94233
| Assignee | ||
Comment 9•5 years ago
|
||
This is tested by test_nsITableEditor_deleteTableRow.html.
Depends on D94234
| Assignee | ||
Comment 10•5 years ago
|
||
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
| Assignee | ||
Comment 11•5 years ago
|
||
Depends on D94236
| Assignee | ||
Comment 12•5 years ago
|
||
This is tested by test_nsITableEditor_getSelectedOrParentTableElement.html.
Depends on D94238
| Assignee | ||
Comment 13•5 years ago
|
||
The method is tested by test_nsITableEditor_getFirstSelectedCellInTable.html.
And now, nobody uses CellAndIndexes so that this patch removes it.
Depends on D94239
| Assignee | ||
Comment 14•5 years ago
|
||
Depends on D94240
| Assignee | ||
Updated•5 years ago
|
| Assignee | ||
Updated•5 years ago
|
Comment 15•5 years ago
|
||
Comment 16•5 years ago
|
||
Backed out 4 changesets (Bug 1671556, Bug 1669479) for causing bustages in HTMLEditUtils.h
Backout link: https://hg.mozilla.org/integration/autoland/rev/2221accc694f206651cccf4adfa53344c193b636
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=319535344&repo=autoland&lineNumber=76667
Comment 17•5 years ago
|
||
| Assignee | ||
Updated•5 years ago
|
Comment 18•5 years ago
|
||
Comment 19•5 years ago
|
||
Comment 21•5 years ago
|
||
Comment 22•5 years ago
|
||
Comment 23•5 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/b2f73fb6876b
https://hg.mozilla.org/mozilla-central/rev/aefb7fc23dc0
https://hg.mozilla.org/mozilla-central/rev/2a1f19d58fa5
https://hg.mozilla.org/mozilla-central/rev/b3008d2467ea
https://hg.mozilla.org/mozilla-central/rev/ef35e6316c77
https://hg.mozilla.org/mozilla-central/rev/78130fed97b7
Comment 24•5 years ago
|
||
Comment 25•5 years ago
|
||
Comment 26•5 years ago
|
||
| bugherder | ||
Comment 28•5 years ago
|
||
Comment 29•5 years ago
|
||
Comment 30•5 years ago
|
||
Comment 31•5 years ago
|
||
Comment 32•5 years ago
|
||
Comment 33•5 years ago
|
||
| bugherder | ||
| Assignee | ||
Updated•5 years ago
|
Description
•