DOM timer throttling for hidden plugins
https://bugs.webkit.org/show_bug.cgi?id=136197
Patch by Gavin Barraclough <[email protected]> on 2014-09-17
Reviewed by Geoff Garen & Andreas Kling.
For non-visible web pages we slow timers (since they can't be driving animations, etc).
We should do the same for plugins.
Source/WebCore:
There are a few steps to this:
- JSPluginElementFunctions notifies DOMTimer when script interacts with a plugin.
- DOMTimerFireState keeps a record of events that occur while a timer is firing.
- DOMTimer::fired detects timers that interact with invisible/inaudible plugins, and flags itself for throtting.
- DOMTimer::intervalClampedToMinimum sets timer intervals appropriately.
- bindings/js/JSPluginElementFunctions.cpp:
(WebCore::pluginScriptObject):
- notify DOMTimer when script interacts with a plugin.
- html/HTMLPlugInElement.cpp:
(WebCore::HTMLPlugInElement::isDetectable):
- html/HTMLPlugInElement.h:
- added isDetectable, to check for visible / audible plugins.
- page/DOMTimer.cpp:
(WebCore::DOMTimerFireState::DOMTimerFireState):
(WebCore::DOMTimerFireState::~DOMTimerFireState):
- track current DOMTimerFireState.
(WebCore::DOMTimer::DOMTimer):
- initialize m_throttleState.
(WebCore::DOMTimer::scriptDidInteractWithPlugin):
- if interaction with a plugin occurs while a timer is firing, record on the DOMTimerFireState.
(WebCore::DOMTimer::fired):
- set DOMTimerFireState, and update m_throttleState accordingly.
(WebCore::DOMTimer::updateTimerIntervalIfNecessary):
- remove redundant check of maxTimerNestingLevel (covered by intervalClampedToMinimum).
(WebCore::DOMTimer::intervalClampedToMinimum):
- Also take m_throttleState into account when throttling.
- page/DOMTimer.h:
- added scriptDidInteractWithPlugin, m_throttleState.
- platform/audio/AudioHardwareListener.h:
- plugins/PluginViewBase.h:
(WebCore::PluginViewBase::audioHardwareActivity):
- expose audioHardwareActivity on PluginViewBase (previously available in subclass).
Source/WebKit2:
- PluginProcess/WebProcessConnection.cpp:
- WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
- remove now redundant includes.
- WebProcess/Plugins/PluginView.h:
- audioHardwareActivity is now virtual, override.