Closed
Bug 564815
Opened 15 years ago
Closed 13 years ago
implement window.devicePixelRatio
Categories
(Core :: DOM: Core & HTML, enhancement)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla18
People
(Reporter: stechz, Assigned: mbrubeck)
References
Details
(Keywords: compat, dev-doc-needed, Whiteboard: [parity-chrome][parity-safari][parity-android][parity-opera])
Attachments
(2 files)
|
4.10 KB,
patch
|
jst
:
review+
sicking
:
superreview+
mbrubeck
:
checkin+
|
Details | Diff | Splinter Review |
|
1.96 KB,
patch
|
bzbarsky
:
review+
mbrubeck
:
checkin+
|
Details | Diff | Splinter Review |
Android browser commit here: https://android.git.kernel.org/?p=platform/external/webkit.git;a=commit;h=f10585d69aaccf4c1b021df143ee0f08e338cf31
Should Fennec implement this? I could see this being of use to Javascript widget libraries that want an easy way to guarantee buttons are of a touchable size.
Comment 1•15 years ago
|
||
This is available to chrome (under a different name), see https://bugzilla.mozilla.org/show_bug.cgi?id=486200. To be honest, I doubt that this is ever needed for content. Content should just use units such as mm. See http://mxr.mozilla.org/mobile-browser/source/themes/wince/platform.css?mark=136-137#135 for an example.
Comment 2•15 years ago
|
||
you can't use things like mm because they're not actually physical units. We need to add new unit types
Comment 3•14 years ago
|
||
We've got mozmm for that.
Updated•13 years ago
|
Component: General → DOM
Product: Fennec → Core
QA Contact: general → general
Updated•13 years ago
|
Summary: Javascript property "devicePixelRatio" → implement window.devicePixelRatio
Comment 4•13 years ago
|
||
http://www.apple.com/ currently has a pretty retina display demo image; it appears to use window.devicePixelRatio to determine whether to load the high-resolution images.
Mobile needs this as well -- we need to be able to figure out what the actual pixel ratio is on high dpi displays, for being able to appropriately choose backing store size for canvas and similar.
| Assignee | ||
Comment 7•13 years ago
|
||
This patch appears to work, although I it always returns 1 on Android, which I think is because of bug 779527.
This patch basically reverts part of bug 507755, though it keeps the nsIDOMWindowUtils method around too for add-on compatibility. I still need to add tests, but first I'd like to know if this is basically correct, and if it's a change that we want to ship.
| Assignee | ||
Comment 8•13 years ago
|
||
http://www.quirksmode.org/blog/archives/2012/07/more_about_devi.html has some notes about how this is implemented in other browsers. Similar to bug 779527, there may be special concerns on mobile where we use a pannable/zoomable "virtual" viewport.
| Assignee | ||
Updated•13 years ago
|
The popular retina.js solution for transparently serving high-res images when necessary (http://retinajs.com) uses "root.devicePixelRatio" as a test for HiDPI displays (https://github.com/imulus/retinajs/blob/master/src/retina.js#L107). This works on Safari (Mobile and Desktop), Google Chrome, but fails with the Firefox HiDPI-enable nightly builds (https://bugzilla.mozilla.org/show_bug.cgi?id=674373).
Comment 10•13 years ago
|
||
The updated QuirksBlog entry is out:
http://www.quirksmode.org/blog/archives/2012/06/devicepixelrati.html
Also, "root.devicePixelRatio" instead of "window.devicePixelRatio" would probably fail in Firefox anyway.
Comment 11•13 years ago
|
||
Ignore me, that was not an update, but a QuirksBlog entry from June, actually older.
| Assignee | ||
Comment 12•13 years ago
|
||
(In reply to Sergey «Mithgol the Webmaster» Sokoloff from comment #10)
> Also, "root.devicePixelRatio" instead of "window.devicePixelRatio" would
> probably fail in Firefox anyway.
"root" is just an alias for "window" in the code referenced above:
https://github.com/imulus/retinajs/blob/master/src/retina.js#L3
Comment 13•13 years ago
|
||
Comment on attachment 652534 [details] [diff] [review]
patch
I think we should take this, it's basically a defacto standard at this point... Is someone raising this is the standards world already? If not, that needs to happen as well.
Attachment #652534 -
Flags: review?(jst) → review+
| Assignee | ||
Updated•13 years ago
|
Attachment #652534 -
Flags: superreview?(jonas)
| Assignee | ||
Comment 14•13 years ago
|
||
Adds some simple assertions to match the ones for screenPixelsPerCSSPixel. Pushed to Try: https://tbpl.mozilla.org/?tree=Try&rev=420ebbefd766
Attachment #656949 -
Flags: review?(jst)
Attachment #652534 -
Flags: superreview?(jonas) → superreview+
| Assignee | ||
Comment 15•13 years ago
|
||
Comment on attachment 652534 [details] [diff] [review]
patch
Pushed the reviewed patch to inbound so that we can start getting coverage of this in nightlies:
https://hg.mozilla.org/integration/mozilla-inbound/rev/84b9f209a913
The other patch is a trivial test-only change; I'll push that whenever it's reviewed.
Attachment #652534 -
Flags: checkin+
| Assignee | ||
Updated•13 years ago
|
Keywords: dev-doc-needed
Target Milestone: --- → mozilla18
Comment 16•13 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
| Assignee | ||
Comment 17•13 years ago
|
||
Comment on attachment 656949 [details] [diff] [review]
test
This test-only patch adds two assertions to check the value of window.devicePixelRatio. Since this new property is an alias for nsIDOMWindowUtils.screenPixelsPerCSSPixel, we expect it to have the same value.
Attachment #656949 -
Flags: review?(jst) → review?(bzbarsky)
Comment 18•13 years ago
|
||
Comment on attachment 656949 [details] [diff] [review]
test
r=me
Attachment #656949 -
Flags: review?(bzbarsky) → review+
Comment 19•13 years ago
|
||
I notice that the test patch here hasn't landed yet... be aware that bug 809788 is proposing to change window.devicePixelRatio (to make it independent of page zoom), so it has a modified version of the test that will supersede this one, assuming we accept that behavior change.
| Assignee | ||
Comment 20•13 years ago
|
||
(In reply to Jonathan Kew (:jfkthame) from comment #19)
> I notice that the test patch here hasn't landed yet...
Oops! I guess that slipped through the cracks here.
> be aware that bug
> 809788 is proposing to change window.devicePixelRatio (to make it
> independent of page zoom), so it has a modified version of the test that
> will supersede this one, assuming we accept that behavior change.
Thanks for the heads-up. If bug 809788 is not already landed soon, then I'll push my test patch so we have basic testing in the meantime.
| Assignee | ||
Comment 21•13 years ago
|
||
Comment on attachment 656949 [details] [diff] [review]
test
https://hg.mozilla.org/integration/mozilla-inbound/rev/abfb3201b753
Attachment #656949 -
Flags: checkin+
Comment 22•13 years ago
|
||
Flags: in-testsuite+
Comment 23•13 years ago
|
||
Unfortunately, in version 18 window.devicePixelRatio not working properly. For Samsung Galaxy S II is 1.0, should be 1.5. For Google Nexus 7 is 1.0, should be 1.3. It should see the page: http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density
Comment 24•13 years ago
|
||
krzbor please file a new bug and cc me on it.
| Assignee | ||
Comment 25•13 years ago
|
||
(In reply to krzbor from comment #23)
> Unfortunately, in version 18 window.devicePixelRatio not working properly.
> For Samsung Galaxy S II is 1.0, should be 1.5. For Google Nexus 7 is 1.0,
> should be 1.3. It should see the page:
> http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density
Yes, window.devicePixelRatio and related properties are broken on Android; see bug 794056 and bug 803207.
Updated•13 years ago
|
Severity: normal → enhancement
Updated•7 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•