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

11613 Коммитов

Автор SHA1 Сообщение Дата
Cristina Horotan 6a90f5eded Backed out 2 changesets (bug 1856795) for causing build bustage at BasicEvents.h CLOSED TREE
Backed out changeset 1d98b028923a (bug 1856795)
Backed out changeset eae2ac93e17c (bug 1856795)
2023-10-14 21:42:14 +03:00
Sylvestre Ledru cc8a0ee742 Bug 1856795 - Remove redundant member init r=emilio
Done with:
./mach static-analysis check --checks="-*, readability-redundant-member-init" --fix .

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html

Differential Revision: https://phabricator.services.mozilla.com/D190002
2023-10-14 17:34:26 +00:00
Masayuki Nakano 0b01d23e7a Bug 1728433 - Make `WSScanResult::AssertIfInvalidData` check the ancestor block element if the reason is `CurrentBlockBoundary` r=m_kato
As the comment in the method, `CurrentBlockBoundary` may be set when `mContent`
is not a block.  However, it's not allowed that there is an editable block
ancestor of `mContent` in same editing host (in this case, `mContent` should be
the block).  Therefore, it should compute ancestor block element and check
whether it's not in same editing host if `mContent` is editable and connected.

Differential Revision: https://phabricator.services.mozilla.com/D190644
2023-10-13 02:57:08 +00:00
Tom Marble 0cb91fe33e Bug 1855300 - convert .ini manifests to .toml: batch 11 remaining **/mochitest.ini r=jmaher,geckoview-reviewers,extension-reviewers,valentin,credential-management-reviewers,cookie-reviewers,sgalich,m_kato,robwu
Differential Revision: https://phabricator.services.mozilla.com/D190515
2023-10-13 02:32:24 +00:00
Natalia Csoregi 8a80ae0079 Backed out changeset cf6b9d74c2f9 (bug 1857303) for causing failures on test_contenteditable_copy_empty_selection.html CLOSED TREE 2023-10-10 23:41:46 +03:00
Divyanshu Agrawal 4f93faf815 Bug 1857303 - Fire copy event when pressing Ctrl+C on contenteditable without selection. r=sefeng,masayuki
Differential Revision: https://phabricator.services.mozilla.com/D190402
2023-10-10 16:22:48 +00:00
Noemi Erli e4a13185fe Backed out changeset bf2277419073 (bug 1857303) for causing failures in test_contenteditable_copy_empty_selection.html CLOSED TREE 2023-10-10 18:06:45 +03:00
Divyanshu Agrawal fe85654dff Bug 1857303 - Fire copy event when pressing Ctrl+C on contenteditable without selection. r=sefeng,masayuki
Differential Revision: https://phabricator.services.mozilla.com/D190402
2023-10-10 13:58:35 +00:00
Emilio Cobos Álvarez 25c0d10932 Bug 1624819 - Remove TaskCategory and other quantum dom remnants. r=smaug,media-playback-reviewers,credential-management-reviewers,cookie-reviewers,places-reviewers,win-reviewers,valentin,mhowell,sgalich,alwu
Sorry this is not a particularly easy patch to review. But it should be
mostly straight-forward.

I kept Document::Dispatch mostly for convenience, but could be
cleaned-up too / changed by SchedulerGroup::Dispatch. Similarly maybe
that can just be NS_DispatchToMainThread if we add an NS_IsMainThread
check there or something (to preserve shutdown semantics).

Differential Revision: https://phabricator.services.mozilla.com/D190450
2023-10-10 08:51:12 +00:00
Jan-Niklas Jaeschke 5005fe0cc5 Bug 1840856: Fixed linefeed/linebreak issues for contenteditable. r=masayuki,dom-core
This patch is related to Bug 1840822, which fixes some issues
regarding additional invisible linebreaks needed at the end of
contenteditables.
This patch in particular fixes the case where the user
presses enter at the end of a pre-formatted
contenteditable, e.g.:
```
<span contenteditable style="display:block;white-space:pre-line">[]</span>
```
Prior to this patch, only one `<br>` was added,
the invisible padding linebreak was missing.
With this patch applied, the behaviour should be as expected:
```
<span contenteditable style="display:block;white-space:pre-line">\n<br></span>
```

Differential Revision: https://phabricator.services.mozilla.com/D190217
2023-10-10 08:38:02 +00:00
Masayuki Nakano bccbdc8b58 Bug 1845241 - Make `nsIFrame::HandleEvent` move caret when secondary mouse button down r=edgar,emilio,dom-core
The other browsers move focus and `Selection` whe right click even if the
clicked element is not editable and even if there is a non-collapsed selection.
Fortunately, we already have similar code for the middle button press.
Therefore, we can make it run when the pressed button is the secondary button.

This also fixes bug 416546 and does not resurrect bug 709476.

However, this patch adds 2 prefs for making users customizable.  Our traditional
behavior is, we never collapse non-collapses selection with a right click even
if clicked outside the selection.  This allows users to open context menu for
selected text much easier.  Therefore, even though the behavior is different
from the others, we should keep the traditional behavior, but some users may
want the other browsers' behavior instead.  For them, this should be switchable
by a pref.

Additionally, I'm still not sure collapsing selection with a right click in
non-editable content especially for users using the caret browsing mode.
Therefore, for making things safer, this adds a pref to disable the new behavior
in the non-editable content.

Differential Revision: https://phabricator.services.mozilla.com/D189991
2023-10-10 03:20:21 +00:00
Masayuki Nakano a56eed4600 Bug 1852849 - Make `HTMLEditor::AutoInlineStyleSetter::ExtendOrShrinkRangeToApplyTheStyle` recompute common ancestor of the range if it updates the range r=m_kato
In this case, `<font face="monospace">abc []<br></font>`, the range applying
new style will be extended as `<font face="monospace">abc [<br>}</font>` first.
https://searchfox.org/mozilla-central/rev/29bdf6ff9965a647c6f64d63fed2b5bd094532c7/editor/libeditor/HTMLStyleEditor.cpp#1944

Then, the start point should be shrunken and the range should become
`<font face="monospace">abc {<br>}</font>`.
https://searchfox.org/mozilla-central/rev/29bdf6ff9965a647c6f64d63fed2b5bd094532c7/editor/libeditor/HTMLStyleEditor.cpp#1977-1978

However, `commonAncestor` is still the text node because it's not updated
after extending the range to include the `<br>`.  Then,
`AutoInlineStyleSetter::GetNextEditableInlineContent` fails to get `<br>`
from the text node.
https://searchfox.org/mozilla-central/rev/29bdf6ff9965a647c6f64d63fed2b5bd094532c7/editor/libeditor/HTMLStyleEditor.cpp#1576-1578

Finally, the unexpected range computation will reach here with the text editor
and adjust the start of the range to start of the text node.
https://searchfox.org/mozilla-central/rev/29bdf6ff9965a647c6f64d63fed2b5bd094532c7/editor/libeditor/HTMLStyleEditor.cpp#420-423

Therefore, the new text which the new style should be applied is jumped to
start of the text node.

Differential Revision: https://phabricator.services.mozilla.com/D190028
2023-10-07 05:56:15 +00:00
Masayuki Nakano dc4686ea4d Bug 1849763 - Make `HTMLEditor::HandleInsertBRElement` suggest caret position as at the invisible <br> if inserted r=jjaschke
If `HTMLEditor::HandleInsertBRElement` inserts an invisible `<br>` element
after a `<br>` element which is requested, new caret position should be
at the invisible `<br>` element.

Differential Revision: https://phabricator.services.mozilla.com/D189997
2023-10-04 07:26:57 +00:00
serge-sans-paille 974e37adf9 Bug 1855955 - Remove useless <iostream> includes r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D189648
2023-09-29 14:15:53 +00:00
Jan Varga c458754592 Bug 1855134 - Move existing MOZ_TRY macros to a dedicated header file; r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D189226
2023-09-28 20:46:07 +00:00
Masayuki Nakano ba6d410ac6 Bug 1851951 - Make `HTMLEditUtils::GetElementOfImmediateBlockBoundary` ignore invisible text node r=m_kato
Without this patch, the following test newly fails:
```
/editing/other/insertparagraph-with-white-space-style.tentative.html?white-space=nowrap&command=insertText
  FAIL <div contenteditable style="white-space:nowrap; display:inline">abc[]</div> (defaultparagraphseparator: div) - assert_equals: A <br> should be inserted at end expected "abc<br><br>" but got "abc<br>"
  FAIL <div contenteditable style="white-space:nowrap; display:inline">abc[]</div> (defaultparagraphseparator: p) - assert_equals: A <br> should be inserted at end expected "abc<br><br>" but got "abc<br>"
```

The reasons is, the inlined editing host is at end of the `<body>`, therefore,
even though the editing host itself is `inline`, it needs a padding `<br>` to
make it the new line visible.

However, `HTMLEditUtils::GetElementOfImmediateBlockBoundary` does not return
`<body>` because the editing host is followed by `<script>` which has
a text node which is not white-spaces only.  Therefore,
`HTMLEditUtils::IsVisibleBRElement` considers the `<br>` element at end of the
editing host is "visible".

Differential Revision: https://phabricator.services.mozilla.com/D188599
2023-09-27 03:01:26 +00:00
Masayuki Nakano 09514edd73 Bug 1851951 - Make `HTMLEditor` refer computed `display` instead of the HTML default style at considering block or inline element r=m_kato
Blink [1] and WebKit [2] refers `display-outside` value when they consider whether an
element is a block or an inline.

However, our editor refers HTML default style instead.  Therefore, our editor
cannot handle the following cases:
* If a container block is a non-HTML element whose `display` style is `block`.
* If a container `<div>` etc is styled as `inline` and typing `Enter` in it.
* If a container `<span>` is styled as `block` and it ends with spaces.

For making users get better result, we should follow the other browsers.

However, this is too risky change.  Therefore, this patch enables new behavior
only in the Nightly channel and early beta builds to collect feedback from
testers.

The big rules of checking block vs. inline are:
* When we handle block level edit actions such as formatting block, indenting
or outdenting selection, making or removing list, we should keep referring
the HTML default style because the other browsers do so and the commands are
intended for modifying the HTML structure.
* Otherwise, we should refer the computed style of the block.  However, if
working with non-connected elements, we may need a special handling that is
falling back to refer the HTML default style because `HTMLEditorDataTransfer`
work with non-connected document fragments.
* Finally, if we check visibility of collapsible white-spaces and `<br>`s, we
should refer computed style.  However, in this case, we may need to treat
ancestor `inline-block`s as block too, but for siblings, we should refer only
`display-outside`.

1. https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/editing_utilities.cc;l=779;drc=31fb07c05718d671d96c227855bfe97af9e3fb20
2. https://searchfox.org/wubkat/rev/b054636fffeffa0314914a11ce39725a3057131e/Source/WebCore/editing/Editing.cpp#317

Differential Revision: https://phabricator.services.mozilla.com/D188598
2023-09-27 03:01:26 +00:00
Joel Maher 99abb50b8d Bug 1853245 - Migrate .ini manifests to .toml (Batch 7.25). r=aryx,webdriver-reviewers,whimboo
Differential Revision: https://phabricator.services.mozilla.com/D189221
2023-09-26 17:40:01 +00:00
Olli Pettay b632508d71 Bug 1843477, remove main thread only CC macros, r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D187146
2023-09-26 12:36:20 +00:00
pommicket 03c8c72db9 Bug 1248186 - prevent focus loss at end of [contenteditable] r=masayuki
Adjust nsFocusManager::GetSelectionLocation so that
it never moves the selection outside of the "ancestor limiter".

Differential Revision: https://phabricator.services.mozilla.com/D186864
2023-09-26 07:45:20 +00:00
Cosmin Sabou baf8a5cf23 Backed out 6 changesets (bug 1843477) for causing hazards failures. CLOSED TREE
Backed out changeset 64b093aa12a9 (bug 1843477)
Backed out changeset bdcd84c938d1 (bug 1843477)
Backed out changeset 05c882dd0d9a (bug 1843477)
Backed out changeset 1de814e5820d (bug 1843477)
Backed out changeset 6a0e19a60a5d (bug 1843477)
Backed out changeset 48942aff586f (bug 1843477)
2023-09-26 05:32:28 +03:00
Olli Pettay ce2ffc54c9 Bug 1843477, remove main thread only CC macros, r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D187146
2023-09-25 21:09:00 +00:00
Gregory Pappas 4083653f6a Bug 1851097 - Remove layout.css.moz-document.content.enabled pref r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D187349
2023-09-15 18:08:14 +00:00
Gregory Pappas 16301b7fe2 Bug 1842986 - Remove dom.forms.inputmode pref r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D187421
2023-09-15 16:49:21 +00:00
Tom Marble 9e40a719f2 Bug 1850545 - convert .ini manifests to .toml: batch 3 chrome.ini (bis) r=jmaher,geckoview-reviewers,extension-reviewers,credential-management-reviewers,devtools-reviewers,fxview-reviewers,places-reviewers,profiler-reviewers,m_kato,mak,mtigley
Differential Revision: https://phabricator.services.mozilla.com/D187597
2023-09-13 18:28:32 +00:00
Cosmin Sabou 2b53f8d322 Backed out 3 changesets (bug 1843477) for causing hazards failures on TelemetryFixture.cpp. CLOSED TREE
Backed out changeset 4dd5d8ac600c (bug 1843477)
Backed out changeset e7bc0b63286a (bug 1843477)
Backed out changeset 4f45f40beaf7 (bug 1843477)
2023-09-08 20:21:46 +03:00
Olli Pettay d7c56b8b4f Bug 1843477, remove main thread only CC macros, r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D187146
2023-09-08 14:51:48 +00:00
Makoto Kato ef2a0ed90f Bug 1851105 - Use nsAString as parameter for WordBreaker::FindWord. r=TYLin
It is better to use nsAString rather than using pointer directly.

Differential Revision: https://phabricator.services.mozilla.com/D187256
2023-09-08 04:35:38 +00:00
Emilio Cobos Álvarez cc72d328af Bug 1851641 - Fix hiding cursor while typing. r=masayuki
This didn't work properly for non-native key bindings because:

  https://hg.mozilla.org/mozilla-central/rev/8934e6e6ccb6

Moved the DetachedFromEditorOrDefaultPrevented() check before the "hide
cursor" check, rather than after. This was a quick fix, because if we're
detached from the editor, then GetPresContext would assert. But I didn't
realize at the time (since it was a long time since I wrote the patch)
that most events there actually are default-prevented.

To fix this, split the checks. Checks for DetachedFromEditor() first,
and only after potentially hiding the cursor check whether the event is
default-prevented.

Differential Revision: https://phabricator.services.mozilla.com/D187536
2023-09-06 14:01:53 +00:00
Masayuki Nakano 2947020013 Bug 1846997 - Get rid of the tasks checking the legacy join/split direction mode of editor r=m_kato,jmaher,taskgraph-reviewers,gbrown,webdriver-reviewers,jgraham
The new join/split node direction mode seems working well in the wild because
we have no regression reports about it.  Therefore, we won't revert the pref
anymore, thus, the legacy mode behavior check is not required.

Differential Revision: https://phabricator.services.mozilla.com/D186680
2023-09-05 02:21:31 +00:00
Masayuki Nakano 40990b50cf Bug 1850910 - Make `WhiteSpaceVisibilityKeepers::DeleteContentNodeAndJoinTextNodesAroundIt()` return caret point correctly r=m_kato
It returns the result of
`MakeSureToKeepVisibleStateOfWhiteSpacesAroundDeletingRange()`, but it suggests
caret position only when it modifies the DOM tree since it does not take the
default caret position.

So, `DeleteContentNodeAndJoinTextNodesAroundIt()` does need to return
`aCaretPoint` with tracking it during DOM mutations if
`MakeSureToKeepVisibleStateOfWhiteSpacesAroundDeletingRange()` does not
suggest caret point.

I found this bug when I was trying to fix the unexpected failing of
forward delete at end of the last block in the editing host (bug 1850666)
because changing the error handling anyway cause another error at this line.
https://searchfox.org/mozilla-central/rev/bdd5b85b56885cd48bd91d262647e0d3499b3a27/editor/libeditor/HTMLEditorDeleteHandler.cpp#1652

Therefore, without fixing bug 1850666, I have no idea how to check this fix.

Differential Revision: https://phabricator.services.mozilla.com/D187196
2023-09-05 01:08:59 +00:00
Jeff Muizelaar 7e5a2fc8be Bug 1850819 - Let "Don't translate new lines for IME" ride into early beta. r=masayuki
This lets bug 1838355 (a5a62ea631e5) ride into early beta.

Differential Revision: https://phabricator.services.mozilla.com/D187141
2023-08-31 18:34:30 +00:00
Emilio Cobos Álvarez 124ea3bca7 Bug 1757463 - Avoid getting a pres context when detached from the editor.
MANUAL PUSH: Trivial orange fix CLOSED TREE
2023-08-31 01:21:04 +02:00
Emilio Cobos Álvarez 6fd7a45c30 Bug 1757463 - Implement hide cursor while typing at the DOM+Editor level. r=handyman,masayuki
This only hides the cursor if it's on the page you're editing, but given
that the point of the feature is to move the cursor out of the way, that
seems acceptable (and honestly it feels more of a feature than a bug).

This should work across platforms (though non-windows platforms need
ui.hideCursorWhileTyping=1 in about:config to enable).

Differential Revision: https://phabricator.services.mozilla.com/D171155
2023-08-30 16:50:26 +00:00
Emilio Cobos Álvarez 33968f7c4e Bug 1850293 - Make editable states not intrinsic. r=smaug,masayuki
This one is tricky because form controls, though I think I got it right...

This fixes a pre-existing bug where we're not following the spec for readonly
inside content-editable.

I filed this as bug 1850390 but other browsers match the spec so add a test and
fix it while at it. This allows cheaper checks for readonlyness in a couple
places.

Differential Revision: https://phabricator.services.mozilla.com/D186896
2023-08-30 09:18:31 +00:00
Emilio Cobos Álvarez f9e14a4261 Bug 1539720 - Annotate new reftests as failing with drawSnapshot.
MANUAL PUSH: Orange fix CLOSED TREE
2023-08-23 14:00:28 -04:00
Emilio Cobos Álvarez e15bc40faf Bug 1539720 - Fix caret overflow adjustment computations. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D186366
2023-08-23 16:28:06 +00:00
Masayuki Nakano 81624b1310 Bug 1849080 - Make `HTMLEditor::MaybeCreatePaddingBRElementForEmptyEditor()` start a top level edit sub-action when it considers to modify the DOM tree r=m_kato
It does nothing in most cases because it inserts a `<br>` element only when
the editable `<body>` does not have meaningful content.  Therefore, we can
make it put off to create `AutoEditSubActionNotifier` to save the cost of
some expensive things done by `OnStartToHandleTopLevelEditSubAction()` and
`OnEndHandlingTopLevelEditSubAction()`.

Differential Revision: https://phabricator.services.mozilla.com/D186514
2023-08-23 08:34:33 +00:00
Masayuki Nakano 8224e1138c Bug 1840519 - Make typing surrogate pair behavior switchable with prefs r=m_kato,smaug
A lone surrogate should not appear in `DOMString` at least when the attribute
values of events because of ill-formed UTF-16 string.

`TextEventDispatcher` does not handle surrogate pairs correctly. It should not
split surrogate pairs when it sets `KeyboardEvent.key` value for avoiding the
problem in some DOM API wrappers, e.g., Rust-running-as-wasm.

On the other hand, `.charCode` is an unsigned long attribute and web apps
may use `String.fromCharCode(event.charCode)` to convert the input to string,
and unfortunately, `fromCharCode` does not support Unicode character code
points over `0xFFFF`.  Therefore, we may need to keep dispatching 2 `keypress`
events per surrogate pair for the backward compatibility.

Therefore, this patch creates 2 prefs.  One is for using single-keypress
event model and double-keypress event model.  The other is for the latter,
whether `.key` value never has ill-formed UTF-16 or it's allowed.

If using the single-keypress event model --this is compatible with Safari and
Chrome in non-Windows platforms--, one `keypress` event is dispatched for
typing a surrogate pair.  Then, its `.charCode` is over `0xFFFF` which can
work with `String.fromCodePoint()` instead of `String.fromCharCode()` and
`.key` value is set to simply the surrogate pair (i.e., its length is 2).

If using the double-keypress event model and disallowing ill-formed UTF-16
--this is the new default behavior for both avoiding ill-formed UTF-16 string
creation and keeping backward compatibility with not-maintained web apps using
`String.fromCharCode`--, 2 `keypress` events are dispatched.  `.charCode` for
first one is the code of the high-surrogate, but `.key` is the surrogate pair.
Then, `.charCode` for second one is the low-surrogate and `.key` is empty
string.  In this mode, `TextEditor` and `HTMLEditor` ignores the second
`keypress`.  Therefore, web apps can cancel it only with the first `keypress`,
but it indicates the `keypress` introduces a surrogate pair with `.key`
attribute.

Otherwise, if using the double-keypress event model and allowing ill-formed
UTF-16 --this is the traditional our behavior and compatible with Chrome in
Windows--, 2 `keypress` events are dispatched with same `.charCode` values as
the previous mode, but first `.key` is the high-surrogate and the other's is
the low surrogate.  Therefore, web apps can cancel either one of them or
both of them.

Finally, this patch makes `TextEditor` and `HTMLEditor` handle text input
with `keypress` events properly.  Except in the last mode, `beforeinput` and
`input` events are fired once and their `data` values are the surrogate pair.
On the other hand, in the last mode, 2 sets of `beforeinput` and `input` are
fired and their `.data` values has only the surrogate so that ill-formed
UTF-16 values.

Note that this patch also fixes an issue on Windows.  Windows may send a high
surrogate and a low surrogate with 2 sets of `WM_KEYDOWN` and `WM_KEYUP` whose
virtual keycode is `VK_PACKET` (typically, this occurs with `SendInput` API).
For handling this correctly, this patch changes `NativeKey` class to make it
just store the high surrogate for the first `WM_KEYDOWN` and `WM_KEYUP` and use
it when it'll receive another `WM_KEYDOWN` for a low surrogate.

Differential Revision: https://phabricator.services.mozilla.com/D182142
2023-08-23 01:16:59 +00:00
Cosmin Sabou 99faeda407 Backed out 2 changesets (bug 1539720) for causing caret related failures. CLOSED TREE
Backed out changeset a6a541637edd (bug 1539720)
Backed out changeset 970525aa04f1 (bug 1539720)
2023-08-17 14:16:49 +03:00
Emilio Cobos Álvarez e278cf26ab Bug 1539720 - Fix caret overflow adjustment computations. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D186366
2023-08-17 10:06:10 +00:00
Jan-Niklas Jaeschke 09be4ee8df Bug 1840822, part 3: Don't add a second line break if between block element and end of editing host. r=masayuki,dom-core
This patch deals with this case:
```
<span contenteditable><div>foo</div>[]</span>
```
In this case only one `<br>` should be added since one
line break is already added because of the `<div>` block.

Differential Revision: https://phabricator.services.mozilla.com/D185935
2023-08-16 09:34:50 +00:00
Jan-Niklas Jaeschke df8b4a288b Bug 1840822, part 2: Add an invisible line break at the end of a contenteditable for `InsertLineBreak` case. r=masayuki,dom-core
The logic behind this patch is similar to that of part 1, only that this covers the case where a user triggers a line break instead of a new paragraph (i.e. by pressing [Shift/cmd]+[Enter]).
If the inserted BR element is followed by a block boundary, another BR element is added.

Depends on D182339

Differential Revision: https://phabricator.services.mozilla.com/D182485
2023-08-16 09:34:50 +00:00
Jan-Niklas Jaeschke 9a0cf05339 Bug 1840822, part 1: Add an invisible line break at the end of a contenteditable for `insertParagraph` case. r=masayuki,dom-core
If a user presses <Enter> to add a new paragraph at the end of a contenteditable, a second (invisible) line break has to be added:
`<span contenteditable>foo[]</span>` --> `<span contenteditable>foo<br><br></span>`

This patch deals with contenteditables which do not preformat whitespaces
(i.e. should insert linebreaks, not linefeeds).
The linefeed cases are handled in Bug 1840856.
Also this patch only deals with a code path that uses `insertParagraph`.
The code path that uses `InsertLineBreak` is handled in part 2 of this Bug.

The patch implements a lambda function that inserts a second `<br>` element,
which is called in two situations:
1. The editing host is empty:
  `<span contenteditable>[]</span>`--> `<span contenteditable><br><br></span>`
2. The caret is at a block boundary:
  `<span contenteditable>abc[]</span>` --> `<span contenteditable>abc<br><br></span>`

Differential Revision: https://phabricator.services.mozilla.com/D182339
2023-08-16 09:34:50 +00:00
Sean Feng 4379a8876c Bug 1848409 - Tweak the UpdateDefaultPreventedOnContent call to only special case the HTMLEditorEventListener case r=masayuki,dom-core
Calling `UpdateDefaultPreventedOnContent` separately from
`PreventDefault()` is error-prone. This patch should make it
safer.

Differential Revision: https://phabricator.services.mozilla.com/D186052
2023-08-15 13:46:42 +00:00
Masayuki Nakano c204c013dd Bug 1845215 - part 1: Make `ContentIteratorBase` a template class to work without strong pointers r=smaug
`ContentEventHandler` works with `PostContentIterator` and `PreContentIterator`
when it scans DOM nodes in a range.  While iterating the DOM nodes, script
never runs.  Therefore, we can make `ContentEventHandler` work with new
content iterators which do not store nodes with strong pointers.

This patch makes `ContentIteratorBase` a template class and create new
`UnsafePostContentIterator` and `UnsafePreContentIterator`.  They will
check whether DOM mutation or GC occurs before destruction to detect dangerous
regressions.

Differential Revision: https://phabricator.services.mozilla.com/D184441
2023-08-10 00:59:28 +00:00
CanadaHonk a117230132 Bug 1824121 - Implement the <search> element r=hsivonen,Jamie,emilio
Implemented the new <search> HTML element.
All WPT tests for it now pass (except one for iso-8859-8, not done generally).

A11y role uses just landmark as recommended instead of a new search role (for now).

Co-authored-by: Henri Sivonen <hsivonen@mozilla.com>

Differential Revision: https://phabricator.services.mozilla.com/D176967
2023-08-07 22:11:05 +00:00
Stanca Serban 183a888a39 Backed out 3 changesets (bug 1824121) for causing wpt failures in html5lib_search-element.html. CLOSED TREE
Backed out changeset e3aec91d79e4 (bug 1824121)
Backed out changeset e3a3324b1732 (bug 1824121)
Backed out changeset 6ff5c272ab8e (bug 1824121)
2023-08-07 21:20:18 +03:00
Cosmin Sabou c3bb54bb28 Bug 1824121 - Fix assertion on HTMLEditUtils.cpp. a=test-fix CLOSED TREE 2023-08-07 18:11:19 +03:00
Makoto Kato 7a484e97aa Bug 1719535 - Part 10.2. Update test results of editor with new segmenter. r=masayuki
Depends on D180774

Differential Revision: https://phabricator.services.mozilla.com/D180775
2023-08-07 06:24:01 +00:00
Masayuki Nakano 0f39d7eda7 Bug 1266437 - Drop "OS" modifier r=smaug,m_kato,karlt,Gijs
On Windows, Windows logo key was mapped to "OS" modifier, and on Linux,
it's same and the key is called "Super" and "Hyper".  That conformed to the
older UI Events spec.

However, UI Events declares that they should be mapped to "Meta" now and Chrome
handles it as the spec in Windows and Linux.  Therefore, we should align the
behavior to them.

Note that we've treated the legacy "Meta" modifier on Linux as DOM "Meta"
modifier state, and we'll keep this as-is because in Sun/Solaris keyboard
layout, they keys are mapped to the legacy "Meta".

Finally, the following check only `IsMeta()` but not `IsOS()`.  I think that
they should've checked `IsOS()` too.  Therefore, they will behave differently
in Windows and Linux.
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/base/Element.cpp#3287-3288
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/html/HTMLInputElement.cpp#3762-3764
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/html/HTMLInputElement.cpp#3796-3806
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/html/HTMLLabelElement.cpp#127-128
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/widget/gtk/nsGtkKeyUtils.cpp#1461-1462

Note that `KEY_NAME_INDEX_OS` will be removed in the patch for bug 1232918.

Differential Revision: https://phabricator.services.mozilla.com/D183480
2023-08-07 01:03:58 +00:00
Cristian Tuns f5572b469f Backed out 2 changesets (bug 1266437, bug 1232918) for causing mochitest failures in test_autoplay_policy_key_blacklist.html CLOSED TREE
Backed out changeset 33e3c6593d4b (bug 1232918)
Backed out changeset 1b56e99dd221 (bug 1266437)
2023-08-03 23:29:52 -04:00
Masayuki Nakano 0664d98bce Bug 1266437 - Drop "OS" modifier r=smaug,m_kato,karlt,Gijs
On Windows, Windows logo key was mapped to "OS" modifier, and on Linux,
it's same and the key is called "Super" and "Hyper".  That conformed to the
older UI Events spec.

However, UI Events declares that they should be mapped to "Meta" now and Chrome
handles it as the spec in Windows and Linux.  Therefore, we should align the
behavior to them.

Note that we've treated the legacy "Meta" modifier on Linux as DOM "Meta"
modifier state, and we'll keep this as-is because in Sun/Solaris keyboard
layout, they keys are mapped to the legacy "Meta".

Finally, the following check only `IsMeta()` but not `IsOS()`.  I think that
they should've checked `IsOS()` too.  Therefore, they will behave differently
in Windows and Linux.
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/base/Element.cpp#3287-3288
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/html/HTMLInputElement.cpp#3762-3764
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/html/HTMLInputElement.cpp#3796-3806
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/dom/html/HTMLLabelElement.cpp#127-128
* https://searchfox.org/mozilla-central/rev/9a4666e63199bd1bcfc9095f6efec3488c358458/widget/gtk/nsGtkKeyUtils.cpp#1461-1462

Note that `KEY_NAME_INDEX_OS` will be removed in the patch for bug 1232918.

Differential Revision: https://phabricator.services.mozilla.com/D183480
2023-08-04 00:10:11 +00:00
Emilio Cobos Álvarez 595328df6d Bug 1846745 - Remove nsColorNames.h. r=tlouw
Use the CSS parser to parse named colors.

Differential Revision: https://phabricator.services.mozilla.com/D185156
2023-08-03 10:52:14 +00:00
Olli Pettay ed29a8210b Bug 1837268, update inline spellchecker when text data is modified, r=masayuki
Using the test for bug 1602526 as the basis for the new test but tweaking it by
adding the event listener used in the first testcase of the bug.

Differential Revision: https://phabricator.services.mozilla.com/D184987
2023-08-03 09:25:44 +00:00
Sandor Molnar 13c7e4a350 Backed out 14 changesets (bug 1719535) for causing mochitest failures in accessible/tests/browser/mac/browser_text_basics.js CLOSED TREE
Backed out changeset 338c2c8d91af (bug 1719535)
Backed out changeset 3fdb2e999aba (bug 1719535)
Backed out changeset 63b9d2064827 (bug 1719535)
Backed out changeset 09c216cdbbc8 (bug 1719535)
Backed out changeset 29977dc00fb3 (bug 1719535)
Backed out changeset d3f8850a343b (bug 1719535)
Backed out changeset 90f1f621031f (bug 1719535)
Backed out changeset 52ca9bdc5bd4 (bug 1719535)
Backed out changeset 94536f0d5a1f (bug 1719535)
Backed out changeset d615264f9f5f (bug 1719535)
Backed out changeset f16f9e583378 (bug 1719535)
Backed out changeset e1abdee07587 (bug 1719535)
Backed out changeset 45f9ad406428 (bug 1719535)
Backed out changeset caa2b8a731dc (bug 1719535)
2023-08-02 14:55:26 +03:00
Makoto Kato bbb56c5782 Bug 1719535 - Part 10.2. Update test results of editor with new segmenter. r=masayuki
Depends on D180774

Differential Revision: https://phabricator.services.mozilla.com/D180775
2023-08-02 10:32:56 +00:00
Masayuki Nakano da566fe581 Bug 1845208 - Make `HTMLEditor::SplitAncestorStyledInlineElementsAtRangeEdges` abort if splitting points are lost r=m_kato
Due to the `DOMNodeRemoved` event listener, splitting at range boundaries
may fail tracking the DOM tree due to unexpected container lost.  In the
cases, the method should abort its task.

Differential Revision: https://phabricator.services.mozilla.com/D184457
2023-07-27 03:21:31 +00:00
Tooru Fujisawa d984b79117 Bug 1843794 - Rewrite editor/AsyncSpellCheckTestHelper.sys.mjs consumers in html/xhtml to use ChromeUtils.importESModule. r=masayuki
Depends on D183689

Differential Revision: https://phabricator.services.mozilla.com/D183690
2023-07-19 00:43:33 +00:00
Emilio Cobos Álvarez 7e60f84b6e Bug 1843663 - Remove pre windows-10-specific media queries and styles. r=dao,Gijs,handyman,settings-reviewers
Some basic clean-up. I want to do this before doing bigger changes in
bug 1843044.

There's tons more code that can get cleaned-up on the widget side, but
let's start with this.

Differential Revision: https://phabricator.services.mozilla.com/D183622
2023-07-18 14:11:33 +00:00
Jan-Niklas Jaeschke ea550f0d1a Bug 1842546 - Removed `dom.input_events.beforeinput.enabled` pref. r=dom-core,webidl,smaug,masayuki
Differential Revision: https://phabricator.services.mozilla.com/D183578
2023-07-17 08:50:11 +00:00
Dan Robertson 60e435c258 Bug 1842679 - Update test expectations for Element.focus change. r=emilio,credential-management-reviewers,devtools-reviewers,sgalich,ochameau
Element.focus() now centers an element in the block and inline
directions when the element should be scrolled into view. Update tests
to account for this.

Differential Revision: https://phabricator.services.mozilla.com/D183541
2023-07-16 21:27:22 +00:00
Jeff Muizelaar 78554540c7 Bug 1838355. Don't translate new lines for IME on Nightly. r=masayuki
This translation shows up prominently in the TipTap
Speedometer3 test. Chrome doesn't seem to do this translation
and other Windows programs also show inconsistency around
new lines.

Let's try disabling it on Nightly to check if anything breaks.

Differential Revision: https://phabricator.services.mozilla.com/D183046
2023-07-13 03:21:46 +00:00
Masayuki Nakano 3462eaa9e4 Bug 1840500 - Make `HTMLEditor::ClearStyleAt()` remove `<br>` for reuse before removing its parent from the tree r=m_kato
Once a parent node is removed from the tree, the node may become not editable
because editable state "inherits" from ancestor nodes.
`HTMLEditor::ClearStyleAt` cleans up unnecessary parent inline elements first,
but if `<br>` element which should be reused in the block parent is contained
the inline elements, `HTMLEditUtils::IsRemovableNode()` will start returning
`false` for the `<br>` element because of in a document fragment which do not
contain an element whose `contenteditable` is `true`.  Then,
`MoveNodeWithTransaction` fails to move it because of unremovable.

Therefore, this patch makes the method move `<br>` element before removing
inline elements and use `InsertNodeWithTransaction` instead if `<br>` element
is an orphan node.

Differential Revision: https://phabricator.services.mozilla.com/D182640
2023-07-12 00:52:39 +00:00
Sean Feng caee73fc75 Bug 1817723 - Allow HTMLEditor can receive events when the focus is switched between elements in the same shadow tree. r=masayuki
The EditorEventListener for HTMLEditor is registered on document,
which is problematic because it can't receive events when the focus is
switched between elements in the same shadow tree due to shadow dom
encapsulation.

We fix this by moving the EditorEventListener to nsWindowRoot so the
events can always be received.

Differential Revision: https://phabricator.services.mozilla.com/D178215
2023-07-07 14:55:28 +00:00
Sandor Molnar a81a88f6b1 Backed out 2 changesets (bug 1840822) editor/libeditor/tests/test_htmleditor_keyevent_handling.html CLOSED TREE
Backed out changeset a4bcffd471cb (bug 1840822)
Backed out changeset 8d5b2fe1fb51 (bug 1840822)
2023-07-06 16:07:49 +03:00
Jan-Niklas Jaeschke 1ed46919e6 Bug 1840822, part 2: Add an invisible line break at the end of a contenteditable for `InsertLineBreak` case. r=masayuki,dom-core
The logic behind this patch is similar to that of part 1, only that this covers the case where a user triggers a line break instead of a new paragraph (i.e. by pressing [Shift/cmd]+[Enter]).
If the inserted BR element is followed by a block boundary, another BR element is added.

Differential Revision: https://phabricator.services.mozilla.com/D182485
2023-07-06 10:29:18 +00:00
Jan-Niklas Jaeschke e5eaaeda7c Bug 1840822, part 1: Add an invisible line break at the end of a contenteditable for `insertParagraph` case. r=masayuki,dom-core
If a user presses <Enter> to add a new paragraph at the end of a contenteditable, a second (invisible) line break has to be added:
`<span contenteditable>foo[]</span>` --> `<span contenteditable>foo<br><br></span>`

This patch deals with contenteditables which do not preformat whitespaces
(i.e. should insert linebreaks, not linefeeds).
The linefeed cases are handled in Bug 1840856.
Also this patch only deals with a code path that uses `insertParagraph`.
The code path that uses `InsertLineBreak` is handled in part 2 of this Bug.

The patch implements a lambda function that inserts a second `<br>` element,
which is called in two situations:
1. The editing host is empty:
  `<span contenteditable>[]</span>`--> `<span contenteditable><br><br></span>`
2. The caret is at a block boundary:
  `<span contenteditable>abc[]</span>` --> `<span contenteditable>abc<br><br></span>`

Differential Revision: https://phabricator.services.mozilla.com/D182339
2023-07-06 10:29:17 +00:00
Masayuki Nakano 4aad801fd1 Bug 1840804 - Make `TextEditor::OnBlur` stop finalizing `Selection` if new element already gets focus r=m_kato
Before bug 1770874, `EditorBase::OnBlur` checked that for both `TextEditor`
and `HTMLEditor`.  However, accidentally, I removed the check from `TextEditor`.
Therefore, a call of `EditorBase::FinalizeSelection()` will hide the caret
even after another editor gets focus.

Therefore, this patch just take it back into `TextEditor::OnBlur`.

Note that I don't think the design mode handling is required there because
`TextEditor`s shouldn't be created in the design mode document.

Differential Revision: https://phabricator.services.mozilla.com/D182468
2023-06-30 00:17:05 +00:00
Kershaw Chang 705e17a537 Bug 1838829 - Skip failed tests, r=necko-reviewers,extension-reviewers,credential-management-reviewers,devtools-reviewers,dimi,valentin,robwu
Differential Revision: https://phabricator.services.mozilla.com/D181251
2023-06-28 13:21:00 +00:00
Masayuki Nakano 3ccab28855 Bug 1839553 - Move `EditorBase::IsInPlaintextMode()` to `HTMLEditor` with renaming to `IsPlaintextMailComposer()` r=m_kato
Now, most users of `EditorBase::IsInPlaintextMode()` are `HTMLEditor` itself.

There are some exceptions:

`EditorBase::GetDesiredSpellCheckState()` uses it to consider whether the root
(`<body>` if `HTMLEditor`) element's `specllcheck` attribute should be referred
or document's editing state.  I think that this should just check
`IsHTMLEditor()`, but I think it must be okay to keep this as-is for now.

`EditorEventListener::KeyUp()` uses it to consider whether `Ctrl` + left/right
`Shift` switches the text direction of the editing host if and only if user
installed both LTR/RTL keyboard layouts and running in Windows.  I think that
this should keep working in plaintext mail composer because nobody can control
the direction in plaintext editor.  Therefore, this needs to check either
`IsTextEditor()` or `IsPlaintextMailComposer()` returning `true`.

`EditorEventListener::DragEventHasSupportingData()` uses it to consider
whether the editor accepts styled text and files.  Therefore, it needs to check
either `IsTextEditor()` or `IsPlaintextMailComposer()` returning `false`.

Finally, we can stop setting `nsIEditor::eEditorPlaintextMask` to `TextEditor`.

Differential Revision: https://phabricator.services.mozilla.com/D181866
2023-06-28 01:01:12 +00:00
Emilio Cobos Álvarez a398815dad Bug 1839950 - CSSStyleDeclaration.getPropertyValue doesn't throw. r=peterv
We fixed nsComputedDOMStyle ages ago.

Differential Revision: https://phabricator.services.mozilla.com/D181944
2023-06-27 08:21:46 +00:00
Masayuki Nakano d1b927e773 Bug 1839814 - Move `nsIEditor.wrapWidth` to `nsIEditorMailSupport` r=m_kato
It's used only by the mail composers.  However, `EditorBase::mWrapColumn` is
also used by `TextEditor`.  Therefore, `EditorBase` still needs to manage the
member, but the setters, `SetWrapColumn()` and `SetWrapWidth()` can be in
`TextEditor` and `HTMLEditor`.

Differential Revision: https://phabricator.services.mozilla.com/D181836
2023-06-27 05:47:55 +00:00
Masayuki Nakano 88bfd15c96 Bug 1839793 - Move `EditorBase::FindBetterInsertionPoint` into `TextEditor` r=m_kato
Currently it runs if the instance is a `TextEditor` or it's in the plaintext
mode of `HTMLEditor`.  However, it does not make sense to run it only in
specific mode of `HTMLEditor`, and most part does not make sense for
`HTMLEditor`.

This patch moves the method to `TextEditor`, and for
`EditorBase::InsertTextWithTransaction()` and
`AutoRangeArray::ExtendAnchorFocusRangeFor()`, adds new method to
`EditorDOMPointBase` to get a text node position if it points around
a text node.

Differential Revision: https://phabricator.services.mozilla.com/D181835
2023-06-27 04:23:09 +00:00
Norisz Fay 07a91b8c6a Backed out 2 changesets (bug 1838829) for causing perma mochitest failure with dom/websocket/tests being skipped CLOSED TREE
Backed out changeset 19a5d4f1850a (bug 1838829)
Backed out changeset 97cd8a256954 (bug 1838829)
2023-06-27 02:52:52 +03:00
Norisz Fay ace9aded9a Backed out changeset f9f8e7cfe057 (bug 1817723) as requested by dev for causing regressions CLOSED TREE 2023-06-27 01:22:11 +03:00
Kershaw Chang 75c68b6864 Bug 1838829 - Skip failed tests, r=necko-reviewers,extension-reviewers,credential-management-reviewers,devtools-reviewers,dimi,valentin,robwu
Differential Revision: https://phabricator.services.mozilla.com/D181251
2023-06-26 14:22:14 +00:00
Masayuki Nakano cd6c4af40f Bug 1839555 - Get rid of `nsIFormControl::AllowDrop` r=dom-core,peterv
It was introduced in bug 206859, but the `<input type="text">` in
`<input type="file">` was replaced with `<label>` in bug 345195.
Additionally, it's used only by `EditorBase` to check `<input type="text">`
is in `<input type="file">`.  Therefore, we don't need it anymore.

Differential Revision: https://phabricator.services.mozilla.com/D181599
2023-06-24 00:58:44 +00:00
Emilio Cobos Álvarez 4cc6758558 Bug 1839922 - Remove usage of {Has,Get}Attr(kNameSpaceID_None, ..). r=edgar
We have more readable and faster versions (that just omit the namespace
arg).

Mostly done via sed, with a couple helpers to use the faster lookups
where possible.

Differential Revision: https://phabricator.services.mozilla.com/D181795
2023-06-23 10:01:32 +00:00
Emilio Cobos Álvarez 7bddcf9e5a Bug 1839223 - Remove nsMappedAttributes. r=smaug
Instead, lazily schedule evaluation of them before styling, much like we
were doing for SVG.

A subtle tweak is that we only remain scheduled while in the document.
This allows us to use the "in document" bit plus the "mapped attributes
dirty" bit to know our scheduled status. It also prevents doing silly
work for disconnected elements, and having to do hashmap lookups on
adoption and node destruction.

Differential Revision: https://phabricator.services.mozilla.com/D181549
2023-06-22 17:22:03 +00:00
Cristian Tuns 6957543e5e Backed out changeset a3e55d5f9f13 (bug 1839223) for causing multiple failures in Document.cpp CLOSED TREE 2023-06-22 11:34:15 -04:00
Emilio Cobos Álvarez 2c6de5f038 Bug 1839223 - Remove nsMappedAttributes. r=smaug
Instead, lazily schedule evaluation of them before styling, much like we
were doing for SVG.

A subtle tweak is that we only remain scheduled while in the document.
This allows us to use the "in document" bit plus the "mapped attributes
dirty" bit to know our scheduled status. It also prevents doing silly
work for disconnected elements, and having to do hashmap lookups on
adoption and node destruction.

Differential Revision: https://phabricator.services.mozilla.com/D181549
2023-06-22 14:31:16 +00:00
Norisz Fay e86f1fa0e9 Backed out 5 changesets (bug 1838829) for causing mochitest failures CLOSED TREE
Backed out changeset 693d34c8447d (bug 1838829)
Backed out changeset 903d9ff4afaa (bug 1838829)
Backed out changeset 5e51feff7467 (bug 1838829)
Backed out changeset e125be49d2a6 (bug 1838829)
Backed out changeset 1a8cf3c83dc4 (bug 1838829)
2023-06-22 03:37:07 +03:00
Kershaw Chang 2cdb6b3a96 Bug 1838829 - Skip failed tests, r=necko-reviewers,extension-reviewers,credential-management-reviewers,devtools-reviewers,dimi,valentin,robwu
Differential Revision: https://phabricator.services.mozilla.com/D181251
2023-06-21 19:43:33 +00:00
Sean Feng ddb6212fd9 Bug 1817723 - Allow HTMLEditor can receive events when the focus is switched between elements in the same shadow tree. r=masayuki
The EditorEventListener for HTMLEditor is registered on document,
which is problematic because it can't receive events when the focus is
switched between elements in the same shadow tree due to shadow dom
encapsulation.

We fix this by moving the EditorEventListener to nsWindowRoot so the
events can always be received.

Differential Revision: https://phabricator.services.mozilla.com/D178215
2023-06-19 17:58:15 +00:00
Masayuki Nakano 123489c9c6 Bug 1821799 - Make `AutoTrackDOMPoint` clear tracking point if the result gets lost from the document r=m_kato
It should not meet such situation if only editor updates the DOM tree.
Therefore, the result should be cleared in that case and all users should return
`NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE` in this case.

Depends on D180785

Differential Revision: https://phabricator.services.mozilla.com/D180786
2023-06-19 00:23:50 +00:00
Masayuki Nakano 6dfe53690e Bug 1837463 - Make move node methods return `nsresult` instead of using `ErrorResult` out-param r=m_kato
The assertion failure is caused by that `RemoveChild()` or `InsertBefore()` is
failed, and overriding the error code with `NS_ERROR_EDITOR_DESTROYED`.

For saving the construction cost of `ErrorResult` instances, the related methods
take `ErrorResult&` as in/out-param.  However, the cost is not so high if we
use `IgnoredErrorResult` and do not create it in the `for` loop in
`MoveChildrenBetween()`.  Therefore, this patch make them return `nsresult`
simply to avoid updating error code and suppressing JS error in various places.

Depends on D180786

Differential Revision: https://phabricator.services.mozilla.com/D180787
2023-06-16 08:17:16 +00:00
Masayuki Nakano 00a79d5c45 Bug 1755710 - Fix the assertion in `WhiteSpaceVisibilityKeeper::MakeSureToKeepVisibleStateOfWhiteSpacesAroundDeletingRange` r=m_kato
The assertion was introduced in bug 1655988.  However, the assertion assumes
that the given range ends before start of the deleting range (invisible
white-spaces), but that is wrong, the range may ends in middle of or end of
collapsible white-spaces.  Therefore, this patch just fixes the assertion.

Depends on D180783

Differential Revision: https://phabricator.services.mozilla.com/D180785
2023-06-16 05:08:56 +00:00
Masayuki Nakano 84694d94e2 Bug 1832511 - Fix bustage of gcc non-unified build in `HTMLEditor` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D181011
2023-06-15 11:12:18 +00:00
Masayuki Nakano a03d5b0201 Bug 1775380 - Clean up for-loops in `AutoRangeArray` with range-based for loops r=m_kato
Depends on D180782

Differential Revision: https://phabricator.services.mozilla.com/D180783
2023-06-15 08:15:38 +00:00
Masayuki Nakano 9a4701f405 Bug 1756237 - Make `HTMLEditor::HandleHTMLIndentAroundRanges` validate DOM tree in each time of the loop r=m_kato
There are 2 possible scenarios which are not handled by the method.

1. Moving content node to new `<blockquote>` has already been moved to outside
of the editing host.
2. There is no container to insert new `<blockquote>`, e.g., in an inline
editing host.

In the case #1, we should ignore the ex-child node.  In the case #2, we should
abort it.  Note that Chrome inserts `<blockquote>` even if there is no proper
container.  However, such behavior is disagreed in interop-2023.  Therefore,
it's okay just to abort it for now.

Depends on D180781

Differential Revision: https://phabricator.services.mozilla.com/D180782
2023-06-15 08:15:38 +00:00
Masayuki Nakano 0cc07c7aa0 Bug 1835427 - Make `HTMLEditor::ClearStyleAt` track given point at calling `SplitAncestorStyledInlineElementsAt()` r=m_kato
It may be called with `AutoTransactionsConserveSelection` instance.
Therefore, it may return `aPoint` as-is even after modifying the DOM tree.
So it should track the point during a call of
`SplitAncestorStyledInlineElementsAt()`.

Depends on D179421

Differential Revision: https://phabricator.services.mozilla.com/D179422
2023-06-12 00:23:31 +00:00
Masayuki Nakano e4eecd8149 Bug 1835444 - Make `HTMLEditor` never move unremovable nodes r=m_kato
The `outdent` handler faces unexpected scenario due to the `<blockquote>`
element becomes not editable due to the `onstart` listener. The event listener
runs when the `<marquee>` moves from its container to new left node at splitting
it. Therefore, we need to put a lot of "removable node checks" before moving
nodes.

Differential Revision: https://phabricator.services.mozilla.com/D179421
2023-06-12 00:23:31 +00:00
Masayuki Nakano 9f3eb23029 Bug 1768317 - Make `InsertTextTransaction::GetData()` returns reference of its `mStringToInsert` r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D179521
2023-06-12 00:08:02 +00:00
Jan-Niklas Jaeschke 1bbcb68c33 Bug 1828469, part 1: Prepare `RangeBoundaryBase` to be able to handle non-`MutationObserver` Range classes. r=masayuki
In order to support `StaticRange`s, which are not `MutationObserver`s, RangeBoundaries need to have an alternative way of ensuring that `mRef` points to the correct node.
This is now done by validating `mRef` every time `Ref()` is called using the parent and offset.
For performance reasons, this is disabled by default and should only be used for `StaticRange`s.

Differential Revision: https://phabricator.services.mozilla.com/D177892
2023-05-31 08:23:45 +00:00
Emilio Cobos Álvarez 0cc70589db Bug 1832275 - Fix up focused selection when focus returns to something else. r=masayuki
I was going to write an automated test but turns out that some of this
became much harder to test after bug 582459 :-(

Let me know if you want me to take a look at writing a browser test
(since I think otherwise we can't test this, we need to move focus
outside of the active tab).

Differential Revision: https://phabricator.services.mozilla.com/D178825
2023-05-28 22:07:29 +00:00
Sandor Molnar c06a989790 Backed out changeset 6a96bb1f430f (bug 1817723) for causing reftest crashes. CLOSED TREE 2023-05-24 17:31:13 +03:00
Sean Feng a7d8029535 Bug 1817723 - Allow HTMLEditor can receive events when the focus is switched between elements in the same shadow tree. r=masayuki
The EditorEventListener for HTMLEditor is registered on document,
which is problematic because it can't receive events when the focus is
switched between elements in the same shadow tree due to shadow dom
encapsulation.

We fix this by moving the EditorEventListener to nsWindowRoot so the
events can always be received.

Differential Revision: https://phabricator.services.mozilla.com/D178215
2023-05-24 13:31:57 +00:00
Sandor Molnar c7daca2e34 Backed out changeset e8b6a5dbf398 (bug 1817723) for causing mochitest failures in editor/libeditor/EditorEventListener.cpp CLOSED TREE 2023-05-24 10:03:39 +03:00
Sean Feng df6c9aefca Bug 1817723 - Allow HTMLEditor can receive events when the focus is switched between elements in the same shadow tree. r=masayuki
The EditorEventListener for HTMLEditor is registered on document,
which is problematic because it can't receive events when the focus is
switched between elements in the same shadow tree due to shadow dom
encapsulation.

We fix this by moving the EditorEventListener to nsWindowRoot so the
events can always be received.

Differential Revision: https://phabricator.services.mozilla.com/D178215
2023-05-23 22:57:16 +00:00
Masayuki Nakano fb4359c2c7 Bug 1833320 - Make `HTMLEditor::HandleInsertParagraphInListItemElement` consider caret position without `WSScanResult` if it reaches a block boundary r=m_kato
When `WSRunScanner::ScanNextVisibleNodeOrBlockBoundary` reaches a block
boundary, it may return `WSScanResult` without valid position value from
this path:
https://searchfox.org/mozilla-central/rev/11a4d97a7b5cdfa133f4bda4525649f651703018/editor/libeditor/WSRunObject.cpp#1777-1782

That happens if the reason is `WSType::CurrentBlockBoundary` or
`WSType::OtherBlockBoundary` even in usual cases.

If it's `WSType::CurrentBlockBoundary`, `TextFragmentDataAtStartRef().EndRef()`
may point in a text node in the block, but its `GetEndReasonContent()` returns
the block.  I'm not sure whether this is intentional result. (I guess t's a
bug.)

If it's `WSType::OtherBlockBoundary`, `TextFragmentDataAtStartRef().EndRef()`
may point in the list item, but `GetEndReasonContent()` returns a child block.

Those scan result change needs to understand `TextFragmentData` behavior again,
but it's difficult as you know. Therefore, this fixes the caller side not to
use `WSScanResult::Point()` if it meets a block boundary since start of the
block boundary is a good place to put caret.

Differential Revision: https://phabricator.services.mozilla.com/D178281
2023-05-23 02:46:20 +00:00
Mark Banner 130a655906 Bug 1826062 - Automatic fixes for upgrading Prettier to 2.8.8. r=mossop,perftest-reviewers,webcompat-reviewers,geckoview-reviewers,denschub,devtools-reviewers,sparky,calu
Differential Revision: https://phabricator.services.mozilla.com/D177027
2023-05-20 12:26:53 +00:00
Mark Banner 8219a5c503 Bug 1826062 - Automatic fixes for Prettier 2.0.5 upgrade. r=mossop,perftest-reviewers,webcompat-reviewers,geckoview-reviewers,denschub,devtools-reviewers,sparky,owlish
Differential Revision: https://phabricator.services.mozilla.com/D177025
2023-05-20 12:26:49 +00:00
Masayuki Nakano d646c17aa7 Bug 1833543 - Get rid of `typedef`s from the editor module r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D178275
2023-05-19 02:58:53 +00:00
Katherine Patenio ac4145f34d Bug 1830419 - Convert PanelMutiView.jsm and CustomizableUITestUtils.jsm in browser/components/customizableui to ESMs r=search-reviewers,Standard8,devtools-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D178362
2023-05-18 18:34:51 +00:00
Masayuki Nakano 859144ba5e Bug 1832710 - Make `EditorBase::DispatchClipboardEventAndUpdateClipboard` handle `ePasteNoFormatting` event message r=m_kato
Just a mistake, it should treat `ePasteNoFormatting` as an equivalent of `ePaste`.

Differential Revision: https://phabricator.services.mozilla.com/D177988
2023-05-16 22:44:10 +00:00
Masayuki Nakano 34b8e92a91 Bug 1828078 - part 2: Stop moving comment nodes when deleting a block/line boundary r=m_kato
With the preceding patch, comment nodes are also moved at deleting a block/line
boundary.  However, this causes some WPT failures.  Therefore, this adds an
option to the related methods.

Note that Chrome removes all comment nodes in moving nodes.  However, I don't
have the motivation to do that because it requires additional cost and I have
no idea to improve the compatibility in usual web apps.  So I believe that
doing it wastes the runtime performance unless we'd get a bug reports by the
difference.

Therefore, this patch does not update WPTs too.

Differential Revision: https://phabricator.services.mozilla.com/D176767
2023-05-16 00:30:52 +00:00
Masayuki Nakano 95e22b6d09 Bug 1828078 - part 1: Make `HTMLEditUtils::CanNodeContain` handle comment node r=m_kato
`HTMLEditUtils::CanNodeContain` does not handle comment nodes and cdata section
nodes (the latter one is available only in XHTML documents, it's treated as a
comment node in HTML documents).

When copying HTML from Word on Windows, that contains 2 comment nodes at
start of pasting body (which does not appear in clipboard viewer, so, Gecko
creates them somewhere) and that causes `HTMLEditUtils::CanNodeContain` returns
`false` for any parents.  Therefore,
`HTMLEditor::InsertNodeIntoProperAncestorWithTransaction` returns error
and the pasting fails with odd state and unexpectedly split the list item in
`HTMLWithContextInserter::InsertContents`.  Finally, undoing fails to do some
of them and causes destroying the editable nodes.

This patch makes `HTMLEditUtils::CanNodeContain` work with comment nodes
and cdata section nodes (the latter is treated as a comment node since there
is no "cdata" tag definition of `nsHTMLTag`) and
`HTMLEditor::InsertNodeIntoProperAncestorWithTransaction` just return
"not handled" result for some other types of nodes which cannot be inserted
in any elements.

Note that the result of pasting from Word is different from Chrome's result.
Chrome does not paste such comment nodes (but inserts comment nodes with
`insertHTML` command).  For now, I don't want to work on fixing this
compatibility issue since comment nodes does not cause any known troubles.
Therefore, this patch does not contain WPT updates.

Differential Revision: https://phabricator.services.mozilla.com/D176766
2023-05-16 00:30:52 +00:00
Masayuki Nakano f2950b7b62 Bug 1831434 - Make `EditorBase::InsertNodeWithTransaction` return error if inserted node is moved by JS r=m_kato
Some handlers, e.g., `HTMLWithContextInserter` may want to skip post processing
after inserting new node instead of immediately stop handling the action.
Currently, `HTMLWithContextInserter` correctly ignores the cases only when
`NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE` is required.  Therefore, making
`InsertNodeWithTransaction` return the error makes `HTMLWithContextInserter`
work correctly in tricky cases.

Differential Revision: https://phabricator.services.mozilla.com/D177446
2023-05-10 23:51:12 +00:00
Masayuki Nakano d092d9ee9a Bug 1815969 - part 5: Make editors handle pasting something in new focused editor if a `paste` event listener moves focus r=m_kato
If a `paste` event listener moves focus, Chrome makes new editor keep handling
the pasting.  For the compatibility, we should follow it unless the new focused
element is in different document because user should allow to paste it
explicitly.

On the other hand, this just stops handling "cut" in same situation because
handling it requires to update clipboard without user's activation.  Therefore,
the clipboard content and/or the new editor content may be lost from the users
point of view.

Note that `nsContentUtils::GetActiveEditor` may return `HTMLEditor` instance
when focused element does not have `TextEditor` even when non-editable element
has focus.  Therefore, if it returns an `HTMLEditor`, we need to check whether
it's active in the DOM window with a call of `HTMEditor::IsActiveInDOMWindow`.

Differential Revision: https://phabricator.services.mozilla.com/D176741
2023-05-10 06:44:53 +00:00
Masayuki Nakano c36cb31246 Bug 1815969 - part 4: Redesign `PasteTransferableAsAction` as same as the methods touched by the previous patch r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D176740
2023-05-10 06:44:53 +00:00
Masayuki Nakano 7e86134c89 Bug 1815969 - part 3: Redesign `EditorBase::PasteAsAction` and `EditorBase::PasteAsQuotationAsAction` r=m_kato
This patch makes `EditorBase` implement them as non-virtual methods and
implement their first part.  Then, they call new virtual methods to handle
paste and paste-as-quotation.

With this change, `TextEditor` starts to dispatch `paste` event when
paste-as-quotation.  The new test checks it.

Differential Revision: https://phabricator.services.mozilla.com/D176739
2023-05-10 06:44:52 +00:00
Masayuki Nakano ce7f71dbf7 Bug 1815969 - part 2: Make `PasteAsAction` and `PasteAsQuotationAsAction` stop taking `bool` argument r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D176738
2023-05-10 06:44:52 +00:00
Masayuki Nakano 294c506854 Bug 1815969 - part 1: Redesign `EditorBase::FireClipboardEvent` r=m_kato
It does not handle critical cases properly, and it uses an out-param.
We can rewrite it with `Result`.  However, unfortunately,
`nsCopySupport::FireClipboardEvent` does not return error.  Therefore,
the root callers still need to treat the error cases as "canceled".

Differential Revision: https://phabricator.services.mozilla.com/D176737
2023-05-10 06:44:52 +00:00
Stanca Serban de76f219a6 Backed out 5 changesets (bug 1815969) for causing build bustages in EditorBase.cpp. CLOSED TREE
Backed out changeset 1a47a7baf147 (bug 1815969)
Backed out changeset 5cbc7a690417 (bug 1815969)
Backed out changeset d36c58bcd9d7 (bug 1815969)
Backed out changeset 644cbb12a064 (bug 1815969)
Backed out changeset a42837f38b02 (bug 1815969)
2023-05-10 04:08:53 +03:00
Masayuki Nakano d822e1f271 Bug 1815969 - part 5: Make editors handle pasting something in new focused editor if a `paste` event listener moves focus r=m_kato
If a `paste` event listener moves focus, Chrome makes new editor keep handling
the pasting.  For the compatibility, we should follow it unless the new focused
element is in different document because user should allow to paste it
explicitly.

On the other hand, this just stops handling "cut" in same situation because
handling it requires to update clipboard without user's activation.  Therefore,
the clipboard content and/or the new editor content may be lost from the users
point of view.

Note that `nsContentUtils::GetActiveEditor` may return `HTMLEditor` instance
when focused element does not have `TextEditor` even when non-editable element
has focus.  Therefore, if it returns an `HTMLEditor`, we need to check whether
it's active in the DOM window with a call of `HTMEditor::IsActiveInDOMWindow`.

Differential Revision: https://phabricator.services.mozilla.com/D176741
2023-05-10 00:24:58 +00:00
Masayuki Nakano 0466156174 Bug 1815969 - part 4: Redesign `PasteTransferableAsAction` as same as the methods touched by the previous patch r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D176740
2023-05-10 00:24:58 +00:00
Masayuki Nakano a0040a10ce Bug 1815969 - part 3: Redesign `EditorBase::PasteAsAction` and `EditorBase::PasteAsQuotationAsAction` r=m_kato
This patch makes `EditorBase` implement them as non-virtual methods and
implement their first part.  Then, they call new virtual methods to handle
paste and paste-as-quotation.

With this change, `TextEditor` starts to dispatch `paste` event when
paste-as-quotation.  The new test checks it.

Differential Revision: https://phabricator.services.mozilla.com/D176739
2023-05-10 00:24:58 +00:00
Masayuki Nakano df325589c2 Bug 1815969 - part 2: Make `PasteAsAction` and `PasteAsQuotationAsAction` stop taking `bool` argument r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D176738
2023-05-10 00:24:57 +00:00
Masayuki Nakano 8926e2479e Bug 1815969 - part 1: Redesign `EditorBase::FireClipboardEvent` r=m_kato
It does not handle critical cases properly, and it uses an out-param.
We can rewrite it with `Result`.  However, unfortunately,
`nsCopySupport::FireClipboardEvent` does not return error.  Therefore,
the root callers still need to treat the error cases as "canceled".

Differential Revision: https://phabricator.services.mozilla.com/D176737
2023-05-10 00:24:57 +00:00
Mathew Hodson aa1d9b8575 Bug 1830460 - Update tests for ComponentUtils ESM. r=arai,perftest-reviewers,sparky
Differential Revision: https://phabricator.services.mozilla.com/D176783
2023-05-03 15:18:46 +00:00
Masayuki Nakano 411f6268ab Bug 1818122 - Skip test_nsIEditorMailSupport_insertTextWithQuotations.html if xorigin test r=m_kato
This test checks the behavior for Thunderbird.  Therefore, we don't need to
check it in different origin's `<iframe>`.

Differential Revision: https://phabricator.services.mozilla.com/D176244
2023-04-25 00:28:32 +00:00
Masayuki Nakano 770f2ee8b6 Bug 1829048 - Clean up ini files under editor/ r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D175975
2023-04-21 04:28:27 +00:00
Masayuki Nakano e4a81444c1 Bug 1807495 - part 1: Make `Document` notify `HTMLEditor` and `IMEStateManager` of pseudo focus change when editing state of focused editing host or document is changed r=smaug,m_kato
`IMEStateManager` basically runs at focus change.  However, when `designMode`
is set to `"off"` or focused editing host becomes non-editable (removing
`contenteditable` attribute or `contenteditable` attribute is set to `false`),
IME may be disabled without a focus change.  Therefore, `Document` needs to
notify `IMEStateManager` of the timing.

Additionally, `nsFocusManager` does not change focus when focused element
becomes not focusable (bug 1807597).  Therefore, `Document` needs to kick
`focus` or `blur` event handler of `HTMLEditor` when active editing host
becomes not editable.

However, if an ancestor of focused element becomes editable, I think that
`HTMLEditor` does not work well without focus move because it computes
editing host with current editing state in a lot of places, but `Selection`
and `nsFocusManager::GetFocusedElement` keeps working with previous focused
element which is now a editable child of editing host.  Therefore, this patch
marks them as `todo` in the new tests.

Differential Revision: https://phabricator.services.mozilla.com/D171196
2023-04-11 23:26:03 +00:00
Emilio Cobos Álvarez 641fa20731 Bug 1825825 - Simplify NAC setup. r=smaug
Make all UA widgets also NAC.

Keep the UA widget flag but break at anonymous subtree boundaries, so
that only nodes inside the UA widget directly (and not NAC from those)
get the flag.

This is important because two callers depend on this difference:

 * The style system, since we still want to match content rules from
   stylesheets in the UA widget. We also match user rules, which is a
   bit sketchy, but that was the previous behavior, will file a
   follow-up for that.

 * The reflector code, since we want the scope for UA widgets to not
   include the NAC nodes inside that UA widget. nsINode::IsInUAWidget
   got it wrong.

After this patch, ChromeOnlyAccess is equivalent to
IsInNativeAnonymousSubtree, so we should probably unify the naming.
That's left for a follow-up patch because I don't have a strong
preference.

Differential Revision: https://phabricator.services.mozilla.com/D174310
2023-04-05 09:19:15 +00:00
Makoto Kato cda1a13b1c Bug 1819109 - Remove snav.enabled. r=masayuki,geckoview-reviewers,emilio,owlish
Although we have removed Spatial navigation by bug 1341737, we still touch
`snav.enabled`. Let's remove it.

Differential Revision: https://phabricator.services.mozilla.com/D172390
2023-03-22 02:40:53 +00:00
Masayuki Nakano 050517a46f Bug 1810663 - Add Gecko specific command to enable new join/split node direction r=smaug,m_kato
This API is temporarily available and useful for web app developers who want to
stop supporting Gecko specific join/split direction handling as soon as possible
and who do not want Mozilla block their release schedule by rescheduling of
shipping the new behavior.  Additionally, adding this command allows web apps
detects whether Gecko supports the new behavior and whether it's enabled.

On the other hand, We don't want to ship opt-out API because it's hard to keep
maintaining the legacy behavior specific paths.  Therefore, the command does
nothing if web app calls
`Document.execCommand("enableCompatibleJoinSplitDirection", false "false")` if
the new behavior is enabled by default.

Differential Revision: https://phabricator.services.mozilla.com/D172351
2023-03-21 23:58:04 +00:00
Kershaw Chang 5e58575e28 Bug 1809843 - Skip Failed tests, r=necko-reviewers,extension-reviewers,credential-management-reviewers,valentin,sgalich,robwu
Differential Revision: https://phabricator.services.mozilla.com/D171842
2023-03-21 09:09:58 +00:00
Masayuki Nakano e5f024930b Bug 1820972 - Make `nsBaseDragService::FireDragEventAtSource` update `mSourceNode` if it's disconnected while `HTMLEditor` deletes selection caused by a drag operation r=edgar
The source node is typically a text node, and it may be editable by
`contenteditable` or `designMode`.  In that case, the source node may be removed
during the DnD session even without tricky JS code.  In this case, Blink and
WebKit updates the source node to dispatch `dragend` to the editing host.
This behavior does not conform to the standardized DnD behavior, however,
this is reasonable for editor apps which want to listen to events in editing
host or window/document for footprint and/or performance reason.  Therefore,
we should follow their behavior.

Differential Revision: https://phabricator.services.mozilla.com/D172091
2023-03-16 06:37:18 +00:00
Masayuki Nakano 60979a1af3 Bug 1820905 - Make `HTMLEditor::SplitNodeWithTransaction` return `NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE` if split nodes have been removed from the DOM tree r=m_kato
If one of them are removed from the DOM tree, it's hard to keep handling it
since we have both split direction paths.  Therefore, let's just return error
but not throw new exception in the case.

Differential Revision: https://phabricator.services.mozilla.com/D172205
2023-03-13 18:31:00 +00:00
Masayuki Nakano f56e91369e Bug 1820448 - Make `RangeUpdater::SelAdjSplitNode` handle insertion better r=m_kato
The root cause of this bug is, we tried to compute new offset with offset at
the new node.  However, as explained in the inline comments, it should compute
the offset with the right node offset in the new mode.  Therefore, it needs
to handle it by itself instead of just calling `SelAdjInsertNode`.

Differential Revision: https://phabricator.services.mozilla.com/D171965
2023-03-13 18:30:04 +00:00
Marian-Vasile Laza ee72efd1e9 Backed out 5 changesets (bug 1809843) for causing Cargo related build bustages. CLOSED TREE
Backed out changeset 5c494680f448 (bug 1809843)
Backed out changeset 02742b38edab (bug 1809843)
Backed out changeset 2b9b32ca8294 (bug 1809843)
Backed out changeset 56631cb02ae6 (bug 1809843)
Backed out changeset 37e35a60a71f (bug 1809843)
2023-03-13 13:53:26 +02:00
Kershaw Chang a60df34ad0 Bug 1809843 - Skip Failed tests, r=necko-reviewers,extension-reviewers,credential-management-reviewers,valentin,sgalich,robwu
Differential Revision: https://phabricator.services.mozilla.com/D171842
2023-03-13 11:12:33 +00:00
Masayuki Nakano b68e3ef35e Bug 1820449 - Make `WhiteSpaceVisibilityKeeper` verify tracking point of start of right joining node after flushing the tracker r=m_kato
In the legacy mode, right node is not removed from the DOM tree, therefore,
this bug was hidden.  However, after enabling the new mode, the point will
be out of the document.  Therefore, the check will cause
`NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE` error and the joining code stops handling
the deletion.

Differential Revision: https://phabricator.services.mozilla.com/D171822
2023-03-10 02:39:26 +00:00
Tiaan Louw c8476cb106 Bug 1817641 - Convert RGBA to AbsoluteColor for computed/animated/resolved CSS colors r=emilio
Computed color values will not be in the correct format, closer to the
one specified by the author.  This also means that colors accross the
code are stored now as AbsoluteColor or StyleAbsoluteColor.  This allows
color space/gamut information to be available for use.

Some animation related test failures had to be changed, because colors
now has greater precision.  Animated a color now causes a lot more
animation updates, which was not initially expected.  See the bug for
discussion.

Differential Revision: https://phabricator.services.mozilla.com/D171021
2023-03-07 11:28:15 +00:00
Mark Banner 9bbd275235 Bug 1820593 - Convert AsyncSpellCheckTestHelper to an ES module. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D171748
2023-03-07 09:40:39 +00:00
Masayuki Nakano 31b7027bb9 Bug 1818339 - Make `AutoRangeArray` set `mAnchorFocusRange` correctly r=m_kato
There are some paths which do not set `mAnchorFocusRange` correctly.
Therefore, even if its `RangeCount()` returns 1 or larger,
`GetAnchorFocusRange()` may return `nullptr`.

Differential Revision: https://phabricator.services.mozilla.com/D171045
2023-02-28 00:46:17 +00:00
Masayuki Nakano 3b390e1249 Bug 1817127 - Make `HTMLEditUtils::ContentIsInert` check `nsStyleUI::IsInert` instead of climbing up the tree r=emilio
However, we still need to climbing up the tree when
`nsIFrame::GetPrimaryFrame()` returns `nullptr`.

`<span inert style="display:none">` cases fail in Chrome. It must be caused by
their editor's `Selection` normalization result, but I think that it's wrong
behavior because `Selection` is a DOM API and the range is `inert`ed element.
Therefore, it's odd to change the behavior from the style.

Differential Revision: https://phabricator.services.mozilla.com/D170164
2023-02-23 15:08:30 +00:00
Masayuki Nakano 806244c866 Bug 1815827 - part 6: Get rid of `editor.use_div_for_default_newlines` pref r=m_kato
Depends on D169764

Differential Revision: https://phabricator.services.mozilla.com/D169765
2023-02-21 22:54:26 +00:00
Masayuki Nakano 05f8285a93 Bug 1815827 - part 5: Get rid of `editor.resizing.preserve_ratio` pref r=m_kato
Depends on D169763

Differential Revision: https://phabricator.services.mozilla.com/D169764
2023-02-21 22:54:26 +00:00
Masayuki Nakano 2c9a95743d Bug 1815827 - part 4: Get rid of `editor.positioning.offset` pref r=m_kato
Depends on D169762

Differential Revision: https://phabricator.services.mozilla.com/D169763
2023-02-21 22:54:25 +00:00
Masayuki Nakano 893c30b69c Bug 1815827 - part 3: Get rid of `editor.initialize_element_before_connect` pref r=m_kato
Depends on D169761

Differential Revision: https://phabricator.services.mozilla.com/D169762
2023-02-21 22:54:25 +00:00
Masayuki Nakano b29a944ac4 Bug 1815827 - part 2: Get rid of `editor.hr_element.allow_to_delete_from_following_line` pref r=m_kato
Depends on D169760

Differential Revision: https://phabricator.services.mozilla.com/D169761
2023-02-21 22:54:25 +00:00
Masayuki Nakano 3fa7da3abb Bug 1815827 - part 1: Get rid of `editor.css.default_length_unit` pref r=m_kato
Depends on D169759

Differential Revision: https://phabricator.services.mozilla.com/D169760
2023-02-21 22:54:24 +00:00
Jan-Niklas Jaeschke 2243494a74 Bug 1810403: Allow `nsRange`s to be in multiple `Selection`s. r=masayuki
The Custom Highlight API allows a use case where a `Range` of a `Highlight`
is also used as `Selection`. Due to the decision to use the `Selection` mechanism
to display `Highlight`s, a `Range` can be part of several `Selection`s.
Since the `Range` has a pointer to its associated `Selection`
to notify about changes, this must be adapted to allow several `Selections`.

As a tradeoff of performance and memory usage, the `Selection`s are stored
as `mozilla::LinkedList`. A helper class `mozilla::SelectionListWrapper`
was implemented to allow `Selection`s to be in multiple of these lists
and without having to be derived from `LinkedListElement<T>`.

To simplify usage of the list, the use case  "does this range belong to Selection x?"
is wrapped into the convenience method`IsInSelection(Selection&)`;
The method previously named like this was renamed to `IsInAnySelection()`
to be named more precisely.

Registering and unregistering of the closest common inclusive ancestor
of the `Range` is done when the first `Selection` is registered and
the last `Selection` is unregistered.

Differential Revision: https://phabricator.services.mozilla.com/D169597
2023-02-21 12:25:28 +00:00
Masayuki Nakano c9f870645d Bug 1815639 - part 12: Make `AutoDeleteRangesHandler::HandleDeleteHRElement()` stop touching `Selection` r=m_kato
Depends on D169757

Differential Revision: https://phabricator.services.mozilla.com/D169758
2023-02-21 11:19:10 +00:00
Masayuki Nakano 74f7cdb361 Bug 1815639 - part 11: Make `AutoDeleteRangesHandler::HandleDeleteAtomicContent` stop touching `Selection` directly r=m_kato
Depends on D169756

Differential Revision: https://phabricator.services.mozilla.com/D169757
2023-02-21 11:11:42 +00:00
Masayuki Nakano 8f518a5dfe Bug 1815639 - part 10: Make `AutoDeleteRangesHandler::HandleDeleteCollapsedSelectionAtVisibleChar` stop touching `Selection` directly r=m_kato
Depends on D169755

Differential Revision: https://phabricator.services.mozilla.com/D169756
2023-02-21 11:04:05 +00:00
Masayuki Nakano 695da959d9 Bug 1815639 - part 9: Make `AutoDeleteRangesHandler::HandleDeleteCollapsedSelectionAtWhiteSpaces` stop touching `Selection` directly r=m_kato
Depends on D169754

Differential Revision: https://phabricator.services.mozilla.com/D169755
2023-02-21 10:51:14 +00:00
Masayuki Nakano 39598d7624 Bug 1815639 - part 8: Make `HTMLEditor::InsertBRElementIfHardLineIsEmptyAndEndsWithBlockBoundary` stop touching `Selection` directly r=m_kato
Depends on D169753

Differential Revision: https://phabricator.services.mozilla.com/D169754
2023-02-21 10:45:10 +00:00