Commit Graph

10349 Commits

Author SHA1 Message Date
Masayuki Nakano
5599ddec3c Bug 1683226 - part 3: Get rid of pathes for handling plugin from IMEStateManager, IMEContentObserver and ContentEventHandler r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D100102
2020-12-21 05:52:49 +00:00
Masayuki Nakano
d27602eee6 Bug 1683226 - part 1: Make IMEState::Enabled an enum class r=m_kato,geckoview-reviewers
Before deleting `IMEState::Enabled::PLUGIN`, let's make it an enum class
for making the change safer.  Almost all of this change is done by
"replace" of VSCode.

Differential Revision: https://phabricator.services.mozilla.com/D100100
2020-12-21 05:52:03 +00:00
Emilio Cobos Álvarez
039592f4d8 Bug 1682003 - Avoid UTF-8 -> UTF-16 conversion during CSSOM serialization. r=heycam
This lifts a bunch of string conversions higher up the stack, but allows
us to make the servo code use utf-8 unconditionally, and seemed faster
in my benchmarking (see comment 0).

It should also make a bunch of attribute setters faster too (like
setting .cssText), now that we use UTF8String for them (we couldn't
because we couldn't specify different string types for the getter and
setters).

Differential Revision: https://phabricator.services.mozilla.com/D99590
2020-12-17 14:04:35 +00:00
Henri Sivonen
97959884fc Bug 1666300 test - Test SVG style sanitization on paste. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D93634
2020-11-18 17:18:56 +00:00
Kartik Gautam
f7ffcd09fb Bug 1679758 - Remove trailing empty lines r=sylvestre,marionette-reviewers,jgraham
Differential Revision: https://phabricator.services.mozilla.com/D99595
2020-12-15 10:34:54 +00:00
Makoto Kato
832ca9a3d8 Bug 1671764 - Part 2. Respect application/system locale if language code is matched. r=masayuki
When we don't match exactly dictionary name with `lang` attribute, we look for
language name. When looking for language name (ex. en/fr etc), we don't
consider the priority by application/system locale. So if lang=en, it may be
selected by character order. Most case is that en-GB is always selected if it
is installed.

We should respect application/system locale if language name is matched to
current content language before random selection.

Depends on D99336

Differential Revision: https://phabricator.services.mozilla.com/D99337
2020-12-14 03:01:08 +00:00
Makoto Kato
ddeba05428 Bug 1671764 - Part 1. Use ACString for dictionary language instead. r=masayuki
Actually, our locale service doesn't use UTF-16 for locale name and it will
be ASCII. Although dictionary name of spell checker is locale/language name,
it still uses UTF-16. To use locale API, I should replace it with `ACString`.

Differential Revision: https://phabricator.services.mozilla.com/D99336
2020-12-14 03:01:05 +00:00
Dorel Luca
7320ae982a Backed out changeset f3aaf04fce3b (bug 1679758) for Devtool failures in browser_styleeditor_syncAddProperty.js. CLOSED TREE 2020-12-13 16:38:21 +02:00
Kartik Gautam
caf549c200 Bug 1679758 - Remove trailing empty lines r=sylvestre
Differential Revision: https://phabricator.services.mozilla.com/D99595
2020-12-13 13:28:30 +00:00
Emilio Cobos Álvarez
b1964fa19a Bug 1682006 - Don't call Truncate() on the return string in GetPropertyValue. r=xidorn
Turns out this causes a bit of overhead when appending to an AutoString,
because Truncate() calls SetToEmptyBuffer(), which makes it go from
inline-string to buffer string, and next time we append we need to turn
the string from a buffer-based string to an inline string again, which
is some minor, but measurable, work, while profiling some
micro-benchmarks.

Probably we should make Truncate() a no-op for a zero-length string, but
I'll send that separately.

Differential Revision: https://phabricator.services.mozilla.com/D99493
2020-12-12 12:06:06 +00:00
Kagami Sascha Rosylight
8aba7414f7 Bug 1680167 - Part 6: Use RefPtr for nsFocusManager in editor r=masayuki
Depends on D98628

Differential Revision: https://phabricator.services.mozilla.com/D98629
2020-12-03 21:35:20 +00:00
Simon Giesecke
dd80614fa0 Bug 1678062 - Remove unnecessary includes. r=andi
Differential Revision: https://phabricator.services.mozilla.com/D97467

Depends on D96561
2020-11-23 16:12:02 +00:00
Simon Giesecke
f15895390e Bug 1673931 - Avoid including Element.h from header files.
Differential Revision: https://phabricator.services.mozilla.com/D96535

Depends on D96534
2020-11-23 16:08:40 +00:00
Simon Giesecke
071c7c035f Bug 1676356 - Avoid including PresShell.h from header files. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D96534

Depends on D95184
2020-11-23 16:08:23 +00:00
Simon Giesecke
5bfbb2a572 Bug 1673931 - Avoid including Document.h from header files. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D95046

Depends on D95045
2020-11-23 16:07:43 +00:00
Simon Giesecke
971b645fe3 Bug 1660470 - Add missing include directives/forward declarations. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D87865
2020-11-23 16:21:38 +00:00
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