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

10483 Коммитов

Автор SHA1 Сообщение Дата
Kagami Sascha Rosylight 7db6203754 Bug 1678361 - Return gracely when GetDataTransfer fails r=masayuki
DragEvent::GetDataTransfer() is fallible when memory allocation fails as it lazily constructs DataTransfer. This tries failing gracely when that happens.

Differential Revision: https://phabricator.services.mozilla.com/D97663
2020-11-20 06:04:43 +00:00
Mirko Brodesser 2bd707b236 Bug 1669963: factor some constants and functions for testing the clipboard out. r=ahal
They'll be used by other tests too.

Differential Revision: https://phabricator.services.mozilla.com/D97329
2020-11-17 20:28:48 +00:00
Masayuki Nakano 1edcd70cdd Bug 1676295 - Add WPT to test deleting in/around/across list items r=smaug
There are not enough tests comparing delete operation result and result of
`getTargetRanges()` when selection is in/around/across list item elements.
This patch creates a utility method to make the test body not need to use
Selection API for making simpler tests.

The expected behavior is based on Blink and WebKit unless their behavior is
buggy because their behavior is more reasonable than Gecko's in most cases.

Note that the removing tests are covered by the new tests.

Differential Revision: https://phabricator.services.mozilla.com/D96800
2020-11-14 10:30:31 +00:00
Masayuki Nakano 00b602a0f0 Bug 1627673 - Do null-check the result of `DragEvent::GetDataTransfer()` in `EditorEventListener`` r=smaug
I guess that `DataTransfer::HasType()` is inlined in the opt builds and
actually crashed in `EditorEventListener::DragEventHasSupportingData()`
at accessing `aDragEvent->GetDataTransfer()` result without null-check
because `DataTransfer::mItems` is set to `nullptr` only by the cycle
collector, but it does not make sense to think that it occurs the STR
in bug 1627673 comment 3.

Therefore, this patch adds null-checks in
`EditorEventListener::DragEventHasSupportingData()`.

I have no idea how to test this with automated tests.

Differential Revision: https://phabricator.services.mozilla.com/D96310
2020-11-09 23:39:10 +00:00
Masayuki Nakano c6d7f7e4f8 Bug 1605741 - Make all callers of `HTMLEditor::InsertBRElementIfHardLineIsEmptyAndEndsWithBlockBoundary()` check whether there is a caret or not r=m_kato
`InsertBRElementIfHardLineIsEmptyAndEndsWithBlockBoundary()` checks whether
a line containing `aPointToInsert` requires invisible `<br>` element.
Therefore, `aPointToInsert` must be set and valid.  However, all selection
ranges may be removed by somebody when modifying the DOM tree before that.

Therefore, this patch makes all callers of it check whether they succeeded
to retrieve caret position or not.

Differential Revision: https://phabricator.services.mozilla.com/D96280
2020-11-09 03:01:16 +00:00
Masayuki Nakano 6109e35d9e Bug 1579934 - Make `WhiteSpaceVisibilityKeeper::MergeFirstLineOf*()` stop handling their job if calling `DeleteInvisibleASCIIWhiteSpace()` makes the descendant block position changed r=m_kato
They join first line of a descendant block element into the line at the other
block contains the descendant block.  First of all of their jobs, they call
`DeleteInvisibleASCIIWhiteSpace()` to clean up unnecessary whitespaces at
the other block.  At this time, the point which tells whether the descendant
element is contained in the other block may become invalid if script runs
and it causes changing the DOM tree.  Therefore, they should check the
given point is still valid after calling `DeleteInvisibleASCIIWhiteSpace()`
because `AutoTrackDOMPoint` requires valid point.

Differential Revision: https://phabricator.services.mozilla.com/D95987
2020-11-06 06:38:49 +00:00
Masayuki Nakano 994715338f Bug 1578916 - Add reported testcase to crashtests (the crash was fixed by bug 1627175) r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D95983
2020-11-06 04:07:28 +00:00
Andrew Halberstadt 331bc892dd Bug 1675319 - [manifestparser] Properly support multiline skip-if statements, r=jmaher,extension-reviewers,zombie
This supports one manifestparser expression per line in the 'skip-if',
'fail-if' and 'run-if' keys. As a side effect the:

    skip-if = foo ||
        bar

syntax is no longer supported. Instead it can be:

    skip-if =
        foo  # bug 123
        bar  # bug 456

Differential Revision: https://phabricator.services.mozilla.com/D95927
2020-11-05 19:55:08 +00:00
tobar2018 eb66350c76 Bug 1674609 - HTMLEditorDeleteHandler.cpp: redundant continue statement at the end of loop statement. r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D95669
2020-11-03 22:58:01 +00:00
Masayuki Nakano ec06061862 Bug 1581246 - Add reported testcase as a crashtest (the crash was fixed by bug 1666556) r=m_kato
This does not require recursive call of `execCommand` so that this does not
set the pref.

Depends on D95268

Differential Revision: https://phabricator.services.mozilla.com/D95269
2020-10-30 12:03:59 +00:00
Masayuki Nakano 10b3906382 Bug 1666556 - Make `HTMLEditor` stop accepting focus event when a text control which is an editing host gets focus r=m_kato
`HTMLEditor` ignores input events when a text control element in an editing
host has focus.
https://searchfox.org/mozilla-central/rev/d866b96d74ec2a63f09ee418f048d23f4fd379a2/editor/libeditor/HTMLEditor.cpp#6322

However, focus event does not check it and modifies ancestor limiter of
`Selection` for the document.  And even in this case, public methods for
handling some edit actions are open for `execCommand` requests.  Then,
edit action handlers may set selection outside the elements, but new focus
event to update the selection ancestor limiter will be handled later.
Therefore, until getting next focus event, `HTMLEditor` does not work as
expected since `Selection::*InLimiter()` APIs refuse to change selection.

Ideally, we should make `nsFocusManager` notifies editor of focus change
synchronously, but I cannot fix it quickly because it needs to touch security
sensitive area.  Therefore, this patch makes `HTMLEditor` do not set
ancestor limiter when a text control in any editing host gets focus.

Additionally, this patch makes
`HTMLEditor::AutoDeleteRangesHandler::AutoBlockElementsJoiner::HandleDeleteAtOtherBlockBoundary`
stop handling leaf node deletion if it cannot change caret position.

Differential Revision: https://phabricator.services.mozilla.com/D95268
2020-10-30 13:45:48 +00:00
Masayuki Nakano 1fe9274aa4 Bug 1663725 - Add reported test as a crashtest (the crash bug itself was fixed by bug 1663601) r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D95127
2020-10-30 04:18:36 +00:00
Masayuki Nakano 9b606cfb10 Bug 1624005 - Make `WSScanResult` have error state and make the scan methods of `WSRunScanner` use it when it fails to initialize `TextFragmentData` r=m_kato
The test runs `execCommand("insertHorizontalRule")` when the document node
has no children.  In this case, `TextFragmentData` fails to initialize itself.
In this case, our editor cannot do anything.  Therefore, returning error
in this case must be better.

This patch makes all callers of the scan methods handle the error case unless
the caller cannot return error.

Comparing with Blink, perhaps, we should insert `<html>` and `<body>` element
in this case first and keep doing the requested operation in the future.
Currently, doing it may cause another complicated issue with mutation event
listeners.

Differential Revision: https://phabricator.services.mozilla.com/D95126
2020-10-30 07:33:39 +00:00
Masayuki Nakano e58b93b3d9 Bug 1613521 - Make `NeedsToDispatchBeforeInputEvent()` return false if the edit action requires a clipboard event and it's not dispatched yet r=m_kato
The reason of hitting the assertion is, a clipboard event listener nests
another edit action, initializing the editor, runs, and tries to create an
anonymous `<br>` element with transaction, but it checks whether `beforeinput`
event has already been dispatched or not with the parent edit action data.

For fixing it, this patch adds a flag to edit action data to indicate whether
a clipboard event has already been dispatched or not.  If it's already been
dispatched, it's **okay** to modify the DOM tree.  Ideally, we should put off
modifying the DOM tree after dispatching `beforeinput` event, but this case
does not notify web apps anything so that this patch should be fine.

Although this patch adds a crash test which is attached by the reporter,
it's not reproducible with current editor code because we stopped modifying
native anonymous nodes with transaction, but it depends on the behavior.
Still this assertion hits in `test_clipboard_noeditor.html` intermittently,
but I don't have idea how to reproduce this permanently.  Therefore, this
patch does not contain a test to check to regression actually.

Differential Revision: https://phabricator.services.mozilla.com/D95115
2020-10-30 07:21:40 +00:00
Makoto Kato 85f53704b2 Bug 1673816 - DeleteNodeWithTransaction should allow non-editable node which parent is editable. r=masayuki
Actually, `DeleteNodeWithTransaction` cannot remove non-editable node. But
we should allow it which parent node is ediatble.

Differential Revision: https://phabricator.services.mozilla.com/D94937
2020-10-30 01:38:41 +00:00
Masayuki Nakano 9d40c25ea2 Bug 1673790 - Split `editor/libeditor/HTMLEditSubActionHandler.cpp` r=m_kato
It's too big (+15k lines) and there are 2 groups which does not depend on the
others.  One is getting current state for `Document.queryCommandState` etc.
This is copied to `HTMLEditorState.cpp`.  And the other is delete handlers.
This is copied to `HTMLEditorDeleteHandler.cpp`.

Differential Revision: https://phabricator.services.mozilla.com/D94934
2020-10-28 13:08:34 +00:00
Masayuki Nakano 21fd55f3a4 Bug 1663793 - part 7: Make `runTest()` automatically handle editor value check in the case canceling `beforeinput` r=m_kato
When `beforeinput` event is canceled, the editor content shouldn't be modified.
Therefore, `runTest()` can handle it with caching initial value before
running the test body.

Additionally, this patch makes every test ensure that target editor has focus.
So, finally, each test is now isolated completely.  Developers can run only
a test with commenting out the other tests.

Depends on D94520

Differential Revision: https://phabricator.services.mozilla.com/D94521
2020-10-27 09:10:05 +00:00
Masayuki Nakano 58a805938e Bug 1663793 - part 6: Encapsulate all variables interacting with event listeners into a function r=m_kato
This patch makes all test functions call `runTest()` and it adds event listeners
only while running the function.  Therefore, this makes each test function do:
* initializing for running test
* running test with `runTest` and specifying expected data

Depends on D94519

Differential Revision: https://phabricator.services.mozilla.com/D94520
2020-10-27 08:08:51 +00:00
Masayuki Nakano 4302a60fd8 Bug 1663793 - part 5: Create a common method to check editor content, beforeinput event and input event r=m_kato
Depends on D94518

Differential Revision: https://phabricator.services.mozilla.com/D94519
2020-10-27 04:34:36 +00:00
Masayuki Nakano b6a756a7b5 Bug 1663793 - part 4: Make all test functions take an object for consistency r=m_kato
This allows the following patches will make all functions use batch function
to test with a framework.

Depends on D94517

Differential Revision: https://phabricator.services.mozilla.com/D94518
2020-10-27 03:49:42 +00:00
Masayuki Nakano 8b035a3c62 Bug 1663793 - part 3: Use same function to check canceling "beforeinput" and not canceling it r=m_kato
So, this removes functions named as `*_and_canceling_beforeinput` and
makes corresponding function take an object which has `action` and
`cancelBeforeInput` to reduce dependency on wider scope variables.

Depends on D94516

Differential Revision: https://phabricator.services.mozilla.com/D94517
2020-10-27 01:48:34 +00:00
Masayuki Nakano 50d3d995a4 Bug 1663793 - part 2: Split each chunk into IIFE r=m_kato
Although, still there are dependencies between the functions, this allows
stack has meaningful name where a failure occurs.

Depends on D94515

Differential Revision: https://phabricator.services.mozilla.com/D94516
2020-10-26 13:01:36 +00:00
Masayuki Nakano 3cd4b0ed5d Bug 1663793 - part 1: Make sure description of `ok()`, `is()`, etc. have its own line r=m_kato
Indent level of the tests will be increased.  Therefore, all descriptions
should be in their own lines.

Note that this and following patches rewrite almost all lines in the test
files again and again.  Therefore, it's hard to rebase and existing bugs
will be fixed when I was writing each patch.  So, I'd like reviewers just
put inline comment which should be fixed before landing.  Then, I'll add
a patch to fix them.

Differential Revision: https://phabricator.services.mozilla.com/D94515
2020-10-26 09:11:41 +00:00
Masayuki Nakano 03ae5e76db Bug 1669479 - part 2: Make `HTMLEditor::ComputeTargetRanges()` handle table cell selection mode with new utilities r=m_kato
So, the root cause of this assertion hit was, I forgot to add this path
when I implement the methods to compute target ranges.  Although the other
browsers don't support multiple selection ranges, this patch adds WPTs
for the cases.

Depends on D94241

Differential Revision: https://phabricator.services.mozilla.com/D94242
2020-10-26 09:10:29 +00:00
Masayuki Nakano 7f22e0e96a 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
Ricky Stewart 02a7b4ebdf Bug 1654103: Standardize on Black for Python code in `mozilla-central`.
Allow-list all Python code in tree for use with the black linter, and re-format all code in-tree accordingly.

To produce this patch I did all of the following:

1. Make changes to tools/lint/black.yml to remove include: stanza and update list of source extensions.

2. Run ./mach lint --linter black --fix

3. Make some ad-hoc manual updates to python/mozbuild/mozbuild/test/configure/test_configure.py -- it has some hard-coded line numbers that the reformat breaks.

4. Make some ad-hoc manual updates to `testing/marionette/client/setup.py`, `testing/marionette/harness/setup.py`, and `testing/firefox-ui/harness/setup.py`, which have hard-coded regexes that break after the reformat.

5. Add a set of exclusions to black.yml. These will be deleted in a follow-up bug (1672023).

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D94045
2020-10-26 18:34:53 +00:00
Masayuki Nakano 632bea14d4 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 624be44b8c 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 8a7dfed0fd 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 7a6b5b722c 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
Edgar Chen 0c7b507968 Bug 1653457 - Enable editor/libeditor/tests/test_bug1151186.html on fission and cross-origin; r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D94677
2020-10-24 23:25:27 +00:00
Masayuki Nakano 379413947b 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 c159d456cd 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 c3e66c2cd1 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 b757a23d31 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 d8a219bbef Bug 1671556 - part 5: Make `HTMLEditor::HandleDeleteSelection()` stop using `HTMLEditor::GetFirstSelectedTableCellElement()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D94231
2020-10-24 04:13:17 +00:00
Masayuki Nakano 055932a8ee Bug 1671556 - part 4: Make `HTMLEditor::HTMLWithContextInserter::Run()` stop using `HTMLEditor::GetFirstSelectedTableCellElement()` r=m_kato
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

Differential Revision: https://phabricator.services.mozilla.com/D94230
2020-10-24 04:13:04 +00:00
Masayuki Nakano 8165ffcad7 Bug 1671556 - part 3: Make `HTMLEditor::SetHTMLBackgroundColorWithTransaction()` stop using `HTMLEditor::Get(First|Next)SelectedTableCellElement()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D94229
2020-10-24 04:12:51 +00:00
Masayuki Nakano d57d81d139 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 f450442d99 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
Masayuki Nakano 4482ff7eab Bug 1669479 - part 1: Make `WSRunScanner::TextFragmentData::GetNonCollapsedRangeInTexts()` stop searching text node when given range is collapsed r=m_kato
This is a simple mistake.  If the given range is collapsed, scanning text node
to before/after from collapsed range may create reversed range.

Differential Revision: https://phabricator.services.mozilla.com/D94225
2020-10-24 04:11:56 +00:00
Bogdan Tara da1098d4aa Backed out 10 changesets (bug 1654103, bug 1672023, bug 1518999) for PanZoomControllerTest.touchEventForResult gv-junit failures CLOSED TREE
Backed out changeset ff3fb0b4a512 (bug 1672023)
Backed out changeset e7834b600201 (bug 1654103)
Backed out changeset 807893ca8069 (bug 1518999)
Backed out changeset 13e6b92440e9 (bug 1518999)
Backed out changeset 8b2ac5a6c98a (bug 1518999)
Backed out changeset 575748295752 (bug 1518999)
Backed out changeset 65f07ce7b39b (bug 1518999)
Backed out changeset 4bb80556158d (bug 1518999)
Backed out changeset 8ac8461d7bd7 (bug 1518999)
Backed out changeset e8ba13ee17f5 (bug 1518999)
2020-10-24 03:36:18 +03:00
Ricky Stewart c0cea3b0fa Bug 1654103: Standardize on Black for Python code in `mozilla-central`. r=remote-protocol-reviewers,marionette-reviewers,webdriver-reviewers,perftest-reviewers,devtools-backward-compat-reviewers,jgilbert,preferences-reviewers,sylvestre,maja_zf,webcompat-reviewers,denschub,ntim,whimboo,sparky
Allow-list all Python code in tree for use with the black linter, and re-format all code in-tree accordingly.

To produce this patch I did all of the following:

1. Make changes to tools/lint/black.yml to remove include: stanza and update list of source extensions.

2. Run ./mach lint --linter black --fix

3. Make some ad-hoc manual updates to python/mozbuild/mozbuild/test/configure/test_configure.py -- it has some hard-coded line numbers that the reformat breaks.

4. Make some ad-hoc manual updates to `testing/marionette/client/setup.py`, `testing/marionette/harness/setup.py`, and `testing/firefox-ui/harness/setup.py`, which have hard-coded regexes that break after the reformat.

5. Add a set of exclusions to black.yml. These will be deleted in a follow-up bug (1672023).

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D94045
2020-10-23 20:40:42 +00:00
Henri Sivonen 4362f51641 Bug 1666300 part 2 - Parse into an inert document. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D93478
2020-10-23 12:48:52 +00:00
Mihai Alexandru Michis f0df85d472 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 e3ee32aed5 Bug 1671556 - part 3: Make `HTMLEditor::SetHTMLBackgroundColorWithTransaction()` stop using `HTMLEditor::Get(First|Next)SelectedTableCellElement()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D94229
2020-10-23 10:51:20 +00:00
Masayuki Nakano d115dc42a4 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
Masayuki Nakano 0b038d0a0b 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-23 10:51:08 +00:00
Masayuki Nakano fdd3d5b1af Bug 1669479 - part 1: Make `WSRunScanner::TextFragmentData::GetNonCollapsedRangeInTexts()` stop searching text node when given range is collapsed r=m_kato
This is a simple mistake.  If the given range is collapsed, scanning text node
to before/after from collapsed range may create reversed range.

Differential Revision: https://phabricator.services.mozilla.com/D94225
2020-10-23 10:51:05 +00:00
Razvan Maries b4044e05f9 Backed out 3 changesets (bug 1666300, bug 1667113) for perma failures on browser_parsable_css.js. CLOSED TREE
Backed out changeset 29c5257d0a06 (bug 1667113)
Backed out changeset 0f0fc78ad521 (bug 1666300)
Backed out changeset 9b0c50269ef7 (bug 1666300)
2020-10-22 14:04:15 +03:00
Henri Sivonen 8439bf4064 Bug 1666300 part 2 - Parse into an inert document. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D93478
2020-10-19 13:42:31 +00:00
Dorel Luca 1ff59cb7a3 Backed out changeset 7558c8821a07 (bug 1654103) for multiple failures. CLOSED TREE 2020-10-22 03:51:06 +03:00
Ricky Stewart 50762dacab Bug 1654103: Standardize on Black for Python code in `mozilla-central`. r=remote-protocol-reviewers,marionette-reviewers,webdriver-reviewers,perftest-reviewers,devtools-backward-compat-reviewers,jgilbert,preferences-reviewers,sylvestre,maja_zf,webcompat-reviewers,denschub,ntim,whimboo,sparky
Allow-list all Python code in tree for use with the black linter, and re-format all code in-tree accordingly.

To produce this patch I did all of the following:

1. Make changes to tools/lint/black.yml to remove include: stanza and update list of source extensions.

2. Run ./mach lint --linter black --fix

3. Make some ad-hoc manual updates to python/mozbuild/mozbuild/test/configure/test_configure.py -- it has some hard-coded line numbers that the reformat breaks.

4. Add a set of exclusions to black.yml. These will be deleted in a follow-up bug (1672023).

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D94045
2020-10-21 21:27:27 +00:00
Masayuki Nakano 04027a5656 Bug 1607131 - Make `beforeinput` event for `MozEditableElement.setUserInput()` not cancelable by default r=smaug
Blink and WebKit do not fire `beforeinput` event when user uses build-in
password manager and autocomplete.  But the `inputType` value for this case,
`"insertReplacementText"` is defined as cancelable in the spec, and it's
actually cancelable when it's fired for correcting a word with built-in
spellchecker of them.

For making only our users' autocomplete and password manager not blocked by
web apps, we should make them not cancelable by default, but I think that we
should keep dispatching such non-cancelable `beforeinput` for conforming to
the standard unless we'd get a web-compat report for this.

Differential Revision: https://phabricator.services.mozilla.com/D93206
2020-10-20 00:13:43 +00:00
Kagami Sascha Rosylight 2c5fb988f2 Bug 1615296 - Part 2: Fix MOZ_CAN_RUN_SCRIPT warnings in editor module r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D93599
2020-10-15 19:12:44 +00:00
Masayuki Nakano 049c973fbf Bug 1671197 - Make `HTMLEditor::SelectAllInternal()` select all children of `<body>` element if computed selection root is an ancestor of the `<body>` element r=m_kato
In strictly speaking, we should shrink selection ranges at very first time
of edit action handling.  However, we support multiple selection ranges and
it makes the check cost really expensive, and the code would be really
complicated since ranges cannot be overlapped.  I.e., changing one range
could affect some of the others.

Therefore, this patch changes `HTMLEditor::SelectAllInternal()` instead.
If computed selection root is an ancestor of `<body>` element in HTML document,
it use the `<body>` element instead.

Note that, in HTML document, there should be only one `<body>` element and
only its content should be editable at least for now.  (Note that in XHTML
document, no `<body>` is allowed, multiple `<body>` elements allowed.)

Differential Revision: https://phabricator.services.mozilla.com/D93712
2020-10-16 09:38:56 +00:00
Masayuki Nakano 053daa2052 Bug 1627924 - Make `HTMLEditor::HideGrabberInternal()` reset dragging state r=emilio
When the grabber to move absolutely positioned element is disabled,
`HTMLEditor::HideGrabberInternal()` is called to delete it.  However,
it does not reset dragging state.  Therefore, `mousemove` event listener
will try to handle drag even after the grabber is removed.

This patch makes `HideGrabberInternal()` reset the dragging state to
make the event listener stop handling the drag action.

However, I hit a buggy assertion in `EventStateManager`.  It tries to
set active state to parent of the grabber (in this case, absolutely positioned
element).  However, editable element in `contenteditable` cannot have
active state.  Therefore, `leaf` becomes `nullptr`, but `newleaf` is the
absolutely positioned element.  Therefore, this patch adds this condition
into the `MOZ_ASSERT`.

Differential Revision: https://phabricator.services.mozilla.com/D93632
2020-10-16 02:34:15 +00:00
Magnus Melin 53d4e1215b Bug 1649005 - fix crash when rewrapping an empty message via mozilla::HTMLEditor::InsertTextWithQuotationsInternal. r=masayuki
If empty input, aStringToInsert.First() will crash at https://searchfox.org/mozilla-central/rev/c2e3ac11be4837718c2604e58085fbc8252b69dd/xpcom/string/nsTSubstring.cpp#968

Needed to adjust whether rewrap needs beforeinput handling:
NeedsBeforeInputEventHandling would return false, because rewrap was set not to need that
https://searchfox.org/mozilla-central/rev/803b368879fa332e8e2c1840bf1ec164f7ed2c32/editor/libeditor/EditorBase.h#1152
.. so EditorBase::AutoEditActionDataSetter::MaybeDispatchBeforeInputEvent would assert

rewrap also needs to be allowed for MayEditActionDeleteSelection (not to assert)

Differential Revision: https://phabricator.services.mozilla.com/D93167
2020-10-14 12:55:00 +00:00
Razvan Maries 5d8ff793a4 Backed out changeset c7cca3c4602b (bug 1649005) for perma failures on EditorBase.cpp. CLOSED TREE 2020-10-12 14:55:29 +03:00
Magnus Melin 336b9a62fd Bug 1649005 - fix crash when rewrapping an empty message via mozilla::HTMLEditor::InsertTextWithQuotationsInternal. r=masayuki
If empty input, aStringToInsert.First() will crash at https://searchfox.org/mozilla-central/rev/c2e3ac11be4837718c2604e58085fbc8252b69dd/xpcom/string/nsTSubstring.cpp#968

Differential Revision: https://phabricator.services.mozilla.com/D93167
2020-10-12 11:11:55 +00:00
Masayuki Nakano 498c3f96b9 Bug 1668134 - part 3: Add telemetry probes to collect how percentage of `HTMLEditor` is or is not handled with `beforeinput` event listeners r=smaug data-review=tdsmith
Unfortunately, there is no official way to detect whether browser supports
or not `beforeinput` event in the wild because Chromium does not support
`onbeforeinput` event handler attribute.  On the other hand, we're the
last browser vendor which does not support `beforeinput` event, and we
make `InputEvent.getTargetRanges()` enabled only when `beforeinput` event
because it returns meaningful value only when the event type is `beforeinput`.
So, web apps can detect `beforeinput` event support with checking type of
or existence of it instead.  However, in our experience, it's guessed what
a lot of web apps check whether "Firefox" or not to consider whether it
can use `beforeinput` events.  If so, we need to announce shipping
`beforeinput` event and the way to feature detection before actually shipping
it.  Otherwise, we wouldn't get enough feedback from testers.

First of all for shipping `beforeinput` events, we should collect how much
web apps which use `HTMLEditor` use `beforeinput` event when it's enabled,
and how much web apps use mutation events or mutation observer instead of
`beforeinput` events even when it's enabled.

Honestly, I'd like to collect URLs which don't use `beforeinput` event, but
use mutation events or mutation observer.  But it's really sensitive data
so that I believe that we shouldn't collect it.

Differential Revision: https://phabricator.services.mozilla.com/D92548
2020-10-09 23:54:19 +00:00
Masayuki Nakano 0f46ae6a8e Bug 1668134 - part 2: Make `nsPIDOMWindowInner` have an API to know whether a node is (was) in the window has been observed by web apps with a mutation observer r=smaug
There is similar API in `Document`, but they indicate whether a node has been
observed by any mutation receiver, not only by `MutationObserver` of JS.
However, I'd like to know the percentage of web apps which use
`MutationObserver`, but not use `beforeinput` events.  Therefore, this patch
adds similar API into `nsPIDOMWindowInner` as same as `beforeinput` and
ignores `MutationObserver`s which are created by chrome script and addons.

Differential Revision: https://phabricator.services.mozilla.com/D92547
2020-10-08 02:25:35 +00:00
Masayuki Nakano 8c5fa85517 Bug 1668134 - part 1: Make `nsPIDOMWindowInner` have an API to know whether the window or its descendants has had `beforeinput` event listeners r=smaug
When `HTMLEditor` instances are destroyed, I'd like to collect how much
instances are worked with `beforeinput` event listeners.  Before adding such
telemetry probe, this patch adds methods to set/get whether a `beforeinput`
event listener has had added or not to `nsPIDOMWindowInner`.

Differential Revision: https://phabricator.services.mozilla.com/D92546
2020-10-08 02:25:35 +00:00
Masayuki Nakano 2fde14a338 Bug 1623918 - part 2: Mark `nsINode::GetSelectionRootContent()` and its root callers as `MOZ_CAN_RUN_SCRIPT` as far as possible r=smaug
This patch tries to mark root callers of `nsINode::GetSelectionRootContent()`
which calls `nsINode::GetAnonymousRootElementOfTextEditor()` as far as possible
(and reasonable).

It's used by `ContentEventHandler` so that a lot of methods of
`EventStateManager`, `ContentEventHandler`, `IMEContentObserver` which are main
users of it are also marked as `MOZ_CAN_RUN_SCRIPT`.  I think that this is
reasonable.

On the other hand, it might not be reasonable to mark `IMEStateManager` methods
as `MOZ_CAN_RUN_SCRIPT` for initializing `IMEContentObserver` because
`IMEStateManager` may be able to initialize `IMEContentObserver` asynchronously
and its root callers are in XUL layout code.  Therefore, this patch uses
`MOZ_CAN_RUN_SCRIPT_BOUNDARY` for `IMEStateManager` at least for now.

Differential Revision: https://phabricator.services.mozilla.com/D92730
2020-10-09 02:37:47 +00:00
Mirko Brodesser 6ef121943b Bug 1639972: don't insert a node in `InsertNodeIntoProperAncestorWithTransaction` when there's no proper ancestor. r=masayuki
The previous behavior was added in bug 858918. However, it was wrong
when trying to insert a `<tr>` into a `<div contenteditable>`.

After this change, the test in bug 858918 still passes, so that specific
functionality doesn't break. However, the code is complex and one can't
exclude that other functionality breaks. The previous fix already
mentioned the same concern
https://bugzilla.mozilla.org/show_bug.cgi?id=858918#c25.

With this change,
https://searchfox.org/mozilla-central/rev/35245411b9e8a911fe3f5adb0632c3394f8b4ccb/editor/libeditor/HTMLEditorDataTransfer.cpp#938
doesn't insert the `<tr>`, but climbs up the `<tr>`'s ancestors, so that
a `<table>` is inserted. When `designMode = "on"`, this was already
previously the case.

The new code seems more correct, including pasting tables to
`contenteditable` elements working now. Therefore, it seems worth
submitting this patch, despite being unable to exclude regressions by
pure reasoning.

Differential Revision: https://phabricator.services.mozilla.com/D92590
2020-10-08 14:44:44 +00:00
Narcis Beleuzu c163b394ef Backed out 2 changesets (bug 1623918) for crashtest failure on 1623918.html CLOSED TREE
Backed out changeset 519ca1b069e5 (bug 1623918)
Backed out changeset d8a09a5fea47 (bug 1623918)
2020-10-08 12:06:58 +03:00
Masayuki Nakano da386ef224 Bug 1623918 - part 2: Mark `nsINode::GetSelectionRootContent()` and its root callers as `MOZ_CAN_RUN_SCRIPT` as far as possible r=smaug
This patch tries to mark root callers of `nsINode::GetSelectionRootContent()`
which calls `nsINode::GetAnonymousRootElementOfTextEditor()` as far as possible
(and reasonable).

It's used by `ContentEventHandler` so that a lot of methods of
`EventStateManager`, `ContentEventHandler`, `IMEContentObserver` which are main
users of it are also marked as `MOZ_CAN_RUN_SCRIPT`.  I think that this is
reasonable.

On the other hand, it might not be reasonable to mark `IMEStateManager` methods
as `MOZ_CAN_RUN_SCRIPT` for initializing `IMEContentObserver` because
`IMEStateManager` may be able to initialize `IMEContentObserver` asynchronously
and its root callers are in XUL layout code.  Therefore, this patch uses
`MOZ_CAN_RUN_SCRIPT_BOUNDARY` for `IMEStateManager` at least for now.

Differential Revision: https://phabricator.services.mozilla.com/D92730
2020-10-08 03:56:51 +00:00
Simon Giesecke 59dd6d410d Bug 1668757 - Fix lifetime extension issues with 0-length literals. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D92179
2020-10-06 15:03:01 +00:00
Masayuki Nakano ec2e1c9705 Bug 1669133 - Get rid of pref to disable `text` event in the default group and telemetry for it r=smaug
The telemetry probe was added in bug 1506434, and it's not necessary anymore
because of the event in the default group was completely disabled in
bug 1288640 (Gecko 65).

Therefore, we can get rid of the pref, and we can take back a room for a
bool member in `nsPIDOMWindowInner` for new telemetry probes which need
to know whether a specific event listener has been added or not.

Depends on D92395

Differential Revision: https://phabricator.services.mozilla.com/D92397
2020-10-05 11:17:17 +00:00
Timothy Nikkel 223e9bb630 Bug 1667612. Factor waitToClearOutAnyPotentialScrolls out from various tests and put it in apz_test_utils.js. r=kats
Differential Revision: https://phabricator.services.mozilla.com/D92318
2020-10-03 15:58:16 +00:00
Masayuki Nakano 49a0527874 Bug 1609291 - Make `AutoEditActionDataSetter::MaybeDispatchBeforeInputEvent()` stop returning error when there is no proper event target of `beforeinput` event r=smaug
`editor/libeditor/tests/test_bug974309.html` and
`editor/libeditor/tests/test_bug1268736.html` start to throw exception if
`beforeinput` event is enabled.  They test XPCOM editor API when a non-editable
element has focus and it's outside of any editing hosts.  In this case,
we shouldn't throw an exception for backward compatibility.  Although the
all callers should stop handling any edit action in this case, let's make
`MaybeDispatchBeforeInputEvent()` return a special success code instead of
an error code for making all callers keep working with traditional paths.

Differential Revision: https://phabricator.services.mozilla.com/D91864
2020-10-01 09:15:19 +00:00
Masayuki Nakano ad49c80971 Bug 1609291 - Fix new failure of `test_bug430392.html` when `beforeinput` is enabled r=smaug
If `beforeinput` event is enabled, the assertion count hitting in
`WSRunScanner::GetEditableBlockParentOrTopmotEditableInlineContent()` becomes 0.
The reason is, `AutoEditActionDataSetter::MaybeDispatchBeforeInputEvent()`
gets `nullptr` as the result of `HTMLEditor.GetInputEventTargetElement()`.
Then, it returns error and every edit action handlers stop handling it.
However, for the main purpose of `beforeinput`, i.e., overriding browsers'
default action, we need to dispatch `beforeinput` event even in such case.
(I.e., web apps may want to do something around the non-editable node.)

Therefore, this patch makes `HTMLEditor.GetInputEventTargetElement()` scan
editing host by itself if `HTMLEditor.GetActiveEditingHost()` returns `nullptr`
due to non-editable focus node.  And also make `test_bug430392.html` check
whether `beforeinput` events and `input` events are fired as expected.

I think that I should add new WPT to check nested editing host cases for
considering `beforeinput` and `input` event target, but I'd like to do it
in another bug for shipping `beforeinput` in Nightly channel as soon as
possible.

Differential Revision: https://phabricator.services.mozilla.com/D91863
2020-10-01 09:15:06 +00:00
Mirko Brodesser 96caedd514 Bug 1665645: add missing `requestFlakyTimeout` call to "editor/libeditor/tests/test_CF_HTML_clipboard.html". r=hsivonen
See <https://bugzilla.mozilla.org/show_bug.cgi?id=1665645#c7> for more
context.

Differential Revision: https://phabricator.services.mozilla.com/D90838
2020-09-28 08:13:33 +00:00
Masayuki Nakano a9cd962def Bug 1658702 - part 22: Get rid of wrong `MOZ_ASSERT`s in `WSRunScanner::GetRangeExtendToContainInvisibleWhiteSpacesAtRangeBoundaries()` r=m_kato
If deleting/replacing range selects a text node, it may shrink the range
to start and end of the text node.  So, the result may not be wider than
the original range.

This behavior is compatible with Blink.

Depends on D90639

Differential Revision: https://phabricator.services.mozilla.com/D90640
2020-09-27 06:02:38 +00:00
Masayuki Nakano d3fe79f0e9 Bug 1658702 - part 21 Initialize target ranges for all edit actions which runs `DeleteSelectionAsSubAction()` r=m_kato
A lot of edit actions calls `DeleteSelectionAsSubAction()` if selection is
not collapsed.  In such case, `getTargetRanges()` should return same result
as when the selection range is simply deleted.

This patch creates 2 methods to consider whether `EditAction` causes
running `DeleteSelectionAsSubAction()` with collapsed selection or
non-collapsed selection.

And makes `DeleteSelectionAsAction()` stop initializing the target ranges
itself.  Instead, makes `AutoEditActionDataSetter` do it immediately before
dispatching `beforeinput` event unless it's been already initialized manually.
* https://searchfox.org/mozilla-central/rev/30e70f2fe80c97bfbfcd975e68538cefd7f58b2a/editor/libeditor/TextEditor.cpp#492
* https://searchfox.org/mozilla-central/rev/30e70f2fe80c97bfbfcd975e68538cefd7f58b2a/editor/libeditor/TextEditor.cpp#731
* https://searchfox.org/mozilla-central/rev/30e70f2fe80c97bfbfcd975e68538cefd7f58b2a/editor/libeditor/TextEditorDataTransfer.cpp#503

The correctness of the new utility methods are tested with new `MOZ_ASSERT`
in `DeleteSelectionAsSubAction()`.

Additionally, this reorganizes `input-events-get-target-ranges-*.html`.
* Moving common code into `input-events-get-target-ranges.js`
* Moving non-collapsed selection cases into `input-events-get-target-ranges-non-collapsed-selection.html`
* Adding "typing a" case into the new test for testing this patch's behavior

Depends on D90542

Differential Revision: https://phabricator.services.mozilla.com/D90639
2020-09-27 04:49:41 +00:00
Mirko Brodesser 6726171836 Bug 1649121: part 95) Update `ElementInfo`'s documentation. r=m_kato
Helps understanding the members.

Differential Revision: https://phabricator.services.mozilla.com/D91145
2020-09-24 17:10:48 +00:00
Masayuki Nakano a2893f0106 Bug 1658702 - part 20: Get rid of all `nsIEditor::EStripWrappers` argument from all methods computing target ranges r=m_kato
Currently, target ranges do not extend the ranges even when deleting empty
parent elements of the range.  Therefore, the frag indicating whether empty
parents removed or not is not necessary for the methods.

Differential Revision: https://phabricator.services.mozilla.com/D90542
2020-09-24 12:47:03 +00:00
Masayuki Nakano 83ade05419 Bug 1658702 - part 19: Make `WSRunScanner::GetRangeForDeletingBlockElementBoundaries()` contain preceding invisible `<br>` element at start of joining blocks range r=m_kato
When joining 2 block elements, the left block element may ends with invisible
`<br>` element or the right block element may follows an invisible `<br>`
element if it's a descendant of the left block element.  In those cases, the
invisible `<br>` element must be start of the target range of the joining
block elements since it'll be deleted.

Differential Revision: https://phabricator.services.mozilla.com/D90541
2020-09-24 12:46:45 +00:00
Masayuki Nakano ddc2f11b46 Bug 1658702 - part 18: Implement the path to compute target ranges when deleting around an invisible `<br>` element r=m_kato
This patch corresponds to:
* https://searchfox.org/mozilla-central/rev/30e70f2fe80c97bfbfcd975e68538cefd7f58b2a/editor/libeditor/HTMLEditSubActionHandler.cpp#3431,3450,3459-3489,3511-3517

However, it seems that this is a dead path in most cases because most tests
added by this patch are handled as non-collapsed range deletion.  The
collapsed range is extended by `AutoRangeArray::ExtendAnchorFocusRangeFor()`.

Differential Revision: https://phabricator.services.mozilla.com/D90540
2020-09-24 12:46:22 +00:00
Masayuki Nakano 82f1264243 Bug 1658702 - part 17: Implement the last path to handle non-collapsed ranges deletion r=m_kato
This patch corresponds to:
* https://searchfox.org/mozilla-central/rev/0c97a6410ff018c22e65a0cbe4e5f2ca4581b22e/editor/libeditor/HTMLEditSubActionHandler.cpp#4812-4825,4839-4850
* https://searchfox.org/mozilla-central/rev/0c97a6410ff018c22e65a0cbe4e5f2ca4581b22e/editor/libeditor/HTMLEditSubActionHandler.cpp#4699-4706,4709,4734-4747

Like mentioned in the first link, the logic is completely broken so that this
just follows the broken logic to return actual "affected ranges".

Differential Revision: https://phabricator.services.mozilla.com/D90214
2020-09-24 12:46:15 +00:00
Mirko Brodesser b49443686f Bug 1649121: part 94) Factor adding flavors in best order out. r=m_kato
This clarifies why the flavors are added in a certain order and why
retrieving the first available one is the best one.

Moreover, this enables previously, accidentally disabled
`NS_WARNING_ASSERTIONS`.

Differential Revision: https://phabricator.services.mozilla.com/D90883
2020-09-24 12:38:09 +00:00
Mirko Brodesser 759a716466 Bug 1649121: part 93) Change `aTransferable` to `mTransferable`. r=m_kato
To adhere the style-guide.

Differential Revision: https://phabricator.services.mozilla.com/D90882
2020-09-24 12:37:57 +00:00
Mirko Brodesser 96f3ba77b4 Bug 1649121: part 92) Factor `HTMLTransferablePreparer` out. r=m_kato
Preparing the transferable has the hidden requirement that the order of
the added flavors matters.

This is the preparation for expressing this in code.

`aTransferable` is renamed in the following commit.

Differential Revision: https://phabricator.services.mozilla.com/D90881
2020-09-24 12:39:59 +00:00
Dorel Luca 1e813d19c8 Backed out 3 changesets (bug 1649121) for Build bustage in editor/libeditor/HTMLEditorDataTransfer.cpp. CLOSED TREE
Backed out changeset eedf67df5cde (bug 1649121)
Backed out changeset 081bc411deaf (bug 1649121)
Backed out changeset 4db50381fa96 (bug 1649121)
2020-09-24 14:53:40 +03:00
Mirko Brodesser c3f9a9042c Bug 1649121: part 94) Factor adding flavors in best order out. r=m_kato
This clarifies why the flavors are added in a certain order and why
retrieving the first available one is the best one.

Moreover, this enables previously, accidentally disabled
`NS_WARNING_ASSERTIONS`.

Differential Revision: https://phabricator.services.mozilla.com/D90883
2020-09-23 14:46:20 +00:00
Mirko Brodesser 2a0b5e8022 Bug 1649121: part 93) Change `aTransferable` to `mTransferable`. r=m_kato
To adhere the style-guide.

Differential Revision: https://phabricator.services.mozilla.com/D90882
2020-09-23 14:46:12 +00:00
Mirko Brodesser 87fbdd3f84 Bug 1649121: part 92) Factor `HTMLTransferablePreparer` out. r=m_kato
Preparing the transferable has the hidden requirement that the order of
the added flavors matters.

This is the preparation for expressing this in code.

`aTransferable` is renamed in the following commit.

Differential Revision: https://phabricator.services.mozilla.com/D90881
2020-09-23 14:46:04 +00:00
Simon Giesecke de7bab0f06 Bug 1650145 - Replace all value uses of Empty[C]String by 0-length _ns literals. r=froydnj,geckoview-reviewers,agi
Differential Revision: https://phabricator.services.mozilla.com/D82325
2020-09-23 15:17:15 +00:00
Mirko Brodesser cd6abf059e Bug 1649121: part 91) Document some arguments of some `DataTransfer`-related methods. r=m_kato
A step towards making `HTMLEditor::InsertFromDataTransfer`
understandable.

Differential Revision: https://phabricator.services.mozilla.com/D90689
2020-09-23 08:15:21 +00:00
Mirko Brodesser bd154d5816 Bug 1649121: part 90) Declare some editor methods `const` or `static`. r=m_kato
Simplifies reasoning about them.

Differential Revision: https://phabricator.services.mozilla.com/D90688
2020-09-22 16:03:55 +00:00
Nicholas Nethercote 3d3e201817 Bug 1665258 - Shrink `CSSEquivTable`. r=heycam
Better field packing reduces it from 48 bytes to 40 bytes on 64-bit.

This reduces the memory used by each process by 336 bytes on 64-bit.

Differential Revision: https://phabricator.services.mozilla.com/D90344
2020-09-23 01:08:21 +00:00
Simon Giesecke c8ed33ab9d Bug 1665850 - Remove specifics for reference error types from mozilla::Result. r=emilio,jandem
Also update the documentation on optimizations and representation to
better reflect the current situation.

Differential Revision: https://phabricator.services.mozilla.com/D90662
2020-09-21 13:14:28 +00:00
Simon Giesecke 2e065c64d6 Bug 1665614 - Make mozilla::Result work with non-copyable/non-param error types. r=emilio,jandem
Among other things, there were some misuses of std::forward, and
GenericErrorResult was (presumably accidentally) instatiated with
references as the template argument type, e.g. const nsresult&,
which circumvented the check for not calling it with NS_OK in
ResultExtensions.h

Differential Revision: https://phabricator.services.mozilla.com/D90561
2020-09-21 13:12:48 +00:00
Simon Giesecke f193981fb7 Bug 1665850 - Remove specifics for reference error types from mozilla::Result. r=emilio,jandem
Also update the documentation on optimizations and representation to
better reflect the current situation.

Differential Revision: https://phabricator.services.mozilla.com/D90662
2020-09-21 11:09:09 +00:00
Simon Giesecke 3b0420646e Bug 1665614 - Make mozilla::Result work with non-copyable/non-param error types. r=emilio,jandem
Among other things, there were some misuses of std::forward, and
GenericErrorResult was (presumably accidentally) instatiated with
references as the template argument type, e.g. const nsresult&,
which circumvented the check for not calling it with NS_OK in
ResultExtensions.h

Differential Revision: https://phabricator.services.mozilla.com/D90561
2020-09-21 10:38:19 +00:00
Sylvestre Ledru ec8859e69e Bug 1519636 - Reformat recent changes to the Google coding style r=andi
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D90793
2020-09-20 10:14:09 +00:00
Masayuki Nakano 6551ca6994 Bug 1658702 - part 16: Implement `AutoBlockElementsJoiner::ComputeRangesToDeleteContentInRanges()` and `AutoBlockElementsJoiner::ComputeRangesToJoinBlockElementsInSameParent()` r=m_kato
They need to just call
`AutoDeleteRangesHandler::ComputeRangesToDeleteRangesWithTransaction()` because
their corresponding methods calls `EditorBase::DeleteRangesWithTransaction()`
and do additional different jobs after that, but the they don't affect the
ranges.

* https://searchfox.org/mozilla-central/rev/0c97a6410ff018c22e65a0cbe4e5f2ca4581b22e/editor/libeditor/HTMLEditSubActionHandler.cpp#4602,4627-4628,4639-4642
* https://searchfox.org/mozilla-central/rev/0c97a6410ff018c22e65a0cbe4e5f2ca4581b22e/editor/libeditor/HTMLEditSubActionHandler.cpp#4650,4669-4670,4676-4678,4685-4686

Depends on D90212

Differential Revision: https://phabricator.services.mozilla.com/D90213
2020-09-17 08:39:31 +00:00
Masayuki Nakano 3a879cadbe Bug 1658702 - part 15: Implement shortcut case of `AutoDeleteRangesHandler::HandleDeleteNonCollapsedRanges()` r=m_kato
This patch corresponds to:
* https://searchfox.org/mozilla-central/rev/0c97a6410ff018c22e65a0cbe4e5f2ca4581b22e/editor/libeditor/HTMLEditSubActionHandler.cpp#4500-4527

Depends on D90211

Differential Revision: https://phabricator.services.mozilla.com/D90212
2020-09-17 08:30:10 +00:00
Mirko Brodesser 60e705c860 Bug 1649121: part 88) Declare some methods around `DataTransfer` `const`. r=masayuki
Helps reasoning about them.

Differential Revision: https://phabricator.services.mozilla.com/D90528
2020-09-17 08:52:42 +00:00
Masayuki Nakano bddc344c4c Bug 1658702 - part 14: Implement a path to compute target ranges of `EditorBase::DeleteRangesWithTransaction()` r=m_kato
`HTMLEditor` falls back to `EditorBase::DeleteRangesWithTransaction()` in
some cases, especially when handling non-collapsed ranges.  Therefore, we
need to implement it for the following patches.

The code corresponds to:
* https://searchfox.org/mozilla-central/rev/62c443a7c801ba9672de34c2867ec1665a4bbe67/editor/libeditor/EditorBase.cpp#3848-3862
* https://searchfox.org/mozilla-central/rev/62c443a7c801ba9672de34c2867ec1665a4bbe67/editor/libeditor/EditorBase.cpp#3355,3371,3374,3376,3386-3387,3392
* https://searchfox.org/mozilla-central/rev/62c443a7c801ba9672de34c2867ec1665a4bbe67/editor/libeditor/EditorBase.cpp#3421,3431-3432,3435-3436,3444,3453-3455,3464-3465,3473-3474,3477-3478,3486,3495-3497,3506-3507,3515-3520,3526-3528,3535-3538,3543-3544,3546-3549,3558-3562,3570-3572,3579-3580
* https://searchfox.org/mozilla-central/rev/62c443a7c801ba9672de34c2867ec1665a4bbe67/editor/libeditor/DeleteTextTransaction.cpp#34,49-51,59,69-71

Basically, we don't need to touch the ranges, but if `aDirectionAndAmount` is
`nsIEditor::eNext` or `nsIEditor::ePrevious`, each collapsed range is extened
for:
* previous character (treating only surrogate pair)
* next character (treating only surrogate pair)
* selecting another content node

This logic is much rougher than what `AutoDeleteRangesHandler` and its nested
classes do.  So, `HTMLEditor` should stop using it in the future, but we need
to keep using it for now.

Depends on D90210

Differential Revision: https://phabricator.services.mozilla.com/D90211
2020-09-17 08:29:27 +00:00
Mirko Brodesser 6007e4f7d3 Bug 1649121: part 87) Add minimal documentation to `HTMLEditor::ParseCFHTML`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D90419
2020-09-16 20:17:47 +00:00
Masayuki Nakano c808508f5a Bug 1664741 - Make `AutoBlockElementsJoiner::DeleteNodesEntirelyInRangeButKeepTableStructure()` check whether it deletes a visible content or not before deleting the contents r=m_kato
Oddly, it checks whether it deletes at least one visible thing after deleting
each content from the DOM tree.  It should be done before deleting from the
DOM tree because all text nodes become visible if they are not in the DOM tree
anymore.

Unfortunately, this change does not fix any automated test result, but the
base logic --only when it does not delete any visible things, join the adjacent
block elements-- sounds reasonable.  Therefore, let's take this change.
Note that without this change, cannot compute "affected ranges" of
`getTargetRanges()` in the case running this method later.

Differential Revision: https://phabricator.services.mozilla.com/D90065
2020-09-17 01:45:30 +00:00
Makoto Kato 0a0fc918b8 Bug 1663638 - Don't use edit transaction for editing UI. r=masayuki
Although we use CSS property for Inline table editing UI, we use edit
transaction for it unfortunately. When hiding this UI, since removing
element doesn't use edit transaction, transaction will be canceled before
showing this UI.

It is unnecessary to use edit transaction for UI, so we shouldn't use it.

Differential Revision: https://phabricator.services.mozilla.com/D90056
2020-09-14 05:10:08 +00:00
Masayuki Nakano 969699a0f3 Bug 1658702 - part 12: Implement paths to compute ranges to delete non-collapsed ranges r=m_kato
This patch corresponds to:
* https://searchfox.org/mozilla-central/rev/8a0745cd346f0cfb89ae71690babbf7bff706113/editor/libeditor/HTMLEditSubActionHandler.cpp#3531-3537
* https://searchfox.org/mozilla-central/rev/8a0745cd346f0cfb89ae71690babbf7bff706113/editor/libeditor/HTMLEditSubActionHandler.cpp#4443-4561
* https://searchfox.org/mozilla-central/rev/8a0745cd346f0cfb89ae71690babbf7bff706113/editor/libeditor/HTMLEditSubActionHandler.cpp#2778-2822

Note that the new failure of `input-events-get-target-ranges-forwarddelete.html`
is mismatch between target range (including the trailing white-space) and
actually deleted range (not including the trailing white-space).  Let's
accept this new failure for now since not so important problem and same test
with backspace has same bug.

Differential Revision: https://phabricator.services.mozilla.com/D89870
2020-09-16 10:55:22 +00:00
Masayuki Nakano e09be3fb17 Bug 1664109 - Fix `!=` operator of `EditorDOMRangeBase` r=m_kato
This is causes taking back bugs in
`WSRunScanner::GetNewInvisibleLeadingWhiteSpaceRangeIfSplittingAt()` and
`WSRunScanner::GetNewInvisibleTrailingWhiteSpaceRangeIfSplittingAt()`  (I.e.,
they were fixed by bug 1647556).  Therefore, this removes the odd `if` blocks
which are pointed with `XXX` comment for avoiding "regressions" (without them,
some WPTs for `InputEvents.getTargetRanges()` become failure).

Depends on D89582

Differential Revision: https://phabricator.services.mozilla.com/D89869
2020-09-16 02:17:33 +00:00
Masayuki Nakano a5c5234e6f Bug 1658702 - part 11: Implement a path to compute target ranges when joining 2 blocks from outer block boundary r=m_kato
This patch corresponds to:
* https://searchfox.org/mozilla-central/rev/b2716c233e9b4398fc5923cbe150e7f83c7c6c5b/editor/libeditor/HTMLEditSubActionHandler.cpp#3679-3697
* https://searchfox.org/mozilla-central/rev/b2716c233e9b4398fc5923cbe150e7f83c7c6c5b/editor/libeditor/HTMLEditSubActionHandler.cpp#2733-2751
* https://searchfox.org/mozilla-central/rev/b2716c233e9b4398fc5923cbe150e7f83c7c6c5b/editor/libeditor/HTMLEditSubActionHandler.cpp#4286-4302
* https://searchfox.org/mozilla-central/rev/b2716c233e9b4398fc5923cbe150e7f83c7c6c5b/editor/libeditor/HTMLEditSubActionHandler.cpp#4309-4355

`HandleDeleteCollapsedSelectionAtCurrentBlockBoundary()` delete leaf content
of the child block when the block is not joined with current block.  For
doing it, it creates another `AutoDeleteRangesHandler` with collapsing selection
in the child block.  Then, it may refer selection for handling bidi text.
Therefore, the computation code which is added by this patch may modify
selection temporarily for the child `AutoDeleteRangeHandler`.  However, the
selection change shouldn't cause running any scrip (even if chrome script)
because it's required only for this hack.  Therefore, this patch blocks all
notifications and selection change events with `AutoHideSelectionChanges`.
Therefore, this patch marks
`AutoBlockElementsJoiner::ComputeRangesToDeleteAtOtherBlockBoundary()` as
`MOZ_CAN_RUN_SCRIPT_BOUNDARY` for using `HTMLEditor::CollapseSelectionTo()`.

Differential Revision: https://phabricator.services.mozilla.com/D89582
2020-09-16 05:36:57 +00:00
longsonr dee8245fe3 Bug 1664788 - rewrite nsEditingSession::SetupEditorOnWindow r=masayuki
Avoid converting strings from UTF16 to ASCII

Differential Revision: https://phabricator.services.mozilla.com/D90092
2020-09-15 14:40:54 +00:00
Masayuki Nakano 620c728792 Bug 1658702 - part 10: Implement a path to compute target ranges when joining 2 blocks from current block boundary r=m_kato
This patch corresponds to:
* https://searchfox.org/mozilla-central/rev/2b250967a66886398e5e798371484fd018d88a22/editor/libeditor/HTMLEditSubActionHandler.cpp#3525-3543
* https://searchfox.org/mozilla-central/rev/2b250967a66886398e5e798371484fd018d88a22/editor/libeditor/HTMLEditSubActionHandler.cpp#2710-2719
* https://searchfox.org/mozilla-central/rev/2b250967a66886398e5e798371484fd018d88a22/editor/libeditor/HTMLEditSubActionHandler.cpp#4140-4165
* https://searchfox.org/mozilla-central/rev/2b250967a66886398e5e798371484fd018d88a22/editor/libeditor/HTMLEditSubActionHandler.cpp#5650-5716
* https://searchfox.org/mozilla-central/rev/2b250967a66886398e5e798371484fd018d88a22/editor/libeditor/WSRunObject.cpp#97-213
* https://searchfox.org/mozilla-central/rev/2b250967a66886398e5e798371484fd018d88a22/editor/libeditor/WSRunObject.cpp#218-386
* https://searchfox.org/mozilla-central/rev/2b250967a66886398e5e798371484fd018d88a22/editor/libeditor/WSRunObject.cpp#391-480

In `WSRunObject.cpp`, joining 2 blocks code is split to 3 methods, they are
for:

1. left block element is an ancestor of right block element
2. right block element is an ancestor of left block element
3. left block element and right block element are siblings

The reason why they are split to is, they need to move descendants of child
block element or right block element with different logic.  However, this
difference is not a big problem when we compute target ranges because only
the difference is where we need to check whether there are invisible white-
spaces.  Therefore, this patch creates only a utility method in `WSRunScanner`
and makes `AutoInclusiveAncestorBlockElementsJoiner::ComputeRangesToDelete()`
much simpler than `AutoInclusiveAncestorBlockElementsJoiner::Run()`.

Differential Revision: https://phabricator.services.mozilla.com/D89278
2020-09-11 06:24:08 +00:00
Masayuki Nakano d060d644d6 Bug 1663797 - Make delete handler of `HTMLEditor` not try to join `<html>`, `<head>` and `<body>` r=m_kato
It'll fail to join them when its utility methods actually join them.
However, it should be considered earlier timing because the preparation
DOM tree changes before joining them causes creating odd tree (see the
removed cases of the test).  Therefore, we should make them stop handling
deletion before modifying the DOM tree.

Depends on D89579

Differential Revision: https://phabricator.services.mozilla.com/D89580
2020-09-15 07:33:58 +00:00
Masayuki Nakano 7effeb6cde Bug 1663370 - part 9: Make `AutoInclusiveAncestorBlockElementsJoiner::Prepare()` consider whether it will NOT join the elements or not r=m_kato
This makes `AutoInclusiveAncestorBlockElementsJoiner` stores whether `Run()`
will return "ignored" or not when `Prepare()` is called.  And this patch adds
`NS_ASSERTION()` to compare the result of `Run()` and the guess.

Note that this shouldn't used for considering whether its user call or not
`Run()` actually for the risk of regressions and if we do it with current
implementation, some web apps may be broken if they do modify the DOM tree
at white-space adjustment before joining the left and right block elements.

The method will be used by `ComputeTargetRanges()` which will be implemented
by bug 1658702.

Depends on D89578

Differential Revision: https://phabricator.services.mozilla.com/D89579
2020-09-15 06:07:01 +00:00
Masayuki Nakano 9ed84efbc7 Bug 1663370 - part 8: Make `AutoInclusiveAncestorBlockElementsJoiner::Prepare()` scan preceding invisible `<br>` element r=m_kato
When its `Run()` join the block elements, even if it won't move any content
nodes in first line, it may notify the callers as "handled" when there is a
preceding invisible `<br>` element since it needs to delete it in any cases.
Therefore, whether there is or not a preceding invisible `<br>` element is
important to compute target ranges since if there is one, `Run()` won't return
"ignored" and the callers won't delete leaf content instead.

Note that the new assertions are not hit in any tests, but due to searching
preceding invisible `<br>` element in `Prepare()`, expected assertion
count of 2 tests is increased.

Depends on D89577

Differential Revision: https://phabricator.services.mozilla.com/D89578
2020-09-14 13:35:42 +00:00
Masayuki Nakano 4a6cf53eeb Bug 1663370 - part 7: Make `AutoInclusiveAncestorBlockElementsJoiner::Prepare()` check the relation of its `mLeftBlockElement` and `mRightBlockElement` r=m_kato
The relation is important when the class handles both joining them and computing
target ranges.  Additionally, it's required to consider whether it can join the
block elements.  So, it should store the relation when `Prepare()` is called.

Depends on D89576

Differential Revision: https://phabricator.services.mozilla.com/D89577
2020-09-14 11:40:34 +00:00
Masayuki Nakano da0f19a5f3 Bug 1663370 - part 6: Create a method to check whether `HTMLEditor::MoveOneHardLineContents()` returns "handled" or "canceled" r=m_kato
Unfortunately, `HTMLEditor::MoveOneHardLineContents()`,
`HTMLEditor::MoveChildrenWithTransaction()` and
`HTMLEditor::MoveNodeOrChildrenWithTransaction()` return strict result whether
at least one node is moved or not.  Therefore, we need to scan the DOM tree
whether there is at least one content node which can be moved by them for
computing target ranges.

We cannot do same thing for ``HTMLEditor::MoveOneHardLineContents()` because
it split parent elements first and use `ContentSubtreeIterator` which lists
up topmost nodes which are completely in the range, but we need to compute
target ranges without splitting nodes at the range boundaries.  Therefore,
this patch checks whether the line containing specified point has content
except invisible `<br>` element.

The others are simple.  We can use same logic with them.

Finally, this adds `NS_ASSERTION()`s to check whether the computation is done
correctly at running any automated tests on debug build, and I don't see any
failure with them.

Depends on D89575

Differential Revision: https://phabricator.services.mozilla.com/D89576
2020-09-14 10:54:42 +00:00
Masayuki Nakano 6355f06829 Bug 1663370 - part 5: Make helper methods of `AutoInclusiveAncestorBlockElementsJoiner::Run()` use simple constructor of `EditActionResult` when they return error r=m_kato
When they return error, neither "handled" nor "canceled" state is referred.
So, for making the code simpler, we can make them return
`EditActionResult(NS_ERROR_*)` instead of `EditActionIgnored(NS_ERROR_*)`.

Depends on D89574

Differential Revision: https://phabricator.services.mozilla.com/D89575
2020-09-14 07:25:08 +00:00
Masayuki Nakano f081792788 Bug 1663370 - part 4: Sort out "handled" state settings around `AutoInclusiveAncestorBlockElementsJoiner` users r=m_kato
The 2 of them always mark the edit action as "handled", but it's not important
when it's "canceled" or an error.  Therefore, we can make the users simpler
as this patch does.

Depends on D89573

Differential Revision: https://phabricator.services.mozilla.com/D89574
2020-09-14 05:07:48 +00:00
Masayuki Nakano 0e90b72f58 Bug 1663370 - part 3: Use early-return style when `AutoInclusiveAncestorBlockElementsJoiner::Prepare()` returns `false` r=m_kato
Note that in such cases, current code mark the results as both "canceled" and
"handled", but only "canceled" state is important for the root caller.
* https://searchfox.org/mozilla-central/rev/ac142717cc067d875e83e4b1316f004f6e063a46/editor/libeditor/HTMLEditSubActionHandler.cpp#4200-4204
* https://searchfox.org/mozilla-central/rev/ac142717cc067d875e83e4b1316f004f6e063a46/editor/libeditor/HTMLEditSubActionHandler.cpp#3452-3457
* https://searchfox.org/mozilla-central/rev/ac142717cc067d875e83e4b1316f004f6e063a46/editor/libeditor/HTMLEditSubActionHandler.cpp#3100-3125

Depends on D89572

Differential Revision: https://phabricator.services.mozilla.com/D89573
2020-09-14 03:44:54 +00:00
Masayuki Nakano a87c9efc84 Bug 1663370 - part 2: Move `AutoTrackDOMPoint` for `AutoInclusiveAncestorBlockElementsJoiner::Run()` into the minimum scope r=m_kato
Now, `AutoInclusiveAncestorBlockElementsJoiner::Run()` is wrapped by a
small block in every caller.  Therefore, `AutoTrackDOMPoint` for it can
be moved into the small blocks.

Depends on D89571

Differential Revision: https://phabricator.services.mozilla.com/D89572
2020-09-14 01:36:42 +00:00
Masayuki Nakano c326309928 Bug 1663370 - part 1: Make `AutoInclusiveAncestorBlockElementsJoiner::Prepare()` stop returning `EditActionResult` r=m_kato
For making the refactoring patch simpler, `Prepare()` considers the
`EditActionResult` value of its callers instead.  However, this is odd
so that it just return whether the caller should keep working with
it or not as `bool` result.  Then, for the additional information, whether
the caller should consume the edit action handling or not, this patch
adds a new method, `CanJoinBlocks()`.

Depends on D89440

Differential Revision: https://phabricator.services.mozilla.com/D89571
2020-09-14 01:25:52 +00:00
longsonr da2fc5609a Bug 1664699 - Remove unused HTMLEditor::GetHTMLDocument method r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D90039
2020-09-14 01:54:33 +00:00
Timothy Nikkel 30f528e804 Bug 1664446. Properly wait to make sure any potential scroll events get fired in several tests. r=kats
Doing rAF rAF flushApzRepaints is not enough to make sure that any potential scroll events are sent to content. The reason is that if the apz repaint request causes us to do scrolling on the main thread then the scrolling will be finished after flushApzRepaints, and the scroll event will be pending, but it's not sent until the next refresh driver tick. So we need to do at least one rAF after flushApzRepaints.

Differential Revision: https://phabricator.services.mozilla.com/D90035
2020-09-13 20:21:11 +00:00
Timothy Nikkel 3fa3a926a6 Bug 1664446. Disable zoom to focus input for mochitests in editor/libeditor/tests/. r=botond
I think the scrolls that zoom to focus input causes are giving us scroll events that we don't expect. I don't think there is a better way around this.

Differential Revision: https://phabricator.services.mozilla.com/D89993
2020-09-11 23:30:26 +00:00
Timothy Nikkel fa760298a9 Bug 1664446. Increase fuzz in editor/libeditor/tests/test_selection_move_commands.html slightly. r=botond
Disabling zoom to focused input seems to have slightly changed how much fuzz we get when comparing scroll position.

Differential Revision: https://phabricator.services.mozilla.com/D90005
2020-09-12 01:24:23 +00:00
Emilio Cobos Álvarez 20252cfeaf Bug 1664411 - Factor out a condition to unconditionally enable clipboard events in some documents. r=masayuki
This patch shouldn't introduce any behavior change.

Differential Revision: https://phabricator.services.mozilla.com/D89834
2020-09-11 11:08:35 +00:00
Timothy Nikkel 86ef6eea77 Bug 1663537. Fix various tests for desktop zooming scrollbars. r=kats
The test fixes all fell into the follow categories:

A) The test uses requestAnimationFrame to wait one frame and expects scrolling to be complete. With the desktop zooming scrollbars in order for the scrolling to show up on the main thread we need to send the scroll request to the compositor and then hear back from it via an apz repaint request (apz callback helper). Waiting on requestAnimationFrame will complete the first part, but not necessarily the second part. The fix is to wait for a scroll event.

B) Switching tests to wait for scroll events exposes another problem: the test can do things that cause a scroll in order to setup the test (and that may not be obvious that it causes a scroll) before actually proceeding to do the test and do something that causes a scroll and then checks for the scroll change of the second thing. Waiting for a requestAnimationFrame would include both those scrolls without desktop zooming scrollbars, but if we wait for a scroll event we will get the scroll event for the first thing which we are not interested in. So we need to make sure scroll events are cleared out before waiting for any scroll events. We do this by waiting two requestAnimationFrame's and waiting for apz to be flushed. We also use this when a test does something and it wants to test that scrolling is not performed.

The main thing that causes scrolling that may not be obvious: calling node.focus(). With stacks like:

from test_scroll_per_page.html

```
#01: mozilla::ScrollFrameHelper::CompleteAsyncScroll(nsRect const&, mozilla::ScrollOrigin) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x47d6cc0]
#02: mozilla::ScrollFrameHelper::ScrollToWithOrigin(nsPoint, mozilla::ScrollMode, mozilla::ScrollOrigin, nsRect const*, nsIScrollbarMediator::ScrollSnapMode) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x47d7732]
#03: mozilla::layout::ScrollAnchorContainer::ApplyAdjustments() [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x4742913]
#04: mozilla::PresShell::FlushPendingScrollAnchorAdjustments() [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x4650069]
#05: mozilla::PresShell::ProcessReflowCommands(bool) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x465742b]
#06: mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x4656af8]
#07: mozilla::dom::Document::FlushPendingNotifications(mozilla::ChangesToFlush) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1a87d3c]
#08: mozilla::PresShell::ScrollContentIntoView(nsIContent*, mozilla::ScrollAxis, mozilla::ScrollAxis, mozilla::ScrollFlags) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x4652b96]
#09: nsFocusManager::ScrollIntoView(mozilla::PresShell*, nsIContent*, unsigned int) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1bedd1c]
#10: nsFocusManager::Focus(nsPIDOMWindowOuter*, mozilla::dom::Element*, unsigned int, bool, bool, bool, bool, bool, nsIContent*) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1be6be0]
#11: nsFocusManager::SetFocusInner(mozilla::dom::Element*, int, bool, bool) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1be212f]
#12: nsFocusManager::SetFocus(mozilla::dom::Element*, unsigned int) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1be32ba]
#13: mozilla::dom::Element::Focus(mozilla::dom::FocusOptions const&, mozilla::dom::CallerType, mozilla::ErrorResult&) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1aaf283]
#14: mozilla::dom::HTMLElement_Binding::focus(JSContext*, JS::Handle<JSObject*>, void*, JSJitMethodCallArgs const&) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x2d65f3b]
```

from editor/libeditor/tests/test_bug549262.html

```
#01: mozilla::ScrollFrameHelper::CompleteAsyncScroll(nsRect const&, mozilla::ScrollOrigin) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x47d6cc0]
#02: mozilla::ScrollFrameHelper::ScrollToWithOrigin(nsPoint, mozilla::ScrollMode, mozilla::ScrollOrigin, nsRect const*, nsIScrollbarMediator::ScrollSnapMode) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x47d7732]
#03: mozilla::PresShell::ScrollFrameRectIntoView(nsIFrame*, nsRect const&, mozilla::ScrollAxis, mozilla::ScrollAxis, mozilla::ScrollFlags) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x46541bc]
#04: mozilla::PresShell::DoScrollContentIntoView() [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x4653776]
#05: mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x4656b11]
#06: mozilla::dom::Document::FlushPendingNotifications(mozilla::ChangesToFlush) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1a87d3c]
#07: mozilla::PresShell::ScrollContentIntoView(nsIContent*, mozilla::ScrollAxis, mozilla::ScrollAxis, mozilla::ScrollFlags) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x4652b96]
#08: nsFocusManager::ScrollIntoView(mozilla::PresShell*, nsIContent*, unsigned int) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1bedd1c]
#09: nsFocusManager::Focus(nsPIDOMWindowOuter*, mozilla::dom::Element*, unsigned int, bool, bool, bool, bool, bool, nsIContent*) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1be6be0]
#10: nsFocusManager::SetFocusInner(mozilla::dom::Element*, int, bool, bool) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1be212f]
#11: nsFocusManager::SetFocus(mozilla::dom::Element*, unsigned int) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1be32ba]
#12: mozilla::dom::Element::Focus(mozilla::dom::FocusOptions const&, mozilla::dom::CallerType, mozilla::ErrorResult&) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x1aaf283]
#13: mozilla::dom::HTMLElement_Binding::focus(JSContext*, JS::Handle<JSObject*>, void*, JSJitMethodCallArgs const&) [/Users/tim/ffopt2/src/obj-x86_64-apple-darwin19.6.0/toolkit/library/build/XUL + 0x2d65f3b]
```

C) Several tests use nsIDOMWindowUtils advanceTimeAndRefresh/restoreNormalRefresh and expect scrolling to be done after a call to advanceTimeAndRefresh. This is basically A), advanceTimeAndRefresh does a refresh driver tick but doesn't allow a repaint request to come back to the main thread.

Differential Revision: https://phabricator.services.mozilla.com/D89403
2020-09-11 10:45:28 +00:00
Emilio Cobos Álvarez 3ccd260400 Bug 1664114 - Try to find a more usable selection for copy-paste if copying from an HTMLEditor. r=masayuki
See the bug for the complications that made me write this slightly hacky
fix... Other solutions definitely welcome.

Add a test, adjusted so it would fail without the change.

Differential Revision: https://phabricator.services.mozilla.com/D89835
2020-09-11 09:14:07 +00:00
Kagami Sascha Rosylight eb9d5c9792 Bug 1623764 - Part 5: Prevent test failure by subpixel difference r=emilio
The failures already have been there: https://treeherder.mozilla.org/#/jobs?repo=try&revision=3d6cc94f2db7a2e55f41405ef0575102637e0633&selectedTaskRun=ZUj4QROIQo6nGympvvqvjA.0

... but they only fail inside a job "geckoview-test-verify" and the job even does not always runs the test. It makes hard to track the initial failure, so this patch just allows subpixel difference.

Differential Revision: https://phabricator.services.mozilla.com/D86486
2020-09-09 23:45:45 +00:00
Kagami Sascha Rosylight a9222dc61e Bug 1623764 - Part 4: Stop at hard linebreaks when eat_space_to_next_word r=emilio,masayuki
Differential Revision: https://phabricator.services.mozilla.com/D85923
2020-09-09 23:45:37 +00:00
Masayuki Nakano 8bb9ef510a Bug 1663601 - Make `RangeBoundaryBase::GetNextSiblingOfChildAtOffset()` check whether `mRef` is nullptr or not r=mbrodesser
`RangeBoundaryBase` stores a previous sibling of child node at offset with
`mRef`.  Therefore, even if the callers check whether its instance points a
child node, `mRef` may be `nullptr` when it points first child of its container.
So, `GetNextSiblingOfChildAtOffset()` needs to handle the case.

This patch adds the crash case test into
`test_dom_input_event_on_htmleditor.html` because of a basic behavior.
For now, this patch adds 2 chunks which are coded with using same style as
previous ones.  However, the test should be redesigned later for making
non-dependency of each chunk guaranteed.  (The new chunks are completely
independent from previously running tests.)

Differential Revision: https://phabricator.services.mozilla.com/D89440
2020-09-09 11:19:04 +00:00
Jonathan Kew 60e923ac0b Bug 1533462 - Add a possible retry step in test_bug1200533 to handle potential disruption by font-list refresh. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D89120
2020-09-07 16:20:56 +00:00
Masayuki Nakano 3ed5c1ea83 Bug 1658702 - part 9: Add `AutoDeleteRangesHandler::ComputeRangesToDeleteHRElement()` to compute the target range for deleting `<hr>` element r=m_kato
This patch corresponds to:
* https://searchfox.org/mozilla-central/rev/0c682c4f01442c3de0fa6cd286e9cadc8276b45f/editor/libeditor/HTMLEditSubActionHandler.cpp#3362-3375
* https://searchfox.org/mozilla-central/rev/0c682c4f01442c3de0fa6cd286e9cadc8276b45f/editor/libeditor/HTMLEditSubActionHandler.cpp#3679-3695
* https://searchfox.org/mozilla-central/rev/0c682c4f01442c3de0fa6cd286e9cadc8276b45f/editor/libeditor/HTMLEditSubActionHandler.cpp#3728-3742

Note that the complicated cases (surrounded by invisible `<br>` element and/or
surrounded by invisible white-spaces) are handled as deleting non-collapsed
range so that this improves only the simple cases.

And also this adds a pref to disable the Gecko specific complicated `<hr>`
element handling.

Differential Revision: https://phabricator.services.mozilla.com/D88969
2020-09-07 03:09:30 +00:00
Masayuki Nakano 76a83d0a21 Bug 1661893 - Make `WhiteSpaceVisibilityKeeper::ReplaceText()` refer replacing range end information to consider whether the last ASCII white-space of inserting string should be replaced with an NBSP or not r=m_kato
This is simple mistake of the patch:
https://phabricator.services.mozilla.com/D82286

The method refers start of replacing range to consider whether replace or
keep last ASCII white-space of inserting string, but it should refer the
end of the replacing range, of course.

Differential Revision: https://phabricator.services.mozilla.com/D89124
2020-09-07 03:20:35 +00:00
Masayuki Nakano dc906b0477 Bug 1658702 - part 8: Add `AutoDeleteRangesHandler::ComputeRangesToDeleteAtomicContent()` to compute atomic content deleting target range r=m_kato
This patch corresponds to the following part:
* https://searchfox.org/mozilla-central/rev/0c682c4f01442c3de0fa6cd286e9cadc8276b45f/editor/libeditor/HTMLEditSubActionHandler.cpp#3346-3360
* https://searchfox.org/mozilla-central/rev/0c682c4f01442c3de0fa6cd286e9cadc8276b45f/editor/libeditor/HTMLEditSubActionHandler.cpp#3750-3761
* https://searchfox.org/mozilla-central/rev/0c682c4f01442c3de0fa6cd286e9cadc8276b45f/editor/libeditor/WSRunObject.cpp#1075-1113

Let's return a range selecting the deleting atomic content (i.e., between
`EditorDOMPoint(&content)` and `EditorDOMPoint::After(content)`).

For doing it, we need to shrink the computed range after
`AutoRangeArray::ExtendAnchorFocusRangeFor()` because layout code puts
range boundaries to start or end of text node in this case.

Then, surprisingly, our deletion code have not used
`HandleDeleteCollapsedSelectionAtAtomicContent()` in most cases because
`AutoRangeArray::ExtendAnchorFocusRangeFor()` makes the collapsed range
to non-collapsed.  For making the deletion faster and simpler, this patch
shrinks the result of `AutoRangeArray::ExtendAnchorFocusRangeFor()` if
it has only one range and selects only one atomic content node.

Differential Revision: https://phabricator.services.mozilla.com/D88968
2020-09-07 04:59:22 +00:00
Masayuki Nakano f1c2353722 Bug 1658702 - part 7: Make `AutoDeleteRangesHandler::ComputeRangesToDelete()` compute text deletion range from a collapsed range r=m_kato
Just for computing the deletion range, we can use new path for the Blink-compat
white-space normalizer.

This patch corresponds to:
* https://searchfox.org/mozilla-central/rev/ce21a13035623c1d349980057d09000e70669802/editor/libeditor/HTMLEditSubActionHandler.cpp#3278-3284
* https://searchfox.org/mozilla-central/rev/ce21a13035623c1d349980057d09000e70669802/editor/libeditor/HTMLEditSubActionHandler.cpp#3298-3344
* https://searchfox.org/mozilla-central/rev/ce21a13035623c1d349980057d09000e70669802/editor/libeditor/HTMLEditSubActionHandler.cpp#3422-3455

Differential Revision: https://phabricator.services.mozilla.com/D88941
2020-09-04 11:30:52 +00:00
Masayuki Nakano 1bc1fa2c82 Bug 1658702 - part 6: Make `AutoDeleteRangesHandler::ComputeRangesToDelete()` skip the case deleting an invisible `<br>` element for now r=m_kato
For implementing this case, we need more helper methods.  Let's do this after
implementing other cases.
https://searchfox.org/mozilla-central/rev/ce21a13035623c1d349980057d09000e70669802/editor/libeditor/HTMLEditSubActionHandler.cpp#3207-3276

Depends on D88939

Differential Revision: https://phabricator.services.mozilla.com/D88940
2020-09-04 02:34:41 +00:00
Masayuki Nakano 040765e7aa Bug 1658702 - part 5: Add preparation part for deleting collapsed range to `AutoDeleteRangesHandler::ComputeRangesToDelete()` r=m_kato
This patch implements the preparation part of deleting collapsed range.
https://searchfox.org/mozilla-central/rev/ce21a13035623c1d349980057d09000e70669802/editor/libeditor/HTMLEditSubActionHandler.cpp#3188-3206

Depends on D88379

Differential Revision: https://phabricator.services.mozilla.com/D88939
2020-09-01 08:01:34 +00:00
Kagami Sascha Rosylight 11ef0ef23e 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 0600dacd03 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 010d7de462 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
Aaron Klotz 14408edb59 Bug 1662313: Add a wait on a selectionchange event to test_resizers_resizing_elements to prevent race condition in test; r=masayuki DONTBUILD
Wait for `selectionchange` to ensure that input events have been processed
before verifying a target's bounds.

Differential Revision: https://phabricator.services.mozilla.com/D88936
2020-09-01 04:46:04 +00:00
Mirko Brodesser 7056730ef8 Bug 1649121: part 85) Follow-up for part 74. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D88430
2020-08-31 12:30:54 +00:00
Mirko Brodesser d396b5502a Bug 1649121: part 78) Revert part 77. r=masayuki
The assertion added in part 77 isn't violated, but it needs exhaustive
analysis to ensure it's indeed intended to not be violated.

Differential Revision: https://phabricator.services.mozilla.com/D88258
2020-09-01 02:07:24 +00:00
Masayuki Nakano 06407fa939 Bug 1658702 - part 4: Make `AutoDeleteRangesHandler::ComputeRangesToDelete()` extend collapsed ranges for deleting adjacent character or word or the line r=m_kato
This patch adding computation code corresponding to:
https://searchfox.org/mozilla-central/rev/27932d4e6ebd2f4b8519865dad864c72176e4e3b/editor/libeditor/HTMLEditSubActionHandler.cpp#3157-3185

For `beforeinput` event listeners, `AutoSetTemporaryAncestorLimiter` is not
enough since when `beforeinput` event listeners modifies `Selection`, the
ancestor limit is not set when it has a job.  Perhaps, we should make editor
stop using focus/blur event listener and makes `nsFocusManager` notifies
editor of them synchronously before dispatching the events.  But it's not
scope of this bug at least.

Differential Revision: https://phabricator.services.mozilla.com/D88379
2020-09-01 02:04:02 +00:00
Masayuki Nakano c8894e5ea6 Bug 1658702 - part 3: Make `AutoDeleteRangesHandler::ComputeRangesToDelete()` quit without modifying the ranges when it shouldn't delete adjacent character(s) in bidi text r=m_kato
This change is corresponding to the part:
https://searchfox.org/mozilla-central/rev/73a14f1b367948faa571ed2fe5d7eb29460787c1/editor/libeditor/HTMLEditSubActionHandler.cpp#3143-3155

When caret is not adjacent the deleting character in bidi text, we may do
nothing except putting caret to the character.  So, `ComputeRangesToDelete()`
shouldn't update the caret position since the caret position will be check
by its `Run()` later if `beforeinput` event is not canceled.  For avoiding
the code duplication, this patch reimplements
`EditorBase::SetCaretBidiLevelForDeletion()` as a stack only class and
split the check and updating part from correcting the data.

Note that by the default pref, the new tests failed since it won't be
canceled, and the method still don't compute for deleting a character.

Differential Revision: https://phabricator.services.mozilla.com/D88378
2020-09-01 02:03:23 +00:00
Masayuki Nakano f94c0a973f Bug 1658702 - part 2: Make `AutoDeleteRangesHandler::ComputeRangesToDelete()` handle the case deleting empty ancestor(s) r=m_kato
This patch implements computation of target ranges for this part:
https://searchfox.org/mozilla-central/rev/73a14f1b367948faa571ed2fe5d7eb29460787c1/editor/libeditor/HTMLEditSubActionHandler.cpp#3099-3141

This patch adds some utility methods for computing the ranges.  Currently,
it's not yet standardized, but the other browser engines look for leaf content
of another block when blocks are joined (or a block is deleted like this case).
Therefore, we follow the behavior basically, but different from the other
browsers, we should include invisible white-spaces into the range when they
are included.  That avoids the invisible white-spaces become visible when
web apps do something instead of us.  Note that utility methods have the code,
but this patch does not use it because in this case, we just delete a empty
block ancestor, not join it with previous/next block.

Differential Revision: https://phabricator.services.mozilla.com/D88377
2020-09-01 02:02:50 +00:00
Mihai Alexandru Michis e0f7ab5885 Backed out changeset bacd9a2d26c1 (bug 1658702) for causing hazard bustages in HTMLEditSubActionHandler.cpp
CLOSED TREE
2020-08-31 13:29:36 +03:00
Masayuki Nakano a43b290e4e Bug 1658702 - part 2: Make `AutoDeleteRangesHandler::ComputeRangesToDelete()` handle the case deleting empty ancestor(s) r=m_kato
This patch implements computation of target ranges for this part:
https://searchfox.org/mozilla-central/rev/73a14f1b367948faa571ed2fe5d7eb29460787c1/editor/libeditor/HTMLEditSubActionHandler.cpp#3099-3141

This patch adds some utility methods for computing the ranges.  Currently,
it's not yet standardized, but the other browser engines look for leaf content
of another block when blocks are joined (or a block is deleted like this case).
Therefore, we follow the behavior basically, but different from the other
browsers, we should include invisible white-spaces into the range when they
are included.  That avoids the invisible white-spaces become visible when
web apps do something instead of us.  Note that utility methods have the code,
but this patch does not use it because in this case, we just delete a empty
block ancestor, not join it with previous/next block.

Differential Revision: https://phabricator.services.mozilla.com/D88377
2020-08-31 08:33:14 +00:00
Masayuki Nakano cb8cfd084a Bug 1658702 - part 1: Create a path to compute target ranges of deleting edit actions for `beforeinput` events on `HTMLEditor` r=m_kato
In strictly speaking, we should use same computed target ranges for any edit
actions which causes removing non-collapsed selection.  However, for now,
this patch makes only `DeleteSelectionAsAction()` because it's not so important
differences for shipping `beforeinput` in Nightly channel.

Differential Revision: https://phabricator.services.mozilla.com/D88376
2020-08-31 03:48:39 +00:00
Jonathan Kew 84a6685131 Bug 1533462 - Execute the deferred font-info loader immediately when running spell-check and animation mochitests, to avoid intermittent issues. r=jwatt
Depends on D87194

Differential Revision: https://phabricator.services.mozilla.com/D87195
2020-08-30 22:59:57 +00:00
Mirko Brodesser 26fc5e08a4 Bug 1649121: part 77) `MOZ_ASSERT` html info is only provided when there's html context. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D88257
2020-08-28 12:56:29 +00:00
Mirko Brodesser e564162061 Bug 1649121: part 76) Factor `IsInsertionCookie` out. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D88247
2020-08-28 10:28:39 +00:00
Mirko Brodesser e5822e1262 Bug 1649121: part 75) Declare `FragmentFromPasteCreator`'s `Document` argument `const`. r=masayuki
Simplifies reasoning about it.

Differential Revision: https://phabricator.services.mozilla.com/D88119
2020-08-27 15:00:00 +00:00
Mirko Brodesser 9c5b92954c Bug 1649121: part 74) Pass `Document` instead of `HTMLEditor` to `CreateDocumentFragmentFromPaste`. r=masayuki
`CreateDocumentFragmentFromPaste` doesn't need to know about
`HTMLEditor`, `Document` suffices.

Differential Revision: https://phabricator.services.mozilla.com/D88118
2020-08-28 10:27:30 +00:00
Mirko Brodesser 355bcdd416 Bug 1652557: remove failure expectation for "test_resizers_resizing_elements.html" when xorigin iframes and fission are enabled. r=hsivonen
Fixed by bug 1653160.

Differential Revision: https://phabricator.services.mozilla.com/D88563
2020-08-28 09:59:39 +00:00
Masayuki Nakano 5bca4199fb Bug 1660378 - part 9: Avoid QI for getting `nsStyledElement` pointer r=smaug
The editor modules does QI too many times when it sets or removes some style
with `execCommand` or XPCOM API.  Therefore, there should be an API to
retrieve `nsStyledElement` pointer from `nsINode*`.

Differential Revision: https://phabricator.services.mozilla.com/D87990
2020-08-26 05:29:06 +00:00
Masayuki Nakano b500d7d549 Bug 1660378 - part 8: Make `HTMLEditor::IsSimpleModifiableNode()` take `Element&` instead of `nsIContent*` r=m_kato
Although it starts to return error if it causes destroying the editor, but
it should not occur because it modifies new and orphan node and it shouldn't
kick any mutation event listeners.  Therefore, this patch makes the callers
handle error as-is rather than ignoring errors except
`NS_ERROR_EDITOR_DESTROYED`.

Differential Revision: https://phabricator.services.mozilla.com/D87989
2020-08-26 04:48:36 +00:00
Masayuki Nakano bc279d2448 Bug 1660378 - part 7: Make `CSSEditUtils::SetCSSEquivalentToHTMLStyle()` take `nsStyledElement&` instead of `Element*` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87988
2020-08-26 04:48:32 +00:00
Masayuki Nakano decd85f7d6 Bug 1660378 - part 6: Make `CSSEditUtils::SetCSSProperty()` and its callers take `nsStyledElement&` instead of `Element&` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87987
2020-08-26 04:48:28 +00:00
Masayuki Nakano d03e0e65d8 Bug 1660378 - part 5: Make `CSSEditUtils::RemoveCSSInlineStyle()` take `nsStyledElement&` instead of `nsINode&` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87986
2020-08-26 04:48:25 +00:00
Masayuki Nakano 67e64be5b4 Bug 1660378 - part 4: Make `CSSEditUtils::DoElementsHaveSameStyle()` take `nsStyledElement&` instead of `Element&` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87985
2020-08-26 04:48:22 +00:00
Masayuki Nakano 2a4a68855c Bug 1660378 - part 3: Make `CSSEditUtils::RemoveCSSEquivalentToHTMLStyle()` take `nsStyledElement&` instead of `Element*` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87984
2020-08-26 04:48:19 +00:00
Masayuki Nakano 801ca86f89 Bug 1660378 - part 2: Make `CSSEditUtils::RemoveCSSPoperty()` take `nsStyledElement&` instead of `Element&` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87983
2020-08-26 04:48:16 +00:00
Masayuki Nakano 5d36739f8b Bug 1660378 - part 1: Get rid of `CSSEditUtils::GetInlineStyles()` r=m_kato
It should take `nsStyledElement&` instead of `const Element&`.  Then, it won't
fail and will just return the result of `nsStyleElement::Style()`.  Therefore,
we can get rid of it.

Note that this patch makes all its callers keep using strong pointer because
I'm not sure whether the layout APIs which are called with them are safe or
not.

Differential Revision: https://phabricator.services.mozilla.com/D87982
2020-08-26 04:48:12 +00:00
Masayuki Nakano f75a7ec162 Bug 1658536 - part 8: Make `AutoBlockElementsJoiner::HandleDeleteCollapsedSelectionAtOtherBlockBoundary()` creates another instance of `AutoDeleteRangesHandler` by itself r=m_kato
When it returns `EditActionIgnored()`,
`AutoDeleteRangesHandler::HandleDeleteAroundCollapsedRanges()` creates another
`AutoDeleteRangesHandler` instance to delete leaf content node in another
block element.  However, this dependency makes developers understand the
behavior harder.  Therefore, we should make the method do it instead.

Differential Revision: https://phabricator.services.mozilla.com/D87439
2020-08-24 03:06:03 +00:00
Masayuki Nakano 68e817dd75 Bug 1658536 - part 7: Make `HTMLEditor::HandleDeleteSelection()` stop calling `DeleteRangesWithTransaction()` a fallback when `AutoDeleteRangesHandler::Run()` returns "ignored" r=m_kato
For avoiding infinite recursive calls, `AutoDeleteRangesHandler` returns
`EditActionIgnored()` when it needs to fall it back to
`DeleteRangesWithTransaction()` after modifying the DOM tree or the ranges
to delete.  However, this makes developers understand the code harder.
And now, with making constructor of `AutoDeleteRangesHandler` manage the
recursive call state, we can make `HandleDeleteSelection()` stop handling
the fallback path.

Differential Revision: https://phabricator.services.mozilla.com/D87438
2020-08-24 03:06:00 +00:00
Masayuki Nakano fd1b043de1 Bug 1658536 - part 6: Move `AutoEmptyBlockAncestorDeleter` into `AutoDeleteRangesHandler` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87437
2020-08-24 03:05:56 +00:00
Masayuki Nakano cf5d24e31e Bug 1658536 - part 5: Move `HTMLEditor::HandleDeleteSelectionInternal()` into `AutoDeleteRangesHandler` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87436
2020-08-24 03:05:53 +00:00
Masayuki Nakano 0a484e2bdb Bug 1658536 - part 4: Move some methods used only in `AutoDeleteRangesHandler` into the class r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87435
2020-08-24 00:53:32 +00:00
Masayuki Nakano 7a2da49ab3 Bug 1658536 - part 3: Move `HTMLEditor::SelectionWasCollapsed` into `AutoDeleteRangesHandler` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87434
2020-08-24 00:53:13 +00:00
Masayuki Nakano 05434c1073 Bug 1658536 - part 2: Move `AutoBlockElementsJoiner` and `AutoInclusiveAncestorBlockElementsJoiner` into `AutoDeleteRangesHandler` r=m_kato
Even though their method names in stack trace become too long, but we can
guarantee that they are used only at handling deletion.

Differential Revision: https://phabricator.services.mozilla.com/D87433
2020-08-24 00:52:58 +00:00
Masayuki Nakano cfc4ba0b10 Bug 1658536 - part 1: Move methods called by `HTMLEditor::HandleDeleteSelectionInternal()` to `AutoDeleteRangesHandler` r=m_kato
This patch just moves them into the new stack only class and make each of them
take `HTMLEditor&` as their first argument.

Differential Revision: https://phabricator.services.mozilla.com/D87432
2020-08-24 00:52:44 +00:00
Masayuki Nakano 4405418105 Bug 1659717 - Make `AutoSetTemporaryAncestorLimiter` update cached ranges if selection limiter is updated r=m_kato
If `AutoSetTemporaryAncestorLimiter` sets ancestor limiter of the `Selection`,
existing range which is already cached by `AutoRangeArray` may be changed
into the new limiter.

Therefore, this patch makes `AutoSetTemporaryAncestorLimiter` take
`AutoRangeArray` optionally and reset it only when it sets new limiter for
the performance.

Differential Revision: https://phabricator.services.mozilla.com/D87820
2020-08-24 08:54:56 +00:00
Masayuki Nakano 19c23d725f Bug 1659276 - Make `AutoPlaceholderBatch` choose whether do or do not `ScrollSelectionIntoView` r=m_kato
The root cause of this bug is a bug of async `ScrollSelectionIntoView` that
is what it won't be canceled even if web app changes scroll position with
any API.  Fixing it is really risky and this bug affects an existing website.
Therefore, this patch makes the constructors of `AutoPlaceholderBatch` take
whether do or do not `ScrollSelectionIntoView` when it's destructed.  And
makes `HTMLEditor::SetInlinePropertyAsAction()` not request
`ScrollSelectionIntoView` for taking back the traditional behavior.

Note that this patch does not make it an optional argument because it's hard to
guess that it'll run `ScrollSelectionIntoView` automatically.

Differential Revision: https://phabricator.services.mozilla.com/D87819
2020-08-24 06:39:50 +00:00
Chris Fronk 3b7a1daba2 Bug 1647536 - Support ref counted pointers in nsDeque r=froydnj
Adds a new specialization of nsDeque, nsRefPtrDeque for use with
reference counted pointers.

Differential Revision: https://phabricator.services.mozilla.com/D84766
2020-08-22 15:47:59 +00:00
Simon Giesecke cfd7d0ea9c Bug 1659923 - Avoid unnecessary copies around Base64Encode. r=xpcom-reviewers,necko-reviewers,froydnj,valentin
This also adds some more variants of Base64Encode and Base64EncodeAppend.

Differential Revision: https://phabricator.services.mozilla.com/D87559
2020-08-19 17:45:16 +00:00
Masayuki Nakano 37a2794486 Bug 1655388 - part 7: Split off the check whether `<hr>` element should be removed or not from `HTMLEditor::HandleDeleteCollapsedSelectionAtHRElement()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D87035
2020-08-19 06:48:31 +00:00
Masayuki Nakano d84d4847b0 Bug 1655388 - part 6: Get rid of unnecessary arguments of `HTMLEditor::HandleDeleteCollapsedSelectionAtAtomicContent()` and `HTMLEditor::HandleDeleteCollapsedSelectionAtHRElement()` r=m_kato
Depends on D87033

Differential Revision: https://phabricator.services.mozilla.com/D87034
2020-08-19 05:39:36 +00:00
Masayuki Nakano c9bee9126b Bug 1655388 - part 5: Split the special handling for `<hr>` element off from `HTMLEditor::HandleDeleteCollapsedSelectionAtAtomicContent()` r=m_kato
Depends on D87032

Differential Revision: https://phabricator.services.mozilla.com/D87033
2020-08-19 02:15:01 +00:00
Masayuki Nakano 416bf2f5ad Bug 1655388 - part 4: Get rid of `WhiteSpaceVisiblityKeeper::PrepareToDeleteNode()` r=m_kato
Now, the new method is only user of it.  So, we can get rid of it.

Depends on D87031

Differential Revision: https://phabricator.services.mozilla.com/D87032
2020-08-18 23:03:08 +00:00
Masayuki Nakano e844854c69 Bug 1655388 - part 3: Make `HTMLEditor::HandleDeleteSelectionInternal()` use the new method when it removes an invisible `<br>` element r=m_kato
Even though it hasn't normalize white-spaces before invisible `<br>` element,
it needs to do it for making them visible.  Therefore, we should make it
use the new method in this case too.

Depends on D87030

Differential Revision: https://phabricator.services.mozilla.com/D87031
2020-08-18 09:23:16 +00:00
Masayuki Nakano 9494d7d9c7 Bug 1655388 - part 2: Make deleting `<br>` element after `<hr>` element in `HTMLEditor::HandleDeleteCollapsedSelectionAtAtomicContent()` use the new method r=m_kato
Although it does not need to join text nodes around the `<br>` element since
its previous node is `<hr>`, it can use
`WhiteSpaceVisibilityKeeper::DeleteContentNodeAndJoinTextNodesAroundIt()` too.

Depends on D87029

Differential Revision: https://phabricator.services.mozilla.com/D87030
2020-08-18 08:17:17 +00:00
Masayuki Nakano 07e4f0f69d Bug 1655388 - part 1: Move the last part of `HTMLEditor::HandleDeleteCollapsedSelectionAtAtomicContent()` into `WhiteSpaceVisibilityKeeper` r=m_kato
It works with the traditional white-space normalizer.  Therefore, it should
be moved into `WhiteSpaceVisibilityKeeper`.

Depends on D86910

Differential Revision: https://phabricator.services.mozilla.com/D87029
2020-08-18 08:16:33 +00:00
Sonia Singla 5f5c9fd7f2 Bug 1659267 - Remove usages of -moz-user-select across the Firefox codebase. r=emilio,marionette-reviewers,geckoview-reviewers,preferences-reviewers,whimboo,agi
Differential Revision: https://phabricator.services.mozilla.com/D87499
2020-08-18 23:37:51 +00:00
Masayuki Nakano 3da9fc2299 Bug 1658534 - part 2: Avoid infinite recursive calls at removing an invisible `<br>` element r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D86910
2020-08-18 07:26:02 +00:00
Masayuki Nakano e21079f1fd Bug 1658534 - part 1: Split the removing invisible `<br>` element part off from `HTMLEditor::HandleDeleteCollapsedSelectionAtAtomicContent()` r=m_kato
Depends on D86886

Differential Revision: https://phabricator.services.mozilla.com/D86909
2020-08-18 05:35:39 +00:00
Masayuki Nakano d550a723f8 Bug 1658472 - part 6: Make some utility methods for `AutoInclusiveAncestorBlockElementsJoiner` r=m_kato
This patch changes the behavior in the following 2 points:
* When both content is in same block element, won't return error
* When `<hr>` element has block children accidentally, this solves its container

The former case must not change actual behavior because
`AutoBlockElementsJoiner` is used with content nodes which are in different
blocks.

Differential Revision: https://phabricator.services.mozilla.com/D86886
2020-08-17 10:57:47 +00:00
Masayuki Nakano 909288b9a6 Bug 1658472 - part 5: Split `AutoInclusiveAncestorBlockElementsJoiner::Run()` to computation part and touching the DOM tree part r=m_kato
Depends on D86884

Differential Revision: https://phabricator.services.mozilla.com/D86885
2020-08-17 10:51:44 +00:00
Masayuki Nakano 5d03594318 Bug 1658472 - part 4: Make `AutoInclusiveAncestorBlockElementsJoiner` store new list element tag name with its member r=m_kato
Depends on D86883

Differential Revision: https://phabricator.services.mozilla.com/D86884
2020-08-17 10:24:13 +00:00
Masayuki Nakano 3e0a1d8d61 Bug 1658472 - part 3: Make `AutoInclusiveAncestorBlockElementsJoiner` store left block element and right block element as its members r=m_kato
Depends on D86882

Differential Revision: https://phabricator.services.mozilla.com/D86883
2020-08-17 09:54:49 +00:00
Masayuki Nakano 3496851ec0 Bug 1658472 - part 2: Make `AutoInclusiveAncestorBlockElementsJoiner` store left content and right content at construction r=m_kato
Depends on D86881

Differential Revision: https://phabricator.services.mozilla.com/D86882
2020-08-17 09:34:11 +00:00
Masayuki Nakano 1a08039730 Bug 1658472 - part 1: Move `HTMLEditor::TryToJoinBlocksWithTransaction()` into new nested class of `AutoBlockElementsJoiner` r=m_kato
Now all users of the method is methods of `AutoBlockElementsJoiner`.
Therefore, we can move it into the nested class.  And for splitting the
method in the following patch, it should be a nested class of
`AutoBlockElementJoiner`.

Depends on D86791

Differential Revision: https://phabricator.services.mozilla.com/D86881
2020-08-17 09:22:19 +00:00
Masayuki Nakano 33a78c310f Bug 1655392 - part 6: Split the text deletion part of start and/or end of range off from `HandleDeleteNonCollapsedRanges` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D86791
2020-08-17 00:26:24 +00:00
Masayuki Nakano 21d81f986c Bug 1655392 - part 5: Split the part removing contents in each range off from `HandleDeleteNonCollapsedRanges()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D86790
2020-08-16 04:33:39 +00:00
Masayuki Nakano 9d1482c813 Bug 1655392 - part 4: Give independent mode and handler for the next block of `AutoBlockElementsJoiner::HandleDeleteNonCollapsedRanges()` r=m_kato
And now, `HTMLEditor::JoinNodesDeepWithTransaction()` is used only by
`AutoBlockElementsJoiner`.  Therefore, this patch moves it to the
stack only class.

Differential Revision: https://phabricator.services.mozilla.com/D86789
2020-08-16 04:20:38 +00:00
Masayuki Nakano aa3497a28e Bug 1655392 - part 3: Give independent mode and handler for first case of `AutoBlockElementsJoiner::HandleDeleteNonCollapsedRanges()` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D86788
2020-08-13 11:54:21 +00:00
Masayuki Nakano fa6c54cc66 Bug 1655392 - part 2: Make `AutoBlockElementsJoiner::PrepareToDeleteNonCollapsedRange()` initialize `mLeftContent` and `mRightContent` with inclusive ancestor block elements of start and end of first range r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D86787
2020-08-13 11:17:24 +00:00
Masayuki Nakano 7d56bc1b36 Bug 1655392 - part 1: Move some part of `HTMLEditor::HandleDeleteNonCollapsedRanges()` to `AutoBlockElementsJoiner` r=m_kato
For making the following review easier, this patch just moves some part of
`HandleDeleteNonCollapsedRanges()` into `AutoBlockElementJoiner`.

Differential Revision: https://phabricator.services.mozilla.com/D86786
2020-08-13 10:12:13 +00:00
Mihai Alexandru Michis fb644eda26 Backed out changeset 5838f8b581ed (bug 1647536) for causing failures in browser_active_mediasession_among_tabs.js
CLOSED TREE
2020-08-14 19:42:51 +03:00
Chris Fronk 8770c8a332 Bug 1647536 - Support ref counted pointers in nsDeque r=froydnj
Adds a new specialization of nsDeque, nsRefPtrDeque for use with
reference counted pointers.

Differential Revision: https://phabricator.services.mozilla.com/D84766
2020-08-14 15:19:48 +00:00
Mirko Brodesser 21078a7903 Bug 1652557: don't skip test_bug767684.html when xorigin iframes and fission are enabled. r=masayuki
The test failed neither locally nor on try, hence enabling it again.

Differential Revision: https://phabricator.services.mozilla.com/D86706
2020-08-12 02:02:49 +00:00
Masayuki Nakano 220db95ff0 Bug 1657269 - part 2: Make `HTMLEditor::HandleDeleteSelectionInternal()` take `AutoRangeArray` instead of referring `Selection` ranges r=m_kato
Now, only when deleting table cell contents, `HandleDeleteSelectionInternal()`
depends on `Selection`.  However, this can be moved to `HandleDeleteSelection()`
because recursive callers expects `Selection` is collapsed by its previous job.

Differential Revision: https://phabricator.services.mozilla.com/D86183
2020-08-11 09:35:42 +00:00