[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

steveblock at google.com steveblock at google.com
Wed Dec 22 11:27:56 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit cdd899132073daf921dbbb3f0571dd08e51e8c16
Author: steveblock at google.com <steveblock at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jul 26 16:01:30 2010 +0000

    2010-07-26  Steve Block  <steveblock at google.com>
    
            Reviewed by Jeremy Orlow.
    
            DeviceOrientation event listeners should never be called synchronously from addEventListener()
            https://bugs.webkit.org/show_bug.cgi?id=42304
    
            No new tests as there are currently no implementations to test. Tests will be
            added once LayoutTestController methods for providing a mock implementation are
            in place, see Bug 39589.
    
            * dom/DeviceOrientationController.cpp:
            (WebCore::DeviceOrientationController::DeviceOrientationController):
            (WebCore::DeviceOrientationController::timerFired):
            (WebCore::DeviceOrientationController::addListener):
            (WebCore::DeviceOrientationController::removeListener):
            (WebCore::DeviceOrientationController::removeAllListeners):
            * dom/DeviceOrientationController.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64048 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1a90245..4f4ebae 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-07-26  Steve Block  <steveblock at google.com>
+
+        Reviewed by Jeremy Orlow.
+
+        DeviceOrientation event listeners should never be called synchronously from addEventListener()
+        https://bugs.webkit.org/show_bug.cgi?id=42304
+
+        No new tests as there are currently no implementations to test. Tests will be
+        added once LayoutTestController methods for providing a mock implementation are
+        in place, see Bug 39589.
+
+        * dom/DeviceOrientationController.cpp:
+        (WebCore::DeviceOrientationController::DeviceOrientationController):
+        (WebCore::DeviceOrientationController::timerFired):
+        (WebCore::DeviceOrientationController::addListener):
+        (WebCore::DeviceOrientationController::removeListener):
+        (WebCore::DeviceOrientationController::removeAllListeners):
+        * dom/DeviceOrientationController.h:
+
 2010-07-26  Andreas Kling  <andreas.kling at nokia.com>
 
         Reviewed by Tor Arne Vestbø.
diff --git a/WebCore/dom/DeviceOrientationController.cpp b/WebCore/dom/DeviceOrientationController.cpp
index f6867ec..a6a33f5 100644
--- a/WebCore/dom/DeviceOrientationController.cpp
+++ b/WebCore/dom/DeviceOrientationController.cpp
@@ -37,21 +37,38 @@ namespace WebCore {
 DeviceOrientationController::DeviceOrientationController(Page* page, DeviceOrientationClient* client)
     : m_page(page)
     , m_client(client)
+    , m_timer(this, &DeviceOrientationController::timerFired)
 {
 }
 
+void DeviceOrientationController::timerFired(Timer<DeviceOrientationController>* timer)
+{
+    ASSERT_UNUSED(timer, timer == &m_timer);
+    ASSERT(!m_client || m_client->lastOrientation());
+
+    RefPtr<DeviceOrientation> orientation = m_client ?  m_client->lastOrientation() : DeviceOrientation::create();
+    RefPtr<DeviceOrientationEvent> event = DeviceOrientationEvent::create(eventNames().deviceorientationEvent, orientation.get());
+
+    Vector<DOMWindow*> listenersVector;
+    copyToVector(m_newListeners, listenersVector);
+    m_newListeners.clear();
+    for (size_t i = 0; i < listenersVector.size(); ++i)
+        listenersVector[i]->dispatchEvent(event);
+}
+
 void DeviceOrientationController::addListener(DOMWindow* window)
 {
-    // If no client is present, signal that no orientation data is available.
-    // If the client already has an orientation, call back to this new listener
-    // immediately.
-    if (!m_client) {
-        RefPtr<DeviceOrientation> emptyOrientation = DeviceOrientation::create();
-        window->dispatchEvent(DeviceOrientationEvent::create(eventNames().deviceorientationEvent, emptyOrientation.get()));
-    } else if (m_client && m_client->lastOrientation())
-        window->dispatchEvent(DeviceOrientationEvent::create(eventNames().deviceorientationEvent, m_client->lastOrientation()));
-
-    // The client may call back synchronously.
+    // If no client is present, we should fire an event with all parameters null. If
+    // the client already has an orientation, we should fire an event with that
+    // orientation. In both cases, the event is fired asynchronously, but without
+    // waiting for the client to get a new orientation.
+    if (!m_client || m_client->lastOrientation()) {
+        m_newListeners.add(window);
+        if (!m_timer.isActive())
+            m_timer.startOneShot(0);
+    }
+
+    // The client must not call back synchronously.
     bool wasEmpty = m_listeners.isEmpty();
     m_listeners.add(window);
     if (wasEmpty && m_client)
@@ -61,6 +78,7 @@ void DeviceOrientationController::addListener(DOMWindow* window)
 void DeviceOrientationController::removeListener(DOMWindow* window)
 {
     m_listeners.remove(window);
+    m_newListeners.remove(window);
     if (m_listeners.isEmpty() && m_client)
         m_client->stopUpdating();
 }
@@ -72,6 +90,7 @@ void DeviceOrientationController::removeAllListeners(DOMWindow* window)
         return;
 
     m_listeners.removeAll(window);
+    m_newListeners.remove(window);
     if (m_listeners.isEmpty() && m_client)
         m_client->stopUpdating();
 }
diff --git a/WebCore/dom/DeviceOrientationController.h b/WebCore/dom/DeviceOrientationController.h
index 376e14c..9517791 100644
--- a/WebCore/dom/DeviceOrientationController.h
+++ b/WebCore/dom/DeviceOrientationController.h
@@ -27,6 +27,8 @@
 #define DeviceOrientationController_h
 
 #include "DOMWindow.h"
+#include "Timer.h"
+
 #include <wtf/HashCountedSet.h>
 
 namespace WebCore {
@@ -46,10 +48,15 @@ public:
     void didChangeDeviceOrientation(DeviceOrientation*);
 
 private:
+    void timerFired(Timer<DeviceOrientationController>*);
+
     Page* m_page;
     DeviceOrientationClient* m_client;
-    typedef HashCountedSet<DOMWindow*> ListenersSet;
-    ListenersSet m_listeners;
+    typedef HashCountedSet<DOMWindow*> ListenersCountedSet;
+    ListenersCountedSet m_listeners;
+    typedef HashSet<DOMWindow*> ListenersSet;
+    ListenersSet m_newListeners;
+    Timer<DeviceOrientationController> m_timer;
 };
 
 } // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list