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

789 Коммитов

Автор SHA1 Сообщение Дата
Divyanshu Agrawal 13347e51bb 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-27 18:36:02 +00:00
Masayuki Nakano 982ddb7a9a Bug 1859245 - part 3: Make `JoinNodesTransaction` and `SplitNodeTransaction` handle only the new direction mode r=m_kato
Depends on D191606

Differential Revision: https://phabricator.services.mozilla.com/D191607
2023-10-27 01:57:29 +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
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
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
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
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
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
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 ace9aded9a Backed out changeset f9f8e7cfe057 (bug 1817723) as requested by dev for causing regressions CLOSED TREE 2023-06-27 01:22:11 +03: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
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
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 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 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 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 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
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
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 b1b8ae7fb7 Bug 1815383 - part 1: Make `InsertTextTransaction::DoTransaction` stop updating `Selection` directly r=m_kato
And also this patch makes its only user,
`EditorBase::InsertTextIntoTextNodeWithTransaction`, and its only caller,
`EditorBase::InsertTextWithTransaction`, return `InsertTextResult` for
returning both end of inserted text and caret point suggestion.  Note that
if it's for IME composition, `CompositionTransaction` needs to update
`Selection` directly.  Therefore, caret point may be unset under composition
to updating `Selection` to wrong point (it seems that
`TextEditor::HandleInsertText` can be simplified later because of this change).

Depends on D169044

Differential Revision: https://phabricator.services.mozilla.com/D169744
2023-02-17 08:25:24 +00:00
Masayuki Nakano c2c61ff76b Bug 1797247 - part 5: Make `EditorBase::DeleteTextWithTransaction` and `HTMLEditor::DeleteTextWithTransaction` stop touching `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D169042
2023-02-15 22:46:42 +00:00
Masayuki Nakano 9fc0118afc Bug 1797247 - part 4: Make `EditorBase::DeleteRangesWithTransaction` not touch `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D169041
2023-02-15 22:40:14 +00:00
Masayuki Nakano f99f4540be Bug 1797247 - part 3: Make `EditorBase::DeleteRangesWithTransaction` do post-processing without `Selection` r=m_kato
Due to the loose error checks, this patch changes the behavior in edge cases.
E.g., if there is a case that `Selection` is extended by some unexpected JS
listeners/observers, the result may be different.  However, it must be not a
problem because normal web apps should handle it later.

Differential Revision: https://phabricator.services.mozilla.com/D169040
2023-02-15 22:31:09 +00:00
Masayuki Nakano b8589fff01 Bug 1797247 - part 2: Make `DeleteTextTransaction::DoTransaction` and `DeleteRangeTransaction::DoTransaction` stop updating `Selection` directly r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D169039
2023-02-15 22:23:34 +00:00
Masayuki Nakano 2c93600238 Bug 1797247 - part 1: Add delete transaction classes to use build time type checks r=m_kato
First, `EditorBase::CreateTransactionForDeleteSelection` returns an instance of
`EditAggregateTransaction`. It's a base class of `PlaceholderTransaction` and
`DeleteRangeTransaction` but it's also a concrete class.  However, it's too
generic.  Therefore, this patch creates `DeleteMultipleRangesTransaction` which
is a simple sub-class of it, and makes `EditAggregateTransaction` be an abstract
class.  Then, add `AddChild` methods to each concrete class to restrict the
type of child transactions.

Next, `DeleteRangeTransaction` contains only `DeleteNodeTransaction` and
`DeleteTextTransaction`.  Therefore, once they have a common base class,
we can check the type easier.  Therefore, this patch also adds
`DeleteContentTransactionBase` and
`EditorBase::CreateTransactionForCollapsedRange` becomes clearer what it
returns.

With these changes, `DeleteRangeTransaction` obviously contains only
`DeleteContentTransactionBase`, `DeleteMultipleRangesTransaction` contains only
`DeleteRangeTransaction`, `DeleteNodeTransaction` and `DeleteTextTransaction`.
And they are guaranteed at build time (at least from outside the classes).
***
fix

Differential Revision: https://phabricator.services.mozilla.com/D169038
2023-02-15 22:17:17 +00:00
Masayuki Nakano 46b5e78f5d Bug 1811161 - Make the style editor sets `color` attribute value of `<font>` to normalized color value r=m_kato
Currently, our editor sets `color` attribute of `<font>` to given value as-is.
However, the other browsers normalize it to `#[0-9a-z]{6}` before setting the
value, and some WTP expects the behavior.  Therefore, we need to follow it for
avoiding meaningless failures.

According to WPT, the parameter can be `"transparent"` even without
`styleWithCSS`.  Additionally, CSS color values are also allowed if
`styleWithCSS` is `true`.  Therefore, this patch includes some fixes for them
too to avoid new failures.

Differential Revision: https://phabricator.services.mozilla.com/D167500
2023-01-26 10:04:23 +00:00
Masayuki Nakano 5255ec92fc Bug 1803044 - part 3: Make `EditorBase::RemoveAttributeWithTransaction` stop creating transaction if the element does not have the removing attribute r=m_kato
Depends on D163997

Differential Revision: https://phabricator.services.mozilla.com/D163998
2022-12-13 01:17:11 +00:00
Masayuki Nakano ab06299299 Bug 1768315 - Get rid of `nsIEditor.transactionManager` due to unused r=m_kato
`nsITransactionManager` provides too low level things and editor may want to
stop using it in the future if Undo Manager spec is implemented in another
browser.  Therefore, I'd like to stop exposing `nsITransactionManager` instance
for editor.

Note that `mozilla::TransactionManager` is still created and used by the
UI of mailer of SeaMonkey (i.e., under `mailnews`), once we move
`nsITransactionManager` instance moved into SeaMonkey, we can make
`mozilla::TransactionManager` stop inheriting `nsITransactionManager`.

Differential Revision: https://phabricator.services.mozilla.com/D160008
2022-10-27 22:50:07 +00:00
Jan-Niklas Jaeschke 67840fe563 Bug 1783641: Deleting a selected word deletes surrounding whitespace on MacOS. r=masayuki
Native behaviour on MacOS dictates one whitespace being removed after double-clicking a word and pressing delete.
This behaviour is achieved by saving the information that the selection is created by doubleclick to the `nsFrameSelection`
and using it in the `DeleteRangeTransaction`, where the range is extended by one whitespace character before or after the range.

Differential Revision: https://phabricator.services.mozilla.com/D159613
2022-10-25 07:00:26 +00:00
Andrew McCreight b1fa3e3b36 Bug 1794811, part 1 - Include nsISupports.h instead of nsISupportsBase.h. r=necko-reviewers,nika,valentin
nsISupports.h includes nsISupportsBase.h, so it should be equivalent.

In the next patch, I'm changing things so that nsISupports is defined in
nsISupports.h instead of nsISupportsBase.h, and deleting the latter, so
this change will be needed anyways. I'm guessing people were using IWYU
or something like that.

Differential Revision: https://phabricator.services.mozilla.com/D159169
2022-10-17 16:09:22 +00:00
Masayuki Nakano ff05850ef8 Bug 1793694 - part 7: Stop exposting `CSSEditUtils.h` and `ChangeStyleTransaction.h` r=m_kato
Depends on D158636

Differential Revision: https://phabricator.services.mozilla.com/D158637
2022-10-12 02:44:20 +00:00