From 28fcf32ce2dd434f8436657d248fab55ab9005be Mon Sep 17 00:00:00 2001 From: girst Date: Mon, 2 Dec 2019 15:36:43 +0100 Subject: [PATCH] replace imported ContentClick module with stub The module was replaced at the very end of the 72 cycle with ClickHandlerParent.jsm, which made contentAreaClick non-static. It would have been technically possible to just ship the old module with either VimFx or LegacFox, but since it is so small and it was replaced to support Fission, it seemed better to extract the relevant parts of the method and just inline them. We'll need to keep it up-to-date either way. Note that despite this we are _not_ fission compatible; when a 3rd-party iframe is present, hints mode breaks. Regressed by: Bug 1595155 --- extension/lib/commands.coffee | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/extension/lib/commands.coffee b/extension/lib/commands.coffee index a9ee19d..836ad62 100644 --- a/extension/lib/commands.coffee +++ b/extension/lib/commands.coffee @@ -16,7 +16,10 @@ translate = require('./translate') utils = require('./utils') viewportUtils = require('./viewport') -{ContentClick} = Cu.import('resource:///modules/ContentClick.jsm', {}) +{PlacesUIUtils} = Cu.import('resource:///modules/PlacesUIUtils.jsm', {}) +{PrivateBrowsingUtils} = + Cu.import('resource://gre/modules/PrivateBrowsingUtils.jsm', {}) +{E10SUtils} = Cu.import('resource://gre/modules/E10SUtils.jsm', {}) {FORWARD, BACKWARD} = SelectionManager READER_VIEW_PREFIX = 'about:reader?url=' @@ -532,13 +535,35 @@ helper_follow_clickable = (options, args) -> vim._focusMarkerElement(elementIndex) if inTab + contentAreaClick = (json, browser) -> + # Note this function is shortened from the same-named one currently in + # mozilla-central/browser/actors/ClickHandlerParent.jsm. Keep in sync! + window = browser.ownerGlobal + params = { + charset: browser.characterSet, + referrerInfo: E10SUtils.deserializeReferrerInfo(json.referrerInfo), + allowMixedContent: json.allowMixedContent, + isContentWindowPrivate: json.isContentWindowPrivate, + originPrincipal: json.originPrincipal, + originStoragePrincipal: json.originStoragePrincipal, + triggeringPrincipal: json.triggeringPrincipal, + csp: if json.csp then E10SUtils.deserializeCSP(json.csp) else null, + frameOuterWindowID: json.frameOuterWindowID, + allowInheritPrincipal: true, + } + if json.originAttributes.userContextId + params.userContextId = json.originAttributes.userContextId + try if not PrivateBrowsingUtils.isWindowPrivate(window) + PlacesUIUtils.markPageAsFollowedLink(json.href) + window.openLinkIn(json.href, window.whereToOpenLink(json), params) + utils.nextTick(window, -> # `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({ + contentAreaClick({ href: marker.wrapper.href shiftKey: not inBackground ctrlKey: true -- 2.39.3