Title: [219526] trunk/Source
Revision
219526
Author
[email protected]
Date
2017-07-14 15:04:20 -0700 (Fri, 14 Jul 2017)

Log Message

Allow clients to override their own hardware media requirements where no fallback media exists.
https://bugs.webkit.org/show_bug.cgi?id=174426
<rdar://problem/32537704>

Reviewed by Eric Carlson.

Source/WebCore:

Add a new setting which allows clients to specify their own mediaContentTypesRequiringHardwareSupport should be
ignared in the case where no fallback exists, such as the case of a single <source> element, or setting the src
attribute directly.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::havePotentialSourceChild):
(WebCore::HTMLMediaElement::selectNextSourceChild):
(WebCore::HTMLMediaElement::sourceWasAdded):
(WebCore::HTMLMediaElement::sourceWasRemoved):
(WebCore::HTMLMediaElement::mediaPlayerShouldCheckHardwareSupport):
* html/HTMLMediaElement.h:
* page/Settings.h:
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::shouldCheckHardwareSupport):
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerShouldCheckHardwareSupport):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::assetStatus):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset):

Source/WebKit:

Add a new WKWebViewConfiguration property, as well as a new WKPreferences function, both to control
WebCore's new allowMediaContentTypesRequiringHardwareSupportAsFallback setting.

* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesGetAllowMediaContentTypesRequiringHardwareSupportAsFallback):
(WKPreferencesSetAllowMediaContentTypesRequiringHardwareSupportAsFallback):
* UIProcess/API/C/WKPreferencesRef.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration init]):
(-[WKWebViewConfiguration copyWithZone:]):
(-[WKWebViewConfiguration _setAllowMediaContentTypesRequiringHardwareSupportAsFallback:]):
(-[WKWebViewConfiguration _allowMediaContentTypesRequiringHardwareSupportAsFallback]):
* UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

Source/WebKitLegacy/mac:

Add a new WebPreferences property to control WebCore's new
allowMediaContentTypesRequiringHardwareSupportAsFallback setting.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences allowMediaContentTypesRequiringHardwareSupportAsFallback]):
(-[WebPreferences setAllowMediaContentTypesRequiringHardwareSupportAsFallback:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (219525 => 219526)


--- trunk/Source/WebCore/ChangeLog	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebCore/ChangeLog	2017-07-14 22:04:20 UTC (rev 219526)
@@ -1,3 +1,32 @@
+2017-07-14  Jer Noble  <[email protected]>
+
+        Allow clients to override their own hardware media requirements where no fallback media exists.
+        https://bugs.webkit.org/show_bug.cgi?id=174426
+        <rdar://problem/32537704>
+
+        Reviewed by Eric Carlson.
+
+        Add a new setting which allows clients to specify their own mediaContentTypesRequiringHardwareSupport should be
+        ignared in the case where no fallback exists, such as the case of a single <source> element, or setting the src
+        attribute directly.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::havePotentialSourceChild):
+        (WebCore::HTMLMediaElement::selectNextSourceChild):
+        (WebCore::HTMLMediaElement::sourceWasAdded):
+        (WebCore::HTMLMediaElement::sourceWasRemoved):
+        (WebCore::HTMLMediaElement::mediaPlayerShouldCheckHardwareSupport):
+        * html/HTMLMediaElement.h:
+        * page/Settings.h:
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::shouldCheckHardwareSupport):
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::MediaPlayerClient::mediaPlayerShouldCheckHardwareSupport):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::assetStatus):
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+        (WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset):
+
 2017-07-14  Chris Dumez  <[email protected]>
 
         Possible crash under NetworkSocketStream::didFailSocketStream()

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (219525 => 219526)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-07-14 22:04:20 UTC (rev 219526)
@@ -43,7 +43,7 @@
 #include "DiagnosticLoggingKeys.h"
 #include "Document.h"
 #include "DocumentLoader.h"
-#include "ElementIterator.h"
+#include "ElementChildIterator.h"
 #include "EventNames.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
@@ -4222,7 +4222,7 @@
     // Stash the current <source> node and next nodes so we can restore them after checking
     // to see there is another potential.
     RefPtr<HTMLSourceElement> currentSourceNode = m_currentSourceNode;
-    RefPtr<Node> nextNode = m_nextChildNodeToConsider;
+    RefPtr<HTMLSourceElement> nextNode = m_nextChildNodeToConsider;
 
     URL nextURL = selectNextSourceChild(0, 0, DoNothing);
 
@@ -4250,31 +4250,21 @@
         return URL();
     }
 
-    URL mediaURL;
-    HTMLSourceElement* source = nullptr;
-    String type;
-    bool lookingForStartNode = m_nextChildNodeToConsider;
-    bool canUseSourceElement = false;
-    bool okToLoadSourceURL;
+    // Because the DOM may be mutated in the course of the following algorithm,
+    // keep strong references to each of the child source nodes, and verify that
+    // each still is a child of this media element before using.
+    Vector<Ref<HTMLSourceElement>> potentialSourceNodes;
+    auto sources = childrenOfType<HTMLSourceElement>(*this);
+    for (auto next = m_nextChildNodeToConsider ? sources.beginAt(*m_nextChildNodeToConsider) : sources.begin(), end = sources.end(); next != end; ++next)
+        potentialSourceNodes.append(*next);
 
-    NodeVector potentialSourceNodes;
-    getChildNodes(*this, potentialSourceNodes);
-
-    for (unsigned i = 0; !canUseSourceElement && i < potentialSourceNodes.size(); ++i) {
-        Node& node = potentialSourceNodes[i].get();
-        if (lookingForStartNode && m_nextChildNodeToConsider != &node)
+    for (auto& source : potentialSourceNodes) {
+        if (source->parentNode() != this)
             continue;
-        lookingForStartNode = false;
 
-        if (!node.hasTagName(sourceTag))
-            continue;
-        if (node.parentNode() != this)
-            continue;
-
-        source = downcast<HTMLSourceElement>(&node);
-
         // If candidate does not have a src attribute, or if its src attribute's value is the empty string ... jump down to the failed step below
-        mediaURL = source->getNonEmptyURLAttribute(srcAttr);
+        auto mediaURL = source->getNonEmptyURLAttribute(srcAttr);
+        String type;
 #if !LOG_DISABLED
         if (shouldLog)
             LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - 'src' is %s", this, urlForLoggingMedia(mediaURL).utf8().data());
@@ -4309,7 +4299,8 @@
 #if ENABLE(MEDIA_STREAM)
             parameters.isMediaStream = mediaURL.protocolIs(mediaStreamBlobProtocol);
 #endif
-            parameters.contentTypesRequiringHardwareSupport = mediaContentTypesRequiringHardwareSupport();
+            if (!document().settings().allowMediaContentTypesRequiringHardwareSupportAsFallback() || Traversal<HTMLSourceElement>::nextSkippingChildren(source))
+                parameters.contentTypesRequiringHardwareSupport = mediaContentTypesRequiringHardwareSupport();
 
             if (!MediaPlayer::supportsType(parameters, this))
                 goto CheckAgain;
@@ -4316,41 +4307,41 @@
         }
 
         // Is it safe to load this url?
-        okToLoadSourceURL = isSafeToLoadURL(mediaURL, actionIfInvalid) && dispatchBeforeLoadEvent(mediaURL.string());
+        if (!isSafeToLoadURL(mediaURL, actionIfInvalid) || !dispatchBeforeLoadEvent(mediaURL.string()))
+            goto CheckAgain;
 
         // A 'beforeload' event handler can mutate the DOM, so check to see if the source element is still a child node.
-        if (node.parentNode() != this) {
+        if (source->parentNode() != this) {
             LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) - 'beforeload' removed current element", this);
-            source = nullptr;
-            goto CheckAgain;
+            continue;
         }
 
-        if (!okToLoadSourceURL)
-            goto CheckAgain;
-
         // Making it this far means the <source> looks reasonable.
-        canUseSourceElement = true;
+        if (contentType)
+            *contentType = ContentType(type);
+        m_nextChildNodeToConsider = Traversal<HTMLSourceElement>::nextSkippingChildren(source);
+        m_currentSourceNode = WTFMove(source);
 
+#if !LOG_DISABLED
+        if (shouldLog)
+            LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) -> %p, %s", this, m_currentSourceNode.get(), urlForLoggingMedia(mediaURL).utf8().data());
+#endif
+
+        return mediaURL;
+
 CheckAgain:
-        if (!canUseSourceElement && actionIfInvalid == Complain && source)
+        if (actionIfInvalid == Complain)
             source->scheduleErrorEvent();
     }
 
-    if (canUseSourceElement) {
-        if (contentType)
-            *contentType = ContentType(type);
-        m_currentSourceNode = source;
-        m_nextChildNodeToConsider = source->nextSibling();
-    } else {
-        m_currentSourceNode = nullptr;
-        m_nextChildNodeToConsider = nullptr;
-    }
+    m_currentSourceNode = nullptr;
+    m_nextChildNodeToConsider = nullptr;
 
 #if !LOG_DISABLED
     if (shouldLog)
-        LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) -> %p, %s", this, m_currentSourceNode.get(), canUseSourceElement ? urlForLoggingMedia(mediaURL).utf8().data() : "");
+        LOG(Media, "HTMLMediaElement::selectNextSourceChild(%p) -> %p, failed", this, m_currentSourceNode.get());
 #endif
-    return canUseSourceElement ? mediaURL : URL();
+    return URL();
 }
 
 void HTMLMediaElement::sourceWasAdded(HTMLSourceElement& source)
@@ -4380,7 +4371,7 @@
         return;
     }
 
-    if (m_currentSourceNode && &source == m_currentSourceNode->nextSibling()) {
+    if (m_currentSourceNode && &source == Traversal<HTMLSourceElement>::nextSibling(*m_currentSourceNode)) {
         LOG(Media, "HTMLMediaElement::sourceWasAdded(%p) - <source> inserted immediately after current source", this);
         m_nextChildNodeToConsider = &source;
         return;
@@ -4419,8 +4410,7 @@
         return;
 
     if (&source == m_nextChildNodeToConsider) {
-        if (m_currentSourceNode)
-            m_nextChildNodeToConsider = m_currentSourceNode->nextSibling();
+        m_nextChildNodeToConsider = m_currentSourceNode ? Traversal<HTMLSourceElement>::nextSibling(*m_currentSourceNode) : nullptr;
         LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_nextChildNodeToConsider set to %p", this, m_nextChildNodeToConsider.get());
     } else if (&source == m_currentSourceNode) {
         // Clear the current source node pointer, but don't change the movie as the spec says:
@@ -6676,6 +6666,20 @@
     return document().settings().mediaContentTypesRequiringHardwareSupport();
 }
 
+bool HTMLMediaElement::mediaPlayerShouldCheckHardwareSupport() const
+{
+    if (!document().settings().allowMediaContentTypesRequiringHardwareSupportAsFallback())
+        return true;
+
+    if (m_loadState == LoadingFromSourceElement && m_currentSourceNode && !m_nextChildNodeToConsider)
+        return false;
+
+    if (m_loadState == LoadingFromSrcAttr)
+        return false;
+
+    return true;
+}
+
 #if USE(GSTREAMER)
 void HTMLMediaElement::requestInstallMissingPlugins(const String& details, const String& description, MediaPlayerRequestInstallMissingPluginsCallback& callback)
 {

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (219525 => 219526)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2017-07-14 22:04:20 UTC (rev 219526)
@@ -684,6 +684,7 @@
     double mediaPlayerRequestedPlaybackRate() const final;
     VideoFullscreenMode mediaPlayerFullscreenMode() const final { return fullscreenMode(); }
     bool mediaPlayerShouldDisableSleep() const final { return shouldDisableSleep() == SleepType::Display; }
+    bool mediaPlayerShouldCheckHardwareSupport() const final;
     const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const final;
 
 #if USE(GSTREAMER)
@@ -931,7 +932,7 @@
     enum LoadState { WaitingForSource, LoadingFromSrcAttr, LoadingFromSourceElement };
     LoadState m_loadState { WaitingForSource };
     RefPtr<HTMLSourceElement> m_currentSourceNode;
-    RefPtr<Node> m_nextChildNodeToConsider;
+    RefPtr<HTMLSourceElement> m_nextChildNodeToConsider;
 
     VideoFullscreenMode m_videoFullscreenMode { VideoFullscreenModeNone };
     bool m_preparedForInline;

Modified: trunk/Source/WebCore/page/Settings.in (219525 => 219526)


--- trunk/Source/WebCore/page/Settings.in	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebCore/page/Settings.in	2017-07-14 22:04:20 UTC (rev 219526)
@@ -297,3 +297,5 @@
 constantPropertiesEnabled initial=false
 
 viewportFitEnabled initial=false
+
+allowMediaContentTypesRequiringHardwareSupportAsFallback initial=false

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (219525 => 219526)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2017-07-14 22:04:20 UTC (rev 219526)
@@ -1482,6 +1482,11 @@
     return client().mediaContentTypesRequiringHardwareSupport();
 }
 
+bool MediaPlayer::shouldCheckHardwareSupport() const
+{
+    return client().mediaPlayerShouldCheckHardwareSupport();
 }
 
+}
+
 #endif

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (219525 => 219526)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2017-07-14 22:04:20 UTC (rev 219526)
@@ -276,6 +276,7 @@
 
     virtual bool mediaPlayerShouldDisableSleep() const { return false; }
     virtual const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const;
+    virtual bool mediaPlayerShouldCheckHardwareSupport() const { return false; }
 };
 
 class MediaPlayerSupportsTypeClient {
@@ -594,6 +595,7 @@
     bool contentMIMETypeWasInferredFromExtension() const { return m_contentMIMETypeWasInferredFromExtension; }
 
     const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const;
+    bool shouldCheckHardwareSupport() const;
 
 private:
     MediaPlayer(MediaPlayerClient&);

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (219525 => 219526)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2017-07-14 22:04:20 UTC (rev 219526)
@@ -1609,6 +1609,9 @@
             return MediaPlayerAVAssetStatusCancelled; // Loading of at least one key was cancelled.
     }
 
+    if (!player()->shouldCheckHardwareSupport())
+        m_tracksArePlayable = true;
+
     if (!m_tracksArePlayable) {
         m_tracksArePlayable = true;
         for (AVAssetTrack *track in [m_avAsset tracks]) {

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (219525 => 219526)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h	2017-07-14 22:04:20 UTC (rev 219526)
@@ -120,6 +120,7 @@
 #endif
 
     const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const;
+    bool shouldCheckHardwareSupport() const;
 
     WeakPtr<MediaPlayerPrivateMediaSourceAVFObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (219525 => 219526)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2017-07-14 22:04:20 UTC (rev 219526)
@@ -961,6 +961,11 @@
     return m_player->mediaContentTypesRequiringHardwareSupport();
 }
 
+bool MediaPlayerPrivateMediaSourceAVFObjC::shouldCheckHardwareSupport() const
+{
+    return m_player->shouldCheckHardwareSupport();
+}
+
 void MediaPlayerPrivateMediaSourceAVFObjC::setReadyState(MediaPlayer::ReadyState readyState)
 {
     if (m_readyState == readyState)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (219525 => 219526)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2017-07-14 22:04:20 UTC (rev 219526)
@@ -485,10 +485,12 @@
     if (!m_mediaSource)
         return;
 
-    for (AVAssetTrack *track in [asset tracks]) {
-        if (!assetTrackMeetsHardwareDecodeRequirements(track, m_mediaSource->player()->mediaContentTypesRequiringHardwareSupport())) {
-            m_parsingSucceeded = false;
-            return;
+    if (m_mediaSource->player()->shouldCheckHardwareSupport()) {
+        for (AVAssetTrack *track in [asset tracks]) {
+            if (!assetTrackMeetsHardwareDecodeRequirements(track, m_mediaSource->player()->mediaContentTypesRequiringHardwareSupport())) {
+                m_parsingSucceeded = false;
+                return;
+            }
         }
     }
 

Modified: trunk/Source/WebKit/ChangeLog (219525 => 219526)


--- trunk/Source/WebKit/ChangeLog	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebKit/ChangeLog	2017-07-14 22:04:20 UTC (rev 219526)
@@ -1,3 +1,30 @@
+2017-07-14  Jer Noble  <[email protected]>
+
+        Allow clients to override their own hardware media requirements where no fallback media exists.
+        https://bugs.webkit.org/show_bug.cgi?id=174426
+        <rdar://problem/32537704>
+
+        Reviewed by Eric Carlson.
+
+        Add a new WKWebViewConfiguration property, as well as a new WKPreferences function, both to control
+        WebCore's new allowMediaContentTypesRequiringHardwareSupportAsFallback setting.
+
+        * Shared/WebPreferencesDefinitions.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesGetAllowMediaContentTypesRequiringHardwareSupportAsFallback):
+        (WKPreferencesSetAllowMediaContentTypesRequiringHardwareSupportAsFallback):
+        * UIProcess/API/C/WKPreferencesRef.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _initializeWithConfiguration:]):
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration init]):
+        (-[WKWebViewConfiguration copyWithZone:]):
+        (-[WKWebViewConfiguration _setAllowMediaContentTypesRequiringHardwareSupportAsFallback:]):
+        (-[WKWebViewConfiguration _allowMediaContentTypesRequiringHardwareSupportAsFallback]):
+        * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2017-07-14  Chris Dumez  <[email protected]>
 
         Possible crash under NetworkSocketStream::didFailSocketStream()

Modified: trunk/Source/WebKit/Shared/WebPreferencesDefinitions.h (219525 => 219526)


--- trunk/Source/WebKit/Shared/WebPreferencesDefinitions.h	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebKit/Shared/WebPreferencesDefinitions.h	2017-07-14 22:04:20 UTC (rev 219526)
@@ -95,6 +95,12 @@
 #define DEFAULT_LEGACY_ENCRYPTED_MEDIA_API_ENABLED true
 #endif
 
+#if PLATFORM(COCOA)
+#define DEFAULT_ALLOW_MEDIA_CONTENT_TYPES_REQUIRING_HARDWARE_SUPPORT_AS_FALLBACK true
+#else
+#define DEFAULT_ALLOW_MEDIA_CONTENT_TYPES_REQUIRING_HARDWARE_SUPPORT_AS_FALLBACK false
+#endif
+
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
 #define DEFAULT_SUBPIXEL_ANTIALIASED_LAYER_TEXT_ENABLED true
 #else
@@ -285,6 +291,7 @@
     macro(ResourceTimingEnabled, resourceTimingEnabled, Bool, bool, DEFAULT_RESOURCE_TIMING_ENABLED, "Resource Timing", "Enable ResourceTiming API") \
     macro(UserTimingEnabled, userTimingEnabled, Bool, bool, true, "User Timing", "Enable UserTiming API") \
     macro(LegacyEncryptedMediaAPIEnabled, legacyEncryptedMediaAPIEnabled, Bool, bool, DEFAULT_LEGACY_ENCRYPTED_MEDIA_API_ENABLED, "Enable Legacy EME API", "Enable legacy EME API") \
+    macro(AllowMediaContentTypesRequiringHardwareSupportAsFallback, allowMediaContentTypesRequiringHardwareSupportAsFallback, Bool, bool, DEFAULT_ALLOW_MEDIA_CONTENT_TYPES_REQUIRING_HARDWARE_SUPPORT_AS_FALLBACK, "Allow Media Content Types Requirining Hardware As Fallback", "Allow Media Content Types Requirining Hardware As Fallback") \
     \
 
 #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp (219525 => 219526)


--- trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2017-07-14 22:04:20 UTC (rev 219526)
@@ -1802,3 +1802,14 @@
 {
     return toImpl(preferencesRef)->setLegacyEncryptedMediaAPIEnabled(enabled);
 }
+
+bool WKPreferencesGetAllowMediaContentTypesRequiringHardwareSupportAsFallback(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->allowMediaContentTypesRequiringHardwareSupportAsFallback();
+}
+
+void WKPreferencesSetAllowMediaContentTypesRequiringHardwareSupportAsFallback(WKPreferencesRef preferencesRef, bool allow)
+{
+    return toImpl(preferencesRef)->setAllowMediaContentTypesRequiringHardwareSupportAsFallback(allow);
+}
+

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRef.h (219525 => 219526)


--- trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRef.h	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRef.h	2017-07-14 22:04:20 UTC (rev 219526)
@@ -300,6 +300,10 @@
 WK_EXPORT bool WKPreferencesGetLegacyEncryptedMediaAPIEnabled(WKPreferencesRef preferencesRef);
 WK_EXPORT void WKPreferencesSetLegacyEncryptedMediaAPIEnabled(WKPreferencesRef preferencesRef, bool enabled);
 
+// Defaults to true.
+WK_EXPORT bool WKPreferencesGetAllowMediaContentTypesRequiringHardwareSupportAsFallback(WKPreferencesRef preferencesRef);
+WK_EXPORT void WKPreferencesSetAllowMediaContentTypesRequiringHardwareSupportAsFallback(WKPreferencesRef preferencesRef, bool allow);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (219525 => 219526)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2017-07-14 22:04:20 UTC (rev 219526)
@@ -512,6 +512,7 @@
 
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::needsStorageAccessFromFileURLsQuirkKey(), WebKit::WebPreferencesStore::Value(!![_configuration _needsStorageAccessFromFileURLsQuirk]));
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::mediaContentTypesRequiringHardwareSupportKey(), WebKit::WebPreferencesStore::Value(String([_configuration _mediaContentTypesRequiringHardwareSupport])));
+    pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::allowMediaContentTypesRequiringHardwareSupportAsFallbackKey(), WebKit::WebPreferencesStore::Value(!![_configuration _allowMediaContentTypesRequiringHardwareSupportAsFallback]));
 
 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
     pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::legacyEncryptedMediaAPIEnabledKey(), WebKit::WebPreferencesStore::Value(!![_configuration _legacyEncryptedMediaAPIEnabled]));

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (219525 => 219526)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2017-07-14 22:04:20 UTC (rev 219526)
@@ -151,6 +151,7 @@
 #endif
     BOOL _needsStorageAccessFromFileURLsQuirk;
     BOOL _legacyEncryptedMediaAPIEnabled;
+    BOOL _allowMediaContentTypesRequiringHardwareSupportAsFallback;
 
     RetainPtr<NSString> _overrideContentSecurityPolicy;
     RetainPtr<NSString> _mediaContentTypesRequiringHardwareSupport;
@@ -220,6 +221,7 @@
 #endif
 
     _mediaContentTypesRequiringHardwareSupport = Settings::defaultMediaContentTypesRequiringHardwareSupport();
+    _allowMediaContentTypesRequiringHardwareSupportAsFallback = YES;
 
     return self;
 }
@@ -357,6 +359,7 @@
     configuration->_urlSchemeHandlers.set(adoptNS([self._urlSchemeHandlers mutableCopyWithZone:zone]));
     configuration->_mediaContentTypesRequiringHardwareSupport = adoptNS([self._mediaContentTypesRequiringHardwareSupport copyWithZone:zone]);
     configuration->_legacyEncryptedMediaAPIEnabled = self->_legacyEncryptedMediaAPIEnabled;
+    configuration->_allowMediaContentTypesRequiringHardwareSupportAsFallback = self->_allowMediaContentTypesRequiringHardwareSupportAsFallback;
 
     return configuration;
 }
@@ -873,6 +876,16 @@
     return _legacyEncryptedMediaAPIEnabled;
 }
 
+- (void)_setAllowMediaContentTypesRequiringHardwareSupportAsFallback:(BOOL)allow
+{
+    _allowMediaContentTypesRequiringHardwareSupportAsFallback = allow;
+}
+
+- (BOOL)_allowMediaContentTypesRequiringHardwareSupportAsFallback
+{
+    return _allowMediaContentTypesRequiringHardwareSupportAsFallback;
+}
+
 @end
 
 @implementation WKWebViewConfiguration (WKDeprecated)

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h (219525 => 219526)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h	2017-07-14 22:04:20 UTC (rev 219526)
@@ -87,6 +87,7 @@
 @property (nonatomic, setter=_setOverrideContentSecurityPolicy:) NSString *_overrideContentSecurityPolicy WK_API_AVAILABLE(macosx(10.12.3), ios(10.3));
 @property (nonatomic, setter=_setMediaContentTypesRequiringHardwareSupport:) NSString *_mediaContentTypesRequiringHardwareSupport WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 @property (nonatomic, setter=_setLegacyEncryptedMediaAPIEnabled:) BOOL _legacyEncryptedMediaAPIEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, setter=_setAllowMediaContentTypesRequiringHardwareSupportAsFallback:) BOOL _allowMediaContentTypesRequiringHardwareSupportAsFallback WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 @end
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (219525 => 219526)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2017-07-14 22:04:20 UTC (rev 219526)
@@ -3375,6 +3375,7 @@
     settings.setAnimatedImageAsyncDecodingEnabled(store.getBoolValueForKey(WebPreferencesKey::animatedImageAsyncDecodingEnabledKey()));
     settings.setShouldSuppressKeyboardInputDuringProvisionalNavigation(store.getBoolValueForKey(WebPreferencesKey::shouldSuppressKeyboardInputDuringProvisionalNavigationKey()));
     settings.setMediaContentTypesRequiringHardwareSupport(store.getStringValueForKey(WebPreferencesKey::mediaContentTypesRequiringHardwareSupportKey()));
+    settings.setAllowMediaContentTypesRequiringHardwareSupportAsFallback(store.getBoolValueForKey(WebPreferencesKey::allowMediaContentTypesRequiringHardwareSupportAsFallbackKey()));
 
     settings.setMediaDocumentEntersFullscreenAutomatically(store.getBoolValueForKey(WebPreferencesKey::mediaDocumentEntersFullscreenAutomaticallyKey()));
 

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (219525 => 219526)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2017-07-14 22:04:20 UTC (rev 219526)
@@ -1,3 +1,23 @@
+2017-07-14  Jer Noble  <[email protected]>
+
+        Allow clients to override their own hardware media requirements where no fallback media exists.
+        https://bugs.webkit.org/show_bug.cgi?id=174426
+        <rdar://problem/32537704>
+
+        Reviewed by Eric Carlson.
+
+        Add a new WebPreferences property to control WebCore's new
+        allowMediaContentTypesRequiringHardwareSupportAsFallback setting.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences allowMediaContentTypesRequiringHardwareSupportAsFallback]):
+        (-[WebPreferences setAllowMediaContentTypesRequiringHardwareSupportAsFallback:]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2017-07-12  Said Abou-Hallawa  <[email protected]>
 
         Async image decoding for large images should be disabled by default

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h (219525 => 219526)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h	2017-07-14 22:04:20 UTC (rev 219526)
@@ -244,3 +244,4 @@
 #define WebKitResourceTimingEnabledPreferenceKey @"WebKitResourceTimingEnabled"
 #define WebKitMediaContentTypesRequiringHardwareSupportPreferenceKey @"WebKitMediaContentTypesRequiringHardwareSupport"
 #define WebKitLegacyEncryptedMediaAPIEnabledKey @"WebKitLegacyEncryptedMediaAPIEnabled"
+#define WebKitAllowMediaContentTypesRequiringHardwareSupportAsFallbackKey @"WebKitAllowMediaContentTypesRequiringHardwareSupportAsFallback"

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm (219525 => 219526)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm	2017-07-14 22:04:20 UTC (rev 219526)
@@ -677,6 +677,7 @@
 #endif
         @YES, WebKitViewportFitEnabledPreferenceKey,
         @YES, WebKitConstantPropertiesEnabledPreferenceKey,
+        @YES, WebKitAllowMediaContentTypesRequiringHardwareSupportAsFallbackKey,
         (NSString *)Settings::defaultMediaContentTypesRequiringHardwareSupport(), WebKitMediaContentTypesRequiringHardwareSupportPreferenceKey,
         nil];
 
@@ -3174,6 +3175,16 @@
     [self _setBoolValue:flag forKey:WebKitConstantPropertiesEnabledPreferenceKey];
 }
 
+- (BOOL)allowMediaContentTypesRequiringHardwareSupportAsFallback
+{
+    return [self _boolValueForKey:WebKitAllowMediaContentTypesRequiringHardwareSupportAsFallbackKey];
+}
+
+- (void)setAllowMediaContentTypesRequiringHardwareSupportAsFallback:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitAllowMediaContentTypesRequiringHardwareSupportAsFallbackKey];
+}
+
 @end
 
 @implementation WebPreferences (WebInternal)

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h (219525 => 219526)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h	2017-07-14 22:04:20 UTC (rev 219526)
@@ -580,6 +580,7 @@
 @property (nonatomic) BOOL legacyEncryptedMediaAPIEnabled;
 @property (nonatomic) BOOL viewportFitEnabled;
 @property (nonatomic) BOOL constantPropertiesEnabled;
+@property (nonatomic) BOOL allowMediaContentTypesRequiringHardwareSupportAsFallback;
 
 #if TARGET_OS_IPHONE
 @property (nonatomic) BOOL quickLookDocumentSavingEnabled;

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (219525 => 219526)


--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2017-07-14 21:45:40 UTC (rev 219525)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2017-07-14 22:04:20 UTC (rev 219526)
@@ -3038,6 +3038,8 @@
     RuntimeEnabledFeatures::sharedFeatures().setLegacyEncryptedMediaAPIEnabled(preferences.legacyEncryptedMediaAPIEnabled);
 #endif
 
+    settings.setAllowMediaContentTypesRequiringHardwareSupportAsFallback(preferences.allowMediaContentTypesRequiringHardwareSupportAsFallback);
+
     NSTimeInterval timeout = [preferences incrementalRenderingSuppressionTimeoutInSeconds];
     if (timeout > 0)
         settings.setIncrementalRenderingSuppressionTimeoutInSeconds(timeout);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to