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"/> <parameter name="fn"/>
<body> <body>
<![CDATA[ <![CDATA[
this.inLoadURI = true; if (!this.isRemoteBrowser) {
try { this.inLoadURI = true;
try {
fn();
} finally {
this.inLoadURI = false;
}
} else {
fn(); fn();
} finally {
this.inLoadURI = false;
} }
]]> ]]>
</body> </body>
@ -296,7 +300,7 @@
<method name="preserveLayers"> <method name="preserveLayers">
<parameter name="preserve"/> <parameter name="preserve"/>
<body> <body>
<!-- Only useful for remote browsers. --> // Only useful for remote browsers.
</body> </body>
</method> </method>
@ -327,9 +331,8 @@
</getter> </getter>
</property> </property>
<!-- stubbed to false until all callers are removed -->
<property name="isRemoteBrowser" <property name="isRemoteBrowser"
onget="return false;" onget="return (this.getAttribute('remote') == 'true');"
readonly="true"/> readonly="true"/>
<property name="messageManager" <property name="messageManager"
@ -910,7 +913,7 @@
os.addObserver(this, "browser:purge-session-history", true); os.addObserver(this, "browser:purge-session-history", true);
// enable global history if we weren't told otherwise // enable global history if we weren't told otherwise
if (!this.hasAttribute("disableglobalhistory")) { if (!this.hasAttribute("disableglobalhistory") && !this.isRemoteBrowser) {
try { try {
this.docShell.useGlobalHistory = true; this.docShell.useGlobalHistory = true;
} catch (ex) { } catch (ex) {
@ -939,7 +942,9 @@
this.relatedBrowser = relatedBrowser; this.relatedBrowser = relatedBrowser;
} }
this.addEventListener("pagehide", this.onPageHide, true); if (!this.isRemoteBrowser) {
this.addEventListener("pagehide", this.onPageHide, true);
}
if (this.messageManager) { if (this.messageManager) {
this.messageManager.addMessageListener("PopupBlocking:UpdateBlockedPopups", this); this.messageManager.addMessageListener("PopupBlocking:UpdateBlockedPopups", this);
@ -988,7 +993,9 @@
this.lastURI = null; this.lastURI = null;
this.removeEventListener("pagehide", this.onPageHide, true); if (!this.isRemoteBrowser) {
this.removeEventListener("pagehide", this.onPageHide, true);
}
if (this._autoScrollNeedsCleanup) { if (this._autoScrollNeedsCleanup) {
// we polluted the global scope, so clean it up // we polluted the global scope, so clean it up
@ -1274,6 +1281,9 @@
<parameter name="aOtherBrowser"/> <parameter name="aOtherBrowser"/>
<body> <body>
<![CDATA[ <![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. // Give others a chance to swap state.
// IMPORTANT: Since a swapDocShells call does not swap the messageManager // IMPORTANT: Since a swapDocShells call does not swap the messageManager
// instances attached to a browser to aOtherBrowser, others // instances attached to a browser to aOtherBrowser, others
@ -1307,6 +1317,28 @@
"_webNavigation" "_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 ourFieldValues = {};
var otherFieldValues = {}; var otherFieldValues = {};
for (let field of fieldsToSwap) { for (let field of fieldsToSwap) {
@ -1329,10 +1361,27 @@
aOtherBrowser[field] = ourFieldValues[field]; aOtherBrowser[field] = ourFieldValues[field];
} }
// Null the current nsITypeAheadFind instances so that they're if (!this.isRemoteBrowser) {
// lazily re-created on access. We need to do this because they // Null the current nsITypeAheadFind instances so that they're
// might have attached the wrong docShell. // lazily re-created on access. We need to do this because they
this._fastFind = aOtherBrowser._fastFind = null; // 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}); event = new CustomEvent("EndSwapDocShells", {"detail": aOtherBrowser});
this.dispatchEvent(event); this.dispatchEvent(event);
@ -1474,6 +1523,11 @@
event.preventDefault(); 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"]. let linkHandler = Components.classes["@mozilla.org/content/dropped-link-handler;1"].
getService(Components.interfaces.nsIDroppedLinkHandler); getService(Components.interfaces.nsIDroppedLinkHandler);
if (linkHandler.canDropLink(event, false)) if (linkHandler.canDropLink(event, false))
@ -1482,7 +1536,9 @@
</handler> </handler>
<handler event="drop" group="system"> <handler event="drop" group="system">
<![CDATA[ <![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; return;
let name = { }; let name = { };