mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
Bug 263433 - 'text-link' XUL widget should open tabs rather than windows. r=enn
--HG-- extra : rebase_source : aab45840ef599a15d491d5548fdfd3fd19a738c4
This commit is contained in:
parent
2c59cbb336
commit
9b436bde67
@ -281,6 +281,16 @@ BrowserGlue.prototype = {
|
||||
case "initial-migration-did-import-default-bookmarks":
|
||||
this._initPlaces(true);
|
||||
break;
|
||||
case "handle-xul-text-link":
|
||||
let linkHandled = subject.QueryInterface(Ci.nsISupportsPRBool);
|
||||
if (!linkHandled.data) {
|
||||
let win = this.getMostRecentBrowserWindow();
|
||||
if (win) {
|
||||
win.openUILinkIn(data, "tab");
|
||||
linkHandled.data = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@ -312,6 +322,7 @@ BrowserGlue.prototype = {
|
||||
os.addObserver(this, "places-shutdown", false);
|
||||
this._isPlacesShutdownObserver = true;
|
||||
os.addObserver(this, "defaultURIFixup-using-keyword-pref", false);
|
||||
os.addObserver(this, "handle-xul-text-link", false);
|
||||
},
|
||||
|
||||
// cleanup (called on application shutdown)
|
||||
@ -342,6 +353,7 @@ BrowserGlue.prototype = {
|
||||
if (this._isPlacesShutdownObserver)
|
||||
os.removeObserver(this, "places-shutdown");
|
||||
os.removeObserver(this, "defaultURIFixup-using-keyword-pref");
|
||||
os.removeObserver(this, "handle-xul-text-link");
|
||||
UserAgentOverrides.uninit();
|
||||
webappsUI.uninit();
|
||||
SignInToWebsiteUX.uninit();
|
||||
|
@ -350,19 +350,27 @@
|
||||
Components.utils.reportError(ex);
|
||||
}
|
||||
|
||||
aEvent.preventDefault();
|
||||
href = uri ? uri.spec : href;
|
||||
|
||||
// Try handing off the link to the host application, e.g. for
|
||||
// opening it in a tabbed browser.
|
||||
var linkHandled = Components.classes["@mozilla.org/supports-PRBool;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsPRBool);
|
||||
linkHandled.data = false;
|
||||
Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService)
|
||||
.notifyObservers(linkHandled, "handle-xul-text-link", href);
|
||||
if (linkHandled.data)
|
||||
return;
|
||||
|
||||
// otherwise, fall back to opening the anchor directly
|
||||
var win = window;
|
||||
if (window instanceof Components.interfaces.nsIDOMChromeWindow) {
|
||||
while (win.opener && !win.opener.closed)
|
||||
win = win.opener;
|
||||
}
|
||||
|
||||
if (uri)
|
||||
win.open(uri.spec);
|
||||
else
|
||||
win.open(href);
|
||||
|
||||
aEvent.preventDefault();
|
||||
win.open(href);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
Loading…
Reference in New Issue
Block a user