2011-07-27 Eric Carlson <eric.carlson@apple.com>
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jul 2011 22:01:02 +0000 (22:01 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jul 2011 22:01:02 +0000 (22:01 +0000)
        Load delegate not consulted before loading some poster images
        https://bugs.webkit.org/show_bug.cgi?id=65270

        Reviewed by Darin Adler.

        Test: media/video-poster-blocked-by-willsendrequest.html

        * html/HTMLVideoElement.cpp:
        (WebCore::HTMLVideoElement::setDisplayMode): Don't ask media engine to set poster if
            willLoadMediaElementURL returns false.

2011-07-27  Eric Carlson  <eric.carlson@apple.com>

        Load delegate not consulted before loading some poster images
        https://bugs.webkit.org/show_bug.cgi?id=65270

        Reviewed by Darin Adler.

        * media/video-poster-blocked-by-willsendrequest-expected.txt: Added.
        * media/video-poster-blocked-by-willsendrequest.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/media/video-poster-blocked-by-willsendrequest-expected.txt [new file with mode: 0644]
LayoutTests/media/video-poster-blocked-by-willsendrequest.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLVideoElement.cpp

index d11bf75..3bcf68f 100644 (file)
@@ -1,3 +1,13 @@
+2011-07-27  Eric Carlson  <eric.carlson@apple.com>
+
+        Load delegate not consulted before loading some poster images
+        https://bugs.webkit.org/show_bug.cgi?id=65270
+
+        Reviewed by Darin Adler.
+
+        * media/video-poster-blocked-by-willsendrequest-expected.txt: Added.
+        * media/video-poster-blocked-by-willsendrequest.html: Added.
+
 2011-07-27  Ryosuke Niwa  <rniwa@webkit.org>
 
         Chromium rebaselines for r89627 and r91497.
diff --git a/LayoutTests/media/video-poster-blocked-by-willsendrequest-expected.txt b/LayoutTests/media/video-poster-blocked-by-willsendrequest-expected.txt
new file mode 100644 (file)
index 0000000..1554508
--- /dev/null
@@ -0,0 +1,13 @@
+Test for https://bugs.webkit.org/show_bug.cgi?id=65270. 
+Resource load delegate should be able to block poster loading.
+
+
+Testing before setting poster
+EXPECTED (video.clientWidth == '300') OK
+EXPECTED (video.clientHeight == '150') OK
+
+Test after setting poster
+EXPECTED (video.clientWidth == '300') OK
+EXPECTED (video.clientHeight == '150') OK
+END OF TEST
+
diff --git a/LayoutTests/media/video-poster-blocked-by-willsendrequest.html b/LayoutTests/media/video-poster-blocked-by-willsendrequest.html
new file mode 100644 (file)
index 0000000..2408f8d
--- /dev/null
@@ -0,0 +1,52 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            video {
+                border: 3px solid red;
+                background-color: magenta;
+            }
+        </style>
+
+        <script src=video-test.js></script>
+        <script>
+        
+            var width, height;
+        
+            function testAfterLoadingPoster()
+            {
+                consoleWrite("<br><b>Test after setting poster</b>");
+
+                testExpected("video.clientWidth", 300);
+                testExpected("video.clientHeight", 150);
+
+                endTest();
+            }
+
+            function start()
+            {
+                if (window.layoutTestController) {
+                    layoutTestController.dumpAsText();
+                    layoutTestController.setWillSendRequestReturnsNull(true);
+                } else
+                    consoleWrite("<b>This test can only be run in DumpRenderTree!</b>");
+
+                video = document.querySelectorAll('video')[0];
+
+                consoleWrite("<br><b>Testing before setting poster</b>");
+                testExpected("video.clientWidth", 300);
+                testExpected("video.clientHeight", 150);
+
+                video.poster = "content/abe.png";
+
+                setTimeout(testAfterLoadingPoster, 100);
+            }
+        </script>
+    </head>
+
+    <body onload="start()">
+        <video id=video></video>
+        <p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=65270">https://bugs.webkit.org/show_bug.cgi?id=65270</a>. <br>
+        Resource load delegate should be able to block poster loading.</p>
+    </body>
+</html>
index 7f38dff..d8ab671 100644 (file)
@@ -1,3 +1,16 @@
+2011-07-27  Eric Carlson  <eric.carlson@apple.com>
+
+        Load delegate not consulted before loading some poster images
+        https://bugs.webkit.org/show_bug.cgi?id=65270
+
+        Reviewed by Darin Adler.
+
+        Test: media/video-poster-blocked-by-willsendrequest.html
+
+        * html/HTMLVideoElement.cpp:
+        (WebCore::HTMLVideoElement::setDisplayMode): Don't ask media engine to set poster if
+            willLoadMediaElementURL returns false.
+
 2011-07-27  Stephen White  <senorblanco@chromium.org>
 
         Fix for printing with accelerated <canvas>
index 7274bf1..7141423 100644 (file)
@@ -34,6 +34,7 @@
 #include "ChromeClient.h"
 #include "Document.h"
 #include "ExceptionCode.h"
+#include "Frame.h"
 #include "HTMLImageLoader.h"
 #include "HTMLNames.h"
 #include "Page.h"
@@ -196,8 +197,12 @@ void HTMLVideoElement::setDisplayMode(DisplayMode mode)
 
     HTMLMediaElement::setDisplayMode(mode);
 
-    if (player() && player()->canLoadPoster())
-        player()->setPoster(poster);
+    if (player() && player()->canLoadPoster()) {
+        Frame* frame = document()->frame();
+        FrameLoader* loader = frame ? frame->loader() : 0;
+        if (loader && loader->willLoadMediaElementURL(poster))
+            player()->setPoster(poster);
+    }
 
 #if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
     if (renderer() && displayMode() != oldMode)