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

10428 Коммитов

Автор SHA1 Сообщение Дата
Masayuki Nakano d8194cbbea Bug 1704381 - part 3: Add automated test r=m_kato
Depends on D111580

Differential Revision: https://phabricator.services.mozilla.com/D111581
2021-04-13 05:54:49 +00:00
Masayuki Nakano 1d08839089 Bug 1704381 - part 2: Make `AutoEditActionDataSetter` not store whether editor is destroyed after handling its edit action r=m_kato
Currently, its `mEditorWasDestroyed` is set to true even while `input` event
is being dispatched, i.e., even when it finished everything for the edit action.
However, the flag should be only for blocking unexpected cause which is caused
by mutation event listeners or something other unexpected event listeners
which shouldn't be run while editor is handling an edit action.

Therefore, this patch makes it store "handled" state which is marked before
notifying editor observers and dispatching `input` event and the flag won't
be set to true after it's marked as "handled".

Depends on D111579

Differential Revision: https://phabricator.services.mozilla.com/D111580
2021-04-13 05:54:49 +00:00
Masayuki Nakano 518cbe163b Bug 1704381 - part 1: Make `EditorBase::Init` set edit action to `EditAction::eInitializing` r=m_kato
I forgot to do this in `EditorBase::Init`. Therefore, it fails at synchronous
reinitializing during an edit action.

Differential Revision: https://phabricator.services.mozilla.com/D111579
2021-04-13 05:54:49 +00:00
Masayuki Nakano 762db8b745 Bug 1691051 - Make edit action data which is being handled manage whether the editor was temporarily destroyed or not r=m_kato
The editing session is temporarily disabled when opening a document.  Then,
when the document is closed, the editing session is restored with same
`HTMLEditor` instance.  Therefore, initializing editor may occur during
an edit action is being handled.

Probably, this must not be used in normal webapps since mutation events are
used rarely.  So, I think that for avoiding further complicated things, we
should make editor won't accept new edit action handling after original
editing session ended.

This patch renames `AutoEditActionDataSetter::CanHandle()` to
`IsDataAvailable()` since it just checks whether the important resource is
available or not.  And makes new `CanHandle()` return `false` for
non-initializing edit actions if editing session has ended.

Differential Revision: https://phabricator.services.mozilla.com/D111241
2021-04-09 06:59:54 +00:00
Masayuki Nakano 46da3502b3 Bug 1699866 - Make `HTMLEditor::SplitAncestorStyledInlineElementsAt` return "not handled" if there is no splitable element at given point r=m_kato
When given point is **in** a void element, e.g., this can be when JS inserts
nodes into a void element like `<meta>`,
`HTMLEditor::SplitNodeDeepWithTransaction` may return "not handled" state.
So, it's possible case, we shouldn't assert the case.

This patch adds both WPT and crashtests because I couldn't reproduce it
with WPT's simpler API use.

Differential Revision: https://phabricator.services.mozilla.com/D111231
2021-04-09 02:34:23 +00:00
Masayuki Nakano 74d01e2a81 Bug 1701348 - Make `TextEditor::Init()` and `HTMLEditor::Init()` stop using `EditAction::eNotEditing` r=m_kato
Currently, they set `EditAction::eNotEditing` even though they may create a
paddning `<br>` element.  If there is already handling edit action, setting
`eNotEditing` makes inherit the parent edit action.
https://searchfox.org/mozilla-central/rev/be413c29deeb86be6cdac22445e0d0b035cb9e04/editor/libeditor/EditorBase.cpp#5150-5159

However, in the reported case, `FlushPendingNotificationsIfToHandleDeletionWithFrameSelection()`
is called for computing target ranges at `forwarddelete` command handling.
In this case, `EditAction::eDeleteSelection` or something is set as parent
edit action.
https://searchfox.org/mozilla-central/rev/be413c29deeb86be6cdac22445e0d0b035cb9e04/editor/libeditor/EditorBase.cpp#3638-3660
But at this moment, `beforeinput` event hasn't been dispatched.  Then,
initializing code inherits this state and trying to insert a padding `<br>`
element without `beforeinput` event.  Then, we hit the assertion.

For solving this issue, `Init` methods should set edit action to "initializing"
and it should be marked as not requiring `beforeinput` event.

Differential Revision: https://phabricator.services.mozilla.com/D111191
2021-04-08 08:51:41 +00:00
Masayuki Nakano 0175ca9bc4 Bug 1649639 - Add WPT and remove unnecessary `MOZ_ASSERT` of `HTMLEditor::ClearStyleAt` r=m_kato
When the method detects the style coming from a parent block, the `MOZ_ASSERT`
checks whether the current mode is "style with CSS" or not because currently,
`HTMLEditor` does not use `<span>` with CSS when the mode is not "style with
CSS".  However, fixing it requires bigger patch, and the change does not match
with the bug's summary.  So, I just remove the `MOZ_ASSERT`, add WPT and filed
bug 1649639 for the root issue.

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

Differential Revision: https://phabricator.services.mozilla.com/D110896
2021-04-08 01:31:54 +00:00
Masayuki Nakano e1298d770d Bug 1697876 - part 2: Make `EditorBase::EndPlaceholderTransaction()` release placeholder transaction and related stuff before dispatching `input` event r=m_kato
Currently, it dispatches `input` event with holding `mPlaceholderTransaction`
and `mPlaceholerBatch` as 1.  If `input` event listener sets value in XUL
document, the setting value transaction will break the existing placeholder
transaction.  Then, only the last one will be undone, and it causes inserting
new padding `br` element with transaction and clears redo history.

This patch makes it forget them before dispatching `input` event.

Note that I tried to create automated test for this, but I cannot reproduce
this with simple testcase.  I guess something other things also required to
reproduce this bug.

Differential Revision: https://phabricator.services.mozilla.com/D110715
2021-04-05 11:35:49 +00:00
Masayuki Nakano 119be8e287 Bug 1697876 - part 1: Add logging code to transaction classes for making easier to debug r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D110714
2021-04-05 11:35:48 +00:00
Masayuki Nakano cbb83f40f6 Bug 1655988 - Fix assertion in `WhiteSpaceVisibilityKeeper::MakeSureToKeepVisibleStateOfWhiteSpacesAroundDeletingRange()` r=m_kato
This is a bug of the assertion.

When there is 2 text nodes are adjacent, one ends with a visible character and
the other starts with a white-space, and the deleting range ends at end of the
first one, `GetReplaceRangeDataAtEndOfDeletionRange()` returns a range starting
with the start of the second one since it does not need to touch the first one.
Therefore, the white-space range start may be after the deleting range end.

This patch adds new condition to the `MOZ_ASSERT_IF`, and test this specific
case with new `MOZ_ASSERT_IF`.

Differential Revision: https://phabricator.services.mozilla.com/D110068
2021-03-30 06:09:23 +00:00
Masayuki Nakano d68f6fc838 Bug 1220696 - part 6: Support `insertLineBreak` and `insertParagraphSeparator` commands in `<textarea>` r=smaug
Those command handlers just check whether the given editor is an `HTMLEditor`
or not.  Therefore, we should make them check whether the given editor is
a single line editor or not instead.

Differential Revision: https://phabricator.services.mozilla.com/D108572
2021-03-24 01:55:09 +00:00
Masayuki Nakano fad3ed3447 Bug 1220696 - part 5: Support "contentReadOnly" and "getHTML" commands in `<input>` and `<textarea>` r=smaug
Although these commands supported supported only by Gecko, we shouldn't stop
supporting them unless we know the usage in the wild.  Therefore, this patch
adds the handling code for `TextEditor` too.

Differential Revision: https://phabricator.services.mozilla.com/D108571
2021-03-24 01:55:09 +00:00
Masayuki Nakano f956ee81ea Bug 1220696 - part 3: Make `AutoEditorCommandTarget` consider command handling editor with command and focused `TextEditor` or `HTMLEditor` r=smaug
For making `execCommand` and related methods with `<input>` and `<textarea>`
even if they are in `contenteditable` and focused, command should be handled
in active editor (focused editor if in foreground window and tab).

However, some commands should be handled by `HTMLEditor` even if an `TextEditor`
has focus.  Therefore, this patch adds new enum class which have 3 state into
`InternalCommandData` and makes `AutoEditorCommandTarget` consider it with the
enum class.

Note that the new failures about `contentReadOnly` command will be fixed by
a following patch.

Differential Revision: https://phabricator.services.mozilla.com/D108569
2021-03-24 01:55:08 +00:00
Butkovits Atila 3361c11f7d Backed out 7 changesets (bug 1220696) for causing build bustages. CLOSED TREE
Backed out changeset 1ad2d5c0f253 (bug 1220696)
Backed out changeset 5e2f62a11d95 (bug 1220696)
Backed out changeset 07012ed7a30e (bug 1220696)
Backed out changeset a4e90de9355d (bug 1220696)
Backed out changeset 63ec6c3d05fd (bug 1220696)
Backed out changeset f165f45f8e1a (bug 1220696)
Backed out changeset ade95bf58db4 (bug 1220696)
2021-03-24 01:34:56 +02:00
Masayuki Nakano 9892a73421 Bug 1220696 - part 6: Support `insertLineBreak` and `insertParagraphSeparator` commands in `<textarea>` r=smaug
Those command handlers just check whether the given editor is an `HTMLEditor`
or not.  Therefore, we should make them check whether the given editor is
a single line editor or not instead.

Differential Revision: https://phabricator.services.mozilla.com/D108572
2021-03-23 19:29:23 +00:00
Masayuki Nakano 843cdb6b35 Bug 1220696 - part 5: Support "contentReadOnly" and "getHTML" commands in `<input>` and `<textarea>` r=smaug
Although these commands supported supported only by Gecko, we shouldn't stop
supporting them unless we know the usage in the wild.  Therefore, this patch
adds the handling code for `TextEditor` too.

Differential Revision: https://phabricator.services.mozilla.com/D108571
2021-03-23 19:29:23 +00:00
Masayuki Nakano fc94975380 Bug 1220696 - part 3: Make `AutoEditorCommandTarget` consider command handling editor with command and focused `TextEditor` or `HTMLEditor` r=smaug
For making `execCommand` and related methods with `<input>` and `<textarea>`
even if they are in `contenteditable` and focused, command should be handled
in active editor (focused editor if in foreground window and tab).

However, some commands should be handled by `HTMLEditor` even if an `TextEditor`
has focus.  Therefore, this patch adds new enum class which have 3 state into
`InternalCommandData` and makes `AutoEditorCommandTarget` consider it with the
enum class.

Note that the new failures about `contentReadOnly` command will be fixed by
a following patch.

Differential Revision: https://phabricator.services.mozilla.com/D108569
2021-03-23 19:29:22 +00:00
Mirko Brodesser 814b998fc2 Bug 1698786: part 4) Add some logging to `EditorSpellChecker`. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D108624
2021-03-18 09:33:22 +00:00
Jonathan Kew 0bf4eb7c5d Bug 1698734 - Don't create an EventListenerManager just to check for existing listeners. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D108612
2021-03-16 12:49:44 +00:00
Makoto Kato 605d5484aa Bug 1692052 - Don't notify IMEContext of widget when IMEStateManger doesn't manage this content. r=masayuki
This test case doesn't generate body element and isn't general case. Actually
since we don't manage current IME focus on IMEStateManager, we shouldn't notify
IMEContext of widget.

Differential Revision: https://phabricator.services.mozilla.com/D108366
2021-03-15 09:31:58 +00:00
Jonathan Kew a9143c6051 Bug 1692673 - Update tests for new Cut/Copy command-enabling behavior. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107481
2021-03-12 16:34:42 +00:00
Jonathan Kew 4fec409fa9 Bug 1692673 - Avoid enabling Cut/Copy menu commands in text editor context when there's no selection, unless a listener is present. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107480
2021-03-12 16:34:42 +00:00
Brindusan Cristian b073741c99 Backed out 3 changesets (bug 1692673) for bc failures in browser_contextmenu_input.js. CLOSED TREE
Backed out changeset 6060fa16bc3e (bug 1692673)
Backed out changeset 0f6717c26ae3 (bug 1692673)
Backed out changeset 8148b9e5dfba (bug 1692673)
2021-03-12 16:07:49 +02:00
Jonathan Kew 5eda87fe7b Bug 1692673 - Update tests for new Cut/Copy command-enabling behavior. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107481
2021-03-12 12:04:08 +00:00
Jonathan Kew 91adcd2694 Bug 1692673 - Avoid enabling Cut/Copy menu commands in text editor context when there's no selection, unless a listener is present. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107480
2021-03-12 12:04:07 +00:00
Csoregi Natalia 46c0e3eebc Backed out 2 changesets (bug 1692673) for failures on browser_contextmenu.js. CLOSED TREE
Backed out changeset dd24e610d956 (bug 1692673)
Backed out changeset b88ab8c6dd39 (bug 1692673)
2021-03-11 23:27:31 +02:00
Jonathan Kew ba5722b476 Bug 1692673 - Update tests for new Cut/Copy command-enabling behavior. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107481
2021-03-11 16:16:34 +00:00
Jonathan Kew e3ad8e8158 Bug 1692673 - Avoid enabling Cut/Copy menu commands in text editor context when there's no selection, unless a listener is present. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107480
2021-03-11 16:16:33 +00:00
Butkovits Atila 479d6f893c Backed out 2 changesets (bug 1692673) for causing build bustages on EditorBase.cpp. CLOSED TREE
Backed out changeset 988b919adc5c (bug 1692673)
Backed out changeset 5b1ba8dbfc8a (bug 1692673)
2021-03-11 12:43:24 +02:00
Jonathan Kew ba23557a7e Bug 1692673 - Update tests for new Cut/Copy command-enabling behavior. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107481
2021-03-11 10:27:04 +00:00
Jonathan Kew 24a5b45445 Bug 1692673 - Avoid enabling Cut/Copy menu commands in text editor context when there's no selection, unless a listener is present. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107480
2021-03-11 10:27:04 +00:00
Masayuki Nakano 18e444a223 Bug 1697249 - Stop creating `<span>` element for keeping same style as the link when the link will be unlinked r=m_kato
When typing at edge of a link, editor splits the link element at the edge (i.e.,
creating an empty link element).  Then, unlink the new link element (i.e.,
clearing the "link style").  At this time, `class` attribute and `style`
attribute are cloned to new `<span>` element for keeping the original style.
However, in this case, other browsers discard the specified style of the link.

On the other hand, when unlinking a link with `execCommand("unlink")`, the
other browsers keep specified style coming from `style` attribute.

Therefore, this patch adds new state to `PropItem`, which indicates whether
the `class` and `style` attribute should be cloned or discarded.  And then,
when preparing for inserting text, this patch makes it pass to the utility
method.

For better compatibility, we should stop cloning `class` attribute, but not
in this bug because this patch should be minimized for requesting uplift to
beta channel.

Differential Revision: https://phabricator.services.mozilla.com/D107801
2021-03-11 07:19:33 +00:00
Jonathan Kew ceb44d34d6 Bug 1664730 - Disable async font fallback when running mochitests, to avoid unpredictable extra reflows that can disrupt event-/timing-sensitive tests. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D107284
2021-03-10 12:26:52 +00:00
Masayuki Nakano 468bffc558 Bug 1429523 - Make IMEContentObserver ignore character data change notifications of invisible data nodes r=smaug
E.g., comment node is an invisible data node, and it's not handled by
`HTMLEditor` nor `ContentEventHandler`.  Therefore, `IMEContentObserver`
should ignore invisible data nodes, which are not derived from `dom::Text`.

Differential Revision: https://phabricator.services.mozilla.com/D107590
2021-03-09 23:57:56 +00:00
Masayuki Nakano eec5dff65e Bug 1655539 - Add crash test (the bug itself is fixed by the patch for bug 1677566) r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D107589
2021-03-09 23:57:55 +00:00
Masayuki Nakano 7af10cee55 Bug 1677566 - part 3: Ignore non-deletable ranges in `HTMLEditor::HandleDeleteSelection()` r=m_kato
For making delete handlers simpler, and set better target ranges to the
corresponding `beforeinput` event, we should ignore non-editable ranges
before handling deletion.

This patch makes editor stop handling deleteion when a range crosses editing
host boundaries.  In this case, Gecko has done nothing, but fired
`beforeinput` event.  Note that Blink deletes editable contents in the range
**until** it meets first non-editable content, but I don't think this is
a good behavior because it makes things complicated.  Therefore, I filed
a spec issue: https://github.com/w3c/editing/issues/283

On the other hand, this behavior change causes different behavior in
https://searchfox.org/mozilla-central/source/editor/libeditor/crashtests/1345015.html

It tries to insert paragraph into `<html>` element, but our editor currently
does not support it.  Therefore, it hits `MOZ_ASSERT`.  Therefore, this patch
added a new check into `HTMLEditor::InsertParagraphSeparatorAsSubAction()`.

Differential Revision: https://phabricator.services.mozilla.com/D107588
2021-03-09 23:57:54 +00:00
Masayuki Nakano 1229430221 Bug 1677566 - part 2: Make `HTMLEditUtils` treat a found non-editable element as a leaf node even if it has children r=m_kato
Blink treats each non-editable node as an atomic object.  E.g., deleting or
forward-deleting from next to a non-editable element, it deletes only one
non-editable element.

Unfortunately, our layout treat adjacent non-editable nodes as a node.
Therefore, the adding WPTs do not work, but they are not new regression of
this patch.

Differential Revision: https://phabricator.services.mozilla.com/D107587
2021-03-09 23:57:54 +00:00
Masayuki Nakano e659ab60ed Bug 1677566 - part 1: `WSRunScanner::TextFragmentData` stop handling non-editable content r=m_kato
It does not make sense `WSRunScanner` handles invisible white-spaces in
non-editable elements.  Therefore, this patch makes it stop handling in the
cases.

Note that this change causes new fail of some WPTs.  That will be fixed by
the following patch.

Differential Revision: https://phabricator.services.mozilla.com/D107586
2021-03-09 23:57:54 +00:00
Emilio Cobos Álvarez 0a34cbc059 Bug 1695650 - Consider selection editable even if the anchor is the empty <br> element. r=masayuki
Otherwise we disable the context menu commands which seems bad. This also
matches the HTML editor.

Differential Revision: https://phabricator.services.mozilla.com/D107513
2021-03-09 01:32:47 +00:00
Emilio Cobos Álvarez 942ec256fe Bug 1695650 - Clean up some checks in EditorUtils. r=masayuki
No behavior change. We were already returning false for HTML editor +
non-editable so we can simplify it a bit.

Depends on D107511

Differential Revision: https://phabricator.services.mozilla.com/D107512
2021-03-09 00:24:27 +00:00
Emilio Cobos Álvarez 60aae1e6b6 Bug 1695650 - Avoid to warn always. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D107511
2021-03-09 00:24:27 +00:00
Emilio Cobos Álvarez 4f347077a1 Bug 1696378 - Fuzz other test annotation.
MANUAL PUSH: Sheriffs mentioned this failure afterwards.
2021-03-05 02:41:03 +01:00
Kagami Sascha Rosylight e9a7261412 Bug 1360715 - Part 3: Remove remaining cross-context instanceof from tests r=edgar
Differential Revision: https://phabricator.services.mozilla.com/D106663
2021-03-04 22:03:58 +00:00
Brindusan Cristian b926d96be6 Backed out 3 changesets (bug 1360715) for mochitest failures at test_WebCrypto.html. CLOSED TREE
Backed out changeset b4a14c42313d (bug 1360715)
Backed out changeset 0e4b1b65fcbe (bug 1360715)
Backed out changeset fb8b9841d82b (bug 1360715)
2021-03-04 21:15:16 +02:00
Kagami Sascha Rosylight 7bec866ac5 Bug 1360715 - Part 3: Remove remaining cross-context instanceof from tests r=edgar
Differential Revision: https://phabricator.services.mozilla.com/D106663
2021-03-04 15:05:27 +00:00
Masayuki Nakano 3b20d0d64b Bug 1655508 - Add crashtest (the bug itself was fixed by bug 1517028) r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D106873
2021-03-02 06:38:38 +00:00
Masayuki Nakano 5e6dccb510 Bug 1517028 - Make `HTMLEditor::SplitNodeDeepWithTransaction` not try to split non-splittable node and `HTMLEditor::HandleInsertParagraphInHeadingElement` check its result r=m_kato
There are 2 bugs.  One is that `SplitNodeDeepWithTransaction` tries to split
comment node, but it fails.  The other is, the failure result is not checked
by `HandleInsertParagraphInHeadingElement`.  Therefore, the original head
element's previous node may not be a heading element.

Depends on D106591

Differential Revision: https://phabricator.services.mozilla.com/D106620
2021-03-02 00:51:05 +00:00
Makoto Kato b1cd4c6075 Bug 1675779 - Update browserscope for contenteditable=false case. r=masayuki
browserscope is no longer maintained, so contenteditable=false case is
incorrect now. So I would like to update this tests for non editable case.

Differential Revision: https://phabricator.services.mozilla.com/D96299
2021-02-22 10:18:49 +00:00
Makoto Kato 6d173e8282 Bug 1675779 - HandleDeleteAtomicContent should handle non-editable text node. r=masayuki
Since `WSScanResult` can return non-editable/non-removable text node,
`HandleDeleteAtomicContent` is called with non editable text node, then it cannot
remove atomic content.

This fix doesn't follow other block case such as added newer test.

Differential Revision: https://phabricator.services.mozilla.com/D96298
2021-02-22 10:18:48 +00:00