<!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>[165327] 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/165327">165327</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2014-03-07 22:36:02 -0800 (Fri, 07 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WebKit2][iOS] PDF
https://bugs.webkit.org/show_bug.cgi?id=129600
&lt;rdar://problem/15260216&gt;

Reviewed by Anders Carlsson.

Add a single custom content provider which installs a very primitive PDF view
in place of the WKContentView if a PDF is loaded in the main frame.

* Configurations/WebKit2.xcconfig:
Link against CorePDF, for UIPDFPageView.

* UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm:
(-[WKWebViewContentProviderRegistry init]):
Initialize the registry, using WKPDFView for all PDF MIME types.

* WebKit2.xcodeproj/project.pbxproj:
* UIProcess/ios/WKPDFView.h: Added.
* UIProcess/ios/WKPDFView.mm: Added.
Add a very simple PDF view based on UIPDFPageView. Additional functionality
can come in the future; right now, we just create one view for each page, and
depend on CATiledLayer to only paint the pages that are being displayed.

* WebCore.exp.in:
* platform/MIMETypeRegistry.cpp:
(WebCore::initializeSupportedImageMIMETypes):
(WebCore::initializePDFMIMETypes):
(WebCore::initializePostScriptMIMETypes):
(WebCore::initializeMIMETypeRegistry):
(WebCore::MIMETypeRegistry::getPDFMIMETypes):
* platform/MIMETypeRegistry.h:
Split PDF and PostScript MIME types, so WebKit2 can retrieve just the PDF ones
without PostScript included.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreplatformMIMETypeRegistrycpp">trunk/Source/WebCore/platform/MIMETypeRegistry.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformMIMETypeRegistryh">trunk/Source/WebCore/platform/MIMETypeRegistry.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2ConfigurationsWebKit2xcconfig">trunk/Source/WebKit2/Configurations/WebKit2.xcconfig</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWKWebViewContentProviderRegistrymm">trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessiosWKPDFViewh">trunk/Source/WebKit2/UIProcess/ios/WKPDFView.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKPDFViewmm">trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (165326 => 165327)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-08 06:34:07 UTC (rev 165326)
+++ trunk/Source/WebCore/ChangeLog        2014-03-08 06:36:02 UTC (rev 165327)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2014-03-07  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        [WebKit2][iOS] PDF
+        https://bugs.webkit.org/show_bug.cgi?id=129600
+        &lt;rdar://problem/15260216&gt;
+
+        Reviewed by Anders Carlsson.
+
+        * WebCore.exp.in:
+        * platform/MIMETypeRegistry.cpp:
+        (WebCore::initializeSupportedImageMIMETypes):
+        (WebCore::initializePDFMIMETypes):
+        (WebCore::initializePostScriptMIMETypes):
+        (WebCore::initializeMIMETypeRegistry):
+        (WebCore::MIMETypeRegistry::getPDFMIMETypes):
+        * platform/MIMETypeRegistry.h:
+        Split PDF and PostScript MIME types, so WebKit2 can retrieve just the PDF ones
+        without PostScript included.
+
</ins><span class="cx"> 2014-03-07  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Comment in RenderStyle is no longer accurate
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (165326 => 165327)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-03-08 06:34:07 UTC (rev 165326)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-03-08 06:36:02 UTC (rev 165327)
</span><span class="lines">@@ -668,6 +668,7 @@
</span><span class="cx"> __ZN7WebCore16LegacyWebArchive6createEPNS_5RangeE
</span><span class="cx"> __ZN7WebCore16LegacyWebArchive6createEv
</span><span class="cx"> __ZN7WebCore16MIMETypeRegistry15canShowMIMETypeERKN3WTF6StringE
</span><ins>+__ZN7WebCore16MIMETypeRegistry15getPDFMIMETypesEv
</ins><span class="cx"> __ZN7WebCore16MIMETypeRegistry20isJavaAppletMIMETypeERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore16MIMETypeRegistry23getMIMETypeForExtensionERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore16MIMETypeRegistry24isSupportedImageMIMETypeERKN3WTF6StringE
</span><span class="lines">@@ -675,7 +676,6 @@
</span><span class="cx"> __ZN7WebCore16MIMETypeRegistry26getSupportedImageMIMETypesEv
</span><span class="cx"> __ZN7WebCore16MIMETypeRegistry27getUnsupportedTextMIMETypesEv
</span><span class="cx"> __ZN7WebCore16MIMETypeRegistry27isSupportedNonImageMIMETypeERKN3WTF6StringE
</span><del>-__ZN7WebCore16MIMETypeRegistry28getPDFAndPostScriptMIMETypesEv
</del><span class="cx"> __ZN7WebCore16MIMETypeRegistry29getSupportedNonImageMIMETypesEv
</span><span class="cx"> __ZN7WebCore16MIMETypeRegistry32isSupportedImageResourceMIMETypeERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore16NavigationActionC1ERKNS_15ResourceRequestE
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMIMETypeRegistrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.cpp (165326 => 165327)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp        2014-03-08 06:34:07 UTC (rev 165326)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.cpp        2014-03-08 06:36:02 UTC (rev 165327)
</span><span class="lines">@@ -187,6 +187,7 @@
</span><span class="cx"> static HashSet&lt;String&gt;* supportedJavaScriptMIMETypes;
</span><span class="cx"> static HashSet&lt;String&gt;* supportedNonImageMIMETypes;
</span><span class="cx"> static HashSet&lt;String&gt;* supportedMediaMIMETypes;
</span><ins>+static HashSet&lt;String&gt;* pdfMIMETypes;
</ins><span class="cx"> static HashSet&lt;String&gt;* pdfAndPostScriptMIMETypes;
</span><span class="cx"> static HashSet&lt;String&gt;* unsupportedTextMIMETypes;
</span><span class="cx"> 
</span><span class="lines">@@ -339,17 +340,21 @@
</span><span class="cx">       supportedJavaScriptMIMETypes-&gt;add(types[i]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void initializePDFAndPostScriptMIMETypes()
</del><ins>+static void initializePDFMIMETypes()
</ins><span class="cx"> {
</span><span class="cx">     const char* const types[] = {
</span><span class="cx">         &quot;application/pdf&quot;,
</span><del>-        &quot;text/pdf&quot;,
-        &quot;application/postscript&quot;,
</del><ins>+        &quot;text/pdf&quot;
</ins><span class="cx">     };
</span><span class="cx">     for (size_t i = 0; i &lt; WTF_ARRAY_LENGTH(types); ++i)
</span><del>-        pdfAndPostScriptMIMETypes-&gt;add(types[i]);
</del><ins>+        pdfMIMETypes-&gt;add(types[i]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void initializePostScriptMIMETypes()
+{
+    pdfAndPostScriptMIMETypes-&gt;add(&quot;application/postscript&quot;);
+}
+
</ins><span class="cx"> static void initializeSupportedNonImageMimeTypes()
</span><span class="cx"> {
</span><span class="cx">     static const char* types[] = {
</span><span class="lines">@@ -491,9 +496,12 @@
</span><span class="cx">     supportedImageMIMETypes = new HashSet&lt;String&gt;;
</span><span class="cx">     initializeSupportedImageMIMETypes();
</span><span class="cx"> 
</span><del>-    pdfAndPostScriptMIMETypes = new HashSet&lt;String&gt;;
-    initializePDFAndPostScriptMIMETypes();
</del><ins>+    pdfMIMETypes = new HashSet&lt;String&gt;;
+    initializePDFMIMETypes();
</ins><span class="cx"> 
</span><ins>+    pdfAndPostScriptMIMETypes = new HashSet&lt;String&gt;(*pdfMIMETypes);
+    initializePostScriptMIMETypes();
+
</ins><span class="cx">     unsupportedTextMIMETypes = new HashSet&lt;String&gt;;
</span><span class="cx">     initializeUnsupportedTextMIMETypes();
</span><span class="cx"> }
</span><span class="lines">@@ -661,6 +669,14 @@
</span><span class="cx">     return *supportedMediaMIMETypes;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+
+HashSet&lt;String&gt;&amp; MIMETypeRegistry::getPDFMIMETypes()
+{
+    if (!pdfMIMETypes)
+        initializeMIMETypeRegistry();
+    return *pdfMIMETypes;
+}
+
</ins><span class="cx"> HashSet&lt;String&gt;&amp; MIMETypeRegistry::getPDFAndPostScriptMIMETypes()
</span><span class="cx"> {
</span><span class="cx">     if (!pdfAndPostScriptMIMETypes)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMIMETypeRegistryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.h (165326 => 165327)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MIMETypeRegistry.h        2014-03-08 06:34:07 UTC (rev 165326)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.h        2014-03-08 06:36:02 UTC (rev 165327)
</span><span class="lines">@@ -91,6 +91,7 @@
</span><span class="cx">     static HashSet&lt;String&gt;&amp; getSupportedImageMIMETypesForEncoding();
</span><span class="cx">     static HashSet&lt;String&gt;&amp; getSupportedNonImageMIMETypes();
</span><span class="cx">     static HashSet&lt;String&gt;&amp; getSupportedMediaMIMETypes();
</span><ins>+    static HashSet&lt;String&gt;&amp; getPDFMIMETypes();
</ins><span class="cx">     static HashSet&lt;String&gt;&amp; getPDFAndPostScriptMIMETypes();
</span><span class="cx">     static HashSet&lt;String&gt;&amp; getUnsupportedTextMIMETypes();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (165326 => 165327)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-03-08 06:34:07 UTC (rev 165326)
+++ trunk/Source/WebKit2/ChangeLog        2014-03-08 06:36:02 UTC (rev 165327)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2014-03-07  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        [WebKit2][iOS] PDF
+        https://bugs.webkit.org/show_bug.cgi?id=129600
+        &lt;rdar://problem/15260216&gt;
+
+        Reviewed by Anders Carlsson.
+
+        Add a single custom content provider which installs a very primitive PDF view
+        in place of the WKContentView if a PDF is loaded in the main frame.
+
+        * Configurations/WebKit2.xcconfig:
+        Link against CorePDF, for UIPDFPageView.
+
+        * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm:
+        (-[WKWebViewContentProviderRegistry init]):
+        Initialize the registry, using WKPDFView for all PDF MIME types.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        * UIProcess/ios/WKPDFView.h: Added.
+        * UIProcess/ios/WKPDFView.mm: Added.
+        Add a very simple PDF view based on UIPDFPageView. Additional functionality
+        can come in the future; right now, we just create one view for each page, and
+        depend on CATiledLayer to only paint the pages that are being displayed.
+
</ins><span class="cx"> 2014-03-07  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         ArgumentEncoder and ArgumentDecoder should be fastmalloced.
</span></span></pre></div>
<a id="trunkSourceWebKit2ConfigurationsWebKit2xcconfig"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Configurations/WebKit2.xcconfig (165326 => 165327)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Configurations/WebKit2.xcconfig        2014-03-08 06:34:07 UTC (rev 165326)
+++ trunk/Source/WebKit2/Configurations/WebKit2.xcconfig        2014-03-08 06:36:02 UTC (rev 165327)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> DYLIB_INSTALL_NAME_BASE = $(NORMAL_WEBKIT2_FRAMEWORKS_DIR);
</span><span class="cx"> 
</span><span class="cx"> FRAMEWORK_AND_LIBRARY_LDFLAGS = $(FRAMEWORK_AND_LIBRARY_LDFLAGS_$(PLATFORM_NAME));
</span><del>-FRAMEWORK_AND_LIBRARY_LDFLAGS_iphonesimulator = -lobjc -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework UIKit -framework OpenGLES -framework WebKit -lMobileGestalt -lassertion_extension;
</del><ins>+FRAMEWORK_AND_LIBRARY_LDFLAGS_iphonesimulator = -lobjc -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CorePDF -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework UIKit -framework OpenGLES -framework WebKit -lMobileGestalt -lassertion_extension;
</ins><span class="cx"> FRAMEWORK_AND_LIBRARY_LDFLAGS_iphoneos = $(FRAMEWORK_AND_LIBRARY_LDFLAGS_iphonesimulator) -framework IOSurface;
</span><span class="cx"> FRAMEWORK_AND_LIBRARY_LDFLAGS_macosx = -framework ApplicationServices -framework Carbon -framework Cocoa -framework CoreServices -framework IOKit -framework CoreAudio -framework IOSurface -framework OpenGL;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWKWebViewContentProviderRegistrymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm (165326 => 165327)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm        2014-03-08 06:34:07 UTC (rev 165326)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm        2014-03-08 06:36:02 UTC (rev 165327)
</span><span class="lines">@@ -30,8 +30,10 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> 
</span><ins>+#import &quot;WKPDFView.h&quot;
</ins><span class="cx"> #import &quot;WKWebViewInternal.h&quot;
</span><span class="cx"> #import &quot;WebPageProxy.h&quot;
</span><ins>+#import &lt;WebCore/MIMETypeRegistry.h&gt;
</ins><span class="cx"> #import &lt;wtf/HashCountedSet.h&gt;
</span><span class="cx"> #import &lt;wtf/HashMap.h&gt;
</span><span class="cx"> #import &lt;wtf/text/StringHash.h&gt;
</span><span class="lines">@@ -44,6 +46,17 @@
</span><span class="cx">     HashCountedSet&lt;WebPageProxy*&gt; _pages;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (instancetype)init
+{
+    if (!(self = [super init]))
+        return nil;
+
+    for (auto&amp; mimeType : WebCore::MIMETypeRegistry::getPDFMIMETypes())
+        [self registerProvider:[WKPDFView class] forMIMEType:mimeType];
+
+    return self;
+}
+
</ins><span class="cx"> - (void)addPage:(WebPageProxy&amp;)page
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!_pages.contains(&amp;page));
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKPDFViewh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/ios/WKPDFView.h (0 => 165327)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKPDFView.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/ios/WKPDFView.h        2014-03-08 06:36:02 UTC (rev 165327)
</span><span class="lines">@@ -0,0 +1,35 @@
</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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#if PLATFORM(IOS)
+
+#import &quot;WKWebViewContentProvider.h&quot;
+#import &lt;UIKit/UIView.h&gt;
+
+@interface WKPDFView : UIView &lt;WKWebViewContentProvider&gt;
+
+@end
+
+#endif // PLATFORM(IOS)
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKPDFViewmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm (0 => 165327)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm        2014-03-08 06:36:02 UTC (rev 165327)
</span><span class="lines">@@ -0,0 +1,121 @@
</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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;WKPDFView.h&quot;
+
+#if PLATFORM(IOS)
+
+#import &lt;CorePDF/UIPDFDocument.h&gt;
+#import &lt;CorePDF/UIPDFPageView.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+#import &lt;wtf/Vector.h&gt;
+
+const CGFloat pdfPageMargin = 8;
+const CGFloat pdfMinimumZoomScale = 1;
+const CGFloat pdfMaximumZoomScale = 5;
+
+@implementation WKPDFView {
+    RetainPtr&lt;UIPDFDocument&gt; _pdfDocument;
+    Vector&lt;UIPDFPageView*&gt; _pageViews;
+    CGSize _minimumSize;
+    UIScrollView *_scrollView;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame
+{
+    if (!(self = [super initWithFrame:frame]))
+        return nil;
+
+    self.backgroundColor = [UIColor grayColor];
+
+    return self;
+}
+
+- (void)web_setContentProviderData:(NSData *)data
+{
+    for (auto&amp; pageView : _pageViews)
+        [pageView removeFromSuperview];
+
+    _pageViews.clear();
+
+    RetainPtr&lt;CGDataProvider&gt; dataProvider = adoptCF(CGDataProviderCreateWithCFData((CFDataRef)data));
+    RetainPtr&lt;CGPDFDocumentRef&gt; cgPDFDocument = adoptCF(CGPDFDocumentCreateWithProvider(dataProvider.get()));
+    _pdfDocument = adoptNS([[UIPDFDocument alloc] initWithCGPDFDocument:cgPDFDocument.get()]);
+
+    for (NSUInteger page = 0; page &lt; [_pdfDocument numberOfPages]; ++page) {
+        UIPDFPage *pdfPage = [_pdfDocument pageAtIndex:page];
+
+        // FIXME: We should create and destroy views instead of depending on tiling.
+        RetainPtr&lt;UIPDFPageView&gt; pageView = adoptNS([[UIPDFPageView alloc] initWithPage:pdfPage tiledContent:YES]);
+        [self addSubview:pageView.get()];
+        _pageViews.append(pageView.get());
+
+        [pageView contentLayer].contentsScale = self.window.screen.scale;
+    }
+
+    [self layoutViews];
+}
+
+- (void)web_setMinimumSize:(CGSize)size
+{
+    _minimumSize = size;
+
+    [self layoutViews];
+}
+
+- (void)web_setScrollView:(UIScrollView *)scrollView
+{
+    _scrollView = scrollView;
+}
+
+- (void)layoutViews
+{
+    CGRect pageFrame = CGRectMake(0, 0, _minimumSize.width, _minimumSize.height);
+
+    for (auto&amp; pageView : _pageViews) {
+        CGSize pageSize = [pageView.page size];
+
+        pageFrame.size.height = pageSize.height / pageSize.width * pageFrame.size.width;
+
+        CGRect pageFrameWithMarginApplied = CGRectInset(pageFrame, pdfPageMargin, pdfPageMargin);
+        [pageView setFrame:pageFrameWithMarginApplied];
+
+        pageFrame.origin.y += pageFrame.size.height - pdfPageMargin;
+    }
+
+    CGRect newFrame = [self frame];
+    newFrame.size.width = _minimumSize.width;
+    newFrame.size.height = std::max(pageFrame.origin.y + pdfPageMargin, _minimumSize.height);
+    [self setFrame:newFrame];
+
+    [_scrollView setContentSize:newFrame.size];
+    [_scrollView setMinimumZoomScale:pdfMinimumZoomScale];
+    [_scrollView setMaximumZoomScale:pdfMaximumZoomScale];
+}
+
+@end
+
+#endif /* PLATFORM(IOS) */
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (165326 => 165327)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-03-08 06:34:07 UTC (rev 165326)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-03-08 06:36:02 UTC (rev 165327)
</span><span class="lines">@@ -512,6 +512,8 @@
</span><span class="cx">                 2DA049B4180CCCD300AAFA9E /* PlatformCALayerRemote.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DA049B2180CCCD300AAFA9E /* PlatformCALayerRemote.h */; };
</span><span class="cx">                 2DA049B7180CCD0A00AAFA9E /* GraphicsLayerCARemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2DA049B5180CCD0A00AAFA9E /* GraphicsLayerCARemote.cpp */; };
</span><span class="cx">                 2DA049B8180CCD0A00AAFA9E /* GraphicsLayerCARemote.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DA049B6180CCD0A00AAFA9E /* GraphicsLayerCARemote.h */; };
</span><ins>+                2DA1E4FE18C02B6A00DBC929 /* WKPDFView.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DA1E4FC18C02B6A00DBC929 /* WKPDFView.h */; };
+                2DA1E4FF18C02B6A00DBC929 /* WKPDFView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA1E4FD18C02B6A00DBC929 /* WKPDFView.mm */; };
</ins><span class="cx">                 2DA944951884E3B500ED86DB /* WKViewIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA944861884E3B500ED86DB /* WKViewIOS.mm */; };
</span><span class="cx">                 2DA9449E1884E4F000ED86DB /* NativeWebKeyboardEventIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA944971884E4F000ED86DB /* NativeWebKeyboardEventIOS.mm */; };
</span><span class="cx">                 2DA9449F1884E4F000ED86DB /* NativeWebTouchEventIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA944981884E4F000ED86DB /* NativeWebTouchEventIOS.mm */; };
</span><span class="lines">@@ -2276,6 +2278,8 @@
</span><span class="cx">                 2DA049B2180CCCD300AAFA9E /* PlatformCALayerRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCALayerRemote.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2DA049B5180CCD0A00AAFA9E /* GraphicsLayerCARemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsLayerCARemote.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2DA049B6180CCD0A00AAFA9E /* GraphicsLayerCARemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsLayerCARemote.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                2DA1E4FC18C02B6A00DBC929 /* WKPDFView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKPDFView.h; path = ios/WKPDFView.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                2DA1E4FD18C02B6A00DBC929 /* WKPDFView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKPDFView.mm; path = ios/WKPDFView.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 2DA944861884E3B500ED86DB /* WKViewIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKViewIOS.mm; path = ios/WKViewIOS.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2DA944971884E4F000ED86DB /* NativeWebKeyboardEventIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NativeWebKeyboardEventIOS.mm; path = ios/NativeWebKeyboardEventIOS.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2DA944981884E4F000ED86DB /* NativeWebTouchEventIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NativeWebTouchEventIOS.mm; path = ios/NativeWebTouchEventIOS.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -4356,6 +4360,8 @@
</span><span class="cx">                                 0FCB4E3718BBE044000FCFC9 /* PageClientImplIOS.mm */,
</span><span class="cx">                                 0F0C365718C051BA00F607D7 /* RemoteLayerTreeHostIOS.mm */,
</span><span class="cx">                                 0F0C365B18C05CA100F607D7 /* RemoteScrollingCoordinatorProxyIOS.mm */,
</span><ins>+                                2DA1E4FC18C02B6A00DBC929 /* WKPDFView.h */,
+                                2DA1E4FD18C02B6A00DBC929 /* WKPDFView.mm */,
</ins><span class="cx">                                 2DA944A91884E9BA00ED86DB /* TextCheckerIOS.mm */,
</span><span class="cx">                                 2DF9593418A42412009785A1 /* ViewGestureControllerIOS.mm */,
</span><span class="cx">                                 2DAF06D418BD1A470081CEB1 /* SmartMagnificationController.h */,
</span><span class="lines">@@ -6822,6 +6828,7 @@
</span><span class="cx">                                 BC032D7B10F4378D0058C15A /* WebDragClient.h in Headers */,
</span><span class="cx">                                 BCA0EF9F12332642007D3CFB /* WebEditCommandProxy.h in Headers */,
</span><span class="cx">                                 51064D36189781C4004B2FEB /* SQLiteIDBCursor.h in Headers */,
</span><ins>+                                2DA1E4FE18C02B6A00DBC929 /* WKPDFView.h in Headers */,
</ins><span class="cx">                                 BC032D7D10F4378D0058C15A /* WebEditorClient.h in Headers */,
</span><span class="cx">                                 0F5947A8187B517600437857 /* RemoteScrollingCoordinatorMessages.h in Headers */,
</span><span class="cx">                                 2684055318B86ED60022C38B /* ViewUpdateDispatcherMessages.h in Headers */,
</span><span class="lines">@@ -7986,6 +7993,7 @@
</span><span class="cx">                                 37D0B5C81845232700F6CE7D /* WKErrorRecoveryAttempting.m in Sources */,
</span><span class="cx">                                 CD5C66A0134B9D38004FE2A8 /* InjectedBundlePageFullScreenClient.cpp in Sources */,
</span><span class="cx">                                 755422CB180650020046F6A8 /* WebOriginDataManager.cpp in Sources */,
</span><ins>+                                2DA1E4FF18C02B6A00DBC929 /* WKPDFView.mm in Sources */,
</ins><span class="cx">                                 BCA8C6A811E3BA5F00812FB7 /* InjectedBundlePageLoaderClient.cpp in Sources */,
</span><span class="cx">                                 0FCB4E6718BBE3D9000FCFC9 /* WKPrintingView.mm in Sources */,
</span><span class="cx">                                 1AAB037C185F99D800EDF501 /* APIData.cpp in Sources */,
</span></span></pre>
</div>
</div>

</body>
</html>