From 8b19dfcf3bc4fbc0c426f057a4481bd699c09f72 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Thu, 10 Mar 2016 09:14:20 +0000 Subject: 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. --- content_scripts/link_hints.coffee | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'content_scripts') 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 and . onKeyDownInMode: (hintMarkers, event) -> return if event.repeat -- cgit v1.2.3