Skip to content

Commit

Permalink
update windowSizingFix to use config setting, or screen.availTop if n…
Browse files Browse the repository at this point in the history
…ot defined
  • Loading branch information
ladamski committed Jan 6, 2024
1 parent ec388a9 commit 06d95ff
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/features/web-compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ import { URL } from '../captured-globals.js'
/**
* Fixes incorrect sizing value for outerHeight and outerWidth
*/
function windowSizingFix () {
// macOS browser incorrectly reports window height for window.screenY / window.screenTop
function windowSizingFix (settings) {
// macOS browser incorrectly reports screen height for window.screenY / window.screenTop
if (window.screenY === window.screen.height) {
window.screenY = window.screenTop = 0
let screenYOverride = settings?.screenYOverride

if (typeof screenYOverride === 'undefined') {
// @ts-expect-error - typescript known about availTop in this context
screenYOverride = window.screen.availTop
}

window.screenY = window.screenTop = screenYOverride
}

if (window.outerHeight !== 0 && window.outerWidth !== 0) {
Expand Down Expand Up @@ -81,7 +88,8 @@ export default class WebCompat extends ContentFeature {

init () {
if (this.getFeatureSettingEnabled('windowSizing')) {
windowSizingFix()
const settings = this.getFeatureSetting('windowSizing')
windowSizingFix(settings)
}
if (this.getFeatureSettingEnabled('navigatorCredentials')) {
this.navigatorCredentialsFix()
Expand Down

0 comments on commit 06d95ff

Please sign in to comment.