Context Navigation


Changeset 77355


Ignore:
Timestamp:
02/01/11 18:39:31 (22 months ago)
Author:
mihaip@chromium.org
Message:

2011-02-01 Mihai Parparita <mihaip@chromium.org>

Reviewed by James Robinson.

Async event handlers should not fire within a modal dialog
https://bugs.webkit.org/show_bug.cgi?id=53202

Add tests for a scroll event triggered right before a modal dialog is
shown.

  • fast/events/scroll-event-during-modal-dialog-expected.txt: Added.
  • fast/events/scroll-event-during-modal-dialog.html: Added.

2011-02-01 Mihai Parparita <mihaip@chromium.org>

Reviewed by James Robinson.

Async event handlers should not fire within a modal dialog
https://bugs.webkit.org/show_bug.cgi?id=53202

Asychronous events that use EventQueue would currently fire while a
modal dialog (e.g. window.alert()) was up. Change EventQueue to use a
SuspendableTimer (which automatically gets suspended while dialogs are
up and in other cases where JS execution is not allowed).

Test: fast/events/scroll-event-during-modal-dialog.html

  • dom/Document.cpp: (WebCore::Document::Document):
  • dom/EventQueue.cpp: (WebCore::EventQueueTimer::EventQueueTimer): (WebCore::EventQueueTimer::fired): (WebCore::EventQueue::EventQueue): (WebCore::EventQueue::enqueueEvent): (WebCore::EventQueue::pendingEventTimerFired):
  • dom/EventQueue.h: (WebCore::EventQueue::create):
  • page/SuspendableTimer.cpp: (WebCore::SuspendableTimer::SuspendableTimer): (WebCore::SuspendableTimer::suspend): (WebCore::SuspendableTimer::resume):
  • page/SuspendableTimer.h:
Location:
trunk
Files:
2 added
7 edited

  • LayoutTests/ChangeLog (modified) (1 diff)
  • LayoutTests/fast/events/scroll-event-during-modal-dialog-expected.txt (added)
  • LayoutTests/fast/events/scroll-event-during-modal-dialog.html (added)
  • Source/WebCore/ChangeLog (modified) (1 diff)
  • Source/WebCore/dom/Document.cpp (modified) (1 diff)
  • Source/WebCore/dom/EventQueue.cpp (modified) (3 diffs)
  • Source/WebCore/dom/EventQueue.h (modified) (4 diffs)
  • Source/WebCore/page/SuspendableTimer.cpp (modified) (3 diffs)
  • Source/WebCore/page/SuspendableTimer.h (modified) (2 diffs)

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r77347 r77355  
     12011-02-01  Mihai Parparita  <mihaip@chromium.org> 
     2 
     3        Reviewed by James Robinson. 
     4 
     5        Async event handlers should not fire within a modal dialog 
     6        https://bugs.webkit.org/show_bug.cgi?id=53202 
     7         
     8        Add tests for a scroll event triggered right before a modal dialog is 
     9        shown. 
     10 
     11        * fast/events/scroll-event-during-modal-dialog-expected.txt: Added. 
     12        * fast/events/scroll-event-during-modal-dialog.html: Added. 
     13 
    1142011-02-01  Kent Tamura  <tkent@chromium.org> 
    215 
  • trunk/Source/WebCore/ChangeLog

    r77351 r77355  
     12011-02-01  Mihai Parparita  <mihaip@chromium.org> 
     2 
     3        Reviewed by James Robinson. 
     4 
     5        Async event handlers should not fire within a modal dialog 
     6        https://bugs.webkit.org/show_bug.cgi?id=53202 
     7 
     8        Asychronous events that use EventQueue would currently fire while a 
     9        modal dialog (e.g. window.alert()) was up. Change EventQueue to use a 
     10        SuspendableTimer (which automatically gets suspended while dialogs are 
     11        up and in other cases where JS execution is not allowed). 
     12         
     13        Test: fast/events/scroll-event-during-modal-dialog.html 
     14 
     15        * dom/Document.cpp: 
     16        (WebCore::Document::Document): 
     17        * dom/EventQueue.cpp: 
     18        (WebCore::EventQueueTimer::EventQueueTimer): 
     19        (WebCore::EventQueueTimer::fired): 
     20        (WebCore::EventQueue::EventQueue): 
     21        (WebCore::EventQueue::enqueueEvent): 
     22        (WebCore::EventQueue::pendingEventTimerFired): 
     23        * dom/EventQueue.h: 
     24        (WebCore::EventQueue::create): 
     25        * page/SuspendableTimer.cpp: 
     26        (WebCore::SuspendableTimer::SuspendableTimer): 
     27        (WebCore::SuspendableTimer::suspend): 
     28        (WebCore::SuspendableTimer::resume): 
     29        * page/SuspendableTimer.h: 
     30 
    1312011-02-01  Patrick Gansterer  <paroga@webkit.org> 
    232 
  • trunk/Source/WebCore/dom/Document.cpp

    r77333 r77355  
    412412#endif 
    413413    , m_usingGeolocation(false) 
    414     , m_eventQueue(adoptPtr(new EventQueue)) 
     414    , m_eventQueue(EventQueue::create(this)) 
    415415#if ENABLE(WML) 
    416416    , m_containsWMLContent(false) 
  • trunk/Source/WebCore/dom/EventQueue.cpp

    r77241 r77355  
    2929 
    3030#include "DOMWindow.h" 
    31 #include "Document.h" 
    3231#include "Event.h" 
    3332#include "EventNames.h" 
     33#include "ScriptExecutionContext.h" 
     34#include "SuspendableTimer.h" 
    3435 
    3536namespace WebCore { 
    3637 
    37 EventQueue::EventQueue() 
    38     : m_pendingEventTimer(this, &EventQueue::pendingEventTimerFired) 
     38class EventQueueTimer : public SuspendableTimer { 
     39    WTF_MAKE_NONCOPYABLE(EventQueueTimer); 
     40public: 
     41    EventQueueTimer(EventQueue* eventQueue, ScriptExecutionContext* context) 
     42        : SuspendableTimer(context) 
     43        , m_eventQueue(eventQueue) { } 
     44 
     45private: 
     46    virtual void fired() { m_eventQueue->pendingEventTimerFired(); } 
     47    EventQueue* m_eventQueue;     
     48}; 
     49 
     50EventQueue::EventQueue(ScriptExecutionContext* context) 
     51    : m_pendingEventTimer(adoptPtr(new EventQueueTimer(this, context))) 
     52{ 
     53} 
     54 
     55EventQueue::~EventQueue() 
    3956{ 
    4057} 
     
    4562    m_queuedEvents.append(event); 
    4663     
    47     if (!m_pendingEventTimer.isActive()) 
    48         m_pendingEventTimer.startOneShot(0); 
     64    if (!m_pendingEventTimer->isActive()) 
     65        m_pendingEventTimer->startOneShot(0); 
    4966} 
    5067 
     
    6178} 
    6279 
    63 void EventQueue::pendingEventTimerFired(Timer<EventQueue>*) 
     80void EventQueue::pendingEventTimerFired() 
    6481{ 
    65     ASSERT(!m_pendingEventTimer.isActive()); 
     82    ASSERT(!m_pendingEventTimer->isActive()); 
    6683 
    6784    Vector<RefPtr<Event> > queuedEvents; 
  • trunk/Source/WebCore/dom/EventQueue.h

    r77241 r77355  
    2828#define EventQueue_h 
    2929 
    30 #include "Timer.h" 
    3130#include <wtf/HashSet.h> 
    3231#include <wtf/Noncopyable.h> 
     32#include <wtf/OwnPtr.h> 
     33#include <wtf/PassOwnPtr.h> 
    3334#include <wtf/RefPtr.h> 
    3435#include <wtf/Vector.h> 
     
    3738 
    3839class Event; 
     40class EventQueueTimer; 
    3941class Node; 
     42class ScriptExecutionContext; 
    4043 
    4144class EventQueue { 
    4245    WTF_MAKE_NONCOPYABLE(EventQueue); 
    4346 
     47     
    4448public: 
    4549    enum ScrollEventTargetType { 
     
    4852    }; 
    4953 
    50     EventQueue(); 
     54    static PassOwnPtr<EventQueue> create(ScriptExecutionContext* context) 
     55    { 
     56        return adoptPtr(new EventQueue(context)); 
     57    } 
     58 
     59    ~EventQueue(); 
    5160 
    5261    void enqueueEvent(PassRefPtr<Event>); 
     
    5463 
    5564private: 
    56     void pendingEventTimerFired(Timer<EventQueue>*); 
     65    explicit EventQueue(ScriptExecutionContext*); 
     66 
     67    void pendingEventTimerFired(); 
    5768    void dispatchEvent(PassRefPtr<Event>); 
    5869 
    59     Timer<EventQueue> m_pendingEventTimer; 
     70    OwnPtr<EventQueueTimer> m_pendingEventTimer; 
    6071    Vector<RefPtr<Event> > m_queuedEvents; 
    6172    HashSet<Node*> m_nodesWithQueuedScrollEvents; 
     73     
     74    friend class EventQueueTimer;     
    6275}; 
    6376 
  • trunk/Source/WebCore/page/SuspendableTimer.cpp

    r67432 r77355  
    3737    , m_repeatInterval(0) 
    3838#if !ASSERT_DISABLED 
     39    , m_active(false) 
    3940    , m_suspended(false) 
    4041#endif 
     
    6263    m_suspended = true; 
    6364#endif 
    64     m_nextFireInterval = nextFireInterval(); 
    65     m_repeatInterval = repeatInterval(); 
    66     TimerBase::stop(); 
     65    m_active = isActive(); 
     66    if (m_active) { 
     67        m_nextFireInterval = nextFireInterval(); 
     68        m_repeatInterval = repeatInterval(); 
     69        TimerBase::stop(); 
     70    } 
    6771} 
    6872 
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.