2011-05-02 Eric Carlson <eric.carlson@apple.com>
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 May 2011 16:04:26 +0000 (16:04 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 May 2011 16:04:26 +0000 (16:04 +0000)
        Reviewed by Brady Eidson.

        The preload attribute of the video tag is not completely implemented
        https://bugs.webkit.org/show_bug.cgi?id=43673
        <rdar://problem/7508322>

        Test manually with manual-tests/media-elements/video-preload.html.

        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
        (WebCore::MediaPlayerPrivateQTKit::commonMovieAttributes): Add new "limit read-ahead"
            attribute when preload is not "auto".
        (WebCore::MediaPlayerPrivateQTKit::resumeLoad): Remove m_delayingLoad, we don't need it.
        (WebCore::MediaPlayerPrivateQTKit::load): Correct comment.
        (WebCore::MediaPlayerPrivateQTKit::prepareToPlay): Call setPreload('auto').
        (WebCore::MediaPlayerPrivateQTKit::setPreload): Set new attribue if we already have
            a QTMovie.

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm

index 715c2a6..29edfe2 100644 (file)
@@ -6,6 +6,26 @@
         https://bugs.webkit.org/show_bug.cgi?id=43673
         <rdar://problem/7508322>
 
+        Test manually with manual-tests/media-elements/video-preload.html.
+
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
+        (WebCore::MediaPlayerPrivateQTKit::commonMovieAttributes): Add new "limit read-ahead"
+            attribute when preload is not "auto".
+        (WebCore::MediaPlayerPrivateQTKit::resumeLoad): Remove m_delayingLoad, we don't need it.
+        (WebCore::MediaPlayerPrivateQTKit::load): Correct comment.
+        (WebCore::MediaPlayerPrivateQTKit::prepareToPlay): Call setPreload('auto').
+        (WebCore::MediaPlayerPrivateQTKit::setPreload): Set new attribue if we already have
+            a QTMovie.
+
+2011-05-02  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Brady Eidson.
+
+        The preload attribute of the video tag is not completely implemented
+        https://bugs.webkit.org/show_bug.cgi?id=43673
+        <rdar://problem/7508322>
+
         Manual test manual-tests/media-elements/video-preload.html added.
 
         * manual-tests/media-elements/video-preload.html: Added. New manual test for media element 
index d276720..b7bb86b 100644 (file)
@@ -211,7 +211,6 @@ private:
     bool m_visible;
     bool m_hasUnsupportedTracks;
     bool m_videoFrameHasDrawn;
-    bool m_delayingLoad;
     bool m_isAllowedToRender;
     bool m_privateBrowsing;
 #if DRAW_FRAME_RATE
index f24ce2a..5d6cb25 100644 (file)
@@ -232,9 +232,9 @@ MediaPlayerPrivateQTKit::~MediaPlayerPrivateQTKit()
     [m_objcObserver.get() disconnect];
 }
 
-NSMutableDictionaryMediaPlayerPrivateQTKit::commonMovieAttributes() 
+NSMutableDictionary *MediaPlayerPrivateQTKit::commonMovieAttributes() 
 {
-    return [NSMutableDictionary dictionaryWithObjectsAndKeys:
+    NSMutableDictionary *movieAttributes = [NSMutableDictionary dictionaryWithObjectsAndKeys:
             [NSNumber numberWithBool:m_player->preservesPitch()], QTMovieRateChangesPreservePitchAttribute,
             [NSNumber numberWithBool:YES], QTMoviePreventExternalURLLinksAttribute,
             [NSNumber numberWithBool:YES], QTSecurityPolicyNoCrossSiteAttribute,
@@ -243,6 +243,11 @@ NSMutableDictionary* MediaPlayerPrivateQTKit::commonMovieAttributes()
             [NSNumber numberWithBool:!m_privateBrowsing], @"QTMovieAllowPersistentCacheAttribute",
             QTMovieApertureModeClean, QTMovieApertureModeAttribute,
             nil];
+
+    if (m_preload < MediaPlayer::Auto)
+        [movieAttributes setValue:[NSNumber numberWithBool:YES] forKey:@"QTMovieLimitReadAheadAttribute"];
+
+    return movieAttributes;
 }
 
 void MediaPlayerPrivateQTKit::createQTMovie(const String& url)
@@ -634,8 +639,6 @@ QTTime MediaPlayerPrivateQTKit::createQTTime(float time) const
 
 void MediaPlayerPrivateQTKit::resumeLoad()
 {
-    m_delayingLoad = false;
-
     if (!m_movieURL.isNull())
         loadInternal(m_movieURL);
 }
@@ -644,12 +647,9 @@ void MediaPlayerPrivateQTKit::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;
+    // If the element is not supposed to load any data return immediately.
+    if (m_preload == MediaPlayer::None)
         return;
-    }
 
     loadInternal(url);
 }
@@ -685,8 +685,7 @@ void MediaPlayerPrivateQTKit::loadInternal(const String& url)
 
 void MediaPlayerPrivateQTKit::prepareToPlay()
 {
-    if (!m_qtMovie || m_delayingLoad)
-        resumeLoad();
+    setPreload(MediaPlayer::Auto);
 }
 
 PlatformMedia MediaPlayerPrivateQTKit::platformMedia() const
@@ -1592,8 +1591,13 @@ MediaPlayer::MovieLoadType MediaPlayerPrivateQTKit::movieLoadType() const
 void MediaPlayerPrivateQTKit::setPreload(MediaPlayer::Preload preload)
 {
     m_preload = preload;
-    if (m_delayingLoad && m_preload != MediaPlayer::None)
+    if (m_preload == MediaPlayer::None)
+        return;
+
+    if (!m_qtMovie)
         resumeLoad();
+    else if (m_preload == MediaPlayer::Auto)
+        [m_qtMovie.get() setAttribute:[NSNumber numberWithBool:NO] forKey:@"QTMovieLimitReadAheadAttribute"];
 }
 
 float MediaPlayerPrivateQTKit::mediaTimeForTimeValue(float timeValue) const