Skip to content

Exclude Firefox from the scaled DPI fix #2637

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

Merged
merged 3 commits into from
Sep 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions background_scripts/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion content_scripts/vimium_frontend.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion lib/dom_utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 7 additions & 0 deletions lib/utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down