Changeset 31199 in webkit


Ignore:
Timestamp:
Mar 20, 2008 5:14:58 PM (16 years ago)
Author:
Adam Roben
Message:

Allow pausing/blocking of JS execution by plugins

Part of Bug 17133: Should support pausing JavaScript execution without
hanging the process

<http://bugs.webkit.org/show_bug.cgi?id=17133>
<rdar://problem/5719551>

This patch doesn't affect Mac, which doesn't use the shared PluginView
code.

Note that this patch doesn't prevent plugins from executing JS via an
NPObject they've already gotten hold of. It just blocks obtaining new
NPObjects and pauses any requests to evaluate javascript: URIs. This
is probably good enough for now because most plugins seem to always
obtain the Window object each time they want to execute JS.

Reviewed by Tim Hatcher.

  • plugins/PluginView.cpp: (WebCore::PluginView::getValue): Return an error if JS is paused. (WebCore::PluginView::setJavaScriptPaused): Stop the request timer if we're pausing, and resume it if we're unpausing. (WebCore::PluginView::PluginView): Initialize new members.
  • plugins/PluginView.h:
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r31198 r31199  
     12008-03-20  Adam Roben  <aroben@apple.com>
     2
     3        Allow pausing/blocking of JS execution by plugins
     4
     5        Part of Bug 17133: Should support pausing JavaScript execution without
     6        hanging the process
     7
     8        <http://bugs.webkit.org/show_bug.cgi?id=17133>
     9        <rdar://problem/5719551>
     10
     11        This patch doesn't affect Mac, which doesn't use the shared PluginView
     12        code.
     13
     14        Note that this patch doesn't prevent plugins from executing JS via an
     15        NPObject they've already gotten hold of. It just blocks obtaining new
     16        NPObjects and pauses any requests to evaluate javascript: URIs. This
     17        is probably good enough for now because most plugins seem to always
     18        obtain the Window object each time they want to execute JS.
     19
     20        Reviewed by Tim Hatcher.
     21
     22        * plugins/PluginView.cpp:
     23        (WebCore::PluginView::getValue): Return an error if JS is paused.
     24        (WebCore::PluginView::setJavaScriptPaused): Stop the request timer if
     25        we're pausing, and resume it if we're unpausing.
     26        (WebCore::PluginView::PluginView): Initialize new members.
     27        * plugins/PluginView.h:
     28
    1292008-03-20  Adam Roben  <aroben@apple.com>
    230
  • trunk/WebCore/plugins/PluginView.cpp

    r31196 r31199  
    393393NPError PluginView::getValue(NPNVariable variable, void* value)
    394394{
     395    if (m_isJavaScriptPaused)
     396        return NPERR_GENERIC_ERROR;
     397
    395398    switch (variable) {
    396399#if ENABLE(NETSCAPE_PLUGIN_API)
     
    478481
    479482    return false;
     483}
     484
     485void PluginView::setJavaScriptPaused(bool paused)
     486{
     487    if (m_isJavaScriptPaused == paused)
     488        return;
     489    m_isJavaScriptPaused = paused;
     490
     491    if (m_isJavaScriptPaused) {
     492        m_requestTimerWasActive = m_requestTimer.isActive();
     493        m_requestTimer.stop();
     494    } else if (m_requestTimerWasActive)
     495        m_requestTimer.startOneShot(0);
    480496}
    481497
     
    566582    , m_loadManually(loadManually)
    567583    , m_manualStream(0)
     584    , m_isJavaScriptPaused(false)
     585    , m_requestTimerWasActive(false)
    568586{
    569587    if (!m_plugin) {
  • trunk/WebCore/plugins/PluginView.h

    r31196 r31199  
    130130        bool arePopupsAllowed() const;
    131131
     132        void setJavaScriptPaused(bool);
     133
    132134        void disconnectStream(PluginStream*);
    133135        void streamDidFinishLoading(PluginStream* stream) { disconnectStream(stream); }
     
    234236        RefPtr<PluginStream> m_manualStream;
    235237
     238        bool m_isJavaScriptPaused;
     239        bool m_requestTimerWasActive;
     240
    236241        static PluginView* s_currentPluginView;
    237242    };
Note: See TracChangeset for help on using the changeset viewer.