Skip to content

Commit 2342511

Browse files
Merge pull request #2637 from mrmr1993/linkhints-scaled-display-fix
Exclude Firefox from the scaled DPI fix
2 parents f3b186c + 263a7c6 commit 2342511

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

background_scripts/main.coffee

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ root = exports ? window
55
chrome.runtime.onInstalled.addListener ({ reason }) ->
66
# See https://developer.chrome.com/extensions/runtime#event-onInstalled
77
return if reason in [ "chrome_update", "shared_module_update" ]
8+
return if Utils.isFirefox()
89
manifest = chrome.runtime.getManifest()
910
# Content scripts loaded on every page should be in the same group. We assume it is the first.
1011
contentScripts = manifest.content_scripts[0]
@@ -310,6 +311,7 @@ Frames =
310311

311312
isEnabledForUrl: ({request, tabId, port}) ->
312313
urlForTab[tabId] = request.url if request.frameIsFocused
314+
request.isFirefox = Utils.isFirefox() # Update the value for Utils.isFirefox in the frontend.
313315
enabledState = Exclusions.isEnabledForUrl request.url
314316

315317
if request.frameIsFocused

content_scripts/vimium_frontend.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ extend window,
493493
# the page icon.
494494
checkIfEnabledForUrl = do ->
495495
Frame.addEventListener "isEnabledForUrl", (response) ->
496-
{isEnabledForUrl, passKeys, frameIsFocused} = response
496+
{isEnabledForUrl, passKeys, frameIsFocused, isFirefox} = response
497+
Utils.isFirefox = -> isFirefox
497498
initializeOnEnabledStateKnown isEnabledForUrl
498499
normalMode.setPassKeys passKeys
499500
# Hide the HUD if we're not enabled.

lib/dom_utils.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ DomUtils =
293293
style = getComputedStyle box
294294
if style.position == "static" and not /content|paint|strict/.test(style.contain or "")
295295
zoom = +style.zoom || 1
296-
ratio = window.devicePixelRatio ? 1
296+
ratio = window.devicePixelRatio
297+
ratio = 1 if Utils.isFirefox() or not ratio?
297298
top: Math.ceil(window.scrollY * ratio / zoom), left: Math.ceil(window.scrollX * ratio / zoom)
298299
else
299300
rect = box.getBoundingClientRect()

lib/utils.coffee

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ window.forTrusted ?= (handler) -> (event) ->
77
true
88

99
Utils =
10+
isFirefox: do ->
11+
# NOTE(mrmr1993): This test only works in the background page, this is overwritten by isEnabledForUrl for
12+
# content scripts.
13+
isFirefox = false
14+
browser?.runtime?.getBrowserInfo?()?.then? (browserInfo) ->
15+
isFirefox = browserInfo?.name == "Firefox"
16+
-> isFirefox
1017
getCurrentVersion: ->
1118
chrome.runtime.getManifest().version
1219

0 commit comments

Comments
 (0)