From 2d22d57acc551c8d48933ebaa1bf123035094ce4 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Wed, 8 Aug 2012 23:41:08 +0200 Subject: [PATCH] buffer_container: mark hidden buffers inactive When a buffer is not visible, it can still eats CPU due to animations and Javascript. The docShell property 'isActive', introduced in Gecko 2.0, can be used to mitigate this. When false, it stops CSS animations, runs timers less often, and generally causes the inactive buffer to consume a lot less CPU time. --- modules/buffer.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/buffer.js b/modules/buffer.js index 06f4a56..73719d2 100644 --- a/modules/buffer.js +++ b/modules/buffer.js @@ -450,6 +450,8 @@ buffer_container.prototype = { old_value.saved_focused_frame = old_value.focused_frame; old_value.saved_focused_element = old_value.focused_element; + if ('isActive' in old_value.browser.docShell) + old_value.browser.docShell.isActive = false; old_value.browser.setAttribute("type", "content"); }, @@ -458,6 +460,8 @@ buffer_container.prototype = { this.container.selectedPanel = buffer.element; buffer.browser.setAttribute("type", "content-primary"); + if ('isActive' in buffer.browser.docShell) + buffer.browser.docShell.isActive = true; /** * This next focus call seems to be needed to avoid focus -- 2.11.4.GIT