404 Commits
Author SHA1 Message Date
Masayuki Nakano 8e83f7d6a3 Bug 2031894 - part 2: Make TextEditor and HTMLEditor put off to start working with IMEContentObserver and the spellchecker after eFocus event propagation end r=m_kato,smaug
A `focus` event listener may change focus from the `focus` event target
and it's not good thing to run content script before dispatching
`eFocus` event via `OnFocus` of the editor classes. Therefore, let's
make `EditorEventListener` restart listening to `eFocus` event and
handle the things which are not referred by web content script after
the `focus` event propagation in the web content.

Unfortunately, this cannot drop `MOZ_CAN_RUN_SCRIPT` from
`TextEditor::OnFocus` nor `HTMLEditor::OnFocus` because selection
listeners may run. However, they should not run web content script.
So, the preprocessing of `eFocus` or `eBlur` event becomes much safer
by this change.

Differential Revision: https://phabricator.services.mozilla.com/D294361
2026-05-27 04:34:10 +00:00
Masayuki Nakano 7333776605 Bug 2031894 - part 1: Make TextEditor::OnFocus stop flushing the pending notifications r=m_kato
`TextEditor::OnFocus()` is called when
`HTMLInputElement::PreHandleEvent()` or
`HTMLTextAreaElement::PreHandleEvent()` is called, that means that when
it's called, the `eFocus` event has not been dispatched yet.

On the other hand, flushing the layout in `TextEditor::OnFocus()` was
added in bug 1755104 for making `TextEditor` stop handling `eFocus`
event if the focus is redirected by a preceding `focus` event listener.
However, now, there is no preceding `focus` event listener of
`TextEditor::OnFocus()`. Therefore, we don't need to do that anymore.

Differential Revision: https://phabricator.services.mozilla.com/D294360
2026-05-27 04:34:07 +00:00
Emilio Cobos Álvarez 1ddad57128 Bug 2034055 - Clean up NodeList / HTMLCollection set-up. r=smaug
Make them concrete classes rather than interfaces, and make the
inheritance chain simpler.

Differential Revision: https://phabricator.services.mozilla.com/D296484
2026-04-28 07:38:27 +00:00
Silaghi ce61f876cc Revert "Bug 2034055 - Clean up NodeList / HTMLCollection set-up. r=smaug" for causing wpt failures at BaseContentList
This reverts commit cde3e5607b.
2026-04-28 03:43:46 +00:00
Emilio Cobos Álvarez cde3e5607b Bug 2034055 - Clean up NodeList / HTMLCollection set-up. r=smaug
Make them concrete classes rather than interfaces, and make the
inheritance chain simpler.

Differential Revision: https://phabricator.services.mozilla.com/D296484
2026-04-28 00:24:11 +00:00
Nishu Sheth 99a94b4894 Bug 1717071 - Allow copying URLs from iOS devices and pasting them into Firefox on MacOS, using Apple's "Universal Clipboard" feature r=mac-reviewers,masayuki,bradwerth
Differential Revision: https://phabricator.services.mozilla.com/D276492
2026-03-24 02:24:00 +00:00
Sylvestre Ledru 9f5cc05eee Bug 2023419 - Remove Emacs/Vim modelines from editor/ r=masayuki
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287844
2026-03-16 12:52:41 +00:00
Masayuki Nakano 1afcba4cc6 Bug 1998077 - part 3: Add new options to ignore empty/invisible leaf nodes r=m_kato
This adds some options which ignore some types of inline elements.

For example, `IgnoreAnyEmptyInlineContainers` is useful to scan previous
or next editable point because Chrome ignores empty inline elements when
deleting from next to an inline element.

`IgnoreInvisibleInlineVoidElements` is useful to scan invisible line
break from end of a block or checking a line break is invisible because
visible inline element makes a line after the last line break. E.g.,
```html
<div>ABC<br><span></span></div>
```
This shows only one line. However,
```html
<div>ABC<br><span style="border:1px solid"></span></div>
```
This shows 2 lines in the `<div>`.

Additionally, renaming the existing `LeafNodeType` values for making
them easier to understand.

Differential Revision: https://phabricator.services.mozilla.com/D277520
2026-01-13 05:27:41 +00:00
Sandor Molnar b77ea8700f Revert "Bug 1998077 - part 7: Reimplement HTMLEditUtils::GetInclusiveDeepestFirstChildWhichHasOneChild with LeafNodeOptions r=m_kato" for causing build bustages @ WSRunScanner.cpp
This reverts commit 5ccf392dce.

Revert "Bug 1998077 - part 6: Reimplement `HTMLEditUtils::Get(First|Last)Child()` and `HTMLEditUtils::Get(Next|Previous)Sibling()` with `LeafNodeOptions` r=m_kato"

This reverts commit 12eb928cb5.

Revert "Bug 1998077 - part 5: Replace the remaining `HTMLEditUtils::Get(Next|Previous)Content()` with new ones based on `Get(Next|Previous)LeafNodeOr(Next|Previous)BlockElement()` r=m_kato"

This reverts commit 58b4243d10.

Revert "Bug 1998077 - part 4: Replace some callers of `HTMLEditUtils::Get(Next|Previous)Content()` with `HTMLEditUtils::Get(Next|Previous)LeafContentOr(Next|Previous)BlockElement()` r=m_kato"

This reverts commit dd46967eb4.

Revert "Bug 1998077 - part 3: Add new options to ignore empty/invisible leaf nodes r=m_kato"

This reverts commit ca50a4a628.

Revert "Bug 1998077 - part 2: Add `WSType::EmptyInlineContainerElement` r=m_kato"

This reverts commit 4a5d93d631.

Revert "Bug 1998077 - part 1: Make `HTMLEditUtils::IsVisibleElementEvenIfLeafNode` work better if primary frame is available r=m_kato"

This reverts commit b42dc9d35f.
2026-01-07 06:15:59 +00:00
Masayuki Nakano ca50a4a628 Bug 1998077 - part 3: Add new options to ignore empty/invisible leaf nodes r=m_kato
This adds some options which ignore some types of inline elements.

For example, `IgnoreAnyEmptyInlineContainers` is useful to scan previous
or next editable point because Chrome ignores empty inline elements when
deleting from next to an inline element.

`IgnoreInvisibleInlineVoidElements` is useful to scan invisible line
break from end of a block or checking a line break is invisible because
visible inline element makes a line after the last line break. E.g.,
```html
<div>ABC<br><span></span></div>
```
This shows only one line. However,
```html
<div>ABC<br><span style="border:1px solid"></span></div>
```
This shows 2 lines in the `<div>`.

Additionally, renaming the existing `LeafNodeType` values for making
them easier to understand.

Differential Revision: https://phabricator.services.mozilla.com/D277520
2026-01-07 01:12:46 +00:00
Masayuki Nakano ced0b032f2 Bug 2006520 - Make TextInputListener::OnEditActionHandled independent from mFrame r=emilio
It's called by `TextEditor` after (maybe) modifying the value before
dispatching `input` event.

First, it updates the enabled state of the undo/redo commands.  However,
it's managed by the window.  Therefore, it does not make sense to depend
on the frame.

Then, it updates the various state of the related objects. For making
them work with destroyed `TextEditor`, this patch makes `TextEditor`
keep storing the latest value with caching the `Text` while it's
handling something.

Differential Revision: https://phabricator.services.mozilla.com/D276790
2025-12-18 02:12:34 +00:00
Masayuki Nakano a49dc3702d Bug 2001825 - Make EditorBase::GetPreferredIMEState() return Result<IMEState, nsresult> r=m_kato
For making the implementation is for which editor, the method should be
a pure virtual function and `TextEditor` and `HTMLEditor` implement it
as they needed.

Additionally, it should return `Result` to avoid the caller to use
fallback IME state even temporarily.

Differential Revision: https://phabricator.services.mozilla.com/D274386
2025-12-01 23:05:25 +00:00
Masayuki Nakano 5a9aae988c Bug 1992288 - Make AutoEditActionDataSetter manage whether the destroyed editor was reinitialized r=m_kato
Once the editor is destroyed while dispatching `beforeinput` event,
e.g., by a reframe of the text control frame, `AutoEditActionDataSetter`
marks "the editor has destroyed during my lifetime".  Then, nested
`EditAction`s always fail because the parent `AutoEditActionDataSetter`
thinks the editor is not available.

However, the editor can be reinitialized immediately.  Then, the nested
`EditAction`s should work (note that it does not mean that another user
input is handled, `AutoEditActionDataSetter` is used by some query
methods too). Therefore, this patch adds a new `bool` member to store
whether the editor is initialized again.

I think we could reset `mEditorWasDestroyedDuringHandlingEditAction`,
but I'm afraid to do that because it forgets the destroyed thing
completely and some features may need to abort handling something even
if the editor is restored since the editable nodes are recreated.
Therefore, this patch adds a new `bool` member for making this change
safer and anybody can access the details of the state.

Differential Revision: https://phabricator.services.mozilla.com/D271559
2025-11-12 22:54:20 +00:00
Masayuki Nakano 6ba307dd8f Bug 1824143 - part 1: Log TextEditor creation/destruction/focus/blur and when input and beforeinput events are fired r=m_kato
It's important to verify that when `TextEditor` is destroyed temporarily
if the text control frame is reframed by the web app during text input.
Therefore, this patch adds the logger for the timings of `TextEditor`
creation, destruction, focus and blur **and** the common `InputEvent`
dispatcher.

Differential Revision: https://phabricator.services.mozilla.com/D271558
2025-11-12 22:54:18 +00:00
Emilio Cobos Álvarez b59df383b0 Bug 1992551 - Simplify text editor value getter. r=smaug
Textarea no longer creates newlines in the middle (it only has a
trailing newline for caret positioning purposes), so this is equivalent
but avoids going through nsDocumentEncoder, nsPlainTextSerializer and so
on...

Differential Revision: https://phabricator.services.mozilla.com/D267509
2025-10-04 19:39:53 +00:00
Jan-Niklas Jaeschke 573f34249c Bug 1949053, part 4 - Rename CharacterData::TextFragment() to CharacterData::DataBuffer(). r=masayuki,firefox-style-system-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D259935
2025-08-06 08:48:09 +00:00
Jan-Niklas Jaeschke 0151e67615 Bug 1949053, part 2 - Rename nsTextFragment to mozilla::dom::CharacterDataBuffer. r=masayuki
This patch updates all occurrences of the type `nsTextFragment` into its new name, `mozilla::dom::CharacterDataBuffer`.
It also updates the includes, including sorting.

Differential Revision: https://phabricator.services.mozilla.com/D259867
2025-08-06 08:48:01 +00:00
Frédéric Wang 4cca1cbaa3 Bug 1928932 - Part 1 - Add an mIsTrusted flag on script elements. r=smaug,credential-management-reviewers,dimi
This flag can be modified when notifying for character data change,
content appending, content insertion and content removal by specifying
a MutationEffectOnScript flag. By default callers other than the HTML5
parsers always specify "drop trustworthiness" but mIsTrusted flag is not
used anyway, so there is no behavior change.

Spec: https://w3c.github.io/trusted-types/dist/spec/#enforcement-in-scripts
PR: https://github.com/w3c/trusted-types/pull/579/

Differential Revision: https://phabricator.services.mozilla.com/D252020
2025-06-27 15:23:24 +00:00
Cosmin Sabou a15f457eb6 Revert "Bug 1928932 - Part 1 - Add an mIsTrusted flag on script elements. r=smaug,credential-management-reviewers,dimi" for causing macOS build bustages on nsMenuGroupOwnerX.mm
This reverts commit ce2493cdd4.
2025-06-27 12:30:03 +00:00
Frédéric Wang ce2493cdd4 Bug 1928932 - Part 1 - Add an mIsTrusted flag on script elements. r=smaug,credential-management-reviewers,dimi
This flag can be modified when notifying for character data change,
content appending, content insertion and content removal by specifying
a MutationEffectOnScript flag. By default callers other than the HTML5
parsers always specify "drop trustworthiness" but mIsTrusted flag is not
used anyway, so there is no behavior change.

Spec: https://w3c.github.io/trusted-types/dist/spec/#enforcement-in-scripts
PR: https://github.com/w3c/trusted-types/pull/579/

Differential Revision: https://phabricator.services.mozilla.com/D252020
2025-06-27 11:18:48 +00:00
Masayuki Nakano f43bf73bb2 Bug 1953933 - Make TextEditor::IsEmpty() return true if it's not been initialized yet r=m_kato
`GetTextNode()` requires that the instance has already been initialized since
it requires the native anonymous `<div>`.  And `IsEmpty()` is a public method.
Therefore, it should return `true` if there is no editor root, i.e., when it's
not been initialized yet after creation or destroyed.

Additionally, `TextControlState::GetValue()` should call
`TextEditor::ComputeTextValue()` if the editor has not been initialized because
it requires the native anonymous subtree to compute the value.  I'm not sure
whether this is a bug when `<textarea>` is being initialized.
(I guess that it should get the default value of the text control element or
`mValue` in the case, but we should do that in another bug separately.)

I couldn't find the crash testcase, so, this does not contain a new test.

Differential Revision: https://phabricator.services.mozilla.com/D241543
2025-03-14 06:41:47 +00:00
Masayuki Nakano 617c636f1f Bug 1717155 - part 1: Make TextEditor use GetTextNode() more r=m_kato
The anonymous `<div>` of `TextEditor` has only one `Text` as its first child.
Therefore, we can make `TextEditor` simpler to access the `Text` node.

Differential Revision: https://phabricator.services.mozilla.com/D240419
2025-03-13 05:25:45 +00:00
Masayuki Nakano 8bb457917b Bug 1949364 - Make EditorBase::HandleInsertText take further information of composition state r=m_kato
In bug 1940377, `HandleInsertText` will need to normalize surrounding
white-spaces after updating composition string at composition end.  To consider
it easier, it's nicer that it takes more detail for the purpose of inserting
text.

Differential Revision: https://phabricator.services.mozilla.com/D239077
2025-02-26 05:56:24 +00:00
Masayuki Nakano 4e6fcb1183 Bug 1943228 - Rename methods GetSomethingWithoutCreation() to GetExtantSomething() r=edgar,dom-core
Differential Revision: https://phabricator.services.mozilla.com/D235256
2025-01-23 23:47:28 +00:00
Greg Stoll 75942a02c0 Bug 1918027 part 3 - share DataTransfer between clipboard event and calls to HandlePaste() r=edgar,dlp-reviewers,masayuki,handyman
This handles a race condition so if the user copies new data to the clipboard
while Content Analysis is ongoing, the original data will be used in the
paste action.

Differential Revision: https://phabricator.services.mozilla.com/D228719
2024-12-04 22:58:30 +00:00
Alexandru Marc 092f1d11f9 Backed out 5 changesets (bug 1918027) build bustages @ EditorBase.cpp CLOSED TREE
Backed out changeset d9b4046afbae (bug 1918027)
Backed out changeset d45421faa30c (bug 1918027)
Backed out changeset 363a68600396 (bug 1918027)
Backed out changeset 965a766c81be (bug 1918027)
Backed out changeset 7c609b24857b (bug 1918027)
2024-12-04 22:37:48 +02:00
Greg Stoll ff7cdd9272 Bug 1918027 part 3 - share DataTransfer between clipboard event and calls to HandlePaste() r=edgar,dlp-reviewers,masayuki,handyman
This handles a race condition so if the user copies new data to the clipboard
while Content Analysis is ongoing, the original data will be used in the
paste action.

Differential Revision: https://phabricator.services.mozilla.com/D228719
2024-12-04 19:01:10 +00:00
Tom Schuster e8147f2e0f Bug 1809713 - Use ClipboardType in editor. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D214584
2024-07-29 11:52:33 +00:00
Masayuki Nakano 44aae6e962 Bug 1909577 - Make some nsFocusManager::GetFocusedElement() users use its static version instead r=emilio,credential-management-reviewers,issammani
Now, we have `nsFocusManager::GetFocusedElementStatic()` which returns focused
element if the `nsFocusManager` instance is available.  Therefore, if
`nsFocusManager::GetFocusedElement()` users do not use other methods of
`nsFocusManager`, they can use `nsFocusManager::GetFocusedElementStatic()` and
make themselves simpler.

Note that some callers return early if `nsFocusManager` is not available, but
they do not return error and `nsFocusManager` instance is available in most
time of the life time of the process.  Therefore, we can simply stop using the
early return.

Differential Revision: https://phabricator.services.mozilla.com/D217527
2024-07-25 00:33:58 +00:00
Gregory Pappas 48834b756d Bug 1881845 - Remove nsContentCID.h r=smaug,media-playback-reviewers,karlt
All of these components have been converted to static registration, making this
file unneeded.

Differential Revision: https://phabricator.services.mozilla.com/D202633
2024-03-04 23:41:05 +00:00
Greg Stoll b2839267e7 Bug 1871135 - Add content analysis support to clipboard operations r=edgar,nika,masayuki,devtools-reviewers
When content analysis is on, pastes will be checked by the CA
agent while tab input is blocked. The synchronous nsIClipboard.getData()
method must block until the analysis result is received, so this
requires doing a SpinEventLoopUntil.

Differential Revision: https://phabricator.services.mozilla.com/D196997
2024-02-13 11:26:48 +00:00
Cristian Tuns 35a4843e35 Backed out changeset 9dfe3fe4ccc5 (bug 1871135) for causing mochitest failures in nsClipboardProxy.cpp CLOSED TREE 2024-02-12 12:04:41 -05:00
Greg Stoll 215d43e99f Bug 1871135 - Add content analysis support to clipboard operations r=edgar,nika,masayuki,devtools-reviewers
When content analysis is on, pastes will be checked by the CA
agent while tab input is blocked. The synchronous nsIClipboard.getData()
method must block until the analysis result is received, so this
requires doing a SpinEventLoopUntil.

Differential Revision: https://phabricator.services.mozilla.com/D196997
2024-02-12 16:05:06 +00:00
Cristian Tuns 907b8f6b06 Backed out changeset 3caca1d10dcc (bug 1871135) for causing build bustages in nsBaseClipboard.cpp CLOSED TREE 2024-02-12 09:59:09 -05:00
Greg Stoll 1d234e67c7 Bug 1871135 - Add content analysis support to clipboard operations r=edgar,nika,masayuki,devtools-reviewers
When content analysis is on, pastes will be checked by the CA
agent while tab input is blocked. The synchronous nsIClipboard.getData()
method must block until the analysis result is received, so this
requires doing a SpinEventLoopUntil.

Differential Revision: https://phabricator.services.mozilla.com/D196997
2024-02-12 00:49:39 +00:00
Jan Varga 272327b326 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 66135593c4 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
Masayuki Nakano f6b9dc1548 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
Masayuki Nakano f84a751fe1 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
Masayuki Nakano c5d67850e0 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 231cfd3262 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
Stanca Serban 9b398a301a 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 6915af9ae7 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 7417130c12 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
Neil Deakin 21426e24f4 Bug 1776879, replace text/unicode for clipboard and drag and drop and use text/plain directly, r=edgar,mak,stransky,geckoview-reviewers,extension-reviewers,zombie,m_kato
Most usage is a straight replacement but gtk needs extra changes as it transfers plain text in UTF8 natively and needs to be converted into UTF16, and Windows uses single-byte characters for RTF and CF_HTML formats so we preserve this.

Differential Revision: https://phabricator.services.mozilla.com/D158587
2023-02-01 23:30:55 +00:00
Masayuki Nakano e1670faf93 Bug 1793694 - part 5: Move EditorUtils::MaskString to TextEditor r=m_kato
It's the only method which is used outside of the editor module.  Therefore,
we can stop exposing `EditorUtils.h` later.

Depends on D158634

Differential Revision: https://phabricator.services.mozilla.com/D158635
2022-10-12 02:44:19 +00:00
Masayuki Nakano 767307c38d Bug 1791501 - Use EditActionResult as ok type of mozilla::Result r=m_kato
Any callers do not refer "ignored", "handled" and "cancel" state without
checking whether the method returns error or not.  Therefore, error state
can be (and should be) managed by `mozilla::Result`'s error state.

Perhaps, it should store a caret position later because deletion handlers
of `HTMLEditor` use it, but update `Selection` immediately.

Differential Revision: https://phabricator.services.mozilla.com/D158080
2022-09-28 07:21:37 +00:00
Masayuki Nakano 4d67291c6c Bug 1789967 - part 2: Make TextEditor and HTMLEditor implement EditorBase::CollapseSelectionToEndOfLastLeafNode by themselves r=m_kato
It does different thing for `TextEditor` and `HTMLEditor`, and used almost
internally.  Therefore, it should be implemented in the sub classes and
we should name them better.

Differential Revision: https://phabricator.services.mozilla.com/D157407
2022-09-22 06:17:36 +00:00
Masayuki Nakano 843416fac4 Bug 1789967 - part 1: Make TextEditor and HTMLEditor implement EditorBase::InitEditorContentAndSelection by themselves r=m_kato
The method is enough simple, and uses bad cast from point of view of OOP.
Therefore, this patch make the sub classes implement the method only for each.

Differential Revision: https://phabricator.services.mozilla.com/D157406
2022-09-22 06:06:54 +00:00
Iulian Moraru e135bedf74 Backed out changeset 555d2ca16477 (bug 1789967) as per dev request. CLOSED TREE 2022-09-21 06:48:30 +03:00