Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Allow setting devicePixelRatio #13942

Closed
wants to merge 1 commit into from
Closed

Conversation

DeviaVir
Copy link
Contributor

@DeviaVir DeviaVir commented Jan 25, 2016

When qtwebkit/qtwebkit#515 is merged, the changes here will become valid and should allow users to overwrite the devicePixelRatio as first introduced in this PR:
#12839

The sample should still be valid:

var webPage = require('webpage');
var page = webPage.create();

// An example url that supports @2x background-image with the following css:-
/* body {
     background-image: background-image: url('http://retinajs.s3.amazonaws.com/images/backgrounds/bg.jpg');
  }
  @media all and (-webkit-min-device-pixel-ratio: 1.5) {
     body {
       background-image: background-image: url('http://retinajs.s3.amazonaws.com/images/backgrounds/bg@2x.jpg');
    }
} */
var examplePage = 'http://imulus.github.io/retinajs/';

//Pass a dpr of your choosing
page.devicePixelRatio = 1.5; // in this case, >=1.5 to get the retina-supporting bg-image

page.open(examplePage, function() {
   var backgroundImage = page.evaluate(function() {
     return window.getComputedStyle(document.body).backgroundImage;
   });
   console.log(backgroundImage); // returns http://retinajs.s3.amazonaws.com/images/backgrounds/bg@2x.jpg
   page.render('2x.png');
});

Fixes #10964

@ariya
Copy link
Owner

ariya commented Jan 26, 2016

This definitely needs some tests.

@vitallium vitallium force-pushed the master branch 2 times, most recently from 1842ba8 to 842715b Compare March 15, 2016 17:40
@vitallium vitallium force-pushed the master branch 2 times, most recently from e024f31 to 5d99f2a Compare May 19, 2016 20:53
@DeviaVir DeviaVir force-pushed the master branch 5 times, most recently from aa4d53f to 890d5c7 Compare June 20, 2016 14:37
@DeviaVir
Copy link
Contributor Author

DeviaVir commented Jun 20, 2016

Tests results (with src/qt/qtwebkit on my branch):

$ python run-tests.py
ff....................f..........f...............s................ff.............s....f...
60.230s elapsed
  215 passed
   14 failed as expected
    2 skipped

cc: @ariya

@pholmstr
Copy link

pholmstr commented Jul 5, 2016

Could be way off base here, but window.devicePixelRatio is a read only value so I wouldn't think it would be changeable via javascript. If the device supports high DPI then the devicePixelRatio should already be set.

Still waiting desperately for this feature 👍

@DeviaVir
Copy link
Contributor Author

DeviaVir commented Apr 18, 2017

This now depends on qtwebkit/qtwebkit#515

@DeviaVir
Copy link
Contributor Author

ping @ariya, I was hoping to get a pre-approval on this PR while we wait for qtwebkit/qtwebkit#515, is there anything I need to add or update about this PR?

@DeviaVir
Copy link
Contributor Author

The related PR qtwebkit/qtwebkit#515 has been merged, there are no more blockers to merge this PR. @ariya who is best to ping to land this?

@DeviaVir
Copy link
Contributor Author

@vitallium are you the right person to ping for this? I think this PR is cleared to merge.

@DeviaVir
Copy link
Contributor Author

DeviaVir commented Jun 6, 2017

@ariya @vitallium apologies for pinging you in case you are no longer maintaining this: any ideas re: next steps for this PR?

@vitallium
Copy link
Collaborator

Landed in master!

@vitallium vitallium closed this Jun 25, 2017
@vitallium
Copy link
Collaborator

@DeviaVir also, I missed your PR and committed changes by myself. I do not want to take credits for that, send me please your Name and Email and I will alter the author of the commit to you. Sorry and thank you!

@CWBudde
Copy link

CWBudde commented Jul 30, 2017

Does anyone have an idea when there will be a new release including this change? And when will it be added to the documentation?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants