Title: [97982] trunk/Source/WebCore
Revision
97982
Author
o...@webkit.org
Date
2011-10-20 08:30:34 -0700 (Thu, 20 Oct 2011)

Log Message

[Qt] Roll-back r97964, r97972 and fix in https://bugs.webkit.org/show_bug.cgi?id=70328.

* dom/DeviceMotionController.cpp:
(WebCore::DeviceMotionController::timerFired):
(WebCore::DeviceMotionController::addListener):
(WebCore::DeviceMotionController::removeListener):
(WebCore::DeviceMotionController::removeAllListeners):
(WebCore::DeviceMotionController::suspend):
(WebCore::DeviceMotionController::resume):
* dom/DeviceMotionController.h:
* dom/DeviceOrientationController.cpp:
(WebCore::DeviceOrientationController::suspend):
(WebCore::DeviceOrientationController::resume):
* dom/DeviceOrientationController.h:
* dom/Document.cpp:
(WebCore::Document::suspendActiveDOMObjects):
(WebCore::Document::resumeActiveDOMObjects):
(WebCore::Document::stopActiveDOMObjects):
* dom/Document.h:
* dom/ScriptExecutionContext.h:
* page/GeolocationController.cpp:
(WebCore::GeolocationController::suspend):
(WebCore::GeolocationController::resume):
* page/GeolocationController.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (97981 => 97982)


--- trunk/Source/WebCore/ChangeLog	2011-10-20 15:18:54 UTC (rev 97981)
+++ trunk/Source/WebCore/ChangeLog	2011-10-20 15:30:34 UTC (rev 97982)
@@ -1,3 +1,30 @@
+2011-10-20  Csaba Osztrogonác  <o...@webkit.org>
+
+        [Qt] Roll-back r97964, r97972 and fix in https://bugs.webkit.org/show_bug.cgi?id=70328.
+
+        * dom/DeviceMotionController.cpp:
+        (WebCore::DeviceMotionController::timerFired):
+        (WebCore::DeviceMotionController::addListener):
+        (WebCore::DeviceMotionController::removeListener):
+        (WebCore::DeviceMotionController::removeAllListeners):
+        (WebCore::DeviceMotionController::suspend):
+        (WebCore::DeviceMotionController::resume):
+        * dom/DeviceMotionController.h:
+        * dom/DeviceOrientationController.cpp:
+        (WebCore::DeviceOrientationController::suspend):
+        (WebCore::DeviceOrientationController::resume):
+        * dom/DeviceOrientationController.h:
+        * dom/Document.cpp:
+        (WebCore::Document::suspendActiveDOMObjects):
+        (WebCore::Document::resumeActiveDOMObjects):
+        (WebCore::Document::stopActiveDOMObjects):
+        * dom/Document.h:
+        * dom/ScriptExecutionContext.h:
+        * page/GeolocationController.cpp:
+        (WebCore::GeolocationController::suspend):
+        (WebCore::GeolocationController::resume):
+        * page/GeolocationController.h:
+
 2011-10-20  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r97964 and r97972.

Modified: trunk/Source/WebCore/dom/DeviceMotionController.cpp (97981 => 97982)


--- trunk/Source/WebCore/dom/DeviceMotionController.cpp	2011-10-20 15:18:54 UTC (rev 97981)
+++ trunk/Source/WebCore/dom/DeviceMotionController.cpp	2011-10-20 15:30:34 UTC (rev 97982)
@@ -48,10 +48,10 @@
 void DeviceMotionController::timerFired(Timer<DeviceMotionController>* timer)
 {
     ASSERT_UNUSED(timer, timer == &m_timer);
-    ASSERT(!m_client || m_client->currentDeviceMotion());
+    ASSERT(m_client->currentDeviceMotion());
     m_timer.stop();
     
-    RefPtr<DeviceMotionData> deviceMotionData = m_client ? m_client->currentDeviceMotion() : DeviceMotionData::create();
+    RefPtr<DeviceMotionData> deviceMotionData = m_client->currentDeviceMotion();
     RefPtr<DeviceMotionEvent> event = DeviceMotionEvent::create(eventNames().devicemotionEvent, deviceMotionData.get());
  
     Vector<RefPtr<DOMWindow> > listenersVector;
@@ -63,9 +63,9 @@
     
 void DeviceMotionController::addListener(DOMWindow* window)
 {
-    // If no client is present or the client already has motion data,
+    // If the client already has motion data,
     // immediately trigger an asynchronous response.
-    if (!m_client || m_client->currentDeviceMotion()) {
+    if (m_client->currentDeviceMotion()) {
         m_newListeners.add(window);
         if (!m_timer.isActive())
             m_timer.startOneShot(0);
@@ -73,7 +73,7 @@
     
     bool wasEmpty = m_listeners.isEmpty();
     m_listeners.add(window);
-    if (wasEmpty && m_client)
+    if (wasEmpty)
         m_client->startUpdating();
 }
 
@@ -81,7 +81,7 @@
 {
     m_listeners.remove(window);
     m_newListeners.remove(window);
-    if (m_listeners.isEmpty() && m_client)
+    if (m_listeners.isEmpty())
         m_client->stopUpdating();
 }
 
@@ -93,10 +93,22 @@
 
     m_listeners.removeAll(window);
     m_newListeners.remove(window);
-    if (m_listeners.isEmpty() && m_client)
+    if (m_listeners.isEmpty())
         m_client->stopUpdating();
 }
 
+void DeviceMotionController::suspend()
+{
+    if (!m_listeners.isEmpty())
+        m_client->stopUpdating();
+}
+
+void DeviceMotionController::resume()
+{
+    if (!m_listeners.isEmpty())
+        m_client->startUpdating();
+}
+
 void DeviceMotionController::didChangeDeviceMotion(DeviceMotionData* deviceMotionData)
 {
     RefPtr<DeviceMotionEvent> event = DeviceMotionEvent::create(eventNames().devicemotionEvent, deviceMotionData);

Modified: trunk/Source/WebCore/dom/DeviceMotionController.h (97981 => 97982)


--- trunk/Source/WebCore/dom/DeviceMotionController.h	2011-10-20 15:18:54 UTC (rev 97981)
+++ trunk/Source/WebCore/dom/DeviceMotionController.h	2011-10-20 15:30:34 UTC (rev 97982)
@@ -44,6 +44,9 @@
     void removeListener(DOMWindow*);
     void removeAllListeners(DOMWindow*);
 
+    void suspend();
+    void resume();
+
     void didChangeDeviceMotion(DeviceMotionData*);
 
     bool isActive() { return !m_listeners.isEmpty(); }

Modified: trunk/Source/WebCore/dom/DeviceOrientationController.cpp (97981 => 97982)


--- trunk/Source/WebCore/dom/DeviceOrientationController.cpp	2011-10-20 15:18:54 UTC (rev 97981)
+++ trunk/Source/WebCore/dom/DeviceOrientationController.cpp	2011-10-20 15:30:34 UTC (rev 97982)
@@ -99,6 +99,18 @@
         m_client->stopUpdating();
 }
 
+void DeviceOrientationController::suspend()
+{
+    if (!m_listeners.isEmpty())
+        m_client->stopUpdating();
+}
+
+void DeviceOrientationController::resume()
+{
+    if (!m_listeners.isEmpty())
+        m_client->startUpdating();
+}
+
 void DeviceOrientationController::didChangeDeviceOrientation(DeviceOrientation* orientation)
 {
     RefPtr<DeviceOrientationEvent> event = DeviceOrientationEvent::create(eventNames().deviceorientationEvent, orientation);

Modified: trunk/Source/WebCore/dom/DeviceOrientationController.h (97981 => 97982)


--- trunk/Source/WebCore/dom/DeviceOrientationController.h	2011-10-20 15:18:54 UTC (rev 97981)
+++ trunk/Source/WebCore/dom/DeviceOrientationController.h	2011-10-20 15:30:34 UTC (rev 97982)
@@ -46,6 +46,9 @@
     void removeListener(DOMWindow*);
     void removeAllListeners(DOMWindow*);
 
+    void suspend();
+    void resume();
+
     void didChangeDeviceOrientation(DeviceOrientation*);
 
     bool isActive() { return !m_listeners.isEmpty(); }

Modified: trunk/Source/WebCore/dom/Document.cpp (97981 => 97982)


--- trunk/Source/WebCore/dom/Document.cpp	2011-10-20 15:18:54 UTC (rev 97981)
+++ trunk/Source/WebCore/dom/Document.cpp	2011-10-20 15:30:34 UTC (rev 97982)
@@ -47,6 +47,10 @@
 #include "DOMImplementation.h"
 #include "DOMWindow.h"
 #include "DateComponents.h"
+#include "DeviceMotionController.h"
+#include "DeviceMotionEvent.h"
+#include "DeviceOrientationController.h"
+#include "DeviceOrientationEvent.h"
 #include "DocumentFragment.h"
 #include "DocumentLoader.h"
 #include "DocumentMarkerController.h"
@@ -70,6 +74,7 @@
 #include "FrameSelection.h"
 #include "FrameTree.h"
 #include "FrameView.h"
+#include "GeolocationController.h"
 #include "HashChangeEvent.h"
 #include "HTMLAllCollection.h"
 #include "HTMLAnchorElement.h"
@@ -1835,6 +1840,66 @@
         node->removeAllEventListeners();
 }
 
+void Document::suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension why)
+{
+    ScriptExecutionContext::suspendActiveDOMObjects(why);
+
+    if (!page())
+        return;
+
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+    if (page()->geolocationController() && usingGeolocation())
+        page()->geolocationController()->suspend();
+#endif
+
+#if ENABLE(DEVICE_ORIENTATION)
+    if (page()->deviceMotionController())
+        page()->deviceMotionController()->suspend();
+    if (page()->deviceOrientationController())
+        page()->deviceOrientationController()->suspend();
+#endif
+}
+
+void Document::resumeActiveDOMObjects()
+{
+    ScriptExecutionContext::resumeActiveDOMObjects();
+
+    if (!page())
+        return;
+
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+    if (page()->geolocationController() && usingGeolocation())
+        page()->geolocationController()->resume();
+#endif
+
+#if ENABLE(DEVICE_ORIENTATION)
+    if (page()->deviceMotionController())
+        page()->deviceMotionController()->resume();
+    if (page()->deviceOrientationController())
+        page()->deviceOrientationController()->resume();
+#endif
+}
+
+void Document::stopActiveDOMObjects()
+{
+    ScriptExecutionContext::stopActiveDOMObjects();
+
+    if (!page())
+        return;
+
+#if ENABLE(CLIENT_BASED_GEOLOCATION)
+    if (page()->geolocationController() && usingGeolocation())
+        page()->geolocationController()->suspend();
+#endif
+
+#if ENABLE(DEVICE_ORIENTATION)
+    if (page()->deviceMotionController())
+        page()->deviceMotionController()->suspend();
+    if (page()->deviceOrientationController())
+        page()->deviceOrientationController()->suspend();
+#endif
+}
+
 RenderView* Document::renderView() const
 {
     return toRenderView(renderer());

Modified: trunk/Source/WebCore/dom/Document.h (97981 => 97982)


--- trunk/Source/WebCore/dom/Document.h	2011-10-20 15:18:54 UTC (rev 97981)
+++ trunk/Source/WebCore/dom/Document.h	2011-10-20 15:30:34 UTC (rev 97982)
@@ -564,6 +564,11 @@
     virtual void attach();
     virtual void detach();
 
+    // Override ScriptExecutionContext methods to do additional work
+    virtual void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension) OVERRIDE;
+    virtual void resumeActiveDOMObjects() OVERRIDE;
+    virtual void stopActiveDOMObjects() OVERRIDE;
+
     RenderArena* renderArena() { return m_renderArena.get(); }
 
     RenderView* renderView() const;

Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.h (97981 => 97982)


--- trunk/Source/WebCore/dom/ScriptExecutionContext.h	2011-10-20 15:18:54 UTC (rev 97981)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.h	2011-10-20 15:30:34 UTC (rev 97982)
@@ -109,9 +109,10 @@
         bool canSuspendActiveDOMObjects();
         // Active objects can be asked to suspend even if canSuspendActiveDOMObjects() returns 'false' -
         // step-by-step JS debugging is one example.
-        void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension);
-        void resumeActiveDOMObjects();
-        void stopActiveDOMObjects();
+        virtual void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension);
+        virtual void resumeActiveDOMObjects();
+        virtual void stopActiveDOMObjects();
+
         void createdActiveDOMObject(ActiveDOMObject*, void* upcastPointer);
         void destroyedActiveDOMObject(ActiveDOMObject*);
         typedef const HashMap<ActiveDOMObject*, void*> ActiveDOMObjectsMap;

Modified: trunk/Source/WebCore/page/GeolocationController.cpp (97981 => 97982)


--- trunk/Source/WebCore/page/GeolocationController.cpp	2011-10-20 15:18:54 UTC (rev 97981)
+++ trunk/Source/WebCore/page/GeolocationController.cpp	2011-10-20 15:30:34 UTC (rev 97982)
@@ -80,6 +80,18 @@
     }
 }
 
+void GeolocationController::suspend()
+{
+    if (m_client && !m_observers.isEmpty())
+        m_client->stopUpdating();
+}
+
+void GeolocationController::resume()
+{
+    if (m_client && !m_observers.isEmpty())
+        m_client->startUpdating();
+}
+
 void GeolocationController::requestPermission(Geolocation* geolocation)
 {
     if (m_client)

Modified: trunk/Source/WebCore/page/GeolocationController.h (97981 => 97982)


--- trunk/Source/WebCore/page/GeolocationController.h	2011-10-20 15:18:54 UTC (rev 97981)
+++ trunk/Source/WebCore/page/GeolocationController.h	2011-10-20 15:30:34 UTC (rev 97982)
@@ -49,6 +49,9 @@
     void addObserver(Geolocation*, bool enableHighAccuracy);
     void removeObserver(Geolocation*);
 
+    void suspend();
+    void resume();
+
     void requestPermission(Geolocation*);
     void cancelPermissionRequest(Geolocation*);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to