aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-03-10 09:14:20 +0000
committerStephen Blott2016-03-28 05:40:09 +0100
commit8b19dfcf3bc4fbc0c426f057a4481bd699c09f72 (patch)
tree16226a7891b7a14bbf126b47c17c9c0e0480fb54
parent3539ad89382c02bf2f89d890b86e49409059391f (diff)
downloadvimium-8b19dfcf3bc4fbc0c426f057a4481bd699c09f72.tar.bz2
Separate ClickableElements functions from LinkHintsMode.
Really, all of the code related to finding clickable elements is unrelated to LinkHintsMode. Unfortunately, it's embedded in the middle of the class. So, we can't use it from outside of the class. This is a temporary restructuring of the link-hints code. The intention is to move the lines around eventually. For now, however, we do it like this to keep the diff smaller and clearer.
-rw-r--r--content_scripts/link_hints.coffee12
1 files changed, 10 insertions, 2 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 6f99d970..ec57f74a 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -65,7 +65,7 @@ LinkHints =
activateModeToOpenIncognito: (count) -> @activateMode count, OPEN_INCOGNITO
activateModeToDownloadLink: (count) -> @activateMode count, DOWNLOAD_LINK_URL
-class LinkHintsMode
+class LinkHintsModeBase
hintMarkerContainingDiv: null
# One of the enums listed at the top of this file.
mode: undefined
@@ -80,7 +80,7 @@ class LinkHintsMode
# we need documentElement to be ready in order to append links
return unless document.documentElement
- elements = @getVisibleClickableElements()
+ elements = ClickableElements.getVisibleClickableElements()
# For these modes, we filter out those elements which don't have an HREF (since there's nothing we can do
# with them).
elements = (el for el in elements when el.element.href?) if mode in [ COPY_LINK_URL, OPEN_INCOGNITO ]
@@ -146,6 +146,9 @@ class LinkHintsMode
marker
+# TODO(smblott) It is not intended that the code remain structured this way. This a temporary in order to
+# keep the diff smaller and clearer. Basically, we need to move a lot of lines around.
+ClickableElements =
#
# Determine whether the element is visible and clickable. If it is, find the rect bounding the element in
# the viewport. There may be more than one part of element which is clickable (for example, if it's an
@@ -287,6 +290,11 @@ class LinkHintsMode
nonOverlappingElements
+# TODO(smblott) It is not intended that the code remain structured this way. This a temporary in order to
+# keep the diff smaller and clearer. Basically, we need to move a lot of lines around.
+class LinkHintsMode extends LinkHintsModeBase
+ constructor: (args...) -> super args...
+
# Handles <Shift> and <Ctrl>.
onKeyDownInMode: (hintMarkers, event) ->
return if event.repeat