[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

mihaip at chromium.org mihaip at chromium.org
Mon Feb 21 00:36:30 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 279ca48fb0a16cdbf2fd7f4c21594791546df4c4
Author: mihaip at chromium.org <mihaip at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Feb 2 02:39:31 2011 +0000

    2011-02-01  Mihai Parparita  <mihaip at 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 at 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:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77355 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 019ab40..8b68800 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2011-02-01  Mihai Parparita  <mihaip at 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  Kent Tamura  <tkent at chromium.org>
 
         Reviewed by Tony Chang.
diff --git a/LayoutTests/fast/events/scroll-event-during-modal-dialog-expected.txt b/LayoutTests/fast/events/scroll-event-during-modal-dialog-expected.txt
new file mode 100644
index 0000000..b5514b8
--- /dev/null
+++ b/LayoutTests/fast/events/scroll-event-during-modal-dialog-expected.txt
@@ -0,0 +1,13 @@
+Tests that scroll events are not fired while modal dialogs are displayed.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Scrolling window
+Showing modal dialog
+Returned from modal dialog
+Scroll handler fired
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/events/scroll-event-during-modal-dialog.html b/LayoutTests/fast/events/scroll-event-during-modal-dialog.html
new file mode 100644
index 0000000..346dfb6
--- /dev/null
+++ b/LayoutTests/fast/events/scroll-event-during-modal-dialog.html
@@ -0,0 +1,34 @@
+<html>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+<body style="min-height: 2000px"> 
+<p id="description"></p>
+<div id="console"></div>
+
+<script type="text/javascript">
+description('Tests that scroll events are not fired while modal dialogs are displayed.');
+
+var triggeredCaptureListener = false;
+var triggeredBubbleListener = false;
+
+onscroll = function()
+{
+    debug('Scroll handler fired');
+    finishJSTest();
+}
+
+onload = function()
+{
+    debug('Scrolling window');
+    window.scrollTo(200, 200);
+    debug('Showing modal dialog');
+    showModalDialog('resources/scroll-event-modal-dialog.html');
+    debug('Returned from modal dialog');
+}
+
+var successfullyParsed = true;
+var jsTestIsAsync = true;
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index aa0129a..0018b3b 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,33 @@
+2011-02-01  Mihai Parparita  <mihaip at 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:
+
 2011-02-01  Patrick Gansterer  <paroga at webkit.org>
 
         Reviewed by Andreas Kling.
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index 72a4f81..2520ae8 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -411,7 +411,7 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML, con
     , m_normalWorldWrapperCache(0)
 #endif
     , m_usingGeolocation(false)
-    , m_eventQueue(adoptPtr(new EventQueue))
+    , m_eventQueue(EventQueue::create(this))
 #if ENABLE(WML)
     , m_containsWMLContent(false)
 #endif
diff --git a/Source/WebCore/dom/EventQueue.cpp b/Source/WebCore/dom/EventQueue.cpp
index a43929e..a3daae6 100644
--- a/Source/WebCore/dom/EventQueue.cpp
+++ b/Source/WebCore/dom/EventQueue.cpp
@@ -28,14 +28,31 @@
 #include "EventQueue.h"
 
 #include "DOMWindow.h"
-#include "Document.h"
 #include "Event.h"
 #include "EventNames.h"
+#include "ScriptExecutionContext.h"
+#include "SuspendableTimer.h"
 
 namespace WebCore {
 
-EventQueue::EventQueue()
-    : m_pendingEventTimer(this, &EventQueue::pendingEventTimerFired)
+class EventQueueTimer : public SuspendableTimer {
+    WTF_MAKE_NONCOPYABLE(EventQueueTimer);
+public:
+    EventQueueTimer(EventQueue* eventQueue, ScriptExecutionContext* context)
+        : SuspendableTimer(context)
+        , m_eventQueue(eventQueue) { }
+
+private:
+    virtual void fired() { m_eventQueue->pendingEventTimerFired(); }
+    EventQueue* m_eventQueue;    
+};
+
+EventQueue::EventQueue(ScriptExecutionContext* context)
+    : m_pendingEventTimer(adoptPtr(new EventQueueTimer(this, context)))
+{
+}
+
+EventQueue::~EventQueue()
 {
 }
 
@@ -44,8 +61,8 @@ void EventQueue::enqueueEvent(PassRefPtr<Event> event)
     ASSERT(event->target()->toNode() || event->target()->toDOMWindow());
     m_queuedEvents.append(event);
     
-    if (!m_pendingEventTimer.isActive())
-        m_pendingEventTimer.startOneShot(0);
+    if (!m_pendingEventTimer->isActive())
+        m_pendingEventTimer->startOneShot(0);
 }
 
 void EventQueue::enqueueScrollEvent(PassRefPtr<Node> target, ScrollEventTargetType targetType)
@@ -60,9 +77,9 @@ void EventQueue::enqueueScrollEvent(PassRefPtr<Node> target, ScrollEventTargetTy
     enqueueEvent(scrollEvent.release());
 }
 
-void EventQueue::pendingEventTimerFired(Timer<EventQueue>*)
+void EventQueue::pendingEventTimerFired()
 {
-    ASSERT(!m_pendingEventTimer.isActive());
+    ASSERT(!m_pendingEventTimer->isActive());
 
     Vector<RefPtr<Event> > queuedEvents;
     queuedEvents.swap(m_queuedEvents);
diff --git a/Source/WebCore/dom/EventQueue.h b/Source/WebCore/dom/EventQueue.h
index 7f8d5fb..a589ed8 100644
--- a/Source/WebCore/dom/EventQueue.h
+++ b/Source/WebCore/dom/EventQueue.h
@@ -27,38 +27,51 @@
 #ifndef EventQueue_h
 #define EventQueue_h
 
-#include "Timer.h"
 #include <wtf/HashSet.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
 
 class Event;
+class EventQueueTimer;
 class Node;
+class ScriptExecutionContext;
 
 class EventQueue {
     WTF_MAKE_NONCOPYABLE(EventQueue);
 
+    
 public:
     enum ScrollEventTargetType {
         ScrollEventDocumentTarget,
         ScrollEventElementTarget
     };
 
-    EventQueue();
+    static PassOwnPtr<EventQueue> create(ScriptExecutionContext* context)
+    {
+        return adoptPtr(new EventQueue(context));
+    }
+
+    ~EventQueue();
 
     void enqueueEvent(PassRefPtr<Event>);
     void enqueueScrollEvent(PassRefPtr<Node>, ScrollEventTargetType);
 
 private:
-    void pendingEventTimerFired(Timer<EventQueue>*);
+    explicit EventQueue(ScriptExecutionContext*);
+
+    void pendingEventTimerFired();
     void dispatchEvent(PassRefPtr<Event>);
 
-    Timer<EventQueue> m_pendingEventTimer;
+    OwnPtr<EventQueueTimer> m_pendingEventTimer;
     Vector<RefPtr<Event> > m_queuedEvents;
     HashSet<Node*> m_nodesWithQueuedScrollEvents;
+    
+    friend class EventQueueTimer;    
 };
 
 }
diff --git a/Source/WebCore/page/SuspendableTimer.cpp b/Source/WebCore/page/SuspendableTimer.cpp
index 23f00b0..2a4d2e5 100644
--- a/Source/WebCore/page/SuspendableTimer.cpp
+++ b/Source/WebCore/page/SuspendableTimer.cpp
@@ -36,6 +36,7 @@ SuspendableTimer::SuspendableTimer(ScriptExecutionContext* context)
     , m_nextFireInterval(0)
     , m_repeatInterval(0)
 #if !ASSERT_DISABLED
+    , m_active(false)
     , m_suspended(false)
 #endif
 {
@@ -61,9 +62,12 @@ void SuspendableTimer::suspend(ReasonForSuspension)
     ASSERT(!m_suspended);
     m_suspended = true;
 #endif
-    m_nextFireInterval = nextFireInterval();
-    m_repeatInterval = repeatInterval();
-    TimerBase::stop();
+    m_active = isActive();
+    if (m_active) {
+        m_nextFireInterval = nextFireInterval();
+        m_repeatInterval = repeatInterval();
+        TimerBase::stop();
+    }
 }
 
 void SuspendableTimer::resume()
@@ -72,7 +76,8 @@ void SuspendableTimer::resume()
     ASSERT(m_suspended);
     m_suspended = false;
 #endif
-    start(m_nextFireInterval, m_repeatInterval);
+    if (m_active)
+        start(m_nextFireInterval, m_repeatInterval);
 }
 
 bool SuspendableTimer::canSuspend() const
diff --git a/Source/WebCore/page/SuspendableTimer.h b/Source/WebCore/page/SuspendableTimer.h
index cc90b62..fa03d6e 100644
--- a/Source/WebCore/page/SuspendableTimer.h
+++ b/Source/WebCore/page/SuspendableTimer.h
@@ -34,7 +34,7 @@ namespace WebCore {
 
 class SuspendableTimer : public TimerBase, public ActiveDOMObject {
 public:
-    SuspendableTimer(ScriptExecutionContext*);
+    explicit SuspendableTimer(ScriptExecutionContext*);
     virtual ~SuspendableTimer();
 
     // ActiveDOMObject
@@ -49,6 +49,7 @@ private:
 
     double m_nextFireInterval;
     double m_repeatInterval;
+    bool m_active;
 #if !ASSERT_DISABLED
     bool m_suspended;
 #endif

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list