Repaint video controls when buffering during pause.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Jan 2012 01:51:19 +0000 (01:51 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Jan 2012 01:51:19 +0000 (01:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=73957

Source/WebCore:

Pipes support for a new bufferingProgressed() method on MediaControls
elements. Allows controls to be repainted as data buffers when paused.

Patch by Dale Curtis <dalecurtis@chromium.org> on 2012-01-10
Reviewed by Hajime Morita.

Test: http/tests/media/video-buffering-repaints-controls.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setNetworkState):
(WebCore::HTMLMediaElement::progressEventTimerFired):
* html/shadow/MediaControlRootElement.cpp:
(WebCore::MediaControlRootElement::bufferingProgressed):
* html/shadow/MediaControlRootElement.h:
* html/shadow/MediaControlRootElementChromium.cpp:
(WebCore::MediaControlRootElementChromium::bufferingProgressed):
* html/shadow/MediaControlRootElementChromium.h:
* html/shadow/MediaControls.h:

LayoutTests:

Adds video-buffering-repaints-controls test to verify the progress bar
repaints as new data is buffered when paused.

Patch by Dale Curtis <dalecurtis@chromium.org> on 2012-01-10
Reviewed by Hajime Morita.

* http/tests/media/video-buffering-repaints-controls.html: Added.
* platform/chromium-linux/http/tests/media/video-buffering-repaints-controls-expected.png: Added.
* platform/chromium-linux/http/tests/media/video-buffering-repaints-controls-expected.txt: Added.
* platform/chromium/test_expectations.txt:
* platform/gtk/test_expectations.txt:
* platform/mac/test_expectations.txt:
* platform/win/test_expectations.txt:

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

15 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/media/video-buffering-repaints-controls.html [new file with mode: 0644]
LayoutTests/platform/chromium-linux/http/tests/media/video-buffering-repaints-controls-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-linux/http/tests/media/video-buffering-repaints-controls-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/gtk/test_expectations.txt
LayoutTests/platform/mac/test_expectations.txt
LayoutTests/platform/win/test_expectations.txt
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/shadow/MediaControlRootElement.cpp
Source/WebCore/html/shadow/MediaControlRootElement.h
Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp
Source/WebCore/html/shadow/MediaControlRootElementChromium.h
Source/WebCore/html/shadow/MediaControls.h

index e19c48e..2958f4f 100644 (file)
@@ -1,3 +1,21 @@
+2012-01-10  Dale Curtis  <dalecurtis@chromium.org>
+
+        Repaint video controls when buffering during pause.
+        https://bugs.webkit.org/show_bug.cgi?id=73957
+
+        Adds video-buffering-repaints-controls test to verify the progress bar
+        repaints as new data is buffered when paused.
+
+        Reviewed by Hajime Morita.
+
+        * http/tests/media/video-buffering-repaints-controls.html: Added.
+        * platform/chromium-linux/http/tests/media/video-buffering-repaints-controls-expected.png: Added.
+        * platform/chromium-linux/http/tests/media/video-buffering-repaints-controls-expected.txt: Added.
+        * platform/chromium/test_expectations.txt:
+        * platform/gtk/test_expectations.txt:
+        * platform/mac/test_expectations.txt:
+        * platform/win/test_expectations.txt:
+
 2012-01-10  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r104543.
diff --git a/LayoutTests/http/tests/media/video-buffering-repaints-controls.html b/LayoutTests/http/tests/media/video-buffering-repaints-controls.html
new file mode 100644 (file)
index 0000000..6333cb8
--- /dev/null
@@ -0,0 +1,36 @@
+<html>
+   <head>
+       <script src="../../media-resources/media-file.js"></script>
+       <script>
+           var painted = false;
+           function start() {
+               if (window.layoutTestController)
+                   layoutTestController.waitUntilDone();
+
+                var video = document.querySelector('video');
+
+                video.addEventListener('progress', function(event) {
+                    // Each progress event should correlate to a repaint. Check
+                    // by watching for a repaint between progress events.
+                    if (painted) {
+                        layoutTestController.notifyDone();
+                    } else {
+                        layoutTestController.display();
+                        painted = true;
+                    }
+                }, false);
+
+                var mediaFile = findMediaFile("video", "resources/test");
+                var mimeType = mimeTypeForFile(mediaFile);
+
+                // Don't actually play since we're testing via an image diff.
+                video.src = 'http://127.0.0.1:8000/media/video-throttled-load.cgi?&name=' + mediaFile + '&throttle=10&type=' + mimeType
+            }
+        </script>
+    </head>
+
+    <body onload="start();">
+        <p>Test that media controls repaint correctly during paused states when new data is buffered.</p>
+        <video controls preload></video><br/>
+   </body>
+</html>
diff --git a/LayoutTests/platform/chromium-linux/http/tests/media/video-buffering-repaints-controls-expected.png b/LayoutTests/platform/chromium-linux/http/tests/media/video-buffering-repaints-controls-expected.png
new file mode 100644 (file)
index 0000000..21b0eb6
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/http/tests/media/video-buffering-repaints-controls-expected.png differ
diff --git a/LayoutTests/platform/chromium-linux/http/tests/media/video-buffering-repaints-controls-expected.txt b/LayoutTests/platform/chromium-linux/http/tests/media/video-buffering-repaints-controls-expected.txt
new file mode 100644 (file)
index 0000000..f7d5898
--- /dev/null
@@ -0,0 +1,33 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x20
+        RenderText {#text} at (0,0) size 538x19
+          text run at (0,0) width 538: "Test that media controls repaint correctly during paused states when new data is buffered."
+      RenderBlock (anonymous) at (0,36) size 784x240
+        RenderBR {BR} at (320,240) size 0x0
+layer at (8,44) size 320x240
+  RenderVideo {VIDEO} at (0,0) size 320x240
+layer at (8,44) size 320x240
+  RenderBlock (relative positioned) {DIV} at (0,0) size 320x240
+layer at (8,252) size 320x32
+  RenderDeprecatedFlexibleBox (positioned) {DIV} at (0,208) size 320x32 [bgcolor=#00000099]
+layer at (15,258) size 18x19
+  RenderButton {INPUT} at (7,6) size 18x19
+layer at (38,252) size 256x32
+  RenderDeprecatedFlexibleBox (positioned) {DIV} at (30,0) size 256x32 [border: (1px solid #FFFFFF33) none (1px solid #FFFFFF33)]
+    RenderSlider {INPUT} at (7,7) size 184x18 [color=#328CDF] [bgcolor=#FFFFFF14] [border: (1px solid #FFFFFF33)]
+      RenderDeprecatedFlexibleBox {DIV} at (1,1) size 182x16
+        RenderBlock {DIV} at (0,0) size 173x29
+        RenderBlock {DIV} at (173,0) size 9x29
+layer at (235,258) size 58x20 scrollHeight 21
+  RenderDeprecatedFlexibleBox {DIV} at (197,6) size 58x20 [color=#FFFFFF]
+    RenderBlock (anonymous) at (8,0) size 42x21
+      RenderText {#text} at (0,1) size 42x19
+        text run at (0,1) width 42: "00:00"
+layer at (46,254) size 9x29
+  RenderBlock (relative positioned) {DIV} at (0,-6) size 9x29
+layer at (294,252) size 34x32
+  RenderButton {INPUT} at (286,0) size 34x32
index 0910485..c62d672 100644 (file)
@@ -3848,3 +3848,6 @@ BUGWK75932 : fast/js/array-defineOwnProperty.html = TEXT
 BUGWK75932 : fast/js/mozilla/strict/15.4.4.6.html = TEXT
 
 BUGWK75933 WIN : webaudio/convolution-mono-mono.html = TEXT
+
+// New test, needs image results added.
+BUGWK75570 : http/tests/media/video-buffering-repaints-controls.html = IMAGE
index fc37444..b71033a 100644 (file)
@@ -96,4 +96,5 @@ BUGWK74270 : fast/forms/basic-selects.html = FAIL
 
 BUGWK75432 : fast/dom/constructed-objects-prototypes.html = FAIL
 
-
+// New test, needs image results added.
+BUGWK75570 : http/tests/media/video-buffering-repaints-controls.html = IMAGE
index a3879db..bb9bb8f 100644 (file)
@@ -189,3 +189,6 @@ BUGWK74888 : fast/dom/HTMLTableElement/colSpan.html = IMAGE+TEXT
 BUGWK74888 : fast/dom/HTMLTableElement/createCaption.html = IMAGE+TEXT
 BUGWK74888 : fast/repaint/table-section-repaint.html = TEXT
 BUGWK74888 : fast/table/frame-and-rules.html = TEXT
+
+// New test, needs image results added.
+BUGWK75570 : http/tests/media/video-buffering-repaints-controls.html = IMAGE
index 9aa5e92..a34724c 100644 (file)
@@ -122,3 +122,6 @@ BUGWK74888 : fast/css/bidi-override-in-anonymous-block.html = TEXT
 BUGWK74888 : fast/dom/HTMLTableElement/colSpan.html = IMAGE+TEXT
 BUGWK74888 : fast/dom/HTMLTableElement/createCaption.html = IMAGE+TEXT
 BUGWK74888 : fast/repaint/table-section-repaint.html = TEXT
+
+// New test, needs image results added.
+BUGWK75570 : http/tests/media/video-buffering-repaints-controls.html = IMAGE
index 1d6e3f4..096b557 100644 (file)
@@ -1,3 +1,26 @@
+2012-01-10  Dale Curtis  <dalecurtis@chromium.org>
+
+        Repaint video controls when buffering during pause.
+        https://bugs.webkit.org/show_bug.cgi?id=73957
+
+        Pipes support for a new bufferingProgressed() method on MediaControls
+        elements. Allows controls to be repainted as data buffers when paused.
+
+        Reviewed by Hajime Morita.
+
+        Test: http/tests/media/video-buffering-repaints-controls.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::setNetworkState):
+        (WebCore::HTMLMediaElement::progressEventTimerFired):
+        * html/shadow/MediaControlRootElement.cpp:
+        (WebCore::MediaControlRootElement::bufferingProgressed):
+        * html/shadow/MediaControlRootElement.h:
+        * html/shadow/MediaControlRootElementChromium.cpp:
+        (WebCore::MediaControlRootElementChromium::bufferingProgressed):
+        * html/shadow/MediaControlRootElementChromium.h:
+        * html/shadow/MediaControls.h:
+
 2012-01-10  Daniel Cheng  <dcheng@chromium.org>
 
         [chromium] Pasteboard::documentFragment should fall back to text if there's no HTML text
index 524a1fa..97253a3 100644 (file)
@@ -1274,6 +1274,9 @@ void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state)
     if (state == MediaPlayer::Idle) {
         if (m_networkState > NETWORK_IDLE) {
             m_progressEventTimer.stop();
+            if (hasMediaControls() && m_player->bytesLoaded() != m_previousProgress)
+                mediaControls()->bufferingProgressed();
+
             scheduleEvent(eventNames().suspendEvent);
             setShouldDelayLoadEvent(false);
         }
@@ -1289,6 +1292,8 @@ void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state)
     if (state == MediaPlayer::Loaded) {
         if (m_networkState != NETWORK_IDLE) {
             m_progressEventTimer.stop();
+            if (hasMediaControls() && m_player->bytesLoaded() != m_previousProgress)
+                mediaControls()->bufferingProgressed();
 
             // Schedule one last progress event so we guarantee that at least one is fired
             // for files that load very quickly.
@@ -1452,6 +1457,8 @@ void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*)
         m_sentStalledEvent = false;
         if (renderer())
             renderer()->updateFromElement();
+        if (hasMediaControls())
+            mediaControls()->bufferingProgressed();
     }
 }
 
index 46db413..a358bd0 100644 (file)
@@ -664,6 +664,14 @@ const AtomicString& MediaControlRootElement::shadowPseudoId() const
     return id;
 }
 
+void MediaControlRootElement::bufferingProgressed()
+{
+    // We only need to update buffering progress when paused, during normal
+    // playback playbackProgressed() will take care of it.
+    if (m_mediaController->paused())
+        m_timeline->setPosition(m_mediaController->currentTime());
+}
+
 }
 
 #endif
index 7010d02..1067509 100644 (file)
@@ -112,6 +112,8 @@ public:
 
     virtual bool shouldHideControls();
 
+    void bufferingProgressed();
+
 private:
     MediaControlRootElement(Document*);
 
index f2ce626..e69d818 100644 (file)
@@ -398,6 +398,14 @@ const AtomicString& MediaControlRootElementChromium::shadowPseudoId() const
     return id;
 }
 
+void MediaControlRootElementChromium::bufferingProgressed()
+{
+    // We only need to update buffering progress when paused, during normal
+    // playback playbackProgressed() will take care of it.
+    if (m_mediaController->paused())
+        m_timeline->setPosition(m_mediaController->currentTime());
+}
+
 }
 
 #endif
index d895c3b..366186b 100644 (file)
@@ -99,6 +99,8 @@ public:
     void updateTextTrackDisplay();
 #endif
 
+    void bufferingProgressed();
+
     virtual bool shouldHideControls();
 
 private:
index a61e34e..28908a9 100644 (file)
@@ -78,6 +78,8 @@ class MediaControls : public HTMLDivElement {
     virtual void updateTextTrackDisplay() = 0;
 #endif
 
+    virtual void bufferingProgressed() = 0;
+
 protected:
     MediaControls(Document*);