Bug 589337 - Set css viewport to zero when tab is hidden. [r=stechz, a=b3+]
--- a/mobile/chrome/content/bindings/browser.js
+++ b/mobile/chrome/content/bindings/browser.js
@@ -364,8 +364,33 @@ let ContentScroll = {
break;
}
}
}
};
ContentScroll.init();
+let ContentActive = {
+ init: function() {
+ addMessageListener("Content:Activate", this);
+ addMessageListener("Content:Deactivate", this);
+ },
+
+ receiveMessage: function(aMessage) {
+ let json = aMessage.json;
+ switch (aMessage.name) {
+ case "Content:Activate":
+ let focusManager = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
+ focusManager.clearFocus(content);
+ docShell.isActive = false;
+ let utils = Util.getWindowUtils(content);
+ utils.setDisplayPort(0,0,0,0);
+ break;
+
+ case "Content:Deactivate":
+ docShell.isActive = true;
+ break;
+ }
+ }
+};
+
+ContentActive.init();
--- a/mobile/chrome/content/bindings/browser.xml
+++ b/mobile/chrome/content/bindings/browser.xml
@@ -584,16 +584,27 @@
<body><![CDATA[
if (this.contentWindowId != aNewId) {
this.contentWindowId = aNewId;
return true;
}
return false;
]]></body>
</method>
+
+ <field name="_active">false</field>
+ <property name="active" onget="return this._active;">
+ <setter>
+ this._active = val;
+ this.messageManager.sendAsyncMessage((val ? "Content:Activate" : "Content:Deactivate"), {});
+ if (val)
+ this._updateCacheViewport();
+ </setter>
+ </property>
+
</implementation>
</binding>
<binding id="remote-browser" extends="#local-browser">
<implementation type="application/javascript" implements="nsIAccessibleProvider, nsIObserver, nsIDOMEventListener, nsIFrameMessageListener">
<property name="accessibleType" readonly="true">
<getter>
<![CDATA[
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -2677,17 +2677,17 @@ Tab.prototype = {
return browser;
},
_destroyBrowser: function _destroyBrowser() {
if (this._browser) {
let notification = this._notification;
let browser = this._browser;
browser.removeProgressListener(this._listener);
- browser.messageManager.sendAsyncMessage("Browser:Blur", {});
+ browser.active = false;
this._notification = null;
this._browser = null;
this._listener = null;
this._loading = false;
Elements.browsers.removeChild(notification);
}
@@ -2783,22 +2783,22 @@ Tab.prototype = {
return;
let notification = this._notification;
let browser = this._browser;
if (aActive) {
browser.setAttribute("type", "content-primary");
Elements.browsers.selectedPanel = notification;
- browser.messageManager.sendAsyncMessage("Browser:Focus", {});
+ browser.active = true;
document.getElementById("tabs").selectedTab = this._chromeTab;
}
else {
browser.setAttribute("type", "content");
- browser.messageManager.sendAsyncMessage("Browser:Blur", {});
+ browser.active = false;
}
},
get active() {
if (!this._browser)
return false;
return this._browser.getAttribute("type") == "content-primary";
},
--- a/mobile/chrome/content/content.js
+++ b/mobile/chrome/content/content.js
@@ -281,18 +281,16 @@ ProgressController.prototype = {
.getInterface(Ci.nsIWebProgress);
webProgress.removeProgressListener(this);
}
};
/** Can't think of a good description of this class. It probably does too much? */
function Content() {
- addMessageListener("Browser:Blur", this);
- addMessageListener("Browser:Focus", this);
addMessageListener("Browser:KeyEvent", this);
addMessageListener("Browser:MouseDown", this);
addMessageListener("Browser:MouseUp", this);
addMessageListener("Browser:SaveAs", this);
addMessageListener("Browser:ZoomToPoint", this);
addMessageListener("Browser:MozApplicationCache:Fetch", this);
if (Util.isParentProcess())
@@ -363,27 +361,16 @@ Content.prototype = {
receiveMessage: function receiveMessage(aMessage) {
let json = aMessage.json;
let x = json.x;
let y = json.y;
let modifiers = json.modifiers;
switch (aMessage.name) {
- case "Browser:Blur": {
- gFocusManager.clearFocus(content);
- docShell.isActive = false;
- this._selected = false;
- break;
- }
- case "Browser:Focus":
- docShell.isActive = true;
- this._selected = true;
- break;
-
case "Browser:KeyEvent":
let utils = Util.getWindowUtils(content);
let defaultAction;
if (!Util.isParentProcess())
defaultAction = utils.sendKeyEvent(json.type, json.keyCode, json.charCode, modifiers);
if (defaultAction && json.type == "keypress") {
const masks = Ci.nsIDOMNSEvent;
sendAsyncMessage("Browser:KeyPress", {
@@ -530,20 +517,16 @@ Content.prototype = {
startLoading: function startLoading() {
this._loading = true;
},
stopLoading: function stopLoading() {
this._loading = false;
},
-
- isSelected: function isSelected() {
- return this._selected;
- }
};
let contentObject = new Content();
let ViewportHandler = {
metadata: null,
init: function init() {