aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/dom_utils.coffee20
-rw-r--r--lib/keyboard_utils.coffee3
-rw-r--r--lib/utils.coffee2
3 files changed, 18 insertions, 7 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index 38b23202..dcdd5518 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -46,11 +46,21 @@ DomUtils =
#
getVisibleClientRect: (element) ->
# Note: this call will be expensive if we modify the DOM in between calls.
- clientRects = element.getClientRects()
+ clientRects = ({
+ top: clientRect.top, right: clientRect.right, bottom: clientRect.bottom, left: clientRect.left,
+ width: clientRect.width, height: clientRect.height
+ } for clientRect in element.getClientRects())
for clientRect in clientRects
- if (clientRect.top < -2 || clientRect.top >= window.innerHeight - 4 ||
- clientRect.left < -2 || clientRect.left >= window.innerWidth - 4)
+ if (clientRect.top < 0)
+ clientRect.height += clientRect.top
+ clientRect.top = 0
+
+ if (clientRect.left < 0)
+ clientRect.width += clientRect.left
+ clientRect.left = 0
+
+ if (clientRect.top >= window.innerHeight - 4 || clientRect.left >= window.innerWidth - 4)
continue
if (clientRect.width < 3 || clientRect.height < 3)
@@ -99,8 +109,8 @@ DomUtils =
eventSequence = ["mouseover", "mousedown", "mouseup", "click"]
for event in eventSequence
mouseEvent = document.createEvent("MouseEvents")
- mouseEvent.initMouseEvent(event, true, true, window, 1, 0, 0, 0, 0, modifiers.ctrlKey, false, false,
- modifiers.metaKey, 0, null)
+ mouseEvent.initMouseEvent(event, true, true, window, 1, 0, 0, 0, 0, modifiers.ctrlKey, modifiers.altKey,
+ modifiers.shiftKey, modifiers.metaKey, 0, null)
# Debugging note: Firefox will not execute the element's default action if we dispatch this click event,
# but Webkit will. Dispatching a click on an input box does not seem to focus it; we do that separately
element.dispatchEvent(mouseEvent)
diff --git a/lib/keyboard_utils.coffee b/lib/keyboard_utils.coffee
index df5bbbad..d2a843f9 100644
--- a/lib/keyboard_utils.coffee
+++ b/lib/keyboard_utils.coffee
@@ -1,6 +1,7 @@
KeyboardUtils =
keyCodes:
- { ESC: 27, backspace: 8, deleteKey: 46, enter: 13, space: 32, shiftKey: 16, f1: 112, f12: 123, tab: 9 }
+ { ESC: 27, backspace: 8, deleteKey: 46, enter: 13, space: 32, shiftKey: 16, ctrlKey: 17, f1: 112,
+ f12: 123, tab: 9 }
keyNames:
{ 37: "left", 38: "up", 39: "right", 40: "down" }
diff --git a/lib/utils.coffee b/lib/utils.coffee
index 8d588a43..a93831d7 100644
--- a/lib/utils.coffee
+++ b/lib/utils.coffee
@@ -26,7 +26,7 @@ Utils =
-> id += 1
hasChromePrefix: (url) ->
- chromePrefixes = [ 'about', 'view-source', "chrome-extension" ]
+ chromePrefixes = [ "about", "view-source", "chrome-extension", "data" ]
for prefix in chromePrefixes
return true if url.startsWith prefix
false