aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2017-09-15 07:06:50 +0100
committerGitHub2017-09-15 07:06:50 +0100
commit29bb5cca58e549432b57634da582601f87c9c687 (patch)
treec6fb4ad4789ba0020e10f742cfc1b4e7366b6165
parente60f329eb6180cbe3261adf582ee4df3cdc0b0fe (diff)
parent09abac4c4c6be7a567478f726dab5f2456ee433d (diff)
downloadvimium-29bb5cca58e549432b57634da582601f87c9c687.tar.bz2
Merge pull request #2649 from mrmr1993/linkhints-scaled-display-fix
Always use getBoundingClientRect for getViewportTopLeft
-rw-r--r--lib/dom_utils.coffee17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index d0bd4615..b3fc981b 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -291,12 +291,21 @@ DomUtils =
getViewportTopLeft: ->
box = document.documentElement
style = getComputedStyle box
+ rect = box.getBoundingClientRect()
if style.position == "static" and not /content|paint|strict/.test(style.contain or "")
- zoom = +style.zoom || 1
- top: Math.ceil(window.scrollY / zoom), left: Math.ceil(window.scrollX / zoom)
+ # The margin is included in the client rect, so we need to subtract it back out.
+ marginTop = parseInt style.marginTop
+ marginLeft = parseInt style.marginLeft
+ top: -rect.top + marginTop, left: -rect.left + marginLeft
else
- rect = box.getBoundingClientRect()
- top: -rect.top - box.clientTop, left: -rect.left - box.clientLeft
+ if Utils.isFirefox()
+ # These are always 0 for documentElement on Firefox, so we derive them from CSS border.
+ clientTop = parseInt style.borderTopWidth
+ clientLeft = parseInt style.borderLeftWidth
+ else
+ {clientTop, clientLeft} = box
+ top: -rect.top - clientTop, left: -rect.left - clientLeft
+
suppressPropagation: (event) ->
event.stopImmediatePropagation()