Closed Bug 1705877 Opened 3 years ago Closed 3 years ago

Incorrect cursor size when using image-set()

Categories

(Core :: CSS Parsing and Computation, defect)

Firefox 89
defect

Tracking

()

VERIFIED FIXED
90 Branch
Tracking Status
firefox88 --- wontfix
firefox89 --- verified
firefox90 --- verified

People

(Reporter: ashley, Assigned: emilio)

References

(Blocks 1 open bug)

Details

Attachments

(5 files, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0

Steps to reproduce:

When using CSS image-set() for a cursor property on a high-dpi display, Firefox appears to show the wrong size cursor.

Minimal repro: https://downloads.scirra.com/labs/bugs/cursor-image-set/

Using a high-dpi display (my system has devicePixelRatio 2), hover the yellow box in Nightly and see the cursor size. Compare with Chrome.

Actual results:

In Firefox only, the cursor is unexpectedly large.

Expected results:

The cursor should be smaller and use the larger image to increase the detail for high-dpi displays, which is what it does in Chrome (albeit with the -webkit-image-set() prefix).

BTW this affects our browser-based game editor Construct 3 (www.construct.net). Since we use image-set for cursors in our PWA, in Nightly these cursors appear too large.

Blocks: image-set
Status: UNCONFIRMED → NEW
Component: Untriaged → CSS Parsing and Computation
Ever confirmed: true
Product: Firefox → Core

Ah, so I guess this is the one place in case images where we care about the intrinsic size of the image...

For regular image elements density is accounted for here: https://searchfox.org/mozilla-central/rev/00fe1b9131e16daeb71aa90ad3d752454761fb1f/layout/generic/nsImageFrame.cpp#498

Flags: needinfo?(emilio)

Astounding that there was literally no WPT for this at all. I added three, one
for backgrounds, one for list-style-image, and one for content. Cursor is not
handled on this patch because that one requires a fair amount of extra work.

Assignee: nobody → emilio
Status: NEW → ASSIGNED

https://drafts.csswg.org/css-images-4/#image-set-notation has:

[...] it also specifies the image’s natural resolution, overriding any other
source of data that might supply a natural resolution.

Astounding that there was literally no WPT for this at all. I added three, one
for backgrounds, one for list-style-image, and one for content. Cursor is not
handled on this patch because that one requires a fair amount of extra work.

This required more refactoring so it seemed sensible to split it out. GTK
doesn't seem to provide an API for scaled cursors so we get pixelated cursors
instead.

Depends on D112474

Attachment #9216599 - Attachment is obsolete: true

I had overlooked the way to achieve this. This is possible using cairo
surfaces, but they only support integer scale factors, so we ceil and
potentially rasterize the image to a bigger size if needed.

Flags: needinfo?(emilio)
Keywords: leave-open
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/652bf5d7540d
image-set() should influence intrinsic size of the image. r=dholbert,layout-reviewers
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/28588 for changes under testing/web-platform/tests
Blocks: 1304098
Attachment #9216602 - Attachment description: Bug 1705877 - Apply scale factor for cursor on Windows and Mac. r=mstange → Bug 1705877 - Introduce nsIWidget::Cursor. r=mstange,dholbert

This required more refactoring so it seemed sensible to split it out. GTK
doesn't seem to provide an API for scaled cursors so we get pixelated cursors
instead.

Depends on D112475

Attachment #9216951 - Attachment description: Bug 1705877 - Apply scale factor for cursor on Windows and Mac. r=mstange,dholbert → Bug 1705877 - Apply image-set resolution for cursors on Windows and Mac. r=mstange,dholbert
Blocks: 1706288
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9141b021cbed
Introduce nsIWidget::Cursor. r=dholbert
Upstream PR merged by moz-wptsync-bot
Pushed by emilio@crisal.io:
https://hg.mozilla.org/integration/autoland/rev/07f095c42f60
Remove a bunch of useless virtual keywords in nsBaseWidget.h.
Pushed by emilio@crisal.io:
https://hg.mozilla.org/integration/autoland/rev/16194d15c078
Add back some virtual keywords that I shouldn't have removed.

(In reply to Pulsebot from comment #13)

Pushed by emilio@crisal.io:
https://hg.mozilla.org/integration/autoland/rev/07f095c42f60
Remove a bunch of useless virtual keywords in nsBaseWidget.h.

Sylvestre, this is a bit silly, my patch almost gets backed out for introducing one more of these using 'final' rather than 'override', while we had a gazillion of them. Do you know where should I file an issue? If we want to enforce this we should fix all the codebase first (for both 'final' and 'override', not just 'final').

Flags: needinfo?(sledru)

I think cpeterson wrote this checker a while back.

In term of component, it should probably be
https://bugzilla.mozilla.org/enter_bug.cgi?product=Firefox+Build+System&component=Lint+and+Formatting

Flags: needinfo?(sledru) → needinfo?(cpeterson)
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/aecf24e96348
Apply image-set resolution for cursors on Windows and Mac. r=dholbert

(In reply to Emilio Cobos Álvarez (:emilio) from comment #15)

Sylvestre, this is a bit silly, my patch almost gets backed out for introducing one more of these using 'final' rather than 'override', while we had a gazillion of them. Do you know where should I file an issue? If we want to enforce this we should fix all the codebase first (for both 'final' and 'override', not just 'final').

This lint is a simple regular expression that doesn't know how to check function declarations that span multiple lines. That's why some the results are inconsistent even within the same file. At the time, I thought reporting some problems was better than none. But this lint is mostly a style issue, so I can remove it if it's causing problems.

Flags: needinfo?(cpeterson)
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ee030bf89f28
Add support for scaled cursors on GTK. r=stransky
Keywords: leave-open
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch

Thanks for the fix! I can confirm cursors appear at the right size in our PWA in Nightly now.

Comment on attachment 9216600 [details]
Bug 1705877 - image-set() should influence intrinsic size of the image. r=dholbert,#layout-reviewers

Beta/Release Uplift Approval Request

  • User impact if declined: Potentially broken (as in, too big) cursors or backgrounds or other CSS images if they use image-set, a feature that we shipped in 88.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: comment 0
  • List of other uplifts needed: none
  • Risk to taking this patch: Medium
  • Why is the change risky/not risky? (and alternatives if risky): Even though the patches look really really big, it's really mostly plumbing and refactoring of the cursor code, in a way that they only change behavior for cursors using image-set(). It'd be nice to not ship this bug in 89.
  • String changes made/needed: none
Attachment #9216600 - Flags: approval-mozilla-beta?
Attachment #9216602 - Flags: approval-mozilla-beta?
Attachment #9216608 - Flags: approval-mozilla-beta?
Attachment #9216951 - Flags: approval-mozilla-beta?
Flags: qe-verify+

Emilio, I will let these patches on nightly bake a few days before taking a decision on the uplift.

Sure, that's totally fair, thanks Pascal!

QA Whiteboard: [qa-triaged]

I confirm the issue with the larger cursor on Fx 88.0 and Fx 89.0b2 compared with chrome.
Verified - Fixed in latest Nightly 90.0a1, the cursor has the same size with chrome, using Windows 10x64 with 4k monitor, Mac 11 and Ubuntu 18.04.

Status: RESOLVED → VERIFIED

Comment on attachment 9216600 [details]
Bug 1705877 - image-set() should influence intrinsic size of the image. r=dholbert,#layout-reviewers

Visible bug in a new CSS feature we shipped in 88, has tests, verified on nightly and we are early in the beta cycle, uplift approved for beta 4, thanks Emilio.

Attachment #9216600 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9216602 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9216608 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9216951 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Only difference is the mozgtk.c changes, which were needed before bug 1377445.

Flags: needinfo?(pascalc)
Flags: needinfo?(pascalc)

Verified - Fixed in latest Firefox Beta 89.0b8, the cursor has the same size with chrome, using Windows 10x64 Ubuntu 20.04. with 4k monitor, Mac 11.
Verified- Fixed the duplicated bug 1709284 in the latest Fx Beta 89.0b8 using Windows 10x64 Ubuntu 20.04. with 4k monitor, Mac 11.

QA Whiteboard: [qa-triaged]
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: