Commit Graph
189 Commits
Author SHA1 Message Date
Jan-Niklas Jaeschke 0b2d030087 Bug 2030660 - Remove dom.shadowdom.selection_across_boundary.enabled pref. r=masayuki,webidl
Differential Revision: https://phabricator.services.mozilla.com/D293086
2026-04-10 08:02:43 +00:00
Sylvestre Ledru 9eb1a31a98 Bug 2023419 - Remove Emacs/Vim modelines from dom/ r=emilio,media-playback-reviewers,webidl,padenot
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287843
2026-03-16 21:02:32 +00:00
Masayuki Nakano 49e78c50f6 Bug 2012638 - Make nsFrameSelection::RepaintSelection() run UpdateSelectionCacheOnRepaintSelection() in any desktop debug builds r=edgar
The method serializes the selection ranges to update the selection cache
for the OS only on macOS.  So, there are a lot of cases to run
`nsHTMLCopyEncoder` only on macOS because repainting selection occurs
immediately after moving focus.

Therefore, we may see assertion failures around `RangeBoundaryBase` and
`nsHTMLCopyEncoder` itself only of debug builds on macOS.  However,
the macOS machines in trysever are always busy and we need to wait at
least one day and the developers may not run the tests on macOS before
landing their patches due to the slowness.

For solving these issues, this patch makes it run on any debug builds
on any desktop platforms. So, basically, we don't need to run tests on
macOS on tryserver after landing this in the most cases.

Differential Revision: https://phabricator.services.mozilla.com/D280905
2026-01-30 03:23:40 +00:00
Cristina Horotan ceded7b8d7 Revert "Bug 2012638 - Make nsFrameSelection::RepaintSelection() run UpdateSelectionCacheOnRepaintSelection() in any desktop debug builds r=edgar" for causing bc failures on browser_bug1261299.js
This reverts commit 6a059306a5.
2026-01-29 14:33:45 +00:00
Masayuki Nakano 6a059306a5 Bug 2012638 - Make nsFrameSelection::RepaintSelection() run UpdateSelectionCacheOnRepaintSelection() in any desktop debug builds r=edgar
The method serializes the selection ranges to update the selection cache
for the OS only on macOS.  So, there are a lot of cases to run
`nsHTMLCopyEncoder` only on macOS because repainting selection occurs
immediately after moving focus.

Therefore, we may see assertion failures around `RangeBoundaryBase` and
`nsHTMLCopyEncoder` itself only of debug builds on macOS.  However,
the macOS machines in trysever are always busy and we need to wait at
least one day and the developers may not run the tests on macOS before
landing their patches due to the slowness.

For solving these issues, this patch makes it run on any debug builds
on any desktop platforms. So, basically, we don't need to run tests on
macOS on tryserver after landing this in the most cases.

Differential Revision: https://phabricator.services.mozilla.com/D280905
2026-01-29 12:31:57 +00:00
Edgar Chen 70e6d16fa3 Bug 2004603 - Avoid encoding for text/html twice for copying selection; r=hsivonen
The only remaining purpose of the additional encoding is to detect XHTML documents,
but I think we can handle XHTML documents without doing that.

Differential Revision: https://phabricator.services.mozilla.com/D275398
2025-12-10 16:05:08 +00:00
Edgar Chen 2ced0045c3 Bug 2000323 - Get rid of nsIDocumentEncoder::NativeInit(); r=smaug
`nsIDocumentEncoder::NativeInit()` was introduced in bug 574089. It took a
`nsIDocument` directly, whereas `::Init()` took a `nsIDOMDocument` instead.
But now they both take `Document` as an argument. So `NativeInt()` can be
removed and the call sites can use `Init()` instead.

Differential Revision: https://phabricator.services.mozilla.com/D272720
2025-11-15 23:10:55 +00:00
Edgar Chen b587521d00 Bug 1650720 - Part 3: Align link break coversion for clipboard copy with other browsers; r=masayuki
There are two main places that handle line break conversion:
1. https://searchfox.org/firefox-main/rev/0b21972a78f8915f73ce5579eeee2aa8c9c7d67e/dom/serializers/nsPlainTextSerializer.cpp#485-509
   This converts all LF and CR characters to the platform line break or a space,
   depending on whether the serializer is in preformatted mode.
2. https://searchfox.org/firefox-main/rev/0b21972a78f8915f73ce5579eeee2aa8c9c7d67e/dom/serializers/nsPlainTextSerializer.cpp#1628,1641,1658-1701
   This converts also all LF and CR, but this also have special handling for CRLF,
   to the platform line break or a space, depending on whether the serializer is
   in preformatted mode.

Previously, text nodes for selection clipboard copy were handled using method (1),
which could cause an additional line break when a text node contained an LF.

Other browsers don’t convert LF, but only CR, to the platform line break when
copying a selection to the clipboard. They also preserve CRLF on Windows.
(Please see https://bugzilla.mozilla.org/show_bug.cgi?id=1650720#c15 for details)

This patch aligns our behavior with other browsers, whose approach seems more
reasonable.

Now, text nodes for selection clipboard copy are handled using method (2), which
takes CRLF into account during conversion and handles line break conversion
differently when serializing for clipboard copy, while preserving the original
behavior for other cases.

Differential Revision: https://phabricator.services.mozilla.com/D270545
2025-11-10 21:29:58 +00:00
Alexandru Marc 920ab7c173 Revert "Bug 1650720 - Part 4: Add line break tests for copying selection; r=masayuki" for causing mochitest failures @ test_aboutmemory3.xhtml
This reverts commit 62ce647fff.

Revert "Bug 1650720 - Part 3: Align link break coversion for clipboard copy with other browsers; r=masayuki"

This reverts commit 3ced2a72e8.

Revert "Bug 1650720 - Part 2: Simplify nsPlainTextSerializer::ConvertToLinesAndOutput; r=masayuki"

This reverts commit 5e63b05f54.

Revert "Bug 1650720 - Part 1: Add plaintext serializer tests for linebreak; r=masayuki"

This reverts commit 21953f6384.
2025-11-05 01:27:03 +00:00
Edgar Chen 3ced2a72e8 Bug 1650720 - Part 3: Align link break coversion for clipboard copy with other browsers; r=masayuki
There are two main places that handle line break conversion:
1. https://searchfox.org/firefox-main/rev/0b21972a78f8915f73ce5579eeee2aa8c9c7d67e/dom/serializers/nsPlainTextSerializer.cpp#485-509
   This converts all LF and CR characters to the platform line break or a space,
   depending on whether the serializer is in preformatted mode.
2. https://searchfox.org/firefox-main/rev/0b21972a78f8915f73ce5579eeee2aa8c9c7d67e/dom/serializers/nsPlainTextSerializer.cpp#1628,1641,1658-1701
   This converts also all LF and CR, but this also have special handling for CRLF,
   to the platform line break or a space, depending on whether the serializer is
   in preformatted mode.

Previously, text nodes for selection clipboard copy were handled using method (1),
which could cause an additional line break when a text node contained an LF.

Other browsers don’t convert LF, but only CR, to the platform line break when
copying a selection to the clipboard. They also preserve CRLF on Windows.
(Please see https://bugzilla.mozilla.org/show_bug.cgi?id=1650720#c15 for details)

This patch aligns our behavior with other browsers, whose approach seems more
reasonable.

Now, text nodes for selection clipboard copy are handled using method (2), which
takes CRLF into account during conversion and handles line break conversion
differently when serializing for clipboard copy, while preserving the original
behavior for other cases.

Differential Revision: https://phabricator.services.mozilla.com/D270545
2025-11-04 21:40:21 +00:00
Emilio Cobos Álvarez 791917d8af Bug 1976665 - Sort headers in dom/. r=dom-core,media-playback-reviewers,webrtc-reviewers,dom-storage-reviewers,padenot,janv,smaug,jesup,jib
Most changes are automated. Relevant bit is dom/.clang-format. I had to
manually disable clang-format in a few places where importing external
files and so on that aren't self-contained, and fix a couple includes /
forward declarations.

Differential Revision: https://phabricator.services.mozilla.com/D256800
2025-08-05 11:47:34 +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
Jan-Niklas Jaeschke 32b0a740b7 Bug 1933738, part 2 - Change all calls to nsFrameSelection::GetSelection(eNormal) to nsFrameSelection::NormalSelection(). r=emilio
`nsFrameSelection::NormalSelection()` returns a `Selection&`, which eliminates the need for nullptr check at call sites.
This simplifies the code in some places and removes unnecessarily indented blocks.

Differential Revision: https://phabricator.services.mozilla.com/D230583
2024-11-29 07:31:58 +00:00
Sean Feng c6e6d73a26 Bug 1900426 - Implement DnD for shadow-crossing selection r=jjaschke,smaug,dom-core
This patches allows
  1. when the selection is shadow-crossing, dragging it will have the
  correct the drag image correctly displayed. It's hard to test, so
  no tests for this.

  2. The selection can now be serialized and dropped.
  `test_drag_drop_shadow_crossing_selection.html` is the test for
  this.

Differential Revision: https://phabricator.services.mozilla.com/D217318
2024-09-03 15:42:58 +00:00
Noemi Erli 9f28e0b5e5 Backed out changeset 5c6272143175 (bug 1900426) for causing bug 1915027, bug 1915620, bug 1915816 2024-08-30 16:31:30 +03:00
Sean Feng 7bd0868c67 Bug 1900426 - Implement DnD for shadow-crossing selection r=jjaschke,smaug,dom-core
This patches allows
  1. when the selection is shadow-crossing, dragging it will have the
  correct the drag image correctly displayed. It's hard to test, so
  no tests for this.

  2. The selection can now be serialized and dropped.
  `test_drag_drop_shadow_crossing_selection.html` is the test for
  this.

Differential Revision: https://phabricator.services.mozilla.com/D217318
2024-08-28 15:03:17 +00:00
Stanca Serban 781a44c0d1 Backed out changeset d77e541eb497 (bug 1900426) for causing mochitests failures in test_drag_drop_shadow_crossing_selection.html. CLOSED TREE 2024-08-27 04:23:16 +03:00
Sean Feng 882b3545b6 Bug 1900426 - Implement DnD for shadow-crossing selection r=jjaschke,smaug,dom-core
This patches allows
  1. when the selection is shadow-crossing, dragging it will have the
  correct the drag image correctly displayed. It's hard to test, so
  no tests for this.

  2. The selection can now be serialized and dropped.
  `test_drag_drop_shadow_crossing_selection.html` is the test for
  this.

Differential Revision: https://phabricator.services.mozilla.com/D217318
2024-08-26 19:09:03 +00:00
Tamas Szentpeteri e490399751 Backed out changeset 32fba1d43e0a (bug 1900426) for causing mochitest failures on test_synthmousemove_after_dnd.html. CLOSED TREE 2024-08-26 18:12:22 +03:00
Sean Feng 4101262ed0 Bug 1900426 - Implement DnD for shadow-crossing selection r=jjaschke,smaug,dom-core
This patches allows
  1. when the selection is shadow-crossing, dragging it will have the
  correct the drag image correctly displayed. It's hard to test, so
  no tests for this.

  2. The selection can now be serialized and dropped.
  `test_drag_drop_shadow_crossing_selection.html` is the test for
  this.

Differential Revision: https://phabricator.services.mozilla.com/D217318
2024-08-26 13:51:31 +00:00
Tom Schuster c051081043 Bug 1809713 - Make DataTransfer use Maybe<ClipboardType>. r=edgar
Differential Revision: https://phabricator.services.mozilla.com/D214585
2024-07-29 11:52:34 +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
Sean Feng 8b5fa3ca09 Bug 1881095 - Add the copy paste support for ShadowDOM selection r=jjaschke,smaug,dom-core
This patch allows nsDocumentEncoder to serialize contents
in shadow trees when those contents are selected.

Differential Revision: https://phabricator.services.mozilla.com/D211577
2024-06-10 18:59:50 +00:00
Edgar Chen 546880ae4d Bug 1867636 - Rename nsITransferable::requestingPrincipal; r=nika
Differential Revision: https://phabricator.services.mozilla.com/D207272
2024-04-18 10:06:07 +00:00
Greg Stoll 3625ba8618 Bug 1869868 part 2 - do not consult DLP when copy/pasting items in the same tab r=edgar,dlp-reviewers,credential-management-reviewers,handyman,sgalich
Differential Revision: https://phabricator.services.mozilla.com/D205744
2024-04-15 12:10:46 +00:00
Edgar Chen 2333e10d4e Bug 1858627 - Suppress the paste contextmenu in paste event handler; r=nika
Differential Revision: https://phabricator.services.mozilla.com/D191131
2024-03-13 20:44:07 +00:00
Cristian Tuns 4e35ce0b65 Backed out 4 changesets (bug 1858627) for causing build bustages with "-p style --lib" CLOSED TREE
Backed out changeset 7f3f50c77406 (bug 1858627)
Backed out changeset 96327aab8126 (bug 1858627)
Backed out changeset 0655d0feb163 (bug 1858627)
Backed out changeset d3a1b3ac7611 (bug 1858627)
2024-03-13 05:23:51 -04:00
Edgar Chen 024516df40 Bug 1858627 - Suppress the paste contextmenu in paste event handler; r=nika
Depends on D202351

Differential Revision: https://phabricator.services.mozilla.com/D191131
2024-03-13 01:07:18 +00:00
Norisz Fay 6b73c14ada Backed out 4 changesets (bug 1858627) for causing build bustage CLOSED TREE
Backed out changeset eaf5e6b7ddd4 (bug 1858627)
Backed out changeset 9efc1874ac78 (bug 1858627)
Backed out changeset 8f4ca2ab875b (bug 1858627)
Backed out changeset 02f94f12c3ef (bug 1858627)
2024-03-13 01:47:31 +02:00
Edgar Chen 6ffeee967b Bug 1858627 - Suppress the paste contextmenu in paste event handler; r=nika
Depends on D202351

Differential Revision: https://phabricator.services.mozilla.com/D191131
2024-03-12 21:51:54 +00:00
Natalia Csoregi c447e5b344 Backed out 4 changesets (bug 1858627) for causing clipboard/paste failures. CLOSED TREE
Backed out changeset ad694926aa45 (bug 1858627)
Backed out changeset aca702ea720f (bug 1858627)
Backed out changeset 1d5175296606 (bug 1858627)
Backed out changeset 05b957fe3079 (bug 1858627)
2024-03-06 11:52:20 +02:00
Edgar Chen 8f5c19fe0c Bug 1858627 - Suppress the paste contextmenu in paste event handler; r=nika
Depends on D202351

Differential Revision: https://phabricator.services.mozilla.com/D191131
2024-03-06 00:30:59 +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
Emilio Cobos Álvarez a906e9468b Bug 1850295 - Fix non-unified build.
Add some missing includes across the tree.

MANUAL PUSH: Orange fix CLOSED TREE
2024-01-16 14:11:42 +01:00
Edgar Chen 4920a38082 Bug 1777448 - Part 2: Suppress the paste context menu when the clipboard data originates from a same-origin page; r=nika
And don't allow new request being associated with existing pending request if
the requests are from different origin.

This patch also set proper principal to nsItransferable for clipboard write in
various cases,
- Copy image via context menu.
- Copy current selection via keyboard shortcut or context menu.
- Data is provided by script when copy operation is triggered via keyboard
  shortcut or context menu.
- Clipboard data is put via async clipboard.

Depends on D190761

Differential Revision: https://phabricator.services.mozilla.com/D190796
2023-12-08 07:08:42 +00:00
Cristian Tuns 983b4d3824 Backed out 2 changesets (bug 1777448) for causing bc failures in /browser_navigator_clipboard_contextmenu_suppression.js CLOSED TREE
Backed out changeset 6dee3dce64ad (bug 1777448)
Backed out changeset 32841cae9b3b (bug 1777448)
2023-12-06 19:55:14 -05:00
Edgar Chen 154d82633b Bug 1777448 - Part 2: Suppress the paste context menu when the clipboard data originates from a same-origin page; r=nika
And don't allow new request being associated with existing pending request if
the requests are from different origin.

This patch also set proper principal to nsItransferable for clipboard write in
various cases,
- Copy image via context menu.
- Copy current selection via keyboard shortcut or context menu.
- Data is provided by script when copy operation is triggered via keyboard
  shortcut or context menu.
- Clipboard data is put via async clipboard.

Depends on D190761

Differential Revision: https://phabricator.services.mozilla.com/D190796
2023-12-06 20:29:00 +00:00
Jonathan Watt 2bb6b60600 Bug 1865479. Rename nsIContentViewerEdit to nsIDocumentViewerEdit. r=layout-reviewers,tnikkel
Differential Revision: https://phabricator.services.mozilla.com/D193986
2023-11-19 10:13:12 +00:00
Edgar Chen dabf3bd1ac Bug 1854747 - Stop exposing the image data as file to clipboard; r=evilpie
Differential Revision: https://phabricator.services.mozilla.com/D189242
2023-10-06 13:17:52 +00:00
Cristina Horotan 5012f6ea59 Backed out changeset 1e91f547f0c7 (bug 1854747) for causing bc failures at browser_save_filenames.js on a CLOSED TREE 2023-10-05 22:22:27 +03:00
Edgar Chen e30ee78ebe Bug 1854747 - Stop exposing the image data as file to clipboard; r=evilpie
Differential Revision: https://phabricator.services.mozilla.com/D189242
2023-10-05 15:26:35 +00:00
Narcis Beleuzu 86ac9f3a65 Backed out changeset 671cc9eb7842 (bug 1854747) for bc failure browser_save_filenames.js 2023-09-29 19:43:07 +03:00
Edgar Chen 2b667ec70f Bug 1854747 - Stop exposing the image data as file to clipboard; r=evilpie
Differential Revision: https://phabricator.services.mozilla.com/D189242
2023-09-29 12:17:19 +00:00
Logan Rosen 847ac3aef0 Bug 1091187 - remove unused arguments and check from UpdateCommands r=dom-core,webidl,masayuki,smaug
Differential Revision: https://phabricator.services.mozilla.com/D185385
2023-08-10 04:09:08 +00:00
Emilio Cobos Álvarez 42b26244cc 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
Tom Schuster bccb99a631 Bug 1690532 - Making the nsITransferable to use a correct cookieJarSettings when doing a Image Copy on Windows. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D176427
2023-04-27 19:22:43 +00:00
Tom Schuster 30930ea2b7 Bug 1808146 - When creating a file promise for images, remember the referrer. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D172920
2023-03-22 21:55:08 +00:00
Masayuki Nakano 1857a4cbc0 Bug 1818128 - Add logging code for Selection API calls r=smaug
It's hard to check Selection API calls from both JS and internals when we debug
web apps which has complicated `contenteditable` editor.  Therefore, I'd like to
add an ability to log Selection API calls.

This patch needs to stop some methods inlined.  Therefore, this could affect to
the performance in release builds, though.  If so, I need to work on some
optimization later.

For minimizing the impact for performance, this patch also makes them to check
the logging level before calling logging methods.  It's currently redundant
for `LogLevel::Info` case.  However, this avoids any performance impact from
changes of `MOZ_LOG` implementation and in the blocks.

Differential Revision: https://phabricator.services.mozilla.com/D170585
2023-03-05 22:38:05 +00:00