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

7292 Коммитов

Автор SHA1 Сообщение Дата
Ting-Yu Lin 392266a8fd Bug 1733878 - Remove LineBreaker::Prev() in InternetCiter. r=jfkthame,m_kato
This change is a rewrite, and is not expected to change the behavior.
Also, add a testcase exercising wrapping a long line.

Differential Revision: https://phabricator.services.mozilla.com/D128558
2021-10-15 18:10:09 +00:00
Alexandru Michis dac6815201 Backed out changeset 7c08aa027893 (bug 1576768) for causing multiple failures.
CLOSED TREE
2021-10-15 16:52:43 +03:00
Evgenia Kotovich a8b32926fa Bug 1576768 - Automatically format .sjs files using prettier. r=Standard8,agi,zombie,extension-reviewers
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D128482
2021-10-15 12:58:11 +00:00
Masayuki Nakano fc532efa09 Bug 1734771 - part 3: Make `AppendString()` and `AppendSubString()` take `const Text&` instead of `Text*` r=m_kato
Depends on D128139

Differential Revision: https://phabricator.services.mozilla.com/D128140
2021-10-12 15:02:38 +00:00
Masayuki Nakano 1836c00470 Bug 1729170 - Make all methods of `nsTextFragment` take `uint32_t` for the offset and length of text r=smaug
`nsTextFragment` is a storage of data node and DOM offset is `uint32_t`, but
some methods of `nsTextFragment` takes `int32_t` for the offset/length in
its text.  Therefore, callers need to cast from `uint32_t` to `int32_t` if
the offset value is offset in a DOM node.  Therefore, all methods of it should
take `uint32_t` values as offset/length in its text.

Differential Revision: https://phabricator.services.mozilla.com/D127923
2021-10-12 05:05:12 +00:00
Masayuki Nakano d37daf2f82 Bug 1729115 - part 3: Make `IMEStateManager` check whether given focused content matches with null `sContent` in design mode r=m_kato
`nsFocusManager` does not send `focus` event in some cases, e.g., non-editable
root element gets focus.  However, the element may become editable later without
a focus move.  Therefore, even if `IMEStateManager::sContent` is `nullptr`,
`IMEStateManager::UpdateIMEState()` and `IMEStateManager::FocusInEditor()` are
called with focused content when the uncomposed document is in design mode.

With this change, editor does not need to call `IMEStateManager` methods with
`nullptr` when it's in `designMode`.  Therefore, we can get rid of
`GetFocusedContentForIME()` which just returns `nullptr` if focused content is
in design mode.

Differential Revision: https://phabricator.services.mozilla.com/D127612
2021-10-12 04:41:14 +00:00
Masayuki Nakano 25a3c48305 Bug 1732845 - Add `nsINode::IsInDesignMode()` to check whether the node is directly in design mode r=smaug
There are a lot of check of `Document`'s editable state **with** comments. This
means that it's unclear for developers that only `Document` node is editable in
design mode.

Additionally, there are some points which use composed document rather than
uncomposed document even though the raw API uses uncomposed document. Comparing
with the other browsers, checking uncomposed document is compatible behavior,
i.e., nodes in shadow trees are not editable unless `contenteditable`.

Therefore, `nsINode` should have a method to check whether it's in design mode
or not.

Note that it may be called with a node in UA widget.  Therefore, this patch
adds new checks if it's in UA widget subtree or native anonymous subtree,
checking whether it's in design mode with its host.

Differential Revision: https://phabricator.services.mozilla.com/D126764
2021-10-12 03:14:43 +00:00
Jonathan Kew fff2fa76a6 Bug 1734590 - Both the static InternetCiter methods are now infallible, so no need to return/check an nsresult. r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D127865
2021-10-11 12:20:42 +00:00
Jonathan Kew 71472fbcf2 Bug 1734590 - Eliminate use of LineBreaker::DeprecatedNext in InternetCiter.cpp. r=TYLin
If the old DeprecatedNext() returned needs-more-text, we'd just force a break at the EOL position anyhow;
so the new behavior of Next(), always treating end-of-text as a break position, gives us this for free.

Differential Revision: https://phabricator.services.mozilla.com/D127806
2021-10-11 12:20:41 +00:00
Jonathan Kew b74f5de179 No bug - fix spelling of internal constant name: s/Carridge/Carriage/. r=masayuki DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D127972
2021-10-11 07:38:27 +00:00
Geoff Brown 7e36862b61 Bug 1724296 - Remove many skip-if(verify) test annotations (mochitest pt 2); r=jmaher
This completes the review of skip-if(verify) in mochitest.ini.

Differential Revision: https://phabricator.services.mozilla.com/D127992
2021-10-09 16:07:32 +00:00
Csoregi Natalia e92f158606 Backed out 4 changesets (bug 1734590) for failures on test_xmlserializer.js. CLOSED TREE
Backed out changeset e492f8fd3d53 (bug 1734590)
Backed out changeset 0af985bb7569 (bug 1734590)
Backed out changeset 3751b93ae994 (bug 1734590)
Backed out changeset 45059121c015 (bug 1734590)
2021-10-08 14:41:06 +03:00
Jonathan Kew 7daf89e7fe Bug 1734590 - Both the static InternetCiter methods are now infallible, so no need to return/check an nsresult. r=TYLin
Differential Revision: https://phabricator.services.mozilla.com/D127865
2021-10-08 10:05:52 +00:00
Jonathan Kew b69ca8f047 Bug 1734590 - Eliminate use of LineBreaker::DeprecatedNext in InternetCiter.cpp. r=TYLin
If the old DeprecatedNext() returned needs-more-text, we'd just force a break at the EOL position anyhow;
so the new behavior of Next(), always treating end-of-text as a break position, gives us this for free.

Differential Revision: https://phabricator.services.mozilla.com/D127806
2021-10-08 10:05:51 +00:00
Ting-Yu Lin e558c2cbd9 Bug 1733872 Part 2 - Add a new LineBreaker::Next(), and deprecate the old Next(). r=m_kato
This patch is similar to Bug 1728708 Part 4, but for line breaker. This
should make the future integration of ICU4X line segmenter easier. A
UAX14 compatible line breaker always breaks at the end of text
(rule LB3 [1]), and ICU4X line segmenter has this behavior, too.

Current LineBreaker::Next() doesn't treat the end of text as a line
break opportunity, so this patch deprecates it by renaming it, and add a
new Next() method.

TestASCIILB() has adopted the new Next(). All the other callers of the
DeprecatedNext (nsPlainTextSerializer, nsXMLContentSerializer,
InternetCiter) should be audited later, possibly with the removal of
Prev() because the all the usages are very close to Prev().

[1] https://www.unicode.org/reports/tr14/#LB3

Differential Revision: https://phabricator.services.mozilla.com/D127379
2021-10-07 07:39:13 +00:00
Masayuki Nakano fb82cd4173 Bug 1725850 - part 24: Port editor/libeditor/crashtests/636074-1.html to WPT r=saschanaz
Depends on D127511

Differential Revision: https://phabricator.services.mozilla.com/D127512
2021-10-05 23:44:54 +00:00
Masayuki Nakano 88c6ffc414 Bug 1725850 - part 23: Port editor/libeditor/crashtests/615450-1.html to WPT r=saschanaz
Depends on D127510

Differential Revision: https://phabricator.services.mozilla.com/D127511
2021-10-05 23:44:54 +00:00
Masayuki Nakano 458ac8f180 Bug 1725850 - part 22: Port editor/libeditor/crashtests/615015-1.html to WPT r=saschanaz
Depends on D127509

Differential Revision: https://phabricator.services.mozilla.com/D127510
2021-10-05 23:44:54 +00:00
Masayuki Nakano 2c7cc7087c Bug 1725850 - part 21: Port editor/libeditor/crashtests/612565-1.html to WPT r=saschanaz
Depends on D127508

Differential Revision: https://phabricator.services.mozilla.com/D127509
2021-10-05 23:44:53 +00:00
Masayuki Nakano 61f689566c Bug 1725850 - part 20: Port editor/libeditor/crashtests/499044-1.html to WPT r=saschanaz
Depends on D127507

Differential Revision: https://phabricator.services.mozilla.com/D127508
2021-10-05 23:44:53 +00:00
Masayuki Nakano f3f0050435 Bug 1725850 - part 19: Port editor/libeditor/crashtests/459613.html to WPT r=saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D127507
2021-10-05 23:44:53 +00:00
Chris Peterson ea48b5e2c8 Bug 1732234 - Fix non-unified build errors in editor/. r=masayuki
Building with `ac_add_options --disable-unified-build` on macOS hits the following -Wunreachable-code-return warnings-as-errors:

editor/libeditor/HTMLEditor.cpp:4341:26 [-Wunreachable-code-return] 'return' will never be executed
editor/libeditor/HTMLTableEditor.cpp:1629:10: warning: 'return' will never be executed [-Wunreachable-code-return]

Differential Revision: https://phabricator.services.mozilla.com/D126441
2021-09-28 04:26:52 +00:00
Masayuki Nakano 26910d70ce Bug 1725850 - part 18: Port editor/libeditor/crashtests/467647-1.html to WPT r=saschanaz
I think that the crashtests marked as `needs-focus` should wait `focus` event
in the document.  I think that `focus` event is fired only when the window has
focus (*1) and `Element.focus()` steals focus unless chrome UI has focus (*2).
If the testing document hasn't get focus yet, `focus` event will be dispatched
later (*3).

1: https://searchfox.org/mozilla-central/rev/d8d7539593d5a3071841289dee72f971650073ce/dom/base/nsFocusManager.cpp#1672-1681
2: https://searchfox.org/mozilla-central/rev/d8d7539593d5a3071841289dee72f971650073ce/dom/base/nsFocusManager.cpp#1683-1691
3: https://searchfox.org/mozilla-central/rev/d8d7539593d5a3071841289dee72f971650073ce/dom/base/nsFocusManager.cpp#759-777

Depends on D125920

Differential Revision: https://phabricator.services.mozilla.com/D125921
2021-09-22 21:30:54 +00:00
Masayuki Nakano 1e7828e884 Bug 1725850 - part 17: Port editor/libeditor/crashtests/456727-2.html to WPT r=saschanaz
Depends on D125919

Differential Revision: https://phabricator.services.mozilla.com/D125920
2021-09-22 21:30:53 +00:00
Masayuki Nakano 0483379cbe Bug 1725850 - part 16: Port editor/libeditor/crashtests/456727-1.html to WPT r=saschanaz
Depends on D125918

Differential Revision: https://phabricator.services.mozilla.com/D125919
2021-09-22 21:30:53 +00:00
Masayuki Nakano 28bbe04f1b Bug 1725850 - part 15: Port editor/libeditor/crashtests/448329-3.html to WPT r=saschanaz
Depends on D125917

Differential Revision: https://phabricator.services.mozilla.com/D125918
2021-09-22 21:30:52 +00:00
Masayuki Nakano e9d6cc71eb Bug 1725850 - part 14: Port editor/libeditor/crashtests/448329-2.html to WPT r=saschanaz
Depends on D125916

Differential Revision: https://phabricator.services.mozilla.com/D125917
2021-09-22 21:30:52 +00:00
Masayuki Nakano 54be07ba20 Bug 1725850 - part 13: Port editor/libeditor/crashtests/448329-1.html to WPT r=saschanaz
Depends on D125915

Differential Revision: https://phabricator.services.mozilla.com/D125916
2021-09-22 21:30:52 +00:00
Masayuki Nakano c7424ffec6 Bug 1725850 - part 12: Port editor/libeditor/crashtests/430624-1.html to WPT r=saschanaz
Depends on D125914

Differential Revision: https://phabricator.services.mozilla.com/D125915
2021-09-22 21:30:51 +00:00
Masayuki Nakano 0f8cc24fcb Bug 1725850 - part 11: Port editor/libeditor/crashtests/420439.html to WPT r=saschanaz
The test requires to support allowing nested `execCommand` if we want to run
completely.  From point of view of the purose of crashtests, we should allow
it for testing in more complicated situation.  Therefore, this patch allows
it while the test is running by the pref.

Differential Revision: https://phabricator.services.mozilla.com/D125914
2021-09-22 21:30:51 +00:00
Masayuki Nakano 5912f0b3ff Bug 1729480 - Make `keypress` event listener of editor and `execCommand` related methods access editor instance after flushing pending layout r=emilio,smaug
I have no idea how to make the test result stable because the intermittent
failure is caused by a race of `IMEContentObserver`'s content query performend
at vsync and `keypress` event after the `keydown` event.  Therefore, I try to
fix the root cause of the failure.

There are two paths reaching a public method of editor with pending
notifications.  One is `keypress` event listener of the editor.  The other is
`execCommand` related methods of `Document`.  Therefore, we should make them
flush pending notifications before accessing editor, but the cost may be too
expensive.  So we should consider whether we should flush pending notifications
or not as far as later.

Note that we cannot fix the `beforeinput` cases because flushing pending
notifications after dispatching `beforeinput` event may cause oranges.  It'll
be fixed while I'm working on bug 1710784.

Differential Revision: https://phabricator.services.mozilla.com/D125805
2021-09-17 17:48:05 +00:00
Masayuki Nakano f7705eac76 Bug 1731005 - HTMLEditor::GetActiveEditingHost() does not return editing host if selection is collapsed in `<input>` r=m_kato
If we flush pending notifications before calling `execCommand` in
`insert-*-in-void-element.tentative.html`, `HTMLEditor` does not work because
`GetActiveEditingHost()` returns `nullptr`.  This is wrong because `Selection`
cannot cross native anonymous subtree boundaries and the selection collapsed in
`<input>` element is valid.  Therefore, it should not check whether the content
has independent selection or not.

Differential Revision: https://phabricator.services.mozilla.com/D125791
2021-09-17 00:57:22 +00:00
Masayuki Nakano c0d8a32379 Bug 1730429 - part 2: Delete empty inline elements which become newly empty but preserve the styles for next editing r=m_kato
This change makes deletion of all contents in inline elements compatible with
the other browsers.

Differential Revision: https://phabricator.services.mozilla.com/D125369
2021-09-15 04:13:44 +00:00
Masayuki Nakano eecd5a5f1c Bug 1727840 - Make `DeleteNodeTransaction` allow to create its instance for non-editable text node which was created or modified by an editor r=m_kato
Although we don't have a testcase, `HTMLEditor` may need to delete a text node
if it's created for composition.  If it's not allowed, users may see staying
composition string in disabled editor.

Differential Revision: https://phabricator.services.mozilla.com/D125502
2021-09-15 00:20:19 +00:00
Masayuki Nakano 903be77ea2 Bug 1672900 - part 3: Make `ExtendOrShrinkRangeToDelete()` selects all contents in all list items if a list element is selected or all list items in a list element is selected r=m_kato
When a list element has non-empty list item element, even if the list element is
selected, deleting operation should make the list element empty first (i.e.,
making the list element has only one empty list item element).  Then, another
deleting operation/command can delete it completely.  This is Blink compat
behavior in most cases except when the list has non-editable list item element
as first and/or last child of it.

Note that the new failures of the browserscpe are not compatible with the
new behavior, that is, it wants a list element is deleted when the last
list item is deleted.
https://searchfox.org/mozilla-central/rev/08c493902519265d570250c8e7ce575c8cd6f5b5/editor/libeditor/tests/browserscope/lib/richtext2/richtext2/tests/delete.py#161-164
https://searchfox.org/mozilla-central/rev/08c493902519265d570250c8e7ce575c8cd6f5b5/editor/libeditor/tests/browserscope/lib/richtext2/richtext2/tests/forwarddelete.py#146-149

Here is same test in the WPT:
https://searchfox.org/mozilla-central/rev/08c493902519265d570250c8e7ce575c8cd6f5b5/testing/web-platform/tests/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html#386-402
And only Gecko failed in this case:
https://searchfox.org/mozilla-central/rev/08c493902519265d570250c8e7ce575c8cd6f5b5/testing/web-platform/meta/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html.ini#1449-1450
https://searchfox.org/mozilla-central/rev/08c493902519265d570250c8e7ce575c8cd6f5b5/testing/web-platform/meta/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html.ini#1937-1938
https://searchfox.org/mozilla-central/rev/08c493902519265d570250c8e7ce575c8cd6f5b5/testing/web-platform/meta/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html.ini#425-426
https://searchfox.org/mozilla-central/rev/08c493902519265d570250c8e7ce575c8cd6f5b5/testing/web-platform/meta/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html.ini#787-788

https://wpt.fyi/results/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html%3FDelete,ol?run_id=5734231113203712&run_id=6263979761467392&run_id=5750388243300352&run_id=5090688355008512
https://wpt.fyi/results/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html%3FDelete,ul?run_id=5734231113203712&run_id=6263979761467392&run_id=5750388243300352&run_id=5090688355008512
https://wpt.fyi/results/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html%3FBackspace,ol?run_id=5734231113203712&run_id=6263979761467392&run_id=5750388243300352&run_id=5090688355008512
https://wpt.fyi/results/input-events/input-events-get-target-ranges-deleting-in-list-items.tentative.html%3FBackspace,ul?run_id=5734231113203712&run_id=6263979761467392&run_id=5750388243300352&run_id=5090688355008512

Therefore, the new failures are expected result.

Depends on D125029

Differential Revision: https://phabricator.services.mozilla.com/D125030
2021-09-11 07:17:38 +00:00
Masayuki Nakano 48b4d9fa76 Bug 1672900 - part 2: Rewrite `HTMLEditor::AutoDeleteRangesHandler::ExtendRangeToIncludeInvisibleNodes()` with modern helper classes r=m_kato
And this renames the method to `ExtendOrShrinkRangeToDelete` for alining to
new behavior changed by the following patch.

Depends on D125028

Differential Revision: https://phabricator.services.mozilla.com/D125029
2021-09-11 07:17:37 +00:00
Masayuki Nakano 153b43e7e2 Bug 1720809 - part 2: Make `insertLineBreak` command handler in `HTMLEditor` insert a linefeed character instead of `<br>` element in same condition as Blink/WebKit r=m_kato
Similar to the previous patch, this patch makes `insertLineBreak` command
handler of `HTMLEditor` may insert a linefeed character instead of `<br>`
element for compatibility with Blink/WebKit.

Note that for making same name rules as `insertParagraphSeparator` command
handlers, this patch renames
`HTMLEditor::InsertBRElementAtSelectionWithTransaction()` to
`InsertLineBreakAsSubAction()` and moves
`EditorBase::InsertLineBreakAsSubAction()` to `TextEditor` since it's
used only by `TextEditor` instance.

Depends on D124731

Differential Revision: https://phabricator.services.mozilla.com/D124732
2021-09-10 21:45:47 +00:00
Masayuki Nakano 2640b6cdc9 Bug 1720809 - part 1: Make `insertParagraphSeparator` command handler in `HTMLEditor` insert a linefeed character instead of `<br>` element in same condition as Blink/WebKit r=m_kato
Blink and WebKit inserts linefeed character for `insertParagraphSeparator`
command if:
* the insertion point's block parent is an editing host
* the editing host's outside display is "inline"
* the editing host's white space style preformats linefeed characters

For web-compat, we should do this in these conditions.

Depends on D124562

Differential Revision: https://phabricator.services.mozilla.com/D124731
2021-09-10 21:45:47 +00:00
Masayuki Nakano 2884959c1b Bug 1725850 - part 10: Port editor/libeditor/crashtests/418923-1.html to WPT r=saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D124855
2021-09-10 13:09:42 +00:00
Masayuki Nakano 00b18cd680 Bug 1725850 - part 9: Port editor/libeditor/crashtests/414178-1.html to WPT r=saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D124854
2021-09-10 13:09:41 +00:00
Masayuki Nakano b0f9fd251f Bug 1725850 - part 8: Port editor/libeditor/crashtests/407277-1.html to WPT r=saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D124853
2021-09-10 13:09:41 +00:00
Masayuki Nakano d2a5978030 Bug 1725850 - part 7: Port editor/libeditor/crashtests/407256-1.html to WPT r=saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D124852
2021-09-10 13:09:40 +00:00
Masayuki Nakano 83f4defc52 Bug 1725850 - part 6: Port editor/libeditor/crashtests/407079-1.html to WPT r=saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D124851
2021-09-10 13:09:40 +00:00
Masayuki Nakano d07b22b20e Bug 1725850 - part 5: Port editor/libeditor/crashtests/407074-1.html to WPT r=saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D124850
2021-09-10 13:09:39 +00:00
Masayuki Nakano efe248d8b3 Bug 1725850 - part 4: Port editor/libeditor/crashtests/402172-1.html to WPT r=saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D124849
2021-09-10 13:09:39 +00:00
Masayuki Nakano 74249e5767 Bug 1725850 - part 3: Port editor/libeditor/crashtests/382778-1.html to WPT r=saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D124848
2021-09-10 13:09:39 +00:00
Masayuki Nakano 45b2fbb2a1 Bug 1725850 - part 2: Port editor/libeditor/crashtests/382527-1.html to WPT r=saschanaz
The test used CRLF.  Therefore, you may see all lines are changed.

Differential Revision: https://phabricator.services.mozilla.com/D124847
2021-09-10 13:09:38 +00:00
Masayuki Nakano fa96f6f36c Bug 1725850 - part 1: Port editor/libeditor/crashtests/336104.html to WPT r=saschanaz
This uses `setTimeout` for emulating original test as far as possible, but
unfortunately, we need to change `data` URI of the `<iframe>` to `srcdoc`
due to cross-origin error.

Differential Revision: https://phabricator.services.mozilla.com/D124846
2021-09-10 13:09:38 +00:00
Masayuki Nakano b8c286c107 Bug 1724650 - part 8: Update WPT result and add new tests to insert mulitple white-spaces r=m_kato
This does NOT add tests to `inserttext` command which includes linefeed
characters with other characters.  It seems that Blink handles 2 or more
length string is handled as multiple calls for every character.  So each
linefeed character is handled as `insertparagraph`, but Gecko treats the
linefeed characters as-is.  We should add the tests later with changing
Gecko's behavior, but for now, we should keep current behavior because
this difference must not be trobule in the wild, but we need to improve
preformatted string handler of Gecko better against reported web-compat
issues.

Differential Revision: https://phabricator.services.mozilla.com/D124562
2021-09-10 04:04:30 +00:00
Masayuki Nakano d09a8cbb39 Bug 1724650 - part 7: Make `HTMLEditor` treat preformatted linefeed characters correctly when retrieving a line range r=m_kato
`HTMLEditor` tries to collect all children in a line.  However, it does not
handle preformatted linefeed characters.  Especially when there is a
preformatted linefeed immediately before a block boundary, it becomes invisible.
So, the range of line needs to extend the range correctly similar to the case
if there is an invisible `<br>` element.

Differential Revision: https://phabricator.services.mozilla.com/D124561
2021-09-10 04:04:30 +00:00