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

10318 Коммитов

Автор SHA1 Сообщение Дата
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