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

eric.carlson at apple.com eric.carlson at apple.com
Wed Dec 22 13:23:40 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 097ca95f18c52b46872531181bf22a091aa5f007
Author: eric.carlson at apple.com <eric.carlson at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Sep 14 02:41:56 2010 +0000

    2010-09-13  Eric Carlson  <eric.carlson at apple.com>
    
            Reviewed by Geoff Garen.
    
            JavaScript dialog should not deactivate media element
            https://bugs.webkit.org/show_bug.cgi?id=45688
    
            Test: http/tests/media/reload-after-dialog.html
    
            * bindings/generic/ActiveDOMCallback.cpp:
            (WebCore::ActiveDOMObjectCallbackImpl::suspend): Add ReasonForSuspension parameter.
    
            * bindings/js/ScriptDebugServer.cpp:
            (WebCore::ScriptDebugServer::setJavaScriptPaused): Pass new parameter to suspendActiveDOMObjects.
    
            * dom/ActiveDOMObject.cpp:
            (WebCore::ActiveDOMObject::suspend): Add ReasonForSuspension parameter.
            * dom/ActiveDOMObject.h:
    
            * dom/ScriptExecutionContext.cpp:
            (WebCore::ScriptExecutionContext::suspendActiveDOMObjects): Ditto.
            * dom/ScriptExecutionContext.h:
    
            * history/CachedFrame.cpp:
            (WebCore::CachedFrame::CachedFrame): Pass new parameter to suspendActiveDOMObjects.
    
            * html/HTMLMarqueeElement.cpp:
            (WebCore::HTMLMarqueeElement::suspend): Add ReasonForSuspension parameter.
            * html/HTMLMarqueeElement.h:
    
            * html/HTMLMediaElement.cpp:
            (WebCore::HTMLMediaElement::stop): Deal with element being suspended.
            (WebCore::HTMLMediaElement::suspend): Do nothing unless reason for suspension is document
            becoming inactive.
            * html/HTMLMediaElement.h:
    
            * page/PageGroupLoadDeferrer.cpp:
            (WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer): Pass WillShowDialog to suspendActiveDOMObjects.
    
            * page/SuspendableTimer.cpp:
            (WebCore::SuspendableTimer::suspend): Add ReasonForSuspension parameter.
            * page/SuspendableTimer.h:
    
            * websockets/WebSocket.cpp:
            (WebCore::WebSocket::suspend): Ditto.
            * websockets/WebSocket.h:
    
            * xml/XMLHttpRequest.cpp:
            (WebCore::XMLHttpRequest::suspend): Ditto.
            * xml/XMLHttpRequest.h:
    
    2010-09-13  Eric Carlson  <eric.carlson at apple.com>
    
            Reviewed by Geoff Garen.
    
            JavaScript dialog should not deactivate media element
            https://bugs.webkit.org/show_bug.cgi?id=45688
    
            * http/tests/media/reload-after-dialog-expected.txt: Added.
            * http/tests/media/reload-after-dialog.html: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67432 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 5e59504..66c1e54 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-09-13  Eric Carlson  <eric.carlson at apple.com>
+
+        Reviewed by Geoff Garen.
+
+        JavaScript dialog should not deactivate media element
+        https://bugs.webkit.org/show_bug.cgi?id=45688
+
+        * http/tests/media/reload-after-dialog-expected.txt: Added.
+        * http/tests/media/reload-after-dialog.html: Added.
+
 2010-09-13  Dirk Pranke  <dpranke at chromium.org>
 
         Unreviewed, build fix.
diff --git a/LayoutTests/http/tests/media/reload-after-dialog-expected.txt b/LayoutTests/http/tests/media/reload-after-dialog-expected.txt
new file mode 100644
index 0000000..ba2ee2c
--- /dev/null
+++ b/LayoutTests/http/tests/media/reload-after-dialog-expected.txt
@@ -0,0 +1,17 @@
+CONFIRM: I hope the movie continues to play!
+Make sure we don't reload a <video> element after a dialog is shown.
+Test this by loading a movie slowly and showing a dialog when a 'loadstart' event 
+handler is called. If the movie is reloaded when the dialog is "dismissed", another 
+'loadstart' event will be fired
+
+
+'load' event
+*** Setting up element...
+
+'loadstart' event
+*** Showing confirm dialog...
+
+'canplaythrough' event
+
+END OF TEST
+
diff --git a/LayoutTests/http/tests/media/reload-after-dialog.html b/LayoutTests/http/tests/media/reload-after-dialog.html
new file mode 100644
index 0000000..fe8e2c2
--- /dev/null
+++ b/LayoutTests/http/tests/media/reload-after-dialog.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=../../../media/media-file.js></script>
+        <script src=../../../media/video-test.js></script>
+        <script>
+            var loadCount = 0;
+
+            if (window.layoutTestController) {
+                layoutTestController.dumpAsText();
+                layoutTestController.waitUntilDone();
+                layoutTestController.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+            }
+
+            function logEvent(event) 
+            {
+                consoleWrite("<br><b><em>'" + event.type + "'<" + "/em> event<" + "/b>");
+            }
+
+            function loadstart() 
+            {
+                logEvent(event);
+                
+                if (++loadCount > 1) {
+                    consoleWrite('FAIL: loadstart fired more than once.');
+                    endTest();
+                    return;
+                }
+
+                consoleWrite("*** Showing confirm dialog...");
+                confirm('I hope the movie continues to play!');
+            }
+
+            function canplaythrough()
+            {
+                logEvent(event);
+
+                consoleWrite("");
+                endTest();
+            }
+
+            function setup()
+            {
+                logEvent(event);
+                consoleWrite("*** Setting up element...");
+
+                findMediaElement();
+                var movie = findMediaFile("video", "../resources/test");
+                video.src = "http://127.0.0.1:8000/media/video-throttled-load.cgi?name=" + movie + "&throttle=100";
+            }
+
+        </script>
+    </head>
+
+    <body onload="setup()">
+        <video controls
+            oncanplaythrough="canplaythrough()"
+            onloadstart="loadstart()">
+            </video>
+        <p>Make sure we don't reload a &lt;video&gt; element after a dialog is shown.<br>
+        Test this by loading a movie slowly and showing a dialog when a 'loadstart' event <br>
+        handler is called. If the movie is reloaded when the dialog is "dismissed", another <br>
+        'loadstart' event will be fired</p>
+    </body>
+</html>
+
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 9fe295b..255ce2c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,54 @@
+2010-09-13  Eric Carlson  <eric.carlson at apple.com>
+
+        Reviewed by Geoff Garen.
+
+        JavaScript dialog should not deactivate media element
+        https://bugs.webkit.org/show_bug.cgi?id=45688
+
+        Test: http/tests/media/reload-after-dialog.html
+
+        * bindings/generic/ActiveDOMCallback.cpp:
+        (WebCore::ActiveDOMObjectCallbackImpl::suspend): Add ReasonForSuspension parameter.
+
+        * bindings/js/ScriptDebugServer.cpp:
+        (WebCore::ScriptDebugServer::setJavaScriptPaused): Pass new parameter to suspendActiveDOMObjects.
+
+        * dom/ActiveDOMObject.cpp:
+        (WebCore::ActiveDOMObject::suspend): Add ReasonForSuspension parameter.
+        * dom/ActiveDOMObject.h:
+
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::suspendActiveDOMObjects): Ditto.
+        * dom/ScriptExecutionContext.h:
+
+        * history/CachedFrame.cpp:
+        (WebCore::CachedFrame::CachedFrame): Pass new parameter to suspendActiveDOMObjects.
+
+        * html/HTMLMarqueeElement.cpp:
+        (WebCore::HTMLMarqueeElement::suspend): Add ReasonForSuspension parameter.
+        * html/HTMLMarqueeElement.h:
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::stop): Deal with element being suspended.
+        (WebCore::HTMLMediaElement::suspend): Do nothing unless reason for suspension is document
+        becoming inactive.
+        * html/HTMLMediaElement.h:
+
+        * page/PageGroupLoadDeferrer.cpp:
+        (WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer): Pass WillShowDialog to suspendActiveDOMObjects.
+
+        * page/SuspendableTimer.cpp:
+        (WebCore::SuspendableTimer::suspend): Add ReasonForSuspension parameter.
+        * page/SuspendableTimer.h:
+
+        * websockets/WebSocket.cpp:
+        (WebCore::WebSocket::suspend): Ditto.
+        * websockets/WebSocket.h:
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::suspend): Ditto.
+        * xml/XMLHttpRequest.h:
+
 2010-09-13  Sam Weinig  <sam at webkit.org>
 
         Fix the mac build.
diff --git a/WebCore/bindings/generic/ActiveDOMCallback.cpp b/WebCore/bindings/generic/ActiveDOMCallback.cpp
index f62bf83..bc93de5 100644
--- a/WebCore/bindings/generic/ActiveDOMCallback.cpp
+++ b/WebCore/bindings/generic/ActiveDOMCallback.cpp
@@ -76,7 +76,7 @@ public:
         ActiveDOMObject::contextDestroyed();
     }
     virtual bool canSuspend() const { return false; }
-    virtual void suspend()
+    virtual void suspend(ReasonForSuspension)
     {
         MutexLocker locker(m_mutex);
         m_suspended = true;
diff --git a/WebCore/bindings/js/ScriptDebugServer.cpp b/WebCore/bindings/js/ScriptDebugServer.cpp
index ecb7fa6..1decefa 100644
--- a/WebCore/bindings/js/ScriptDebugServer.cpp
+++ b/WebCore/bindings/js/ScriptDebugServer.cpp
@@ -406,7 +406,7 @@ void ScriptDebugServer::setJavaScriptPaused(Frame* frame, bool paused)
 
     Document* document = frame->document();
     if (paused)
-        document->suspendActiveDOMObjects();
+        document->suspendActiveDOMObjects(ActiveDOMObject::JavaScriptDebuggerPaused);
     else
         document->resumeActiveDOMObjects();
 
diff --git a/WebCore/dom/ActiveDOMObject.cpp b/WebCore/dom/ActiveDOMObject.cpp
index 98c9761..0b70b24 100644
--- a/WebCore/dom/ActiveDOMObject.cpp
+++ b/WebCore/dom/ActiveDOMObject.cpp
@@ -66,7 +66,7 @@ bool ActiveDOMObject::canSuspend() const
     return false;
 }
 
-void ActiveDOMObject::suspend()
+void ActiveDOMObject::suspend(ReasonForSuspension)
 {
 }
 
diff --git a/WebCore/dom/ActiveDOMObject.h b/WebCore/dom/ActiveDOMObject.h
index 73b52d5..a6ec7d3 100644
--- a/WebCore/dom/ActiveDOMObject.h
+++ b/WebCore/dom/ActiveDOMObject.h
@@ -48,8 +48,13 @@ namespace WebCore {
         // However, 'suspend' can be called even if canSuspend() would return 'false'. That
         // happens in step-by-step JS debugging for example - in this case it would be incorrect
         // to stop the object. Exact semantics of suspend is up to the object then.
+        enum ReasonForSuspension {
+            JavaScriptDebuggerPaused,
+            WillShowDialog,
+            DocumentWillBecomeInactive
+        };
         virtual bool canSuspend() const;
-        virtual void suspend();
+        virtual void suspend(ReasonForSuspension);
         virtual void resume();
         virtual void stop();
 
diff --git a/WebCore/dom/ScriptExecutionContext.cpp b/WebCore/dom/ScriptExecutionContext.cpp
index 975dece..f7b4420 100644
--- a/WebCore/dom/ScriptExecutionContext.cpp
+++ b/WebCore/dom/ScriptExecutionContext.cpp
@@ -184,13 +184,13 @@ bool ScriptExecutionContext::canSuspendActiveDOMObjects()
     return true;
 }
 
-void ScriptExecutionContext::suspendActiveDOMObjects()
+void ScriptExecutionContext::suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension why)
 {
     // No protection against m_activeDOMObjects changing during iteration: suspend() shouldn't execute arbitrary JS.
     HashMap<ActiveDOMObject*, void*>::iterator activeObjectsEnd = m_activeDOMObjects.end();
     for (HashMap<ActiveDOMObject*, void*>::iterator iter = m_activeDOMObjects.begin(); iter != activeObjectsEnd; ++iter) {
         ASSERT(iter->first->scriptExecutionContext() == this);
-        iter->first->suspend();
+        iter->first->suspend(why);
     }
 }
 
diff --git a/WebCore/dom/ScriptExecutionContext.h b/WebCore/dom/ScriptExecutionContext.h
index 55fa539..5f6f029 100644
--- a/WebCore/dom/ScriptExecutionContext.h
+++ b/WebCore/dom/ScriptExecutionContext.h
@@ -27,6 +27,7 @@
 #ifndef ScriptExecutionContext_h
 #define ScriptExecutionContext_h
 
+#include "ActiveDOMObject.h"
 #include "Console.h"
 #include "KURL.h"
 #include <wtf/Forward.h>
@@ -44,7 +45,6 @@
 
 namespace WebCore {
 
-    class ActiveDOMObject;
     class Blob;
 #if ENABLE(DATABASE)
     class Database;
@@ -99,7 +99,7 @@ namespace WebCore {
         bool canSuspendActiveDOMObjects();
         // Active objects can be asked to suspend even if canSuspendActiveDOMObjects() returns 'false' -
         // step-by-step JS debugging is one example.
-        void suspendActiveDOMObjects();
+        void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension);
         void resumeActiveDOMObjects();
         void stopActiveDOMObjects();
         void createdActiveDOMObject(ActiveDOMObject*, void* upcastPointer);
diff --git a/WebCore/history/CachedFrame.cpp b/WebCore/history/CachedFrame.cpp
index f0a4fed..470e03f 100644
--- a/WebCore/history/CachedFrame.cpp
+++ b/WebCore/history/CachedFrame.cpp
@@ -128,7 +128,7 @@ CachedFrame::CachedFrame(Frame* frame)
     ASSERT(m_view);
 
     // Active DOM objects must be suspended before we cached the frame script data
-    m_document->suspendActiveDOMObjects();
+    m_document->suspendActiveDOMObjects(ActiveDOMObject::DocumentWillBecomeInactive);
     m_cachedFrameScriptData = adoptPtr(new ScriptCachedFrameData(frame));
     
     // Custom scrollbar renderers will get reattached when the document comes out of the page cache
diff --git a/WebCore/html/HTMLMarqueeElement.cpp b/WebCore/html/HTMLMarqueeElement.cpp
index ada26c1..8128188 100644
--- a/WebCore/html/HTMLMarqueeElement.cpp
+++ b/WebCore/html/HTMLMarqueeElement.cpp
@@ -132,7 +132,7 @@ bool HTMLMarqueeElement::canSuspend() const
     return true;
 }
 
-void HTMLMarqueeElement::suspend()
+void HTMLMarqueeElement::suspend(ReasonForSuspension)
 {
     if (RenderMarquee* marqueeRenderer = renderMarquee())
         marqueeRenderer->suspend();
diff --git a/WebCore/html/HTMLMarqueeElement.h b/WebCore/html/HTMLMarqueeElement.h
index 1b3229a..a4825fc 100644
--- a/WebCore/html/HTMLMarqueeElement.h
+++ b/WebCore/html/HTMLMarqueeElement.h
@@ -49,7 +49,7 @@ private:
 
     // ActiveDOMObject
     virtual bool canSuspend() const;
-    virtual void suspend();
+    virtual void suspend(ReasonForSuspension);
     virtual void resume();
 
     RenderMarquee* renderMarquee() const;
diff --git a/WebCore/html/HTMLMediaElement.cpp b/WebCore/html/HTMLMediaElement.cpp
index 65d350f..bf7463a 100644
--- a/WebCore/html/HTMLMediaElement.cpp
+++ b/WebCore/html/HTMLMediaElement.cpp
@@ -2020,29 +2020,38 @@ bool HTMLMediaElement::canSuspend() const
 void HTMLMediaElement::stop()
 {
     LOG(Media, "HTMLMediaElement::stop");
-    suspend();
-}
-
-void HTMLMediaElement::suspend()
-{
-    LOG(Media, "HTMLMediaElement::suspend");
-
     if (m_isFullscreen)
         exitFullscreen();
-
+    
     m_inActiveDocument = false;
     userCancelledLoad();
-
+    
     // Stop the playback without generating events
     setPausedInternal(true);
-
+    
     if (renderer())
         renderer()->updateFromElement();
-
+    
     stopPeriodicTimers();
     cancelPendingEventsAndCallbacks();
 }
 
+void HTMLMediaElement::suspend(ReasonForSuspension why)
+{
+    LOG(Media, "HTMLMediaElement::suspend");
+    
+    switch (why)
+    {
+        case DocumentWillBecomeInactive:
+            stop();
+            break;
+        case JavaScriptDebuggerPaused:
+        case WillShowDialog:
+            // Do nothing, we don't pause media playback in these cases.
+            break;
+    }
+}
+
 void HTMLMediaElement::resume()
 {
     LOG(Media, "HTMLMediaElement::resume");
diff --git a/WebCore/html/HTMLMediaElement.h b/WebCore/html/HTMLMediaElement.h
index adea0fd..db75a9c 100644
--- a/WebCore/html/HTMLMediaElement.h
+++ b/WebCore/html/HTMLMediaElement.h
@@ -199,7 +199,7 @@ private:
     
     // ActiveDOMObject functions.
     virtual bool canSuspend() const;
-    virtual void suspend();
+    virtual void suspend(ReasonForSuspension);
     virtual void resume();
     virtual void stop();
     virtual bool hasPendingActivity() const;
diff --git a/WebCore/page/PageGroupLoadDeferrer.cpp b/WebCore/page/PageGroupLoadDeferrer.cpp
index 79554cf..98a4720 100644
--- a/WebCore/page/PageGroupLoadDeferrer.cpp
+++ b/WebCore/page/PageGroupLoadDeferrer.cpp
@@ -44,8 +44,10 @@ PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page* page, bool deferSelf)
 
                 // This code is not logically part of load deferring, but we do not want JS code executed beneath modal
                 // windows or sheets, which is exactly when PageGroupLoadDeferrer is used.
+                // NOTE: if PageGroupLoadDeferrer is ever used for tasks other than showing a modal window or sheet,
+                // the constructor will need to take a ActiveDOMObject::ReasonForSuspension.
                 for (Frame* frame = otherPage->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
-                    frame->document()->suspendActiveDOMObjects();
+                    frame->document()->suspendActiveDOMObjects(ActiveDOMObject::WillShowDialog);
                     frame->document()->asyncScriptRunner()->suspend();
                 }
             }
diff --git a/WebCore/page/SuspendableTimer.cpp b/WebCore/page/SuspendableTimer.cpp
index 532b0ed..23f00b0 100644
--- a/WebCore/page/SuspendableTimer.cpp
+++ b/WebCore/page/SuspendableTimer.cpp
@@ -55,7 +55,7 @@ void SuspendableTimer::stop()
     TimerBase::stop();
 }
 
-void SuspendableTimer::suspend()
+void SuspendableTimer::suspend(ReasonForSuspension)
 {
 #if !ASSERT_DISABLED
     ASSERT(!m_suspended);
diff --git a/WebCore/page/SuspendableTimer.h b/WebCore/page/SuspendableTimer.h
index eae6153..cc90b62 100644
--- a/WebCore/page/SuspendableTimer.h
+++ b/WebCore/page/SuspendableTimer.h
@@ -41,7 +41,7 @@ public:
     virtual bool hasPendingActivity() const;
     virtual void stop();
     virtual bool canSuspend() const;
-    virtual void suspend();
+    virtual void suspend(ReasonForSuspension);
     virtual void resume();
 
 private:
diff --git a/WebCore/websockets/WebSocket.cpp b/WebCore/websockets/WebSocket.cpp
index 38629d7..073a924 100644
--- a/WebCore/websockets/WebSocket.cpp
+++ b/WebCore/websockets/WebSocket.cpp
@@ -216,7 +216,7 @@ bool WebSocket::canSuspend() const
     return !m_channel;
 }
 
-void WebSocket::suspend()
+void WebSocket::suspend(ReasonForSuspension)
 {
     if (m_channel)
         m_channel->suspend();
diff --git a/WebCore/websockets/WebSocket.h b/WebCore/websockets/WebSocket.h
index fd3ee56..7f63cbf 100644
--- a/WebCore/websockets/WebSocket.h
+++ b/WebCore/websockets/WebSocket.h
@@ -83,7 +83,7 @@ namespace WebCore {
         virtual ScriptExecutionContext* scriptExecutionContext() const;
         virtual void contextDestroyed();
         virtual bool canSuspend() const;
-        virtual void suspend();
+        virtual void suspend(ReasonForSuspension);
         virtual void resume();
         virtual void stop();
 
diff --git a/WebCore/xml/XMLHttpRequest.cpp b/WebCore/xml/XMLHttpRequest.cpp
index 9f93e1a..9c7d076 100644
--- a/WebCore/xml/XMLHttpRequest.cpp
+++ b/WebCore/xml/XMLHttpRequest.cpp
@@ -1061,7 +1061,7 @@ bool XMLHttpRequest::canSuspend() const
     return !m_loader;
 }
 
-void XMLHttpRequest::suspend()
+void XMLHttpRequest::suspend(ReasonForSuspension)
 {
     m_progressEventThrottle.suspend();
 }
diff --git a/WebCore/xml/XMLHttpRequest.h b/WebCore/xml/XMLHttpRequest.h
index d25f63f..ac18828 100644
--- a/WebCore/xml/XMLHttpRequest.h
+++ b/WebCore/xml/XMLHttpRequest.h
@@ -59,7 +59,7 @@ public:
 
     virtual void contextDestroyed();
     virtual bool canSuspend() const;
-    virtual void suspend();
+    virtual void suspend(ReasonForSuspension);
     virtual void resume();
     virtual void stop();
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list