revert "Remove e10s code from browser widget. (083d322b7)" to keep e10s useful.

This commit is contained in:
Roy Tam 2019-06-15 10:16:21 +08:00
commit ef715102e7

View file

@ -36,11 +36,15 @@
<parameter name="fn"/>
<body>
<![CDATA[
this.inLoadURI = true;
try {
if (!this.isRemoteBrowser) {
this.inLoadURI = true;
try {
fn();
} finally {
this.inLoadURI = false;
}
} else {
fn();
} finally {
this.inLoadURI = false;
}
]]>
</body>
@ -296,7 +300,7 @@
<method name="preserveLayers">
<parameter name="preserve"/>
<body>
<!-- Only useful for remote browsers. -->
// Only useful for remote browsers.
</body>
</method>
@ -327,9 +331,8 @@
</getter>
</property>
<!-- stubbed to false until all callers are removed -->
<property name="isRemoteBrowser"
onget="return false;"
onget="return (this.getAttribute('remote') == 'true');"
readonly="true"/>
<property name="messageManager"
@ -910,7 +913,7 @@
os.addObserver(this, "browser:purge-session-history", true);
// enable global history if we weren't told otherwise
if (!this.hasAttribute("disableglobalhistory")) {
if (!this.hasAttribute("disableglobalhistory") && !this.isRemoteBrowser) {
try {
this.docShell.useGlobalHistory = true;
} catch (ex) {
@ -939,7 +942,9 @@
this.relatedBrowser = relatedBrowser;
}
this.addEventListener("pagehide", this.onPageHide, true);
if (!this.isRemoteBrowser) {
this.addEventListener("pagehide", this.onPageHide, true);
}
if (this.messageManager) {
this.messageManager.addMessageListener("PopupBlocking:UpdateBlockedPopups", this);
@ -988,7 +993,9 @@
this.lastURI = null;
this.removeEventListener("pagehide", this.onPageHide, true);
if (!this.isRemoteBrowser) {
this.removeEventListener("pagehide", this.onPageHide, true);
}
if (this._autoScrollNeedsCleanup) {
// we polluted the global scope, so clean it up
@ -1274,6 +1281,9 @@
<parameter name="aOtherBrowser"/>
<body>
<![CDATA[
if (this.isRemoteBrowser != aOtherBrowser.isRemoteBrowser)
throw new Error("Can only swap docshells between browsers in the same process.");
// Give others a chance to swap state.
// IMPORTANT: Since a swapDocShells call does not swap the messageManager
// instances attached to a browser to aOtherBrowser, others
@ -1307,6 +1317,28 @@
"_webNavigation"
];
if (this.isRemoteBrowser) {
fieldsToSwap.push(...[
"_remoteWebNavigation",
"_remoteWebNavigationImpl",
"_remoteWebProgressManager",
"_remoteWebProgress",
"_remoteFinder",
"_securityUI",
"_documentURI",
"_documentContentType",
"_contentTitle",
"_characterSet",
"_contentPrincipal",
"_imageDocument",
"_fullZoom",
"_textZoom",
"_isSyntheticDocument",
"_innerWindowID",
"_manifestURI",
]);
}
var ourFieldValues = {};
var otherFieldValues = {};
for (let field of fieldsToSwap) {
@ -1329,10 +1361,27 @@
aOtherBrowser[field] = ourFieldValues[field];
}
// Null the current nsITypeAheadFind instances so that they're
// lazily re-created on access. We need to do this because they
// might have attached the wrong docShell.
this._fastFind = aOtherBrowser._fastFind = null;
if (!this.isRemoteBrowser) {
// Null the current nsITypeAheadFind instances so that they're
// lazily re-created on access. We need to do this because they
// might have attached the wrong docShell.
this._fastFind = aOtherBrowser._fastFind = null;
}
else {
// Rewire the remote listeners
this._remoteWebNavigationImpl.swapBrowser(this);
aOtherBrowser._remoteWebNavigationImpl.swapBrowser(aOtherBrowser);
if (this._remoteWebProgressManager && aOtherBrowser._remoteWebProgressManager) {
this._remoteWebProgressManager.swapBrowser(this);
aOtherBrowser._remoteWebProgressManager.swapBrowser(aOtherBrowser);
}
if (this._remoteFinder)
this._remoteFinder.swapBrowser(this);
if (aOtherBrowser._remoteFinder)
aOtherBrowser._remoteFinder.swapBrowser(aOtherBrowser);
}
event = new CustomEvent("EndSwapDocShells", {"detail": aOtherBrowser});
this.dispatchEvent(event);
@ -1474,6 +1523,11 @@
event.preventDefault();
}
// No need to handle "dragover" in e10s, since nsDocShellTreeOwner.cpp in the child process
// handles that case using "@mozilla.org/content/dropped-link-handler;1" service.
if (this.isRemoteBrowser)
return;
let linkHandler = Components.classes["@mozilla.org/content/dropped-link-handler;1"].
getService(Components.interfaces.nsIDroppedLinkHandler);
if (linkHandler.canDropLink(event, false))
@ -1482,7 +1536,9 @@
</handler>
<handler event="drop" group="system">
<![CDATA[
if (!this.droppedLinkHandler || event.defaultPrevented)
// No need to handle "drop" in e10s, since nsDocShellTreeOwner.cpp in the child process
// handles that case using "@mozilla.org/content/dropped-link-handler;1" service.
if (!this.droppedLinkHandler || event.defaultPrevented || this.isRemoteBrowser)
return;
let name = { };