<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[168442] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/168442">168442</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2014-05-07 14:59:51 -0700 (Wed, 07 May 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Mac, iOS] REGRESSION: WK2 YouTube support
https://bugs.webkit.org/show_bug.cgi?id=132568
<rdar://problem/11464344>
Reviewed by Darin Adler.
Source/WebCore:
Move the custom YouTube loader code out of the WebFrameLoaderClient into a
PluginReplacement-based class.
* Modules/plugins/PluginReplacement.h:
(WebCore::PluginReplacement::supportsURL): New predicate so we can restrict
use of a plugin to a particular category of URLs.
* Modules/plugins/QuickTimePluginReplacement.mm:
(WebCore::QuickTimePluginReplacement): Updated for new registrar signature.
* Modules/plugins/YouTubePluginReplacement.h: Added.
(WebCore::YouTubePluginReplacement::parentElement):
* Modules/plugins/YouTubePluginReplacement.cpp: Added.
(WebCore::YouTubePluginReplacement::registerPluginReplacement):
(WebCore::YouTubePluginReplacement::create):
(WebCore::YouTubePluginReplacement::supportsMimeType):
(WebCore::YouTubePluginReplacement::supportsFileExtension):
(WebCore::kit):
(WebCore::YouTubePluginReplacement::YouTubePluginReplacement):
(WebCore::YouTubePluginReplacement::createElementRenderer):
(WebCore::objectForKey):
(WebCore::YouTubePluginReplacement::installReplacement):
(WebCore::createYouTubeURL):
(WebCore::processAndCreateYouTubeURL):
(WebCore::YouTubePluginReplacement::youTubeURL):
* WebCore.exp.in: Add new export from WebCore.
* WebCore.xcodeproj/project.pbxproj:
* html/HTMLPlugInElement.cpp:
(WebCore::pluginReplacementForType): Update to also check that the URL is supported
by the plugin.
(WebCore::registeredPluginReplacements): Add new YouTubePluginReplacement to registry.
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::createElementRenderer): Remove custom YouTube code
now that this logic is handled in the plugin replacement class.
(WebCore::HTMLPlugInImageElement::createShadowIFrameSubtree): Deleted.
* html/HTMLPlugInImageElement.h:
* html/shadow/YouTubeEmbedShadowElement.cpp:
(WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement):
(WebCore::YouTubeEmbedShadowElement::shadowPseudoId): Use correct pseudoID for the
plugin replacement architecture.
* html/shadow/YouTubeEmbedShadowElement.h:
* platform/mac/WebCoreNSURLExtras.h:
* platform/mac/WebCoreNSURLExtras.mm:
(WebCore::unescapedQueryValue): Moved from WebKit/Misc/WebNSURLExtras.
(WebCore::queryKeysAndValues): Ditto.
Source/WebKit/mac:
* Misc/WebNSURLExtras.h:
* Misc/WebNSURLExtras.mm: Remove code that has been converted to C++
and added to YouTubePluginReplacement.cpp.
(-[NSURL _webkit_youTubeURL]):
(-[NSString _webkit_queryKeysAndValues]):
(createYouTubeURL): Deleted.
(-[NSString _webkit_unescapedQueryValue]): Deleted.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulespluginsPluginReplacementh">trunk/Source/WebCore/Modules/plugins/PluginReplacement.h</a></li>
<li><a href="#trunkSourceWebCoreModulespluginsQuickTimePluginReplacementh">trunk/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.h</a></li>
<li><a href="#trunkSourceWebCoreModulespluginsQuickTimePluginReplacementmm">trunk/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLPlugInElementcpp">trunk/Source/WebCore/html/HTMLPlugInElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLPlugInImageElementcpp">trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLPlugInImageElementh">trunk/Source/WebCore/html/HTMLPlugInImageElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlshadowYouTubeEmbedShadowElementcpp">trunk/Source/WebCore/html/shadow/YouTubeEmbedShadowElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlshadowYouTubeEmbedShadowElementh">trunk/Source/WebCore/html/shadow/YouTubeEmbedShadowElement.h</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacMiscWebNSURLExtrash">trunk/Source/WebKit/mac/Misc/WebNSURLExtras.h</a></li>
<li><a href="#trunkSourceWebKitmacMiscWebNSURLExtrasmm">trunk/Source/WebKit/mac/Misc/WebNSURLExtras.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebFrameLoaderClientmm">trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreModulespluginsYouTubePluginReplacementcpp">trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulespluginsYouTubePluginReplacementh">trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (168441 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-05-07 21:57:06 UTC (rev 168441)
+++ trunk/Source/WebCore/ChangeLog        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -1,3 +1,55 @@
</span><ins>+2014-05-07 Brent Fulgham <bfulgham@apple.com>
+
+ [Mac, iOS] REGRESSION: WK2 YouTube support
+ https://bugs.webkit.org/show_bug.cgi?id=132568
+ <rdar://problem/11464344>
+
+ Reviewed by Darin Adler.
+
+ Move the custom YouTube loader code out of the WebFrameLoaderClient into a
+ PluginReplacement-based class.
+
+ * Modules/plugins/PluginReplacement.h:
+ (WebCore::PluginReplacement::supportsURL): New predicate so we can restrict
+ use of a plugin to a particular category of URLs.
+ * Modules/plugins/QuickTimePluginReplacement.mm:
+ (WebCore::QuickTimePluginReplacement): Updated for new registrar signature.
+ * Modules/plugins/YouTubePluginReplacement.h: Added.
+ (WebCore::YouTubePluginReplacement::parentElement):
+ * Modules/plugins/YouTubePluginReplacement.cpp: Added.
+ (WebCore::YouTubePluginReplacement::registerPluginReplacement):
+ (WebCore::YouTubePluginReplacement::create):
+ (WebCore::YouTubePluginReplacement::supportsMimeType):
+ (WebCore::YouTubePluginReplacement::supportsFileExtension):
+ (WebCore::kit):
+ (WebCore::YouTubePluginReplacement::YouTubePluginReplacement):
+ (WebCore::YouTubePluginReplacement::createElementRenderer):
+ (WebCore::objectForKey):
+ (WebCore::YouTubePluginReplacement::installReplacement):
+ (WebCore::createYouTubeURL):
+ (WebCore::processAndCreateYouTubeURL):
+ (WebCore::YouTubePluginReplacement::youTubeURL):
+ * WebCore.exp.in: Add new export from WebCore.
+ * WebCore.xcodeproj/project.pbxproj:
+ * html/HTMLPlugInElement.cpp:
+ (WebCore::pluginReplacementForType): Update to also check that the URL is supported
+ by the plugin.
+ (WebCore::registeredPluginReplacements): Add new YouTubePluginReplacement to registry.
+ * html/HTMLPlugInImageElement.cpp:
+ (WebCore::HTMLPlugInImageElement::createElementRenderer): Remove custom YouTube code
+ now that this logic is handled in the plugin replacement class.
+ (WebCore::HTMLPlugInImageElement::createShadowIFrameSubtree): Deleted.
+ * html/HTMLPlugInImageElement.h:
+ * html/shadow/YouTubeEmbedShadowElement.cpp:
+ (WebCore::YouTubeEmbedShadowElement::YouTubeEmbedShadowElement):
+ (WebCore::YouTubeEmbedShadowElement::shadowPseudoId): Use correct pseudoID for the
+ plugin replacement architecture.
+ * html/shadow/YouTubeEmbedShadowElement.h:
+ * platform/mac/WebCoreNSURLExtras.h:
+ * platform/mac/WebCoreNSURLExtras.mm:
+ (WebCore::unescapedQueryValue): Moved from WebKit/Misc/WebNSURLExtras.
+ (WebCore::queryKeysAndValues): Ditto.
+
</ins><span class="cx"> 2014-05-07 Simon Fraser <simon.fraser@apple.com>
</span><span class="cx">
</span><span class="cx"> [iOS] Acclerated overflow-scrolling broken in WK1
</span></span></pre></div>
<a id="trunkSourceWebCoreModulespluginsPluginReplacementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/plugins/PluginReplacement.h (168441 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/plugins/PluginReplacement.h        2014-05-07 21:57:06 UTC (rev 168441)
+++ trunk/Source/WebCore/Modules/plugins/PluginReplacement.h        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> class RenderElement;
</span><span class="cx"> class RenderStyle;
</span><span class="cx"> class ShadowRoot;
</span><ins>+class URL;
</ins><span class="cx">
</span><span class="cx"> class PluginReplacement : public RefCounted<PluginReplacement> {
</span><span class="cx"> public:
</span><span class="lines">@@ -58,13 +59,15 @@
</span><span class="cx"> typedef PassRefPtr<PluginReplacement> (*CreatePluginReplacement)(HTMLPlugInElement&, const Vector<String>& paramNames, const Vector<String>& paramValues);
</span><span class="cx"> typedef bool (*PluginReplacementSupportsType)(const String&);
</span><span class="cx"> typedef bool (*PluginReplacementSupportsFileExtension)(const String&);
</span><del>-
</del><ins>+typedef bool (*PluginReplacementSupportsURL)(const URL&);
+
</ins><span class="cx"> class ReplacementPlugin {
</span><span class="cx"> public:
</span><del>- ReplacementPlugin(CreatePluginReplacement constructor, PluginReplacementSupportsType supportsType, PluginReplacementSupportsFileExtension supportsFileExtension)
</del><ins>+ ReplacementPlugin(CreatePluginReplacement constructor, PluginReplacementSupportsType supportsType, PluginReplacementSupportsFileExtension supportsFileExtension, PluginReplacementSupportsURL supportsURL)
</ins><span class="cx"> : m_constructor(constructor)
</span><span class="cx"> , m_supportsType(supportsType)
</span><span class="cx"> , m_supportsFileExtension(supportsFileExtension)
</span><ins>+ , m_supportsURL(supportsURL)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -72,17 +75,20 @@
</span><span class="cx"> : m_constructor(other.m_constructor)
</span><span class="cx"> , m_supportsType(other.m_supportsType)
</span><span class="cx"> , m_supportsFileExtension(other.m_supportsFileExtension)
</span><ins>+ , m_supportsURL(other.m_supportsURL)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PassRefPtr<PluginReplacement> create(HTMLPlugInElement& element, const Vector<String>& paramNames, const Vector<String>& paramValues) const { return m_constructor(element, paramNames, paramValues); }
</span><span class="cx"> bool supportsType(const String& mimeType) const { return m_supportsType(mimeType); }
</span><span class="cx"> bool supportsFileExtension(const String& extension) const { return m_supportsFileExtension(extension); }
</span><del>-
</del><ins>+ bool supportsURL(const URL& url) const { return m_supportsURL(url); }
+
</ins><span class="cx"> private:
</span><span class="cx"> CreatePluginReplacement m_constructor;
</span><span class="cx"> PluginReplacementSupportsType m_supportsType;
</span><span class="cx"> PluginReplacementSupportsFileExtension m_supportsFileExtension;
</span><ins>+ PluginReplacementSupportsURL m_supportsURL;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> typedef void (*PluginReplacementRegistrar)(const ReplacementPlugin&);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulespluginsQuickTimePluginReplacementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.h (168441 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.h        2014-05-07 21:57:06 UTC (rev 168441)
+++ trunk/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.h        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> static void registerPluginReplacement(PluginReplacementRegistrar);
</span><span class="cx"> static bool supportsMimeType(const String&);
</span><span class="cx"> static bool supportsFileExtension(const String&);
</span><ins>+ static bool supportsURL(const URL&) { return true; }
</ins><span class="cx">
</span><span class="cx"> static PassRefPtr<PluginReplacement> create(HTMLPlugInElement&, const Vector<String>& paramNames, const Vector<String>& paramValues);
</span><span class="cx"> ~QuickTimePluginReplacement();
</span></span></pre></div>
<a id="trunkSourceWebCoreModulespluginsQuickTimePluginReplacementmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm (168441 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm        2014-05-07 21:57:06 UTC (rev 168441)
+++ trunk/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -75,7 +75,7 @@
</span><span class="cx">
</span><span class="cx"> void QuickTimePluginReplacement::registerPluginReplacement(PluginReplacementRegistrar registrar)
</span><span class="cx"> {
</span><del>- registrar(ReplacementPlugin(create, supportsMimeType, supportsFileExtension));
</del><ins>+ registrar(ReplacementPlugin(create, supportsMimeType, supportsFileExtension, supportsURL));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PassRefPtr<PluginReplacement> QuickTimePluginReplacement::create(HTMLPlugInElement& plugin, const Vector<String>& paramNames, const Vector<String>& paramValues)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulespluginsYouTubePluginReplacementcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp (0 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp         (rev 0)
+++ trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -0,0 +1,343 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "YouTubePluginReplacement.h"
+
+#include "HTMLIFrameElement.h"
+#include "HTMLNames.h"
+#include "HTMLPlugInElement.h"
+#include "Page.h"
+#include "RenderElement.h"
+#include "ShadowRoot.h"
+#include "YouTubeEmbedShadowElement.h"
+#include <wtf/text/StringBuilder.h>
+
+namespace WebCore {
+
+void YouTubePluginReplacement::registerPluginReplacement(PluginReplacementRegistrar registrar)
+{
+ registrar(ReplacementPlugin(create, supportsMimeType, supportsFileExtension, supportsURL));
+}
+
+PassRefPtr<PluginReplacement> YouTubePluginReplacement::create(HTMLPlugInElement& plugin, const Vector<String>& paramNames, const Vector<String>& paramValues)
+{
+ return adoptRef(new YouTubePluginReplacement(plugin, paramNames, paramValues));
+}
+
+bool YouTubePluginReplacement::supportsMimeType(const String& mimeType)
+{
+ return equalIgnoringCase(mimeType, "application/x-shockwave-flash")
+ || equalIgnoringCase(mimeType, "application/futuresplash");
+}
+
+bool YouTubePluginReplacement::supportsFileExtension(const String& extension)
+{
+ return equalIgnoringCase(extension, "spl") || equalIgnoringCase(extension, "swf");
+}
+
+YouTubePluginReplacement::YouTubePluginReplacement(HTMLPlugInElement& plugin, const Vector<String>& paramNames, const Vector<String>& paramValues)
+ : m_parentElement(&plugin)
+{
+ ASSERT(paramNames.size() == paramValues.size());
+ for (size_t i = 0; i < paramNames.size(); ++i)
+ m_attributes.add(paramNames[i], paramValues[i]);
+}
+
+RenderPtr<RenderElement> YouTubePluginReplacement::createElementRenderer(HTMLPlugInElement& plugin, PassRef<RenderStyle> style)
+{
+ ASSERT_UNUSED(plugin, m_parentElement == &plugin);
+
+ if (!m_embedShadowElement)
+ return nullptr;
+
+ return m_embedShadowElement->createElementRenderer(std::move(style));
+}
+
+bool YouTubePluginReplacement::installReplacement(ShadowRoot* root)
+{
+ m_embedShadowElement = YouTubeEmbedShadowElement::create(m_parentElement->document());
+
+ root->appendChild(m_embedShadowElement.get());
+
+ RefPtr<HTMLIFrameElement> iframeElement = HTMLIFrameElement::create(HTMLNames::iframeTag, m_parentElement->document());
+ if (m_attributes.contains("width"))
+ iframeElement->setAttribute(HTMLNames::widthAttr, AtomicString("100%", AtomicString::ConstructFromLiteral));
+
+ const auto& heightValue = m_attributes.find("height");
+ if (heightValue != m_attributes.end()) {
+ iframeElement->setAttribute(HTMLNames::styleAttr, AtomicString("max-height: 100%", AtomicString::ConstructFromLiteral));
+ iframeElement->setAttribute(HTMLNames::heightAttr, heightValue->value);
+ }
+
+ iframeElement->setAttribute(HTMLNames::srcAttr, youTubeURL(m_attributes.get("src")));
+ iframeElement->setAttribute(HTMLNames::frameborderAttr, AtomicString("0", AtomicString::ConstructFromLiteral));
+
+ // Disable frame flattening for this iframe.
+ iframeElement->setAttribute(HTMLNames::scrollingAttr, AtomicString("no", AtomicString::ConstructFromLiteral));
+ m_embedShadowElement->appendChild(iframeElement);
+
+ return true;
+}
+
+static inline URL createYouTubeURL(const String& videoID, const String& timeID)
+{
+ ASSERT(!videoID.isEmpty());
+ ASSERT(videoID != "/");
+
+ URL result(URL(), "youtube:" + videoID);
+ if (!timeID.isEmpty())
+ result.setQuery("t=" + timeID);
+
+ return result;
+}
+
+static YouTubePluginReplacement::KeyValueMap queryKeysAndValues(const String& queryString)
+{
+ YouTubePluginReplacement::KeyValueMap queryDictionary;
+
+ size_t queryLength = queryString.length();
+ if (!queryLength)
+ return queryDictionary;
+
+ size_t equalSearchLocation = 0;
+ size_t equalSearchLength = queryLength;
+
+ while (equalSearchLocation < queryLength - 1 && equalSearchLength) {
+
+ // Search for "=".
+ size_t equalLocation = queryString.find("=", equalSearchLocation);
+ if (equalLocation == notFound)
+ break;
+
+ size_t indexAfterEqual = equalLocation + 1;
+ if (indexAfterEqual > queryLength - 1)
+ break;
+
+ // Get the key before the "=".
+ size_t keyLocation = equalSearchLocation;
+ size_t keyLength = equalLocation - equalSearchLocation;
+
+ // Seach for the ampersand.
+ size_t ampersandLocation = queryString.find("&", indexAfterEqual);
+
+ // Get the value after the "=", before the ampersand.
+ size_t valueLocation = indexAfterEqual;
+ size_t valueLength;
+ if (ampersandLocation != notFound)
+ valueLength = ampersandLocation - indexAfterEqual;
+ else
+ valueLength = queryLength - indexAfterEqual;
+
+ // Save the key and the value.
+ if (keyLength && valueLength) {
+ const String& key = queryString.substring(keyLocation, keyLength).lower();
+ String value = queryString.substring(valueLocation, valueLength);
+ value.replace('+', ' ');
+
+ if (!key.isEmpty() && !value.isEmpty())
+ queryDictionary.add(key, value);
+ }
+
+ if (ampersandLocation == notFound)
+ break;
+
+ // Continue searching after the ampersand.
+ size_t indexAfterAmpersand = ampersandLocation + 1;
+ equalSearchLocation = indexAfterAmpersand;
+ equalSearchLength = queryLength - indexAfterAmpersand;
+ }
+
+ return queryDictionary;
+}
+
+static bool hasCaseInsensitivePrefix(const String& input, const String& prefix)
+{
+ return input.startsWith(prefix, false);
+}
+
+static bool isYouTubeURL(const URL& url)
+{
+ const String& hostName = url.host().lower();
+
+ return hostName == "m.youtube.com"
+ || hostName == "youtu.be"
+ || hostName == "www.youtube.com"
+ || hostName == "youtube.com";
+}
+
+static const String& valueForKey(const YouTubePluginReplacement::KeyValueMap& dictionary, const String& key)
+{
+ const auto& value = dictionary.find(key);
+ if (value == dictionary.end())
+ return emptyString();
+
+ return value->value;
+}
+
+static URL processAndCreateYouTubeURL(const URL& url, bool& isYouTubeShortenedURL)
+{
+ if (!url.protocolIs("http") && !url.protocolIs("https"))
+ return URL();
+
+ // Bail out early if we aren't even on www.youtube.com or youtube.com.
+ if (!isYouTubeURL(url))
+ return URL();
+
+ const String& hostName = url.host().lower();
+
+ bool isYouTubeMobileWebAppURL = hostName == "m.youtube.com";
+ isYouTubeShortenedURL = hostName == "youtu.be";
+
+ // Short URL of the form: http://youtu.be/v1d301D
+ if (isYouTubeShortenedURL) {
+ const String& videoID = url.lastPathComponent();
+ if (videoID.isEmpty() || videoID == "/")
+ return URL();
+
+ return createYouTubeURL(videoID, emptyString());
+ }
+
+ String path = url.path();
+ String query = url.query();
+ String fragment = url.fragmentIdentifier();
+
+ // On the YouTube mobile web app, the path and query string are put into the
+ // fragment so that one web page is only ever loaded (see <rdar://problem/9550639>).
+ if (isYouTubeMobileWebAppURL) {
+ size_t location = fragment.find('?');
+ if (location == notFound) {
+ path = fragment;
+ query = emptyString();
+ } else {
+ path = fragment.substring(0, location);
+ query = fragment.substring(location + 1);
+ }
+ fragment = emptyString();
+ }
+
+ if (path.lower() == "/watch") {
+ if (!query.isEmpty()) {
+ const auto& queryDictionary = queryKeysAndValues(query);
+ String videoID = valueForKey(queryDictionary, "v");
+
+ if (!videoID.isEmpty()) {
+ const auto& fragmentDictionary = queryKeysAndValues(url.fragmentIdentifier());
+ String timeID = valueForKey(fragmentDictionary, "t");
+ return createYouTubeURL(videoID, timeID);
+ }
+ }
+
+ // May be a new-style link (see <rdar://problem/7733692>).
+ if (fragment.startsWith('!')) {
+ query = fragment.substring(1);
+
+ if (!query.isEmpty()) {
+ const auto& queryDictionary = queryKeysAndValues(query);
+ String videoID = valueForKey(queryDictionary, "v");
+
+ if (!videoID.isEmpty()) {
+ String timeID = valueForKey(queryDictionary, "t");
+ return createYouTubeURL(videoID, timeID);
+ }
+ }
+ }
+ } else if (hasCaseInsensitivePrefix(path, "/v/") || hasCaseInsensitivePrefix(path, "/e/")) {
+ String videoID = url.lastPathComponent();
+
+ // These URLs are funny - they don't have a ? for the first query parameter.
+ // Strip all characters after and including '&' to remove extraneous parameters after the video ID.
+ size_t ampersand = videoID.find('&');
+ if (ampersand != notFound)
+ videoID = videoID.substring(0, ampersand);
+
+ if (!videoID.isEmpty())
+ return createYouTubeURL(videoID, emptyString());
+ }
+
+ return URL();
+}
+
+String YouTubePluginReplacement::youTubeURL(const String& srcString)
+{
+ URL srcURL(URL(), srcString);
+
+ bool isYouTubeShortenedURL = false;
+ URL youTubeURL = processAndCreateYouTubeURL(srcURL, isYouTubeShortenedURL);
+ if (srcURL.isEmpty() || youTubeURL.isEmpty())
+ return srcString;
+
+ // Transform the youtubeURL (youtube:VideoID) to iframe embed url which has the format: http://www.youtube.com/embed/VideoID
+ const String& srcPath = srcURL.path();
+ const String& videoID = youTubeURL.string().substring(youTubeURL.protocol().length() + 1);
+ size_t locationOfVideoIDInPath = srcPath.find(videoID);
+
+ size_t locationOfPathBeforeVideoID = notFound;
+ if (locationOfVideoIDInPath != notFound) {
+ ASSERT(locationOfVideoIDInPath);
+
+ // From the original URL, we need to get the part before /path/VideoId.
+ locationOfPathBeforeVideoID = srcString.find(srcPath.substring(0, locationOfVideoIDInPath));
+ } else if (srcPath.lower() == "/watch") {
+ // From the original URL, we need to get the part before /watch/#!v=VideoID
+ locationOfPathBeforeVideoID = srcString.find("/watch");
+ } else
+ return srcString;
+
+ ASSERT(locationOfPathBeforeVideoID != notFound);
+
+ const String& srcURLPrefix = srcString.substring(0, locationOfPathBeforeVideoID);
+ String query = srcURL.query();
+
+ // By default, the iframe will display information like the video title and uploader on top of the video. Don't display
+ // them if the embeding html doesn't specify it.
+ if (!query.isEmpty() && !query.contains("showinfo"))
+ query.append("&showinfo=0");
+ else
+ query = "showinfo=0";
+
+ // Append the query string if it is valid. Some sites apparently forget to add "?" for the query string, in that case,
+ // we will discard the parameters in the url.
+ // See: <rdar://problem/11535155>
+ StringBuilder finalURL;
+ if (isYouTubeShortenedURL)
+ finalURL.append("http://www.youtube.com");
+ else
+ finalURL.append(srcURLPrefix);
+ finalURL.appendLiteral("/embed/");
+ finalURL.append(videoID);
+ if (!query.isEmpty()) {
+ finalURL.appendLiteral("?");
+ finalURL.append(query);
+ }
+ return finalURL.toString();
+}
+
+bool YouTubePluginReplacement::supportsURL(const URL& url)
+{
+ return isYouTubeURL(url);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulespluginsYouTubePluginReplacementh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.h (0 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.h         (rev 0)
+++ trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.h        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -0,0 +1,72 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef YouTubePluginReplacement_h
+#define YouTubePluginReplacement_h
+
+#include "PluginReplacement.h"
+
+#include <wtf/HashMap.h>
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+class HTMLPlugInElement;
+class HTMLIFrameElement;
+class RenderElement;
+class RenderStyle;
+class ShadowRoot;
+class YouTubeEmbedShadowElement;
+
+class YouTubePluginReplacement : public PluginReplacement {
+public:
+ static void registerPluginReplacement(PluginReplacementRegistrar);
+
+ typedef HashMap<String, String> KeyValueMap;
+
+private:
+ YouTubePluginReplacement(HTMLPlugInElement&, const Vector<String>& paramNames, const Vector<String>& paramValues);
+
+ static bool supportsMimeType(const String&);
+ static bool supportsFileExtension(const String&);
+ static bool supportsURL(const URL&);
+
+ static PassRefPtr<PluginReplacement> create(HTMLPlugInElement&, const Vector<String>& paramNames, const Vector<String>& paramValues);
+
+ virtual bool installReplacement(ShadowRoot*) override;
+
+ String youTubeURL(const String& rawURL);
+
+ virtual bool willCreateRenderer() override { return m_embedShadowElement; }
+ virtual RenderPtr<RenderElement> createElementRenderer(HTMLPlugInElement&, PassRef<RenderStyle>) override;
+
+ HTMLPlugInElement* m_parentElement;
+ RefPtr<YouTubeEmbedShadowElement> m_embedShadowElement;
+ KeyValueMap m_attributes;
+};
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (168441 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-05-07 21:57:06 UTC (rev 168441)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -2569,7 +2569,6 @@
</span><span class="cx"> __ZN7WebCore21nextParagraphPositionERKNS_15VisiblePositionEi
</span><span class="cx"> __ZN7WebCore21setStrokeAndFillColorEP9CGContextP7CGColor
</span><span class="cx"> __ZN7WebCore21wordRangeFromPositionERKNS_15VisiblePositionE
</span><del>-__ZN7WebCore22HTMLPlugInImageElement25createShadowIFrameSubtreeERKN3WTF6StringE
</del><span class="cx"> __ZN7WebCore22startOfEditableContentERKNS_15VisiblePositionE
</span><span class="cx"> __ZN7WebCore23applicationIsMobileMailEv
</span><span class="cx"> __ZN7WebCore23atBoundaryOfGranularityERKNS_15VisiblePositionENS_15TextGranularityENS_18SelectionDirectionE
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (168441 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-05-07 21:57:06 UTC (rev 168441)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -2306,6 +2306,8 @@
</span><span class="cx">                 7A54858014E02D51006AE05A /* InspectorHistory.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A54857E14E02D51006AE05A /* InspectorHistory.h */; };
</span><span class="cx">                 7A54881714E432A1006AE05A /* DOMPatchSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A54881514E432A1006AE05A /* DOMPatchSupport.h */; };
</span><span class="cx">                 7A54881814E432A1006AE05A /* DOMPatchSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A54881614E432A1006AE05A /* DOMPatchSupport.cpp */; };
</span><ins>+                7A5515F5191830A3009687D2 /* YouTubePluginReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A5515F3191830A3009687D2 /* YouTubePluginReplacement.h */; };
+                7A5515F6191830A3009687D2 /* YouTubePluginReplacement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A5515F4191830A3009687D2 /* YouTubePluginReplacement.cpp */; };
</ins><span class="cx">                 7A674BDB0F9EBF4E006CF099 /* PageGroupLoadDeferrer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A674BD90F9EBF4E006CF099 /* PageGroupLoadDeferrer.cpp */; };
</span><span class="cx">                 7A674BDC0F9EBF4E006CF099 /* PageGroupLoadDeferrer.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A674BDA0F9EBF4E006CF099 /* PageGroupLoadDeferrer.h */; };
</span><span class="cx">                 7A74ECBA101839A600BF939E /* InspectorDOMStorageAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A74ECB8101839A500BF939E /* InspectorDOMStorageAgent.cpp */; };
</span><span class="lines">@@ -9355,6 +9357,8 @@
</span><span class="cx">                 7A54857E14E02D51006AE05A /* InspectorHistory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorHistory.h; sourceTree = "<group>"; };
</span><span class="cx">                 7A54881514E432A1006AE05A /* DOMPatchSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMPatchSupport.h; sourceTree = "<group>"; };
</span><span class="cx">                 7A54881614E432A1006AE05A /* DOMPatchSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMPatchSupport.cpp; sourceTree = "<group>"; };
</span><ins>+                7A5515F3191830A3009687D2 /* YouTubePluginReplacement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YouTubePluginReplacement.h; path = plugins/YouTubePluginReplacement.h; sourceTree = "<group>"; };
+                7A5515F4191830A3009687D2 /* YouTubePluginReplacement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YouTubePluginReplacement.cpp; path = plugins/YouTubePluginReplacement.cpp; sourceTree = "<group>"; };
</ins><span class="cx">                 7A674BD90F9EBF4E006CF099 /* PageGroupLoadDeferrer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageGroupLoadDeferrer.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7A674BDA0F9EBF4E006CF099 /* PageGroupLoadDeferrer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageGroupLoadDeferrer.h; sourceTree = "<group>"; };
</span><span class="cx">                 7A7256B915EB9F5B007323A7 /* InspectorOverlayPage.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = InspectorOverlayPage.html; sourceTree = "<group>"; };
</span><span class="lines">@@ -14317,6 +14321,8 @@
</span><span class="cx">                 072AE1DE183C0513000A5988 /* plugins */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                7A5515F3191830A3009687D2 /* YouTubePluginReplacement.h */,
+                                7A5515F4191830A3009687D2 /* YouTubePluginReplacement.cpp */,
</ins><span class="cx">                                 072AE1DF183C0741000A5988 /* PluginReplacement.h */,
</span><span class="cx">                                 072AE1E0183C0741000A5988 /* QuickTimePluginReplacement.mm */,
</span><span class="cx">                                 072AE1E1183C0741000A5988 /* QuickTimePluginReplacement.css */,
</span><span class="lines">@@ -23157,6 +23163,7 @@
</span><span class="cx">                                 079D0868162F20E800DB8658 /* CaptionUserPreferences.h in Headers */,
</span><span class="cx">                                 079D086B162F21F900DB8658 /* CaptionUserPreferencesMediaAF.h in Headers */,
</span><span class="cx">                                 99CC0B4F18BE9849006CEBCC /* CapturingInputCursor.h in Headers */,
</span><ins>+                                7A5515F5191830A3009687D2 /* YouTubePluginReplacement.h in Headers */,
</ins><span class="cx">                                 6550B69E099DF0270090D781 /* CDATASection.h in Headers */,
</span><span class="cx">                                 CDDD571518B57A8200A94FCB /* CDMSession.h in Headers */,
</span><span class="cx">                                 5FA904CA178E61F5004C8A2D /* CertificateInfo.h in Headers */,
</span><span class="lines">@@ -26858,6 +26865,7 @@
</span><span class="cx">                                 B27535660B053814002CE64F /* Color.cpp in Sources */,
</span><span class="cx">                                 0FCF33240F2B9715004B6795 /* ColorCG.cpp in Sources */,
</span><span class="cx">                                 1ABA76C911D20E47004C201C /* ColorData.cpp in Sources */,
</span><ins>+                                7A5515F6191830A3009687D2 /* YouTubePluginReplacement.cpp in Sources */,
</ins><span class="cx">                                 B22279620D00BF220071B782 /* ColorDistance.cpp in Sources */,
</span><span class="cx">                                 BC29935D17A1DD5800BCE880 /* ColorInputType.cpp in Sources */,
</span><span class="cx">                                 B27535770B053814002CE64F /* ColorMac.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLPlugInElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLPlugInElement.cpp (168441 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLPlugInElement.cpp        2014-05-07 21:57:06 UTC (rev 168441)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.cpp        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
</span><span class="cx"> * (C) 1999 Antti Koivisto (koivisto@kde.org)
</span><span class="cx"> * (C) 2000 Stefan Schimanski (1Stein@gmx.de)
</span><del>- * Copyright (C) 2004, 2005, 2006 Apple Inc.
</del><ins>+ * Copyright (C) 2004, 2005, 2006, 2014 Apple Inc.
</ins><span class="cx"> *
</span><span class="cx"> * This library is free software; you can redistribute it and/or
</span><span class="cx"> * modify it under the terms of the GNU Library General Public
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> #include "QuickTimePluginReplacement.h"
</span><ins>+#include "YouTubePluginReplacement.h"
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -328,6 +329,7 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> QuickTimePluginReplacement::registerPluginReplacement(registrar);
</span><ins>+ YouTubePluginReplacement::registerPluginReplacement(registrar);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> return registeredReplacements;
</span><span class="lines">@@ -357,9 +359,10 @@
</span><span class="cx"> type = mimeTypeFromDataURL(url.string());
</span><span class="cx">
</span><span class="cx"> if (type.isEmpty() && !extension.isEmpty()) {
</span><del>- for (size_t i = 0; i < replacements.size(); i++)
- if (replacements[i]->supportsFileExtension(extension))
- return replacements[i];
</del><ins>+ for (auto* replacement : replacements) {
+ if (replacement->supportsFileExtension(extension) && replacement->supportsURL(url))
+ return replacement;
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (type.isEmpty()) {
</span><span class="lines">@@ -371,9 +374,10 @@
</span><span class="cx"> if (type.isEmpty())
</span><span class="cx"> return nullptr;
</span><span class="cx">
</span><del>- for (unsigned i = 0; i < replacements.size(); i++)
- if (replacements[i]->supportsType(type))
- return replacements[i];
</del><ins>+ for (auto* replacement : replacements) {
+ if (replacement->supportsType(type) && replacement->supportsURL(url))
+ return replacement;
+ }
</ins><span class="cx">
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLPlugInImageElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp (168441 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp        2014-05-07 21:57:06 UTC (rev 168441)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -55,12 +55,6 @@
</span><span class="cx"> #include <wtf/HashMap.h>
</span><span class="cx"> #include <wtf/text/StringHash.h>
</span><span class="cx">
</span><del>-#if PLATFORM(IOS)
-#include "HTMLIFrameElement.h"
-#include "RenderBlockFlow.h"
-#include "YouTubeEmbedShadowElement.h"
-#endif
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> using namespace HTMLNames;
</span><span class="lines">@@ -226,14 +220,6 @@
</span><span class="cx"> if (isImageType())
</span><span class="cx"> return createRenderer<RenderImage>(*this, std::move(style));
</span><span class="cx">
</span><del>-#if PLATFORM(IOS)
- if (ShadowRoot* shadowRoot = this->shadowRoot()) {
- Node* shadowNode = shadowRoot->firstChild();
- if (shadowNode && shadowNode->isElementNode() && toElement(*shadowNode).shadowPseudoId() == "-apple-youtube-shadow-iframe")
- return createRenderer<RenderBlockFlow>(*this, std::move(style));
- }
-#endif
-
</del><span class="cx"> return HTMLPlugInElement::createElementRenderer(std::move(style));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -411,35 +397,6 @@
</span><span class="cx"> return node && snapshotLabel && (node == snapshotLabel.get() || node->isDescendantOf(snapshotLabel.get()));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if PLATFORM(IOS)
-void HTMLPlugInImageElement::createShadowIFrameSubtree(const String& src)
-{
- if (this->shadowRoot())
- return;
-
- if (src.isEmpty())
- return;
-
- RefPtr<YouTubeEmbedShadowElement> shadowElement = YouTubeEmbedShadowElement::create(document());
- ShadowRoot& root = this->ensureUserAgentShadowRoot();
- root.appendChild(shadowElement, ASSERT_NO_EXCEPTION);
-
- RefPtr<HTMLIFrameElement> iframeElement = HTMLIFrameElement::create(iframeTag, document());
- if (hasAttribute(widthAttr))
- iframeElement->setAttribute(widthAttr, AtomicString("100%", AtomicString::ConstructFromLiteral));
- if (hasAttribute(heightAttr)) {
- iframeElement->setAttribute(styleAttr, AtomicString("max-height: 100%", AtomicString::ConstructFromLiteral));
- iframeElement->setAttribute(heightAttr, getAttribute(heightAttr));
- }
- iframeElement->setAttribute(srcAttr, src);
- iframeElement->setAttribute(frameborderAttr, AtomicString("0", AtomicString::ConstructFromLiteral));
-
- // Disable frame flattening for this iframe.
- iframeElement->setAttribute(scrollingAttr, AtomicString("no", AtomicString::ConstructFromLiteral));
- shadowElement->appendChild(iframeElement, ASSERT_NO_EXCEPTION);
-}
-#endif
-
</del><span class="cx"> void HTMLPlugInImageElement::removeSnapshotTimerFired(Timer<HTMLPlugInImageElement>&)
</span><span class="cx"> {
</span><span class="cx"> m_snapshotImage = nullptr;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLPlugInImageElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLPlugInImageElement.h (168441 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLPlugInImageElement.h        2014-05-07 21:57:06 UTC (rev 168441)
+++ trunk/Source/WebCore/html/HTMLPlugInImageElement.h        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -67,10 +67,6 @@
</span><span class="cx"> bool needsWidgetUpdate() const { return m_needsWidgetUpdate; }
</span><span class="cx"> void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; }
</span><span class="cx">
</span><del>-#if PLATFORM(IOS)
- void createShadowIFrameSubtree(const String& src);
-#endif
-
</del><span class="cx"> void userDidClickSnapshot(PassRefPtr<MouseEvent>, bool forwardEvent);
</span><span class="cx"> void checkSnapshotStatus();
</span><span class="cx"> Image* snapshotImage() const { return m_snapshotImage.get(); }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlshadowYouTubeEmbedShadowElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/shadow/YouTubeEmbedShadowElement.cpp (168441 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/shadow/YouTubeEmbedShadowElement.cpp        2014-05-07 21:57:06 UTC (rev 168441)
+++ trunk/Source/WebCore/html/shadow/YouTubeEmbedShadowElement.cpp        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -26,8 +26,6 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "YouTubeEmbedShadowElement.h"
</span><span class="cx">
</span><del>-#if PLATFORM(IOS)
-
</del><span class="cx"> #include "HTMLEmbedElement.h"
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -42,6 +40,12 @@
</span><span class="cx"> YouTubeEmbedShadowElement::YouTubeEmbedShadowElement(Document& document)
</span><span class="cx"> : HTMLDivElement(HTMLNames::divTag, document)
</span><span class="cx"> {
</span><ins>+ setPseudo(shadowPseudoId());
+
+ setInlineStyleProperty(CSSPropertyDisplay, CSSValueInlineBlock);
+ setInlineStyleProperty(CSSPropertyPosition, CSSValueRelative);
+ setInlineStyleProperty(CSSPropertyWidth, CSSValue100);
+ setInlineStyleProperty(CSSPropertyHeight, CSSValue100);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> HTMLPlugInImageElement* YouTubeEmbedShadowElement::pluginElement() const
</span><span class="lines">@@ -53,10 +57,8 @@
</span><span class="cx">
</span><span class="cx"> const AtomicString& YouTubeEmbedShadowElement::shadowPseudoId() const
</span><span class="cx"> {
</span><del>- DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, pseudoId, ("-apple-youtube-shadow-iframe"));
</del><ins>+ DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, pseudoId, ("-webkit-plugin-replacement"));
</ins><span class="cx"> return pseudoId;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> }
</span><del>-
-#endif
</del></span></pre></div>
<a id="trunkSourceWebCorehtmlshadowYouTubeEmbedShadowElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/shadow/YouTubeEmbedShadowElement.h (168441 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/shadow/YouTubeEmbedShadowElement.h        2014-05-07 21:57:06 UTC (rev 168441)
+++ trunk/Source/WebCore/html/shadow/YouTubeEmbedShadowElement.h        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -26,8 +26,6 @@
</span><span class="cx"> #ifndef YouTubeEmbedShadowElement_h
</span><span class="cx"> #define YouTubeEmbedShadowElement_h
</span><span class="cx">
</span><del>-#if PLATFORM(IOS)
-
</del><span class="cx"> #include "HTMLDivElement.h"
</span><span class="cx"> #include <wtf/Forward.h>
</span><span class="cx">
</span><span class="lines">@@ -48,6 +46,4 @@
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#endif // PLATFORM(IOS)
-
</del><span class="cx"> #endif // YouTubeEmbedShadowElement_h
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (168441 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2014-05-07 21:57:06 UTC (rev 168441)
+++ trunk/Source/WebKit/mac/ChangeLog        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2014-05-07 Brent Fulgham <bfulgham@apple.com>
+
+ [Mac, iOS] REGRESSION: WK2 YouTube support
+ https://bugs.webkit.org/show_bug.cgi?id=132568
+ <rdar://problem/11464344>
+
+ Reviewed by Darin Adler.
+
+ * Misc/WebNSURLExtras.h:
+ * Misc/WebNSURLExtras.mm: Remove code that has been converted to C++
+ and added to YouTubePluginReplacement.cpp.
+ (-[NSURL _webkit_youTubeURL]):
+ (-[NSString _webkit_queryKeysAndValues]):
+ (createYouTubeURL): Deleted.
+ (-[NSString _webkit_unescapedQueryValue]): Deleted.
+
</ins><span class="cx"> 2014-05-07 Jeremy Jones <jeremyj@apple.com>
</span><span class="cx">
</span><span class="cx"> HTMLMediaElement should exitFullscreen when view is removed from the window.
</span></span></pre></div>
<a id="trunkSourceWebKitmacMiscWebNSURLExtrash"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/Misc/WebNSURLExtras.h (168441 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/Misc/WebNSURLExtras.h        2014-05-07 21:57:06 UTC (rev 168441)
+++ trunk/Source/WebKit/mac/Misc/WebNSURLExtras.h        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -72,8 +72,6 @@
</span><span class="cx"> - (NSURL *)_webkit_URLFromURLOrSchemelessFileURL;
</span><span class="cx">
</span><span class="cx"> #if TARGET_OS_IPHONE
</span><del>-- (NSURL *)_webkit_youTubeURL;
-
</del><span class="cx"> + (NSURL *)uniqueURLWithRelativePart:(NSString *)relativePart;
</span><span class="cx"> #endif
</span><span class="cx"> @end
</span><span class="lines">@@ -99,9 +97,4 @@
</span><span class="cx"> - (NSString *)_webkit_URLFragment;
</span><span class="cx"> - (NSString *)_webkit_scriptIfJavaScriptURL;
</span><span class="cx">
</span><del>-#if TARGET_OS_IPHONE
-- (NSString *)_webkit_unescapedQueryValue;
-- (NSDictionary *)_webkit_queryKeysAndValues;
-#endif
-
</del><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKitmacMiscWebNSURLExtrasmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/Misc/WebNSURLExtras.mm (168441 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/Misc/WebNSURLExtras.mm        2014-05-07 21:57:06 UTC (rev 168441)
+++ trunk/Source/WebKit/mac/Misc/WebNSURLExtras.mm        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -274,100 +274,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-static inline NSURL *createYouTubeURL(NSString *videoID, NSString *timeID)
-{
- // This method creates a youtube: URL, which is an internal format that is passed to YouTube.app.
- // If the format of these internal links is changed below, then the app probably needs to be updated as well.
-
- ASSERT(videoID && [videoID length] > 0 && ![videoID isEqualToString:@"/"]);
-
- if ([timeID length])
- return [NSURL URLWithString:[NSString stringWithFormat:@"youtube:%@?t=%@", videoID, timeID]];
- return [NSURL URLWithString:[NSString stringWithFormat:@"youtube:%@", videoID]];
-}
-
-- (NSURL *)_webkit_youTubeURL
-{
- // Bail out early if we aren't even on www.youtube.com or youtube.com.
- NSString *scheme = [[self scheme] lowercaseString];
- if (![scheme isEqualToString:@"http"] && ![scheme isEqualToString:@"https"])
- return nil;
-
- NSString *hostName = [[self host] lowercaseString];
- BOOL isYouTubeMobileWebAppURL = [hostName isEqualToString:@"m.youtube.com"];
- BOOL isYouTubeShortenedURL = [hostName isEqualToString:@"youtu.be"];
- if (!isYouTubeMobileWebAppURL
- && !isYouTubeShortenedURL
- && ![hostName isEqualToString:@"www.youtube.com"]
- && ![hostName isEqualToString:@"youtube.com"])
- return nil;
-
- NSString *path = [self path];
-
- // Short URL of the form: http://youtu.be/v1d301D
- if (isYouTubeShortenedURL) {
- NSString *videoID = [path lastPathComponent];
- if (videoID && ![videoID isEqualToString:@"/"])
- return createYouTubeURL(videoID, nil);
- return nil;
- }
-
- NSString *query = [self query];
- NSString *fragment = [self fragment];
-
- // On the YouTube mobile web app, the path and query string are put into the
- // fragment so that one web page is only ever loaded (see <rdar://problem/9550639>).
- if (isYouTubeMobileWebAppURL) {
- NSRange range = [fragment rangeOfString:@"?"];
- if (range.location == NSNotFound) {
- path = fragment;
- query = nil;
- } else {
- path = [fragment substringToIndex:range.location];
- query = [fragment substringFromIndex:(range.location + 1)];
- }
- fragment = nil;
- }
-
- if ([[path lowercaseString] isEqualToString:@"/watch"]) {
- if ([query length]) {
- NSString *videoID = [[query _webkit_queryKeysAndValues] objectForKey:@"v"];
- if (videoID) {
- NSDictionary *fragmentDict = [[self fragment] _webkit_queryKeysAndValues];
- NSString *timeID = [fragmentDict objectForKey:@"t"];
- return createYouTubeURL(videoID, timeID);
- }
- }
-
- // May be a new-style link (see <rdar://problem/7733692>).
- if ([fragment hasPrefix:@"!"]) {
- query = [fragment substringFromIndex:1];
-
- if ([query length]) {
- NSDictionary *queryDict = [query _webkit_queryKeysAndValues];
- NSString *videoID = [queryDict objectForKey:@"v"];
- if (videoID) {
- NSString *timeID = [queryDict objectForKey:@"t"];
- return createYouTubeURL(videoID, timeID);
- }
- }
- }
- } else if ([path _web_hasCaseInsensitivePrefix:@"/v/"] || [path _web_hasCaseInsensitivePrefix:@"/e/"]) {
- NSString *videoID = [path lastPathComponent];
-
- // These URLs are funny - they don't have a ? for the first query parameter.
- // Strip all characters after and including '&' to remove extraneous parameters after the video ID.
- NSRange ampersand = [videoID rangeOfString:@"&"];
- if (ampersand.location != NSNotFound)
- videoID = [videoID substringToIndex:ampersand.location];
-
- if (videoID)
- return createYouTubeURL(videoID, nil);
- }
-
- return nil;
-}
-
</del><span class="cx"> + (NSURL *)uniqueURLWithRelativePart:(NSString *)relativePart
</span><span class="cx"> {
</span><span class="cx"> CFUUIDRef UUIDRef = CFUUIDCreate(kCFAllocatorDefault);
</span><span class="lines">@@ -490,73 +396,4 @@
</span><span class="cx"> return [self substringFromIndex:fragmentRange.location + 1];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if PLATFORM(IOS)
-
-- (NSString *)_webkit_unescapedQueryValue
-{
- NSMutableString *string = [[[self stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] mutableCopy] autorelease];
- if (!string) // If we failed to decode the URL as UTF8, fall back to Latin1
- string = [[[self stringByReplacingPercentEscapesUsingEncoding:NSISOLatin1StringEncoding] mutableCopy] autorelease];
- [string replaceOccurrencesOfString:@"+" withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [string length])];
- return string;
-}
-
-- (NSDictionary *)_webkit_queryKeysAndValues
-{
- unsigned queryLength = [self length];
- if (!queryLength)
- return nil;
-
- NSMutableDictionary *queryKeysAndValues = nil;
- NSRange equalSearchRange = NSMakeRange(0, queryLength);
-
- while (equalSearchRange.location < queryLength - 1 && equalSearchRange.length) {
-
- // Search for "=".
- NSRange equalRange = [self rangeOfString:@"=" options:NSLiteralSearch range:equalSearchRange];
- if (equalRange.location == NSNotFound)
- break;
-
- unsigned indexAfterEqual = equalRange.location + 1;
- if (indexAfterEqual > queryLength - 1)
- break;
-
- // Get the key before the "=".
- NSRange keyRange = NSMakeRange(equalSearchRange.location, equalRange.location - equalSearchRange.location);
-
- // Seach for the ampersand.
- NSRange ampersandSearchRange = NSMakeRange(indexAfterEqual, queryLength - indexAfterEqual);
- NSRange ampersandRange = [self rangeOfString:@"&" options:NSLiteralSearch range:ampersandSearchRange];
-
- // Get the value after the "=", before the ampersand.
- NSRange valueRange;
- if (ampersandRange.location != NSNotFound)
- valueRange = NSMakeRange(indexAfterEqual, ampersandRange.location - indexAfterEqual);
- else
- valueRange = NSMakeRange(indexAfterEqual, queryLength - indexAfterEqual);
-
- // Save the key and the value.
- if (keyRange.length && valueRange.length) {
- if (queryKeysAndValues == nil)
- queryKeysAndValues = [NSMutableDictionary dictionary];
- NSString *key = [[self substringWithRange:keyRange] lowercaseString];
- NSString *value = [[self substringWithRange:valueRange] _webkit_unescapedQueryValue];
- if ([key length] && [value length])
- [queryKeysAndValues setObject:value forKey:key];
- }
-
- // At the end.
- if (ampersandRange.location == NSNotFound)
- break;
-
- // Continue searching after the ampersand.
- unsigned indexAfterAmpersand = ampersandRange.location + 1;
- equalSearchRange = NSMakeRange(indexAfterAmpersand, queryLength - indexAfterAmpersand);
- }
-
- return queryKeysAndValues;
-}
-
-#endif // PLATFORM(IOS)
-
</del><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebFrameLoaderClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm (168441 => 168442)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm        2014-05-07 21:57:06 UTC (rev 168441)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm        2014-05-07 21:59:51 UTC (rev 168442)
</span><span class="lines">@@ -2000,66 +2000,7 @@
</span><span class="cx"> [error release];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if PLATFORM(IOS)
- // See if this is a YouTube Flash plug-in
- if ([MIMEType isEqualToString:@"application/x-shockwave-flash"]) {
- NSDictionary *attributes = [NSDictionary dictionaryWithObjects:kit(paramValues) forKeys:kit(paramNames)];
- NSString *srcString = [attributes objectForKey:@"src"];
- if (srcString) {
- NSURL *srcURL = [NSURL URLWithString:srcString];
- NSURL *youtubeURL = [srcURL _webkit_youTubeURL];
- if (srcURL && youtubeURL) {
- // Transform the youtubeURL (youtube:VideoID) to iframe embed url which has the format: http://www.youtube.com/embed/VideoID
- NSString *srcPath = [srcURL path];
- NSString *videoID = [[youtubeURL absoluteString] substringFromIndex:[[youtubeURL scheme] length] + 1];
- NSRange rangeOfVideoIDInPath = [srcPath rangeOfString:videoID];
- NSString *srcURLPrefix = nil;
- if (rangeOfVideoIDInPath.location == NSNotFound && !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_YOUTUBE_EMBED_IFRAME_TRANSFORM)) {
- // If the videoID is not inside srcPath, the embed src url is in wrong format. We still want to support them for apps build against 5.1 and older.
- // For embed src like http://www.youtube.com/watch?v=VideoID, we make srcURLPrefix "http://www.youtube.com".
- // See: <rdar://problem/11517502> youtube videos don't work in FAO Forestry
- srcURLPrefix = [srcString substringToIndex:[srcString rangeOfString:srcPath].location];
- } else {
- ASSERT(rangeOfVideoIDInPath.length);
-
- // From the original URL, we need to get the part before /path/VideoId.
- NSRange rangeOfPathBeforeVideoID = [srcString rangeOfString:[srcPath substringToIndex:rangeOfVideoIDInPath.location]];
- ASSERT(rangeOfPathBeforeVideoID.length);
-
- srcURLPrefix = [srcString substringToIndex:rangeOfPathBeforeVideoID.location];
- }
- NSString *query = [srcURL query];
- // By default, the iframe will display information like the video title and uploader on top of the video. Don't display
- // them if the embeding html doesn't specify it.
- if (query && [query length] && [query rangeOfString:@"showinfo"].location == NSNotFound)
- query = [query stringByAppendingFormat:@"&showinfo=0"];
- else
- query = @"showinfo=0";
-
- // Append the query string if it is valid. Some sites apparently forget to add "?" for the query string, in that case,
- // we will discard the parameters in the url.
- // See: <rdar://problem/11535155> [Bincompat] Regression: SC2Casts app: Videos don't play in SC2Casts
- NSString *embedSrc = query ? [srcURLPrefix stringByAppendingFormat:@"/embed/%@?%@", videoID, query] : [srcURLPrefix stringByAppendingFormat:@"/embed/%@", videoID];
-
- if (element->hasTagName(HTMLNames::embedTag) || element->hasTagName(HTMLNames::objectTag)) {
- // Create a shadow subtree for the plugin element, the iframe player is injected in the shadow tree.
- toHTMLPlugInImageElement(*element).createShadowIFrameSubtree(embedSrc);
- return nullptr;
- }
-
- // If this is a YouTube Flash plug-in. We don't have Flash. Create an instance of Apple's special YouTube plug-in instead
- pluginPackage = [webView _pluginForMIMEType:@"application/x-apple-fake-youtube-plugin"];
- if (pluginPackage) {
- view = pluginView(m_webFrame.get(), (WebPluginPackage *)pluginPackage, kit(paramNames), kit(paramValues), baseURL, kit(element), loadManually);
- if (view)
- return adoptRef(new PluginWidgetIOS(view));
- }
- }
- }
- }
-#endif // PLATFORM(IOS)
-
- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> ASSERT(view);
</span></span></pre>
</div>
</div>
</body>
</html>