Bug 92737 - Part 4: Open multiple tabs when multiple items are dropped on tab

+ Follow up:
Bug 92737 - Part 3: Open multiple tabs when multiple items are dropped
on remote content area
- browser.js: "usercontextid" (default: 0)
This commit is contained in:
janekptacijarabaci 2018-04-15 11:43:52 +02:00 • committed by Roy Tam
commit eaf424b1c9
2 changed files with 21 additions and 25 deletions

View file

@ -5124,7 +5124,8 @@ function handleDroppedLink(event, urlOrLinks, name)
let lastLocationChange = gBrowser.selectedBrowser.lastLocationChange; let lastLocationChange = gBrowser.selectedBrowser.lastLocationChange;
let userContextId = gBrowser.selectedBrowser.getAttribute("usercontextid"); let userContextId = gBrowser.selectedBrowser
.getAttribute("usercontextid") || 0;
let inBackground = Services.prefs.getBoolPref("browser.tabs.loadInBackground"); let inBackground = Services.prefs.getBoolPref("browser.tabs.loadInBackground");
if (event.shiftKey) if (event.shiftKey)

View file

@ -4507,40 +4507,35 @@
this.tabbrowser.updateCurrentBrowser(true); this.tabbrowser.updateCurrentBrowser(true);
} else { } else {
// Pass true to disallow dropping javascript: or data: urls // Pass true to disallow dropping javascript: or data: urls
let url; let links;
try { try {
url = browserDragAndDrop.drop(event, { }, true); links = browserDragAndDrop.dropLinks(event, true);
} catch (ex) {} } catch (ex) {}
// // valid urls don't contain spaces ' '; if we have a space it isn't a valid url. // // valid urls don't contain spaces ' '; if we have a space it isn't a valid url.
// if (!url || url.includes(" ")) //PMed // if (!url || url.includes(" ")) //PMed
if (!url) //FF if (!links || links.length === 0) //FF
return; return;
let bgLoad = Services.prefs.getBoolPref("browser.tabs.loadInBackground"); let inBackground = Services.prefs.getBoolPref("browser.tabs.loadInBackground");
if (event.shiftKey) if (event.shiftKey)
bgLoad = !bgLoad; inBackground = !inBackground;
let tab = this._getDragTargetTab(event); let targetTab = this._getDragTargetTab(event);
if (!tab || dropEffect == "copy") { let userContextId = this.selectedItem
// We're adding a new tab. .getAttribute("usercontextid") || 0;
let newIndex = this._getDropIndex(event); let replace = !(!tab || dropEffect == "copy");
let newTab = this.tabbrowser.loadOneTab(url, {inBackground: bgLoad, allowThirdPartyFixup: true}); let newIndex = this._getDropIndex(event);
this.tabbrowser.moveTabTo(newTab, newIndex); let urls = links.map(link => link.url);
} else { this.tabbrowser.loadTabs(urls, {
// Load in an existing tab. inBackground,
try { replace,
let webNav = Ci.nsIWebNavigation; allowThirdPartyFixup: true,
let flags = webNav.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP | targetTab,
webNav.LOAD_FLAGS_FIXUP_SCHEME_TYPOS; newIndex,
this.tabbrowser.getBrowserForTab(tab).loadURIWithFlags(url, flags); userContextId,
if (!bgLoad) });
this.selectedItem = tab;
} catch(ex) {
// Just ignore invalid urls
}
}
} }
if (draggedTab) { if (draggedTab) {