Closed Bug 1940790 Opened 1 year ago Closed 9 months ago

Support PNG when pasting images into Firefox

Categories

(Core :: Widget: Win32, defect, P2)

Firefox 134
defect

Tracking

()

RESOLVED FIXED
139 Branch
Tracking Status
relnote-firefox --- 139+
firefox139 --- fixed

People

(Reporter: rkraesig, Assigned: gstoll)

References

(Blocks 1 open bug, )

Details

Attachments

(1 file)

At present, when a pasted/dropped image is PNG and the paste/drop target within Firefox wants PNG, we unconditionally convert the pasted image(s) from PNG into BMP and back. Not only is this wasteful, it strips transparency information.

We should avoid doing this whenever possible.

Severity: -- → S2
Priority: -- → P2
Version: unspecified → Firefox 134

As my issue is related to a single program (Paint.NET), preferring PNG to DIB will perfectly solve my concerns.

This bug is not about DIB or DIBv5. If you have any comments appertaining thereto, they belong on bug 1866655 or on the now-meta-bug 460969, not here.

Blocks: 1857764
Assignee: rkraesig → gstoll

On Windows, for the image/png MIME type we should read the "PNG" format
from the clipboard. Note that this is not officially defined by Microsoft
but seems to be commonly in use. (by at least us and Paint.NET)

The new test passes on Windows (after this change), and also Mac and
Linux.

Pushed by gstoll@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/77a9e19339e4 read PNG format from clipboard on Windows r=edgar
Status: NEW → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 139 Branch
Regressions: 1957903

Release Note Request (optional, but appreciated)
[Why is this notable]: Long-standing S2 bug (it was only filed a few months ago but I doubt Firefox ever supported this) that caused images pasted into Firefox to lose their transparency
[Affects Firefox for Android]: no
[Suggested wording]: PNG images with transparency will keep their transparency when pasted into Firefox.
[Links (documentation, blog post, etc)]:

relnote-firefox: --- → ?

Added to the Fx139 relnotes.

Regressions: 1958434

Backed out as requested by gstoll for causing Bug 1958434.

Status: RESOLVED → REOPENED
Flags: needinfo?(gstoll)
Resolution: FIXED → ---
Target Milestone: 139 Branch → ---
+      } else if (flavorStr.EqualsLiteral(kPNGImageMime)) {
+        // Fall back to DIBV5 format
+        dataFound = NS_SUCCEEDED(GetNativeDataOffClipboard(
+            aDataObject, anIndex, CF_DIBV5, flavorStr.get(), &data, &dataLen));

I do not know your code really well, but this code wouldn’t pass my review. Found PNG and dig for DIB?

(In reply to mercury13 from comment #14)

+      } else if (flavorStr.EqualsLiteral(kPNGImageMime)) {
+        // Fall back to DIBV5 format
+        dataFound = NS_SUCCEEDED(GetNativeDataOffClipboard(
+            aDataObject, anIndex, CF_DIBV5, flavorStr.get(), &data, &dataLen));

I do not know your code really well, but this code wouldn’t pass my review. Found PNG and dig for DIB?

This was essentially the old behavior before this fix. Although it's definitely possible this is what caused the regression, which I'll take a look at next week.

This was essentially the old behavior before this fix. Although it's definitely possible this is what caused the regression, which I'll take a look at next week.

No, that’s from https://hg.mozilla.org/mozilla-central/rev/77a9e19339e4 pushed on Apr 2 and quickly reverted.

My point is that this is basically equivalent to this line which set the format to CF_DIBV5 if the flavorStr was kPNGImageMime, which was the behavior before this change.

Another strange line. Format JPEG → set DIB, probably “JPEG is not supported”.
Format JPEG or PNG → set DIB, what?

SORRY, that’s actually OK, used to be JPEG and PNG not supported, and now some special bhv for PNG.

Unfortunately after reapplying my change locally I'm having trouble reproducing bug 1958434

Flags: needinfo?(gstoll)
Pushed by gstoll@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/743e7d6d8927 read PNG format from clipboard on Windows r=edgar
Status: REOPENED → RESOLVED
Closed: 9 months ago9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 139 Branch

In case this becomes a problem in the future, https://bug460969.bmoattachments.org/attachment.cgi?id=9053448 is a good testcase for this.

QA Whiteboard: [qa-triage-done-c140/b139]
Duplicate of this bug: 1717306
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: