Commit Graph
104 Commits
Author SHA1 Message Date
Josh Aas 19613b5043 Bug 1425483 - Fix cmd-left, cmd-right, cmd-shift-left, cmd-shift-right in RTL text fields on macOS. r=spohl,masayuki
Differential Revision: https://phabricator.services.mozilla.com/D296521
2026-04-29 21:13:31 +00:00
Josh Aas 6d07b772d4 Bug 103422 - Add support for paragraph movement commands on macOS, including their selection variants. r=bradwerth,masayuki
Differential Revision: https://phabricator.services.mozilla.com/D284945
2026-04-21 13:09:47 +00:00
rperta c39bffe05c Revert "Bug 103422 - Add support for paragraph movement commands on macOS, including their selection variants. r=bradwerth,masayuki" for causing chrome failures at test_native_key_bindings_mac.html
This reverts commit af9bcc8b73.
2026-04-12 19:57:14 +00:00
Josh Aas af9bcc8b73 Bug 103422 - Add support for paragraph movement commands on macOS, including their selection variants. r=bradwerth,masayuki
Differential Revision: https://phabricator.services.mozilla.com/D284945
2026-04-12 03:46:37 +00:00
rperta 00f45b10a1 Revert "Bug 103422 - Add support for paragraph movement commands on macOS, including their selection variants. r=bradwerth,masayuki" for causing chrome failures at test_native_key_bindings_mac.html
This reverts commit a0be1de7fe.
2026-04-01 18:32:15 +00:00
Josh Aas a0be1de7fe Bug 103422 - Add support for paragraph movement commands on macOS, including their selection variants. r=bradwerth,masayuki
Differential Revision: https://phabricator.services.mozilla.com/D284945
2026-04-01 16:27:08 +00:00
Silaghi ad6d40e1c0 Revert "Bug 103422 - Add support for paragraph movement commands on macOS, including their selection variants. r=bradwerth,masayuki" for causing mochitest failures at browser_reservedkey.js
This reverts commit f786295c08.
2026-03-27 10:17:53 +00:00
Josh Aas f786295c08 Bug 103422 - Add support for paragraph movement commands on macOS, including their selection variants. r=bradwerth,masayuki
Differential Revision: https://phabricator.services.mozilla.com/D284945
2026-03-27 02:58:13 +00:00
serge-sans-paille 115d971353 Bug 2025273 - Activate modernize-loop-convert clang-tidy check r=media-playback-reviewers,webrtc-reviewers,profiler-reviewers,firefox-svg-reviewers,canaltinova,longsonr,mjf,alwu
This is mostly the result of running ./mach static-analysis check --fix
with the new linter activated, with the following caveats:

- use std::fill when it makes sense
- use appropriate names for the loop target variable
- fix constness
- use array default initialization instead of an explicit loop when it
  makes sense

Differential Revision: https://phabricator.services.mozilla.com/D289172
2026-03-26 12:27:13 +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
Edgar Chen dc97c63653 Bug 1998195 - Expose execCommand("paste") with a pop-up menu to web content; r=smaug,masayuki
This patch exposes the execCommand("paste") to web content with the same security
model as async Clipboard API. That is, a paste contextmenu will be shown to request
user confirmation if the clipboard data originated from cross-origin content.

Differential Revision: https://phabricator.services.mozilla.com/D274490
2025-12-13 00:10:46 +00:00
pstanciu bd4fd98495 Revert "Bug 1998195 - Expose execCommand("paste") with a pop-up menu to web content; r=smaug,masayuki" for causing build bustage @nsGlobalWindowCommands.cpp
This reverts commit 57912b1d82.
2025-12-12 11:39:05 +00:00
Edgar Chen 57912b1d82 Bug 1998195 - Expose execCommand("paste") with a pop-up menu to web content; r=smaug,masayuki
This patch exposes the execCommand("paste") to web content with the same security
model as async Clipboard API. That is, a paste contextmenu will be shown to request
user confirmation if the clipboard data originated from cross-origin content.

Differential Revision: https://phabricator.services.mozilla.com/D274490
2025-12-12 10:16:07 +00:00
serge-sans-paille 1667ec582b Bug 1995723 - Remove unused inclusion of mozilla/ArrayUtils.h r=necko-reviewers,application-update-reviewers,media-playback-reviewers,profiler-reviewers,win-reviewers,firefox-svg-reviewers,layout-reviewers,gstoll,canaltinova,bytesized,alwu,dholbert
Differential Revision: https://phabricator.services.mozilla.com/D269573
2025-10-23 07:30:37 +00:00
Emilio Cobos Álvarez f4bc770eef Bug 1987024 - De-comify a bit command handling. r=masayuki,dom-core
The nsIControllerCommandTable already assumes it's an
nsControllerCommandTable as it has infallible casts. Similarly,
nsIControllerCommand doesn't need to be scriptable.

This is in preparation to expose a global list of always-enabled
commands for the IPC code to use and avoid sending back and forth.

Differential Revision: https://phabricator.services.mozilla.com/D263807
2025-09-05 10:30:55 +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
Stanca Serban 487746bf1b Backed out 2 changesets (bug 1862256) for causing mochitests failures in test_native_key_bindings_mac.html. CLOSED TREE
Backed out changeset b23e836dc19b (bug 1862256)
Backed out changeset ccb29705b1d5 (bug 1862256)
2024-11-07 14:31:58 +02:00
Laura Hausmann a52d3dad74 Bug 1862256 - Fix textarea home/end behavior r=saschanaz
Differential Revision: https://phabricator.services.mozilla.com/D192724
2024-11-07 10:30:46 +00:00
serge-sans-paille 262f78c07f Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.

Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-28 08:21:19 +00:00
Alexandru Marc a5eb905bf4 Backed out changeset d92f391b3b0c (bug 1922838) for backing out bug 1915351 2024-10-25 16:42:33 +03:00
serge-sans-paille 07101ac24d Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.

Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-24 09:06:01 +00:00
Alexandru Marc 004e704b22 Backed out changeset 448597bce69d (bug 1922838) for causing build bustages. CLOSED TREE 2024-10-24 11:37:49 +03:00
serge-sans-paille 2c916d4973 Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang
Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.

Differential Revision: https://phabricator.services.mozilla.com/D224611
2024-10-24 07:38:30 +00:00
John Bieling f827cbcb51 Bug 1883367 - Disable editor commands for read-only editors. r=masayuki
The purpose of this patch is to prevent users to make changes to
read-only editors.

This patch forces `IsCommandEnabled()` to return false for read-only
editors for "standard" editor commands that could have an associated
icon or menu entry and are therefore user-accessible.

This patch does not modify/test any paste commands or any of the
advanced internal editor commands.

Differential Revision: https://phabricator.services.mozilla.com/D203754
2024-03-08 17:55:57 +00:00
Cristian Tuns 8578673fe1 Backed out changeset dd6b961d3b69 (bug 1883367) for causing mochitest failures in test_command_state_when_readonly_in_chrome.html CLOSED TREE 2024-03-08 05:55:01 -05:00
John Bieling 10cdbd275d Bug 1883367 - Disable editor commands for read-only editors. r=masayuki
The purpose of this patch is to prevent users to make changes to
read-only editors.

This patch forces `IsCommandEnabled()` to return false for read-only
editors for "standard" editor commands that could have an associated
icon or menu entry and are therefore user-accessible.

Advanced internal editor commands are not touched.

Differential Revision: https://phabricator.services.mozilla.com/D203754
2024-03-08 10:24:21 +00:00
Masayuki Nakano e43678f4c4 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 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 0f9da65e23 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 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
Masayuki Nakano 0b6a0a1e43 Bug 1713756 - Make editor command classes treat EditorBase instead of TextEditor r=m_kato
`TextEditor` will be not a parent class of `HTMLEditor`.  Therefore, editor
command classes should use `EditorBase` class instead.

Depends on D117116

Differential Revision: https://phabricator.services.mozilla.com/D117117
2021-06-09 07:17:52 +00:00
Masayuki Nakano b5172b32d8 Bug 1540037 - part 41: Split TextEditor::PasteAsAction() r=m_kato
It should be a virtual method derived from `EditorBase`, and `TextEditor`
and `HTMLEditor` should override it.  Then, `nsIEditor::Paste()` requires
referring vtable again if we keep implementing it only in `EditorBase`.
Therefore, this patch avoid it with implementing it in both `TextEditor`
and `HTMLEditor`.

Depends on D116567

Differential Revision: https://phabricator.services.mozilla.com/D116568
2021-06-04 05:01:39 +00:00
Masayuki Nakano c26d895d1e Bug 1540037 - part 28: Add pure virtual methods to EditorBase, which are originated from TextEditor r=m_kato
`TextEditor` declares some virtual methods newly.  However, for moving some
methods from `TextEditor` to `EditorBase`, they should be accessible from
`EditorBase`.  Therefore, this patch adds declarations of pure virtual
methods of them to `EditorBase`.

Differential Revision: https://phabricator.services.mozilla.com/D115796
2021-05-26 02:00:45 +00:00
Masayuki Nakano 24a58695c3 Bug 1540037 - part 25: Move TextEditor::CutAsAction() to EditorBase r=m_kato
It's a common method to cut selection.  Therefore, it should be in `EditorBase`.

Differential Revision: https://phabricator.services.mozilla.com/D115793
2021-05-26 00:25:30 +00:00
Masayuki Nakano 62758252a3 Bug 1540037 - part 20: Move UndoAsAction() and RedoAsAction() from TextEditor to EditorBase r=m_kato
They just work with a transaction manager and transactions, and they are used
by both `TextEditor` and `HTMLEditor`.  Therefore, they should be in
`EditorBase` for making `HTMLEditor` stop inheriting `TextEditor` in the
future.

Depends on D115787

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

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

Differential Revision: https://phabricator.services.mozilla.com/D108572
2021-03-23 19:29:23 +00:00
Simon Giesecke ab6f0a7137 Bug 1650145 - Replace all value uses of Empty[C]String by 0-length _ns literals. r=froydnj,geckoview-reviewers,agi
Differential Revision: https://phabricator.services.mozilla.com/D82325
2020-09-23 15:17:15 +00:00
Botond Ballo 96547d35fb Bug 1633014 - Fix non-unified build errors in editor/. r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D72470
2020-04-27 03:36:57 +00:00
Masayuki Nakano 6956b76bb0 Bug 1632724 - part 1: Move common methods for handling delete selection to EditorBase r=m_kato
`DeleteSelection*()` are members of `TextEditor`, but they are also used by
`HTMLEditor`.  Therefore, they and pref cache members for them should be
in `EditorBase` too.

Depends on D71911

Differential Revision: https://phabricator.services.mozilla.com/D72290
2020-04-24 14:55:09 +00:00
Masayuki Nakano caa91aff02 Bug 1620504 - part 11: Clean up warnings in editor command classes r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D65877
2020-03-10 04:34:15 +00:00
Masayuki Nakano c78e748f7c Bug 1540029 - part 2: Get rid of TextEditRules::DocumentIsEmpty() and HTMLEditRules::DocumentIsEmpty() r=m_kato
`TextEditRules::DocumentIsEmpty()` is a wrapper of `TextEditor::IsEmpty()` so
that we can get rid of it simply.

`HTMLEditRules::DocumentIsEmpty()` needs to change.  It's oddly checks only
`EditorBase::mPaddingBRElementForEmptyEditor` is `nullptr` or not.  However,
the editor may be completely empty.  And the result may be different from
`TextEditor::IsEmpty()` which is not overridden by `HTMLEditor`.  For partially
solving this issue, this patch makes `HTMLEditor` overrides `IsEmpty()` and
optimizes `TextEditor::IsEmpty()`.

With this change, the caller of `HTMLEditRules::DocumentIsEmpty()` may behave
differently in the only caller, `HTMLEditor::SelectEntireDocument()`.  And
unfortunately, its root called from `SelectAllCommand::DoCommand()`.  However,
it does just collapse `Selection` into the root element (`<body>` or
`Document.documentElement`) if it returns `true`.  Therefore, this change
must be safe since anyway `SelectionRefPtr()->SelectAllChildren()` with
the root element is exactly same as `SelectionRefPtr()->Collapse()` with
the empty root element if it's truly empty.

Differential Revision: https://phabricator.services.mozilla.com/D45784
2019-09-17 06:58:06 +00:00
Masayuki Nakano 1b80622ecb Bug 1574852 - part 52: Make HTMLEditRules::WillInsertParagraph() merged with HTMLEditor::InsertParagraphSeparatorAsSubAction() r=m_kato
Meaningful job of `HTMLEditor::InsertParagraphSeparatorAsSubAction()` is only
calling `HTMLEditRules::WillInsertParagraph()` via
`HTMLEditRules::WillDoAction()`.  Therefore, we can move all jobs in them
into `HTMLEditRules::WillInsertParagraph()` and rename it to
`HTMLEditor::InsertParagraphSeparatorAsSubAction()`.

Differential Revision: https://phabricator.services.mozilla.com/D44190
2019-09-03 03:59:11 +00:00
Masayuki Nakano 824e4af1a0 Bug 1560032 - part 2: Make cut/copy in password field available r=m_kato,smaug
First, we need to make `nsCopySupport::FireClipboardEvent()` keep handling
`eCopy` and `eCut` event even in password field, only if `TextEditor` allows
them.

Then, we need to make `nsPlainTextSerializer::AppendText()` not expose
masked password for making users safer.  Although `TextEditor` does not allow
`eCopy` nor `eCut` when selection is not in unmasked range.  Fortunately,
retrieving masked and unmasked password from `nsTextFragment` has already
been implemented in `ContentEventHandler.cpp`.  This patch moves it into
`EditorUtils` and makes `ContentEventHandler.cpp` and `nsPlaintextSerializer`
share it.

Differential Revision: https://phabricator.services.mozilla.com/D39000
2019-07-29 06:21:42 +00:00
Masayuki Nakano 938ae260ee Bug 1560032 - part 1: Make TextEditor for password allow to copy password when selected range is in unmasked range r=m_kato
It does not make sense to copy masked password with mask characters.
Therefore, we should allow users to copy/cut in password fields only when
selected range is in unmasked range.

Note that for web-compat, copy/cut are always enabled in HTML/XHTML document
in content.  Therefore this patch changes the behavior only in chrome's
password fields.

Additionally, only the test uses `nsIEditor.canDelete()`.  Therefore, this
removes it and make the test use `nsIDocShell.isCommandEnabled()` instead.
Unfortunately, `nsIEditor.canCopy()` and `nsIEditor.canCut()` are used by
BlueGriffon, therefore, we cannot get rid of them for now.

Differential Revision: https://phabricator.services.mozilla.com/D38999
2019-07-29 06:21:14 +00:00
Masayuki Nakano da22b4eaf4 Bug 1529884 - part 6: Through subject principal at Document::ExecCommand() to constructor of EditorBase::AutoEditActionDataSetter r=smaug
`Document::ExecCommand()` knows subject principal.  This patch makes it tell
`EditorCommand::DoCommand()` and `EditorCommand::DoCommandParam()`.  Then,
makes they tell each editor public methods which may cause dispatching
`beforeinput` event once we implement it.  Finally, each editor public
method sets it to the constructor of `EditorBase::AutoEditActionDataSetter`.
This means that when editor tries to dispatch `beforeinput` event, editor
can check whether it's called by JS or not from everywhere.

Differential Revision: https://phabricator.services.mozilla.com/D29635
2019-06-10 10:27:07 +00:00