aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--background_scripts/main.coffee2
-rw-r--r--content_scripts/vimium_frontend.coffee3
-rw-r--r--lib/dom_utils.coffee3
-rw-r--r--lib/utils.coffee7
4 files changed, 13 insertions, 2 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index 15292ab6..379239ae 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -5,6 +5,7 @@ root = exports ? window
chrome.runtime.onInstalled.addListener ({ reason }) ->
# See https://developer.chrome.com/extensions/runtime#event-onInstalled
return if reason in [ "chrome_update", "shared_module_update" ]
+ return if Utils.isFirefox()
manifest = chrome.runtime.getManifest()
# Content scripts loaded on every page should be in the same group. We assume it is the first.
contentScripts = manifest.content_scripts[0]
@@ -310,6 +311,7 @@ Frames =
isEnabledForUrl: ({request, tabId, port}) ->
urlForTab[tabId] = request.url if request.frameIsFocused
+ request.isFirefox = Utils.isFirefox() # Update the value for Utils.isFirefox in the frontend.
enabledState = Exclusions.isEnabledForUrl request.url
if request.frameIsFocused
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index dae25f5c..02bdfa2c 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -493,7 +493,8 @@ extend window,
# the page icon.
checkIfEnabledForUrl = do ->
Frame.addEventListener "isEnabledForUrl", (response) ->
- {isEnabledForUrl, passKeys, frameIsFocused} = response
+ {isEnabledForUrl, passKeys, frameIsFocused, isFirefox} = response
+ Utils.isFirefox = -> isFirefox
initializeOnEnabledStateKnown isEnabledForUrl
normalMode.setPassKeys passKeys
# Hide the HUD if we're not enabled.
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index 24747837..c8ddcedf 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -293,7 +293,8 @@ DomUtils =
style = getComputedStyle box
if style.position == "static" and not /content|paint|strict/.test(style.contain or "")
zoom = +style.zoom || 1
- ratio = window.devicePixelRatio ? 1
+ ratio = window.devicePixelRatio
+ ratio = 1 if Utils.isFirefox() or not ratio?
top: Math.ceil(window.scrollY * ratio / zoom), left: Math.ceil(window.scrollX * ratio / zoom)
else
rect = box.getBoundingClientRect()
diff --git a/lib/utils.coffee b/lib/utils.coffee
index 78eed12c..93cc3246 100644
--- a/lib/utils.coffee
+++ b/lib/utils.coffee
@@ -7,6 +7,13 @@ window.forTrusted ?= (handler) -> (event) ->
true
Utils =
+ isFirefox: do ->
+ # NOTE(mrmr1993): This test only works in the background page, this is overwritten by isEnabledForUrl for
+ # content scripts.
+ isFirefox = false
+ browser?.runtime?.getBrowserInfo?()?.then? (browserInfo) ->
+ isFirefox = browserInfo?.name == "Firefox"
+ -> isFirefox
getCurrentVersion: ->
chrome.runtime.getManifest().version