Title: [117345] branches/safari-536-branch/Source/WebCore

Diff

Modified: branches/safari-536-branch/Source/WebCore/ChangeLog (117344 => 117345)


--- branches/safari-536-branch/Source/WebCore/ChangeLog	2012-05-16 21:31:06 UTC (rev 117344)
+++ branches/safari-536-branch/Source/WebCore/ChangeLog	2012-05-16 21:51:33 UTC (rev 117345)
@@ -1,5 +1,53 @@
 2012-05-16  Lucas Forschler  <lforsch...@apple.com>
 
+    Merge 117147
+
+    2012-05-14  Jer Noble  <jer.no...@apple.com>
+
+            Site-specific hack: Disclaim WebM as a supported type on Mac for YouTube.
+            https://bugs.webkit.org/show_bug.cgi?id=86409
+
+            Reviewed by Darin Adler.
+
+            No new tests; site specific hack.
+
+            Add a Mac-only site-specific hack which disclaims both video/webm and video/x-flv
+            as supported types when the media element's document has a host of youtube.com.
+
+            Add a new, pure-virtual prototype class for use by MediaPlayer::supportsType:
+            * platform/graphics/MediaPlayer.h:
+            (MediaPlayerSupportsTypeClient):
+            (WebCore::MediaPlayerSupportsTypeClient::~MediaPlayerSupportsTypeClient):
+            (WebCore::MediaPlayerSupportsTypeClient::mediaPlayerNeedsSiteSpecificHacks):
+            (WebCore::MediaPlayerSupportsTypeClient::mediaPlayerDocumentHost):
+
+            Use these new client calls to determine whether to apply the site-specific
+            hack:
+            * platform/graphics/MediaPlayer.cpp:
+            (WebCore::MediaPlayer::supportsType):
+
+            Add this prototype class as a superclass of HTMLMediaElement.  Pass in the
+            HTMLMediaElement's this pointer when calling MediaPlayer::supportsType():
+            * html/HTMLMediaElement.cpp:
+            (WebCore::HTMLMediaElement::canPlayType):
+            (WebCore::HTMLMediaElement::selectNextSourceChild):
+            (WebCore::HTMLMediaElement::mediaPlayerNeedsSiteSpecificHacks):
+            (WebCore::HTMLMediaElement::mediaPlayerDocumentHost):
+            * html/HTMLMediaElement.h:
+
+            As is HTMLMediaElement, a MediaPlayerSupportsTypeClient class is needed. Add a
+            new class DOMImplementationSupportsTypeClient, an instance of which will be 
+            passed to MediaPlayer::supportsType():
+            * dom/DOMImplementation.cpp:
+            (DOMImplementationSupportsTypeClient):
+            (WebCore::DOMImplementationSupportsTypeClient::DOMImplementationSupportsTypeClient):
+            (WebCore::DOMImplementation::createDocument):
+            (WebCore::DOMImplementation::mediaPlayerNeedsSiteSpecificHacks):
+            (WebCore::DOMImplementation::mediaPlayerDocumentHost):
+            * dom/DOMImplementation.h:
+
+2012-05-16  Lucas Forschler  <lforsch...@apple.com>
+
     Merge 117129
 
     2012-05-15  Anders Carlsson  <ander...@apple.com>

Modified: branches/safari-536-branch/Source/WebCore/dom/DOMImplementation.cpp (117344 => 117345)


--- branches/safari-536-branch/Source/WebCore/dom/DOMImplementation.cpp	2012-05-16 21:31:06 UTC (rev 117344)
+++ branches/safari-536-branch/Source/WebCore/dom/DOMImplementation.cpp	2012-05-16 21:51:33 UTC (rev 117345)
@@ -67,6 +67,22 @@
     set.add(string);
 }
 
+class DOMImplementationSupportsTypeClient : public MediaPlayerSupportsTypeClient {
+public:
+    DOMImplementationSupportsTypeClient(bool needsHacks, const String& host)
+        : m_needsHacks(needsHacks)
+        , m_host(host)
+    {
+    }
+
+private:
+    virtual bool mediaPlayerNeedsSiteSpecificHacks() const OVERRIDE { return m_needsHacks; }
+    virtual String mediaPlayerDocumentHost() const OVERRIDE { return m_host; }
+
+    bool m_needsHacks;
+    String m_host;
+};
+
 #if ENABLE(SVG)
 
 static bool isSVG10Feature(const String &feature, const String &version)
@@ -387,7 +403,8 @@
 #if ENABLE(VIDEO)
      // Check to see if the type can be played by our MediaPlayer, if so create a MediaDocument
     // Key system is not applicable here.
-    if (MediaPlayer::supportsType(ContentType(type), String()))
+    DOMImplementationSupportsTypeClient client(frame->settings() && frame->settings()->needsSiteSpecificQuirks(), url.host());
+    if (MediaPlayer::supportsType(ContentType(type), String(), &client))
          return MediaDocument::create(frame, url);
 #endif
 

Modified: branches/safari-536-branch/Source/WebCore/dom/DOMImplementation.h (117344 => 117345)


--- branches/safari-536-branch/Source/WebCore/dom/DOMImplementation.h	2012-05-16 21:31:06 UTC (rev 117344)
+++ branches/safari-536-branch/Source/WebCore/dom/DOMImplementation.h	2012-05-16 21:51:33 UTC (rev 117345)
@@ -25,6 +25,7 @@
 #define DOMImplementation_h
 
 #include "Document.h"
+#include "MediaPlayer.h"
 #include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>

Modified: branches/safari-536-branch/Source/WebCore/html/HTMLMediaElement.cpp (117344 => 117345)


--- branches/safari-536-branch/Source/WebCore/html/HTMLMediaElement.cpp	2012-05-16 21:31:06 UTC (rev 117344)
+++ branches/safari-536-branch/Source/WebCore/html/HTMLMediaElement.cpp	2012-05-16 21:51:33 UTC (rev 117345)
@@ -617,7 +617,7 @@
 
 String HTMLMediaElement::canPlayType(const String& mimeType, const String& keySystem) const
 {
-    MediaPlayer::SupportsType support = MediaPlayer::supportsType(ContentType(mimeType), keySystem);
+    MediaPlayer::SupportsType support = MediaPlayer::supportsType(ContentType(mimeType), keySystem, this);
     String canPlay;
 
     // 4.8.10.3
@@ -3097,7 +3097,7 @@
             if (shouldLog)
                 LOG(Media, "HTMLMediaElement::selectNextSourceChild - 'type' is '%s' - key system is '%s'", type.utf8().data(), system.utf8().data());
 #endif
-            if (!MediaPlayer::supportsType(ContentType(type), system))
+            if (!MediaPlayer::supportsType(ContentType(type), system, this))
                 goto check_again;
         }
 
@@ -4385,6 +4385,17 @@
 
 }
 
+bool HTMLMediaElement::mediaPlayerNeedsSiteSpecificHacks() const
+{
+    Settings* settings = document()->settings();
+    return settings && settings->needsSiteSpecificQuirks();
+}
+
+String HTMLMediaElement::mediaPlayerDocumentHost() const
+{
+    return document()->url().host();
+}
+
 void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture()
 {
     m_restrictions = NoRestrictions;

Modified: branches/safari-536-branch/Source/WebCore/html/HTMLMediaElement.h (117344 => 117345)


--- branches/safari-536-branch/Source/WebCore/html/HTMLMediaElement.h	2012-05-16 21:31:06 UTC (rev 117344)
+++ branches/safari-536-branch/Source/WebCore/html/HTMLMediaElement.h	2012-05-16 21:51:33 UTC (rev 117345)
@@ -76,7 +76,7 @@
 // But it can't be until the Chromium WebMediaPlayerClientImpl class is fixed so it
 // no longer depends on typecasting a MediaPlayerClient to an HTMLMediaElement.
 
-class HTMLMediaElement : public HTMLElement, public MediaPlayerClient, private MediaCanStartListener, public ActiveDOMObject, public MediaControllerInterface
+class HTMLMediaElement : public HTMLElement, public MediaPlayerClient, public MediaPlayerSupportsTypeClient, private MediaCanStartListener, public ActiveDOMObject, public MediaControllerInterface
 #if ENABLE(VIDEO_TRACK)
     , private TextTrackClient
 #endif
@@ -422,6 +422,9 @@
     virtual String mediaPlayerReferrer() const OVERRIDE;
     virtual String mediaPlayerUserAgent() const OVERRIDE;
 
+    virtual bool mediaPlayerNeedsSiteSpecificHacks() const OVERRIDE;
+    virtual String mediaPlayerDocumentHost() const OVERRIDE;
+
     void loadTimerFired(Timer<HTMLMediaElement>*);
     void progressEventTimerFired(Timer<HTMLMediaElement>*);
     void playbackProgressTimerFired(Timer<HTMLMediaElement>*);

Modified: branches/safari-536-branch/Source/WebCore/platform/graphics/MediaPlayer.cpp (117344 => 117345)


--- branches/safari-536-branch/Source/WebCore/platform/graphics/MediaPlayer.cpp	2012-05-16 21:31:06 UTC (rev 117344)
+++ branches/safari-536-branch/Source/WebCore/platform/graphics/MediaPlayer.cpp	2012-05-16 21:51:33 UTC (rev 117345)
@@ -712,7 +712,7 @@
     m_private->paintCurrentFrameInContext(p, r);
 }
 
-MediaPlayer::SupportsType MediaPlayer::supportsType(const ContentType& contentType, const String& keySystem)
+MediaPlayer::SupportsType MediaPlayer::supportsType(const ContentType& contentType, const String& keySystem, const MediaPlayerSupportsTypeClient* client)
 {
     String type = contentType.type().lower();
     // The codecs string is not lower-cased because MP4 values are case sensitive
@@ -729,6 +729,21 @@
     if (!engine)
         return IsNotSupported;
 
+#if PLATFORM(MAC)
+    // YouTube will ask if the HTMLMediaElement canPlayType video/webm, then
+    // video/x-flv, then finally video/mp4, and will then load a URL of the first type
+    // in that list which returns "probably". When Perian is installed,
+    // MediaPlayerPrivateQTKit claims to support both video/webm and video/x-flv, but
+    // due to a bug in Perian, loading media in these formats will sometimes fail on
+    // slow connections. <https://bugs.webkit.org/show_bug.cgi?id=86409>
+    if (client && client->mediaPlayerNeedsSiteSpecificHacks()) {
+        String host = client->mediaPlayerDocumentHost();
+        if ((host.endsWith(".youtube.com", false) || equalIgnoringCase("youtube.com", host))
+            && (contentType.type().startsWith("video/webm", false) || contentType.type().startsWith("video/x-flv", false)))
+            return IsNotSupported;
+    }
+#endif
+
 #if ENABLE(ENCRYPTED_MEDIA)
     return engine->supportsTypeAndCodecs(type, typeCodecs, system);
 #else

Modified: branches/safari-536-branch/Source/WebCore/platform/graphics/MediaPlayer.h (117344 => 117345)


--- branches/safari-536-branch/Source/WebCore/platform/graphics/MediaPlayer.h	2012-05-16 21:31:06 UTC (rev 117344)
+++ branches/safari-536-branch/Source/WebCore/platform/graphics/MediaPlayer.h	2012-05-16 21:51:33 UTC (rev 117345)
@@ -180,6 +180,14 @@
     virtual String mediaPlayerUserAgent() const { return String(); }
 };
 
+class MediaPlayerSupportsTypeClient {
+public:
+    virtual ~MediaPlayerSupportsTypeClient() { }
+
+    virtual bool mediaPlayerNeedsSiteSpecificHacks() const { return false; }
+    virtual String mediaPlayerDocumentHost() const { return String(); }
+};
+
 class MediaPlayer {
     WTF_MAKE_NONCOPYABLE(MediaPlayer); WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -192,7 +200,7 @@
 
     // Media engine support.
     enum SupportsType { IsNotSupported, IsSupported, MayBeSupported };
-    static MediaPlayer::SupportsType supportsType(const ContentType&, const String& keySystem);
+    static MediaPlayer::SupportsType supportsType(const ContentType&, const String& keySystem, const MediaPlayerSupportsTypeClient*);
     static void getSupportedTypes(HashSet<String>&);
     static bool isAvailable();
     static void getSitesInMediaCache(Vector<String>&);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to