2009-11-30 Eric Carlson <eric.carlson@apple.com>
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Nov 2009 21:43:57 +0000 (21:43 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Nov 2009 21:43:57 +0000 (21:43 +0000)
        Reviewed by Simon Fraser.

        All HTML5 media element events should be regular events
        https://bugs.webkit.org/show_bug.cgi?id=30513

        * html/HTMLMediaElement.cpp:
        (WebCore::HTMLMediaElement::selectMediaResource):
        (WebCore::HTMLMediaElement::noneSupported):
        (WebCore::HTMLMediaElement::mediaEngineError):
        (WebCore::HTMLMediaElement::setNetworkState):
        (WebCore::HTMLMediaElement::userCancelledLoad):
            Call scheduleEvent instead of scheduleProgressEvent.
        (WebCore::HTMLMediaElement::progressEventTimerFired):
            Call scheduleEvent instead of scheduleProgressEvent. Call renderer->updateFromElement
            after scheduling a 'progress' event so the controller will update download
            progress indicator.
        * html/HTMLMediaElement.h:
            Remove scheduleProgressEvent prototype.

2009-11-30  Eric Carlson  <eric.carlson@apple.com>

        Reviewed by Simon Fraser.

        All HTML5 media element events should be regular events
        https://bugs.webkit.org/show_bug.cgi?id=30513

        Remove progress event tests.

        * media/progress-event-at-least-one-expected.txt: Removed.
        * media/progress-event-at-least-one.html: Removed.
        * media/progress-event-expected.txt: Removed.
        * media/progress-event-total-expected.txt: Removed.
        * media/progress-event-total.html: Removed.
        * media/progress-event.html: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@51511 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/media/progress-event-at-least-one-expected.txt [deleted file]
LayoutTests/media/progress-event-at-least-one.html [deleted file]
LayoutTests/media/progress-event-expected.txt [deleted file]
LayoutTests/media/progress-event-total-expected.txt [deleted file]
LayoutTests/media/progress-event-total.html [deleted file]
LayoutTests/media/progress-event.html [deleted file]
WebCore/ChangeLog
WebCore/html/HTMLMediaElement.cpp
WebCore/html/HTMLMediaElement.h

index 20b2a03..7232df5 100644 (file)
@@ -1,3 +1,19 @@
+2009-11-30  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Simon Fraser.
+
+        All HTML5 media element events should be regular events
+        https://bugs.webkit.org/show_bug.cgi?id=30513
+        
+        Remove progress event tests.
+
+        * media/progress-event-at-least-one-expected.txt: Removed.
+        * media/progress-event-at-least-one.html: Removed.
+        * media/progress-event-expected.txt: Removed.
+        * media/progress-event-total-expected.txt: Removed.
+        * media/progress-event-total.html: Removed.
+        * media/progress-event.html: Removed.
+
 2009-11-30  Yuzo Fujishima  <yuzo@google.com>
 
         Reviewed by Alexey Proskuryakov.
diff --git a/LayoutTests/media/progress-event-at-least-one-expected.txt b/LayoutTests/media/progress-event-at-least-one-expected.txt
deleted file mode 100644 (file)
index 353eb0d..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-Test that at least one 'progress' event is fired before the 'load' event.
-
-RUN(mediaElement = document.createElement('audio'))
-RUN(mediaElement.src = 'content/test.wav')
-RUN(mediaElement.load())
-
-EVENT(loadstart)
-EVENT(durationchange)
-EVENT(loadedmetadata)
-EVENT(loadeddata)
-EVENT(canplaythrough)
-EXPECTED (progressEventCount >= '1') OK
-END OF TEST
-
diff --git a/LayoutTests/media/progress-event-at-least-one.html b/LayoutTests/media/progress-event-at-least-one.html
deleted file mode 100644 (file)
index d129156..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<html>
-    <head>
-        <script src=media-file.js></script>
-        <script src=video-test.js></script>
-
-        <script>
-
-            var progressEventCount = 0;
-
-            function progress()
-            {
-                // 'progress' events can fire an arbitrary number of times if the
-                // file loads slowly, and the order of the first event in relation
-                // to the other events is not guaranteed, and we only want to ensure
-                // that AT LEAST one is fired so just count the number of events instead
-                // of logging them.
-                if (++progressEventCount > 1)
-                    return;
-            }
-
-            function canplaythrough()
-            {
-                consoleWrite("EVENT(canplaythrough)");
-                
-                testExpected('progressEventCount', 1, '>=');
-                endTest();
-            }
-
-            function start()
-            {
-                run("mediaElement = document.createElement('audio')");
-
-                mediaElement.setAttribute('oncanplaythrough', "canplaythrough()");
-                mediaElement.setAttribute('onprogress', "progress()");
-
-                waitForEvent("loadstart");
-                waitForEvent("loaded");
-                waitForEvent("waiting");
-                waitForEvent("ratechange");
-                waitForEvent("durationchange");
-                waitForEvent("pause");
-                waitForEvent("play");
-                waitForEvent("playing");
-                waitForEvent('loadedmetadata');
-                waitForEvent('loadeddata');
-
-                var mediaFile = findMediaFile("audio", "content/test");
-                run("mediaElement.src = '" + mediaFile + "'");
-                run("mediaElement.load()");
-
-                consoleWrite("");
-            }
-
-        </script>
-    </head>
-
-    <body onload="start()">
-
-    <p>Test that at least one 'progress' event is fired before the 'load' event.</p>
-
-    </body>
-</html>
diff --git a/LayoutTests/media/progress-event-expected.txt b/LayoutTests/media/progress-event-expected.txt
deleted file mode 100644 (file)
index 72c0b26..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-EVENT(loadstart)
-EXPECTED (!event.lengthComputable == 'true') OK
-EXPECTED (event.total == '0') OK
-EXPECTED (event.loaded == '0') OK
-END OF TEST
-
diff --git a/LayoutTests/media/progress-event-total-expected.txt b/LayoutTests/media/progress-event-total-expected.txt
deleted file mode 100644 (file)
index 818aab7..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-EVENT(loadstart)
-EXPECTED (!event.lengthComputable == 'true') OK
-EXPECTED (event.total == '0') OK
-EXPECTED (event.loaded == '0') OK
-EVENT(progress)
-EXPECTED (event.lengthComputable == 'true') OK
-EXPECTED (event.loaded > '0') OK
-END OF TEST
-
diff --git a/LayoutTests/media/progress-event-total.html b/LayoutTests/media/progress-event-total.html
deleted file mode 100644 (file)
index ed4959e..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<html>
-    <head>
-
-        <script src=media-file.js></script>
-        <script src=video-test.js></script>
-        <script>
-            function testOnLoadStart()
-            {
-                consoleWrite("EVENT(" + event.type + ")");
-                testExpected("!event.lengthComputable", true);
-                testExpected("event.total", 0);
-                testExpected("event.loaded", 0);
-            }
-        
-            function testOnProgress()
-            {
-                consoleWrite("EVENT(" + event.type + ")");
-                testExpected("event.lengthComputable", true);
-                testExpected("event.loaded", 0, '>');
-                endTest();
-            }
-
-            function start()
-            {
-                setSrcByTagName("video", findMediaFile("video", "content/test"));
-                findMediaElement();
-            }
-
-        </script>
-    </head>
-
-    <body onload="start()">
-
-        <video controls onloadstart="testOnLoadStart()" onprogress="testOnProgress()">
-        </video>
-
-    </body>
-</html>
diff --git a/LayoutTests/media/progress-event.html b/LayoutTests/media/progress-event.html
deleted file mode 100644 (file)
index 35cbff0..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<html>
-    <head>
-
-        <script src=media-file.js></script>
-        <script src=video-test.js></script>
-        <script>
-            function testOnLoadStart()
-            {
-                consoleWrite("EVENT(" + event.type + ")");
-                testExpected("!event.lengthComputable", true);
-                testExpected("event.total", 0);
-                testExpected("event.loaded", 0);
-                endTest();
-            }
-        
-            function start()
-            {
-                setSrcByTagName("video", findMediaFile("video", "content/test"));
-                findMediaElement();
-            }
-        </script>
-    </head>
-
-    <body onload="start()">
-
-        <video controls onloadstart="testOnLoadStart()" >
-        </video>
-
-    </body>
-</html>
index 548ccdd..6692c4f 100644 (file)
@@ -1,3 +1,24 @@
+2009-11-30  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Simon Fraser.
+
+        All HTML5 media element events should be regular events
+        https://bugs.webkit.org/show_bug.cgi?id=30513
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::selectMediaResource):
+        (WebCore::HTMLMediaElement::noneSupported):
+        (WebCore::HTMLMediaElement::mediaEngineError):
+        (WebCore::HTMLMediaElement::setNetworkState):
+        (WebCore::HTMLMediaElement::userCancelledLoad):
+            Call scheduleEvent instead of scheduleProgressEvent.
+        (WebCore::HTMLMediaElement::progressEventTimerFired):
+            Call scheduleEvent instead of scheduleProgressEvent. Call renderer->updateFromElement
+            after scheduling a 'progress' event so the controller will update download
+            progress indicator.
+        * html/HTMLMediaElement.h:
+            Remove scheduleProgressEvent prototype.
+
 2009-11-30  Joseph Pecoraro  <joepeck@webkit.org>
 
         Reviewed by Pavel Feldman.
index 99e2f1e..30f762a 100644 (file)
@@ -297,24 +297,6 @@ void HTMLMediaElement::scheduleNextSourceChild()
     m_loadTimer.startOneShot(0);
 }
 
-void HTMLMediaElement::scheduleProgressEvent(const AtomicString& eventName)
-{
-    if (!m_sendProgressEvents)
-        return;
-
-    // FIXME: don't schedule timeupdate or progress events unless there are registered listeners
-
-    bool totalKnown = m_player && m_player->totalBytesKnown();
-    unsigned loaded = m_player ? m_player->bytesLoaded() : 0;
-    unsigned total = m_player ? m_player->totalBytes() : 0;
-
-    RefPtr<ProgressEvent> evt = ProgressEvent::create(eventName, totalKnown, loaded, total);
-    enqueueEvent(evt);
-
-    if (renderer())
-        renderer()->updateFromElement();
-}
-
 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName)
 {
     enqueueEvent(Event::create(eventName, false, true));
@@ -529,7 +511,7 @@ void HTMLMediaElement::selectMediaResource()
     m_networkState = NETWORK_LOADING;
 
     // 5
-    scheduleProgressEvent(eventNames().loadstartEvent);
+    scheduleEvent(eventNames().loadstartEvent);
 
     // 6 - If the media element has a src attribute, then run these substeps
     ContentType contentType("");
@@ -652,7 +634,7 @@ void HTMLMediaElement::noneSupported()
     // 7 - Queue a task to fire a progress event called error at the media element, in
     // the context of the fetching process that was used to try to obtain the media
     // resource in the resource fetch algorithm.
-    scheduleProgressEvent(eventNames().errorEvent);
+    scheduleEvent(eventNames().errorEvent);
 
     // 8 - Set the element's delaying-the-load-event flag to false. This stops delaying the load event.
     m_delayingTheLoadEvent = false;
@@ -677,7 +659,7 @@ void HTMLMediaElement::mediaEngineError(PassRefPtr<MediaError> err)
 
     // 3 - Queue a task to fire a progress event called error at the media element, in
     // the context of the fetching process started by this instance of this algorithm.
-    scheduleProgressEvent(eventNames().errorEvent);
+    scheduleEvent(eventNames().errorEvent);
 
     // 4 - Set the element's networkState attribute to the NETWORK_EMPTY value and queue a
     // task to fire a simple event called emptied at the element.
@@ -744,7 +726,7 @@ void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state)
     if (state == MediaPlayer::Idle) {
         if (m_networkState > NETWORK_IDLE) {
             stopPeriodicTimers();
-            scheduleProgressEvent(eventNames().suspendEvent);
+            scheduleEvent(eventNames().suspendEvent);
         }
         m_networkState = NETWORK_IDLE;
     }
@@ -764,7 +746,7 @@ void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state)
 
             // Schedule one last progress event so we guarantee that at least one is fired
             // for files that load very quickly.
-            scheduleProgressEvent(eventNames().progressEvent);
+            scheduleEvent(eventNames().progressEvent);
 
             // Check to see if readyState changes need to be dealt with before sending the 
             // 'load' event so we report 'canplaythrough' first. This is necessary because a
@@ -773,7 +755,7 @@ void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state)
             if (static_cast<ReadyState>(currentState) != m_readyState)
                 setReadyState(currentState);
 
-            scheduleProgressEvent(eventNames().loadEvent);
+            scheduleEvent(eventNames().loadEvent);
         }
     }
 }
@@ -890,14 +872,16 @@ void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*)
 
     if (progress == m_previousProgress) {
         if (timedelta > 3.0 && !m_sentStalledEvent) {
-            scheduleProgressEvent(eventNames().stalledEvent);
+            scheduleEvent(eventNames().stalledEvent);
             m_sentStalledEvent = true;
         }
     } else {
-        scheduleProgressEvent(eventNames().progressEvent);
+        scheduleEvent(eventNames().progressEvent);
         m_previousProgress = progress;
         m_previousProgressTime = time;
         m_sentStalledEvent = false;
+        if (renderer())
+            renderer()->updateFromElement();
     }
 }
 
@@ -1657,7 +1641,7 @@ void HTMLMediaElement::userCancelledLoad()
 
     // 3 - Queue a task to fire a progress event called abort at the media element, in the context
     // of the fetching process started by this instance of this algorithm.
-    scheduleProgressEvent(eventNames().abortEvent);
+    scheduleEvent(eventNames().abortEvent);
 
     // 5 - If the media element's readyState attribute has a value equal to HAVE_NOTHING, set the
     // element's networkState attribute to the NETWORK_EMPTY value and queue a task to fire a
index b868359..bc39dd7 100644 (file)
@@ -218,7 +218,6 @@ private:
     void addPlayedRange(float start, float end);
     
     void scheduleTimeupdateEvent(bool periodicEvent);
-    void scheduleProgressEvent(const AtomicString& eventName);
     void scheduleEvent(const AtomicString& eventName);
     void enqueueEvent(RefPtr<Event> event);