Skip to content
Permalink
Browse files
shouldUsePluginDocument() needs to be respected when a document is cr…
…eated

https://bugs.webkit.org/show_bug.cgi?id=110308

Patch by Max Feil <mfeil@rim.com> on 2013-05-09
Reviewed by Rob Buis.

Source/WebCore:

In DOMImplementation::createDocument() we should create
a PluginDocument for mime types that return "true" for
shouldAlwaysUsePluginDocument(), even if there is no pluginData
for them. This lets a client choose plugins for which the "missing
plugin" text or icon should appear more consistently. Otherwise
plugins referenced by iFrames will be treated as an HTMLDocument,
possibly resulting in binary files rendered as gibberish text.

Layout test platform/blackberry/plugins/swf-as-src-of-iframe.html

* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createDocument):

Source/WebKit/blackberry:

This patch implements shouldAlwaysUsePluginDocument() in the
BlackBerry frame loader client. It is called in several places
within WebCore to determine whether a PluginDocument should
be created.

* WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
(WebCore::FrameLoaderClientBlackBerry::shouldAlwaysUsePluginDocument):
(WebCore):
(WebCore::FrameLoaderClientBlackBerry::createPlugin):
* WebCoreSupport/FrameLoaderClientBlackBerry.h:
(FrameLoaderClientBlackBerry):

Source/WebKit/win:

Renaming shouldUsePluginDocument() to shouldAlwaysUsePluginDocument()
for clarity.

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::shouldAlwaysUsePluginDocument):
* WebCoreSupport/WebFrameLoaderClient.h:
(WebFrameLoaderClient):

Source/WebKit2:

Renaming shouldUsePluginDocument() to shouldAlwaysUsePluginDocument()
for clarity.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::shouldAlwaysUsePluginDocument):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
(WebFrameLoaderClient):

Canonical link: https://commits.webkit.org/134290@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@149830 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Max Feil authored and webkit-commit-queue committed May 9, 2013
1 parent 6d481df commit 055d836cf2bbf8ce30261d9167716539d81bef1d
Showing 16 changed files with 132 additions and 10 deletions.
@@ -0,0 +1 @@
PASSED
@@ -0,0 +1,46 @@
<html>
<head>
<title>Test that iframe with src set to swf uses plugin document</title>
<!--- This will ensure that the "missing plugin text" is shown when the FlashPlayer plugin is disabled. -->
<script>
function runTest() {
framedocument = document.getElementById('frame').contentWindow.document;
innerhtml = framedocument.getElementsByTagName('body')[0].innerHTML;
if (innerhtml[0] === 'C') {
// This is the 'C' from the ActionScript SWC. The contents are being
// rendered as text. Fail the test.
document.getElementById('console').textContent = "FAILED due to plugin rendered as gibberish text (PR293098).";
} else {
var flashplayerLoaded = false;
for (i = 0; i < navigator.plugins.length; ++i) {
for (j = 0; j < navigator.plugins[i].length; ++j) {
if (navigator.plugins[i][j].type == "application/x-shockwave-flash") {
flashplayerLoaded = true;
}
}
}
if (flashplayerLoaded) {
document.getElementById('console').textContent = "FAILED due to FlashPlayer plugin enabled. Please disable it.";
} else if (framedocument.getElementsByTagName('embed')[0]){
// There is an embed element instead of gibberish text. This is what we
// want and indicates that a plugin document was created instead of an
// HTML document.
document.getElementById('console').textContent = "PASSED";
} else {
document.getElementById('console').textContent = "FAILED for an unknown reson.";
}
}

}
</script>
</head>

<body onload="runTest();">

<iframe id="frame" src="../../../plugins/resources/simple_blank.swf" width="100" height="100">
</iframe>

<div id="console"></div>
</body>

</html>
@@ -1,3 +1,23 @@
2013-05-09 Max Feil <mfeil@rim.com>

shouldUsePluginDocument() needs to be respected when a document is created
https://bugs.webkit.org/show_bug.cgi?id=110308

Reviewed by Rob Buis.

In DOMImplementation::createDocument() we should create
a PluginDocument for mime types that return "true" for
shouldAlwaysUsePluginDocument(), even if there is no pluginData
for them. This lets a client choose plugins for which the "missing
plugin" text or icon should appear more consistently. Otherwise
plugins referenced by iFrames will be treated as an HTMLDocument,
possibly resulting in binary files rendered as gibberish text.

Layout test platform/blackberry/plugins/swf-as-src-of-iframe.html

* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createDocument):

2013-05-09 Timothy Hatcher <timothy@apple.com>

Fix an exception when hovering native functions while paused in the debugger.
@@ -418,7 +418,7 @@ PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame
// Everything else except text/plain can be overridden by plugins. In particular, Adobe SVG Viewer should be used for SVG, if installed.
// Disallowing plug-ins to use text/plain prevents plug-ins from hijacking a fundamental type that the browser is expected to handle,
// and also serves as an optimization to prevent loading the plug-in database in the common case.
if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type))
if (type != "text/plain" && ((pluginData && pluginData->supportsMimeType(type)) || (frame && frame->loader()->client()->shouldAlwaysUsePluginDocument(type))))
return PluginDocument::create(frame, url);
if (isTextMIMEType(type))
return TextDocument::create(frame, url);
@@ -104,7 +104,7 @@ void DocumentWriter::begin()

PassRefPtr<Document> DocumentWriter::createDocument(const KURL& url)
{
if (!m_frame->loader()->stateMachine()->isDisplayingInitialEmptyDocument() && m_frame->loader()->client()->shouldUsePluginDocument(m_mimeType))
if (!m_frame->loader()->stateMachine()->isDisplayingInitialEmptyDocument() && m_frame->loader()->client()->shouldAlwaysUsePluginDocument(m_mimeType))
return PluginDocument::create(m_frame, url);
if (!m_frame->loader()->client()->hasHTMLView())
return PlaceholderDocument::create(m_frame, url);
@@ -293,7 +293,7 @@ namespace WebCore {
virtual bool shouldCacheResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&, const unsigned char* data, unsigned long long length) = 0;
#endif

virtual bool shouldUsePluginDocument(const String& /*mimeType*/) const { return false; }
virtual bool shouldAlwaysUsePluginDocument(const String& /*mimeType*/) const { return false; }
virtual bool shouldLoadMediaElementURL(const KURL&) const { return true; }

virtual void didChangeScrollOffset() { }
@@ -414,7 +414,7 @@ bool SubframeLoader::allowPlugins(ReasonForCallingAllowPlugins reason)

bool SubframeLoader::shouldUsePlugin(const KURL& url, const String& mimeType, bool shouldPreferPlugInsForImages, bool hasFallback, bool& useFallback)
{
if (m_frame->loader()->client()->shouldUsePluginDocument(mimeType)) {
if (m_frame->loader()->client()->shouldAlwaysUsePluginDocument(mimeType)) {
useFallback = false;
return true;
}
@@ -1,3 +1,22 @@
2013-05-09 Max Feil <mfeil@rim.com>

shouldUsePluginDocument() needs to be respected when a document is created
https://bugs.webkit.org/show_bug.cgi?id=110308

Reviewed by Rob Buis.

This patch implements shouldAlwaysUsePluginDocument() in the
BlackBerry frame loader client. It is called in several places
within WebCore to determine whether a PluginDocument should
be created.

* WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
(WebCore::FrameLoaderClientBlackBerry::shouldAlwaysUsePluginDocument):
(WebCore):
(WebCore::FrameLoaderClientBlackBerry::createPlugin):
* WebCoreSupport/FrameLoaderClientBlackBerry.h:
(FrameLoaderClientBlackBerry):

2013-05-09 Mike Fenton <mifenton@rim.com>

[BlackBerry] Style updates required based on new check-webkit-style
@@ -308,6 +308,11 @@ void FrameLoaderClientBlackBerry::committedLoad(DocumentLoader* loader, const ch
}
}

bool FrameLoaderClientBlackBerry::shouldAlwaysUsePluginDocument(const String& mimeType) const
{
return mimeType == "application/x-shockwave-flash";
}

PassRefPtr<Widget> FrameLoaderClientBlackBerry::createPlugin(const IntSize& pluginSize,
HTMLPlugInElement* element, const KURL& url, const Vector<String>& paramNames,
const Vector<String>& paramValues, const String& mimeTypeIn, bool loadManually)
@@ -316,7 +321,7 @@ PassRefPtr<Widget> FrameLoaderClientBlackBerry::createPlugin(const IntSize& plug
if (mimeType.isEmpty()) {
mimeType = MIMETypeRegistry::getMIMETypeForPath(url.path());
mimeType = MIMETypeRegistry::getNormalizedMIMEType(mimeType);
if (mimeType != "application/x-shockwave-flash")
if (!shouldAlwaysUsePluginDocument(mimeType))
mimeType = mimeTypeIn;
}

@@ -330,7 +335,7 @@ PassRefPtr<Widget> FrameLoaderClientBlackBerry::createPlugin(const IntSize& plug
// will generally be a valid media mime type, or it may be null. We
// explicitly check for Flash content so it does not get rendered as
// text at this point, producing garbled characters.
if (mimeType != "application/x-shockwave-flash" && m_frame->loader() && m_frame->loader()->subframeLoader() && !url.isNull())
if (!shouldAlwaysUsePluginDocument(mimeType) && m_frame->loader() && m_frame->loader()->subframeLoader() && !url.isNull())
m_frame->loader()->subframeLoader()->requestFrame(element, url, String());

return 0;
@@ -144,6 +144,7 @@ class FrameLoaderClientBlackBerry : public FrameLoaderClient {
virtual void dispatchDidBecomeFrameset(bool) { }
virtual void convertMainResourceLoadToDownload(DocumentLoader*, const ResourceRequest&, const ResourceResponse&);
virtual PassRefPtr<Frame> createFrame(const KURL&, const String&, HTMLFrameOwnerElement*, const String&, bool, int, int);
virtual bool shouldAlwaysUsePluginDocument(const String&) const;
virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool);
virtual void redirectDataToPlugin(Widget*);
virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL&, const Vector<String>&, const Vector<String>&) { notImplemented(); return 0; }
@@ -1,3 +1,18 @@
2013-05-09 Max Feil <mfeil@rim.com>

shouldUsePluginDocument() needs to be respected when a document is created
https://bugs.webkit.org/show_bug.cgi?id=110308

Reviewed by Rob Buis.

Renaming shouldUsePluginDocument() to shouldAlwaysUsePluginDocument()
for clarity.

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::shouldAlwaysUsePluginDocument):
* WebCoreSupport/WebFrameLoaderClient.h:
(WebFrameLoaderClient):

2013-05-06 Darin Adler <darin@apple.com>

Use adoptCF and adoptNS in more places
@@ -896,7 +896,7 @@ WebHistory* WebFrameLoaderClient::webHistory() const
return WebHistory::sharedHistory();
}

bool WebFrameLoaderClient::shouldUsePluginDocument(const String& mimeType) const
bool WebFrameLoaderClient::shouldAlwaysUsePluginDocument(const String& mimeType) const
{
WebView* webView = m_webFrame->webView();
if (!webView)
@@ -118,7 +118,7 @@ class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
virtual void recreatePlugin(WebCore::Widget*) { }
virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget);

virtual bool shouldUsePluginDocument(const WTF::String& mimeType) const;
virtual bool shouldAlwaysUsePluginDocument(const WTF::String& mimeType) const;

virtual void dispatchDidFailToStartPlugin(const WebCore::PluginView*) const;

@@ -1,3 +1,18 @@
2013-05-09 Max Feil <mfeil@rim.com>

shouldUsePluginDocument() needs to be respected when a document is created
https://bugs.webkit.org/show_bug.cgi?id=110308

Reviewed by Rob Buis.

Renaming shouldUsePluginDocument() to shouldAlwaysUsePluginDocument()
for clarity.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::shouldAlwaysUsePluginDocument):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
(WebFrameLoaderClient):

2013-05-09 Timothy Hatcher <timothy@apple.com>

Make dragging off a tab in Safari with a docked Inspector reattach the Inspector.
@@ -1536,7 +1536,7 @@ NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader*, un

#endif // PLATFORM(MAC)

bool WebFrameLoaderClient::shouldUsePluginDocument(const String& /*mimeType*/) const
bool WebFrameLoaderClient::shouldAlwaysUsePluginDocument(const String& /*mimeType*/) const
{
notImplemented();
return false;
@@ -214,7 +214,7 @@ class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
virtual NSCachedURLResponse* willCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const OVERRIDE;
#endif

virtual bool shouldUsePluginDocument(const String& /*mimeType*/) const OVERRIDE;
virtual bool shouldAlwaysUsePluginDocument(const String& /*mimeType*/) const OVERRIDE;

virtual void didChangeScrollOffset() OVERRIDE;

0 comments on commit 055d836

Please sign in to comment.