From 4eb240f50c259cb7a1b6eaa3f2a487a816101274 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sun, 24 Apr 2016 12:01:52 +0200 Subject: [PATCH] Improve "open link in new tab" interoperability When opening a link in a new tab, such as when using the `F` or `gf` commands, we now try to closely mimic what Firefox does when you click links using the mouse, instead of directly using `gBrowser.loadOneTab(url, options)`. This provides interoperability with the BackTrack Tab History add-on, which fixes #720, and allows to remove Tree Style Tab-specific code. --- extension/lib/commands.coffee | 18 ++++++++++++++---- extension/lib/utils.coffee | 6 ------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/extension/lib/commands.coffee b/extension/lib/commands.coffee index a664382..c88ce72 100644 --- a/extension/lib/commands.coffee +++ b/extension/lib/commands.coffee @@ -33,6 +33,8 @@ prefs = require('./prefs') translate = require('./l10n') utils = require('./utils') +{ContentClick} = Cu.import('resource:///modules/ContentClick.jsm', {}) + commands = {} @@ -466,10 +468,18 @@ helper_follow_clickable = (options, {vim, count = 1}) -> if inTab utils.nextTick(vim.window, -> - utils.openTab(vim.window, marker.wrapper.href, { - inBackground - relatedToCurrent: true - }) + # `ContentClick.contentAreaClick` is what Firefox invokes when you click + # links using the mouse. Using that instead of simply + # `gBrowser.loadOneTab(url, options)` gives better interoperability with + # other add-ons, such as Tree Style Tab and BackTrack Tab History. + reset = prefs.root.tmp('browser.tabs.loadInBackground', true) + ContentClick.contentAreaClick({ + href: marker.wrapper.href + shiftKey: not inBackground + ctrlKey: true + metaKey: true + }, vim.browser) + reset() ) else vim._run('click_marker_element', { diff --git a/extension/lib/utils.coffee b/extension/lib/utils.coffee index a417f34..5c955b6 100644 --- a/extension/lib/utils.coffee +++ b/extension/lib/utils.coffee @@ -616,11 +616,6 @@ openPopup = (popup) -> window.screenY + window.outerHeight / 2 - popup.clientHeight / 2 ) -openTab = (window, url, options) -> - {gBrowser} = window - window.TreeStyleTabService?.readyToOpenChildTab(gBrowser.selectedTab) - gBrowser.loadOneTab(url, options) - writeToClipboard = (text) -> nsIClipboardHelper.copyString(text) @@ -683,6 +678,5 @@ module.exports = { loadCss observe openPopup - openTab writeToClipboard } -- 2.39.3