https://bugs.webkit.org/show_bug.cgi?id=133944
<rdar://problem/
17205983>
Reviewed by Dan Bates.
* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createDocument):
Make a ImageDocument to show our subframe PDF, if the setting is enabled.
* html/ImageDocument.cpp:
(WebCore::ImageDocument::finishedParsing):
(WebCore::ImageDocument::createDocumentStructure):
Set the ResourceResponse on the ImageElement upon creation, instead of
when the load finishes. This way, when the internal CachedImage creates
its Image, it can have the correct MIME type for the response, and can
make a PDFDocumentImage if necessary.
We never noticed this before because CachedImage falls back to making a
BitmapImage, and that was the only case that was normally used.
Throw an explicit white background behind PDF ImageDocuments; PDFDocumentImage
paints with a transparent background, but when used as an ImageDocument
it seems reasonable to assume that there should be a white page background
(similar to what PDFPlugin and friends do).
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::createDocument):
Don't make a PDFDocument if we want to use an ImageDocument for this subframe PDF.
* page/Settings.in:
* platform/MIMETypeRegistry.cpp:
(WebCore::MIMETypeRegistry::isPDFMIMEType):
* platform/MIMETypeRegistry.h:
Expose the already implemented pdfMIMETypes table just like all the rest.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
Always use ImageDocument for subframe PDFs in WebKit2 on iOS.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170091
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-06-17 Tim Horton <timothy_horton@apple.com>
+
+ [iOS][wk2] Use ImageDocument to display subframe PDFs
+ https://bugs.webkit.org/show_bug.cgi?id=133944
+ <rdar://problem/17205983>
+
+ Reviewed by Dan Bates.
+
+ * dom/DOMImplementation.cpp:
+ (WebCore::DOMImplementation::createDocument):
+ Make a ImageDocument to show our subframe PDF, if the setting is enabled.
+
+ * html/ImageDocument.cpp:
+ (WebCore::ImageDocument::finishedParsing):
+ (WebCore::ImageDocument::createDocumentStructure):
+ Set the ResourceResponse on the ImageElement upon creation, instead of
+ when the load finishes. This way, when the internal CachedImage creates
+ its Image, it can have the correct MIME type for the response, and can
+ make a PDFDocumentImage if necessary.
+
+ We never noticed this before because CachedImage falls back to making a
+ BitmapImage, and that was the only case that was normally used.
+
+ Throw an explicit white background behind PDF ImageDocuments; PDFDocumentImage
+ paints with a transparent background, but when used as an ImageDocument
+ it seems reasonable to assume that there should be a white page background
+ (similar to what PDFPlugin and friends do).
+
+ * loader/DocumentWriter.cpp:
+ (WebCore::DocumentWriter::createDocument):
+ Don't make a PDFDocument if we want to use an ImageDocument for this subframe PDF.
+
+ * page/Settings.in:
+
+ * platform/MIMETypeRegistry.cpp:
+ (WebCore::MIMETypeRegistry::isPDFMIMEType):
+ * platform/MIMETypeRegistry.h:
+ Expose the already implemented pdfMIMETypes table just like all the rest.
+
2014-06-17 Ryuan Choi <ryuan.choi@samsung.com>
Unreviewed build fix with ENABLE_NOSNIFF after r170021
#include "HTMLDocument.h"
#include "Image.h"
#include "ImageDocument.h"
+#include "MainFrame.h"
#include "MediaDocument.h"
#include "MediaList.h"
#include "MIMETypeRegistry.h"
return FTPDirectoryDocument::create(frame, url);
#endif
+ // If we want to useImageDocumentForSubframePDF, we'll let that override plugin support.
+ if (frame && !frame->isMainFrame() && MIMETypeRegistry::isPDFMIMEType(type) && frame->settings().useImageDocumentForSubframePDF())
+ return ImageDocument::create(*frame, url);
+
PluginData* pluginData = 0;
PluginData::AllowedPluginTypes allowedPluginTypes = PluginData::OnlyApplicationPlugins;
if (frame && frame->page()) {
// PDF is one image type for which a plugin can override built-in support.
// We do not want QuickTime to take over all image types, obviously.
- if ((MIMETypeRegistry::isPDFOrPostScriptMIMEType(type)) && pluginData && pluginData->supportsMimeType(type, allowedPluginTypes))
+ if (MIMETypeRegistry::isPDFOrPostScriptMIMEType(type) && pluginData && pluginData->supportsMimeType(type, allowedPluginTypes))
return PluginDocument::create(frame, url);
if (Image::supportsType(type))
return ImageDocument::create(*frame, url);
#include "FrameLoader.h"
#include "FrameLoaderClient.h"
#include "FrameView.h"
+#include "HTMLBodyElement.h"
#include "HTMLHtmlElement.h"
#include "HTMLImageElement.h"
#include "HTMLNames.h"
#include "LocalizedStrings.h"
+#include "MIMETypeRegistry.h"
#include "MainFrame.h"
#include "MouseEvent.h"
#include "Page.h"
cachedImage.finishLoading(data.get());
cachedImage.finish();
- cachedImage.setResponse(loader()->response());
-
// Report the natural image size in the page title, regardless of zoom level.
// At a zoom level of 1 the image is guaranteed to have an integer size.
updateStyleIfNeeded();
RefPtr<Element> body = Document::createElement(bodyTag, false);
body->setAttribute(styleAttr, "margin: 0px");
+ if (MIMETypeRegistry::isPDFMIMEType(document().loader()->responseMIMEType()))
+ toHTMLBodyElement(body.get())->setInlineStyleProperty(CSSPropertyBackgroundColor, "white", CSSPrimitiveValue::CSS_IDENT);
rootElement->appendChild(body);
RefPtr<ImageDocumentElement> imageElement = ImageDocumentElement::create(*this);
imageElement->setAttribute(styleAttr, "-webkit-user-select:none;");
imageElement->setLoadManually(true);
imageElement->setSrc(url().string());
+ imageElement->cachedImage()->setResponse(loader()->response());
body->appendChild(imageElement);
if (m_shouldShrinkImage) {
#include "FrameLoaderClient.h"
#include "FrameLoaderStateMachine.h"
#include "FrameView.h"
+#include "MIMETypeRegistry.h"
+#include "MainFrame.h"
#include "PluginDocument.h"
#include "RawDataDocumentParser.h"
#include "ScriptController.h"
if (!m_frame->loader().stateMachine().isDisplayingInitialEmptyDocument() && m_frame->loader().client().shouldAlwaysUsePluginDocument(m_mimeType))
return PluginDocument::create(m_frame, url);
#if PLATFORM(IOS)
- if (equalIgnoringCase(m_mimeType, "application/pdf"))
+ if (MIMETypeRegistry::isPDFMIMEType(m_mimeType) && (m_frame->isMainFrame() || !m_frame->settings().useImageDocumentForSubframePDF()))
return PDFDocument::create(m_frame, url);
#endif
if (!m_frame->loader().client().hasHTMLView())
aggressiveTileRetentionEnabled initial=false
temporaryTileCohortRetentionEnabled initial=true
+
+useImageDocumentForSubframePDF initial=false
return pdfAndPostScriptMIMETypes->contains(mimeType);
}
+bool MIMETypeRegistry::isPDFMIMEType(const String& mimeType)
+{
+ if (mimeType.isEmpty())
+ return false;
+ if (!pdfMIMETypes)
+ initializeMIMETypeRegistry();
+ return pdfMIMETypes->contains(mimeType);
+}
+
bool MIMETypeRegistry::canShowMIMEType(const String& mimeType)
{
if (isSupportedImageMIMEType(mimeType) || isSupportedNonImageMIMEType(mimeType) || isSupportedMediaMIMEType(mimeType))
// Check to see if a mime type is one of the common PDF/PS types.
static bool isPDFOrPostScriptMIMEType(const String& mimeType);
+ static bool isPDFMIMEType(const String& mimeType);
// Check to see if a mime type is suitable for being shown inside a page.
// Returns true if any of isSupportedImageMIMEType(), isSupportedNonImageMIMEType(), isSupportedMediaMIMEType() returns true
+2014-06-17 Tim Horton <timothy_horton@apple.com>
+
+ [iOS][wk2] Use ImageDocument to display subframe PDFs
+ https://bugs.webkit.org/show_bug.cgi?id=133944
+ <rdar://problem/17205983>
+
+ Reviewed by Dan Bates.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::updatePreferences):
+ Always use ImageDocument for subframe PDFs in WebKit2 on iOS.
+
2014-06-17 Anders Carlsson <andersca@apple.com>
Make it possible to use -[NSBundle classNamed:] to find WebKitLegacy classes
settings.setShouldDispatchJavaScriptWindowOnErrorEvents(true);
+#if PLATFORM(IOS)
+ settings.setUseImageDocumentForSubframePDF(true);
+#endif
+
if (store.getBoolValueForKey(WebPreferencesKey::pageVisibilityBasedProcessSuppressionEnabledKey()))
m_processSuppressionDisabledByWebPreference.stop();
else