Commit Graph
131 Commits
Author SHA1 Message Date
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
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
Masayuki Nakano b6b3a5c82e 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 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
Masayuki Nakano 53ac14cc2a 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 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 6b1989c012 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 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
Masayuki Nakano 1c06c1043b 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
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 b2046e1fd7 Bug 1793694 - part 6: Stop exposting EditorUtils.h r=m_kato
Depends on D158635

Differential Revision: https://phabricator.services.mozilla.com/D158636
2022-10-12 02:44:20 +00:00
Masayuki Nakano d2d1d167aa Bug 1793381 - part 1: Make HTMLEditor::InsertObject and related methods use enum class instead of bool r=m_kato
They use `bool` arguments a lot.  Therefore, some call-sites are hard to read.
They should be replaced with `enum class`es.  Note that this patch does not
make the raw value of new `enum class`es to `bool` unless they are used in the
heap.

Differential Revision: https://phabricator.services.mozilla.com/D158481
2022-10-09 01:27:34 +00:00
Masayuki Nakano 22aa786ab3 Bug 1753508 - Add logger of selection batch r=smaug
This was required for debugging the bug.

Differential Revision: https://phabricator.services.mozilla.com/D139350
2022-03-11 02:24:24 +00:00
Norisz Fay 1b38335ea5 Backed out changeset 00f6bd7aa727 (bug 1755481) for causing multiple clipboard related failures CLOSED TREE 2022-02-16 12:14:58 +02:00
Mirko Brodesser af3e92b960 Bug 1755481: rename nsIClipboard::getData to nsIClipboard::getSomeData and document it. r=mccr8
Before, it was confusing. One could have assumed that the method gets
the data for all flavors.

Differential Revision: https://phabricator.services.mozilla.com/D138776
2022-02-16 09:03:00 +00:00
Neil Deakin a86bbee056 Bug 1727176, use the principal to determine the source of the drag, r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D123522
2021-08-31 00:58:35 +00:00
Masayuki Nakano c3500e3f66 Bug 1723125 - Ignore normal selection when updating composition string r=m_kato
Web apps can modify normal selection even during IME composition and no
browsers stop composition by it.  However, our editor tries to delete
non-collapsed selected range before updating composition.  Therefore,
we need additional state at handling inserting text whether selection
should be deleted or ignored.

Depends on D121371

Differential Revision: https://phabricator.services.mozilla.com/D121372
2021-08-02 08:23:50 +00:00
Masayuki Nakano dd9b44e378 Bug 1714918 - Sort out editor class accessors of nsIEditor r=m_kato
For consistency with the similar internal DOM API, `As*()` should just cast
the type without checking editor type.  Instead, `GetAs*()` should do it.

Differential Revision: https://phabricator.services.mozilla.com/D117381
2021-06-11 03:01:08 +00:00
Masayuki Nakano 6eca46c4a2 Bug 1540037 - part 45: Move TextEditor::OnDrop() into EditorBase r=m_kato
Depends on D116802

Differential Revision: https://phabricator.services.mozilla.com/D116803
2021-06-07 11:38:18 +00:00
Masayuki Nakano a380a7b318 Bug 1540037 - part 44: Move the inserting dropped items part of TextEditor::OnDrop() to the new virtual method r=m_kato
This patch makes the previously created handler method to virtual (derived from
`EditorBase`), and makes `TextEditor` override it.

Depends on D116801

Differential Revision: https://phabricator.services.mozilla.com/D116802
2021-06-07 06:20:25 +00:00
Masayuki Nakano 055949a338 Bug 1540037 - part 43: Move inserting dropped items part on HTMLEditor to HTMLEditor r=m_kato
`TextEditor::OnDrop()` handles both cases, in `TextEditor` and in `HTMLEditor`
because the common part is too complicated to duplicate.  However, most
different part is inserting the dropped items part.  So, let's make them
into a virtual method.

In this patch, creating a method only in `HTMLEditor` and moves the part
into it.

Depends on D116569

Differential Revision: https://phabricator.services.mozilla.com/D116801
2021-06-07 04:18:08 +00:00
Masayuki Nakano fd1688b098 Bug 1540037 - part 42: Move TextEditor::DeleteSelectionByDragAsAction() into EditorBase r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D116569
2021-06-04 05:23:05 +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 20169b9a45 Bug 1540037 - part 40: Move TextEditor::PrepareTransferable() into EditorUtils r=m_kato
It just creates an `nsITransferable` instance and add 2 flavors for storing
plain text.  Therefore, it can be in `EditorUtils` instead.

Depends on D116566

Differential Revision: https://phabricator.services.mozilla.com/D116567
2021-06-04 04:32:28 +00:00
Masayuki Nakano 633107ea8d Bug 1540037 - part 39: Move TextEditor::IsSafeToInsertData() into EditorBase r=m_kato
Depends on D116565

Differential Revision: https://phabricator.services.mozilla.com/D116566
2021-06-04 03:28:24 +00:00
Masayuki Nakano 3e9a71a9ca Bug 1540037 - part 38: Move TextEditor::InsertTextAt() into EditorBase r=m_kato
Depends on D116564

Differential Revision: https://phabricator.services.mozilla.com/D116565
2021-06-03 21:00:07 +00:00
Masayuki Nakano b6580746d8 Bug 1540037 - part 37: Move TextEditor::PrepareToInsertContent() into EditorBase r=m_kato
Depends on D116541

Differential Revision: https://phabricator.services.mozilla.com/D116564
2021-06-03 19:48:47 +00:00
Masayuki Nakano 04ff975886 Bug 1703144 - Get rid of MOZ_KnownLive for EditorBase::SelectionRefPtr() r=m_kato
The lifetime of it is guaranteed by `AutoEditActionDataSetter` which grabs
`Selection` until it's destroyed, and it's a stack only class and created
at first step of all public method calls.  Therefore, we can mark it as
`MOZ_KNOWN_LIVE` and we can change it returning reference of `Selection`
instead of reference of `RefPtr<Selection>`.

Differential Revision: https://phabricator.services.mozilla.com/D110896
2021-04-08 01:31:54 +00:00
Kagami Sascha Rosylight c74bf29617 Bug 1680167 - Part 6: Use RefPtr for nsFocusManager in editor r=masayuki
Depends on D98628

Differential Revision: https://phabricator.services.mozilla.com/D98629
2020-12-03 21:35:20 +00:00
Masayuki Nakano 0eba024e2d Bug 1613521 - Make NeedsToDispatchBeforeInputEvent() return false if the edit action requires a clipboard event and it's not dispatched yet r=m_kato
The reason of hitting the assertion is, a clipboard event listener nests
another edit action, initializing the editor, runs, and tries to create an
anonymous `<br>` element with transaction, but it checks whether `beforeinput`
event has already been dispatched or not with the parent edit action data.

For fixing it, this patch adds a flag to edit action data to indicate whether
a clipboard event has already been dispatched or not.  If it's already been
dispatched, it's **okay** to modify the DOM tree.  Ideally, we should put off
modifying the DOM tree after dispatching `beforeinput` event, but this case
does not notify web apps anything so that this patch should be fine.

Although this patch adds a crash test which is attached by the reporter,
it's not reproducible with current editor code because we stopped modifying
native anonymous nodes with transaction, but it depends on the behavior.
Still this assertion hits in `test_clipboard_noeditor.html` intermittently,
but I don't have idea how to reproduce this permanently.  Therefore, this
patch does not contain a test to check to regression actually.

Differential Revision: https://phabricator.services.mozilla.com/D95115
2020-10-30 07:21:40 +00:00
Kagami Sascha Rosylight 7bbd547c89 Bug 1615296 - Part 2: Fix MOZ_CAN_RUN_SCRIPT warnings in editor module r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D93599
2020-10-15 19:12:44 +00:00
Mirko Brodesser 9343d1f42f Bug 1649121: part 90) Declare some editor methods const or static. r=m_kato
Simplifies reasoning about them.

Differential Revision: https://phabricator.services.mozilla.com/D90688
2020-09-22 16:03:55 +00:00
Emilio Cobos Álvarez 2e179aba86 Bug 1664411 - Factor out a condition to unconditionally enable clipboard events in some documents. r=masayuki
This patch shouldn't introduce any behavior change.

Differential Revision: https://phabricator.services.mozilla.com/D89834
2020-09-11 11:08:35 +00:00
Kagami Sascha Rosylight a20339adb5 Bug 1623413 - Part 2: Rename Collapse() to CollapseInLimiter() r=masayuki
Depends on D88702

Differential Revision: https://phabricator.services.mozilla.com/D88920
2020-09-03 03:45:26 +00:00
Mihai Alexandru Michis d775b8dd6d Backed out 3 changesets (bug 1623413) for causing failures in Selection_collapse.html
CLOSED TREE

Backed out changeset d3d67293f115 (bug 1623413)
Backed out changeset 75ed1b8a5c67 (bug 1623413)
Backed out changeset 0eef32d6a454 (bug 1623413)
2020-09-03 05:37:49 +03:00
Kagami Sascha Rosylight 3eab64fd31 Bug 1623413 - Part 2: Rename Collapse() to CollapseInLimiter() r=masayuki
Depends on D88702

Differential Revision: https://phabricator.services.mozilla.com/D88920
2020-09-02 23:42:27 +00:00
Masayuki Nakano c9e542c37f Bug 1659276 - Make AutoPlaceholderBatch choose whether do or do not ScrollSelectionIntoView r=m_kato
The root cause of this bug is a bug of async `ScrollSelectionIntoView` that
is what it won't be canceled even if web app changes scroll position with
any API.  Fixing it is really risky and this bug affects an existing website.
Therefore, this patch makes the constructors of `AutoPlaceholderBatch` take
whether do or do not `ScrollSelectionIntoView` when it's destructed.  And
makes `HTMLEditor::SetInlinePropertyAsAction()` not request
`ScrollSelectionIntoView` for taking back the traditional behavior.

Note that this patch does not make it an optional argument because it's hard to
guess that it'll run `ScrollSelectionIntoView` automatically.

Differential Revision: https://phabricator.services.mozilla.com/D87819
2020-08-24 06:39:50 +00:00
Simon Giesecke a69d79b6db Bug 1648010 - Replace uses of NS_LITERAL_STRING/NS_LITERAL_CSTRING macros by _ns literals. r=geckoview-reviewers,jgilbert,agi,hsivonen,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80860
2020-07-01 08:29:29 +00:00
Kagami Sascha Rosylight 3d73cee9fb Bug 1632425 - Part 1: Add EditorUtils::IsPointInSelection() r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D77812
2020-06-03 03:08:05 +00:00
Mirko Brodesser aace44041e Bug 1634663: part 2) Declare callers of GetRangeAt around EditorBase const. r=masayuki
Depends on D73444

Differential Revision: https://phabricator.services.mozilla.com/D73445
2020-05-02 23:44:46 +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 a0fa22d622 Bug 1632724 - part 4: Rename HTMLEditor::DeleteSelectionWithTransaction() r=m_kato
`HTMLEditor::DeleteSelectionWithTransaction()` calls `EditorBase`'s overridden
method and handles `nsIEditor::eStrip` case.  Therefore, we can rename it with
stop calling the `EditorBase::DeleteSelectionWithTransaction()`, and make it
called by `EditorBase::DeleteSelectionWithTransaction()` only when it's
necessary.

Additionally, we can make all internal method callers of editor classes always
set `nsIEditor::eNoStrip` if the instance is `TextEditor`.  This must make
the code easier to understand.

Depends on D72292

Differential Revision: https://phabricator.services.mozilla.com/D72293
2020-04-27 00:36:10 +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 ff544c4af8 Bug 1620504 - part 21: Clean up warnings in TextEditor r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D66852
2020-03-18 01:14:42 +00:00