From 94cfcc5de7275c4c2774941088a2cc24ae98ef0b Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 3 Apr 2016 07:24:07 +0100 Subject: Freeze frame state on link-hint activation. We take a copy of the frame Ids and ports at the point which link-hints mode is launched, and use that subsequently. Therefore, a newly created frame cannot cause the hint coordinator to become confused. Also: add debugging code. --- content_scripts/link_hints.coffee | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'content_scripts') diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 910e65f1..adbd758c 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -50,14 +50,17 @@ availableModes = [OPEN_IN_CURRENT_TAB, OPEN_IN_NEW_BG_TAB, OPEN_IN_NEW_FG_TAB, O OPEN_INCOGNITO, DOWNLOAD_LINK_URL] HintCoordinator = + debug: false onExit: [] localHints: null suppressKeyboardEvents: null sendMessage: (messageType, request = {}) -> + console.log "sendMessage", frameId, "[#{messageType}]" if @debug Frame.postMessage "linkHintsMessage", extend request, {messageType} prepareToActivateMode: (mode, onExit) -> + console.log "prepareToActivateMode", frameId if @debug # We need to communicate with the background page (and other frames) to initiate link-hints mode. To # prevent other Vimium commands from being triggered before link-hints mode is launched, we install a # temporary mode to block keyboard events. @@ -70,9 +73,11 @@ HintCoordinator = @sendMessage "prepareToActivateMode", modeIndex: availableModes.indexOf mode getHintDescriptors: -> + console.log "getHintDescriptors", frameId if @debug # Ensure that the settings are loaded. The request might have been initiated in another frame. Settings.onLoaded => @localHints = LocalHints.getLocalHints() + console.log "getHintDescriptors", frameId, "[#{@localHints.length}]" if @debug @sendMessage "postHintDescriptors", hintDescriptors: @localHints.map ({rect, linkText, showLinkText, hasHref, reason}, localIndex) -> {rect, linkText, showLinkText, hasHref, reason, frameId, localIndex} @@ -81,6 +86,7 @@ HintCoordinator = # We also propagate the key state between frames. Therefore, the hint-selection process proceeds in lock # step in every frame, and @linkHintsMode is in the same state in every frame. activateMode: ({hintDescriptors, modeIndex, originatingFrameId}) -> + console.log "activateMode", frameId if @debug @suppressKeyboardEvents?.exit() if @suppressKeyboardEvents?.modeIsActive @suppressKeyboardEvents = null # Ensure that the settings are loaded. The request might have been initiated in another frame. @@ -95,6 +101,7 @@ HintCoordinator = getLocalHintMarker: (hint) -> if hint.frameId == frameId then @localHints[hint.localIndex] else null exit: ({isSuccess}) -> + console.log "exit", frameId, "[#{isSuccess}]" if @debug @linkHintsMode.deactivateMode() @onExit.pop() isSuccess while 0 < @onExit.length @linkHintsMode = @localHints = null -- cgit v1.2.3