[PluginProxy] Add a setting to disable video plugin proxy support in HTMLMediaElement.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Nov 2013 22:53:32 +0000 (22:53 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Nov 2013 22:53:32 +0000 (22:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123621

Reviewed by Eric Carlson.

Source/WebCore:

Add a new Setting which will disable the video plugin proxy. Enable support for AVFoundation
in iOS (which requries fixing a few compile errors resulting from classes and methods which
are not available on iOS.

* WebCore.exp.in: Export wkAVAssetResolvedURL.
* css/StyleResolver.cpp:
(WebCore::StyleResolver::canShareStyleWithElement): Make conditional upon
    new isVideoPluginProxyEnabled() setting.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::parseAttribute): Ditto.
* html/HTMLMediaElement.h:
* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::createRenderer): Ditto.
(WebCore::HTMLVideoElement::attach): Ditto.
(WebCore::HTMLVideoElement::parseAttribute): Ditto.
(HTMLVideoElement::setDisplayMode): Ditto.
* html/HTMLVideoElement.h:
* page/Settings.cpp:
(WebCore::Settings::setVideoPluginProxyEnabled): Simple setter.
* page/Settings.h:
(WebCore::Settings::isVideoPluginProxyEnabled): Simple getter.
* platform/graphics/MediaPlayer.cpp:
(WebCore::installedMediaEngines): Conditionally add MediaPlayerPrivateIOS and always add
    MediaPlayerPriateAVFoundationObjC.
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::deliverNotification): Add default implementation.
(WebCore::MediaPlayerPrivateInterface::setMediaPlayerProxy): Ditto.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC): Use new
    HAS_ and USE_ macros instead of __MAC_OS_MIN_VERNSION_REQUIRED.
(WebCore::MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::hasContextRenderer): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::createContextVideoRenderer): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::destroyContextVideoRenderer): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::paint): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): Use cachedCGColor instead
    of CGColorGetConstantColor.
(WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoOutput): Use CVPixelBuffer pixel
    format constant instead of QuickDraw constant.
(WebCore::MediaPlayerPrivateAVFoundationObjC::createPixelBuffer): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput): Draw to intermediary
    CGImage on iOS.
* platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h:
* platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
* platform/ios/WebCoreSystemInterfaceIOS.mm:
* platform/mac/WebCoreSystemInterface.h:

Source/WebKit/mac:

Add a new isVideoPluginProxyEnabled setting.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]): Set isVideoPluginProxyEnabled preference.
(-[WebPreferences isVideoPluginProxyEnabled]): Pass through to Settings.
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]): Set isVideoPluginProxyEnabled preference.

Source/WebKit2:

Add WebKit2 functions for setting then new isVideoPluginProxyEnabled preference.

* Shared/WebPreferencesStore.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetVideoPluginProxyEnabled):
(WKPreferencesGetVideoPluginProxyEnabled):
* UIProcess/API/C/WKPreferences.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

Source/WTF:

Enable WTF_USE_AVFOUNDATION and add some HAVE_AVFOUNDATION_* defines
to replace the existing __MAC_OS_X_VERSION_MIN_REQUIRED macros in
MediaPlayerPrivateAVFoundationObjC.mm.

* wtf/Platform.h:

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

27 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLVideoElement.cpp
Source/WebCore/html/HTMLVideoElement.h
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.h
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/MediaPlayerPrivate.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h
Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKit/mac/WebView/WebPreferences.mm
Source/WebKit/mac/WebView/WebPreferencesPrivate.h
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesStore.h
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferences.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 727d58bd39ea11cb08c63a81967ae5972141541c..cfc9a902759ae2b9f6e288f10ad00b47c0939528 100644 (file)
@@ -1,3 +1,16 @@
+2013-11-01  Jer Noble  <jer.noble@apple.com>
+
+        [PluginProxy] Add a setting to disable video plugin proxy support in HTMLMediaElement.
+        https://bugs.webkit.org/show_bug.cgi?id=123621
+
+        Reviewed by Eric Carlson.
+
+        Enable WTF_USE_AVFOUNDATION and add some HAVE_AVFOUNDATION_* defines
+        to replace the existing __MAC_OS_X_VERSION_MIN_REQUIRED macros in
+        MediaPlayerPrivateAVFoundationObjC.mm.
+
+        * wtf/Platform.h:
+
 2013-11-02  Patrick Gansterer  <paroga@webkit.org>
 
         Fix compilation of DateMath.cpp with MSVC
index 3022e2633811d914296e3d820e0f4fba7e35a9d9..93420536917a1fe31a74f0d4c81f262c87a8bc25 100644 (file)
 #define ENABLE_BINDING_INTEGRITY 1
 #endif
 
-#if PLATFORM(MAC) && !PLATFORM(IOS)
+#if PLATFORM(IOS) || PLATFORM(MAC)
 #define WTF_USE_AVFOUNDATION 1
 #endif
 
-#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080)
+#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000) || ((PLATFORM(MAC) && !PLATFORM(IOS)) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080)
 #define WTF_USE_COREMEDIA 1
+#define HAVE_AVFOUNDATION_VIDEO_OUTPUT 1
 #endif
 
-#if (PLATFORM(MAC) || (OS(WINDOWS) && USE(CG))) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 50000) || ((PLATFORM(MAC) && !PLATFORM(IOS)) || (OS(WINDOWS) && USE(CG)) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080)
 #define HAVE_AVFOUNDATION_MEDIA_SELECTION_GROUP 1
 #endif
 
-#if (PLATFORM(MAC) || (OS(WINDOWS) && USE(CG))) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000) || (((PLATFORM(MAC) && !PLATFORM(IOS)) || (OS(WINDOWS) && USE(CG))) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
 #define HAVE_AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT 1
+#define HAVE_MEDIA_ACCESSIBILITY_FRAMEWORK 1
 #endif
 
-#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000) || ((PLATFORM(MAC) || (OS(WINDOWS) && USE(CG))) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
-#define HAVE_MEDIA_ACCESSIBILITY_FRAMEWORK 1
+#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000) || ((PLATFORM(MAC) && !PLATFORM(IOS)) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
+#define HAVE_AVFOUNDATION_LOADER_DELEGATE 1
+#endif
+
+#if (PLATFORM(MAC) && !PLATFORM(IOS)) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+#define WTF_USE_VIDEOTOOLBOX 1
 #endif
 
 #if PLATFORM(MAC) || PLATFORM(GTK) || (PLATFORM(WIN) && !USE(WINGDI) && !PLATFORM(WIN_CAIRO))
index be1621452f9cd3efbef328d64564e040d3851a73..2db75b42638d637c97257448f54ec36ff9e2ffe0 100644 (file)
@@ -1,3 +1,59 @@
+2013-11-01  Jer Noble  <jer.noble@apple.com>
+
+        [PluginProxy] Add a setting to disable video plugin proxy support in HTMLMediaElement.
+        https://bugs.webkit.org/show_bug.cgi?id=123621
+
+        Reviewed by Eric Carlson.
+
+        Add a new Setting which will disable the video plugin proxy. Enable support for AVFoundation
+        in iOS (which requries fixing a few compile errors resulting from classes and methods which
+        are not available on iOS.
+
+        * WebCore.exp.in: Export wkAVAssetResolvedURL.
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::canShareStyleWithElement): Make conditional upon
+            new isVideoPluginProxyEnabled() setting.
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::parseAttribute): Ditto.
+        * html/HTMLMediaElement.h:
+        * html/HTMLVideoElement.cpp:
+        (WebCore::HTMLVideoElement::createRenderer): Ditto.
+        (WebCore::HTMLVideoElement::attach): Ditto.
+        (WebCore::HTMLVideoElement::parseAttribute): Ditto.
+        (HTMLVideoElement::setDisplayMode): Ditto.
+        * html/HTMLVideoElement.h:
+        * page/Settings.cpp:
+        (WebCore::Settings::setVideoPluginProxyEnabled): Simple setter.
+        * page/Settings.h:
+        (WebCore::Settings::isVideoPluginProxyEnabled): Simple getter.
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::installedMediaEngines): Conditionally add MediaPlayerPrivateIOS and always add
+            MediaPlayerPriateAVFoundationObjC.
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::deliverNotification): Add default implementation.
+        (WebCore::MediaPlayerPrivateInterface::setMediaPlayerProxy): Ditto.
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC): Use new
+            HAS_ and USE_ macros instead of __MAC_OS_MIN_VERNSION_REQUIRED.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC): Ditto.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::hasContextRenderer): Ditto.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createContextVideoRenderer): Ditto.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::destroyContextVideoRenderer): Ditto.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL): Ditto.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::paint): Ditto.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): Use cachedCGColor instead
+            of CGColorGetConstantColor.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoOutput): Use CVPixelBuffer pixel
+            format constant instead of QuickDraw constant.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createPixelBuffer): Ditto.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput): Draw to intermediary
+            CGImage on iOS.
+        * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h:
+        * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
+        * platform/ios/WebCoreSystemInterfaceIOS.mm:
+        * platform/mac/WebCoreSystemInterface.h:
+
 2013-11-04  Andreas Kling  <akling@apple.com>
 
         REGRESSION(r158561): fast/block/float/float-append-child-crash.html asserting.
index 0b34dd4131159f31e13aee4d7efa124a87f89a2e..0c0c64aa7d2368d1228bf4af9519fa8f507147ee 100644 (file)
@@ -2790,6 +2790,8 @@ __ZN7WebCore16ScriptController16createRootObjectEPv
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
 __ZN7WebCore16HTMLMediaElement19deliverNotificationE32MediaPlayerProxyNotificationType
 __ZN7WebCore16HTMLMediaElement19setMediaPlayerProxyEP19WebMediaPlayerProxy
+__ZN7WebCore8Settings24gVideoPluginProxyEnabledE
+__ZN7WebCore8Settings26setVideoPluginProxyEnabledEb
 __ZN7WebCore9HTMLNames8audioTagE
 #endif
 
index 6ecce3b402e57ca23d875864b59322e327c84899..900db670a772797ed6af73df13d5eab097317522 100644 (file)
 #include "WebVTTElement.h"
 #endif
 
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+#include "HTMLMediaElement.h"
+#endif
+
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -671,13 +675,15 @@ bool StyleResolver::canShareStyleWithElement(StyledElement* element) const
 #if USE(ACCELERATED_COMPOSITING)
     // Turn off style sharing for elements that can gain layers for reasons outside of the style system.
     // See comments in RenderObject::setStyle().
-    if (element->hasTagName(iframeTag) || element->hasTagName(frameTag) || element->hasTagName(embedTag) || element->hasTagName(objectTag) || element->hasTagName(appletTag) || element->hasTagName(canvasTag)
+    if (element->hasTagName(iframeTag) || element->hasTagName(frameTag) || element->hasTagName(embedTag) || element->hasTagName(objectTag) || element->hasTagName(appletTag) || element->hasTagName(canvasTag))
+        return false;
+
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-        // With proxying, the media elements are backed by a RenderEmbeddedObject.
-        || element->hasTagName(videoTag) || isHTMLAudioElement(element)
-#endif
-        )
+    // With proxying, the media elements are backed by a RenderEmbeddedObject.
+    if ((element->hasTagName(videoTag) || element->hasTagName(audioTag)) && toMediaElement(element)->shouldUseVideoPluginProxy())
         return false;
+#endif
+
 #endif
 
     if (elementHasDirectionAuto(element))
index 01675594609b2fcfbecb67157b3ff036d091fba1..fed07cd6693625a1ea505921f68381ea39e048fa 100644 (file)
@@ -547,8 +547,10 @@ void HTMLMediaElement::finishParsingChildren()
     m_parsingInProgress = false;
 
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-    document().updateStyleIfNeeded();
-    createMediaPlayerProxy();
+    if (shouldUseVideoPluginProxy()) {
+        document().updateStyleIfNeeded();
+        createMediaPlayerProxy();
+    }
 #endif
     
 #if ENABLE(VIDEO_TRACK)
@@ -563,28 +565,28 @@ void HTMLMediaElement::finishParsingChildren()
 bool HTMLMediaElement::rendererIsNeeded(const RenderStyle& style)
 {
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-    UNUSED_PARAM(style);
-    return true;
-#else
-    return controls() && HTMLElement::rendererIsNeeded(style);
+    if (shouldUseVideoPluginProxy())
+        return true;
 #endif
+    return controls() && HTMLElement::rendererIsNeeded(style);
 }
 
 RenderElement* HTMLMediaElement::createRenderer(PassRef<RenderStyle> style)
 {
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-    // Setup the renderer if we already have a proxy widget.
-    RenderEmbeddedObject* mediaRenderer = new RenderEmbeddedObject(*this, std::move(style));
-    if (m_proxyWidget) {
-        mediaRenderer->setWidget(m_proxyWidget);
-
-        if (Frame* frame = document().frame())
-            frame->loader().client().showMediaPlayerProxyPlugin(m_proxyWidget.get());
+    if (shouldUseVideoPluginProxy()) {
+        // Setup the renderer if we already have a proxy widget.
+        RenderEmbeddedObject* mediaRenderer = new RenderEmbeddedObject(*this, std::move(style));
+        if (m_proxyWidget) {
+            mediaRenderer->setWidget(m_proxyWidget);
+
+            if (Frame* frame = document().frame())
+                frame->loader().client().showMediaPlayerProxyPlugin(m_proxyWidget.get());
+        }
+        return mediaRenderer;
     }
-    return mediaRenderer;
-#else
-    return new RenderMedia(*this, std::move(style));
 #endif
+    return new RenderMedia(*this, std::move(style));
 }
 
 bool HTMLMediaElement::childShouldCreateRenderer(const Node* child) const
@@ -653,7 +655,8 @@ void HTMLMediaElement::willAttachRenderers()
     ASSERT(!attached());
 
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-    m_needWidgetUpdate = true;
+    if (shouldUseVideoPluginProxy())
+        m_needWidgetUpdate = true;
 #endif
 }
 
@@ -681,9 +684,10 @@ void HTMLMediaElement::scheduleDelayedAction(DelayedActionType actionType)
 
     if ((actionType & LoadMediaResource) && !(m_pendingActionFlags & LoadMediaResource)) {
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-        createMediaPlayerProxy();
+        if (shouldUseVideoPluginProxy())
+            createMediaPlayerProxy();
 #endif
-        
+
         prepareForLoad();
         setFlags(m_pendingActionFlags, LoadMediaResource);
     }
@@ -842,14 +846,15 @@ void HTMLMediaElement::prepareForLoad()
     closeMediaSource();
 #endif
 
-#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-    createMediaPlayer();
-#else
-    if (m_player)
-        m_player->cancelLoad();
-    else
-        createMediaPlayerProxy();
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    if (shouldUseVideoPluginProxy())
+        if (m_player)
+            m_player->cancelLoad();
+        else
+            createMediaPlayerProxy();
+    } else
 #endif
+    createMediaPlayer();
 
     // 4 - If the media element's networkState is not set to NETWORK_EMPTY, then run these substeps
     if (m_networkState != NETWORK_EMPTY) {
@@ -1020,10 +1025,11 @@ void HTMLMediaElement::loadNextSourceChild()
         return;
     }
 
-#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-    // Recreate the media player for the new url
-    createMediaPlayer();
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    if (!shouldUseVideoPluginProxy())
 #endif
+        // Recreate the media player for the new url
+        createMediaPlayer();
 
     m_loadState = LoadingFromSourceElement;
     loadResource(mediaURL, contentType, keySystem);
@@ -4163,14 +4169,11 @@ void HTMLMediaElement::clearMediaPlayer(int flags)
     removeAllInbandTracks();
 #endif
 
-#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-
 #if ENABLE(MEDIA_SOURCE)
     closeMediaSource();
 #endif
 
     m_player.clear();
-#endif
     stopPeriodicTimers();
     m_loadTimer.stop();
 
@@ -4287,24 +4290,26 @@ void HTMLMediaElement::visibilityStateChanged()
 void HTMLMediaElement::defaultEventHandler(Event* event)
 {
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-    auto renderer = this->renderer();
-    if (!renderer || !renderer->isWidget())
-        return;
+    if (shouldUseVideoPluginProxy()) {
+        auto renderer = this->renderer();
+        if (!renderer || !renderer->isWidget())
+            return;
 
-    if (Widget* widget = toRenderWidget(renderer)->widget())
-        widget->handleEvent(event);
-#else
-    HTMLElement::defaultEventHandler(event);
+        if (Widget* widget = toRenderWidget(renderer)->widget())
+            widget->handleEvent(event);
+        return;
+    }
 #endif
+    HTMLElement::defaultEventHandler(event);
 }
 
 bool HTMLMediaElement::willRespondToMouseClickEvents()
 {
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-    return true;
-#else
-    return HTMLElement::willRespondToMouseClickEvents();
+    if (shouldUseVideoPluginProxy())
+        return true;
 #endif
+    return HTMLElement::willRespondToMouseClickEvents();
 }
 
 #if ENABLE(VIDEO_TRACK)
@@ -4724,13 +4729,25 @@ bool HTMLMediaElement::createMediaControls()
 
 void HTMLMediaElement::configureMediaControls()
 {
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    if (shouldUseVideoPluginProxy()) {
+        if (m_player)
+            m_player->setControls(controls());
+
+        if (!hasMediaControls() && inDocument())
+            createMediaControls();
+        return;
+    }
+#endif
+
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
     if (!controls() || !inDocument())
         return;
 
     ensureUserAgentShadowRoot();
     return;
-#elif !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+#endif
+
     if (!controls() || !inDocument()) {
         if (hasMediaControls())
             mediaControls()->hide();
@@ -4741,13 +4758,6 @@ void HTMLMediaElement::configureMediaControls()
         return;
 
     mediaControls()->show();
-#else 
-    if (m_player)
-        m_player->setControls(controls());
-
-    if (!hasMediaControls() && inDocument())
-        createMediaControls();
-#endif
 }
 
 #if ENABLE(VIDEO_TRACK)
@@ -5185,6 +5195,13 @@ void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture()
     m_restrictions = NoRestrictions;
 }
 
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+bool HTMLMediaElement::shouldUseVideoPluginProxy() const
+{
+    return document()->settings() && document()->settings()->isVideoPluginProxyEnabled();
+}
+#endif
+
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
 DOMWrapperWorld& HTMLMediaElement::ensureIsolatedWorld()
 {
index 8400526743499c699a3f3305d488f3de1a70febd..89cb692b5dc66c5e7beb463c22868e207852fb33 100644 (file)
@@ -383,6 +383,10 @@ public:
 
     void enteredOrExitedFullscreen() { configureMediaControls(); }
 
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    bool shouldUseVideoPluginProxy() const;
+#endif
+
 protected:
     HTMLMediaElement(const QualifiedName&, Document&, bool);
     virtual ~HTMLMediaElement();
@@ -427,6 +431,8 @@ protected:
     void endIgnoringTrackDisplayUpdateRequests();
 #endif
 
+    virtual RenderElement* createRenderer(PassRef<RenderStyle>) OVERRIDE;
+
 private:
     void createMediaPlayer();
 
@@ -437,7 +443,6 @@ private:
     virtual bool supportsFocus() const OVERRIDE;
     virtual bool isMouseFocusable() const OVERRIDE;
     virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE;
-    virtual RenderElement* createRenderer(PassRef<RenderStyle>) OVERRIDE;
     virtual bool childShouldCreateRenderer(const Node*) const OVERRIDE;
     virtual InsertionNotificationRequest insertedInto(ContainerNode&) OVERRIDE;
     virtual void removedFrom(ContainerNode&) OVERRIDE;
index a2b50b960e55b3b0a1ec54c4ed3f65bbe83d6a50..2fb13094c326a8f9b37260297759f4349287047a 100644 (file)
@@ -68,25 +68,31 @@ bool HTMLVideoElement::rendererIsNeeded(const RenderStyle& style)
     return HTMLElement::rendererIsNeeded(style); 
 }
 
-#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
 RenderElement* HTMLVideoElement::createRenderer(PassRef<RenderStyle> style)
 {
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    if (shouldUseVideoPluginProxy())
+        return HTMLMediaElement::createRenderer(arena, style);
+#endif
     return new RenderVideo(*this, std::move(style));
 }
-#endif
 
 void HTMLVideoElement::didAttachRenderers()
 {
     HTMLMediaElement::didAttachRenderers();
 
-#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-    updateDisplayState();
-    if (shouldDisplayPosterImage()) {
-        if (!m_imageLoader)
-            m_imageLoader = adoptPtr(new HTMLImageLoader(this));
-        m_imageLoader->updateFromElement();
-        if (renderer())
-            toRenderImage(renderer())->imageResource()->setCachedImage(m_imageLoader->image()); 
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    if (!shouldUseVideoPluginProxy()) {
+#endif
+        updateDisplayState();
+        if (shouldDisplayPosterImage()) {
+            if (!m_imageLoader)
+                m_imageLoader = adoptPtr(new HTMLImageLoader(this));
+            m_imageLoader->updateFromElement();
+            if (renderer())
+                toRenderImage(renderer())->imageResource()->setCachedImage(m_imageLoader->image()); 
+        }
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
     }
 #endif
 }
@@ -114,7 +120,10 @@ void HTMLVideoElement::parseAttribute(const QualifiedName& name, const AtomicStr
         // Force a poster recalc by setting m_displayMode to Unknown directly before calling updateDisplayState.
         HTMLMediaElement::setDisplayMode(Unknown);
         updateDisplayState();
-#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+        if (shouldUseVideoPluginProxy())
+            return;
+#endif
         if (shouldDisplayPosterImage()) {
             if (!m_imageLoader)
                 m_imageLoader = adoptPtr(new HTMLImageLoader(this));
@@ -123,7 +132,6 @@ void HTMLVideoElement::parseAttribute(const QualifiedName& name, const AtomicStr
             if (renderer())
                 toRenderImage(renderer())->imageResource()->setCachedImage(0); 
         }
-#endif
     } else
         HTMLMediaElement::parseAttribute(name, value);
 }
@@ -220,10 +228,12 @@ void HTMLVideoElement::setDisplayMode(DisplayMode mode)
             player()->setPoster(poster);
     }
 
-#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    if (shouldUseVideoPluginProxy())
+        return;
+#endif
     if (renderer() && displayMode() != oldMode)
         renderer()->updateFromElement();
-#endif
 }
 
 void HTMLVideoElement::updateDisplayState()
index d0b70fdc385a64aa7b6bc261fd7b5abe53c117f7..523f68a1a0fd3151349f1f1259607f5812d2b5d7 100644 (file)
@@ -75,9 +75,7 @@ private:
     HTMLVideoElement(const QualifiedName&, Document&, bool);
 
     virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE;
-#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
     virtual RenderElement* createRenderer(PassRef<RenderStyle>) OVERRIDE;
-#endif
     virtual void didAttachRenderers() OVERRIDE;
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
     virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
index 48fd6ffde0cd3a57e1c86aa466d8ae495336039e..6a366ba3cf9c7ee65fd32f738b0ba8ccafb91d06 100644 (file)
@@ -81,6 +81,10 @@ bool Settings::gAVFoundationEnabled = false;
 bool Settings::gQTKitEnabled = true;
 #endif
 
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+bool Settings::gVideoPluginProxyEnabled = true;
+#endif
+
 bool Settings::gMockScrollbarsEnabled = false;
 bool Settings::gUsesOverlayScrollbars = false;
 
@@ -579,6 +583,17 @@ void Settings::setQTKitEnabled(bool enabled)
 }
 #endif
 
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+void Settings::setVideoPluginProxyEnabled(bool enabled)
+{
+    if (gVideoPluginProxyEnabled == enabled)
+        return;
+
+    gVideoPluginProxyEnabled = enabled;
+    HTMLMediaElement::resetMediaEngines();
+}
+#endif
+
 void Settings::setScrollingPerformanceLoggingEnabled(bool enabled)
 {
     m_scrollingPerformanceLoggingEnabled = enabled;
index 159e4d93ef0f408c696ae9dae8771af4c270ed73..6875bf3b79b089a5b1bc12b8dac9b64f59567a10 100644 (file)
@@ -267,6 +267,11 @@ public:
     static bool lowPowerVideoAudioBufferSizeEnabled() { return gLowPowerVideoAudioBufferSizeEnabled; }
     static void setLowPowerVideoAudioBufferSizeEnabled(bool);
 
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    static void setVideoPluginProxyEnabled(bool flag);
+    static bool isVideoPluginProxyEnabled() { return gVideoPluginProxyEnabled; }
+#endif
+
 private:
     explicit Settings(Page*);
 
@@ -353,6 +358,10 @@ private:
     static double gHiddenPageDOMTimerAlignmentInterval;
 
     static bool gLowPowerVideoAudioBufferSizeEnabled;
+
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    static bool gVideoPluginProxyEnabled;
+#endif
 };
 
 } // namespace WebCore
index fd32ff38b0ab8a9f13c7c281de0252e2a2d20688..6ec71c86e107a0bd3e4fa4d39e0b969fc40954b4 100644 (file)
@@ -204,9 +204,14 @@ static Vector<MediaPlayerFactory*>& installedMediaEngines(RequeryEngineOptions r
     if (!enginesQueried) {
         enginesQueried = true;
 
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    if (Settings::isVideoPluginProxyEnabled())
+        MediaPlayerPrivateIOS::registerMediaEngine(addMediaEngine);
+#endif
+
 #if USE(AVFOUNDATION)
         if (Settings::isAVFoundationEnabled()) {
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || PLATFORM(IOS)
             MediaPlayerPrivateAVFoundationObjC::registerMediaEngine(addMediaEngine);
 #elif PLATFORM(WIN)
             MediaPlayerPrivateAVFoundationCF::registerMediaEngine(addMediaEngine);
index b578436cd77e42b0f0bb0b2934c579c87a1c907d..9e7f091f425c92362a26b76926c68c0df1b17db8 100644 (file)
@@ -129,8 +129,8 @@ public:
     virtual void setPoster(const String&) { }
 
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-    virtual void deliverNotification(MediaPlayerProxyNotificationType) = 0;
-    virtual void setMediaPlayerProxy(WebMediaPlayerProxy*) = 0;
+    virtual void deliverNotification(MediaPlayerProxyNotificationType) { }
+    virtual void setMediaPlayerProxy(WebMediaPlayerProxy*) { }
     virtual void setControls(bool) { }
 #endif
 
index 06e54179987ac986e53ca7ce04b42602bdc194c4..751c06390bf87e7712a09c56ca86d6b7f012c3f5 100644 (file)
@@ -46,7 +46,7 @@ OBJC_CLASS WebCoreAVFMovieObserver;
 
 typedef struct objc_object* id;
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
 OBJC_CLASS WebCoreAVFLoaderDelegate;
 OBJC_CLASS AVAssetResourceLoadingRequest;
 #endif
@@ -77,7 +77,7 @@ public:
     void flushCues();
 #endif
     
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
     bool shouldWaitForLoadingOfResource(AVAssetResourceLoadingRequest*);
     void didCancelLoadingRequest(AVAssetResourceLoadingRequest*);
     void didStopLoadingRequest(AVAssetResourceLoadingRequest *);
@@ -156,7 +156,7 @@ private:
     RetainPtr<CGImageRef> createImageForTimeInRect(float, const IntRect&);
     void paintWithImageGenerator(GraphicsContext*, const IntRect&);
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+#if HAVE(AVFOUNDATION_VIDEO_OUTPUT)
     void createVideoOutput();
     void destroyVideoOutput();
     RetainPtr<CVPixelBufferRef> createPixelBuffer();
@@ -200,14 +200,16 @@ private:
     bool m_haveCheckedPlayability;
 
     RetainPtr<AVAssetImageGenerator> m_imageGenerator;
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+#if HAVE(AVFOUNDATION_VIDEO_OUTPUT)
     RetainPtr<AVPlayerItemVideoOutput> m_videoOutput;
     RetainPtr<CVPixelBufferRef> m_lastImage;
 #endif
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if USE(VIDEOTOOLBOX)
     RetainPtr<VTPixelTransferSessionRef> m_pixelTransferSession;
+#endif
 
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
     friend class WebCoreAVFResourceLoader;
     HashMap<RetainPtr<AVAssetResourceLoadingRequest>, RefPtr<WebCoreAVFResourceLoader>> m_resourceLoaderMap;
     RetainPtr<WebCoreAVFLoaderDelegate> m_loaderDelegate;
index c3cacb9cde28ce8cb5e50a42ed0a49cb79582ebd..821a9276828aebe6296daa8fb4f732a6d0228647 100644 (file)
 
 #import <AVFoundation/AVFoundation.h>
 #import <CoreMedia/CoreMedia.h>
+#import <QuartzCore/CoreImage.h>
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if USE(VIDEOTOOLBOX)
 #import <CoreVideo/CoreVideo.h>
 #import <VideoToolbox/VideoToolbox.h>
 #endif
 
 SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
 SOFT_LINK_FRAMEWORK_OPTIONAL(CoreMedia)
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+SOFT_LINK_FRAMEWORK_OPTIONAL(CoreImage)
 SOFT_LINK_FRAMEWORK_OPTIONAL(CoreVideo)
+
+#if USE(VIDEOTOOLBOX)
 SOFT_LINK_FRAMEWORK_OPTIONAL(VideoToolbox)
 #endif
 
@@ -80,9 +82,9 @@ SOFT_LINK(CoreMedia, CMTimeMakeWithSeconds, CMTime, (Float64 seconds, int32_t pr
 SOFT_LINK(CoreMedia, CMTimeGetSeconds, Float64, (CMTime time), (time))
 SOFT_LINK(CoreMedia, CMTimeRangeGetEnd, CMTime, (CMTimeRange range), (range))
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
 SOFT_LINK(CoreVideo, CVPixelBufferGetWidth, size_t, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
 SOFT_LINK(CoreVideo, CVPixelBufferGetHeight, size_t, (CVPixelBufferRef pixelBuffer), (pixelBuffer))
+#if USE(VIDEOTOOLBOX)
 SOFT_LINK(VideoToolbox, VTPixelTransferSessionCreate, OSStatus, (CFAllocatorRef allocator, VTPixelTransferSessionRef *pixelTransferSessionOut), (allocator, pixelTransferSessionOut))
 SOFT_LINK(VideoToolbox, VTPixelTransferSessionTransferImage, OSStatus, (VTPixelTransferSessionRef session, CVPixelBufferRef sourceBuffer, CVPixelBufferRef destinationBuffer), (session, sourceBuffer, destinationBuffer))
 #endif
@@ -93,6 +95,8 @@ SOFT_LINK_CLASS(AVFoundation, AVPlayerItemVideoOutput)
 SOFT_LINK_CLASS(AVFoundation, AVPlayerLayer)
 SOFT_LINK_CLASS(AVFoundation, AVURLAsset)
 SOFT_LINK_CLASS(AVFoundation, AVAssetImageGenerator)
+SOFT_LINK_CLASS(CoreImage, CIContext)
+SOFT_LINK_CLASS(CoreImage, CIImage)
 
 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicVisual, NSString *)
 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicAudible, NSString *)
@@ -104,6 +108,7 @@ SOFT_LINK_POINTER(AVFoundation, AVAssetImageGeneratorApertureModeCleanAperture,
 SOFT_LINK_POINTER(AVFoundation, AVURLAssetReferenceRestrictionsKey, NSString *)
 SOFT_LINK_POINTER(AVFoundation, AVLayerVideoGravityResizeAspect, NSString *)
 SOFT_LINK_POINTER(AVFoundation, AVLayerVideoGravityResize, NSString *)
+SOFT_LINK_POINTER(CoreVideo, kCVPixelBufferPixelFormatTypeKey, NSString *)
 
 SOFT_LINK_CONSTANT(CoreMedia, kCMTimeZero, CMTime)
 
@@ -124,6 +129,7 @@ SOFT_LINK_CONSTANT(CoreMedia, kCMTimeZero, CMTime)
 #define AVURLAssetReferenceRestrictionsKey getAVURLAssetReferenceRestrictionsKey()
 #define AVLayerVideoGravityResizeAspect getAVLayerVideoGravityResizeAspect()
 #define AVLayerVideoGravityResize getAVLayerVideoGravityResize()
+#define kCVPixelBufferPixelFormatTypeKey getkCVPixelBufferPixelFormatTypeKey()
 
 #if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
 typedef AVMediaSelectionGroup AVMediaSelectionGroupType;
@@ -179,7 +185,7 @@ enum MediaPlayerAVFoundationObservationContext {
 #endif
 @end
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
 @interface WebCoreAVFLoaderDelegate : NSObject<AVAssetResourceLoaderDelegate> {
     MediaPlayerPrivateAVFoundationObjC* m_callback;
 }
@@ -210,7 +216,7 @@ static PlayerToPrivateMapType& playerToPrivateMap()
 };
 #endif
 
-#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
 static dispatch_queue_t globalLoaderDelegateQueue()
 {
     static dispatch_queue_t globalQueue;
@@ -238,7 +244,7 @@ MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC(MediaPlay
     , m_objcObserver(adoptNS([[WebCoreAVFMovieObserver alloc] initWithCallback:this]))
     , m_videoFrameHasDrawn(false)
     , m_haveCheckedPlayability(false)
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
     , m_loaderDelegate(adoptNS([[WebCoreAVFLoaderDelegate alloc] initWithCallback:this]))
 #endif
     , m_currentTrack(0)
@@ -253,7 +259,7 @@ MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC()
 #if ENABLE(ENCRYPTED_MEDIA_V2)
     playerToPrivateMap().remove(player());
 #endif
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
     [m_loaderDelegate.get() setCallback:0];
     [[m_avAsset.get() resourceLoader] setDelegate:nil queue:0];
 #endif
@@ -308,7 +314,7 @@ bool MediaPlayerPrivateAVFoundationObjC::hasLayerRenderer() const
 
 bool MediaPlayerPrivateAVFoundationObjC::hasContextRenderer() const
 {
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+#if HAVE(AVFOUNDATION_VIDEO_OUTPUT)
     if (m_videoOutput)
         return true;
 #endif
@@ -317,7 +323,7 @@ bool MediaPlayerPrivateAVFoundationObjC::hasContextRenderer() const
 
 void MediaPlayerPrivateAVFoundationObjC::createContextVideoRenderer()
 {
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+#if HAVE(AVFOUNDATION_VIDEO_OUTPUT)
     createVideoOutput();
 #else
     createImageGenerator();
@@ -343,7 +349,7 @@ void MediaPlayerPrivateAVFoundationObjC::createImageGenerator()
 
 void MediaPlayerPrivateAVFoundationObjC::destroyContextVideoRenderer()
 {
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+#if HAVE(AVFOUNDATION_VIDEO_OUTPUT)
     destroyVideoOutput();
 #endif
     destroyImageGenerator();
@@ -367,7 +373,7 @@ void MediaPlayerPrivateAVFoundationObjC::createVideoLayer()
     if (!m_videoLayer) {
         m_videoLayer = adoptNS([[AVPlayerLayer alloc] init]);
         [m_videoLayer.get() setPlayer:m_avPlayer.get()];
-        [m_videoLayer.get() setBackgroundColor:CGColorGetConstantColor(kCGColorBlack)];
+        [m_videoLayer.get() setBackgroundColor:cachedCGColor(Color::black, ColorSpaceDeviceRGB)];
 #ifndef NDEBUG
         [m_videoLayer.get() setName:@"Video layer"];
 #endif
@@ -427,7 +433,7 @@ void MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL(const String& url)
     NSURL *cocoaURL = URL(ParsedURLString, url);
     m_avAsset = adoptNS([[AVURLAsset alloc] initWithURL:cocoaURL options:options.get()]);
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
     [[m_avAsset.get() resourceLoader] setDelegate:m_loaderDelegate.get() queue:globalLoaderDelegateQueue()];
 #endif
 
@@ -793,7 +799,7 @@ void MediaPlayerPrivateAVFoundationObjC::paintCurrentFrameInContext(GraphicsCont
     setDelayCallbacks(true);
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+#if HAVE(AVFOUNDATION_VIDEO_OUTPUT)
     if (videoOutputHasAvailableFrame())
         paintWithVideoOutput(context, rect);
     else
@@ -921,7 +927,7 @@ MediaPlayer::SupportsType MediaPlayerPrivateAVFoundationObjC::supportsType(const
     return [AVURLAsset isPlayableExtendedMIMEType:typeString] ? MediaPlayer::IsSupported : MediaPlayer::MayBeSupported;;
 }
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
 bool MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource(AVAssetResourceLoadingRequest* avRequest)
 {
     String scheme = [[[avRequest request] URL] scheme];
@@ -1177,7 +1183,7 @@ bool MediaPlayerPrivateAVFoundationObjC::hasSingleSecurityOrigin() const
     return resolvedOrigin->isSameSchemeHostPort(requestedOrigin.get());
 }
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
+#if HAVE(AVFOUNDATION_VIDEO_OUTPUT)
 void MediaPlayerPrivateAVFoundationObjC::createVideoOutput()
 {
     LOG(Media, "MediaPlayerPrivateAVFoundationObjC::createVideoOutput(%p)", this);
@@ -1185,10 +1191,10 @@ void MediaPlayerPrivateAVFoundationObjC::createVideoOutput()
     if (!m_avPlayerItem || m_videoOutput)
         return;
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if USE(VIDEOTOOLBOX)
     NSDictionary* attributes = @{ (NSString*)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_422YpCbCr8) };
 #else
-    NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:k32BGRAPixelFormat], kCVPixelBufferPixelFormatTypeKey,
+    NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA], kCVPixelBufferPixelFormatTypeKey,
                                 nil];
 #endif
     m_videoOutput = adoptNS([[AVPlayerItemVideoOutput alloc] initWithPixelBufferAttributes:attributes]);
@@ -1230,7 +1236,7 @@ RetainPtr<CVPixelBufferRef> MediaPlayerPrivateAVFoundationObjC::createPixelBuffe
     if (!buffer)
         return 0;
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if USE(VIDEOTOOLBOX)
     // Create a VTPixelTransferSession, if necessary, as we cannot guarantee timely delivery of ARGB pixels.
     if (!m_pixelTransferSession) {
         VTPixelTransferSessionRef session = 0;
@@ -1239,7 +1245,7 @@ RetainPtr<CVPixelBufferRef> MediaPlayerPrivateAVFoundationObjC::createPixelBuffe
     }
 
     CVPixelBufferRef outputBuffer;
-    CVPixelBufferCreate(kCFAllocatorDefault, CVPixelBufferGetWidth(buffer.get()), CVPixelBufferGetHeight(buffer.get()), k32BGRAPixelFormat, 0, &outputBuffer);
+    CVPixelBufferCreate(kCFAllocatorDefault, CVPixelBufferGetWidth(buffer.get()), CVPixelBufferGetHeight(buffer.get()), kCVPixelFormatType_32BGRA, 0, &outputBuffer);
     VTPixelTransferSessionTransferImage(m_pixelTransferSession.get(), buffer.get(), outputBuffer);
     buffer = adoptCF(outputBuffer);
 #endif
@@ -1280,14 +1286,24 @@ void MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput(GraphicsContext* c
         GraphicsContextStateSaver stateSaver(*context);
         context->translate(rect.x(), rect.y() + rect.height());
         context->scale(FloatSize(1.0f, -1.0f));
-        RetainPtr<CIImage> image = adoptNS([[CIImage alloc] initWithCVImageBuffer:m_lastImage.get() options:@{ kCIImageColorSpace: (id)deviceRGBColorSpaceRef() }]);
+
+        CGRect outputRect = { CGPointZero, rect.size() };
+        CGRect imageRect = CGRectMake(0, 0, CVPixelBufferGetWidth(m_lastImage.get()), CVPixelBufferGetHeight(m_lastImage.get()));
+#if PLATFORM(IOS)
+        // ciContext does not use a RetainPtr for results of contextWithCGContext:, as the returned value
+        // is autoreleased, and there is no non-autoreleased version of that function.
+        CIContext* ciContext = [getCIContextClass() contextWithOptions:nil];
+        RetainPtr<CIImage> image = adoptNS([[getCIImageClass() alloc] initWithCVPixelBuffer:m_lastImage.get()]);
+        RetainPtr<CGImage> cgImage = adoptCF([ciContext createCGImage:image.get() fromRect:imageRect]);
+        context->drawNativeImage(cgImage.get(), FloatSize(imageRect.size), ColorSpaceDeviceRGB, FloatRect(outputRect), FloatRect(imageRect), 1);
+#else
 
         // ciContext does not use a RetainPtr for results of contextWithCGContext:, as the returned value
         // is autoreleased, and there is no non-autoreleased version of that function.
         CIContext* ciContext = [CIContext contextWithCGContext:context->platformContext() options:nil];
-        CGRect outputRect = { CGPointZero, rect.size() };
-        CGRect imageRect = CGRectMake(0, 0, CVPixelBufferGetWidth(m_lastImage.get()), CVPixelBufferGetHeight(m_lastImage.get()));
+        RetainPtr<CIImage> image = adoptNS([[CIImage alloc] initWithCVImageBuffer:m_lastImage.get() options:@{ kCIImageColorSpace: (id)deviceRGBColorSpaceRef() }]);
         [ciContext drawImage:image.get() inRect:outputRect fromRect:imageRect];
+#endif
 
         // If we have created an AVAssetImageGenerator in the past due to m_videoOutput not having an available
         // video frame, destroy it now that it is no longer needed.
@@ -1776,7 +1792,7 @@ NSArray* itemKVOProperties()
 
 @end
 
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
 @implementation WebCoreAVFLoaderDelegate
 
 - (id)initWithCallback:(MediaPlayerPrivateAVFoundationObjC*)callback
index 4a049e781eaa3da986870fe281d1ecf7a674741e..1a65f53452d4398a64fd1f5d756ff01e24a3d8ea 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef WebCoreAVFResourceLoader_h
 #define WebCoreAVFResourceLoader_h
 
-#if ENABLE(VIDEO) && USE(AVFOUNDATION) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if ENABLE(VIDEO) && USE(AVFOUNDATION) && HAVE(AVFOUNDATION_LOADER_DELEGATE)
 
 #include "CachedRawResourceClient.h"
 #include "CachedResourceHandle.h"
index 756210f014e795ededa5d77d38ab8ef554262985..99c92848a0fe02dcbff4026bf6ccc5ec965d7021 100644 (file)
@@ -26,7 +26,7 @@
 #import "config.h"
 #import "WebCoreAVFResourceLoader.h"
 
-#if ENABLE(VIDEO) && USE(AVFOUNDATION) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if ENABLE(VIDEO) && USE(AVFOUNDATION) && HAVE(AVFOUNDATION_LOADER_DELEGATE)
 
 #import "CachedRawResource.h"
 #import "CachedResourceLoader.h"
index 87359c6fff6f74c707cc33c77db22145b1a4e094..0e2faa53d6907678b797746c2ac33e4f844650cb 100644 (file)
@@ -1,3 +1,20 @@
+2013-11-01  Jer Noble  <jer.noble@apple.com>
+
+        [PluginProxy] Add a setting to disable video plugin proxy support in HTMLMediaElement.
+        https://bugs.webkit.org/show_bug.cgi?id=123621
+
+        Reviewed by Eric Carlson.
+
+        Add a new isVideoPluginProxyEnabled setting.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]): Set isVideoPluginProxyEnabled preference.
+        (-[WebPreferences isVideoPluginProxyEnabled]): Pass through to Settings.
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]): Set isVideoPluginProxyEnabled preference.
+
 2013-11-01  Andy Estes  <aestes@apple.com>
 
         [iOS] Make some headers Private
index 343f22f9bd33a2cae6bf19cf73c396b932bd71bf..52bebe74bb2ac03aae985e23367130d1262788fc 100644 (file)
 #define WebKitAsynchronousSpellCheckingEnabledPreferenceKey @"WebKitAsynchronousSpellCheckingEnabled"
 #define WebKitHyperlinkAuditingEnabledPreferenceKey @"WebKitHyperlinkAuditingEnabled"
 #define WebKitAVFoundationEnabledKey @"WebKitAVFoundationEnabled"
+#define WebKitVideoPluginProxyEnabledKey @"WebKitVideoPluginProxyEnabled"
 #define WebKitHixie76WebSocketProtocolEnabledKey @"WebKitHixie76WebSocketProtocolEnabled"
 #define WebKitMediaPlaybackRequiresUserGesturePreferenceKey @"WebKitMediaPlaybackRequiresUserGesture"
 #define WebKitMediaPlaybackAllowsInlinePreferenceKey @"WebKitMediaPlaybackAllowsInline"
index 2d49b2ec1c47f40aaa8c9db411f48f129808a402..775c2f32caab3d2c9e9963970cbd973c5baf5940 100644 (file)
@@ -425,6 +425,9 @@ public:
         [NSNumber numberWithBool:NO], WebKitHiddenPageDOMTimerThrottlingEnabledPreferenceKey,
         [NSNumber numberWithBool:NO], WebKitHiddenPageCSSAnimationSuspensionEnabledPreferenceKey,
         [NSNumber numberWithBool:NO], WebKitLowPowerVideoAudioBufferSizeEnabledPreferenceKey,
+#if !PLATFORM(IOS)
+        [NSNumber numberWithBool:NO],   WebKitVideoPluginProxyEnabledKey,
+#endif
         nil];
 
 
@@ -1667,6 +1670,16 @@ static NSString *classIBCreatorID = nil;
     return [self _boolValueForKey:WebKitQTKitEnabledPreferenceKey];
 }
 
+- (void)setVideoPluginProxyEnabled:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitVideoPluginProxyEnabledKey];
+}
+
+- (BOOL)isVideoPluginProxyEnabled
+{
+    return [self _boolValueForKey:WebKitVideoPluginProxyEnabledKey];
+}
+
 - (void)setHixie76WebSocketProtocolEnabled:(BOOL)flag
 {
 }
index bdd045559eb8d96d990d441dddcd85dd56aa28c0..4071abc5b03890b456d39868934cdc7458a78fe4 100644 (file)
@@ -289,6 +289,11 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification;
 - (void)setQTKitEnabled:(BOOL)flag;
 - (BOOL)isQTKitEnabled;
 
+// VideoPluginProxy support is dependent on WebCore/WebKit being
+// compiled with ENABLE_PLUGIN_PROXY_FOR_VIDEO.
+- (void)setVideoPluginProxyEnabled:(BOOL)flag;
+- (BOOL)isVideoPluginProxyEnabled;
+
 // WebSocket support depends on ENABLE(WEB_SOCKETS).
 - (void)setHixie76WebSocketProtocolEnabled:(BOOL)flag;
 - (BOOL)isHixie76WebSocketProtocolEnabled;
index bea36756482baef3788f6d03777938ae5b6bb166..9fb9a52ec6453f51421831ed280e49f45c11be75 100644 (file)
@@ -1719,6 +1719,10 @@ static bool needsSelfRetainWhileLoadingQuirk()
     settings.setDiagnosticLoggingEnabled([preferences diagnosticLoggingEnabled]);
     settings.setLowPowerVideoAudioBufferSizeEnabled([preferences lowPowerVideoAudioBufferSizeEnabled]);
 
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    settings->setVideoPluginProxyEnabled([preferences isVideoPluginProxyEnabled]);
+#endif
+
     switch ([preferences storageBlockingPolicy]) {
     case WebAllowAllStorage:
         settings.setStorageBlockingPolicy(SecurityOrigin::AllowAllStorage);
index 949666c55581c3677a45e9359cc48ce54db4c294..209e5a62604622b6a5f57fa8abb10d227b1457d8 100644 (file)
@@ -1,3 +1,20 @@
+2013-11-01  Jer Noble  <jer.noble@apple.com>
+
+        [PluginProxy] Add a setting to disable video plugin proxy support in HTMLMediaElement.
+        https://bugs.webkit.org/show_bug.cgi?id=123621
+
+        Reviewed by Eric Carlson.
+
+        Add WebKit2 functions for setting then new isVideoPluginProxyEnabled preference.
+
+        * Shared/WebPreferencesStore.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetVideoPluginProxyEnabled):
+        (WKPreferencesGetVideoPluginProxyEnabled):
+        * UIProcess/API/C/WKPreferences.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2013-11-04  Anders Carlsson  <andersca@apple.com>
 
         More WKRemoteObjectRegistry work
index 8307e42a1efa5629114a67b0dd5002b5bca905e7..1613f14d23762eb87f7d65846e557d687d1bfd4f 100644 (file)
@@ -64,6 +64,12 @@ namespace WebKit {
 #define DEFAULT_PDFPLUGIN_ENABLED false
 #endif
 
+#if PLATFORM(IOS)
+#define DEFAULT_VIDEO_PLUGIN_PROXY_ENABLED true
+#else
+#define DEFAULT_VIDEO_PLUGIN_PROXY_ENABLED false
+#endif
+
 #define FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
     macro(JavaScriptEnabled, javaScriptEnabled, Bool, bool, true) \
     macro(JavaScriptMarkupEnabled, javaScriptMarkupEnabled, Bool, bool, true) \
@@ -168,6 +174,7 @@ namespace WebKit {
     macro(SimpleLineLayoutEnabled, simpleLineLayoutEnabled, Bool, bool, true) \
     macro(SimpleLineLayoutDebugBordersEnabled, simpleLineLayoutDebugBordersEnabled, Bool, bool, false) \
     macro(MediaStreamEnabled, mediaStreamEnabled, Bool, bool, false) \
+    macro(VideoPluginProxyEnabled, isVideoPluginProxyEnabled, Bool, bool, DEFAULT_VIDEO_PLUGIN_PROXY_ENABLED) \
     \
 
 #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
index 1bd16ccbd799cc8fc19e5a247fe2e0a4efd8282f..f96c5befa5102782e3ae2c0c4fa11fa0a3bc3c8b 100644 (file)
@@ -1205,3 +1205,13 @@ bool WKPreferencesGetMediaStreamEnabled(WKPreferencesRef preferencesRef)
 {
     return toImpl(preferencesRef)->mediaStreamEnabled();
 }
+
+void WKPreferencesSetVideoPluginProxyEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+    toImpl(preferencesRef)->setVideoPluginProxyEnabled(enabled);
+}
+
+bool WKPreferencesGetVideoPluginProxyEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->isVideoPluginProxyEnabled();
+}
index 882effd2c8dfbd071471784872969b63fe1c8e0e..3515f32d4bbb6095a125ddebd22ba03adf20733b 100644 (file)
@@ -244,6 +244,10 @@ WK_EXPORT bool WKPreferencesGetAsynchronousSpellCheckingEnabled(WKPreferencesRef
 WK_EXPORT void WKPreferencesSetMediaStreamEnabled(WKPreferencesRef preferencesRef, bool enabled);
 WK_EXPORT bool WKPreferencesGetMediaStreamEnabled(WKPreferencesRef preferencesRef);
 
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetVideoPluginProxyEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetVideoPluginProxyEnabled(WKPreferencesRef preferencesRef);
+
 #ifdef __cplusplus
 }
 #endif
index fd56e6d2a02a5c8c48493210ca5a333df2c62f4e..cb0c1533437b066b69f86507d4b2f2dd3b8aa666 100644 (file)
@@ -2423,6 +2423,10 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     settings.setQTKitEnabled(store.getBoolValueForKey(WebPreferencesKey::isQTKitEnabledKey()));
 #endif
 
+#if USE(PLUGIN_PROXY_FOR_VIDEO)
+    settings->setVideoPluginProxyEnabled(store.getBoolValueForKey(WebPreferencesKey::isVideoPluginProxyEnabledKey()));
+#endif
+
 #if ENABLE(WEB_AUDIO)
     settings.setWebAudioEnabled(store.getBoolValueForKey(WebPreferencesKey::webAudioEnabledKey()));
 #endif