Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Merge mozilla-central to mozilla-inbound
Browse files Browse the repository at this point in the history
  • Loading branch information
BavarianTomcat committed Feb 11, 2016
2 parents 10c0856 + bbe3d01 commit b1eedbe
Show file tree
Hide file tree
Showing 120 changed files with 3,149 additions and 2,200 deletions.
2 changes: 1 addition & 1 deletion browser/base/content/abouthome/aboutHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ function showDefaultSnippets()
}

function fitToWidth() {
if (window.scrollMaxX != window.scrollMinX) {
if (document.documentElement.scrollWidth > window.innerWidth) {
document.body.setAttribute("narrow", "true");
} else if (document.body.hasAttribute("narrow")) {
document.body.removeAttribute("narrow");
Expand Down
3 changes: 3 additions & 0 deletions browser/base/content/nsContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ nsContextMenu.prototype = {
return;

this.hasPageMenu = false;
this.isContentSelected = !this.selectionInfo.docSelectionIsCollapsed;
if (!aIsShift) {
if (this.isRemote) {
this.hasPageMenu =
Expand Down Expand Up @@ -71,6 +72,8 @@ nsContextMenu.prototype = {
Ci.nsIPrefLocalizedString).data;
} catch (e) { }

// Reset after "on-build-contextmenu" notification in case selection was
// changed during the notification.
this.isContentSelected = !this.selectionInfo.docSelectionIsCollapsed;
this.onPlainTextLink = false;

Expand Down
92 changes: 57 additions & 35 deletions browser/base/content/tabbrowser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2936,6 +2936,62 @@
</body>
</method>

<!-- Adopts a tab from another browser window, and inserts it at aIndex -->
<method name="adoptTab">
<parameter name="aTab"/>
<parameter name="aIndex"/>
<parameter name="aSelectTab"/>
<body>
<![CDATA[
// Swap the dropped tab with a new one we create and then close
// it in the other window (making it seem to have moved between
// windows).
let newTab = this.addTab("about:blank");
let newBrowser = this.getBrowserForTab(newTab);
let newURL = aTab.linkedBrowser.currentURI.spec;
// If we're an e10s browser window, an exception will be thrown
// if we attempt to drag a non-remote browser in, so we need to
// ensure that the remoteness of the newly created browser is
// appropriate for the URL of the tab being dragged in.
this.updateBrowserRemotenessByURL(newBrowser, newURL);
// Stop the about:blank load.
newBrowser.stop();
// Make sure it has a docshell.
newBrowser.docShell;
let numPinned = this._numPinnedTabs;
if (aIndex < numPinned || (aTab.pinned && aIndex == numPinned)) {
this.pinTab(newTab);
}
this.moveTabTo(newTab, aIndex);
// We need to select the tab before calling swapBrowsersAndCloseOther
// so that window.content in chrome windows points to the right tab
// when pagehide/show events are fired. This is no longer necessary
// for any exiting browser code, but it may be necessary for add-on
// compatibility.
if (aSelectTab) {
this.selectedTab = newTab;
}
aTab.parentNode._finishAnimateTabMove();
this.swapBrowsersAndCloseOther(newTab, aTab);
if (aSelectTab) {
// Call updateCurrentBrowser to make sure the URL bar is up to date
// for our new tab after we've done swapBrowsersAndCloseOther.
this.updateCurrentBrowser(true);
}
return newTab;
]]>
</body>
</method>


<method name="moveTabBackward">
<body>
<![CDATA[
Expand Down Expand Up @@ -5791,42 +5847,8 @@
this.tabbrowser.moveTabTo(draggedTab, newIndex);
}
} else if (draggedTab) {
// swap the dropped tab with a new one we create and then close
// it in the other window (making it seem to have moved between
// windows)
let newIndex = this._getDropIndex(event, false);
let newTab = this.tabbrowser.addTab("about:blank");
let newBrowser = this.tabbrowser.getBrowserForTab(newTab);
let draggedBrowserURL = draggedTab.linkedBrowser.currentURI.spec;
// If we're an e10s browser window, an exception will be thrown
// if we attempt to drag a non-remote browser in, so we need to
// ensure that the remoteness of the newly created browser is
// appropriate for the URL of the tab being dragged in.
this.tabbrowser.updateBrowserRemotenessByURL(newBrowser,
draggedBrowserURL);
// Stop the about:blank load
newBrowser.stop();
// make sure it has a docshell
newBrowser.docShell;
let numPinned = this.tabbrowser._numPinnedTabs;
if (newIndex < numPinned || draggedTab.pinned && newIndex == numPinned)
this.tabbrowser.pinTab(newTab);
this.tabbrowser.moveTabTo(newTab, newIndex);
// We need to select the tab before calling swapBrowsersAndCloseOther
// so that window.content in chrome windows points to the right tab
// when pagehide/show events are fired.
this.tabbrowser.selectedTab = newTab;
draggedTab.parentNode._finishAnimateTabMove();
this.tabbrowser.swapBrowsersAndCloseOther(newTab, draggedTab);
// Call updateCurrentBrowser to make sure the URL bar is up to date
// for our new tab after we've done swapBrowsersAndCloseOther.
this.tabbrowser.updateCurrentBrowser(true);
this.tabbrowser.adoptTab(draggedTab, newIndex, true);
} else {
// Pass true to disallow dropping javascript: or data: urls
let url;
Expand Down
1 change: 1 addition & 0 deletions browser/base/content/test/general/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ support-files =
skip-if = os == "linux" # Bug 924307
[browser_aboutHome.js]
skip-if = e10s # Bug 1093153 - no about:home support yet
[browser_aboutHome_wrapsCorrectly.js]
[browser_action_keyword.js]
[browser_action_keyword_override.js]
[browser_action_searchengine.js]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
add_task(function* () {
let newWindow = yield BrowserTestUtils.openNewBrowserWindow();

let resizedPromise = BrowserTestUtils.waitForEvent(newWindow, "resize");
newWindow.resizeTo(300, 300);
yield resizedPromise;

yield BrowserTestUtils.openNewForegroundTab(newWindow.gBrowser, "about:home");

yield ContentTask.spawn(newWindow.gBrowser.selectedBrowser, {}, function* () {
is(content.document.body.getAttribute("narrow"), "true", "narrow mode");
});

resizedPromise = BrowserTestUtils.waitForContentEvent(newWindow.gBrowser.selectedBrowser, "resize");


yield ContentTask.spawn(newWindow.gBrowser.selectedBrowser, {}, function* () {
content.window.resizeTo(800, 800);
});

yield resizedPromise;

yield ContentTask.spawn(newWindow.gBrowser.selectedBrowser, {}, function* () {
is(content.document.body.hasAttribute("narrow"), false, "non-narrow mode");
});

yield BrowserTestUtils.closeWindow(newWindow);
});
44 changes: 20 additions & 24 deletions browser/components/customizableui/CustomizableWidgets.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const CustomizableWidgets = [
let items = doc.getElementById("PanelUI-historyItems");
// Clear previous history items.
while (items.firstChild) {
items.removeChild(items.firstChild);
items.firstChild.remove();
}

// Get all statically placed buttons to supply them with keyboard shortcuts.
Expand All @@ -205,32 +205,28 @@ const CustomizableWidgets = [
PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
.asyncExecuteLegacyQueries([query], 1, options, {
handleResult: function (aResultSet) {
let onHistoryVisit = function (aUri, aEvent, aItem) {
doc.defaultView.openUILink(aUri, aEvent);
CustomizableUI.hidePanelForNode(aItem);
let onItemClick = function (aEvent) {
let item = aEvent.target;
win.openUILink(item.getAttribute("targetURI"), aEvent);
CustomizableUI.hidePanelForNode(item);
};
let fragment = doc.createDocumentFragment();
for (let row, i = 0; (row = aResultSet.getNextRow()); i++) {
try {
let uri = row.getResultByIndex(1);
let title = row.getResultByIndex(2);
let icon = row.getResultByIndex(6);

let item = doc.createElementNS(kNSXUL, "toolbarbutton");
item.setAttribute("label", title || uri);
item.setAttribute("targetURI", uri);
item.setAttribute("class", "subviewbutton");
item.addEventListener("click", function (aEvent) {
onHistoryVisit(uri, aEvent, item);
});
if (icon) {
let iconURL = "moz-anno:favicon:" + icon;
item.setAttribute("image", iconURL);
}
fragment.appendChild(item);
} catch (e) {
log.error("Error while showing history subview: " + e);
let row;
while ((row = aResultSet.getNextRow())) {
let uri = row.getResultByIndex(1);
let title = row.getResultByIndex(2);
let icon = row.getResultByIndex(6);

let item = doc.createElementNS(kNSXUL, "toolbarbutton");
item.setAttribute("label", title || uri);
item.setAttribute("targetURI", uri);
item.setAttribute("class", "subviewbutton");
item.addEventListener("click", onItemClick);
if (icon) {
let iconURL = "moz-anno:favicon:" + icon;
item.setAttribute("image", iconURL);
}
fragment.appendChild(item);
}
items.appendChild(fragment);
},
Expand Down
10 changes: 10 additions & 0 deletions browser/components/extensions/ext-desktop-runtime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use strict";

/* eslint-disable mozilla/balanced-listeners */
extensions.on("uninstall", (msg, extension) => {
if (extension.uninstallURL) {
let browser = Services.wm.getMostRecentWindow("navigator:browser").gBrowser;
browser.addTab(extension.uninstallURL, { relatedToCurrent: true });
}
});

48 changes: 20 additions & 28 deletions browser/components/extensions/ext-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,41 +613,33 @@ extensions.registerSchemaAPI("tabs", null, (extension, context) => {

// If the window is not specified, use the window from the tab.
let window = destinationWindow || tab.ownerDocument.defaultView;
let windowId = WindowManager.getId(window);
let gBrowser = window.gBrowser;

let getInsertionPoint = () => {
let point = indexMap.get(window) || index;
// If the index is -1 it should go to the end of the tabs.
if (point == -1) {
point = gBrowser.tabs.length;
}
indexMap.set(window, point + 1);
return point;
};
let insertionPoint = indexMap.get(window) || index;
// If the index is -1 it should go to the end of the tabs.
if (insertionPoint == -1) {
insertionPoint = gBrowser.tabs.length;
}

if (WindowManager.getId(tab.ownerDocument.defaultView) !== windowId) {
// If the window we are moving the tab in is different, then move the tab
// to the new window.
let newTab = gBrowser.addTab("about:blank");
let newBrowser = gBrowser.getBrowserForTab(newTab);
gBrowser.updateBrowserRemotenessByURL(newBrowser, tab.linkedBrowser.currentURI.spec);
newBrowser.stop();
// This is necessary for getter side-effects.
void newBrowser.docShell;

if (tab.pinned) {
gBrowser.pinTab(newTab);
}
// We can only move pinned tabs to a point within, or just after,
// the current set of pinned tabs. Unpinned tabs, likewise, can only
// be moved to a position after the current set of pinned tabs.
// Attempts to move a tab to an illegal position are ignored.
let numPinned = gBrowser._numPinnedTabs;
let ok = tab.pinned ? insertionPoint <= numPinned : insertionPoint >= numPinned;
if (!ok) {
continue;
}

gBrowser.moveTabTo(newTab, getInsertionPoint());
indexMap.set(window, insertionPoint + 1);

tab.parentNode._finishAnimateTabMove();
gBrowser.swapBrowsersAndCloseOther(newTab, tab);
tab = newTab;
if (tab.ownerDocument.defaultView !== window) {
// If the window we are moving the tab in is different, then move the tab
// to the new window.
tab = gBrowser.adoptTab(tab, insertionPoint, false);
} else {
// If the window we are moving is the same, just move the tab.
gBrowser.moveTabTo(tab, getInsertionPoint());
gBrowser.moveTabTo(tab, insertionPoint);
}
tabsMoved.push(tab);
}
Expand Down
1 change: 1 addition & 0 deletions browser/components/extensions/jar.mn
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ browser.jar:
content/browser/ext-contextMenus.js
content/browser/ext-browserAction.js
content/browser/ext-pageAction.js
content/browser/ext-desktop-runtime.js
content/browser/ext-tabs.js
content/browser/ext-windows.js
content/browser/ext-bookmarks.js
1 change: 1 addition & 0 deletions browser/components/extensions/test/browser/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ support-files =
[browser_ext_contextMenus.js]
[browser_ext_getViews.js]
[browser_ext_lastError.js]
[browser_ext_runtime_setUninstallURL.js]
[browser_ext_tabs_audio.js]
[browser_ext_tabs_captureVisibleTab.js]
[browser_ext_tabs_executeScript.js]
Expand Down
Loading

0 comments on commit b1eedbe

Please sign in to comment.