[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric.carlson at apple.com eric.carlson at apple.com
Thu Apr 8 02:11:24 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 3c0a3857ebe2a30c31c463bc93b69c6d3f11b11a
Author: eric.carlson at apple.com <eric.carlson at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Mar 5 17:13:50 2010 +0000

    2010-03-04  Eric Carlson  <eric.carlson at apple.com>
    
            Reviewed by Adele Peterson.
    
            <rdar://problem/7718442> Implement 'preload=none'
            https://bugs.webkit.org/show_bug.cgi?id=35789
    
            Don't load any media data when preload is 'none'.
    
            Test: media/video-preload.html
    
            * html/HTMLMediaElement.cpp:
            (WebCore::HTMLMediaElement::loadResource): Don't call player's setPreload method
                when autoplay is set.
    
            * platform/graphics/MediaPlayer.cpp:
            (WebCore::MediaPlayer::setPreload): Set m_preload so we have the correct value when
                the media engine is created.
    
            * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
            * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
            (WebCore::MediaPlayerPrivate::MediaPlayerPrivate): Initialize m_preload.
            (WebCore::MediaPlayerPrivate::resumeLoad): New, kick off postponed a load.
            (WebCore::MediaPlayerPrivate::load): Do nothing if preload is 'none'
            (WebCore::MediaPlayerPrivate::loadInternal): New, complete loading.
            (WebCore::MediaPlayerPrivate::prepareToPlay): New, resume a postponed load as someone
                has called play().
            (WebCore::MediaPlayerPrivate::setPreload): New, set m_preload.
    
    
    2010-03-04  Eric Carlson  <eric.carlson at apple.com>
    
            Reviewed by Adele Peterson.
    
            <rdar://problem/7718442> Implement 'preload=none'
            https://bugs.webkit.org/show_bug.cgi?id=35789
    
            Functional test of the 'proload' attribute.
    
            * media/video-preload-expected.txt: Added.
            * media/video-preload.html: Added.
            * platform/win/Skipped: Skip on Windows for now.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55587 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 6d1daae..78a633b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2010-03-04  Eric Carlson  <eric.carlson at apple.com>
+
+        Reviewed by Adele Peterson.
+
+        <rdar://problem/7718442> Implement 'preload=none'
+        https://bugs.webkit.org/show_bug.cgi?id=35789
+
+        Functional test of the 'proload' attribute.
+
+        * media/video-preload-expected.txt: Added.
+        * media/video-preload.html: Added.
+        * platform/win/Skipped: Skip on Windows for now.
+
 2010-03-03  Antonio Gomes  <tonikitoo at webkit.org>
 
         Reviewed by Holger Freyther
diff --git a/LayoutTests/media/video-preload-expected.txt b/LayoutTests/media/video-preload-expected.txt
new file mode 100644
index 0000000..4d90a68
--- /dev/null
+++ b/LayoutTests/media/video-preload-expected.txt
@@ -0,0 +1,36 @@
+Test to see if media loads automatically when 'preload' is specified.
+
+
+Will load "content/silence.mpg" with 'preload=none', should not buffer automatically until 'play()' is called
+RUN(video.setAttribute('preload', 'none'))
+RUN(video.removeAttribute('autoplay'))
+EVENT(loadstart)
+did not buffer automatically OK
+RUN(video.play())
+EVENT(play)
+EVENT(loadedmetadata)
+buffered automatically OK
+
+Will load "content/silence.mpg" with 'preload=metadata', should buffer automatically 
+RUN(video.setAttribute('preload', 'metadata'))
+RUN(video.removeAttribute('autoplay'))
+EVENT(loadstart)
+EVENT(loadedmetadata)
+buffered automatically OK
+
+Will load "content/silence.mpg" with 'preload=auto', should buffer automatically 
+RUN(video.setAttribute('preload', 'auto'))
+RUN(video.removeAttribute('autoplay'))
+EVENT(loadstart)
+EVENT(loadedmetadata)
+buffered automatically OK
+
+Will load "content/silence.mpg" with 'preload=none', should buffer automatically because of 'autoplay'
+RUN(video.setAttribute('preload', 'none'))
+RUN(video.setAttribute('autoplay', 'true'))
+EVENT(loadstart)
+EVENT(loadedmetadata)
+buffered automatically OK
+
+END OF TEST
+
diff --git a/LayoutTests/media/video-preload.html b/LayoutTests/media/video-preload.html
new file mode 100644
index 0000000..1d06bbe
--- /dev/null
+++ b/LayoutTests/media/video-preload.html
@@ -0,0 +1,124 @@
+<!DOCTYPE HTML>
+
+<html>
+    <head>
+        <script src=media-file.js></script>
+        <script src=video-test.js></script>
+
+        <script>
+            var timer = null;
+            var movieInfo = 
+            {
+                current : -1,
+                movies : 
+                [ 
+                    {
+                        // should not buffer, 'preload' is 'none'
+                        url : "content/silence.mpg", 
+                        preload : "none",
+                        shouldBuffer : false,
+                        autoPlay : false,
+                        description : "until 'play()' is called", 
+                    },
+                    {
+                        url : "content/silence.mpg", 
+                        preload : "metadata",
+                        shouldBuffer : true,
+                        autoPlay : false,
+                        description : "", 
+                    },
+                    {
+                        url : "content/silence.mpg", 
+                        preload : "auto",
+                        shouldBuffer : true,
+                        autoPlay : false,
+                        description : "", 
+                    },
+                    {
+                        // should buffer because 'autoplay' is set
+                        url : "content/silence.mpg", 
+                        preload : "none",
+                        shouldBuffer : true,
+                        autoPlay : true,
+                        description : " because of 'autoplay'", 
+                    },
+                ]
+            };
+            var timer = null;
+
+            function checkLoad()
+            {
+                var movie = movieInfo.movies[movieInfo.current];
+
+                logResult(true, "did not buffer automatically");
+                
+                // start playback, which should force data to load
+                movie.shouldBuffer = true;
+                run("video.play()");
+            }
+
+            function loadedmetadata()
+            {
+                var movie = movieInfo.movies[movieInfo.current];
+
+                clearTimeout(timer);
+                logResult(movie.shouldBuffer, "buffered automatically");
+                openNextMovie();
+            }
+
+            function setupAttribute(attr, value)
+            {
+                if (value)
+                    run("video.setAttribute('" + attr + "', '" + value + "')");
+                else
+                    run("video.removeAttribute('" + attr + "')");
+            }
+
+            function openNextMovie()
+            {
+                consoleWrite("");
+
+                movieInfo.current++;
+                if (movieInfo.current >= movieInfo.movies.length)
+                {
+                    endTest();
+                    return;
+                }
+
+                var movie = movieInfo.movies[movieInfo.current];
+                var desc = "Will load <em>\""+ movie.url + "\"</em>"
+                            + " with <em>'preload=" + movie.preload + "'</em>"
+                            + ", <b>should" + (movie.shouldBuffer ? "" : " not") + " </b> buffer automatically "
+                            + movie.description;
+                consoleWrite(desc);
+
+                setupAttribute('preload', movie.preload);
+                setupAttribute('autoplay', movie.autoPlay);
+
+                video.src = movie.url;
+                if (movieInfo.current > 0)
+                    video.load();
+                if (!movie.shouldBuffer)
+                    timer = setTimeout(checkLoad, 200);
+            }
+            
+            function start()
+            {
+                findMediaElement();
+
+                waitForEvent("error");
+                waitForEvent("loadstart");
+                waitForEvent("play");
+                waitForEvent('loadedmetadata', loadedmetadata);
+            
+                openNextMovie();
+            }
+
+        </script>
+    </head>
+
+    <body onload="start()">
+        <p>Test to see if media loads automatically when 'preload' is specified.</p>
+        <video controls ></video>
+    </body>
+</html>
diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped
index 57c58db..e7b6174 100644
--- a/LayoutTests/platform/win/Skipped
+++ b/LayoutTests/platform/win/Skipped
@@ -777,3 +777,6 @@ java
 
 # Need to add functionality to DumpRenderTree to handle enable/disable Spatial Navigation
 fast/events/spatial-navigation
+
+# <rdar://problem/7718442> Implement 'preload=none'
+media/video-preload.html
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 9ee852a..401fa33 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,32 @@
+2010-03-04  Eric Carlson  <eric.carlson at apple.com>
+
+        Reviewed by Adele Peterson.
+
+        <rdar://problem/7718442> Implement 'preload=none'
+        https://bugs.webkit.org/show_bug.cgi?id=35789
+
+        Don't load any media data when preload is 'none'.
+
+        Test: media/video-preload.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::loadResource): Don't call player's setPreload method
+            when autoplay is set.
+
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::setPreload): Set m_preload so we have the correct value when
+            the media engine is created.
+
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
+        (WebCore::MediaPlayerPrivate::MediaPlayerPrivate): Initialize m_preload.
+        (WebCore::MediaPlayerPrivate::resumeLoad): New, kick off postponed a load.
+        (WebCore::MediaPlayerPrivate::load): Do nothing if preload is 'none'
+        (WebCore::MediaPlayerPrivate::loadInternal): New, complete loading.
+        (WebCore::MediaPlayerPrivate::prepareToPlay): New, resume a postponed load as someone
+            has called play().
+        (WebCore::MediaPlayerPrivate::setPreload): New, set m_preload.
+
 2010-03-04  Nate Chapin  <japhet at chromium.org>
 
         Reviewed by Dimitri Glazkov.
diff --git a/WebCore/html/HTMLMediaElement.cpp b/WebCore/html/HTMLMediaElement.cpp
index 8def9c7..48af1ae 100644
--- a/WebCore/html/HTMLMediaElement.cpp
+++ b/WebCore/html/HTMLMediaElement.cpp
@@ -601,7 +601,8 @@ void HTMLMediaElement::loadResource(const KURL& initialURL, ContentType& content
         m_player = MediaPlayer::create(this);
 #endif
 
-    m_player->setPreload(m_preload);
+    if (!autoplay())
+        m_player->setPreload(m_preload);
     m_player->setPreservesPitch(m_webkitPreservesPitch);
     updateVolume();
 
diff --git a/WebCore/platform/graphics/MediaPlayer.cpp b/WebCore/platform/graphics/MediaPlayer.cpp
index 9e6f1ab..1fdc1e5 100644
--- a/WebCore/platform/graphics/MediaPlayer.cpp
+++ b/WebCore/platform/graphics/MediaPlayer.cpp
@@ -489,6 +489,7 @@ MediaPlayer::Preload MediaPlayer::preload() const
 
 void MediaPlayer::setPreload(MediaPlayer::Preload preload)
 {
+    m_preload = preload;
     m_private->setPreload(preload);
 }
 
diff --git a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
index 355aa68..2636aeb 100644
--- a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
+++ b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
@@ -59,7 +59,6 @@ class MediaPlayerPrivate : public MediaPlayerPrivateInterface {
 public:
     static void registerMediaEngine(MediaEngineRegistrar);
 
-    ~MediaPlayerPrivate();
 
     void repaint();
     void loadStateChanged();
@@ -70,6 +69,7 @@ public:
 
 private:
     MediaPlayerPrivate(MediaPlayer*);
+    ~MediaPlayerPrivate();
 
     // engine support
     static MediaPlayerPrivateInterface* create(MediaPlayer* player);
@@ -89,9 +89,12 @@ private:
     
     void load(const String& url);
     void cancelLoad();
+    void loadInternal(const String& url);
+    void resumeLoad();
     
     void play();
     void pause();    
+    void prepareToPlay();
     
     bool paused() const;
     bool seeking() const;
@@ -107,6 +110,8 @@ private:
     bool hasClosedCaptions() const;
     void setClosedCaptionsVisible(bool);
 
+    void setPreload(MediaPlayer::Preload);
+
     MediaPlayer::NetworkState networkState() const { return m_networkState; }
     MediaPlayer::ReadyState readyState() const { return m_readyState; }
     
@@ -172,6 +177,7 @@ private:
     RetainPtr<QTMovieView> m_qtMovieView;
     RetainPtr<QTVideoRendererWebKitOnly> m_qtVideoRenderer;
     RetainPtr<WebCoreMovieObserver> m_objcObserver;
+    String m_movieURL;
     float m_seekTo;
     Timer<MediaPlayerPrivate> m_seekTimer;
     MediaPlayer::NetworkState m_networkState;
@@ -184,11 +190,13 @@ private:
     float m_cachedDuration;
     float m_timeToRestore;
     RetainPtr<QTMovieLayer> m_qtVideoLayer;
+    MediaPlayer::Preload m_preload;
     bool m_startedPlaying;
     bool m_isStreaming;
     bool m_visible;
     bool m_hasUnsupportedTracks;
     bool m_videoFrameHasDrawn;
+    bool m_delayingLoad;
 #if DRAW_FRAME_RATE
     int  m_frameCountWhilePlaying;
     double m_timeStartedPlaying;
diff --git a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
index 2b90f7a..9646699 100644
--- a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
+++ b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
@@ -211,6 +211,7 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
     , m_reportedDuration(-1)
     , m_cachedDuration(-1)
     , m_timeToRestore(-1)
+    , m_preload(MediaPlayer::Auto)
     , m_startedPlaying(false)
     , m_isStreaming(false)
     , m_visible(false)
@@ -549,8 +550,30 @@ QTTime MediaPlayerPrivate::createQTTime(float time) const
     return QTMakeTime(time * timeScale, timeScale);
 }
 
+void MediaPlayerPrivate::resumeLoad()
+{
+    m_delayingLoad = false;
+
+    if (m_movieURL)
+        loadInternal(m_movieURL);
+}
+
 void MediaPlayerPrivate::load(const String& url)
 {
+    m_movieURL = url;
+
+    // If the element is not supposed to load any data return immediately because QTKit
+    // doesn't have API to throttle loading.
+    if (m_preload == MediaPlayer::None) {
+        m_delayingLoad = true;
+        return;
+    }
+
+    loadInternal(url);
+}
+
+void MediaPlayerPrivate::loadInternal(const String& url)
+{
     if (m_networkState != MediaPlayer::Loading) {
         m_networkState = MediaPlayer::Loading;
         m_player->networkStateChanged();
@@ -570,6 +593,12 @@ void MediaPlayerPrivate::load(const String& url)
     [m_objcObserver.get() setDelayCallbacks:NO];
 }
 
+void MediaPlayerPrivate::prepareToPlay()
+{
+    if (!m_qtMovie || m_delayingLoad)
+        resumeLoad();
+}
+
 PlatformMedia MediaPlayerPrivate::platformMedia() const
 {
     PlatformMedia plaftformMedia = { m_qtMovie.get() };
@@ -1437,6 +1466,12 @@ MediaPlayer::MovieLoadType MediaPlayerPrivate::movieLoadType() const
     return movieType;
 }
 
+void MediaPlayerPrivate::setPreload(MediaPlayer::Preload preload)
+{
+    m_preload = preload;
+    if (m_delayingLoad && m_preload != MediaPlayer::None)
+        resumeLoad();
+}
 
 } // namespace WebCore
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list