@@ -421,7 +421,7 @@ function preparePanel() {
421
421
panel = createdPanel ;
422
422
}
423
423
424
- function updatePanel ( { previewTabId, title, url, tooltipHtml, hasPreview, previewURL, previewTabRect, offsetTop, align, rtl, scale, logging, animation, backgroundColor, borderColor, color } = { } ) {
424
+ function updatePanel ( { previewTabId, title, url, tooltipHtml, hasPreview, previewURL, previewTabRect, offsetTop, align, rtl, scale, logging, animation, backgroundColor, borderColor, color, widthInOuterWorld } = { } ) {
425
425
if ( ! panel )
426
426
return ;
427
427
@@ -432,7 +432,7 @@ function updatePanel({ previewTabId, title, url, tooltipHtml, hasPreview, previe
432
432
hasPreview = hasLoadablePreviewURL ;
433
433
434
434
if ( logging )
435
- console . log ( 'updatePanel ' , { previewTabId, title, url, tooltipHtml, hasPreview, previewURL, previewTabRect, offsetTop, align, rtl, scale } ) ;
435
+ console . log ( 'updatePanel ' , { previewTabId, title, url, tooltipHtml, hasPreview, previewURL, previewTabRect, offsetTop, align, rtl, scale, widthInOuterWorld } ) ;
436
436
437
437
panel . classList . add ( 'updating' ) ;
438
438
panel . classList . toggle ( 'animation' , animation ) ;
@@ -452,13 +452,23 @@ function updatePanel({ previewTabId, title, url, tooltipHtml, hasPreview, previe
452
452
// from both the sidebar and the content area, because all contents
453
453
// of the browser window can be scaled on a high-DPI display by the
454
454
// platform.
455
- scale = window . devicePixelRatio * ( scale || 1 ) ;
455
+ const isResistFingerprintingMode = window . mozInnerScreenY == 0 && window . screenY == 0 ;
456
+ const devicePixelRatio = ( widthInOuterWorld || window . innerWidth ) / window . innerWidth ;
457
+ if ( logging )
458
+ console . log ( 'updatePanel: isResistFingerprintingMode ' , isResistFingerprintingMode , { devicePixelRatio } ) ;
459
+ // But window.devicePixelRatio is not available if privacy.resistFingerprinting=true,
460
+ // thus we need to calculate it based on tabs.Tab.width.
461
+ scale = devicePixelRatio * ( scale || 1 ) ;
456
462
document . documentElement . style . setProperty ( '--tab-preview-panel-scale' , scale ) ;
457
463
const panelWidth = Math . min ( window . innerWidth , BASE_PANEL_WIDTH / scale ) ;
458
464
panel . style . setProperty ( '--panel-width' , `${ panelWidth } px` ) ;
459
465
460
- const offsetFromWindowEdge = ( window . mozInnerScreenY - window . screenY ) * scale ;
461
- const sidebarContentsOffset = ( offsetTop - offsetFromWindowEdge ) / scale ;
466
+ const offsetFromWindowEdge = isResistFingerprintingMode ?
467
+ 0 :
468
+ ( window . mozInnerScreenY - window . screenY ) * scale ;
469
+ const sidebarContentsOffset = isResistFingerprintingMode ?
470
+ 0 :
471
+ ( offsetTop - offsetFromWindowEdge ) / scale ;
462
472
463
473
if ( previewTabRect ) {
464
474
const panelTopEdge = windowId ? previewTabRect . bottom : previewTabRect . top ;
0 commit comments