-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Various adapters: consolidate devicepixelratio usage into approximation #14192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Various adapters: consolidate devicepixelratio usage into approximation #14192
Conversation
Removed direct devicePixelRatio retrieval and validation.
|
Whoa there, partner! 🌵🤠 We wrangled some duplicated code in your PR:
Reducing code duplication by importing common functions from a library not only makes our code cleaner but also easier to maintain. Please move the common code from both files into a library and import it in each. We hate that we have to mention this, however, commits designed to hide from this utility by renaming variables or reordering an object are poor conduct. We will not look upon them kindly! Keep up the great work! 🚀 |
…odule 51Degrees RTD Provider: remove device pixel ratio helper
|
Whoa there, partner! 🌵🤠 We wrangled some duplicated code in your PR:
Reducing code duplication by importing common functions from a library not only makes our code cleaner but also easier to maintain. Please move the common code from both files into a library and import it in each. We hate that we have to mention this, however, commits designed to hide from this utility by renaming variables or reordering an object are poor conduct. We will not look upon them kindly! Keep up the great work! 🚀 |
|
duplication solved here #14186 |
|
Whoa there, partner! 🌵🤠 We wrangled some duplicated code in your PR:
Reducing code duplication by importing common functions from a library not only makes our code cleaner but also easier to maintain. Please move the common code from both files into a library and import it in each. We hate that we have to mention this, however, commits designed to hide from this utility by renaming variables or reordering an object are poor conduct. We will not look upon them kindly! Keep up the great work! 🚀 |
|
Whoa there, partner! 🌵🤠 We wrangled some duplicated code in your PR:
Reducing code duplication by importing common functions from a library not only makes our code cleaner but also easier to maintain. Please move the common code from both files into a library and import it in each. We hate that we have to mention this, however, commits designed to hide from this utility by renaming variables or reordering an object are poor conduct. We will not look upon them kindly! Keep up the great work! 🚀 |
dgirardi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed an update about the code itself, but I'm not convinced the approximation works:
- the fallback using
screen.height / innerHeightis way off for me (dpr = 1, approx ~= 5.5) screen.width / innerWidthkinda works (1 vs 1.02) but only if the browser window is maximized. Resizing it changes the approximated value significantly whiledevicePixelRatioremains constant- I know very little about
devicePixelRatiobut I suspect it would behave differently on mobile.
|
I missed some unit tests that would need to be updated to work with this, but I'll wait to see what we want to do before addressing them |
|
I updated this to keep the centralization but just return |
|
|
||
| export function getDevicePixelRatio(win) { | ||
| try { | ||
| return getFallbackWindow(win).devicePixelRatio; |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting
|
|
||
| function getScreenParams() { | ||
| return `${window.screen.width}x${window.screen.height}@${window.devicePixelRatio}`; | ||
| return `${window.screen.width}x${window.screen.height}@${getDevicePixelRatio(window)}`; |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting
| 'wxo': win.pageXOffset, | ||
| 'wyo': win.pageYOffset, | ||
| 'wpr': win.devicePixelRatio, | ||
| 'wpr': getDevicePixelRatio(win), |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting
| deviceWidth: screen.width, | ||
| deviceHeight: screen.height, | ||
| devicePixelRatio: topWindow.devicePixelRatio, | ||
| devicePixelRatio: getDevicePixelRatio(topWindow), |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting
| tpl: mosttopURL, | ||
| ce: storage.cookiesAreEnabled(), | ||
| dpr: topWindow.devicePixelRatio || 1, | ||
| dpr: getDevicePixelRatio(topWindow), |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting
| const uuid = uids[0] ? uids[0] : generateTemporaryUUID(); | ||
| const floor = getBidFloor(request, request.sizes || []); | ||
| const dpr = typeof window !== 'undefined' ? window.devicePixelRatio : 1; | ||
| const dpr = typeof window !== 'undefined' ? getDevicePixelRatio(window) : 1; |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting
| const req = buildRequest(imps, bidderRequest, context); | ||
| req.tmax = DEFAULT_TIMEOUT; | ||
| deepSetValue(req, 'device.pxratio', window.devicePixelRatio); | ||
| deepSetValue(req, 'device.pxratio', getDevicePixelRatio(getWindowContext())); |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting
| 'CH-Downlink': connection.downlink, | ||
| 'CH-DeviceMemory': null, | ||
| 'CH-Dpr': W.devicePixelRatio, | ||
| 'CH-Dpr': getDevicePixelRatio(W), |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting
| deviceWidth: screen.width, | ||
| deviceHeight: screen.height, | ||
| devicePixelRatio: topWindow.devicePixelRatio, | ||
| devicePixelRatio: getDevicePixelRatio(topWindow), |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting
|
|
||
| export function getDevicePixelRatio(win) { | ||
| try { | ||
| return getFallbackWindow(win).devicePixelRatio; |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting Warning
|
|
||
| function getScreenParams() { | ||
| return `${window.screen.width}x${window.screen.height}@${window.devicePixelRatio}`; | ||
| return `${window.screen.width}x${window.screen.height}@${getDevicePixelRatio(window)}`; |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting Warning
| deviceWidth: screen.width, | ||
| deviceHeight: screen.height, | ||
| devicePixelRatio: topWindow.devicePixelRatio, | ||
| devicePixelRatio: getDevicePixelRatio(topWindow), |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting Warning
| tpl: mosttopURL, | ||
| ce: storage.cookiesAreEnabled(), | ||
| dpr: topWindow.devicePixelRatio || 1, | ||
| dpr: getDevicePixelRatio(topWindow), |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting Warning
| const uuid = uids[0] ? uids[0] : generateTemporaryUUID(); | ||
| const floor = getBidFloor(request, request.sizes || []); | ||
| const dpr = typeof window !== 'undefined' ? window.devicePixelRatio : 1; | ||
| const dpr = typeof window !== 'undefined' ? getDevicePixelRatio(window) : 1; |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting Warning
| const req = buildRequest(imps, bidderRequest, context); | ||
| req.tmax = DEFAULT_TIMEOUT; | ||
| deepSetValue(req, 'device.pxratio', window.devicePixelRatio); | ||
| deepSetValue(req, 'device.pxratio', getDevicePixelRatio(getWindowContext())); |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting Warning
| 'CH-Downlink': connection.downlink, | ||
| 'CH-DeviceMemory': null, | ||
| 'CH-Dpr': W.devicePixelRatio, | ||
| 'CH-Dpr': getDevicePixelRatio(W), |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting Warning
| deviceWidth: screen.width, | ||
| deviceHeight: screen.height, | ||
| devicePixelRatio: topWindow.devicePixelRatio, | ||
| devicePixelRatio: getDevicePixelRatio(topWindow), |
Check warning
Code scanning / CodeQL
Use of browser API associated with fingerprinting Warning
|
marking as on hold for next pmc, we didnt cover today |
No description provided.