<!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>[191922] 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/191922">191922</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2015-11-02 16:25:04 -0800 (Mon, 02 Nov 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>PDFPlugin should take advantage of threaded scrolling
https://bugs.webkit.org/show_bug.cgi?id=150037

Reviewed by Anders Carlsson.

Duplicate PDFPlugin, creating PDFPlugin (the modern version), and
DeprecatedPDFPlugin (containing the code that used to be in PDFPlugin
prior to this patch).

The new PDFPlugin differs from the old one in a few significant ways,
and we need to keep both alive for the time being. Significant differences
include:

- PDFPlugin is no longer a ScrollableArea
- PDFPlugin no longer hosts layers owned by PDFKit; instead, it draws
  into the page tiles, allowing WebCore's threaded scrolling to do its job
- PDFPlugin now resizes itself to the size of the document
- PDFPlugin doesn't handle zooming itself, it just delegates to the page
- PDFLayerController has large and incompatible API changes
- PDFPlugin now implements more of the HUD behavior, but it's still
  painted by PDFLayerController (into a view-relative PageOverlay)

[ File list elided because it's long and useless. ]

* page/PageOverlay.cpp:
(WebCore::PageOverlay::PageOverlay):
(WebCore::PageOverlay::setNeedsDisplay):
Don't reset the overlay layer's opacity if we're not animating,
because it's possible the client wants to manage it.

* page/PageOverlayController.cpp:
(WebCore::PageOverlayController::updateForceSynchronousScrollLayerPositionUpdates):
Let the overlay itself determine whether it needes synchronous scrolling,
and let PageOverlay clients override the default.

* platform/Widget.h:
(WebCore::Widget::boundsRect):
Export a few useful things.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepagePageOverlaycpp">trunk/Source/WebCore/page/PageOverlay.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageOverlayh">trunk/Source/WebCore/page/PageOverlay.h</a></li>
<li><a href="#trunkSourceWebCorepagePageOverlayControllercpp">trunk/Source/WebCore/page/PageOverlayController.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformWidgeth">trunk/Source/WebCore/platform/Widget.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PluginProcessPluginControllerProxycpp">trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2PluginProcessPluginControllerProxyh">trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.h</a></li>
<li><a href="#trunkSourceWebKit2PluginProcessPluginControllerProxymessagesin">trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2SharedmacPDFKitImportsh">trunk/Source/WebKit2/Shared/mac/PDFKitImports.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxymessagesin">trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsNetscapeNetscapePlugincpp">trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsNetscapeNetscapePluginh">trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPDFPDFPluginh">trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPDFPDFPluginmm">trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPDFPDFPluginAnnotationmm">trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginAnnotation.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPDFPDFPluginChoiceAnnotationmm">trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPDFPDFPluginPasswordFieldmm">trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginPasswordField.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPDFPDFPluginTextAnnotationmm">trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPluginh">trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPluginProxycpp">trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPluginProxyh">trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPluginViewcpp">trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPluginViewh">trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebFrameLoaderClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebFramecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebFrameh">trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm">trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPDFDeprecatedPDFLayerControllerSPIh">trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPDFDeprecatedPDFPluginh">trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPDFDeprecatedPDFPluginmm">trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPDFPDFLayerControllerSPIh">trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPDFPDFLayerControllerDetailsh">trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerDetails.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebCore/ChangeLog        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2015-11-02  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        PDFPlugin should take advantage of threaded scrolling
+        https://bugs.webkit.org/show_bug.cgi?id=150037
+
+        Reviewed by Anders Carlsson.
+
+        * page/PageOverlay.cpp:
+        (WebCore::PageOverlay::PageOverlay):
+        (WebCore::PageOverlay::setNeedsDisplay):
+        Don't reset the overlay layer's opacity if we're not animating,
+        because it's possible the client wants to manage it.
+
+        * page/PageOverlayController.cpp:
+        (WebCore::PageOverlayController::updateForceSynchronousScrollLayerPositionUpdates):
+        Let the overlay itself determine whether it needes synchronous scrolling,
+        and let PageOverlay clients override the default.
+
+        * platform/Widget.h:
+        (WebCore::Widget::boundsRect):
+        Export a few useful things.
+
</ins><span class="cx"> 2015-11-02  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Regression(r191673): Crash in RunLoopTimer::schedule()
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageOverlaycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PageOverlay.cpp (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PageOverlay.cpp        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebCore/page/PageOverlay.cpp        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -53,14 +53,10 @@
</span><span class="cx"> 
</span><span class="cx"> PageOverlay::PageOverlay(Client&amp; client, OverlayType overlayType)
</span><span class="cx">     : m_client(client)
</span><del>-    , m_page(nullptr)
</del><span class="cx">     , m_fadeAnimationTimer(*this, &amp;PageOverlay::fadeAnimationTimerFired)
</span><del>-    , m_fadeAnimationStartTime(0)
</del><span class="cx">     , m_fadeAnimationDuration(fadeAnimationDuration)
</span><del>-    , m_fadeAnimationType(NoAnimation)
-    , m_fractionFadedIn(1)
</del><ins>+    , m_needsSynchronousScrolling(overlayType == OverlayType::View)
</ins><span class="cx">     , m_overlayType(overlayType)
</span><del>-    , m_backgroundColor(Color::transparent)
</del><span class="cx">     , m_pageOverlayID(generatePageOverlayID())
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -163,7 +159,8 @@
</span><span class="cx"> void PageOverlay::setNeedsDisplay(const IntRect&amp; dirtyRect)
</span><span class="cx"> {
</span><span class="cx">     if (auto pageOverlayController = controller()) {
</span><del>-        pageOverlayController-&gt;setPageOverlayOpacity(*this, m_fractionFadedIn);
</del><ins>+        if (m_fadeAnimationType != FadeAnimationType::NoAnimation)
+            pageOverlayController-&gt;setPageOverlayOpacity(*this, m_fractionFadedIn);
</ins><span class="cx">         pageOverlayController-&gt;setPageOverlayNeedsDisplay(*this, dirtyRect);
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageOverlayh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PageOverlay.h (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PageOverlay.h        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebCore/page/PageOverlay.h        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -115,6 +115,9 @@
</span><span class="cx">     // FIXME: PageOverlay should own its layer, instead of PageOverlayController.
</span><span class="cx">     WEBCORE_EXPORT GraphicsLayer&amp; layer();
</span><span class="cx"> 
</span><ins>+    bool needsSynchronousScrolling() const { return m_needsSynchronousScrolling; }
+    void setNeedsSynchronousScrolling(bool needsSynchronousScrolling) { m_needsSynchronousScrolling = needsSynchronousScrolling; }
+
</ins><span class="cx"> private:
</span><span class="cx">     explicit PageOverlay(Client&amp;, OverlayType);
</span><span class="cx"> 
</span><span class="lines">@@ -122,10 +125,10 @@
</span><span class="cx">     void fadeAnimationTimerFired();
</span><span class="cx"> 
</span><span class="cx">     Client&amp; m_client;
</span><del>-    Page* m_page;
</del><ins>+    Page* m_page { nullptr };
</ins><span class="cx"> 
</span><span class="cx">     Timer m_fadeAnimationTimer;
</span><del>-    double m_fadeAnimationStartTime;
</del><ins>+    double m_fadeAnimationStartTime { 0 };
</ins><span class="cx">     double m_fadeAnimationDuration;
</span><span class="cx"> 
</span><span class="cx">     enum FadeAnimationType {
</span><span class="lines">@@ -134,13 +137,15 @@
</span><span class="cx">         FadeOutAnimation,
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    FadeAnimationType m_fadeAnimationType;
-    float m_fractionFadedIn;
</del><ins>+    FadeAnimationType m_fadeAnimationType { NoAnimation };
+    float m_fractionFadedIn { 1 };
</ins><span class="cx"> 
</span><ins>+    bool m_needsSynchronousScrolling;
+
</ins><span class="cx">     OverlayType m_overlayType;
</span><span class="cx">     IntRect m_overrideFrame;
</span><span class="cx"> 
</span><del>-    RGBA32 m_backgroundColor;
</del><ins>+    RGBA32 m_backgroundColor { Color::transparent };
</ins><span class="cx">     PageOverlayID m_pageOverlayID;
</span><span class="cx"> 
</span><span class="cx">     bool m_shouldIgnoreMouseEventsOutsideBounds { true };
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageOverlayControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PageOverlayController.cpp (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PageOverlayController.cpp        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebCore/page/PageOverlayController.cpp        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -163,7 +163,7 @@
</span><span class="cx">     bool forceSynchronousScrollLayerPositionUpdates = false;
</span><span class="cx"> 
</span><span class="cx">     for (auto&amp; overlay : m_pageOverlays) {
</span><del>-        if (overlay-&gt;overlayType() == PageOverlay::OverlayType::View)
</del><ins>+        if (overlay-&gt;needsSynchronousScrolling())
</ins><span class="cx">             forceSynchronousScrollLayerPositionUpdates = true;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformWidgeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Widget.h (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Widget.h        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebCore/platform/Widget.h        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -110,7 +110,7 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT virtual void setFrameRect(const IntRect&amp;);
</span><span class="cx">     WEBCORE_EXPORT IntRect frameRect() const;
</span><del>-    IntRect boundsRect() const { return IntRect(0, 0, width(),  height()); }
</del><ins>+    WEBCORE_EXPORT IntRect boundsRect() const { return IntRect(0, 0, width(),  height()); }
</ins><span class="cx"> 
</span><span class="cx">     void resize(int w, int h) { setFrameRect(IntRect(x(), y(), w, h)); }
</span><span class="cx">     void resize(const IntSize&amp; s) { setFrameRect(IntRect(location(), s)); }
</span><span class="lines">@@ -151,7 +151,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void notifyWidget(WidgetNotification) { }
</span><span class="cx"> 
</span><del>-    IntRect convertToRootView(const IntRect&amp;) const;
</del><ins>+    WEBCORE_EXPORT IntRect convertToRootView(const IntRect&amp;) const;
</ins><span class="cx">     IntRect convertFromRootView(const IntRect&amp;) const;
</span><span class="cx"> 
</span><span class="cx">     IntPoint convertToRootView(const IntPoint&amp;) const;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/ChangeLog        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2015-11-02  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        PDFPlugin should take advantage of threaded scrolling
+        https://bugs.webkit.org/show_bug.cgi?id=150037
+
+        Reviewed by Anders Carlsson.
+
+        Duplicate PDFPlugin, creating PDFPlugin (the modern version), and
+        DeprecatedPDFPlugin (containing the code that used to be in PDFPlugin
+        prior to this patch).
+
+        The new PDFPlugin differs from the old one in a few significant ways,
+        and we need to keep both alive for the time being. Significant differences
+        include:
+
+        - PDFPlugin is no longer a ScrollableArea
+        - PDFPlugin no longer hosts layers owned by PDFKit; instead, it draws
+          into the page tiles, allowing WebCore's threaded scrolling to do its job
+        - PDFPlugin now resizes itself to the size of the document
+        - PDFPlugin doesn't handle zooming itself, it just delegates to the page
+        - PDFLayerController has large and incompatible API changes
+        - PDFPlugin now implements more of the HUD behavior, but it's still
+          painted by PDFLayerController (into a view-relative PageOverlay)
+
+        [ File list elided because it's long and useless. ]
+
</ins><span class="cx"> 2015-11-02  Andy Estes  &lt;aestes@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Cocoa] Add tvOS and watchOS to SUPPORTED_PLATFORMS
</span></span></pre></div>
<a id="trunkSourceWebKit2PluginProcessPluginControllerProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -565,6 +565,11 @@
</span><span class="cx">     isHandled = m_plugin-&gt;handlesPageScaleFactor();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PluginControllerProxy::requiresUnifiedScaleFactor(bool&amp; required)
+{
+    required = m_plugin-&gt;requiresUnifiedScaleFactor();
+}
+
</ins><span class="cx"> void PluginControllerProxy::paintEntirePlugin()
</span><span class="cx"> {
</span><span class="cx">     if (m_pluginSize.isEmpty())
</span></span></pre></div>
<a id="trunkSourceWebKit2PluginProcessPluginControllerProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.h (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.h        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.h        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -144,6 +144,7 @@
</span><span class="cx">     void handleEditingCommand(const String&amp;, const String&amp;, bool&amp;);
</span><span class="cx">     void isEditingCommandEnabled(const String&amp;, bool&amp;);
</span><span class="cx">     void handlesPageScaleFactor(bool&amp;);
</span><ins>+    void requiresUnifiedScaleFactor(bool&amp;);
</ins><span class="cx">     void paintEntirePlugin();
</span><span class="cx">     void supportsSnapshotting(bool&amp;);
</span><span class="cx">     void snapshot(ShareableBitmap::Handle&amp; backingStoreHandle);
</span></span></pre></div>
<a id="trunkSourceWebKit2PluginProcessPluginControllerProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -89,6 +89,9 @@
</span><span class="cx">     # Return whether or not a plugin wants to handle page scale factor itself.
</span><span class="cx">     HandlesPageScaleFactor() -&gt; (bool enabled);
</span><span class="cx"> 
</span><ins>+    # Return whether or not a plugin wants page scale, page zoom, and text zoom all to affect page scale.
+    RequiresUnifiedScaleFactor() -&gt; (bool required);
+
</ins><span class="cx">     # Sent when the plug-in focus changes.
</span><span class="cx">     SetFocus(bool isFocused)
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacPDFKitImportsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/PDFKitImports.h (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/PDFKitImports.h        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/Shared/mac/PDFKitImports.h        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -26,6 +26,12 @@
</span><span class="cx"> #ifndef PDFKitImports_h
</span><span class="cx"> #define PDFKitImports_h
</span><span class="cx"> 
</span><ins>+#if __has_include(&lt;PDFKit/PDFLayerControllerVersioningPriv.h&gt;)
+#import &lt;PDFKit/PDFLayerControllerVersioningPriv.h&gt;
+#endif
+
+#define USE_DEPRECATED_PDF_PLUGIN (!defined(PDFKIT_HAS_PDFLAYERCONTROLLER_2) || !PDFKIT_HAS_PDFLAYERCONTROLLER_2)
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> NSString *pdfKitFrameworkPath();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -2251,7 +2251,7 @@
</span><span class="cx"> {
</span><span class="cx">     // Zoom factor for non-PDF pages persists across page loads. We maintain a separate member variable for PDF
</span><span class="cx">     // zoom which ensures that we don't use the PDF zoom for a normal page.
</span><del>-    if (m_mainFrame &amp;&amp; m_mainFrame-&gt;isDisplayingPDFDocument())
</del><ins>+    if (m_mainFramePluginHandlesPageScaleGesture)
</ins><span class="cx">         return m_pluginZoomFactor;
</span><span class="cx">     return m_pageZoomFactor;
</span><span class="cx"> }
</span><span class="lines">@@ -2260,7 +2260,7 @@
</span><span class="cx"> {
</span><span class="cx">     // PDF documents use zoom and scale factors to size themselves appropriately in the window. We store them
</span><span class="cx">     // separately but decide which to return based on the main frame.
</span><del>-    if (m_mainFrame &amp;&amp; m_mainFrame-&gt;isDisplayingPDFDocument())
</del><ins>+    if (m_mainFramePluginHandlesPageScaleGesture)
</ins><span class="cx">         return m_pluginScaleFactor;
</span><span class="cx">     return m_pageScaleFactor;
</span><span class="cx"> }
</span><span class="lines">@@ -2957,7 +2957,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String&amp; mimeType, bool frameHasCustomContentProvider, uint32_t opaqueFrameLoadType, const WebCore::CertificateInfo&amp; certificateInfo, bool containsPluginDocument, const UserData&amp; userData)
</del><ins>+void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String&amp; mimeType, bool frameHasCustomContentProvider, bool pluginHandlesPageScaleGesture, uint32_t opaqueFrameLoadType, const WebCore::CertificateInfo&amp; certificateInfo, bool containsPluginDocument, const UserData&amp; userData)
</ins><span class="cx"> {
</span><span class="cx">     PageClientProtector protector(m_pageClient);
</span><span class="cx"> 
</span><span class="lines">@@ -3016,9 +3016,13 @@
</span><span class="cx">     // WebPageProxy's cache of the value can get out of sync (e.g. in the case where a
</span><span class="cx">     // plugin is handling page scaling itself) so we should reset it to the default
</span><span class="cx">     // for standard main frame loads.
</span><del>-    if (frame-&gt;isMainFrame() &amp;&amp; static_cast&lt;FrameLoadType&gt;(opaqueFrameLoadType) == FrameLoadType::Standard) {
-        m_pageScaleFactor = 1;
-        m_pluginScaleFactor = 1;
</del><ins>+    if (frame-&gt;isMainFrame()) {
+        m_mainFramePluginHandlesPageScaleGesture = pluginHandlesPageScaleGesture;
+
+        if (static_cast&lt;FrameLoadType&gt;(opaqueFrameLoadType) == FrameLoadType::Standard) {
+            m_pageScaleFactor = 1;
+            m_pluginScaleFactor = 1;
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_pageLoadState.commitChanges();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -1122,7 +1122,7 @@
</span><span class="cx">     void didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String&amp;, const UserData&amp;);
</span><span class="cx">     void didChangeProvisionalURLForFrame(uint64_t frameID, uint64_t navigationID, const String&amp; url);
</span><span class="cx">     void didFailProvisionalLoadForFrame(uint64_t frameID, const WebCore::SecurityOriginData&amp; frameSecurityOrigin, uint64_t navigationID, const String&amp; provisionalURL, const WebCore::ResourceError&amp;, const UserData&amp;);
</span><del>-    void didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String&amp; mimeType, bool frameHasCustomContentProvider, uint32_t frameLoadType, const WebCore::CertificateInfo&amp;, bool containsPluginDocument, const UserData&amp;);
</del><ins>+    void didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String&amp; mimeType, bool frameHasCustomContentProvider, bool mainFramePluginHandlesPageScaleGesture, uint32_t frameLoadType, const WebCore::CertificateInfo&amp;, bool containsPluginDocument, const UserData&amp;);
</ins><span class="cx">     void didFinishDocumentLoadForFrame(uint64_t frameID, uint64_t navigationID, const UserData&amp;);
</span><span class="cx">     void didFinishLoadForFrame(uint64_t frameID, uint64_t navigationID, const UserData&amp;);
</span><span class="cx">     void didFailLoadForFrame(uint64_t frameID, uint64_t navigationID, const WebCore::ResourceError&amp;, const UserData&amp;);
</span><span class="lines">@@ -1719,6 +1719,8 @@
</span><span class="cx">     bool m_shouldRecordNavigationSnapshots;
</span><span class="cx">     bool m_isShowingNavigationGestureSnapshot;
</span><span class="cx"> 
</span><ins>+    bool m_mainFramePluginHandlesPageScaleGesture { false };
+
</ins><span class="cx">     unsigned m_pageCount;
</span><span class="cx"> 
</span><span class="cx">     WebCore::IntRect m_visibleScrollerThumbRect;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -126,7 +126,7 @@
</span><span class="cx">     DidReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, String url, WebKit::UserData userData)
</span><span class="cx">     DidChangeProvisionalURLForFrame(uint64_t frameID, uint64_t navigationID, String url)
</span><span class="cx">     DidFailProvisionalLoadForFrame(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, uint64_t navigationID, String provisionalURL, WebCore::ResourceError error, WebKit::UserData userData)
</span><del>-    DidCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, String mimeType, bool hasCustomContentProvider, uint32_t loadType, WebCore::CertificateInfo certificateInfo, bool containsPluginDocument, WebKit::UserData userData)
</del><ins>+    DidCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, String mimeType, bool hasCustomContentProvider, bool pluginHandlesPageScaleGesture, uint32_t loadType, WebCore::CertificateInfo certificateInfo, bool containsPluginDocument, WebKit::UserData userData)
</ins><span class="cx">     DidFailLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::ResourceError error, WebKit::UserData userData)
</span><span class="cx">     DidFinishDocumentLoadForFrame(uint64_t frameID, uint64_t navigationID, WebKit::UserData userData)
</span><span class="cx">     DidFinishLoadForFrame(uint64_t frameID, uint64_t navigationID, WebKit::UserData userData)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -608,6 +608,7 @@
</span><span class="cx">                 2D2ADF0916362DD500197E47 /* PDFPluginTextAnnotation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D2ADF0616362DC700197E47 /* PDFPluginTextAnnotation.mm */; };
</span><span class="cx">                 2D2ADF0B16362DDB00197E47 /* PDFPluginAnnotation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D2ADF031636243500197E47 /* PDFPluginAnnotation.mm */; };
</span><span class="cx">                 2D2ADF1016364D8200197E47 /* PDFPluginChoiceAnnotation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D2ADF0E16364D8200197E47 /* PDFPluginChoiceAnnotation.mm */; };
</span><ins>+                2D3494641BCC2EC30064F0BE /* DeprecatedPDFPlugin.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D0035231BC7414800DA8716 /* DeprecatedPDFPlugin.mm */; };
</ins><span class="cx">                 2D3A65DA1A7C3A1F00CAC637 /* WKNavigationActionRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D3A65D81A7C3A1F00CAC637 /* WKNavigationActionRef.cpp */; };
</span><span class="cx">                 2D3A65DB1A7C3A1F00CAC637 /* WKNavigationActionRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3A65D91A7C3A1F00CAC637 /* WKNavigationActionRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 2D3A65DE1A7C3A7D00CAC637 /* WKNavigationResponseRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D3A65DC1A7C3A7D00CAC637 /* WKNavigationResponseRef.cpp */; };
</span><span class="lines">@@ -2760,6 +2761,8 @@
</span><span class="cx">                 29D55DEE161BF8780031A2E3 /* WebPageGroupProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebPageGroupProxy.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 29D55DEF161BF9F10031A2E3 /* WebPageGroupProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPageGroupProxyMessageReceiver.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 29D55DF0161BF9F10031A2E3 /* WebPageGroupProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPageGroupProxyMessages.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                2D0035221BC7414800DA8716 /* DeprecatedPDFPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DeprecatedPDFPlugin.h; path = PDF/DeprecatedPDFPlugin.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                2D0035231BC7414800DA8716 /* DeprecatedPDFPlugin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DeprecatedPDFPlugin.mm; path = PDF/DeprecatedPDFPlugin.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 2D125C5C1857EA05003BA3CB /* ViewGestureController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewGestureController.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D125C5D1857EA05003BA3CB /* ViewGestureControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewGestureControllerMac.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D1B5D5A18586599006C6596 /* ViewGestureController.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = ViewGestureController.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -2777,9 +2780,10 @@
</span><span class="cx">                 2D2ADF031636243500197E47 /* PDFPluginAnnotation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPluginAnnotation.mm; path = PDF/PDFPluginAnnotation.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D2ADF0516362DC700197E47 /* PDFPluginTextAnnotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPluginTextAnnotation.h; path = PDF/PDFPluginTextAnnotation.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D2ADF0616362DC700197E47 /* PDFPluginTextAnnotation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPluginTextAnnotation.mm; path = PDF/PDFPluginTextAnnotation.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                2D2ADF0C16363DEC00197E47 /* PDFLayerControllerDetails.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PDFLayerControllerDetails.h; path = PDF/PDFLayerControllerDetails.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><ins>+                2D2ADF0C16363DEC00197E47 /* DeprecatedPDFLayerControllerSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DeprecatedPDFLayerControllerSPI.h; path = PDF/DeprecatedPDFLayerControllerSPI.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 2D2ADF0D16364D8200197E47 /* PDFPluginChoiceAnnotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPluginChoiceAnnotation.h; path = PDF/PDFPluginChoiceAnnotation.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D2ADF0E16364D8200197E47 /* PDFPluginChoiceAnnotation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPluginChoiceAnnotation.mm; path = PDF/PDFPluginChoiceAnnotation.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                2D3494631BCC23BF0064F0BE /* PDFLayerControllerSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PDFLayerControllerSPI.h; path = PDF/PDFLayerControllerSPI.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 2D3A65D81A7C3A1F00CAC637 /* WKNavigationActionRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKNavigationActionRef.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D3A65D91A7C3A1F00CAC637 /* WKNavigationActionRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNavigationActionRef.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D3A65DC1A7C3A7D00CAC637 /* WKNavigationResponseRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKNavigationResponseRef.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -7500,7 +7504,10 @@
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><span class="cx">                                 3574B37F1665932C00859BB7 /* PDFAnnotationTextWidgetDetails.h */,
</span><del>-                                2D2ADF0C16363DEC00197E47 /* PDFLayerControllerDetails.h */,
</del><ins>+                                2D2ADF0C16363DEC00197E47 /* DeprecatedPDFLayerControllerSPI.h */,
+                                2D0035221BC7414800DA8716 /* DeprecatedPDFPlugin.h */,
+                                2D0035231BC7414800DA8716 /* DeprecatedPDFPlugin.mm */,
+                                2D3494631BCC23BF0064F0BE /* PDFLayerControllerSPI.h */,
</ins><span class="cx">                                 2D870D0D1622B7F9000A3F20 /* PDFPlugin.h */,
</span><span class="cx">                                 2D870D0E1622B7F9000A3F20 /* PDFPlugin.mm */,
</span><span class="cx">                                 2D2ADF021636243500197E47 /* PDFPluginAnnotation.h */,
</span><span class="lines">@@ -10195,6 +10202,7 @@
</span><span class="cx">                                 BCBAACEC145225E30053F82F /* WKProcessGroup.mm in Sources */,
</span><span class="cx">                                 1A158419189044F50017616C /* WKProcessPool.mm in Sources */,
</span><span class="cx">                                 512F58FB12A88A5400629530 /* WKProtectionSpace.cpp in Sources */,
</span><ins>+                                2D3494641BCC2EC30064F0BE /* DeprecatedPDFPlugin.mm in Sources */,
</ins><span class="cx">                                 1AD01BCC1905D54900C9C45F /* WKReloadFrameErrorRecoveryAttempter.mm in Sources */,
</span><span class="cx">                                 1A9E329A1822E1CC00F5D04C /* WKRemoteObject.mm in Sources */,
</span><span class="cx">                                 1A9E329E1822FEDD00F5D04C /* WKRemoteObjectCoder.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsNetscapeNetscapePlugincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -997,7 +997,7 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool NetscapePlugin::handlesPageScaleFactor()
</del><ins>+bool NetscapePlugin::handlesPageScaleFactor() const
</ins><span class="cx"> {
</span><span class="cx">     return false;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsNetscapeNetscapePluginh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -225,7 +225,7 @@
</span><span class="cx">     virtual bool shouldAllowScripting() override;
</span><span class="cx">     virtual bool shouldAllowNavigationFromDrags() override;
</span><span class="cx">     
</span><del>-    virtual bool handlesPageScaleFactor() override;
</del><ins>+    virtual bool handlesPageScaleFactor() const override;
</ins><span class="cx"> 
</span><span class="cx">     virtual NPObject* pluginScriptableNPObject() override;
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFDeprecatedPDFLayerControllerSPIh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h (0 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -0,0 +1,158 @@
</span><ins>+/*
+ * Copyright (C) 2012, 2015 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.
+ */
+
+#ifndef DeprecatedPDFLayerControllerSPI_h
+#define DeprecatedPDFLayerControllerSPI_h
+
+#if ENABLE(PDFKIT_PLUGIN) &amp;&amp; USE(DEPRECATED_PDF_PLUGIN)
+
+#import &lt;PDFKit/PDFKit.h&gt;
+
+@class CPReadingModel;
+@class PDFViewLayout;
+
+@protocol PDFLayerControllerDelegate &lt;NSObject&gt;
+
+- (void)updateScrollPosition:(CGPoint)newPosition;
+- (void)writeItemsToPasteboard:(NSArray *)items withTypes:(NSArray *)types;
+- (void)showDefinitionForAttributedString:(NSAttributedString *)string atPoint:(CGPoint)point;
+- (void)performWebSearch:(NSString *)string;
+- (void)performSpotlightSearch:(NSString *)string;
+- (void)openWithNativeApplication;
+- (void)saveToPDF;
+
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeActiveAnnotation:(PDFAnnotation *)annotation;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController clickedLinkWithURL:(NSURL *)url;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeContentScaleFactor:(CGFloat)scaleFactor;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeDisplayMode:(int)mode;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeSelection:(PDFSelection *)selection;
+
+@end
+
+@interface PDFLayerController : NSObject
+@end
+
+@interface PDFLayerController ()
+
+@property (retain) CALayer *parentLayer;
+@property (retain) PDFDocument *document;
+@property (retain) id&lt;PDFLayerControllerDelegate&gt; delegate;
+
+- (void)setFrameSize:(CGSize)size;
+
+- (PDFDisplayMode)displayMode;
+- (void)setDisplayMode:(PDFDisplayMode)mode;
+- (void)setDisplaysPageBreaks:(BOOL)pageBreaks;
+
+- (CGFloat)contentScaleFactor;
+- (void)setContentScaleFactor:(CGFloat)scaleFactor;
+
+- (CGFloat)deviceScaleFactor;
+- (void)setDeviceScaleFactor:(CGFloat)scaleFactor;
+
+- (CGSize)contentSize;
+- (CGSize)contentSizeRespectingZoom;
+
+- (void)snapshotInContext:(CGContextRef)context;
+
+- (void)magnifyWithMagnification:(CGFloat)magnification atPoint:(CGPoint)point immediately:(BOOL)immediately;
+
+- (CGPoint)scrollPosition;
+- (void)setScrollPosition:(CGPoint)newPosition;
+- (void)scrollWithDelta:(CGSize)delta;
+
+- (void)mouseDown:(NSEvent *)event;
+- (void)rightMouseDown:(NSEvent *)event;
+- (void)mouseMoved:(NSEvent *)event;
+- (void)mouseUp:(NSEvent *)event;
+- (void)mouseDragged:(NSEvent *)event;
+- (void)mouseEntered:(NSEvent *)event;
+- (void)mouseExited:(NSEvent *)event;
+
+- (NSMenu *)menuForEvent:(NSEvent *)event;
+
+- (NSArray *)findString:(NSString *)string caseSensitive:(BOOL)isCaseSensitive highlightMatches:(BOOL)shouldHighlightMatches;
+
+- (PDFSelection *)currentSelection;
+- (void)setCurrentSelection:(PDFSelection *)selection;
+- (PDFSelection *)searchSelection;
+- (void)setSearchSelection:(PDFSelection *)selection;
+- (void)gotoSelection:(PDFSelection *)selection;
+- (PDFSelection *)getSelectionForWordAtPoint:(CGPoint)point;
+- (NSArray *)rectsForSelectionInLayoutSpace:(PDFSelection *)selection;
+- (NSArray *)rectsForAnnotationInLayoutSpace:(PDFAnnotation *)annotation;
+- (PDFViewLayout *)layout;
+- (NSRect)frame;
+
+- (PDFPage *)currentPage;
+- (NSUInteger)lastPageIndex;
+- (NSUInteger)currentPageIndex;
+- (void)gotoNextPage;
+- (void)gotoPreviousPage;
+
+- (void)copySelection;
+- (void)selectAll;
+
+- (bool)keyDown:(NSEvent *)event;
+
+- (void)setHUDEnabled:(BOOL)enabled;
+- (BOOL)hudEnabled;
+
+- (CGRect)boundsForAnnotation:(PDFAnnotation *)annotation;
+- (void)activateNextAnnotation:(BOOL)previous;
+
+- (void)attemptToUnlockWithPassword:(NSString *)password;
+
+- (void)searchInDictionaryWithSelection:(PDFSelection *)selection;
+
+// Accessibility
+
+- (CPReadingModel *)readingModel;
+- (id)accessibilityFocusedUIElement;
+- (NSArray *)accessibilityAttributeNames;
+- (BOOL)accessibilityIsAttributeSettable:(NSString *)attribute;
+- (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute;
+- (NSArray *)accessibilityParameterizedAttributeNames;
+- (NSString *)accessibilityRoleAttribute;
+- (NSString *)accessibilityRoleDescriptionAttribute;
+- (NSString *)accessibilityValueAttribute;
+- (BOOL)accessibilityIsValueAttributeSettable;
+- (NSString *)accessibilitySelectedTextAttribute;
+- (BOOL)accessibilityIsSelectedTextAttributeSettable;
+- (NSValue *)accessibilitySelectedTextRangeAttribute;
+- (NSNumber *)accessibilityNumberOfCharactersAttribute;
+- (BOOL)accessibilityIsNumberOfCharactersAttributeSettable;
+- (NSValue *)accessibilityVisibleCharacterRangeAttribute;
+- (BOOL)accessibilityIsVisibleCharacterRangeAttributeSettable;
+- (NSNumber *)accessibilityLineForIndexAttributeForParameter:(id)parameter;
+- (NSValue *)accessibilityRangeForLineAttributeForParameter:(id)parameter;
+- (NSString *)accessibilityStringForRangeAttributeForParameter:(id)parameter;
+- (NSValue *)accessibilityBoundsForRangeAttributeForParameter:(id)parameter;
+
+@end
+
+#endif
+
+#endif // DeprecatedPDFLayerControllerSPI_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFDeprecatedPDFPluginh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h (0 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -0,0 +1,322 @@
</span><ins>+/*
+ * Copyright (C) 2011, 2012, 2015 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.
+ */
+
+#ifndef DeprecatedPDFPlugin_h
+#define DeprecatedPDFPlugin_h
+
+#include &quot;PDFKitImports.h&quot;
+
+#if ENABLE(PDFKIT_PLUGIN) &amp;&amp; USE(DEPRECATED_PDF_PLUGIN)
+
+#include &quot;Plugin.h&quot;
+#include &quot;WebEvent.h&quot;
+#include &quot;WebHitTestResultData.h&quot;
+#include &lt;WebCore/AffineTransform.h&gt;
+#include &lt;WebCore/FindOptions.h&gt;
+#include &lt;WebCore/ScrollableArea.h&gt;
+#include &lt;wtf/RetainPtr.h&gt;
+
+typedef const struct OpaqueJSContext* JSContextRef;
+typedef struct OpaqueJSValue* JSObjectRef;
+typedef const struct OpaqueJSValue* JSValueRef;
+
+OBJC_CLASS NSArray;
+OBJC_CLASS NSAttributedString;
+OBJC_CLASS NSData;
+OBJC_CLASS NSString;
+OBJC_CLASS PDFAnnotation;
+OBJC_CLASS PDFLayerController;
+OBJC_CLASS PDFSelection;
+OBJC_CLASS WKPDFPluginAccessibilityObject;
+OBJC_CLASS WKPDFLayerControllerDelegate;
+
+namespace IPC {
+class DataReference;
+}
+
+namespace WebCore {
+class Element;
+struct PluginInfo;
+}
+
+namespace WebKit {
+
+class PDFPluginAnnotation;
+class PDFPluginPasswordField;
+class PluginView;
+class WebFrame;
+
+class PDFPlugin final : public Plugin, private WebCore::ScrollableArea {
+public:
+    static Ref&lt;PDFPlugin&gt; create(WebFrame*);
+    ~PDFPlugin();
+
+    static WebCore::PluginInfo pluginInfo();
+
+    WebCore::IntSize size() const { return m_size; }
+
+    void didMutatePDFDocument() { m_pdfDocumentWasMutated = true; }
+
+    void paintControlForLayerInContext(CALayer *, CGContextRef);
+    void setActiveAnnotation(PDFAnnotation *);
+    
+    using ScrollableArea::notifyScrollPositionChanged;
+    void notifyContentScaleFactorChanged(CGFloat scaleFactor);
+    void notifyDisplayModeChanged(int);
+
+    void notifySelectionChanged(PDFSelection *);
+
+    void clickedLink(NSURL *);
+    void saveToPDF();
+    void openWithNativeApplication();
+    void writeItemsToPasteboard(NSString *pasteboardName, NSArray *items, NSArray *types);
+    void showDefinitionForAttributedString(NSAttributedString *, CGPoint);
+    void performWebSearch(NSString *);
+    void performSpotlightSearch(NSString *);
+
+    void focusNextAnnotation();
+    void focusPreviousAnnotation();
+
+    void attemptToUnlockPDF(const String&amp; password);
+
+    WebCore::FloatRect convertFromPDFViewToScreen(const WebCore::FloatRect&amp;) const;
+    WebCore::IntRect boundsOnScreen() const;
+    
+    bool showContextMenuAtPoint(const WebCore::IntPoint&amp;);
+
+    String lookupTextAtLocation(const WebCore::FloatPoint&amp;, WebHitTestResultData&amp;, PDFSelection **, NSDictionary **) const;
+    WebCore::FloatRect rectForSelectionInRootView(PDFSelection *) const;
+
+    CGFloat scaleFactor() const;
+
+private:
+    explicit PDFPlugin(WebFrame*);
+
+    // Plugin functions.
+    virtual bool initialize(const Parameters&amp;) override;
+    virtual void destroy() override;
+    virtual void paint(WebCore::GraphicsContext&amp;, const WebCore::IntRect&amp; dirtyRectInWindowCoordinates) override { }
+    virtual void updateControlTints(WebCore::GraphicsContext&amp;) override;
+    virtual bool supportsSnapshotting() const override { return true; }
+    virtual RefPtr&lt;ShareableBitmap&gt; snapshot() override;
+    virtual PlatformLayer* pluginLayer() override;
+    virtual bool isTransparent() override { return false; }
+    virtual bool wantsWheelEvents() override { return true; }
+    virtual void geometryDidChange(const WebCore::IntSize&amp; pluginSize, const WebCore::IntRect&amp; clipRect, const WebCore::AffineTransform&amp; pluginToRootViewTransform) override;
+    virtual void contentsScaleFactorChanged(float) override;
+    virtual void visibilityDidChange(bool) override { }
+    virtual void frameDidFinishLoading(uint64_t requestID) override;
+    virtual void frameDidFail(uint64_t requestID, bool wasCancelled) override;
+    virtual void didEvaluateJavaScript(uint64_t requestID, const String&amp; result) override;
+    virtual void streamWillSendRequest(uint64_t streamID, const WebCore::URL&amp; requestURL, const WebCore::URL&amp; responseURL, int responseStatus) override { }
+    virtual void streamDidReceiveResponse(uint64_t streamID, const WebCore::URL&amp; responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const String&amp; mimeType, const String&amp; headers, const String&amp; suggestedFileName) override;
+    virtual void streamDidReceiveData(uint64_t streamID, const char* bytes, int length) override;
+    virtual void streamDidFinishLoading(uint64_t streamID) override;
+    virtual void streamDidFail(uint64_t streamID, bool wasCancelled) override;
+    virtual void manualStreamDidReceiveResponse(const WebCore::URL&amp; responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const WTF::String&amp; mimeType, const WTF::String&amp; headers, const String&amp; suggestedFileName) override;
+    virtual void manualStreamDidReceiveData(const char* bytes, int length) override;
+    virtual void manualStreamDidFinishLoading() override;
+    virtual void manualStreamDidFail(bool wasCancelled) override;
+    virtual bool handleMouseEvent(const WebMouseEvent&amp;) override;
+    virtual bool handleWheelEvent(const WebWheelEvent&amp;) override;
+    virtual bool handleMouseEnterEvent(const WebMouseEvent&amp;) override;
+    virtual bool handleMouseLeaveEvent(const WebMouseEvent&amp;) override;
+    virtual bool handleContextMenuEvent(const WebMouseEvent&amp;) override;
+    virtual bool handleKeyboardEvent(const WebKeyboardEvent&amp;) override;
+    virtual bool handleEditingCommand(const String&amp; commandName, const String&amp; argument) override;
+    virtual bool isEditingCommandEnabled(const String&amp;) override;
+    virtual bool handlesPageScaleFactor() const override;
+    virtual void setFocus(bool) override { }
+    virtual NPObject* pluginScriptableNPObject() override { return 0; }
+    virtual void windowFocusChanged(bool) override { }
+    virtual void windowAndViewFramesChanged(const WebCore::IntRect&amp; windowFrameInScreenCoordinates, const WebCore::IntRect&amp; viewFrameInWindowCoordinates) override { }
+    virtual void windowVisibilityChanged(bool) override { }
+    virtual uint64_t pluginComplexTextInputIdentifier() const override { return 0; }
+    virtual void sendComplexTextInput(const String&amp; textInput) override { }
+    virtual void setLayerHostingMode(LayerHostingMode) override { }
+    virtual WebCore::Scrollbar* horizontalScrollbar() override { return m_horizontalScrollbar.get(); }
+    virtual WebCore::Scrollbar* verticalScrollbar() override { return m_verticalScrollbar.get(); }
+    virtual void storageBlockingStateChanged(bool) override { }
+    virtual void privateBrowsingStateChanged(bool) override { }
+    virtual bool getFormValue(String&amp; formValue) override { return false; }
+    virtual bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity) override;
+    virtual RefPtr&lt;WebCore::SharedBuffer&gt; liveResourceData() const override;
+
+    virtual bool isBeingAsynchronouslyInitialized() const override { return false; }
+
+    virtual RetainPtr&lt;PDFDocument&gt; pdfDocumentForPrinting() const override { return m_pdfDocument; }
+    virtual NSObject *accessibilityObject() const override;
+
+    virtual unsigned countFindMatches(const String&amp; target, WebCore::FindOptions, unsigned maxMatchCount) override;
+    virtual bool findString(const String&amp; target, WebCore::FindOptions, unsigned maxMatchCount) override;
+
+    PDFSelection *nextMatchForString(const String&amp; target, BOOL searchForward, BOOL caseSensitive, BOOL wrapSearch, PDFSelection *initialSelection, BOOL startInSelection);
+
+    bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&amp;) override;
+    String getSelectionString() const override;
+    String getSelectionForWordAtPoint(const WebCore::FloatPoint&amp;) const override;
+    bool existingSelectionContainsPoint(const WebCore::FloatPoint&amp;) const override;
+
+    virtual bool shouldAllowScripting() override { return false; }
+    virtual bool shouldAllowNavigationFromDrags() override { return true; }
+    virtual bool shouldAlwaysAutoStart() const override { return true; }
+
+    // ScrollableArea functions.
+    virtual WebCore::IntRect scrollCornerRect() const override;
+    virtual WebCore::ScrollableArea* enclosingScrollableArea() const override;
+    virtual bool isScrollableOrRubberbandable() override { return true; }
+    virtual bool hasScrollableOrRubberbandableAncestor() override { return true; }
+    virtual WebCore::IntRect scrollableAreaBoundingBox() const override;
+    virtual void setScrollOffset(const WebCore::IntPoint&amp;) override;
+    virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&amp;) override;
+    virtual void invalidateScrollCornerRect(const WebCore::IntRect&amp;) override;
+    virtual WebCore::IntPoint lastKnownMousePosition() const override { return m_lastMousePositionInPluginCoordinates; }
+    virtual int scrollSize(WebCore::ScrollbarOrientation) const override;
+    virtual bool isActive() const override;
+    virtual bool isScrollCornerVisible() const override { return false; }
+    virtual int scrollPosition(WebCore::Scrollbar*) const override;
+    virtual WebCore::IntPoint scrollPosition() const override;
+    virtual WebCore::IntPoint minimumScrollPosition() const override;
+    virtual WebCore::IntPoint maximumScrollPosition() const override;
+    virtual WebCore::IntSize visibleSize() const override { return m_size; }
+    virtual WebCore::IntSize contentsSize() const override { return m_pdfDocumentSize; }
+    virtual WebCore::Scrollbar* horizontalScrollbar() const override { return m_horizontalScrollbar.get(); }
+    virtual WebCore::Scrollbar* verticalScrollbar() const override { return m_verticalScrollbar.get(); }
+    virtual bool shouldSuspendScrollAnimations() const override { return false; } // If we return true, ScrollAnimatorMac will keep cycling a timer forever, waiting for a good time to animate.
+    virtual void scrollbarStyleChanged(WebCore::ScrollbarStyle, bool forceUpdate) override;
+    virtual WebCore::IntRect convertFromScrollbarToContainingView(const WebCore::Scrollbar*, const WebCore::IntRect&amp; scrollbarRect) const override;
+    virtual WebCore::IntRect convertFromContainingViewToScrollbar(const WebCore::Scrollbar*, const WebCore::IntRect&amp; parentRect) const override;
+    virtual WebCore::IntPoint convertFromScrollbarToContainingView(const WebCore::Scrollbar*, const WebCore::IntPoint&amp; scrollbarPoint) const override;
+    virtual WebCore::IntPoint convertFromContainingViewToScrollbar(const WebCore::Scrollbar*, const WebCore::IntPoint&amp; parentPoint) const override;
+    virtual bool updatesScrollLayerPositionOnMainThread() const override { return true; }
+    virtual bool forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const override;
+
+    // PDFPlugin functions.
+    void updateScrollbars();
+    PassRefPtr&lt;WebCore::Scrollbar&gt; createScrollbar(WebCore::ScrollbarOrientation);
+    void destroyScrollbar(WebCore::ScrollbarOrientation);
+    void pdfDocumentDidLoad();
+    void addArchiveResource();
+    void computePageBoxes();
+    void calculateSizes();
+    void runScriptsInPDFDocument();
+
+    NSEvent *nsEventForWebMouseEvent(const WebMouseEvent&amp;);
+    WebCore::IntPoint convertFromPluginToPDFView(const WebCore::IntPoint&amp;) const;
+    WebCore::IntPoint convertFromRootViewToPlugin(const WebCore::IntPoint&amp;) const;
+    WebCore::IntPoint convertFromPDFViewToRootView(const WebCore::IntPoint&amp;) const;
+    
+    bool supportsForms();
+    bool isFullFramePlugin() const;
+
+    void updatePageAndDeviceScaleFactors();
+
+    void createPasswordEntryForm();
+
+    RetainPtr&lt;PDFDocument&gt; pdfDocument() const { return m_pdfDocument; }
+    void setPDFDocument(RetainPtr&lt;PDFDocument&gt; document) { m_pdfDocument = document; }
+
+    WebCore::IntSize pdfDocumentSize() const { return m_pdfDocumentSize; }
+    void setPDFDocumentSize(WebCore::IntSize size) { m_pdfDocumentSize = size; }
+
+    NSData *liveData() const;
+    NSData *rawData() const { return (NSData *)m_data.get(); }
+
+    WebFrame* webFrame() const { return m_frame; }
+
+    enum UpdateCursorMode {
+        UpdateIfNeeded,
+        ForceUpdate
+    };
+
+    enum HitTestResult {
+        None,
+        Text
+    };
+
+    void updateCursor(const WebMouseEvent&amp;, UpdateCursorMode = UpdateIfNeeded);
+
+    JSObjectRef makeJSPDFDoc(JSContextRef);
+    static JSValueRef jsPDFDocPrint(JSContextRef, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+    void convertPostScriptDataIfNeeded();
+
+    // Regular plug-ins don't need access to view, but we add scrollbars to embedding FrameView for proper event handling.
+    PluginView* pluginView();
+    const PluginView* pluginView() const;
+
+    WebFrame* m_frame;
+
+    bool m_isPostScript;
+    bool m_pdfDocumentWasMutated;
+
+    WebCore::IntSize m_scrollOffset;
+
+    RetainPtr&lt;CALayer&gt; m_containerLayer;
+    RetainPtr&lt;CALayer&gt; m_contentLayer;
+    RetainPtr&lt;CALayer&gt; m_horizontalScrollbarLayer;
+    RetainPtr&lt;CALayer&gt; m_verticalScrollbarLayer;
+    RetainPtr&lt;CALayer&gt; m_scrollCornerLayer;
+    RetainPtr&lt;PDFLayerController&gt; m_pdfLayerController;
+    RetainPtr&lt;WKPDFPluginAccessibilityObject&gt; m_accessibilityObject;
+    
+    RefPtr&lt;PDFPluginAnnotation&gt; m_activeAnnotation;
+    RefPtr&lt;PDFPluginPasswordField&gt; m_passwordField;
+    RefPtr&lt;WebCore::Element&gt; m_annotationContainer;
+
+    WebCore::AffineTransform m_rootViewToPluginTransform;
+    WebMouseEvent m_lastMouseEvent;
+    WebCore::IntPoint m_lastMousePositionInPluginCoordinates;
+
+    String m_temporaryPDFUUID;
+
+    String m_lastFoundString;
+
+    HitTestResult m_lastHitTestResult;
+    
+    RetainPtr&lt;WKPDFLayerControllerDelegate&gt; m_pdfLayerControllerDelegate;
+
+    WebCore::IntSize m_size;
+
+    WebCore::URL m_sourceURL;
+
+    String m_suggestedFilename;
+    RetainPtr&lt;CFMutableDataRef&gt; m_data;
+
+    RetainPtr&lt;PDFDocument&gt; m_pdfDocument;
+    Vector&lt;WebCore::IntRect&gt; m_pageBoxes;
+    WebCore::IntSize m_pdfDocumentSize; // All pages, including gaps.
+
+    RefPtr&lt;WebCore::Scrollbar&gt; m_horizontalScrollbar;
+    RefPtr&lt;WebCore::Scrollbar&gt; m_verticalScrollbar;
+};
+
+} // namespace WebKit
+
+SPECIALIZE_TYPE_TRAITS_PLUGIN(PDFPlugin, PDFPluginType)
+
+#endif // ENABLE(PDFKIT_PLUGIN)
+
+#endif // DeprecatedPDFPlugin_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFDeprecatedPDFPluginmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm (0 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -0,0 +1,2062 @@
</span><ins>+/*
+ * Copyright (C) 2009, 2011, 2012, 2015 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;DeprecatedPDFPlugin.h&quot;
+
+#if ENABLE(PDFKIT_PLUGIN) &amp;&amp; USE(DEPRECATED_PDF_PLUGIN)
+
+#import &quot;ArgumentCoders.h&quot;
+#import &quot;DataReference.h&quot;
+#import &quot;PDFAnnotationTextWidgetDetails.h&quot;
+#import &quot;PDFLayerControllerSPI.h&quot;
+#import &quot;PDFPluginAnnotation.h&quot;
+#import &quot;PDFPluginPasswordField.h&quot;
+#import &quot;PluginView.h&quot;
+#import &quot;WKAccessibilityWebPageObjectMac.h&quot;
+#import &quot;WKPageFindMatchesClient.h&quot;
+#import &quot;WebCoreArgumentCoders.h&quot;
+#import &quot;WebEvent.h&quot;
+#import &quot;WebEventConversion.h&quot;
+#import &quot;WebPage.h&quot;
+#import &quot;WebPageProxyMessages.h&quot;
+#import &quot;WebPasteboardProxyMessages.h&quot;
+#import &quot;WebProcess.h&quot;
+#import &lt;JavaScriptCore/JSContextRef.h&gt;
+#import &lt;JavaScriptCore/JSObjectRef.h&gt;
+#import &lt;JavaScriptCore/JSStringRef.h&gt;
+#import &lt;JavaScriptCore/JSStringRefCF.h&gt;
+#import &lt;PDFKit/PDFKit.h&gt;
+#import &lt;QuartzCore/QuartzCore.h&gt;
+#import &lt;WebCore/ArchiveResource.h&gt;
+#import &lt;WebCore/Chrome.h&gt;
+#import &lt;WebCore/Cursor.h&gt;
+#import &lt;WebCore/DictionaryLookup.h&gt;
+#import &lt;WebCore/DocumentLoader.h&gt;
+#import &lt;WebCore/FocusController.h&gt;
+#import &lt;WebCore/FormState.h&gt;
+#import &lt;WebCore/Frame.h&gt;
+#import &lt;WebCore/FrameLoader.h&gt;
+#import &lt;WebCore/FrameView.h&gt;
+#import &lt;WebCore/GraphicsContext.h&gt;
+#import &lt;WebCore/HTMLElement.h&gt;
+#import &lt;WebCore/HTMLFormElement.h&gt;
+#import &lt;WebCore/HTMLPlugInElement.h&gt;
+#import &lt;WebCore/LocalizedStrings.h&gt;
+#import &lt;WebCore/MainFrame.h&gt;
+#import &lt;WebCore/MouseEvent.h&gt;
+#import &lt;WebCore/Page.h&gt;
+#import &lt;WebCore/Pasteboard.h&gt;
+#import &lt;WebCore/PluginData.h&gt;
+#import &lt;WebCore/PluginDocument.h&gt;
+#import &lt;WebCore/RenderBoxModelObject.h&gt;
+#import &lt;WebCore/ScrollAnimator.h&gt;
+#import &lt;WebCore/ScrollbarTheme.h&gt;
+#import &lt;WebCore/Settings.h&gt;
+#import &lt;WebCore/UUID.h&gt;
+#import &lt;WebCore/WheelEventTestTrigger.h&gt;
+#import &lt;WebKitSystemInterface.h&gt;
+#import &lt;wtf/CurrentTime.h&gt;
+
+using namespace WebCore;
+
+// Set overflow: hidden on the annotation container so &lt;input&gt; elements scrolled out of view don't show
+// scrollbars on the body. We can't add annotations directly to the body, because overflow: hidden on the body
+// will break rubber-banding.
+static const char* annotationStyle =
+&quot;#annotationContainer {&quot;
+&quot;    overflow: hidden; &quot;
+&quot;    position: absolute; &quot;
+&quot;    pointer-events: none; &quot;
+&quot;    top: 0; &quot;
+&quot;    left: 0; &quot;
+&quot;    right: 0; &quot;
+&quot;    bottom: 0; &quot;
+&quot;    display: -webkit-box; &quot;
+&quot;    -webkit-box-align: center; &quot;
+&quot;    -webkit-box-pack: center; &quot;
+&quot;} &quot;
+&quot;.annotation { &quot;
+&quot;    position: absolute; &quot;
+&quot;    pointer-events: auto; &quot;
+&quot;} &quot;
+&quot;textarea.annotation { &quot;
+&quot;    resize: none; &quot;
+&quot;} &quot;
+&quot;input.annotation[type='password'] { &quot;
+&quot;    position: static; &quot;
+&quot;    width: 200px; &quot;
+&quot;    margin-top: 100px; &quot;
+&quot;} &quot;;
+
+// In non-continuous modes, a single scroll event with a magnitude of &gt;= 20px
+// will jump to the next or previous page, to match PDFKit behavior.
+static const int defaultScrollMagnitudeThresholdForPageFlip = 20;
+
+@interface WKPDFPluginAccessibilityObject : NSObject {
+    PDFLayerController *_pdfLayerController;
+    NSObject *_parent;
+    WebKit::PDFPlugin* _pdfPlugin;
+}
+
+@property (assign) PDFLayerController *pdfLayerController;
+@property (assign) NSObject *parent;
+@property (assign) WebKit::PDFPlugin* pdfPlugin;
+
+- (id)initWithPDFPlugin:(WebKit::PDFPlugin *)plugin;
+
+@end
+
+@implementation WKPDFPluginAccessibilityObject
+
+@synthesize pdfLayerController=_pdfLayerController;
+@synthesize parent=_parent;
+@synthesize pdfPlugin=_pdfPlugin;
+
+- (id)initWithPDFPlugin:(WebKit::PDFPlugin *)plugin
+{
+    if (!(self = [super init]))
+        return nil;
+
+    _pdfPlugin = plugin;
+
+    return self;
+}
+
+- (BOOL)accessibilityIsIgnored
+{
+    return NO;
+}
+
+- (id)accessibilityAttributeValue:(NSString *)attribute
+{
+    if ([attribute isEqualToString:NSAccessibilityParentAttribute])
+        return _parent;
+    if ([attribute isEqualToString:NSAccessibilityValueAttribute])
+        return [_pdfLayerController accessibilityValueAttribute];
+    if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute])
+        return [_pdfLayerController accessibilitySelectedTextAttribute];
+    if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute])
+        return [_pdfLayerController accessibilitySelectedTextRangeAttribute];
+    if ([attribute isEqualToString:NSAccessibilityNumberOfCharactersAttribute])
+        return [_pdfLayerController accessibilityNumberOfCharactersAttribute];
+    if ([attribute isEqualToString:NSAccessibilityVisibleCharacterRangeAttribute])
+        return [_pdfLayerController accessibilityVisibleCharacterRangeAttribute];
+    if ([attribute isEqualToString:NSAccessibilityTopLevelUIElementAttribute])
+        return [_parent accessibilityAttributeValue:NSAccessibilityTopLevelUIElementAttribute];
+    if ([attribute isEqualToString:NSAccessibilityRoleAttribute])
+        return [_pdfLayerController accessibilityRoleAttribute];
+    if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute])
+        return [_pdfLayerController accessibilityRoleDescriptionAttribute];
+    if ([attribute isEqualToString:NSAccessibilityWindowAttribute])
+        return [_parent accessibilityAttributeValue:NSAccessibilityWindowAttribute];
+    if ([attribute isEqualToString:NSAccessibilitySizeAttribute])
+        return [NSValue valueWithSize:_pdfPlugin-&gt;boundsOnScreen().size()];
+    if ([attribute isEqualToString:NSAccessibilityFocusedAttribute])
+        return [_parent accessibilityAttributeValue:NSAccessibilityFocusedAttribute];
+    if ([attribute isEqualToString:NSAccessibilityEnabledAttribute])
+        return [_parent accessibilityAttributeValue:NSAccessibilityEnabledAttribute];
+    if ([attribute isEqualToString:NSAccessibilityPositionAttribute])
+        return [NSValue valueWithPoint:_pdfPlugin-&gt;boundsOnScreen().location()];
+
+    return 0;
+}
+
+- (id)accessibilityAttributeValue:(NSString *)attribute forParameter:(id)parameter
+{
+    if ([attribute isEqualToString:NSAccessibilityBoundsForRangeParameterizedAttribute]) {
+        NSRect boundsInPDFViewCoordinates = [[_pdfLayerController accessibilityBoundsForRangeAttributeForParameter:parameter] rectValue];
+        NSRect boundsInScreenCoordinates = _pdfPlugin-&gt;convertFromPDFViewToScreen(boundsInPDFViewCoordinates);
+        return [NSValue valueWithRect:boundsInScreenCoordinates];
+    }
+
+    if ([attribute isEqualToString:NSAccessibilityLineForIndexParameterizedAttribute])
+        return [_pdfLayerController accessibilityLineForIndexAttributeForParameter:parameter];
+    if ([attribute isEqualToString:NSAccessibilityRangeForLineParameterizedAttribute])
+        return [_pdfLayerController accessibilityRangeForLineAttributeForParameter:parameter];
+    if ([attribute isEqualToString:NSAccessibilityStringForRangeParameterizedAttribute])
+        return [_pdfLayerController accessibilityStringForRangeAttributeForParameter:parameter];
+
+    return 0;
+}
+
+- (CPReadingModel *)readingModel
+{
+    return [_pdfLayerController readingModel];
+}
+
+- (NSArray *)accessibilityAttributeNames
+{
+    static NSArray *attributeNames = 0;
+
+    if (!attributeNames) {
+        attributeNames = @[NSAccessibilityValueAttribute,
+            NSAccessibilitySelectedTextAttribute,
+            NSAccessibilitySelectedTextRangeAttribute,
+            NSAccessibilityNumberOfCharactersAttribute,
+            NSAccessibilityVisibleCharacterRangeAttribute,
+            NSAccessibilityParentAttribute,
+            NSAccessibilityRoleAttribute,
+            NSAccessibilityWindowAttribute,
+            NSAccessibilityTopLevelUIElementAttribute,
+            NSAccessibilityRoleDescriptionAttribute,
+            NSAccessibilitySizeAttribute,
+            NSAccessibilityFocusedAttribute,
+            NSAccessibilityEnabledAttribute,
+            NSAccessibilityPositionAttribute];
+        [attributeNames retain];
+    }
+
+    return attributeNames;
+}
+
+- (NSArray *)accessibilityActionNames
+{
+    static NSArray *actionNames = 0;
+    
+    if (!actionNames)
+        actionNames = [[NSArray arrayWithObject:NSAccessibilityShowMenuAction] retain];
+    
+    return actionNames;
+}
+
+- (void)accessibilityPerformAction:(NSString *)action
+{
+    if ([action isEqualToString:NSAccessibilityShowMenuAction])
+        _pdfPlugin-&gt;showContextMenuAtPoint(IntRect(IntPoint(), _pdfPlugin-&gt;size()).center());
+}
+
+- (BOOL)accessibilityIsAttributeSettable:(NSString *)attribute
+{
+    return [_pdfLayerController accessibilityIsAttributeSettable:attribute];
+}
+
+- (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute
+{
+    return [_pdfLayerController accessibilitySetValue:value forAttribute:attribute];
+}
+
+- (NSArray *)accessibilityParameterizedAttributeNames
+{
+    return [_pdfLayerController accessibilityParameterizedAttributeNames];
+}
+
+- (id)accessibilityFocusedUIElement
+{
+    return self;
+}
+
+- (id)accessibilityHitTest:(NSPoint)point
+{
+    return self;
+}
+
+@end
+
+
+@interface WKPDFPluginScrollbarLayer : CALayer {
+    WebKit::PDFPlugin* _pdfPlugin;
+}
+
+@property (assign) WebKit::PDFPlugin* pdfPlugin;
+
+@end
+
+@implementation WKPDFPluginScrollbarLayer
+
+@synthesize pdfPlugin=_pdfPlugin;
+
+- (id)initWithPDFPlugin:(WebKit::PDFPlugin *)plugin
+{
+    if (!(self = [super init]))
+        return nil;
+    
+    _pdfPlugin = plugin;
+    
+    return self;
+}
+
+- (id&lt;CAAction&gt;)actionForKey:(NSString *)key
+{
+    return nil;
+}
+
+- (void)drawInContext:(CGContextRef)ctx
+{
+    _pdfPlugin-&gt;paintControlForLayerInContext(self, ctx);
+}
+
+@end
+
+@interface WKPDFLayerControllerDelegate : NSObject&lt;PDFLayerControllerDelegate&gt; {
+    WebKit::PDFPlugin* _pdfPlugin;
+}
+
+@property (assign) WebKit::PDFPlugin* pdfPlugin;
+
+@end
+
+@implementation WKPDFLayerControllerDelegate
+
+@synthesize pdfPlugin=_pdfPlugin;
+
+- (id)initWithPDFPlugin:(WebKit::PDFPlugin *)plugin
+{
+    if (!(self = [super init]))
+        return nil;
+    
+    _pdfPlugin = plugin;
+    
+    return self;
+}
+
+- (void)updateScrollPosition:(CGPoint)newPosition
+{
+    _pdfPlugin-&gt;notifyScrollPositionChanged(IntPoint(newPosition));
+}
+
+- (void)writeItemsToPasteboard:(NSArray *)items withTypes:(NSArray *)types
+{
+    _pdfPlugin-&gt;writeItemsToPasteboard(NSGeneralPboard, items, types);
+}
+
+- (void)showDefinitionForAttributedString:(NSAttributedString *)string atPoint:(CGPoint)point
+{
+    _pdfPlugin-&gt;showDefinitionForAttributedString(string, point);
+}
+
+- (void)performWebSearch:(NSString *)string
+{
+    _pdfPlugin-&gt;performWebSearch(string);
+}
+
+- (void)performSpotlightSearch:(NSString *)string
+{
+    _pdfPlugin-&gt;performSpotlightSearch(string);
+}
+
+- (void)openWithNativeApplication
+{
+    _pdfPlugin-&gt;openWithNativeApplication();
+}
+
+- (void)saveToPDF
+{
+    _pdfPlugin-&gt;saveToPDF();
+}
+
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController clickedLinkWithURL:(NSURL *)url
+{
+    _pdfPlugin-&gt;clickedLink(url);
+}
+
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeActiveAnnotation:(PDFAnnotation *)annotation
+{
+    _pdfPlugin-&gt;setActiveAnnotation(annotation);
+}
+
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeContentScaleFactor:(CGFloat)scaleFactor
+{
+    _pdfPlugin-&gt;notifyContentScaleFactorChanged(scaleFactor);
+}
+
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeDisplayMode:(int)mode
+{
+    _pdfPlugin-&gt;notifyDisplayModeChanged(mode);
+}
+
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeSelection:(PDFSelection *)selection
+{
+    _pdfPlugin-&gt;notifySelectionChanged(selection);
+}
+
+@end
+
+@interface PDFViewLayout
+- (NSPoint)convertPoint:(NSPoint)point toPage:(PDFPage *)page forScaleFactor:(CGFloat)scaleFactor;
+- (NSRect)convertRect:(NSRect)rect fromPage:(PDFPage *) page forScaleFactor:(CGFloat) scaleFactor;
+- (PDFPage *)pageNearestPoint:(NSPoint)point currentPage:(PDFPage *)currentPage;
+@end
+
+static const char* postScriptMIMEType = &quot;application/postscript&quot;;
+const uint64_t pdfDocumentRequestID = 1; // PluginController supports loading multiple streams, but we only need one for PDF.
+
+static void appendValuesInPDFNameSubtreeToVector(CGPDFDictionaryRef subtree, Vector&lt;CGPDFObjectRef&gt;&amp; values)
+{
+    CGPDFArrayRef names;
+    if (CGPDFDictionaryGetArray(subtree, &quot;Names&quot;, &amp;names)) {
+        size_t nameCount = CGPDFArrayGetCount(names) / 2;
+        for (size_t i = 0; i &lt; nameCount; ++i) {
+            CGPDFObjectRef object;
+            CGPDFArrayGetObject(names, 2 * i + 1, &amp;object);
+            values.append(object);
+        }
+        return;
+    }
+
+    CGPDFArrayRef kids;
+    if (!CGPDFDictionaryGetArray(subtree, &quot;Kids&quot;, &amp;kids))
+        return;
+
+    size_t kidCount = CGPDFArrayGetCount(kids);
+    for (size_t i = 0; i &lt; kidCount; ++i) {
+        CGPDFDictionaryRef kid;
+        if (!CGPDFArrayGetDictionary(kids, i, &amp;kid))
+            continue;
+        appendValuesInPDFNameSubtreeToVector(kid, values);
+    }
+}
+
+static void getAllValuesInPDFNameTree(CGPDFDictionaryRef tree, Vector&lt;CGPDFObjectRef&gt;&amp; allValues)
+{
+    appendValuesInPDFNameSubtreeToVector(tree, allValues);
+}
+
+static void getAllScriptsInPDFDocument(CGPDFDocumentRef pdfDocument, Vector&lt;RetainPtr&lt;CFStringRef&gt;&gt;&amp; scripts)
+{
+    if (!pdfDocument)
+        return;
+
+    CGPDFDictionaryRef pdfCatalog = CGPDFDocumentGetCatalog(pdfDocument);
+    if (!pdfCatalog)
+        return;
+
+    // Get the dictionary of all document-level name trees.
+    CGPDFDictionaryRef namesDictionary;
+    if (!CGPDFDictionaryGetDictionary(pdfCatalog, &quot;Names&quot;, &amp;namesDictionary))
+        return;
+
+    // Get the document-level &quot;JavaScript&quot; name tree.
+    CGPDFDictionaryRef javaScriptNameTree;
+    if (!CGPDFDictionaryGetDictionary(namesDictionary, &quot;JavaScript&quot;, &amp;javaScriptNameTree))
+        return;
+
+    // The names are arbitrary. We are only interested in the values.
+    Vector&lt;CGPDFObjectRef&gt; objects;
+    getAllValuesInPDFNameTree(javaScriptNameTree, objects);
+    size_t objectCount = objects.size();
+
+    for (size_t i = 0; i &lt; objectCount; ++i) {
+        CGPDFDictionaryRef javaScriptAction;
+        if (!CGPDFObjectGetValue(reinterpret_cast&lt;CGPDFObjectRef&gt;(objects[i]), kCGPDFObjectTypeDictionary, &amp;javaScriptAction))
+            continue;
+
+        // A JavaScript action must have an action type of &quot;JavaScript&quot;.
+        const char* actionType;
+        if (!CGPDFDictionaryGetName(javaScriptAction, &quot;S&quot;, &amp;actionType) || strcmp(actionType, &quot;JavaScript&quot;))
+            continue;
+
+        const UInt8* bytes = 0;
+        CFIndex length;
+        CGPDFStreamRef stream;
+        CGPDFStringRef string;
+        RetainPtr&lt;CFDataRef&gt; data;
+        if (CGPDFDictionaryGetStream(javaScriptAction, &quot;JS&quot;, &amp;stream)) {
+            CGPDFDataFormat format;
+            data = adoptCF(CGPDFStreamCopyData(stream, &amp;format));
+            if (!data)
+                continue;
+            bytes = CFDataGetBytePtr(data.get());
+            length = CFDataGetLength(data.get());
+        } else if (CGPDFDictionaryGetString(javaScriptAction, &quot;JS&quot;, &amp;string)) {
+            bytes = CGPDFStringGetBytePtr(string);
+            length = CGPDFStringGetLength(string);
+        }
+        if (!bytes)
+            continue;
+
+        CFStringEncoding encoding = (length &gt; 1 &amp;&amp; bytes[0] == 0xFE &amp;&amp; bytes[1] == 0xFF) ? kCFStringEncodingUnicode : kCFStringEncodingUTF8;
+        RetainPtr&lt;CFStringRef&gt; script = adoptCF(CFStringCreateWithBytes(kCFAllocatorDefault, bytes, length, encoding, true));
+        if (!script)
+            continue;
+        
+        scripts.append(script);
+    }
+}
+
+namespace WebKit {
+
+using namespace HTMLNames;
+
+Ref&lt;PDFPlugin&gt; PDFPlugin::create(WebFrame* frame)
+{
+    return adoptRef(*new PDFPlugin(frame));
+}
+
+PDFPlugin::PDFPlugin(WebFrame* frame)
+    : Plugin(PDFPluginType)
+    , m_frame(frame)
+    , m_isPostScript(false)
+    , m_pdfDocumentWasMutated(false)
+    , m_containerLayer(adoptNS([[CALayer alloc] init]))
+    , m_contentLayer(adoptNS([[CALayer alloc] init]))
+    , m_scrollCornerLayer(adoptNS([[WKPDFPluginScrollbarLayer alloc] initWithPDFPlugin:this]))
+    , m_pdfLayerController(adoptNS([[pdfLayerControllerClass() alloc] init]))
+    , m_pdfLayerControllerDelegate(adoptNS([[WKPDFLayerControllerDelegate alloc] initWithPDFPlugin:this]))
+{
+    m_pdfLayerController.get().delegate = m_pdfLayerControllerDelegate.get();
+    m_pdfLayerController.get().parentLayer = m_contentLayer.get();
+
+    if (supportsForms()) {
+        Document* document = webFrame()-&gt;coreFrame()-&gt;document();
+        m_annotationContainer = document-&gt;createElement(divTag, false);
+        m_annotationContainer-&gt;setAttribute(idAttr, &quot;annotationContainer&quot;);
+
+        Ref&lt;Element&gt; annotationStyleElement = document-&gt;createElement(styleTag, false);
+        annotationStyleElement-&gt;setTextContent(annotationStyle, ASSERT_NO_EXCEPTION);
+
+        m_annotationContainer-&gt;appendChild(WTF::move(annotationStyleElement));
+        document-&gt;bodyOrFrameset()-&gt;appendChild(*m_annotationContainer);
+    }
+
+    m_accessibilityObject = adoptNS([[WKPDFPluginAccessibilityObject alloc] initWithPDFPlugin:this]);
+    [m_accessibilityObject setPdfLayerController:m_pdfLayerController.get()];
+    [m_accessibilityObject setParent:webFrame()-&gt;page()-&gt;accessibilityRemoteObject()];
+
+    [m_containerLayer addSublayer:m_contentLayer.get()];
+    [m_containerLayer addSublayer:m_scrollCornerLayer.get()];
+}
+
+PDFPlugin::~PDFPlugin()
+{
+}
+
+PluginInfo PDFPlugin::pluginInfo()
+{
+    PluginInfo info;
+    info.name = builtInPDFPluginName();
+    info.isApplicationPlugin = true;
+    info.clientLoadPolicy = PluginLoadClientPolicyUndefined;
+
+    MimeClassInfo pdfMimeClassInfo;
+    pdfMimeClassInfo.type = &quot;application/pdf&quot;;
+    pdfMimeClassInfo.desc = pdfDocumentTypeDescription();
+    pdfMimeClassInfo.extensions.append(&quot;pdf&quot;);
+    info.mimes.append(pdfMimeClassInfo);
+
+    MimeClassInfo textPDFMimeClassInfo;
+    textPDFMimeClassInfo.type = &quot;text/pdf&quot;;
+    textPDFMimeClassInfo.desc = pdfDocumentTypeDescription();
+    textPDFMimeClassInfo.extensions.append(&quot;pdf&quot;);
+    info.mimes.append(textPDFMimeClassInfo);
+
+    MimeClassInfo postScriptMimeClassInfo;
+    postScriptMimeClassInfo.type = postScriptMIMEType;
+    postScriptMimeClassInfo.desc = postScriptDocumentTypeDescription();
+    postScriptMimeClassInfo.extensions.append(&quot;ps&quot;);
+    info.mimes.append(postScriptMimeClassInfo);
+    
+    return info;
+}
+
+void PDFPlugin::updateScrollbars()
+{
+    bool hadScrollbars = m_horizontalScrollbar || m_verticalScrollbar;
+
+    if (m_horizontalScrollbar) {
+        if (m_size.width() &gt;= m_pdfDocumentSize.width())
+            destroyScrollbar(HorizontalScrollbar);
+    } else if (m_size.width() &lt; m_pdfDocumentSize.width())
+        m_horizontalScrollbar = createScrollbar(HorizontalScrollbar);
+
+    if (m_verticalScrollbar) {
+        if (m_size.height() &gt;= m_pdfDocumentSize.height())
+            destroyScrollbar(VerticalScrollbar);
+    } else if (m_size.height() &lt; m_pdfDocumentSize.height())
+        m_verticalScrollbar = createScrollbar(VerticalScrollbar);
+
+    int horizontalScrollbarHeight = (m_horizontalScrollbar &amp;&amp; !m_horizontalScrollbar-&gt;isOverlayScrollbar()) ? m_horizontalScrollbar-&gt;height() : 0;
+    int verticalScrollbarWidth = (m_verticalScrollbar &amp;&amp; !m_verticalScrollbar-&gt;isOverlayScrollbar()) ? m_verticalScrollbar-&gt;width() : 0;
+
+    int pageStep = m_pageBoxes.isEmpty() ? 0 : m_pageBoxes[0].height();
+
+    if (m_horizontalScrollbar) {
+        m_horizontalScrollbar-&gt;setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
+        m_horizontalScrollbar-&gt;setProportion(m_size.width() - verticalScrollbarWidth, m_pdfDocumentSize.width());
+        IntRect scrollbarRect(pluginView()-&gt;x(), pluginView()-&gt;y() + m_size.height() - m_horizontalScrollbar-&gt;height(), m_size.width(), m_horizontalScrollbar-&gt;height());
+        if (m_verticalScrollbar)
+            scrollbarRect.contract(m_verticalScrollbar-&gt;width(), 0);
+        m_horizontalScrollbar-&gt;setFrameRect(scrollbarRect);
+    }
+    if (m_verticalScrollbar) {
+        m_verticalScrollbar-&gt;setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
+        m_verticalScrollbar-&gt;setProportion(m_size.height() - horizontalScrollbarHeight, m_pdfDocumentSize.height());
+        IntRect scrollbarRect(IntRect(pluginView()-&gt;x() + m_size.width() - m_verticalScrollbar-&gt;width(), pluginView()-&gt;y(), m_verticalScrollbar-&gt;width(), m_size.height()));
+        if (m_horizontalScrollbar)
+            scrollbarRect.contract(0, m_horizontalScrollbar-&gt;height());
+        m_verticalScrollbar-&gt;setFrameRect(scrollbarRect);
+    }
+
+    FrameView* frameView = m_frame-&gt;coreFrame()-&gt;view();
+    if (!frameView)
+        return;
+
+    bool hasScrollbars = m_horizontalScrollbar || m_verticalScrollbar;
+    if (hadScrollbars != hasScrollbars) {
+        if (hasScrollbars)
+            frameView-&gt;addScrollableArea(this);
+        else
+            frameView-&gt;removeScrollableArea(this);
+
+        frameView-&gt;setNeedsLayout();
+    }
+    
+    if (m_verticalScrollbarLayer) {
+        m_verticalScrollbarLayer.get().frame = verticalScrollbar()-&gt;frameRect();
+        [m_verticalScrollbarLayer setNeedsDisplay];
+    }
+    
+    if (m_horizontalScrollbarLayer) {
+        m_horizontalScrollbarLayer.get().frame = horizontalScrollbar()-&gt;frameRect();
+        [m_horizontalScrollbarLayer setNeedsDisplay];
+    }
+    
+    if (m_scrollCornerLayer) {
+        m_scrollCornerLayer.get().frame = scrollCornerRect();
+        [m_scrollCornerLayer setNeedsDisplay];
+    }
+}
+
+PluginView* PDFPlugin::pluginView()
+{
+    return static_cast&lt;PluginView*&gt;(controller());
+}
+
+const PluginView* PDFPlugin::pluginView() const
+{
+    return static_cast&lt;const PluginView*&gt;(controller());
+}
+
+PassRefPtr&lt;Scrollbar&gt; PDFPlugin::createScrollbar(ScrollbarOrientation orientation)
+{
+    RefPtr&lt;Scrollbar&gt; widget = Scrollbar::createNativeScrollbar(*this, orientation, RegularScrollbar);
+    if (orientation == HorizontalScrollbar) {
+        m_horizontalScrollbarLayer = adoptNS([[WKPDFPluginScrollbarLayer alloc] initWithPDFPlugin:this]);
+        [m_containerLayer addSublayer:m_horizontalScrollbarLayer.get()];
+    } else {
+        m_verticalScrollbarLayer = adoptNS([[WKPDFPluginScrollbarLayer alloc] initWithPDFPlugin:this]);
+        [m_containerLayer addSublayer:m_verticalScrollbarLayer.get()];
+    }
+    didAddScrollbar(widget.get(), orientation);
+    if (Frame* frame = webFrame()-&gt;coreFrame()) {
+        if (Page* page = frame-&gt;page()) {
+            if (page-&gt;expectsWheelEventTriggers())
+                scrollAnimator().setWheelEventTestTrigger(page-&gt;testTrigger());
+        }
+    }
+    pluginView()-&gt;frame()-&gt;view()-&gt;addChild(widget.get());
+    return widget.release();
+}
+
+void PDFPlugin::destroyScrollbar(ScrollbarOrientation orientation)
+{
+    RefPtr&lt;Scrollbar&gt;&amp; scrollbar = orientation == HorizontalScrollbar ? m_horizontalScrollbar : m_verticalScrollbar;
+    if (!scrollbar)
+        return;
+
+    willRemoveScrollbar(scrollbar.get(), orientation);
+    scrollbar-&gt;removeFromParent();
+    scrollbar = nullptr;
+
+    if (orientation == HorizontalScrollbar) {
+        [m_horizontalScrollbarLayer removeFromSuperlayer];
+        m_horizontalScrollbarLayer = 0;
+    } else {
+        [m_verticalScrollbarLayer removeFromSuperlayer];
+        m_verticalScrollbarLayer = 0;
+    }
+}
+
+IntRect PDFPlugin::convertFromScrollbarToContainingView(const Scrollbar* scrollbar, const IntRect&amp; scrollbarRect) const
+{
+    IntRect rect = scrollbarRect;
+    rect.move(scrollbar-&gt;location() - pluginView()-&gt;location());
+
+    return pluginView()-&gt;frame()-&gt;view()-&gt;convertFromRendererToContainingView(pluginView()-&gt;pluginElement()-&gt;renderer(), rect);
+}
+
+IntRect PDFPlugin::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntRect&amp; parentRect) const
+{
+    IntRect rect = pluginView()-&gt;frame()-&gt;view()-&gt;convertFromContainingViewToRenderer(pluginView()-&gt;pluginElement()-&gt;renderer(), parentRect);
+    rect.move(pluginView()-&gt;location() - scrollbar-&gt;location());
+
+    return rect;
+}
+
+IntPoint PDFPlugin::convertFromScrollbarToContainingView(const Scrollbar* scrollbar, const IntPoint&amp; scrollbarPoint) const
+{
+    IntPoint point = scrollbarPoint;
+    point.move(scrollbar-&gt;location() - pluginView()-&gt;location());
+
+    return pluginView()-&gt;frame()-&gt;view()-&gt;convertFromRendererToContainingView(pluginView()-&gt;pluginElement()-&gt;renderer(), point);
+}
+
+IntPoint PDFPlugin::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntPoint&amp; parentPoint) const
+{
+    IntPoint point = pluginView()-&gt;frame()-&gt;view()-&gt;convertFromContainingViewToRenderer(pluginView()-&gt;pluginElement()-&gt;renderer(), parentPoint);
+    point.move(pluginView()-&gt;location() - scrollbar-&gt;location());
+    
+    return point;
+}
+
+bool PDFPlugin::handleScroll(ScrollDirection direction, ScrollGranularity granularity)
+{
+    return scroll(direction, granularity);
+}
+
+IntRect PDFPlugin::scrollCornerRect() const
+{
+    if (!m_horizontalScrollbar || !m_verticalScrollbar)
+        return IntRect();
+    if (m_horizontalScrollbar-&gt;isOverlayScrollbar()) {
+        ASSERT(m_verticalScrollbar-&gt;isOverlayScrollbar());
+        return IntRect();
+    }
+    return IntRect(pluginView()-&gt;width() - m_verticalScrollbar-&gt;width(), pluginView()-&gt;height() - m_horizontalScrollbar-&gt;height(), m_verticalScrollbar-&gt;width(), m_horizontalScrollbar-&gt;height());
+}
+
+ScrollableArea* PDFPlugin::enclosingScrollableArea() const
+{
+    // FIXME: Walk up the frame tree and look for a scrollable parent frame or RenderLayer.
+    return nullptr;
+}
+
+IntRect PDFPlugin::scrollableAreaBoundingBox() const
+{
+    return pluginView()-&gt;frameRect();
+}
+
+int PDFPlugin::scrollSize(ScrollbarOrientation orientation) const
+{
+    Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_horizontalScrollbar : m_verticalScrollbar).get();
+    return scrollbar ? (scrollbar-&gt;totalSize() - scrollbar-&gt;visibleSize()) : 0;
+}
+
+bool PDFPlugin::isActive() const
+{
+    if (Frame* coreFrame = m_frame-&gt;coreFrame()) {
+        if (Page* page = coreFrame-&gt;page())
+            return page-&gt;focusController().isActive();
+    }
+
+    return false;
+}
+
+bool PDFPlugin::forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const
+{
+    if (Frame* coreFrame = m_frame-&gt;coreFrame()) {
+        if (Page* page = coreFrame-&gt;page())
+            return page-&gt;settings().forceUpdateScrollbarsOnMainThreadForPerformanceTesting();
+    }
+
+    return false;
+}
+
+int PDFPlugin::scrollPosition(Scrollbar* scrollbar) const
+{
+    if (scrollbar-&gt;orientation() == HorizontalScrollbar)
+        return m_scrollOffset.width();
+    if (scrollbar-&gt;orientation() == VerticalScrollbar)
+        return m_scrollOffset.height();
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
+IntPoint PDFPlugin::scrollPosition() const
+{
+    return IntPoint(m_scrollOffset.width(), m_scrollOffset.height());
+}
+
+IntPoint PDFPlugin::minimumScrollPosition() const
+{
+    return IntPoint();
+}
+
+IntPoint PDFPlugin::maximumScrollPosition() const
+{
+    int horizontalScrollbarHeight = (m_horizontalScrollbar &amp;&amp; !m_horizontalScrollbar-&gt;isOverlayScrollbar()) ? m_horizontalScrollbar-&gt;height() : 0;
+    int verticalScrollbarWidth = (m_verticalScrollbar &amp;&amp; !m_verticalScrollbar-&gt;isOverlayScrollbar()) ? m_verticalScrollbar-&gt;width() : 0;
+
+    IntPoint maximumOffset(m_pdfDocumentSize.width() - m_size.width() + verticalScrollbarWidth, m_pdfDocumentSize.height() - m_size.height() + horizontalScrollbarHeight);
+    maximumOffset.clampNegativeToZero();
+    return maximumOffset;
+}
+
+void PDFPlugin::scrollbarStyleChanged(ScrollbarStyle style, bool forceUpdate)
+{
+    if (!forceUpdate)
+        return;
+
+    // If the PDF was scrolled all the way to bottom right and scrollbars change to overlay style, we don't want to display white rectangles where scrollbars were.
+    IntPoint newScrollOffset = IntPoint(m_scrollOffset).shrunkTo(maximumScrollPosition());
+    setScrollOffset(newScrollOffset);
+    
+    ScrollableArea::scrollbarStyleChanged(style, forceUpdate);
+    // As size of the content area changes, scrollbars may need to appear or to disappear.
+    updateScrollbars();
+}
+
+void PDFPlugin::addArchiveResource()
+{
+    // FIXME: It's a hack to force add a resource to DocumentLoader. PDF documents should just be fetched as CachedResources.
+
+    // Add just enough data for context menu handling and web archives to work.
+    NSDictionary* headers = @{ @&quot;Content-Disposition&quot;: (NSString *)m_suggestedFilename, @&quot;Content-Type&quot; : @&quot;application/pdf&quot; };
+    RetainPtr&lt;NSURLResponse&gt; response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:m_sourceURL statusCode:200 HTTPVersion:(NSString*)kCFHTTPVersion1_1 headerFields:headers]);
+    ResourceResponse synthesizedResponse(response.get());
+
+    RefPtr&lt;ArchiveResource&gt; resource = ArchiveResource::create(SharedBuffer::wrapCFData(m_data.get()), m_sourceURL, &quot;application/pdf&quot;, String(), String(), synthesizedResponse);
+    pluginView()-&gt;frame()-&gt;document()-&gt;loader()-&gt;addArchiveResource(resource.release());
+}
+
+static void jsPDFDocInitialize(JSContextRef ctx, JSObjectRef object)
+{
+    PDFPlugin* pdfView = static_cast&lt;PDFPlugin*&gt;(JSObjectGetPrivate(object));
+    pdfView-&gt;ref();
+}
+
+static void jsPDFDocFinalize(JSObjectRef object)
+{
+    PDFPlugin* pdfView = static_cast&lt;PDFPlugin*&gt;(JSObjectGetPrivate(object));
+    pdfView-&gt;deref();
+}
+
+JSValueRef PDFPlugin::jsPDFDocPrint(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    PDFPlugin* pdfView = static_cast&lt;PDFPlugin*&gt;(JSObjectGetPrivate(thisObject));
+
+    WebFrame* frame = pdfView-&gt;m_frame;
+    if (!frame)
+        return JSValueMakeUndefined(ctx);
+
+    Frame* coreFrame = frame-&gt;coreFrame();
+    if (!coreFrame)
+        return JSValueMakeUndefined(ctx);
+
+    Page* page = coreFrame-&gt;page();
+    if (!page)
+        return JSValueMakeUndefined(ctx);
+
+    page-&gt;chrome().print(coreFrame);
+
+    return JSValueMakeUndefined(ctx);
+}
+
+JSObjectRef PDFPlugin::makeJSPDFDoc(JSContextRef ctx)
+{
+    static JSStaticFunction jsPDFDocStaticFunctions[] = {
+        { &quot;print&quot;, jsPDFDocPrint, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { 0, 0, 0 },
+    };
+
+    static JSClassDefinition jsPDFDocClassDefinition = {
+        0,
+        kJSClassAttributeNone,
+        &quot;Doc&quot;,
+        0,
+        0,
+        jsPDFDocStaticFunctions,
+        jsPDFDocInitialize, jsPDFDocFinalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
+    };
+
+    static JSClassRef jsPDFDocClass = JSClassCreate(&amp;jsPDFDocClassDefinition);
+
+    return JSObjectMake(ctx, jsPDFDocClass, this);
+}
+
+static RetainPtr&lt;CFMutableDataRef&gt; convertPostScriptDataToPDF(RetainPtr&lt;CFDataRef&gt; postScriptData)
+{
+    // Convert PostScript to PDF using the Quartz 2D API.
+    // http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_ps_convert/chapter_16_section_1.html
+
+    CGPSConverterCallbacks callbacks = { 0, 0, 0, 0, 0, 0, 0, 0 };
+    RetainPtr&lt;CGPSConverterRef&gt; converter = adoptCF(CGPSConverterCreate(0, &amp;callbacks, 0));
+    RetainPtr&lt;CGDataProviderRef&gt; provider = adoptCF(CGDataProviderCreateWithCFData(postScriptData.get()));
+    RetainPtr&lt;CFMutableDataRef&gt; pdfData = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, 0));
+    RetainPtr&lt;CGDataConsumerRef&gt; consumer = adoptCF(CGDataConsumerCreateWithCFData(pdfData.get()));
+    
+    CGPSConverterConvert(converter.get(), provider.get(), consumer.get(), 0);
+    
+    return pdfData;
+}
+
+void PDFPlugin::convertPostScriptDataIfNeeded()
+{
+    if (!m_isPostScript)
+        return;
+
+    m_suggestedFilename = String(m_suggestedFilename + &quot;.pdf&quot;);
+    m_data = convertPostScriptDataToPDF(m_data);
+}
+
+void PDFPlugin::pdfDocumentDidLoad()
+{
+    addArchiveResource();
+    
+    RetainPtr&lt;PDFDocument&gt; document = adoptNS([[pdfDocumentClass() alloc] initWithData:rawData()]);
+
+    setPDFDocument(document);
+
+    updatePageAndDeviceScaleFactors();
+
+    [m_pdfLayerController setFrameSize:size()];
+    m_pdfLayerController.get().document = document.get();
+
+    if (handlesPageScaleFactor())
+        pluginView()-&gt;setPageScaleFactor([m_pdfLayerController contentScaleFactor], IntPoint());
+
+    notifyScrollPositionChanged(IntPoint([m_pdfLayerController scrollPosition]));
+
+    calculateSizes();
+    updateScrollbars();
+
+    runScriptsInPDFDocument();
+
+    if ([document isLocked])
+        createPasswordEntryForm();
+}
+
+void PDFPlugin::streamDidReceiveResponse(uint64_t streamID, const URL&amp;, uint32_t, uint32_t, const String&amp; mimeType, const String&amp;, const String&amp; suggestedFilename)
+{
+    ASSERT_UNUSED(streamID, streamID == pdfDocumentRequestID);
+
+    m_suggestedFilename = suggestedFilename;
+
+    if (equalIgnoringCase(mimeType, postScriptMIMEType))
+        m_isPostScript = true;
+}
+
+void PDFPlugin::streamDidReceiveData(uint64_t streamID, const char* bytes, int length)
+{
+    ASSERT_UNUSED(streamID, streamID == pdfDocumentRequestID);
+
+    if (!m_data)
+        m_data = adoptCF(CFDataCreateMutable(0, 0));
+
+    CFDataAppendBytes(m_data.get(), reinterpret_cast&lt;const UInt8*&gt;(bytes), length);
+}
+
+void PDFPlugin::streamDidFinishLoading(uint64_t streamID)
+{
+    ASSERT_UNUSED(streamID, streamID == pdfDocumentRequestID);
+
+    convertPostScriptDataIfNeeded();
+    pdfDocumentDidLoad();
+}
+
+void PDFPlugin::streamDidFail(uint64_t streamID, bool wasCancelled)
+{
+    ASSERT_UNUSED(streamID, streamID == pdfDocumentRequestID);
+
+    m_data.clear();
+}
+
+void PDFPlugin::manualStreamDidReceiveResponse(const URL&amp; responseURL, uint32_t streamLength,  uint32_t lastModifiedTime, const String&amp; mimeType, const String&amp; headers, const String&amp; suggestedFilename)
+{
+    m_suggestedFilename = suggestedFilename;
+
+    if (equalIgnoringCase(mimeType, postScriptMIMEType))
+        m_isPostScript = true;
+}
+
+void PDFPlugin::manualStreamDidReceiveData(const char* bytes, int length)
+{
+    if (!m_data)
+        m_data = adoptCF(CFDataCreateMutable(0, 0));
+
+    CFDataAppendBytes(m_data.get(), reinterpret_cast&lt;const UInt8*&gt;(bytes), length);
+}
+
+void PDFPlugin::manualStreamDidFinishLoading()
+{
+    convertPostScriptDataIfNeeded();
+    pdfDocumentDidLoad();
+}
+
+void PDFPlugin::manualStreamDidFail(bool)
+{
+    m_data.clear();
+}
+
+void PDFPlugin::runScriptsInPDFDocument()
+{
+    Vector&lt;RetainPtr&lt;CFStringRef&gt;&gt; scripts;
+    getAllScriptsInPDFDocument([m_pdfDocument documentRef], scripts);
+
+    size_t scriptCount = scripts.size();
+    if (!scriptCount)
+        return;
+
+    JSGlobalContextRef ctx = JSGlobalContextCreate(0);
+    JSObjectRef jsPDFDoc = makeJSPDFDoc(ctx);
+
+    for (size_t i = 0; i &lt; scriptCount; ++i) {
+        JSStringRef script = JSStringCreateWithCFString(scripts[i].get());
+        JSEvaluateScript(ctx, script, jsPDFDoc, 0, 0, 0);
+        JSStringRelease(script);
+    }
+    
+    JSGlobalContextRelease(ctx);
+}
+
+void PDFPlugin::createPasswordEntryForm()
+{
+    m_passwordField = PDFPluginPasswordField::create(m_pdfLayerController.get(), this);
+    m_passwordField-&gt;attach(m_annotationContainer.get());
+}
+
+void PDFPlugin::attemptToUnlockPDF(const String&amp; password)
+{
+    [m_pdfLayerController attemptToUnlockWithPassword:password];
+
+    if (![pdfDocument() isLocked]) {
+        m_passwordField = nullptr;
+
+        calculateSizes();
+        updateScrollbars();
+    }
+}
+
+void PDFPlugin::updatePageAndDeviceScaleFactors()
+{
+    double newScaleFactor = controller()-&gt;contentsScaleFactor();
+    if (!handlesPageScaleFactor())
+        newScaleFactor *= webFrame()-&gt;page()-&gt;pageScaleFactor();
+
+    if (newScaleFactor != [m_pdfLayerController deviceScaleFactor])
+        [m_pdfLayerController setDeviceScaleFactor:newScaleFactor];
+}
+
+void PDFPlugin::contentsScaleFactorChanged(float)
+{
+    updatePageAndDeviceScaleFactors();
+}
+
+void PDFPlugin::computePageBoxes()
+{
+    size_t pageCount = CGPDFDocumentGetNumberOfPages([m_pdfDocument documentRef]);
+    for (size_t i = 0; i &lt; pageCount; ++i) {
+        CGPDFPageRef pdfPage = CGPDFDocumentGetPage([m_pdfDocument documentRef], i + 1);
+        ASSERT(pdfPage);
+
+        CGRect box = CGPDFPageGetBoxRect(pdfPage, kCGPDFCropBox);
+        if (CGRectIsEmpty(box))
+            box = CGPDFPageGetBoxRect(pdfPage, kCGPDFMediaBox);
+        m_pageBoxes.append(IntRect(box));
+    }
+}
+
+void PDFPlugin::calculateSizes()
+{
+    if ([pdfDocument() isLocked]) {
+        setPDFDocumentSize(IntSize(0, 0));
+        return;
+    }
+
+    // FIXME: This should come straight from PDFKit.
+    computePageBoxes();
+
+    setPDFDocumentSize(IntSize([m_pdfLayerController contentSizeRespectingZoom]));
+}
+
+bool PDFPlugin::initialize(const Parameters&amp; parameters)
+{
+    m_sourceURL = parameters.url;
+    if (!parameters.shouldUseManualLoader &amp;&amp; !parameters.url.isEmpty())
+        controller()-&gt;loadURL(pdfDocumentRequestID, &quot;GET&quot;, parameters.url.string(), String(), HTTPHeaderMap(), Vector&lt;uint8_t&gt;(), false);
+
+    controller()-&gt;didInitializePlugin();
+    return true;
+}
+
+void PDFPlugin::destroy()
+{
+    m_pdfLayerController.get().delegate = 0;
+
+    if (webFrame()) {
+        if (FrameView* frameView = webFrame()-&gt;coreFrame()-&gt;view())
+            frameView-&gt;removeScrollableArea(this);
+    }
+
+    m_activeAnnotation = nullptr;
+    m_annotationContainer = nullptr;
+
+    destroyScrollbar(HorizontalScrollbar);
+    destroyScrollbar(VerticalScrollbar);
+    
+    [m_scrollCornerLayer removeFromSuperlayer];
+    [m_contentLayer removeFromSuperlayer];
+}
+
+void PDFPlugin::updateControlTints(GraphicsContext&amp; graphicsContext)
+{
+    ASSERT(graphicsContext.updatingControlTints());
+
+    if (m_horizontalScrollbar)
+        m_horizontalScrollbar-&gt;invalidate();
+    if (m_verticalScrollbar)
+        m_verticalScrollbar-&gt;invalidate();
+    invalidateScrollCorner(scrollCornerRect());
+}
+
+void PDFPlugin::paintControlForLayerInContext(CALayer *layer, CGContextRef context)
+{
+    GraphicsContext graphicsContext(context);
+    GraphicsContextStateSaver stateSaver(graphicsContext);
+    
+    graphicsContext.setIsCALayerContext(true);
+    
+    if (layer == m_scrollCornerLayer) {
+        IntRect scrollCornerRect = this-&gt;scrollCornerRect();
+        graphicsContext.translate(-scrollCornerRect.x(), -scrollCornerRect.y());
+        ScrollbarTheme::theme().paintScrollCorner(nullptr, graphicsContext, scrollCornerRect);
+        return;
+    }
+    
+    Scrollbar* scrollbar = nullptr;
+    
+    if (layer == m_verticalScrollbarLayer)
+        scrollbar = verticalScrollbar();
+    else if (layer == m_horizontalScrollbarLayer)
+        scrollbar = horizontalScrollbar();
+
+    if (!scrollbar)
+        return;
+    
+    graphicsContext.translate(-scrollbar-&gt;x(), -scrollbar-&gt;y());
+    scrollbar-&gt;paint(graphicsContext, scrollbar-&gt;frameRect());
+}
+
+RefPtr&lt;ShareableBitmap&gt; PDFPlugin::snapshot()
+{
+    if (size().isEmpty())
+        return nullptr;
+
+    float contentsScaleFactor = controller()-&gt;contentsScaleFactor();
+    IntSize backingStoreSize = size();
+    backingStoreSize.scale(contentsScaleFactor);
+
+    RefPtr&lt;ShareableBitmap&gt; bitmap = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha);
+    auto context = bitmap-&gt;createGraphicsContext();
+
+    context-&gt;scale(FloatSize(contentsScaleFactor, -contentsScaleFactor));
+    context-&gt;translate(-m_scrollOffset.width(), -m_pdfDocumentSize.height() + m_scrollOffset.height());
+
+    [m_pdfLayerController snapshotInContext:context-&gt;platformContext()];
+
+    return bitmap;
+}
+
+PlatformLayer* PDFPlugin::pluginLayer()
+{
+    return m_containerLayer.get();
+}
+
+IntPoint PDFPlugin::convertFromPluginToPDFView(const IntPoint&amp; point) const
+{
+    return IntPoint(point.x(), size().height() - point.y());
+}
+
+IntPoint PDFPlugin::convertFromRootViewToPlugin(const IntPoint&amp; point) const
+{
+    return m_rootViewToPluginTransform.mapPoint(point);
+}
+
+IntPoint PDFPlugin::convertFromPDFViewToRootView(const IntPoint&amp; point) const
+{
+    IntPoint pointInPluginCoordinates(point.x(), size().height() - point.y());
+    return m_rootViewToPluginTransform.inverse().mapPoint(pointInPluginCoordinates);
+}
+
+FloatRect PDFPlugin::convertFromPDFViewToScreen(const FloatRect&amp; rect) const
+{
+    FrameView* frameView = webFrame()-&gt;coreFrame()-&gt;view();
+
+    if (!frameView)
+        return FloatRect();
+
+    FloatPoint originInPluginCoordinates(rect.x(), size().height() - rect.y() - rect.height());
+    FloatRect rectInRootViewCoordinates = m_rootViewToPluginTransform.inverse().mapRect(FloatRect(originInPluginCoordinates, rect.size()));
+
+    return frameView-&gt;contentsToScreen(enclosingIntRect(rectInRootViewCoordinates));
+}
+
+IntRect PDFPlugin::boundsOnScreen() const
+{
+    FrameView* frameView = webFrame()-&gt;coreFrame()-&gt;view();
+
+    if (!frameView)
+        return IntRect();
+
+    FloatRect bounds = FloatRect(FloatPoint(), size());
+    FloatRect rectInRootViewCoordinates = m_rootViewToPluginTransform.inverse().mapRect(bounds);
+    return frameView-&gt;contentsToScreen(enclosingIntRect(rectInRootViewCoordinates));
+}
+
+void PDFPlugin::geometryDidChange(const IntSize&amp; pluginSize, const IntRect&amp;, const AffineTransform&amp; pluginToRootViewTransform)
+{
+    if (size() == pluginSize &amp;&amp; pluginView()-&gt;pageScaleFactor() == [m_pdfLayerController contentScaleFactor])
+        return;
+
+    m_size = pluginSize;
+    m_rootViewToPluginTransform = pluginToRootViewTransform.inverse();
+    [m_pdfLayerController setFrameSize:pluginSize];
+
+    [CATransaction begin];
+    [CATransaction setDisableActions:YES];
+    CATransform3D transform = CATransform3DMakeScale(1, -1, 1);
+    transform = CATransform3DTranslate(transform, 0, -pluginSize.height(), 0);
+    
+    if (handlesPageScaleFactor()) {
+        CGFloat magnification = pluginView()-&gt;pageScaleFactor() - [m_pdfLayerController contentScaleFactor];
+
+        // FIXME: Instead of m_lastMousePositionInPluginCoordinates, we should use the zoom origin from PluginView::setPageScaleFactor.
+        if (magnification)
+            [m_pdfLayerController magnifyWithMagnification:magnification atPoint:convertFromPluginToPDFView(m_lastMousePositionInPluginCoordinates) immediately:NO];
+    } else {
+        // If we don't handle page scale ourselves, we need to respect our parent page's
+        // scale, which may have changed.
+        updatePageAndDeviceScaleFactors();
+    } 
+
+    calculateSizes();
+    updateScrollbars();
+
+    if (m_activeAnnotation)
+        m_activeAnnotation-&gt;updateGeometry();
+
+    [m_contentLayer setSublayerTransform:transform];
+    [CATransaction commit];
+}
+
+void PDFPlugin::frameDidFinishLoading(uint64_t)
+{
+    ASSERT_NOT_REACHED();
+}
+
+void PDFPlugin::frameDidFail(uint64_t, bool)
+{
+    ASSERT_NOT_REACHED();
+}
+
+void PDFPlugin::didEvaluateJavaScript(uint64_t, const WTF::String&amp;)
+{
+    ASSERT_NOT_REACHED();
+}
+
+    
+static NSUInteger modifierFlagsFromWebEvent(const WebEvent&amp; event)
+{
+    return (event.shiftKey() ? NSShiftKeyMask : 0)
+        | (event.controlKey() ? NSControlKeyMask : 0)
+        | (event.altKey() ? NSAlternateKeyMask : 0)
+        | (event.metaKey() ? NSCommandKeyMask : 0);
+}
+    
+static bool getEventTypeFromWebEvent(const WebEvent&amp; event, NSEventType&amp; eventType)
+{
+    switch (event.type()) {
+    case WebEvent::KeyDown:
+        eventType = NSKeyDown;
+        return true;
+    case WebEvent::KeyUp:
+        eventType = NSKeyUp;
+        return true;
+    case WebEvent::MouseDown:
+        switch (static_cast&lt;const WebMouseEvent&amp;&gt;(event).button()) {
+        case WebMouseEvent::LeftButton:
+            eventType = NSLeftMouseDown;
+            return true;
+        case WebMouseEvent::RightButton:
+            eventType = NSRightMouseDown;
+            return true;
+        default:
+            return false;
+        }
+    case WebEvent::MouseUp:
+        switch (static_cast&lt;const WebMouseEvent&amp;&gt;(event).button()) {
+        case WebMouseEvent::LeftButton:
+            eventType = NSLeftMouseUp;
+            return true;
+        case WebMouseEvent::RightButton:
+            eventType = NSRightMouseUp;
+            return true;
+        default:
+            return false;
+        }
+    case WebEvent::MouseMove:
+        switch (static_cast&lt;const WebMouseEvent&amp;&gt;(event).button()) {
+        case WebMouseEvent::LeftButton:
+            eventType = NSLeftMouseDragged;
+            return true;
+        case WebMouseEvent::RightButton:
+            eventType = NSRightMouseDragged;
+            return true;
+        case WebMouseEvent::NoButton:
+            eventType = NSMouseMoved;
+            return true;
+        default:
+            return false;
+        }
+    default:
+        return false;
+    }
+}
+    
+NSEvent *PDFPlugin::nsEventForWebMouseEvent(const WebMouseEvent&amp; event)
+{
+    m_lastMousePositionInPluginCoordinates = convertFromRootViewToPlugin(event.position());
+
+    IntPoint positionInPDFViewCoordinates(convertFromPluginToPDFView(m_lastMousePositionInPluginCoordinates));
+
+    NSEventType eventType;
+
+    if (!getEventTypeFromWebEvent(event, eventType))
+        return 0;
+
+    NSUInteger modifierFlags = modifierFlagsFromWebEvent(event);
+
+    return [NSEvent mouseEventWithType:eventType location:positionInPDFViewCoordinates modifierFlags:modifierFlags timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:event.clickCount() pressure:0];
+}
+
+void PDFPlugin::updateCursor(const WebMouseEvent&amp; event, UpdateCursorMode mode)
+{
+    HitTestResult hitTestResult = None;
+
+    PDFSelection *selectionUnderMouse = [m_pdfLayerController getSelectionForWordAtPoint:convertFromPluginToPDFView(event.position())];
+    if (selectionUnderMouse &amp;&amp; [[selectionUnderMouse string] length])
+        hitTestResult = Text;
+
+    if (hitTestResult == m_lastHitTestResult &amp;&amp; mode == UpdateIfNeeded)
+        return;
+
+    webFrame()-&gt;page()-&gt;send(Messages::WebPageProxy::SetCursor(hitTestResult == Text ? iBeamCursor() : pointerCursor()));
+    m_lastHitTestResult = hitTestResult;
+}
+
+bool PDFPlugin::handleMouseEvent(const WebMouseEvent&amp; event)
+{
+    PlatformMouseEvent platformEvent = platform(event);
+    IntPoint mousePosition = convertFromRootViewToPlugin(event.position());
+
+    m_lastMouseEvent = event;
+
+    RefPtr&lt;Scrollbar&gt; targetScrollbar;
+    RefPtr&lt;Scrollbar&gt; targetScrollbarForLastMousePosition;
+
+    if (m_verticalScrollbarLayer) {
+        IntRect verticalScrollbarFrame(m_verticalScrollbarLayer.get().frame);
+        if (verticalScrollbarFrame.contains(mousePosition))
+            targetScrollbar = verticalScrollbar();
+        if (verticalScrollbarFrame.contains(m_lastMousePositionInPluginCoordinates))
+            targetScrollbarForLastMousePosition = verticalScrollbar();
+    }
+
+    if (m_horizontalScrollbarLayer) {
+        IntRect horizontalScrollbarFrame(m_horizontalScrollbarLayer.get().frame);
+        if (horizontalScrollbarFrame.contains(mousePosition))
+            targetScrollbar = horizontalScrollbar();
+        if (horizontalScrollbarFrame.contains(m_lastMousePositionInPluginCoordinates))
+            targetScrollbarForLastMousePosition = horizontalScrollbar();
+    }
+
+    if (m_scrollCornerLayer &amp;&amp; IntRect(m_scrollCornerLayer.get().frame).contains(mousePosition))
+        return false;
+
+    if ([pdfDocument() isLocked])
+        return false;
+
+    // Right-clicks and Control-clicks always call handleContextMenuEvent as well.
+    if (event.button() == WebMouseEvent::RightButton || (event.button() == WebMouseEvent::LeftButton &amp;&amp; event.controlKey()))
+        return true;
+
+    NSEvent *nsEvent = nsEventForWebMouseEvent(event);
+
+    switch (event.type()) {
+    case WebEvent::MouseMove:
+        mouseMovedInContentArea();
+        updateCursor(event);
+
+        if (targetScrollbar) {
+            if (!targetScrollbarForLastMousePosition) {
+                targetScrollbar-&gt;mouseEntered();
+                return true;
+            }
+            return targetScrollbar-&gt;mouseMoved(platformEvent);
+        }
+
+        if (!targetScrollbar &amp;&amp; targetScrollbarForLastMousePosition)
+            targetScrollbarForLastMousePosition-&gt;mouseExited();
+
+        switch (event.button()) {
+        case WebMouseEvent::LeftButton:
+            [m_pdfLayerController mouseDragged:nsEvent];
+            return true;
+        case WebMouseEvent::RightButton:
+        case WebMouseEvent::MiddleButton:
+            return false;
+        case WebMouseEvent::NoButton:
+            [m_pdfLayerController mouseMoved:nsEvent];
+            return true;
+        }
+        break;
+    case WebEvent::MouseDown:
+        switch (event.button()) {
+        case WebMouseEvent::LeftButton:
+            if (targetScrollbar)
+                return targetScrollbar-&gt;mouseDown(platformEvent);
+
+            [m_pdfLayerController mouseDown:nsEvent];
+            return true;
+        case WebMouseEvent::RightButton:
+            [m_pdfLayerController rightMouseDown:nsEvent];
+            return true;
+        case WebMouseEvent::MiddleButton:
+        case WebMouseEvent::NoButton:
+            return false;
+        }
+        break;
+    case WebEvent::MouseUp:
+        switch (event.button()) {
+        case WebMouseEvent::LeftButton:
+            if (targetScrollbar)
+                return targetScrollbar-&gt;mouseUp(platformEvent);
+
+            [m_pdfLayerController mouseUp:nsEvent];
+            return true;
+        case WebMouseEvent::RightButton:
+        case WebMouseEvent::MiddleButton:
+        case WebMouseEvent::NoButton:
+            return false;
+        }
+        break;
+    default:
+        break;
+    }
+
+    return false;
+}
+
+bool PDFPlugin::handleMouseEnterEvent(const WebMouseEvent&amp; event)
+{
+    mouseEnteredContentArea();
+    updateCursor(event, ForceUpdate);
+    return false;
+}
+
+bool PDFPlugin::handleMouseLeaveEvent(const WebMouseEvent&amp;)
+{
+    mouseExitedContentArea();
+    return false;
+}
+    
+bool PDFPlugin::showContextMenuAtPoint(const IntPoint&amp; point)
+{
+    FrameView* frameView = webFrame()-&gt;coreFrame()-&gt;view();
+    IntPoint contentsPoint = frameView-&gt;contentsToRootView(point);
+    WebMouseEvent event(WebEvent::MouseDown, WebMouseEvent::RightButton, contentsPoint, contentsPoint, 0, 0, 0, 1, static_cast&lt;WebEvent::Modifiers&gt;(0), monotonicallyIncreasingTime(), WebCore::ForceAtClick);
+    return handleContextMenuEvent(event);
+}
+
+bool PDFPlugin::handleContextMenuEvent(const WebMouseEvent&amp; event)
+{
+    FrameView* frameView = webFrame()-&gt;coreFrame()-&gt;view();
+    IntPoint point = frameView-&gt;contentsToScreen(IntRect(frameView-&gt;windowToContents(event.position()), IntSize())).location();
+    
+    if (NSMenu *nsMenu = [m_pdfLayerController menuForEvent:nsEventForWebMouseEvent(event)]) {
+        WKPopupContextMenu(nsMenu, point);
+        return true;
+    }
+    
+    return false;
+}
+
+bool PDFPlugin::handleKeyboardEvent(const WebKeyboardEvent&amp; event)
+{
+    NSEventType eventType;
+
+    if (!getEventTypeFromWebEvent(event, eventType))
+        return false;
+
+    NSUInteger modifierFlags = modifierFlagsFromWebEvent(event);
+    
+    NSEvent *fakeEvent = [NSEvent keyEventWithType:eventType location:NSZeroPoint modifierFlags:modifierFlags timestamp:0 windowNumber:0 context:0 characters:event.text() charactersIgnoringModifiers:event.unmodifiedText() isARepeat:event.isAutoRepeat() keyCode:event.nativeVirtualKeyCode()];
+    
+    switch (event.type()) {
+    case WebEvent::KeyDown:
+        return [m_pdfLayerController keyDown:fakeEvent];
+    default:
+        return false;
+    }
+    
+    return false;
+}
+    
+bool PDFPlugin::handleEditingCommand(const String&amp; commandName, const String&amp; argument)
+{
+    if (commandName == &quot;copy&quot;)
+        [m_pdfLayerController copySelection];
+    else if (commandName == &quot;selectAll&quot;)
+        [m_pdfLayerController selectAll];
+    else if (commandName == &quot;takeFindStringFromSelection&quot;) {
+        NSString *string = [m_pdfLayerController currentSelection].string;
+        if (string.length)
+            writeItemsToPasteboard(NSFindPboard, @[ [string dataUsingEncoding:NSUTF8StringEncoding] ], @[ NSPasteboardTypeString ]);
+    }
+
+    return true;
+}
+
+bool PDFPlugin::isEditingCommandEnabled(const String&amp; commandName)
+{
+    if (commandName == &quot;copy&quot; || commandName == &quot;takeFindStringFromSelection&quot;)
+        return [m_pdfLayerController currentSelection];
+
+    if (commandName == &quot;selectAll&quot;)
+        return true;
+
+    return false;
+}
+
+void PDFPlugin::setScrollOffset(const IntPoint&amp; offset)
+{
+    m_scrollOffset = IntSize(offset.x(), offset.y());
+
+    [CATransaction begin];
+    [m_pdfLayerController setScrollPosition:offset];
+
+    if (m_activeAnnotation)
+        m_activeAnnotation-&gt;updateGeometry();
+
+    [CATransaction commit];
+}
+
+void PDFPlugin::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect&amp; rect)
+{
+    if (scrollbar == horizontalScrollbar())
+        [m_horizontalScrollbarLayer setNeedsDisplay];
+    else if (scrollbar == verticalScrollbar())
+        [m_verticalScrollbarLayer setNeedsDisplay];
+}
+
+void PDFPlugin::invalidateScrollCornerRect(const IntRect&amp; rect)
+{
+    [m_scrollCornerLayer setNeedsDisplay];
+}
+
+bool PDFPlugin::isFullFramePlugin() const
+{
+    // &lt;object&gt; or &lt;embed&gt; plugins will appear to be in their parent frame, so we have to
+    // check whether our frame's widget is exactly our PluginView.
+    Document* document = webFrame()-&gt;coreFrame()-&gt;document();
+    return document-&gt;isPluginDocument() &amp;&amp; static_cast&lt;PluginDocument*&gt;(document)-&gt;pluginWidget() == pluginView();
+}
+
+bool PDFPlugin::handlesPageScaleFactor() const
+{
+    return webFrame()-&gt;isMainFrame() &amp;&amp; isFullFramePlugin();
+}
+
+void PDFPlugin::clickedLink(NSURL *url)
+{
+    URL coreURL = url;
+    if (protocolIsJavaScript(coreURL))
+        return;
+
+    Frame* frame = webFrame()-&gt;coreFrame();
+
+    RefPtr&lt;Event&gt; coreEvent;
+    if (m_lastMouseEvent.type() != WebEvent::NoType)
+        coreEvent = MouseEvent::create(eventNames().clickEvent, frame-&gt;document()-&gt;defaultView(), platform(m_lastMouseEvent), 0, 0);
+
+    frame-&gt;loader().urlSelected(coreURL, emptyString(), coreEvent.get(), LockHistory::No, LockBackForwardList::No, MaybeSendReferrer, ShouldOpenExternalURLsPolicy::ShouldAllow);
+}
+
+void PDFPlugin::setActiveAnnotation(PDFAnnotation *annotation)
+{
+    if (!supportsForms())
+        return;
+
+    if (m_activeAnnotation)
+        m_activeAnnotation-&gt;commit();
+
+    if (annotation) {
+        if ([annotation isKindOfClass:pdfAnnotationTextWidgetClass()] &amp;&amp; static_cast&lt;PDFAnnotationTextWidget *&gt;(annotation).isReadOnly) {
+            m_activeAnnotation = nullptr;
+            return;
+        }
+
+        m_activeAnnotation = PDFPluginAnnotation::create(annotation, m_pdfLayerController.get(), this);
+        m_activeAnnotation-&gt;attach(m_annotationContainer.get());
+    } else
+        m_activeAnnotation = nullptr;
+}
+
+bool PDFPlugin::supportsForms()
+{
+    // FIXME: We support forms for full-main-frame and &lt;iframe&gt; PDFs, but not &lt;embed&gt; or &lt;object&gt;, because those cases do not have their own Document into which to inject form elements.
+    return isFullFramePlugin();
+}
+
+void PDFPlugin::notifyContentScaleFactorChanged(CGFloat scaleFactor)
+{
+    if (handlesPageScaleFactor())
+        pluginView()-&gt;setPageScaleFactor(scaleFactor, IntPoint());
+
+    calculateSizes();
+    updateScrollbars();
+}
+
+void PDFPlugin::notifyDisplayModeChanged(int)
+{
+    calculateSizes();
+    updateScrollbars();
+}
+
+RefPtr&lt;SharedBuffer&gt; PDFPlugin::liveResourceData() const
+{
+    NSData *pdfData = liveData();
+
+    if (!pdfData)
+        return nullptr;
+
+    return SharedBuffer::wrapNSData(pdfData);
+}
+
+void PDFPlugin::saveToPDF()
+{
+    // FIXME: We should probably notify the user that they can't save before the document is finished loading.
+    // PDFViewController does an NSBeep(), but that seems insufficient.
+    if (!pdfDocument())
+        return;
+
+    NSData *data = liveData();
+    webFrame()-&gt;page()-&gt;savePDFToFileInDownloadsFolder(m_suggestedFilename, webFrame()-&gt;url(), static_cast&lt;const unsigned char *&gt;([data bytes]), [data length]);
+}
+
+void PDFPlugin::openWithNativeApplication()
+{
+    if (!m_temporaryPDFUUID) {
+        // FIXME: We should probably notify the user that they can't save before the document is finished loading.
+        // PDFViewController does an NSBeep(), but that seems insufficient.
+        if (!pdfDocument())
+            return;
+
+        NSData *data = liveData();
+
+        m_temporaryPDFUUID = WebCore::createCanonicalUUIDString();
+        ASSERT(m_temporaryPDFUUID);
+
+        webFrame()-&gt;page()-&gt;savePDFToTemporaryFolderAndOpenWithNativeApplication(m_suggestedFilename, webFrame()-&gt;url(), static_cast&lt;const unsigned char *&gt;([data bytes]), [data length], m_temporaryPDFUUID);
+        return;
+    }
+
+    webFrame()-&gt;page()-&gt;send(Messages::WebPageProxy::OpenPDFFromTemporaryFolderWithNativeApplication(m_temporaryPDFUUID));
+}
+
+void PDFPlugin::writeItemsToPasteboard(NSString *pasteboardName, NSArray *items, NSArray *types)
+{
+    Vector&lt;String&gt; pasteboardTypes;
+
+    for (NSString *type in types)
+        pasteboardTypes.append(type);
+
+    uint64_t newChangeCount;
+    auto&amp; webProcess = WebProcess::singleton();
+    webProcess.parentProcessConnection()-&gt;sendSync(Messages::WebPasteboardProxy::SetPasteboardTypes(pasteboardName, pasteboardTypes),
+        Messages::WebPasteboardProxy::SetPasteboardTypes::Reply(newChangeCount), 0);
+
+    for (NSUInteger i = 0, count = items.count; i &lt; count; ++i) {
+        NSString *type = [types objectAtIndex:i];
+        NSData *data = [items objectAtIndex:i];
+
+        // We don't expect the data for any items to be empty, but aren't completely sure.
+        // Avoid crashing in the SharedMemory constructor in release builds if we're wrong.
+        ASSERT(data.length);
+        if (!data.length)
+            continue;
+
+        if ([type isEqualToString:NSStringPboardType] || [type isEqualToString:NSPasteboardTypeString]) {
+            RetainPtr&lt;NSString&gt; plainTextString = adoptNS([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
+            webProcess.parentProcessConnection()-&gt;sendSync(Messages::WebPasteboardProxy::SetPasteboardStringForType(pasteboardName, type, plainTextString.get()), Messages::WebPasteboardProxy::SetPasteboardStringForType::Reply(newChangeCount), 0);
+        } else {
+            RefPtr&lt;SharedBuffer&gt; buffer = SharedBuffer::wrapNSData(data);
+
+            if (!buffer)
+                continue;
+
+            SharedMemory::Handle handle;
+            RefPtr&lt;SharedMemory&gt; sharedMemory = SharedMemory::allocate(buffer-&gt;size());
+            memcpy(sharedMemory-&gt;data(), buffer-&gt;data(), buffer-&gt;size());
+            sharedMemory-&gt;createHandle(handle, SharedMemory::Protection::ReadOnly);
+            webProcess.parentProcessConnection()-&gt;sendSync(Messages::WebPasteboardProxy::SetPasteboardBufferForType(pasteboardName, type, handle, buffer-&gt;size()), Messages::WebPasteboardProxy::SetPasteboardBufferForType::Reply(newChangeCount), 0);
+        }
+    }
+}
+
+void PDFPlugin::showDefinitionForAttributedString(NSAttributedString *string, CGPoint point)
+{
+    DictionaryPopupInfo dictionaryPopupInfo;
+    dictionaryPopupInfo.origin = convertFromPDFViewToRootView(IntPoint(point));
+    dictionaryPopupInfo.attributedString = string;
+
+    webFrame()-&gt;page()-&gt;send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfo));
+}
+
+unsigned PDFPlugin::countFindMatches(const String&amp; target, WebCore::FindOptions options, unsigned maxMatchCount)
+{
+    if (!target.length())
+        return 0;
+
+    int nsOptions = (options &amp; FindOptionsCaseInsensitive) ? NSCaseInsensitiveSearch : 0;
+
+    return [[pdfDocument() findString:target withOptions:nsOptions] count];
+}
+
+PDFSelection *PDFPlugin::nextMatchForString(const String&amp; target, BOOL searchForward, BOOL caseSensitive, BOOL wrapSearch, PDFSelection *initialSelection, BOOL startInSelection)
+{
+    if (!target.length())
+        return nil;
+
+    NSStringCompareOptions options = 0;
+    if (!searchForward)
+        options |= NSBackwardsSearch;
+
+    if (!caseSensitive)
+        options |= NSCaseInsensitiveSearch;
+
+    PDFDocument *document = pdfDocument().get();
+
+    PDFSelection *selectionForInitialSearch = [initialSelection copy];
+    if (startInSelection) {
+        // Initially we want to include the selected text in the search. So we must modify the starting search
+        // selection to fit PDFDocument's search requirements: selection must have a length &gt;= 1, begin before
+        // the current selection (if searching forwards) or after (if searching backwards).
+        int initialSelectionLength = [[initialSelection string] length];
+        if (searchForward) {
+            [selectionForInitialSearch extendSelectionAtStart:1];
+            [selectionForInitialSearch extendSelectionAtEnd:-initialSelectionLength];
+        } else {
+            [selectionForInitialSearch extendSelectionAtEnd:1];
+            [selectionForInitialSearch extendSelectionAtStart:-initialSelectionLength];
+        }
+    }
+
+    PDFSelection *foundSelection = [document findString:target fromSelection:selectionForInitialSearch withOptions:options];
+    [selectionForInitialSearch release];
+
+    // If we first searched in the selection, and we found the selection, search again from just past the selection.
+    if (startInSelection &amp;&amp; [foundSelection isEqual:initialSelection])
+        foundSelection = [document findString:target fromSelection:initialSelection withOptions:options];
+
+    if (!foundSelection &amp;&amp; wrapSearch)
+        foundSelection = [document findString:target fromSelection:nil withOptions:options];
+
+    return foundSelection;
+}
+
+bool PDFPlugin::findString(const String&amp; target, WebCore::FindOptions options, unsigned maxMatchCount)
+{
+    BOOL searchForward = !(options &amp; FindOptionsBackwards);
+    BOOL caseSensitive = !(options &amp; FindOptionsCaseInsensitive);
+    BOOL wrapSearch = options &amp; FindOptionsWrapAround;
+
+    unsigned matchCount;
+    if (!maxMatchCount) {
+        // If the max was zero, any result means we exceeded the max. We can skip computing the actual count.
+        matchCount = static_cast&lt;unsigned&gt;(kWKMoreThanMaximumMatchCount);
+    } else {
+        matchCount = countFindMatches(target, options, maxMatchCount);
+        if (matchCount &gt; maxMatchCount)
+            matchCount = static_cast&lt;unsigned&gt;(kWKMoreThanMaximumMatchCount);
+    }
+
+    if (target.isEmpty()) {
+        PDFSelection* searchSelection = [m_pdfLayerController searchSelection];
+        [m_pdfLayerController findString:target caseSensitive:caseSensitive highlightMatches:YES];
+        [m_pdfLayerController setSearchSelection:searchSelection];
+        m_lastFoundString = emptyString();
+        return false;
+    }
+
+    if (m_lastFoundString == target) {
+        PDFSelection *selection = nextMatchForString(target, searchForward, caseSensitive, wrapSearch, [m_pdfLayerController searchSelection], NO);
+        if (!selection)
+            return false;
+
+        [m_pdfLayerController setSearchSelection:selection];
+        [m_pdfLayerController gotoSelection:selection];
+    } else {
+        [m_pdfLayerController findString:target caseSensitive:caseSensitive highlightMatches:YES];
+        m_lastFoundString = target;
+    }
+
+    return matchCount &gt; 0;
+}
+
+bool PDFPlugin::performDictionaryLookupAtLocation(const WebCore::FloatPoint&amp; point)
+{
+    IntPoint localPoint = convertFromRootViewToPlugin(roundedIntPoint(point));
+    PDFSelection* lookupSelection = [m_pdfLayerController getSelectionForWordAtPoint:convertFromPluginToPDFView(localPoint)];
+
+    if ([[lookupSelection string] length])
+        [m_pdfLayerController searchInDictionaryWithSelection:lookupSelection];
+
+    return true;
+}
+
+void PDFPlugin::focusNextAnnotation()
+{
+    [m_pdfLayerController activateNextAnnotation:false];
+}
+
+void PDFPlugin::focusPreviousAnnotation()
+{
+    [m_pdfLayerController activateNextAnnotation:true];
+}
+
+void PDFPlugin::notifySelectionChanged(PDFSelection *)
+{
+    webFrame()-&gt;page()-&gt;didChangeSelection();
+}
+
+String PDFPlugin::getSelectionString() const
+{
+    return [[m_pdfLayerController currentSelection] string];
+}
+
+String PDFPlugin::getSelectionForWordAtPoint(const WebCore::FloatPoint&amp; point) const
+{
+    IntPoint pointInView = convertFromPluginToPDFView(convertFromRootViewToPlugin(roundedIntPoint(point)));
+    PDFSelection *selectionForWord = [m_pdfLayerController getSelectionForWordAtPoint:pointInView];
+    [m_pdfLayerController setCurrentSelection:selectionForWord];
+    
+    return [selectionForWord string];
+}
+
+bool PDFPlugin::existingSelectionContainsPoint(const WebCore::FloatPoint&amp; locationInViewCoordinates) const
+{
+    PDFSelection *currentSelection = [m_pdfLayerController currentSelection];
+    if (!currentSelection)
+        return false;
+    
+    IntPoint pointInPDFView = convertFromPluginToPDFView(convertFromRootViewToPlugin(roundedIntPoint(locationInViewCoordinates)));
+    PDFSelection *selectionForWord = [m_pdfLayerController getSelectionForWordAtPoint:pointInPDFView];
+
+    NSUInteger currentPageIndex = [m_pdfLayerController currentPageIndex];
+    
+    NSArray *selectionRects = [m_pdfLayerController rectsForSelectionInLayoutSpace:currentSelection];
+    if (!selectionRects || !selectionRects.count)
+        return false;
+    
+    if (currentPageIndex &gt;= selectionRects.count)
+        currentPageIndex = selectionRects.count - 1;
+
+    NSArray *wordSelectionRects = [m_pdfLayerController rectsForSelectionInLayoutSpace:selectionForWord];
+    if (!wordSelectionRects || !wordSelectionRects.count)
+        return false;
+
+    NSValue *selectionBounds = [selectionRects objectAtIndex:currentPageIndex];
+    NSValue *wordSelectionBounds = [wordSelectionRects objectAtIndex:0];
+
+    NSRect selectionBoundsRect = selectionBounds.rectValue;
+    NSRect wordSelectionBoundsRect = wordSelectionBounds.rectValue;
+    return NSIntersectsRect(wordSelectionBoundsRect, selectionBoundsRect);
+}
+
+static NSPoint pointInLayoutSpaceForPointInWindowSpace(PDFLayerController* pdfLayerController, NSPoint pointInView)
+{
+    CGPoint point = NSPointToCGPoint(pointInView);
+    CGPoint scrollOffset = [pdfLayerController scrollPosition];
+    CGFloat scaleFactor = [pdfLayerController contentScaleFactor];
+
+    scrollOffset.y = [pdfLayerController contentSizeRespectingZoom].height - NSRectToCGRect([pdfLayerController frame]).size.height - scrollOffset.y;
+    
+    CGPoint newPoint = CGPointMake(scrollOffset.x + point.x, scrollOffset.y + point.y);
+    newPoint.x /= scaleFactor;
+    newPoint.y /= scaleFactor;
+    return NSPointFromCGPoint(newPoint);
+}
+
+String PDFPlugin::lookupTextAtLocation(const WebCore::FloatPoint&amp; locationInViewCoordinates, WebHitTestResultData&amp; data, PDFSelection **selectionPtr, NSDictionary **options) const
+{
+    PDFSelection*&amp; selection = *selectionPtr;
+
+    selection = [m_pdfLayerController currentSelection];
+    if (existingSelectionContainsPoint(locationInViewCoordinates))
+        return selection.string;
+        
+    IntPoint pointInPDFView = convertFromPluginToPDFView(convertFromRootViewToPlugin(roundedIntPoint(locationInViewCoordinates)));
+    selection = [m_pdfLayerController getSelectionForWordAtPoint:pointInPDFView];
+    if (!selection)
+        return &quot;&quot;;
+
+    NSPoint pointInLayoutSpace = pointInLayoutSpaceForPointInWindowSpace(m_pdfLayerController.get(), pointInPDFView);
+
+    PDFPage *currentPage = [[m_pdfLayerController layout] pageNearestPoint:pointInLayoutSpace currentPage:[m_pdfLayerController currentPage]];
+    
+    NSPoint pointInPageSpace = [[m_pdfLayerController layout] convertPoint:pointInLayoutSpace toPage:currentPage forScaleFactor:1.0];
+    
+    for (PDFAnnotation *annotation in currentPage.annotations) {
+        if (![annotation isKindOfClass:pdfAnnotationLinkClass()])
+            continue;
+    
+        NSRect bounds = annotation.bounds;
+        if (!NSPointInRect(pointInPageSpace, bounds))
+            continue;
+        
+        PDFAnnotationLink *linkAnnotation = (PDFAnnotationLink *)annotation;
+        NSURL *url = linkAnnotation.URL;
+        if (!url)
+            continue;
+        
+        data.absoluteLinkURL = url.absoluteString;
+        data.linkLabel = selection.string;
+        return selection.string;
+    }
+    
+    NSString *lookupText = DictionaryLookup::stringForPDFSelection(selection, options);
+    if (!lookupText || !lookupText.length)
+        return &quot;&quot;;
+
+    [m_pdfLayerController setCurrentSelection:selection];
+    return lookupText;
+}
+
+static NSRect rectInViewSpaceForRectInLayoutSpace(PDFLayerController* pdfLayerController, NSRect layoutSpaceRect)
+{
+    CGRect newRect = NSRectToCGRect(layoutSpaceRect);
+    CGFloat scaleFactor = pdfLayerController.contentScaleFactor;
+    CGPoint scrollOffset = pdfLayerController.scrollPosition;
+
+    scrollOffset.y = pdfLayerController.contentSizeRespectingZoom.height - NSRectToCGRect(pdfLayerController.frame).size.height - scrollOffset.y;
+
+    newRect.origin.x *= scaleFactor;
+    newRect.origin.y *= scaleFactor;
+    newRect.size.width *= scaleFactor;
+    newRect.size.height *= scaleFactor;
+
+    newRect.origin.x -= scrollOffset.x;
+    newRect.origin.y -= scrollOffset.y;
+
+    return NSRectFromCGRect(newRect);
+}
+
+WebCore::FloatRect PDFPlugin::rectForSelectionInRootView(PDFSelection *selection) const
+{
+    PDFPage *currentPage = nil;
+    NSArray* pages = selection.pages;
+    if (pages.count)
+        currentPage = (PDFPage *)[pages objectAtIndex:0];
+
+    if (!currentPage)
+        currentPage = [m_pdfLayerController currentPage];
+    
+    NSRect rectInPageSpace = [selection boundsForPage:currentPage];
+    NSRect rectInLayoutSpace = [[m_pdfLayerController layout] convertRect:rectInPageSpace fromPage:currentPage forScaleFactor:1.0];
+    NSRect rectInView = rectInViewSpaceForRectInLayoutSpace(m_pdfLayerController.get(), rectInLayoutSpace);
+
+    rectInView.origin = convertFromPDFViewToRootView(IntPoint(rectInView.origin));
+
+    return WebCore::FloatRect(rectInView);
+}
+
+CGFloat PDFPlugin::scaleFactor() const
+{
+    return [m_pdfLayerController contentScaleFactor];
+}
+
+void PDFPlugin::performWebSearch(NSString *string)
+{
+    webFrame()-&gt;page()-&gt;send(Messages::WebPageProxy::SearchTheWeb(string));
+}
+
+void PDFPlugin::performSpotlightSearch(NSString *string)
+{
+    webFrame()-&gt;page()-&gt;send(Messages::WebPageProxy::SearchWithSpotlight(string));
+}
+
+bool PDFPlugin::handleWheelEvent(const WebWheelEvent&amp; event)
+{
+    PDFDisplayMode displayMode = [m_pdfLayerController displayMode];
+
+    if (displayMode == kPDFDisplaySinglePageContinuous || displayMode == kPDFDisplayTwoUpContinuous)
+        return ScrollableArea::handleWheelEvent(platform(event));
+
+    NSUInteger currentPageIndex = [m_pdfLayerController currentPageIndex];
+    bool inFirstPage = !currentPageIndex;
+    bool inLastPage = [m_pdfLayerController lastPageIndex] == currentPageIndex;
+
+    bool atScrollTop = !scrollPosition().y();
+    bool atScrollBottom = scrollPosition().y() == maximumScrollPosition().y();
+
+    bool inMomentumScroll = event.momentumPhase() != WebWheelEvent::PhaseNone;
+
+    int scrollMagnitudeThresholdForPageFlip = defaultScrollMagnitudeThresholdForPageFlip;
+
+    // Imprecise input devices should have a lower threshold so that &quot;clicky&quot; scroll wheels can flip pages.
+    if (!event.hasPreciseScrollingDeltas())
+        scrollMagnitudeThresholdForPageFlip = 0;
+
+    if (atScrollBottom &amp;&amp; !inLastPage &amp;&amp; event.delta().height() &lt; 0) {
+        if (event.delta().height() &lt;= -scrollMagnitudeThresholdForPageFlip &amp;&amp; !inMomentumScroll)
+            [m_pdfLayerController gotoNextPage];
+        return true;
+    }
+
+    if (atScrollTop &amp;&amp; !inFirstPage &amp;&amp; event.delta().height() &gt; 0) {
+        if (event.delta().height() &gt;= scrollMagnitudeThresholdForPageFlip &amp;&amp; !inMomentumScroll) {
+            [CATransaction begin];
+            [m_pdfLayerController gotoPreviousPage];
+            scrollToOffsetWithoutAnimation(maximumScrollPosition());
+            [CATransaction commit];
+        }
+        return true;
+    }
+
+    return ScrollableArea::handleWheelEvent(platform(event));
+}
+
+NSData *PDFPlugin::liveData() const
+{
+    if (m_activeAnnotation)
+        m_activeAnnotation-&gt;commit();
+
+    // Save data straight from the resource instead of PDFKit if the document is
+    // untouched by the user, so that PDFs which PDFKit can't display will still be downloadable.
+    if (m_pdfDocumentWasMutated)
+        return [m_pdfDocument dataRepresentation];
+    
+    return rawData();
+}
+
+NSObject *PDFPlugin::accessibilityObject() const
+{
+    return m_accessibilityObject.get();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(PDFKIT_PLUGIN)
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFPDFLayerControllerDetailsh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerDetails.h (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerDetails.h        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerDetails.h        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -1,149 +0,0 @@
</span><del>-/*
- * Copyright (C) 2012, 2015 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 &lt;PDFKit/PDFKit.h&gt;
-
-@class CPReadingModel;
-@class PDFViewLayout;
-
-@protocol PDFLayerControllerDelegate &lt;NSObject&gt;
-
-- (void)updateScrollPosition:(CGPoint)newPosition;
-- (void)writeItemsToPasteboard:(NSArray *)items withTypes:(NSArray *)types;
-- (void)showDefinitionForAttributedString:(NSAttributedString *)string atPoint:(CGPoint)point;
-- (void)performWebSearch:(NSString *)string;
-- (void)performSpotlightSearch:(NSString *)string;
-- (void)openWithNativeApplication;
-- (void)saveToPDF;
-
-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeActiveAnnotation:(PDFAnnotation *)annotation;
-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController clickedLinkWithURL:(NSURL *)url;
-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeContentScaleFactor:(CGFloat)scaleFactor;
-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeDisplayMode:(int)mode;
-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeSelection:(PDFSelection *)selection;
-
-@end
-
-@interface PDFLayerController : NSObject
-@end
-
-@interface PDFLayerController (Details)
-
-@property(retain) CALayer *parentLayer;
-@property(retain) PDFDocument *document;
-@property(retain) id&lt;PDFLayerControllerDelegate&gt; delegate;
-
-- (void)setFrameSize:(CGSize)size;
-
-- (PDFDisplayMode)displayMode;
-- (void)setDisplayMode:(PDFDisplayMode)mode;
-- (void)setDisplaysPageBreaks:(BOOL)pageBreaks;
-
-- (CGFloat)contentScaleFactor;
-- (void)setContentScaleFactor:(CGFloat)scaleFactor;
-
-- (CGFloat)deviceScaleFactor;
-- (void)setDeviceScaleFactor:(CGFloat)scaleFactor;
-
-- (CGSize)contentSize;
-- (CGSize)contentSizeRespectingZoom;
-
-- (void)snapshotInContext:(CGContextRef)context;
-
-- (void)magnifyWithMagnification:(CGFloat)magnification atPoint:(CGPoint)point immediately:(BOOL)immediately;
-
-- (CGPoint)scrollPosition;
-- (void)setScrollPosition:(CGPoint)newPosition;
-- (void)scrollWithDelta:(CGSize)delta;
-
-- (void)mouseDown:(NSEvent *)event;
-- (void)rightMouseDown:(NSEvent *)event;
-- (void)mouseMoved:(NSEvent *)event;
-- (void)mouseUp:(NSEvent *)event;
-- (void)mouseDragged:(NSEvent *)event;
-- (void)mouseEntered:(NSEvent *)event;
-- (void)mouseExited:(NSEvent *)event;
-
-- (NSMenu *)menuForEvent:(NSEvent *)event;
-
-- (NSArray *)findString:(NSString *)string caseSensitive:(BOOL)isCaseSensitive highlightMatches:(BOOL)shouldHighlightMatches;
-
-- (PDFSelection *)currentSelection;
-- (void)setCurrentSelection:(PDFSelection *)selection;
-- (PDFSelection *)searchSelection;
-- (void)setSearchSelection:(PDFSelection *)selection;
-- (void)gotoSelection:(PDFSelection *)selection;
-- (PDFSelection *)getSelectionForWordAtPoint:(CGPoint)point;
-- (NSArray *)rectsForSelectionInLayoutSpace:(PDFSelection *)selection;
-- (NSArray *)rectsForAnnotationInLayoutSpace:(PDFAnnotation *)annotation;
-- (PDFViewLayout *)layout;
-- (NSRect)frame;
-
-- (PDFPage *)currentPage;
-- (NSUInteger)lastPageIndex;
-- (NSUInteger)currentPageIndex;
-- (void)gotoNextPage;
-- (void)gotoPreviousPage;
-
-- (void)copySelection;
-- (void)selectAll;
-
-- (bool)keyDown:(NSEvent *)event;
-
-- (void)setHUDEnabled:(BOOL)enabled;
-- (BOOL)hudEnabled;
-
-- (CGRect)boundsForAnnotation:(PDFAnnotation *)annotation;
-- (void)activateNextAnnotation:(BOOL)previous;
-
-- (void)attemptToUnlockWithPassword:(NSString *)password;
-
-- (void)searchInDictionaryWithSelection:(PDFSelection *)selection;
-
-// Accessibility
-
-- (CPReadingModel *)readingModel;
-- (id)accessibilityFocusedUIElement;
-- (NSArray *)accessibilityAttributeNames;
-- (BOOL)accessibilityIsAttributeSettable:(NSString *)attribute;
-- (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute;
-- (NSArray *)accessibilityParameterizedAttributeNames;
-- (NSString *)accessibilityRoleAttribute;
-- (NSString *)accessibilityRoleDescriptionAttribute;
-- (NSString *)accessibilityValueAttribute;
-- (BOOL)accessibilityIsValueAttributeSettable;
-- (NSString *)accessibilitySelectedTextAttribute;
-- (BOOL)accessibilityIsSelectedTextAttributeSettable;
-- (NSValue *)accessibilitySelectedTextRangeAttribute;
-- (NSNumber *)accessibilityNumberOfCharactersAttribute;
-- (BOOL)accessibilityIsNumberOfCharactersAttributeSettable;
-- (NSValue *)accessibilityVisibleCharacterRangeAttribute;
-- (BOOL)accessibilityIsVisibleCharacterRangeAttributeSettable;
-- (NSNumber *)accessibilityLineForIndexAttributeForParameter:(id)parameter;
-- (NSValue *)accessibilityRangeForLineAttributeForParameter:(id)parameter;
-- (NSString *)accessibilityStringForRangeAttributeForParameter:(id)parameter;
-- (NSValue *)accessibilityBoundsForRangeAttributeForParameter:(id)parameter;
-
-@end
</del></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFPDFLayerControllerSPIh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h (0 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -0,0 +1,172 @@
</span><ins>+/*
+ * Copyright (C) 2012, 2015 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.
+ */
+
+#ifndef PDFLayerControllerSPI_h
+#define PDFLayerControllerSPI_h
+
+#include &quot;PDFKitImports.h&quot;
+
+#if ENABLE(PDFKIT_PLUGIN)
+#if USE(DEPRECATED_PDF_PLUGIN)
+
+#include &quot;DeprecatedPDFLayerControllerSPI.h&quot;
+
+#else // USE(DEPRECATED_PDF_PLUGIN)
+
+#import &lt;PDFKit/PDFKit.h&gt;
+
+@class CPReadingModel;
+@class PDFViewLayout;
+
+@protocol PDFLayerControllerDelegate &lt;NSObject&gt;
+
+@optional
+
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController scrollToPoint:(CGPoint)newPosition;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController invalidateRect:(CGRect)rect;
+- (void)pdfLayerControllerInvalidateHUD:(PDFLayerController *)pdfLayerController;
+
+- (void)pdfLayerControllerZoomIn:(PDFLayerController *)pdfLayerController;
+- (void)pdfLayerControllerZoomOut:(PDFLayerController *)pdfLayerController;
+
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeActiveAnnotation:(PDFAnnotation *)annotation;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didClickLinkWithURL:(NSURL *)url;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeDisplayMode:(int)mode;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeSelection:(PDFSelection *)selection;
+
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController copyItems:(NSArray *)items withTypes:(NSArray *)types;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController showDefinitionForAttributedString:(NSAttributedString *)string atPoint:(CGPoint)point;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController performWebSearchForString:(NSString *)string;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController performSpotlightSearchForString:(NSString *)string;
+- (void)pdfLayerControllerSaveToPDF:(PDFLayerController *)pdfLayerController;
+- (void)pdfLayerControllerOpenWithNativeApplication:(PDFLayerController *)pdfLayerController;
+
+- (NSColorSpace*)pdfLayerControllerColorSpace:(PDFLayerController *)pdfLayerController;
+
+@end
+
+@interface PDFLayerController : NSObject
+@end
+
+@interface PDFLayerController ()
+
+@property (retain) PDFDocument *document;
+@property (assign) id&lt;PDFLayerControllerDelegate&gt; delegate;
+@property (retain) NSArray *searchMatches;
+
+- (void)setFrameSize:(CGSize)size;
+
+- (void)setDisplayMode:(int)mode;
+- (int)displayMode;
+- (int)realDisplayMode;
+
+- (CGSize)contentSize;
+- (CGSize)contentSizeRespectingZoom;
+
+- (CGFloat)contentScaleFactor;
+- (void)setContentScaleFactor:(CGFloat)contentScaleFactor;
+
+- (PDFViewLayout *)layout;
+
+- (void)drawInContext:(CGContextRef)context;
+- (void)drawHUDInContext:(CGContextRef)context;
+
+- (void)mouseDown:(NSEvent *)event;
+- (void)mouseUp:(NSEvent *)event;
+- (void)mouseDragged:(NSEvent *)event;
+
+- (BOOL)mouseDown:(NSEvent *)event inHUDWithBounds:(CGRect)bounds;
+- (BOOL)mouseUp:(NSEvent *)event inHUDWithBounds:(CGRect)bounds;
+- (BOOL)mouseDragged:(NSEvent *)event inHUDWithBounds:(CGRect)bounds;
+
+- (NSMenu *)menuForEvent:(NSEvent *)event;
+
+- (NSArray *)pageRects;
+
+- (void)setVisibleRect:(CGRect)visibleRect;
+
+- (void)gotoSelection:(PDFSelection *)selection;
+- (void)gotoDestination:(PDFDestination *)destination;
+- (void)gotoRect:(CGRect)rect onPage:(PDFPage *)page;
+
+- (PDFSelection *)currentSelection;
+- (void)setCurrentSelection:(PDFSelection *)selection;
+
+- (void)searchInDictionaryWithSelection:(PDFSelection *)selection;
+- (PDFSelection *)getSelectionForWordAtPoint:(CGPoint)point;
+- (NSArray *)rectsForSelectionInLayoutSpace:(PDFSelection *)selection;
+
+- (NSArray *)highlights;
+- (void)setHighlights:(NSArray*)highlights;
+
+- (PDFSelection *)searchSelection;
+- (NSArray *)searchMatches;
+- (void)setSearchSelection:(PDFSelection*)selection;
+- (NSArray *)findString:(NSString *)string caseSensitive:(BOOL)isCaseSensitive highlightMatches:(BOOL)shouldHighlightMatches;
+
+- (void)copySelection;
+- (void)selectAll;
+
+- (PDFPage *)currentPage;
+- (NSUInteger)currentPageIndex;
+
+- (BOOL)documentIsLocked;
+- (void)attemptToUnlockWithPassword:(NSString *)password;
+
+- (CGRect)boundsForAnnotation:(PDFAnnotation *)annotation;
+- (void)activateNextAnnotation:(BOOL)previous;
+
+- (NSRect)frame;
+
+// Accessibility
+
+- (CPReadingModel *)readingModel;
+- (id)accessibilityFocusedUIElement;
+- (NSArray *)accessibilityAttributeNames;
+- (BOOL)accessibilityIsAttributeSettable:(NSString *)attribute;
+- (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute;
+- (NSArray *)accessibilityParameterizedAttributeNames;
+- (NSString *)accessibilityRoleAttribute;
+- (NSString *)accessibilityRoleDescriptionAttribute;
+- (NSString *)accessibilityValueAttribute;
+- (BOOL)accessibilityIsValueAttributeSettable;
+- (NSString *)accessibilitySelectedTextAttribute;
+- (BOOL)accessibilityIsSelectedTextAttributeSettable;
+- (NSValue *)accessibilitySelectedTextRangeAttribute;
+- (NSNumber *)accessibilityNumberOfCharactersAttribute;
+- (BOOL)accessibilityIsNumberOfCharactersAttributeSettable;
+- (NSValue *)accessibilityVisibleCharacterRangeAttribute;
+- (BOOL)accessibilityIsVisibleCharacterRangeAttributeSettable;
+- (NSNumber *)accessibilityLineForIndexAttributeForParameter:(id)parameter;
+- (NSValue *)accessibilityRangeForLineAttributeForParameter:(id)parameter;
+- (NSString *)accessibilityStringForRangeAttributeForParameter:(id)parameter;
+- (NSValue *)accessibilityBoundsForRangeAttributeForParameter:(id)parameter;
+
+@end
+
+#endif // USE(DEPRECATED_PDF_PLUGIN)
+#endif // ENABLE(PDFPLUGIN)
+
+#endif // PDFLayerControllerSPI_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFPDFPluginh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -26,13 +26,21 @@
</span><span class="cx"> #ifndef PDFPlugin_h
</span><span class="cx"> #define PDFPlugin_h
</span><span class="cx"> 
</span><ins>+#include &quot;PDFKitImports.h&quot;
+
</ins><span class="cx"> #if ENABLE(PDFKIT_PLUGIN)
</span><ins>+#if USE(DEPRECATED_PDF_PLUGIN)
</ins><span class="cx"> 
</span><ins>+#include &quot;DeprecatedPDFPlugin.h&quot;
+
+#else // USE(DEPRECATED_PDF_PLUGIN)
+
</ins><span class="cx"> #include &quot;Plugin.h&quot;
</span><span class="cx"> #include &quot;WebEvent.h&quot;
</span><span class="cx"> #include &quot;WebHitTestResultData.h&quot;
</span><span class="cx"> #include &lt;WebCore/AffineTransform.h&gt;
</span><span class="cx"> #include &lt;WebCore/FindOptions.h&gt;
</span><ins>+#include &lt;WebCore/PageOverlay.h&gt;
</ins><span class="cx"> #include &lt;WebCore/ScrollableArea.h&gt;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -66,7 +74,7 @@
</span><span class="cx"> class PluginView;
</span><span class="cx"> class WebFrame;
</span><span class="cx"> 
</span><del>-class PDFPlugin final : public Plugin, private WebCore::ScrollableArea {
</del><ins>+class PDFPlugin final : public Plugin {
</ins><span class="cx"> public:
</span><span class="cx">     static Ref&lt;PDFPlugin&gt; create(WebFrame*);
</span><span class="cx">     ~PDFPlugin();
</span><span class="lines">@@ -74,14 +82,12 @@
</span><span class="cx">     static WebCore::PluginInfo pluginInfo();
</span><span class="cx"> 
</span><span class="cx">     WebCore::IntSize size() const { return m_size; }
</span><ins>+    float scaleFactor() const;
</ins><span class="cx"> 
</span><span class="cx">     void didMutatePDFDocument() { m_pdfDocumentWasMutated = true; }
</span><span class="cx"> 
</span><del>-    void paintControlForLayerInContext(CALayer *, CGContextRef);
</del><span class="cx">     void setActiveAnnotation(PDFAnnotation *);
</span><del>-    
-    using ScrollableArea::notifyScrollPositionChanged;
-    void notifyContentScaleFactorChanged(CGFloat scaleFactor);
</del><ins>+
</ins><span class="cx">     void notifyDisplayModeChanged(int);
</span><span class="cx"> 
</span><span class="cx">     void notifySelectionChanged(PDFSelection *);
</span><span class="lines">@@ -93,37 +99,52 @@
</span><span class="cx">     void showDefinitionForAttributedString(NSAttributedString *, CGPoint);
</span><span class="cx">     void performWebSearch(NSString *);
</span><span class="cx">     void performSpotlightSearch(NSString *);
</span><ins>+    void invalidatePDFRect(WebCore::IntRect);
+    void invalidateHUD();
+    void scrollToPoint(WebCore::IntPoint);
</ins><span class="cx"> 
</span><ins>+    void zoomIn();
+    void zoomOut();
+
</ins><span class="cx">     void focusNextAnnotation();
</span><span class="cx">     void focusPreviousAnnotation();
</span><span class="cx"> 
</span><span class="cx">     void attemptToUnlockPDF(const String&amp; password);
</span><span class="cx"> 
</span><ins>+    WebCore::IntPoint convertFromPluginToPDFView(const WebCore::IntPoint&amp;) const;
+    WebCore::IntPoint convertFromRootViewToPlugin(const WebCore::IntPoint&amp;) const;
+    WebCore::IntPoint convertFromPDFViewToRootView(const WebCore::IntPoint&amp;) const;
+
+    WebCore::IntRect convertFromPDFViewToRootView(const WebCore::IntRect&amp;) const;
</ins><span class="cx">     WebCore::FloatRect convertFromPDFViewToScreen(const WebCore::FloatRect&amp;) const;
</span><ins>+
</ins><span class="cx">     WebCore::IntRect boundsOnScreen() const;
</span><span class="cx">     
</span><span class="cx">     bool showContextMenuAtPoint(const WebCore::IntPoint&amp;);
</span><span class="cx"> 
</span><span class="cx">     String lookupTextAtLocation(const WebCore::FloatPoint&amp;, WebHitTestResultData&amp;, PDFSelection **, NSDictionary **) const;
</span><del>-    WebCore::FloatRect viewRectForSelection(PDFSelection *) const;
</del><ins>+    WebCore::FloatRect rectForSelectionInRootView(PDFSelection *) const;
</ins><span class="cx"> 
</span><del>-    CGFloat scaleFactor() const;
</del><ins>+    PDFLayerController *pdfLayerController() const { return m_pdfLayerController.get(); }
+    WebFrame* webFrame() const { return m_frame; }
</ins><span class="cx"> 
</span><ins>+    bool isLocked() const;
+
</ins><span class="cx"> private:
</span><span class="cx">     explicit PDFPlugin(WebFrame*);
</span><span class="cx"> 
</span><span class="cx">     // Plugin functions.
</span><span class="cx">     virtual bool initialize(const Parameters&amp;) override;
</span><span class="cx">     virtual void destroy() override;
</span><del>-    virtual void paint(WebCore::GraphicsContext&amp;, const WebCore::IntRect&amp; dirtyRectInWindowCoordinates) override { }
-    virtual void updateControlTints(WebCore::GraphicsContext&amp;) override;
-    virtual bool supportsSnapshotting() const override { return true; }
</del><ins>+    virtual void paint(WebCore::GraphicsContext&amp;, const WebCore::IntRect&amp; dirtyRectInWindowCoordinates) override;
+    virtual void updateControlTints(WebCore::GraphicsContext&amp;) override { }
+    virtual bool supportsSnapshotting() const override { return false; }
</ins><span class="cx">     virtual RefPtr&lt;ShareableBitmap&gt; snapshot() override;
</span><del>-    virtual PlatformLayer* pluginLayer() override;
</del><ins>+    virtual PlatformLayer* pluginLayer() override { return nullptr; }
</ins><span class="cx">     virtual bool isTransparent() override { return false; }
</span><del>-    virtual bool wantsWheelEvents() override { return true; }
</del><ins>+    virtual bool wantsWheelEvents() override { return false; }
</ins><span class="cx">     virtual void geometryDidChange(const WebCore::IntSize&amp; pluginSize, const WebCore::IntRect&amp; clipRect, const WebCore::AffineTransform&amp; pluginToRootViewTransform) override;
</span><del>-    virtual void contentsScaleFactorChanged(float) override;
</del><ins>+    virtual void contentsScaleFactorChanged(float) override { }
</ins><span class="cx">     virtual void visibilityDidChange(bool) override { }
</span><span class="cx">     virtual void frameDidFinishLoading(uint64_t requestID) override;
</span><span class="cx">     virtual void frameDidFail(uint64_t requestID, bool wasCancelled) override;
</span><span class="lines">@@ -138,30 +159,32 @@
</span><span class="cx">     virtual void manualStreamDidFinishLoading() override;
</span><span class="cx">     virtual void manualStreamDidFail(bool wasCancelled) override;
</span><span class="cx">     virtual bool handleMouseEvent(const WebMouseEvent&amp;) override;
</span><del>-    virtual bool handleWheelEvent(const WebWheelEvent&amp;) override;
</del><ins>+    virtual bool handleWheelEvent(const WebWheelEvent&amp;) override { return false; }
</ins><span class="cx">     virtual bool handleMouseEnterEvent(const WebMouseEvent&amp;) override;
</span><span class="cx">     virtual bool handleMouseLeaveEvent(const WebMouseEvent&amp;) override;
</span><span class="cx">     virtual bool handleContextMenuEvent(const WebMouseEvent&amp;) override;
</span><del>-    virtual bool handleKeyboardEvent(const WebKeyboardEvent&amp;) override;
</del><ins>+    virtual bool handleKeyboardEvent(const WebKeyboardEvent&amp;) override { return false; }
</ins><span class="cx">     virtual bool handleEditingCommand(const String&amp; commandName, const String&amp; argument) override;
</span><span class="cx">     virtual bool isEditingCommandEnabled(const String&amp;) override;
</span><del>-    virtual bool handlesPageScaleFactor() override;
</del><span class="cx">     virtual void setFocus(bool) override { }
</span><del>-    virtual NPObject* pluginScriptableNPObject() override { return 0; }
</del><ins>+    virtual NPObject* pluginScriptableNPObject() override { return nullptr; }
</ins><span class="cx">     virtual void windowFocusChanged(bool) override { }
</span><span class="cx">     virtual void windowAndViewFramesChanged(const WebCore::IntRect&amp; windowFrameInScreenCoordinates, const WebCore::IntRect&amp; viewFrameInWindowCoordinates) override { }
</span><span class="cx">     virtual void windowVisibilityChanged(bool) override { }
</span><span class="cx">     virtual uint64_t pluginComplexTextInputIdentifier() const override { return 0; }
</span><span class="cx">     virtual void sendComplexTextInput(const String&amp; textInput) override { }
</span><span class="cx">     virtual void setLayerHostingMode(LayerHostingMode) override { }
</span><del>-    virtual WebCore::Scrollbar* horizontalScrollbar() override { return m_horizontalScrollbar.get(); }
-    virtual WebCore::Scrollbar* verticalScrollbar() override { return m_verticalScrollbar.get(); }
</del><ins>+    virtual WebCore::Scrollbar* horizontalScrollbar() override { return nullptr; }
+    virtual WebCore::Scrollbar* verticalScrollbar() override { return nullptr; }
</ins><span class="cx">     virtual void storageBlockingStateChanged(bool) override { }
</span><span class="cx">     virtual void privateBrowsingStateChanged(bool) override { }
</span><span class="cx">     virtual bool getFormValue(String&amp; formValue) override { return false; }
</span><del>-    virtual bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity) override;
</del><ins>+    virtual bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity) override { return false; }
</ins><span class="cx">     virtual RefPtr&lt;WebCore::SharedBuffer&gt; liveResourceData() const override;
</span><span class="cx"> 
</span><ins>+    virtual bool handlesPageScaleFactor() const override { return false; }
+    virtual bool requiresUnifiedScaleFactor() const override { return true; }
+
</ins><span class="cx">     virtual bool isBeingAsynchronouslyInitialized() const override { return false; }
</span><span class="cx"> 
</span><span class="cx">     virtual RetainPtr&lt;PDFDocument&gt; pdfDocumentForPrinting() const override { return m_pdfDocument; }
</span><span class="lines">@@ -180,57 +203,21 @@
</span><span class="cx">     virtual bool shouldAllowScripting() override { return false; }
</span><span class="cx">     virtual bool shouldAllowNavigationFromDrags() override { return true; }
</span><span class="cx">     virtual bool shouldAlwaysAutoStart() const override { return true; }
</span><ins>+    virtual bool canCreateTransientPaintingSnapshot() const override { return false; }
</ins><span class="cx"> 
</span><del>-    // ScrollableArea functions.
-    virtual WebCore::IntRect scrollCornerRect() const override;
-    virtual WebCore::ScrollableArea* enclosingScrollableArea() const override;
-    virtual bool isScrollableOrRubberbandable() override { return true; }
-    virtual bool hasScrollableOrRubberbandableAncestor() override { return true; }
-    virtual WebCore::IntRect scrollableAreaBoundingBox() const override;
-    virtual void setScrollOffset(const WebCore::IntPoint&amp;) override;
-    virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&amp;) override;
-    virtual void invalidateScrollCornerRect(const WebCore::IntRect&amp;) override;
-    virtual WebCore::IntPoint lastKnownMousePosition() const override { return m_lastMousePositionInPluginCoordinates; }
-    virtual int scrollSize(WebCore::ScrollbarOrientation) const override;
-    virtual bool isActive() const override;
-    virtual bool isScrollCornerVisible() const override { return false; }
-    virtual int scrollPosition(WebCore::Scrollbar*) const override;
-    virtual WebCore::IntPoint scrollPosition() const override;
-    virtual WebCore::IntPoint minimumScrollPosition() const override;
-    virtual WebCore::IntPoint maximumScrollPosition() const override;
-    virtual WebCore::IntSize visibleSize() const override { return m_size; }
-    virtual WebCore::IntSize contentsSize() const override { return m_pdfDocumentSize; }
-    virtual WebCore::Scrollbar* horizontalScrollbar() const override { return m_horizontalScrollbar.get(); }
-    virtual WebCore::Scrollbar* verticalScrollbar() const override { return m_verticalScrollbar.get(); }
-    virtual bool shouldSuspendScrollAnimations() const override { return false; } // If we return true, ScrollAnimatorMac will keep cycling a timer forever, waiting for a good time to animate.
-    virtual void scrollbarStyleChanged(WebCore::ScrollbarStyle, bool forceUpdate) override;
-    virtual WebCore::IntRect convertFromScrollbarToContainingView(const WebCore::Scrollbar*, const WebCore::IntRect&amp; scrollbarRect) const override;
-    virtual WebCore::IntRect convertFromContainingViewToScrollbar(const WebCore::Scrollbar*, const WebCore::IntRect&amp; parentRect) const override;
-    virtual WebCore::IntPoint convertFromScrollbarToContainingView(const WebCore::Scrollbar*, const WebCore::IntPoint&amp; scrollbarPoint) const override;
-    virtual WebCore::IntPoint convertFromContainingViewToScrollbar(const WebCore::Scrollbar*, const WebCore::IntPoint&amp; parentPoint) const override;
-    virtual bool updatesScrollLayerPositionOnMainThread() const override { return true; }
-    virtual bool forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const override;
-
</del><span class="cx">     // PDFPlugin functions.
</span><del>-    void updateScrollbars();
-    PassRefPtr&lt;WebCore::Scrollbar&gt; createScrollbar(WebCore::ScrollbarOrientation);
-    void destroyScrollbar(WebCore::ScrollbarOrientation);
</del><span class="cx">     void pdfDocumentDidLoad();
</span><span class="cx">     void addArchiveResource();
</span><span class="cx">     void computePageBoxes();
</span><span class="cx">     void calculateSizes();
</span><ins>+    void didCalculateSizes();
</ins><span class="cx">     void runScriptsInPDFDocument();
</span><span class="cx"> 
</span><span class="cx">     NSEvent *nsEventForWebMouseEvent(const WebMouseEvent&amp;);
</span><del>-    WebCore::IntPoint convertFromPluginToPDFView(const WebCore::IntPoint&amp;) const;
-    WebCore::IntPoint convertFromRootViewToPlugin(const WebCore::IntPoint&amp;) const;
-    WebCore::IntPoint convertFromPDFViewToRootView(const WebCore::IntPoint&amp;) const;
-    
</del><ins>+
</ins><span class="cx">     bool supportsForms();
</span><del>-    bool isFullFramePlugin();
</del><ins>+    bool isFullFramePlugin() const;
</ins><span class="cx"> 
</span><del>-    void updatePageAndDeviceScaleFactors();
-
</del><span class="cx">     void createPasswordEntryForm();
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;PDFDocument&gt; pdfDocument() const { return m_pdfDocument; }
</span><span class="lines">@@ -242,49 +229,67 @@
</span><span class="cx">     NSData *liveData() const;
</span><span class="cx">     NSData *rawData() const { return (NSData *)m_data.get(); }
</span><span class="cx"> 
</span><del>-    WebFrame* webFrame() const { return m_frame; }
-
-    enum UpdateCursorMode {
-        UpdateIfNeeded,
-        ForceUpdate
</del><ins>+    enum class UpdateCursor {
+        IfNeeded,
+        Force
</ins><span class="cx">     };
</span><span class="cx"> 
</span><del>-    enum HitTestResult {
</del><ins>+    enum class HitTestResult {
</ins><span class="cx">         None,
</span><del>-        Text
</del><ins>+        Text,
+        HUD
</ins><span class="cx">     };
</span><span class="cx"> 
</span><del>-    void updateCursor(const WebMouseEvent&amp;, UpdateCursorMode = UpdateIfNeeded);
</del><ins>+    void updateCursor(const WebMouseEvent&amp;, UpdateCursor = UpdateCursor::IfNeeded);
</ins><span class="cx"> 
</span><span class="cx">     JSObjectRef makeJSPDFDoc(JSContextRef);
</span><span class="cx">     static JSValueRef jsPDFDocPrint(JSContextRef, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
</span><span class="cx"> 
</span><span class="cx">     void convertPostScriptDataIfNeeded();
</span><span class="cx"> 
</span><del>-    // Regular plug-ins don't need access to view, but we add scrollbars to embedding FrameView for proper event handling.
</del><span class="cx">     PluginView* pluginView();
</span><span class="cx">     const PluginView* pluginView() const;
</span><span class="cx"> 
</span><ins>+    class HUD : public WebCore::PageOverlay::Client {
+    public:
+        explicit HUD(PDFPlugin&amp; plugin);
+        virtual ~HUD();
+
+        void invalidate();
+        bool containsPointInRootView(WebCore::IntPoint);
+
+        enum class AnimateVisibilityTransition { No, Yes };
+        void setVisible(bool, AnimateVisibilityTransition);
+
+    private:
+        virtual void pageOverlayDestroyed(WebCore::PageOverlay&amp;) override;
+        virtual void willMoveToPage(WebCore::PageOverlay&amp;, WebCore::Page*) override;
+        virtual void didMoveToPage(WebCore::PageOverlay&amp;, WebCore::Page*) override;
+        virtual void drawRect(WebCore::PageOverlay&amp;, WebCore::GraphicsContext&amp;, const WebCore::IntRect&amp; dirtyRect) override;
+        virtual bool mouseEvent(WebCore::PageOverlay&amp;, const WebCore::PlatformMouseEvent&amp;) override;
+
+        WebCore::IntRect frameInRootView() const;
+
+        bool m_visible { false };
+        Ref&lt;WebCore::PageOverlay&gt; m_overlay;
+        PDFPlugin&amp; m_plugin;
+    };
+
</ins><span class="cx">     WebFrame* m_frame;
</span><span class="cx"> 
</span><del>-    bool m_isPostScript;
-    bool m_pdfDocumentWasMutated;
</del><ins>+    bool m_isPostScript { false };
+    bool m_pdfDocumentWasMutated { false };
+    bool m_usingContinuousMode { true };
</ins><span class="cx"> 
</span><del>-    WebCore::IntSize m_scrollOffset;
-
-    RetainPtr&lt;CALayer&gt; m_containerLayer;
-    RetainPtr&lt;CALayer&gt; m_contentLayer;
-    RetainPtr&lt;CALayer&gt; m_horizontalScrollbarLayer;
-    RetainPtr&lt;CALayer&gt; m_verticalScrollbarLayer;
-    RetainPtr&lt;CALayer&gt; m_scrollCornerLayer;
</del><span class="cx">     RetainPtr&lt;PDFLayerController&gt; m_pdfLayerController;
</span><span class="cx">     RetainPtr&lt;WKPDFPluginAccessibilityObject&gt; m_accessibilityObject;
</span><del>-    
</del><ins>+
</ins><span class="cx">     RefPtr&lt;PDFPluginAnnotation&gt; m_activeAnnotation;
</span><span class="cx">     RefPtr&lt;PDFPluginPasswordField&gt; m_passwordField;
</span><del>-    RefPtr&lt;WebCore::Element&gt; m_annotationContainer;
</del><ins>+    RefPtr&lt;WebCore::Element&gt; m_passwordContainer;
</ins><span class="cx"> 
</span><span class="cx">     WebCore::AffineTransform m_rootViewToPluginTransform;
</span><ins>+    WebCore::AffineTransform m_pluginToRootViewTransform;
</ins><span class="cx">     WebMouseEvent m_lastMouseEvent;
</span><span class="cx">     WebCore::IntPoint m_lastMousePositionInPluginCoordinates;
</span><span class="cx"> 
</span><span class="lines">@@ -304,17 +309,16 @@
</span><span class="cx">     RetainPtr&lt;CFMutableDataRef&gt; m_data;
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;PDFDocument&gt; m_pdfDocument;
</span><del>-    Vector&lt;WebCore::IntRect&gt; m_pageBoxes;
</del><span class="cx">     WebCore::IntSize m_pdfDocumentSize; // All pages, including gaps.
</span><span class="cx"> 
</span><del>-    RefPtr&lt;WebCore::Scrollbar&gt; m_horizontalScrollbar;
-    RefPtr&lt;WebCore::Scrollbar&gt; m_verticalScrollbar;
</del><ins>+    HUD m_HUD;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> SPECIALIZE_TYPE_TRAITS_PLUGIN(PDFPlugin, PDFPluginType)
</span><span class="cx"> 
</span><ins>+#endif // USE(DEPRECATED_PDF_PLUGIN)
</ins><span class="cx"> #endif // ENABLE(PDFKIT_PLUGIN)
</span><span class="cx"> 
</span><span class="cx"> #endif // PDFPlugin_h
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFPDFPluginmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -26,13 +26,12 @@
</span><span class="cx"> #import &quot;config.h&quot;
</span><span class="cx"> #import &quot;PDFPlugin.h&quot;
</span><span class="cx"> 
</span><del>-#if ENABLE(PDFKIT_PLUGIN)
</del><ins>+#if ENABLE(PDFKIT_PLUGIN) &amp;&amp; !USE(DEPRECATED_PDF_PLUGIN)
</ins><span class="cx"> 
</span><span class="cx"> #import &quot;ArgumentCoders.h&quot;
</span><span class="cx"> #import &quot;DataReference.h&quot;
</span><span class="cx"> #import &quot;PDFAnnotationTextWidgetDetails.h&quot;
</span><del>-#import &quot;PDFKitImports.h&quot;
-#import &quot;PDFLayerControllerDetails.h&quot;
</del><ins>+#import &quot;PDFLayerControllerSPI.h&quot;
</ins><span class="cx"> #import &quot;PDFPluginAnnotation.h&quot;
</span><span class="cx"> #import &quot;PDFPluginPasswordField.h&quot;
</span><span class="cx"> #import &quot;PluginView.h&quot;
</span><span class="lines">@@ -62,6 +61,7 @@
</span><span class="cx"> #import &lt;WebCore/FrameLoader.h&gt;
</span><span class="cx"> #import &lt;WebCore/FrameView.h&gt;
</span><span class="cx"> #import &lt;WebCore/GraphicsContext.h&gt;
</span><ins>+#import &lt;WebCore/GraphicsLayerCA.h&gt;
</ins><span class="cx"> #import &lt;WebCore/HTMLElement.h&gt;
</span><span class="cx"> #import &lt;WebCore/HTMLFormElement.h&gt;
</span><span class="cx"> #import &lt;WebCore/HTMLPlugInElement.h&gt;
</span><span class="lines">@@ -69,35 +69,32 @@
</span><span class="cx"> #import &lt;WebCore/MainFrame.h&gt;
</span><span class="cx"> #import &lt;WebCore/MouseEvent.h&gt;
</span><span class="cx"> #import &lt;WebCore/Page.h&gt;
</span><ins>+#import &lt;WebCore/PageOverlayController.h&gt;
</ins><span class="cx"> #import &lt;WebCore/Pasteboard.h&gt;
</span><ins>+#import &lt;WebCore/PlatformCAAnimationCocoa.h&gt;
</ins><span class="cx"> #import &lt;WebCore/PluginData.h&gt;
</span><span class="cx"> #import &lt;WebCore/PluginDocument.h&gt;
</span><span class="cx"> #import &lt;WebCore/RenderBoxModelObject.h&gt;
</span><del>-#import &lt;WebCore/ScrollAnimator.h&gt;
-#import &lt;WebCore/ScrollbarTheme.h&gt;
</del><span class="cx"> #import &lt;WebCore/Settings.h&gt;
</span><span class="cx"> #import &lt;WebCore/UUID.h&gt;
</span><del>-#import &lt;WebCore/WheelEventTestTrigger.h&gt;
</del><span class="cx"> #import &lt;WebKitSystemInterface.h&gt;
</span><span class="cx"> #import &lt;wtf/CurrentTime.h&gt;
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><del>-// Set overflow: hidden on the annotation container so &lt;input&gt; elements scrolled out of view don't show
-// scrollbars on the body. We can't add annotations directly to the body, because overflow: hidden on the body
-// will break rubber-banding.
</del><span class="cx"> static const char* annotationStyle =
</span><del>-&quot;#annotationContainer {&quot;
-&quot;    overflow: hidden; &quot;
-&quot;    position: absolute; &quot;
-&quot;    pointer-events: none; &quot;
</del><ins>+&quot;body { &quot;
+&quot;    background-color: rgb(146, 146, 146) !important;&quot;
+&quot;} &quot;
+&quot;#passwordContainer {&quot;
+&quot;    display: -webkit-box; &quot;
+&quot;    -webkit-box-align: center; &quot;
+&quot;    -webkit-box-pack: center; &quot;
+&quot;    position: fixed; &quot;
</ins><span class="cx"> &quot;    top: 0; &quot;
</span><span class="cx"> &quot;    left: 0; &quot;
</span><span class="cx"> &quot;    right: 0; &quot;
</span><span class="cx"> &quot;    bottom: 0; &quot;
</span><del>-&quot;    display: -webkit-box; &quot;
-&quot;    -webkit-box-align: center; &quot;
-&quot;    -webkit-box-pack: center; &quot;
</del><span class="cx"> &quot;} &quot;
</span><span class="cx"> &quot;.annotation { &quot;
</span><span class="cx"> &quot;    position: absolute; &quot;
</span><span class="lines">@@ -112,9 +109,7 @@
</span><span class="cx"> &quot;    margin-top: 100px; &quot;
</span><span class="cx"> &quot;} &quot;;
</span><span class="cx"> 
</span><del>-// In non-continuous modes, a single scroll event with a magnitude of &gt;= 20px
-// will jump to the next or previous page, to match PDFKit behavior.
-static const int defaultScrollMagnitudeThresholdForPageFlip = 20;
</del><ins>+const double zoomButtonScaleMultiplier = 1.18920;
</ins><span class="cx"> 
</span><span class="cx"> @interface WKPDFPluginAccessibilityObject : NSObject {
</span><span class="cx">     PDFLayerController *_pdfLayerController;
</span><span class="lines">@@ -276,41 +271,6 @@
</span><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span><del>-
-@interface WKPDFPluginScrollbarLayer : CALayer {
-    WebKit::PDFPlugin* _pdfPlugin;
-}
-
-@property (assign) WebKit::PDFPlugin* pdfPlugin;
-
-@end
-
-@implementation WKPDFPluginScrollbarLayer
-
-@synthesize pdfPlugin=_pdfPlugin;
-
-- (id)initWithPDFPlugin:(WebKit::PDFPlugin *)plugin
-{
-    if (!(self = [super init]))
-        return nil;
-    
-    _pdfPlugin = plugin;
-    
-    return self;
-}
-
-- (id&lt;CAAction&gt;)actionForKey:(NSString *)key
-{
-    return nil;
-}
-
-- (void)drawInContext:(CGContextRef)ctx
-{
-    _pdfPlugin-&gt;paintControlForLayerInContext(self, ctx);
-}
-
-@end
-
</del><span class="cx"> @interface WKPDFLayerControllerDelegate : NSObject&lt;PDFLayerControllerDelegate&gt; {
</span><span class="cx">     WebKit::PDFPlugin* _pdfPlugin;
</span><span class="cx"> }
</span><span class="lines">@@ -333,42 +293,42 @@
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)updateScrollPosition:(CGPoint)newPosition
</del><ins>+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController scrollToPoint:(CGPoint)newPosition
</ins><span class="cx"> {
</span><del>-    _pdfPlugin-&gt;notifyScrollPositionChanged(IntPoint(newPosition));
</del><ins>+    _pdfPlugin-&gt;scrollToPoint(IntPoint(newPosition));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)writeItemsToPasteboard:(NSArray *)items withTypes:(NSArray *)types
</del><ins>+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController copyItems:(NSArray *)items withTypes:(NSArray *)types
</ins><span class="cx"> {
</span><span class="cx">     _pdfPlugin-&gt;writeItemsToPasteboard(NSGeneralPboard, items, types);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)showDefinitionForAttributedString:(NSAttributedString *)string atPoint:(CGPoint)point
</del><ins>+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController showDefinitionForAttributedString:(NSAttributedString *)string atPoint:(CGPoint)point
</ins><span class="cx"> {
</span><span class="cx">     _pdfPlugin-&gt;showDefinitionForAttributedString(string, point);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)performWebSearch:(NSString *)string
</del><ins>+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController performWebSearchForString:(NSString *)string
</ins><span class="cx"> {
</span><span class="cx">     _pdfPlugin-&gt;performWebSearch(string);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)performSpotlightSearch:(NSString *)string
</del><ins>+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController performSpotlightSearchForString:(NSString *)string
</ins><span class="cx"> {
</span><span class="cx">     _pdfPlugin-&gt;performSpotlightSearch(string);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)openWithNativeApplication
</del><ins>+- (void)pdfLayerControllerOpenWithNativeApplication:(PDFLayerController *)pdfLayerController
</ins><span class="cx"> {
</span><span class="cx">     _pdfPlugin-&gt;openWithNativeApplication();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)saveToPDF
</del><ins>+- (void)pdfLayerControllerSaveToPDF:(PDFLayerController *)pdfLayerController
</ins><span class="cx"> {
</span><span class="cx">     _pdfPlugin-&gt;saveToPDF();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController clickedLinkWithURL:(NSURL *)url
</del><ins>+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didClickLinkWithURL:(NSURL *)url
</ins><span class="cx"> {
</span><span class="cx">     _pdfPlugin-&gt;clickedLink(url);
</span><span class="cx"> }
</span><span class="lines">@@ -378,11 +338,6 @@
</span><span class="cx">     _pdfPlugin-&gt;setActiveAnnotation(annotation);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeContentScaleFactor:(CGFloat)scaleFactor
-{
-    _pdfPlugin-&gt;notifyContentScaleFactorChanged(scaleFactor);
-}
-
</del><span class="cx"> - (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeDisplayMode:(int)mode
</span><span class="cx"> {
</span><span class="cx">     _pdfPlugin-&gt;notifyDisplayModeChanged(mode);
</span><span class="lines">@@ -393,8 +348,52 @@
</span><span class="cx">     _pdfPlugin-&gt;notifySelectionChanged(selection);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController invalidateRect:(CGRect)rect
+{
+    _pdfPlugin-&gt;invalidatePDFRect(enclosingIntRect(rect));
+}
+
+- (void)pdfLayerControllerInvalidateHUD:(PDFLayerController *)pdfLayerController
+{
+    _pdfPlugin-&gt;invalidateHUD();
+}
+
+- (void)pdfLayerControllerZoomIn:(PDFLayerController *)pdfLayerController
+{
+    _pdfPlugin-&gt;zoomIn();
+}
+
+- (void)pdfLayerControllerZoomOut:(PDFLayerController *)pdfLayerController
+{
+    _pdfPlugin-&gt;zoomOut();
+}
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+@interface WKPDFHUDAnimationDelegate : NSObject {
+    std::function&lt;void (bool)&gt; _completionHandler;
+}
+@end
+
+@implementation WKPDFHUDAnimationDelegate
+
+- (id)initWithAnimationCompletionHandler:(std::function&lt;void (bool)&gt;)completionHandler
+{
+    if (!(self = [super init]))
+        return nil;
+
+    _completionHandler = WTF::move(completionHandler);
+
+    return self;
+}
+
+- (void)animationDidStop:(CAAnimation *)animation finished:(BOOL)flag
+{
+    _completionHandler(flag);
+}
+
+@end
+
</ins><span class="cx"> @interface PDFViewLayout
</span><span class="cx"> - (NSPoint)convertPoint:(NSPoint)point toPage:(PDFPage *)page forScaleFactor:(CGFloat)scaleFactor;
</span><span class="cx"> - (NSRect)convertRect:(NSRect)rect fromPage:(PDFPage *) page forScaleFactor:(CGFloat) scaleFactor;
</span><span class="lines">@@ -509,35 +508,24 @@
</span><span class="cx"> PDFPlugin::PDFPlugin(WebFrame* frame)
</span><span class="cx">     : Plugin(PDFPluginType)
</span><span class="cx">     , m_frame(frame)
</span><del>-    , m_isPostScript(false)
-    , m_pdfDocumentWasMutated(false)
-    , m_containerLayer(adoptNS([[CALayer alloc] init]))
-    , m_contentLayer(adoptNS([[CALayer alloc] init]))
-    , m_scrollCornerLayer(adoptNS([[WKPDFPluginScrollbarLayer alloc] initWithPDFPlugin:this]))
</del><span class="cx">     , m_pdfLayerController(adoptNS([[pdfLayerControllerClass() alloc] init]))
</span><span class="cx">     , m_pdfLayerControllerDelegate(adoptNS([[WKPDFLayerControllerDelegate alloc] initWithPDFPlugin:this]))
</span><ins>+    , m_HUD(*this)
</ins><span class="cx"> {
</span><del>-    m_pdfLayerController.get().delegate = m_pdfLayerControllerDelegate.get();
-    m_pdfLayerController.get().parentLayer = m_contentLayer.get();
</del><ins>+    [m_pdfLayerController setDelegate:m_pdfLayerControllerDelegate.get()];
</ins><span class="cx"> 
</span><span class="cx">     if (supportsForms()) {
</span><span class="cx">         Document* document = webFrame()-&gt;coreFrame()-&gt;document();
</span><del>-        m_annotationContainer = document-&gt;createElement(divTag, false);
-        m_annotationContainer-&gt;setAttribute(idAttr, &quot;annotationContainer&quot;);
</del><span class="cx"> 
</span><span class="cx">         Ref&lt;Element&gt; annotationStyleElement = document-&gt;createElement(styleTag, false);
</span><span class="cx">         annotationStyleElement-&gt;setTextContent(annotationStyle, ASSERT_NO_EXCEPTION);
</span><span class="cx"> 
</span><del>-        m_annotationContainer-&gt;appendChild(WTF::move(annotationStyleElement));
-        document-&gt;bodyOrFrameset()-&gt;appendChild(*m_annotationContainer);
</del><ins>+        document-&gt;bodyOrFrameset()-&gt;appendChild(annotationStyleElement.get());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_accessibilityObject = adoptNS([[WKPDFPluginAccessibilityObject alloc] initWithPDFPlugin:this]);
</span><del>-    m_accessibilityObject.get().pdfLayerController = m_pdfLayerController.get();
-    m_accessibilityObject.get().parent = webFrame()-&gt;page()-&gt;accessibilityRemoteObject();
-
-    [m_containerLayer addSublayer:m_contentLayer.get()];
-    [m_containerLayer addSublayer:m_scrollCornerLayer.get()];
</del><ins>+    [m_accessibilityObject setPdfLayerController:m_pdfLayerController.get()];
+    [m_accessibilityObject setParent:webFrame()-&gt;page()-&gt;accessibilityRemoteObject()];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PDFPlugin::~PDFPlugin()
</span><span class="lines">@@ -572,74 +560,6 @@
</span><span class="cx">     return info;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PDFPlugin::updateScrollbars()
-{
-    bool hadScrollbars = m_horizontalScrollbar || m_verticalScrollbar;
-
-    if (m_horizontalScrollbar) {
-        if (m_size.width() &gt;= m_pdfDocumentSize.width())
-            destroyScrollbar(HorizontalScrollbar);
-    } else if (m_size.width() &lt; m_pdfDocumentSize.width())
-        m_horizontalScrollbar = createScrollbar(HorizontalScrollbar);
-
-    if (m_verticalScrollbar) {
-        if (m_size.height() &gt;= m_pdfDocumentSize.height())
-            destroyScrollbar(VerticalScrollbar);
-    } else if (m_size.height() &lt; m_pdfDocumentSize.height())
-        m_verticalScrollbar = createScrollbar(VerticalScrollbar);
-
-    int horizontalScrollbarHeight = (m_horizontalScrollbar &amp;&amp; !m_horizontalScrollbar-&gt;isOverlayScrollbar()) ? m_horizontalScrollbar-&gt;height() : 0;
-    int verticalScrollbarWidth = (m_verticalScrollbar &amp;&amp; !m_verticalScrollbar-&gt;isOverlayScrollbar()) ? m_verticalScrollbar-&gt;width() : 0;
-
-    int pageStep = m_pageBoxes.isEmpty() ? 0 : m_pageBoxes[0].height();
-
-    if (m_horizontalScrollbar) {
-        m_horizontalScrollbar-&gt;setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
-        m_horizontalScrollbar-&gt;setProportion(m_size.width() - verticalScrollbarWidth, m_pdfDocumentSize.width());
-        IntRect scrollbarRect(pluginView()-&gt;x(), pluginView()-&gt;y() + m_size.height() - m_horizontalScrollbar-&gt;height(), m_size.width(), m_horizontalScrollbar-&gt;height());
-        if (m_verticalScrollbar)
-            scrollbarRect.contract(m_verticalScrollbar-&gt;width(), 0);
-        m_horizontalScrollbar-&gt;setFrameRect(scrollbarRect);
-    }
-    if (m_verticalScrollbar) {
-        m_verticalScrollbar-&gt;setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
-        m_verticalScrollbar-&gt;setProportion(m_size.height() - horizontalScrollbarHeight, m_pdfDocumentSize.height());
-        IntRect scrollbarRect(IntRect(pluginView()-&gt;x() + m_size.width() - m_verticalScrollbar-&gt;width(), pluginView()-&gt;y(), m_verticalScrollbar-&gt;width(), m_size.height()));
-        if (m_horizontalScrollbar)
-            scrollbarRect.contract(0, m_horizontalScrollbar-&gt;height());
-        m_verticalScrollbar-&gt;setFrameRect(scrollbarRect);
-    }
-
-    FrameView* frameView = m_frame-&gt;coreFrame()-&gt;view();
-    if (!frameView)
-        return;
-
-    bool hasScrollbars = m_horizontalScrollbar || m_verticalScrollbar;
-    if (hadScrollbars != hasScrollbars) {
-        if (hasScrollbars)
-            frameView-&gt;addScrollableArea(this);
-        else
-            frameView-&gt;removeScrollableArea(this);
-
-        frameView-&gt;setNeedsLayout();
-    }
-    
-    if (m_verticalScrollbarLayer) {
-        m_verticalScrollbarLayer.get().frame = verticalScrollbar()-&gt;frameRect();
-        [m_verticalScrollbarLayer setNeedsDisplay];
-    }
-    
-    if (m_horizontalScrollbarLayer) {
-        m_horizontalScrollbarLayer.get().frame = horizontalScrollbar()-&gt;frameRect();
-        [m_horizontalScrollbarLayer setNeedsDisplay];
-    }
-    
-    if (m_scrollCornerLayer) {
-        m_scrollCornerLayer.get().frame = scrollCornerRect();
-        [m_scrollCornerLayer setNeedsDisplay];
-    }
-}
-
</del><span class="cx"> PluginView* PDFPlugin::pluginView()
</span><span class="cx"> {
</span><span class="cx">     return static_cast&lt;PluginView*&gt;(controller());
</span><span class="lines">@@ -650,175 +570,6 @@
</span><span class="cx">     return static_cast&lt;const PluginView*&gt;(controller());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;Scrollbar&gt; PDFPlugin::createScrollbar(ScrollbarOrientation orientation)
-{
-    RefPtr&lt;Scrollbar&gt; widget = Scrollbar::createNativeScrollbar(*this, orientation, RegularScrollbar);
-    if (orientation == HorizontalScrollbar) {
-        m_horizontalScrollbarLayer = adoptNS([[WKPDFPluginScrollbarLayer alloc] initWithPDFPlugin:this]);
-        [m_containerLayer addSublayer:m_horizontalScrollbarLayer.get()];
-    } else {
-        m_verticalScrollbarLayer = adoptNS([[WKPDFPluginScrollbarLayer alloc] initWithPDFPlugin:this]);
-        [m_containerLayer addSublayer:m_verticalScrollbarLayer.get()];
-    }
-    didAddScrollbar(widget.get(), orientation);
-    if (Frame* frame = webFrame()-&gt;coreFrame()) {
-        if (Page* page = frame-&gt;page()) {
-            if (page-&gt;expectsWheelEventTriggers())
-                scrollAnimator().setWheelEventTestTrigger(page-&gt;testTrigger());
-        }
-    }
-    pluginView()-&gt;frame()-&gt;view()-&gt;addChild(widget.get());
-    return widget.release();
-}
-
-void PDFPlugin::destroyScrollbar(ScrollbarOrientation orientation)
-{
-    RefPtr&lt;Scrollbar&gt;&amp; scrollbar = orientation == HorizontalScrollbar ? m_horizontalScrollbar : m_verticalScrollbar;
-    if (!scrollbar)
-        return;
-
-    willRemoveScrollbar(scrollbar.get(), orientation);
-    scrollbar-&gt;removeFromParent();
-    scrollbar = nullptr;
-
-    if (orientation == HorizontalScrollbar) {
-        [m_horizontalScrollbarLayer removeFromSuperlayer];
-        m_horizontalScrollbarLayer = 0;
-    } else {
-        [m_verticalScrollbarLayer removeFromSuperlayer];
-        m_verticalScrollbarLayer = 0;
-    }
-}
-
-IntRect PDFPlugin::convertFromScrollbarToContainingView(const Scrollbar* scrollbar, const IntRect&amp; scrollbarRect) const
-{
-    IntRect rect = scrollbarRect;
-    rect.move(scrollbar-&gt;location() - pluginView()-&gt;location());
-
-    return pluginView()-&gt;frame()-&gt;view()-&gt;convertFromRendererToContainingView(pluginView()-&gt;pluginElement()-&gt;renderer(), rect);
-}
-
-IntRect PDFPlugin::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntRect&amp; parentRect) const
-{
-    IntRect rect = pluginView()-&gt;frame()-&gt;view()-&gt;convertFromContainingViewToRenderer(pluginView()-&gt;pluginElement()-&gt;renderer(), parentRect);
-    rect.move(pluginView()-&gt;location() - scrollbar-&gt;location());
-
-    return rect;
-}
-
-IntPoint PDFPlugin::convertFromScrollbarToContainingView(const Scrollbar* scrollbar, const IntPoint&amp; scrollbarPoint) const
-{
-    IntPoint point = scrollbarPoint;
-    point.move(scrollbar-&gt;location() - pluginView()-&gt;location());
-
-    return pluginView()-&gt;frame()-&gt;view()-&gt;convertFromRendererToContainingView(pluginView()-&gt;pluginElement()-&gt;renderer(), point);
-}
-
-IntPoint PDFPlugin::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntPoint&amp; parentPoint) const
-{
-    IntPoint point = pluginView()-&gt;frame()-&gt;view()-&gt;convertFromContainingViewToRenderer(pluginView()-&gt;pluginElement()-&gt;renderer(), parentPoint);
-    point.move(pluginView()-&gt;location() - scrollbar-&gt;location());
-    
-    return point;
-}
-
-bool PDFPlugin::handleScroll(ScrollDirection direction, ScrollGranularity granularity)
-{
-    return scroll(direction, granularity);
-}
-
-IntRect PDFPlugin::scrollCornerRect() const
-{
-    if (!m_horizontalScrollbar || !m_verticalScrollbar)
-        return IntRect();
-    if (m_horizontalScrollbar-&gt;isOverlayScrollbar()) {
-        ASSERT(m_verticalScrollbar-&gt;isOverlayScrollbar());
-        return IntRect();
-    }
-    return IntRect(pluginView()-&gt;width() - m_verticalScrollbar-&gt;width(), pluginView()-&gt;height() - m_horizontalScrollbar-&gt;height(), m_verticalScrollbar-&gt;width(), m_horizontalScrollbar-&gt;height());
-}
-
-ScrollableArea* PDFPlugin::enclosingScrollableArea() const
-{
-    // FIXME: Walk up the frame tree and look for a scrollable parent frame or RenderLayer.
-    return nullptr;
-}
-
-IntRect PDFPlugin::scrollableAreaBoundingBox() const
-{
-    return pluginView()-&gt;frameRect();
-}
-
-int PDFPlugin::scrollSize(ScrollbarOrientation orientation) const
-{
-    Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_horizontalScrollbar : m_verticalScrollbar).get();
-    return scrollbar ? (scrollbar-&gt;totalSize() - scrollbar-&gt;visibleSize()) : 0;
-}
-
-bool PDFPlugin::isActive() const
-{
-    if (Frame* coreFrame = m_frame-&gt;coreFrame()) {
-        if (Page* page = coreFrame-&gt;page())
-            return page-&gt;focusController().isActive();
-    }
-
-    return false;
-}
-
-bool PDFPlugin::forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const
-{
-    if (Frame* coreFrame = m_frame-&gt;coreFrame()) {
-        if (Page* page = coreFrame-&gt;page())
-            return page-&gt;settings().forceUpdateScrollbarsOnMainThreadForPerformanceTesting();
-    }
-
-    return false;
-}
-
-int PDFPlugin::scrollPosition(Scrollbar* scrollbar) const
-{
-    if (scrollbar-&gt;orientation() == HorizontalScrollbar)
-        return m_scrollOffset.width();
-    if (scrollbar-&gt;orientation() == VerticalScrollbar)
-        return m_scrollOffset.height();
-    ASSERT_NOT_REACHED();
-    return 0;
-}
-
-IntPoint PDFPlugin::scrollPosition() const
-{
-    return IntPoint(m_scrollOffset.width(), m_scrollOffset.height());
-}
-
-IntPoint PDFPlugin::minimumScrollPosition() const
-{
-    return IntPoint();
-}
-
-IntPoint PDFPlugin::maximumScrollPosition() const
-{
-    int horizontalScrollbarHeight = (m_horizontalScrollbar &amp;&amp; !m_horizontalScrollbar-&gt;isOverlayScrollbar()) ? m_horizontalScrollbar-&gt;height() : 0;
-    int verticalScrollbarWidth = (m_verticalScrollbar &amp;&amp; !m_verticalScrollbar-&gt;isOverlayScrollbar()) ? m_verticalScrollbar-&gt;width() : 0;
-
-    IntPoint maximumOffset(m_pdfDocumentSize.width() - m_size.width() + verticalScrollbarWidth, m_pdfDocumentSize.height() - m_size.height() + horizontalScrollbarHeight);
-    maximumOffset.clampNegativeToZero();
-    return maximumOffset;
-}
-
-void PDFPlugin::scrollbarStyleChanged(ScrollbarStyle style, bool forceUpdate)
-{
-    if (!forceUpdate)
-        return;
-
-    // If the PDF was scrolled all the way to bottom right and scrollbars change to overlay style, we don't want to display white rectangles where scrollbars were.
-    IntPoint newScrollOffset = IntPoint(m_scrollOffset).shrunkTo(maximumScrollPosition());
-    setScrollOffset(newScrollOffset);
-    
-    ScrollableArea::scrollbarStyleChanged(style, forceUpdate);
-    // As size of the content area changes, scrollbars may need to appear or to disappear.
-    updateScrollbars();
-}
-
</del><span class="cx"> void PDFPlugin::addArchiveResource()
</span><span class="cx"> {
</span><span class="cx">     // FIXME: It's a hack to force add a resource to DocumentLoader. PDF documents should just be fetched as CachedResources.
</span><span class="lines">@@ -920,25 +671,24 @@
</span><span class="cx"> 
</span><span class="cx">     setPDFDocument(document);
</span><span class="cx"> 
</span><del>-    updatePageAndDeviceScaleFactors();
</del><ins>+    [m_pdfLayerController setFrameSize:webFrame()-&gt;coreFrame()-&gt;view()-&gt;visibleContentRect().size()]; /// ???
+    [m_pdfLayerController setDocument:document.get()];
</ins><span class="cx"> 
</span><del>-    [m_pdfLayerController setFrameSize:size()];
-    m_pdfLayerController.get().document = document.get();
-
-    if (handlesPageScaleFactor())
-        pluginView()-&gt;setPageScaleFactor([m_pdfLayerController contentScaleFactor], IntPoint());
-
-    notifyScrollPositionChanged(IntPoint([m_pdfLayerController scrollPosition]));
-
</del><span class="cx">     calculateSizes();
</span><del>-    updateScrollbars();
</del><span class="cx"> 
</span><span class="cx">     runScriptsInPDFDocument();
</span><span class="cx"> 
</span><del>-    if ([document isLocked])
</del><ins>+    if (isLocked())
</ins><span class="cx">         createPasswordEntryForm();
</span><ins>+
+    m_HUD.setVisible(!isLocked(), HUD::AnimateVisibilityTransition::No);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool PDFPlugin::isLocked() const
+{
+    return [m_pdfDocument isLocked];
+}
+
</ins><span class="cx"> void PDFPlugin::streamDidReceiveResponse(uint64_t streamID, const URL&amp;, uint32_t, uint32_t, const String&amp; mimeType, const String&amp;, const String&amp; suggestedFilename)
</span><span class="cx"> {
</span><span class="cx">     ASSERT_UNUSED(streamID, streamID == pdfDocumentRequestID);
</span><span class="lines">@@ -1022,64 +772,91 @@
</span><span class="cx">     JSGlobalContextRelease(ctx);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PDFPlugin::invalidatePDFRect(IntRect rect)
+{
+    Widget* widget = pluginView();
+
+    // FIXME: One of the conversion functions should do this (with the flipping).
+    IntRect invalidRect = rect;
+    invalidRect.setY(m_pdfDocumentSize.height() - invalidRect.y() - invalidRect.height());
+
+    widget-&gt;invalidateRect(invalidRect);
+}
+
+void PDFPlugin::invalidateHUD()
+{
+    m_HUD.invalidate();
+}
+
</ins><span class="cx"> void PDFPlugin::createPasswordEntryForm()
</span><span class="cx"> {
</span><ins>+    if (!supportsForms())
+        return;
+
+    Document* document = webFrame()-&gt;coreFrame()-&gt;document();
+    m_passwordContainer = document-&gt;createElement(divTag, false);
+    m_passwordContainer-&gt;setAttribute(idAttr, &quot;passwordContainer&quot;);
+
</ins><span class="cx">     m_passwordField = PDFPluginPasswordField::create(m_pdfLayerController.get(), this);
</span><del>-    m_passwordField-&gt;attach(m_annotationContainer.get());
</del><ins>+    m_passwordField-&gt;attach(m_passwordContainer.get());
+    document-&gt;bodyOrFrameset()-&gt;appendChild(*m_passwordContainer);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PDFPlugin::attemptToUnlockPDF(const String&amp; password)
</span><span class="cx"> {
</span><span class="cx">     [m_pdfLayerController attemptToUnlockWithPassword:password];
</span><span class="cx"> 
</span><del>-    if (![pdfDocument() isLocked]) {
</del><ins>+    if (!isLocked()) {
+        m_passwordContainer = nullptr;
</ins><span class="cx">         m_passwordField = nullptr;
</span><span class="cx"> 
</span><span class="cx">         calculateSizes();
</span><del>-        updateScrollbars();
</del><ins>+
+        m_HUD.setVisible(true, HUD::AnimateVisibilityTransition::Yes);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PDFPlugin::updatePageAndDeviceScaleFactors()
</del><ins>+void PDFPlugin::calculateSizes()
</ins><span class="cx"> {
</span><del>-    double newScaleFactor = controller()-&gt;contentsScaleFactor();
-    if (!handlesPageScaleFactor())
-        newScaleFactor *= webFrame()-&gt;page()-&gt;pageScaleFactor();
</del><ins>+    setPDFDocumentSize(isLocked() ? IntSize() : IntSize([m_pdfLayerController contentSizeRespectingZoom]));
</ins><span class="cx"> 
</span><del>-    if (newScaleFactor != [m_pdfLayerController deviceScaleFactor])
-        [m_pdfLayerController setDeviceScaleFactor:newScaleFactor];
</del><ins>+    // We have to asynchronously update styles because we could be inside layout.
+    RefPtr&lt;PDFPlugin&gt; reffedThis = this;
+    dispatch_async(dispatch_get_main_queue(), [reffedThis] {
+        reffedThis-&gt;didCalculateSizes();
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PDFPlugin::contentsScaleFactorChanged(float)
</del><ins>+void PDFPlugin::didCalculateSizes()
</ins><span class="cx"> {
</span><del>-    updatePageAndDeviceScaleFactors();
-}
</del><ins>+    HTMLPlugInElement* pluginElement = downcast&lt;PluginDocument&gt;(*webFrame()-&gt;coreFrame()-&gt;document()).pluginElement();
</ins><span class="cx"> 
</span><del>-void PDFPlugin::computePageBoxes()
-{
-    size_t pageCount = CGPDFDocumentGetNumberOfPages([m_pdfDocument documentRef]);
-    for (size_t i = 0; i &lt; pageCount; ++i) {
-        CGPDFPageRef pdfPage = CGPDFDocumentGetPage([m_pdfDocument documentRef], i + 1);
-        ASSERT(pdfPage);
-
-        CGRect box = CGPDFPageGetBoxRect(pdfPage, kCGPDFCropBox);
-        if (CGRectIsEmpty(box))
-            box = CGPDFPageGetBoxRect(pdfPage, kCGPDFMediaBox);
-        m_pageBoxes.append(IntRect(box));
</del><ins>+    if (isLocked()) {
+        pluginElement-&gt;setInlineStyleProperty(CSSPropertyWidth, 100, CSSPrimitiveValue::CSS_PERCENTAGE);
+        pluginElement-&gt;setInlineStyleProperty(CSSPropertyHeight, 100, CSSPrimitiveValue::CSS_PERCENTAGE);
+        return;
</ins><span class="cx">     }
</span><del>-}
</del><span class="cx"> 
</span><del>-void PDFPlugin::calculateSizes()
-{
-    if ([pdfDocument() isLocked]) {
-        setPDFDocumentSize(IntSize(0, 0));
</del><ins>+    pluginElement-&gt;setInlineStyleProperty(CSSPropertyWidth, m_pdfDocumentSize.width(), CSSPrimitiveValue::CSS_PX);
+    pluginElement-&gt;setInlineStyleProperty(CSSPropertyHeight, m_pdfDocumentSize.height(), CSSPrimitiveValue::CSS_PX);
+
+    // FIXME: Can't do this in the overflow/subframe case. Where does scroll-snap-type go?
+    if (m_usingContinuousMode || !m_frame-&gt;isMainFrame() || !isFullFramePlugin())
</ins><span class="cx">         return;
</span><ins>+
+    RetainPtr&lt;NSArray&gt; pageRects = [m_pdfLayerController pageRects];
+
+    StringBuilder coordinates;
+    for (NSValue *rect in pageRects.get()) {
+        // FIXME: Why 4?
+        coordinates.appendNumber((long)[rect rectValue].origin.y / 4);
+        coordinates.appendLiteral(&quot;px &quot;);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // FIXME: This should come straight from PDFKit.
-    computePageBoxes();
</del><ins>+    pluginElement-&gt;setInlineStyleProperty(CSSPropertyWebkitScrollSnapCoordinate, coordinates.toString());
</ins><span class="cx"> 
</span><del>-    setPDFDocumentSize(IntSize([m_pdfLayerController contentSizeRespectingZoom]));
</del><ins>+    Document* document = webFrame()-&gt;coreFrame()-&gt;document();
+    document-&gt;bodyOrFrameset()-&gt;setInlineStyleProperty(CSSPropertyWebkitScrollSnapType, &quot;mandatory&quot;);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool PDFPlugin::initialize(const Parameters&amp; parameters)
</span><span class="lines">@@ -1094,90 +871,26 @@
</span><span class="cx"> 
</span><span class="cx"> void PDFPlugin::destroy()
</span><span class="cx"> {
</span><del>-    m_pdfLayerController.get().delegate = 0;
</del><ins>+    [m_pdfLayerController setDelegate:nil];
</ins><span class="cx"> 
</span><del>-    if (webFrame()) {
-        if (FrameView* frameView = webFrame()-&gt;coreFrame()-&gt;view())
-            frameView-&gt;removeScrollableArea(this);
-    }
-
</del><span class="cx">     m_activeAnnotation = nullptr;
</span><del>-    m_annotationContainer = nullptr;
-
-    destroyScrollbar(HorizontalScrollbar);
-    destroyScrollbar(VerticalScrollbar);
-    
-    [m_scrollCornerLayer removeFromSuperlayer];
-    [m_contentLayer removeFromSuperlayer];
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PDFPlugin::updateControlTints(GraphicsContext&amp; graphicsContext)
</del><ins>+void PDFPlugin::paint(GraphicsContext&amp; context, const IntRect&amp; dirtyRectInWindowCoordinates)
</ins><span class="cx"> {
</span><del>-    ASSERT(graphicsContext.updatingControlTints());
-
-    if (m_horizontalScrollbar)
-        m_horizontalScrollbar-&gt;invalidate();
-    if (m_verticalScrollbar)
-        m_verticalScrollbar-&gt;invalidate();
-    invalidateScrollCorner(scrollCornerRect());
</del><ins>+    context.scale(FloatSize(1, -1));
+    context.translate(0, -m_pdfDocumentSize.height());
+    [m_pdfLayerController drawInContext:context.platformContext()];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PDFPlugin::paintControlForLayerInContext(CALayer *layer, CGContextRef context)
-{
-    GraphicsContext graphicsContext(context);
-    GraphicsContextStateSaver stateSaver(graphicsContext);
-    
-    graphicsContext.setIsCALayerContext(true);
-    
-    if (layer == m_scrollCornerLayer) {
-        IntRect scrollCornerRect = this-&gt;scrollCornerRect();
-        graphicsContext.translate(-scrollCornerRect.x(), -scrollCornerRect.y());
-        ScrollbarTheme::theme().paintScrollCorner(nullptr, graphicsContext, scrollCornerRect);
-        return;
-    }
-    
-    Scrollbar* scrollbar = nullptr;
-    
-    if (layer == m_verticalScrollbarLayer)
-        scrollbar = verticalScrollbar();
-    else if (layer == m_horizontalScrollbarLayer)
-        scrollbar = horizontalScrollbar();
-
-    if (!scrollbar)
-        return;
-    
-    graphicsContext.translate(-scrollbar-&gt;x(), -scrollbar-&gt;y());
-    scrollbar-&gt;paint(graphicsContext, scrollbar-&gt;frameRect());
-}
-
</del><span class="cx"> RefPtr&lt;ShareableBitmap&gt; PDFPlugin::snapshot()
</span><span class="cx"> {
</span><del>-    if (size().isEmpty())
-        return nullptr;
-
-    float contentsScaleFactor = controller()-&gt;contentsScaleFactor();
-    IntSize backingStoreSize = size();
-    backingStoreSize.scale(contentsScaleFactor);
-
-    RefPtr&lt;ShareableBitmap&gt; bitmap = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha);
-    auto context = bitmap-&gt;createGraphicsContext();
-
-    context-&gt;scale(FloatSize(contentsScaleFactor, -contentsScaleFactor));
-    context-&gt;translate(-m_scrollOffset.width(), -m_pdfDocumentSize.height() + m_scrollOffset.height());
-
-    [m_pdfLayerController snapshotInContext:context-&gt;platformContext()];
-
-    return bitmap;
</del><ins>+    return nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-PlatformLayer* PDFPlugin::pluginLayer()
-{
-    return m_containerLayer.get();
-}
-
</del><span class="cx"> IntPoint PDFPlugin::convertFromPluginToPDFView(const IntPoint&amp; point) const
</span><span class="cx"> {
</span><del>-    return IntPoint(point.x(), size().height() - point.y());
</del><ins>+    return IntPoint(point.x(), m_size.height() - point.y());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IntPoint PDFPlugin::convertFromRootViewToPlugin(const IntPoint&amp; point) const
</span><span class="lines">@@ -1187,8 +900,8 @@
</span><span class="cx"> 
</span><span class="cx"> IntPoint PDFPlugin::convertFromPDFViewToRootView(const IntPoint&amp; point) const
</span><span class="cx"> {
</span><del>-    IntPoint pointInPluginCoordinates(point.x(), size().height() - point.y());
-    return m_rootViewToPluginTransform.inverse().mapPoint(pointInPluginCoordinates);
</del><ins>+    IntPoint pointInPluginCoordinates(point.x(), m_size.height() - point.y());
+    return m_pluginToRootViewTransform.mapPoint(pointInPluginCoordinates);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> FloatRect PDFPlugin::convertFromPDFViewToScreen(const FloatRect&amp; rect) const
</span><span class="lines">@@ -1198,8 +911,8 @@
</span><span class="cx">     if (!frameView)
</span><span class="cx">         return FloatRect();
</span><span class="cx"> 
</span><del>-    FloatPoint originInPluginCoordinates(rect.x(), size().height() - rect.y() - rect.height());
-    FloatRect rectInRootViewCoordinates = m_rootViewToPluginTransform.inverse().mapRect(FloatRect(originInPluginCoordinates, rect.size()));
</del><ins>+    FloatPoint originInPluginCoordinates(rect.x(), m_size.height() - rect.y() - rect.height());
+    FloatRect rectInRootViewCoordinates = m_pluginToRootViewTransform.mapRect(FloatRect(originInPluginCoordinates, rect.size()));
</ins><span class="cx"> 
</span><span class="cx">     return frameView-&gt;contentsToScreen(enclosingIntRect(rectInRootViewCoordinates));
</span><span class="cx"> }
</span><span class="lines">@@ -1212,44 +925,25 @@
</span><span class="cx">         return IntRect();
</span><span class="cx"> 
</span><span class="cx">     FloatRect bounds = FloatRect(FloatPoint(), size());
</span><del>-    FloatRect rectInRootViewCoordinates = m_rootViewToPluginTransform.inverse().mapRect(bounds);
</del><ins>+    FloatRect rectInRootViewCoordinates = m_pluginToRootViewTransform.mapRect(bounds);
</ins><span class="cx">     return frameView-&gt;contentsToScreen(enclosingIntRect(rectInRootViewCoordinates));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PDFPlugin::geometryDidChange(const IntSize&amp; pluginSize, const IntRect&amp;, const AffineTransform&amp; pluginToRootViewTransform)
</span><span class="cx"> {
</span><del>-    if (size() == pluginSize &amp;&amp; pluginView()-&gt;pageScaleFactor() == [m_pdfLayerController contentScaleFactor])
-        return;
-
-    m_size = pluginSize;
</del><ins>+    m_pluginToRootViewTransform = pluginToRootViewTransform;
</ins><span class="cx">     m_rootViewToPluginTransform = pluginToRootViewTransform.inverse();
</span><del>-    [m_pdfLayerController setFrameSize:pluginSize];
</del><ins>+    m_size = pluginSize;
</ins><span class="cx"> 
</span><del>-    [CATransaction begin];
-    [CATransaction setDisableActions:YES];
-    CATransform3D transform = CATransform3DMakeScale(1, -1, 1);
-    transform = CATransform3DTranslate(transform, 0, -pluginSize.height(), 0);
-    
-    if (handlesPageScaleFactor()) {
-        CGFloat magnification = pluginView()-&gt;pageScaleFactor() - [m_pdfLayerController contentScaleFactor];
</del><ins>+    FrameView* frameView = webFrame()-&gt;coreFrame()-&gt;view();
</ins><span class="cx"> 
</span><del>-        // FIXME: Instead of m_lastMousePositionInPluginCoordinates, we should use the zoom origin from PluginView::setPageScaleFactor.
-        if (magnification)
-            [m_pdfLayerController magnifyWithMagnification:magnification atPoint:convertFromPluginToPDFView(m_lastMousePositionInPluginCoordinates) immediately:NO];
-    } else {
-        // If we don't handle page scale ourselves, we need to respect our parent page's
-        // scale, which may have changed.
-        updatePageAndDeviceScaleFactors();
-    } 
</del><ins>+    [m_pdfLayerController setFrameSize:frameView-&gt;frameRect().size()];
+    [m_pdfLayerController setVisibleRect:frameView-&gt;visibleContentRect()];
</ins><span class="cx"> 
</span><span class="cx">     calculateSizes();
</span><del>-    updateScrollbars();
</del><span class="cx"> 
</span><span class="cx">     if (m_activeAnnotation)
</span><span class="cx">         m_activeAnnotation-&gt;updateGeometry();
</span><del>-
-    [m_contentLayer setSublayerTransform:transform];
-    [CATransaction commit];
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PDFPlugin::frameDidFinishLoading(uint64_t)
</span><span class="lines">@@ -1267,7 +961,6 @@
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-    
</del><span class="cx"> static NSUInteger modifierFlagsFromWebEvent(const WebEvent&amp; event)
</span><span class="cx"> {
</span><span class="cx">     return (event.shiftKey() ? NSShiftKeyMask : 0)
</span><span class="lines">@@ -1279,12 +972,6 @@
</span><span class="cx"> static bool getEventTypeFromWebEvent(const WebEvent&amp; event, NSEventType&amp; eventType)
</span><span class="cx"> {
</span><span class="cx">     switch (event.type()) {
</span><del>-    case WebEvent::KeyDown:
-        eventType = NSKeyDown;
-        return true;
-    case WebEvent::KeyUp:
-        eventType = NSKeyUp;
-        return true;
</del><span class="cx">     case WebEvent::MouseDown:
</span><span class="cx">         switch (static_cast&lt;const WebMouseEvent&amp;&gt;(event).button()) {
</span><span class="cx">         case WebMouseEvent::LeftButton:
</span><span class="lines">@@ -1329,127 +1016,80 @@
</span><span class="cx"> NSEvent *PDFPlugin::nsEventForWebMouseEvent(const WebMouseEvent&amp; event)
</span><span class="cx"> {
</span><span class="cx">     m_lastMousePositionInPluginCoordinates = convertFromRootViewToPlugin(event.position());
</span><del>-
</del><span class="cx">     IntPoint positionInPDFViewCoordinates(convertFromPluginToPDFView(m_lastMousePositionInPluginCoordinates));
</span><span class="cx"> 
</span><span class="cx">     NSEventType eventType;
</span><span class="cx"> 
</span><span class="cx">     if (!getEventTypeFromWebEvent(event, eventType))
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx"> 
</span><span class="cx">     NSUInteger modifierFlags = modifierFlagsFromWebEvent(event);
</span><span class="cx"> 
</span><span class="cx">     return [NSEvent mouseEventWithType:eventType location:positionInPDFViewCoordinates modifierFlags:modifierFlags timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:event.clickCount() pressure:0];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PDFPlugin::updateCursor(const WebMouseEvent&amp; event, UpdateCursorMode mode)
</del><ins>+void PDFPlugin::updateCursor(const WebMouseEvent&amp; event, UpdateCursor mode)
</ins><span class="cx"> {
</span><del>-    HitTestResult hitTestResult = None;
</del><ins>+    // FIXME: Should have a hand for links, and something special for annotations.
</ins><span class="cx"> 
</span><del>-    PDFSelection *selectionUnderMouse = [m_pdfLayerController getSelectionForWordAtPoint:convertFromPluginToPDFView(event.position())];
-    if (selectionUnderMouse &amp;&amp; [[selectionUnderMouse string] length])
-        hitTestResult = Text;
</del><ins>+    HitTestResult hitTestResult = HitTestResult::None;
</ins><span class="cx"> 
</span><del>-    if (hitTestResult == m_lastHitTestResult &amp;&amp; mode == UpdateIfNeeded)
</del><ins>+    IntPoint positionInPDFViewCoordinates(convertFromPluginToPDFView(m_lastMousePositionInPluginCoordinates));
+    if (m_HUD.containsPointInRootView(event.position()))
+        hitTestResult = HitTestResult::HUD;
+    else {
+        PDFSelection *selectionUnderMouse = [m_pdfLayerController getSelectionForWordAtPoint:positionInPDFViewCoordinates];
+        if (selectionUnderMouse &amp;&amp; [[selectionUnderMouse string] length])
+            hitTestResult = HitTestResult::Text;
+    }
+
+    if (hitTestResult == m_lastHitTestResult &amp;&amp; mode == UpdateCursor::IfNeeded)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    webFrame()-&gt;page()-&gt;send(Messages::WebPageProxy::SetCursor(hitTestResult == Text ? iBeamCursor() : pointerCursor()));
</del><ins>+    const Cursor&amp; cursor = [hitTestResult] {
+        switch (hitTestResult) {
+        case HitTestResult::None:
+            return pointerCursor();
+        case HitTestResult::Text:
+            return iBeamCursor();
+        case HitTestResult::HUD:
+            return pointerCursor();
+        };
+    }();
+
+    webFrame()-&gt;page()-&gt;send(Messages::WebPageProxy::SetCursor(cursor));
</ins><span class="cx">     m_lastHitTestResult = hitTestResult;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool PDFPlugin::handleMouseEvent(const WebMouseEvent&amp; event)
</span><span class="cx"> {
</span><span class="cx">     PlatformMouseEvent platformEvent = platform(event);
</span><del>-    IntPoint mousePosition = convertFromRootViewToPlugin(event.position());
</del><span class="cx"> 
</span><span class="cx">     m_lastMouseEvent = event;
</span><span class="cx"> 
</span><del>-    RefPtr&lt;Scrollbar&gt; targetScrollbar;
-    RefPtr&lt;Scrollbar&gt; targetScrollbarForLastMousePosition;
-
-    if (m_verticalScrollbarLayer) {
-        IntRect verticalScrollbarFrame(m_verticalScrollbarLayer.get().frame);
-        if (verticalScrollbarFrame.contains(mousePosition))
-            targetScrollbar = verticalScrollbar();
-        if (verticalScrollbarFrame.contains(m_lastMousePositionInPluginCoordinates))
-            targetScrollbarForLastMousePosition = verticalScrollbar();
-    }
-
-    if (m_horizontalScrollbarLayer) {
-        IntRect horizontalScrollbarFrame(m_horizontalScrollbarLayer.get().frame);
-        if (horizontalScrollbarFrame.contains(mousePosition))
-            targetScrollbar = horizontalScrollbar();
-        if (horizontalScrollbarFrame.contains(m_lastMousePositionInPluginCoordinates))
-            targetScrollbarForLastMousePosition = horizontalScrollbar();
-    }
-
-    if (m_scrollCornerLayer &amp;&amp; IntRect(m_scrollCornerLayer.get().frame).contains(mousePosition))
</del><ins>+    if (isLocked())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    if ([pdfDocument() isLocked])
-        return false;
-
</del><span class="cx">     // Right-clicks and Control-clicks always call handleContextMenuEvent as well.
</span><span class="cx">     if (event.button() == WebMouseEvent::RightButton || (event.button() == WebMouseEvent::LeftButton &amp;&amp; event.controlKey()))
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><ins>+    if (event.button() != WebMouseEvent::LeftButton)
+        return false;
+
</ins><span class="cx">     NSEvent *nsEvent = nsEventForWebMouseEvent(event);
</span><span class="cx"> 
</span><span class="cx">     switch (event.type()) {
</span><span class="cx">     case WebEvent::MouseMove:
</span><del>-        mouseMovedInContentArea();
</del><span class="cx">         updateCursor(event);
</span><del>-
-        if (targetScrollbar) {
-            if (!targetScrollbarForLastMousePosition) {
-                targetScrollbar-&gt;mouseEntered();
-                return true;
-            }
-            return targetScrollbar-&gt;mouseMoved(platformEvent);
-        }
-
-        if (!targetScrollbar &amp;&amp; targetScrollbarForLastMousePosition)
-            targetScrollbarForLastMousePosition-&gt;mouseExited();
-
-        switch (event.button()) {
-        case WebMouseEvent::LeftButton:
-            [m_pdfLayerController mouseDragged:nsEvent];
-            return true;
-        case WebMouseEvent::RightButton:
-        case WebMouseEvent::MiddleButton:
-            return false;
-        case WebMouseEvent::NoButton:
-            [m_pdfLayerController mouseMoved:nsEvent];
-            return true;
-        }
</del><ins>+        [m_pdfLayerController mouseDragged:nsEvent];
+        return true;
</ins><span class="cx">     case WebEvent::MouseDown:
</span><del>-        switch (event.button()) {
-        case WebMouseEvent::LeftButton:
-            if (targetScrollbar)
-                return targetScrollbar-&gt;mouseDown(platformEvent);
-
-            [m_pdfLayerController mouseDown:nsEvent];
-            return true;
-        case WebMouseEvent::RightButton:
-            [m_pdfLayerController rightMouseDown:nsEvent];
-            return true;
-        case WebMouseEvent::MiddleButton:
-        case WebMouseEvent::NoButton:
-            return false;
-        }
</del><ins>+        [m_pdfLayerController mouseDown:nsEvent];
+        return true;
</ins><span class="cx">     case WebEvent::MouseUp:
</span><del>-        switch (event.button()) {
-        case WebMouseEvent::LeftButton:
-            if (targetScrollbar)
-                return targetScrollbar-&gt;mouseUp(platformEvent);
-
-            [m_pdfLayerController mouseUp:nsEvent];
-            return true;
-        case WebMouseEvent::RightButton:
-        case WebMouseEvent::MiddleButton:
-        case WebMouseEvent::NoButton:
-            return false;
-        }
</del><ins>+        [m_pdfLayerController mouseUp:nsEvent];
+        return true;
</ins><span class="cx">     default:
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="lines">@@ -1459,14 +1099,12 @@
</span><span class="cx"> 
</span><span class="cx"> bool PDFPlugin::handleMouseEnterEvent(const WebMouseEvent&amp; event)
</span><span class="cx"> {
</span><del>-    mouseEnteredContentArea();
-    updateCursor(event, ForceUpdate);
</del><ins>+    updateCursor(event, UpdateCursor::Force);
</ins><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool PDFPlugin::handleMouseLeaveEvent(const WebMouseEvent&amp;)
</span><span class="cx"> {
</span><del>-    mouseExitedContentArea();
</del><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx">     
</span><span class="lines">@@ -1474,7 +1112,7 @@
</span><span class="cx"> {
</span><span class="cx">     FrameView* frameView = webFrame()-&gt;coreFrame()-&gt;view();
</span><span class="cx">     IntPoint contentsPoint = frameView-&gt;contentsToRootView(point);
</span><del>-    WebMouseEvent event(WebEvent::MouseDown, WebMouseEvent::RightButton, contentsPoint, contentsPoint, 0, 0, 0, 1, static_cast&lt;WebEvent::Modifiers&gt;(0), monotonicallyIncreasingTime(), WebCore::ForceAtClick);
</del><ins>+    WebMouseEvent event(WebEvent::MouseDown, WebMouseEvent::RightButton, contentsPoint, contentsPoint, 0, 0, 0, 1, static_cast&lt;WebEvent::Modifiers&gt;(0), monotonicallyIncreasingTime(), ForceAtClick);
</ins><span class="cx">     return handleContextMenuEvent(event);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1490,28 +1128,7 @@
</span><span class="cx">     
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><del>-
-bool PDFPlugin::handleKeyboardEvent(const WebKeyboardEvent&amp; event)
-{
-    NSEventType eventType;
-
-    if (!getEventTypeFromWebEvent(event, eventType))
-        return false;
-
-    NSUInteger modifierFlags = modifierFlagsFromWebEvent(event);
</del><span class="cx">     
</span><del>-    NSEvent *fakeEvent = [NSEvent keyEventWithType:eventType location:NSZeroPoint modifierFlags:modifierFlags timestamp:0 windowNumber:0 context:0 characters:event.text() charactersIgnoringModifiers:event.unmodifiedText() isARepeat:event.isAutoRepeat() keyCode:event.nativeVirtualKeyCode()];
-    
-    switch (event.type()) {
-    case WebEvent::KeyDown:
-        return [m_pdfLayerController keyDown:fakeEvent];
-    default:
-        return false;
-    }
-    
-    return false;
-}
-    
</del><span class="cx"> bool PDFPlugin::handleEditingCommand(const String&amp; commandName, const String&amp; argument)
</span><span class="cx"> {
</span><span class="cx">     if (commandName == &quot;copy&quot;)
</span><span class="lines">@@ -1538,45 +1155,14 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PDFPlugin::setScrollOffset(const IntPoint&amp; offset)
</del><ins>+bool PDFPlugin::isFullFramePlugin() const
</ins><span class="cx"> {
</span><del>-    m_scrollOffset = IntSize(offset.x(), offset.y());
-
-    [CATransaction begin];
-    [m_pdfLayerController setScrollPosition:offset];
-
-    if (m_activeAnnotation)
-        m_activeAnnotation-&gt;updateGeometry();
-
-    [CATransaction commit];
-}
-
-void PDFPlugin::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect&amp; rect)
-{
-    if (scrollbar == horizontalScrollbar())
-        [m_horizontalScrollbarLayer setNeedsDisplay];
-    else if (scrollbar == verticalScrollbar())
-        [m_verticalScrollbarLayer setNeedsDisplay];
-}
-
-void PDFPlugin::invalidateScrollCornerRect(const IntRect&amp; rect)
-{
-    [m_scrollCornerLayer setNeedsDisplay];
-}
-
-bool PDFPlugin::isFullFramePlugin()
-{
</del><span class="cx">     // &lt;object&gt; or &lt;embed&gt; plugins will appear to be in their parent frame, so we have to
</span><span class="cx">     // check whether our frame's widget is exactly our PluginView.
</span><span class="cx">     Document* document = webFrame()-&gt;coreFrame()-&gt;document();
</span><span class="cx">     return document-&gt;isPluginDocument() &amp;&amp; static_cast&lt;PluginDocument*&gt;(document)-&gt;pluginWidget() == pluginView();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool PDFPlugin::handlesPageScaleFactor()
-{
-    return webFrame()-&gt;isMainFrame() &amp;&amp; isFullFramePlugin();
-}
-
</del><span class="cx"> void PDFPlugin::clickedLink(NSURL *url)
</span><span class="cx"> {
</span><span class="cx">     URL coreURL = url;
</span><span class="lines">@@ -1607,7 +1193,8 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         m_activeAnnotation = PDFPluginAnnotation::create(annotation, m_pdfLayerController.get(), this);
</span><del>-        m_activeAnnotation-&gt;attach(m_annotationContainer.get());
</del><ins>+        Document* document = webFrame()-&gt;coreFrame()-&gt;document();
+        m_activeAnnotation-&gt;attach(document-&gt;bodyOrFrameset());
</ins><span class="cx">     } else
</span><span class="cx">         m_activeAnnotation = nullptr;
</span><span class="cx"> }
</span><span class="lines">@@ -1618,21 +1205,12 @@
</span><span class="cx">     return isFullFramePlugin();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PDFPlugin::notifyContentScaleFactorChanged(CGFloat scaleFactor)
</del><ins>+void PDFPlugin::notifyDisplayModeChanged(int mode)
</ins><span class="cx"> {
</span><del>-    if (handlesPageScaleFactor())
-        pluginView()-&gt;setPageScaleFactor(scaleFactor, IntPoint());
-
</del><ins>+    m_usingContinuousMode = (mode == kPDFDisplaySinglePageContinuous || mode == kPDFDisplayTwoUpContinuous);
</ins><span class="cx">     calculateSizes();
</span><del>-    updateScrollbars();
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PDFPlugin::notifyDisplayModeChanged(int)
-{
-    calculateSizes();
-    updateScrollbars();
-}
-
</del><span class="cx"> RefPtr&lt;SharedBuffer&gt; PDFPlugin::liveResourceData() const
</span><span class="cx"> {
</span><span class="cx">     NSData *pdfData = liveData();
</span><span class="lines">@@ -1664,7 +1242,7 @@
</span><span class="cx"> 
</span><span class="cx">         NSData *data = liveData();
</span><span class="cx"> 
</span><del>-        m_temporaryPDFUUID = WebCore::createCanonicalUUIDString();
</del><ins>+        m_temporaryPDFUUID = createCanonicalUUIDString();
</ins><span class="cx">         ASSERT(m_temporaryPDFUUID);
</span><span class="cx"> 
</span><span class="cx">         webFrame()-&gt;page()-&gt;savePDFToTemporaryFolderAndOpenWithNativeApplication(m_suggestedFilename, webFrame()-&gt;url(), static_cast&lt;const unsigned char *&gt;([data bytes]), [data length], m_temporaryPDFUUID);
</span><span class="lines">@@ -1814,7 +1392,7 @@
</span><span class="cx">     return matchCount &gt; 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool PDFPlugin::performDictionaryLookupAtLocation(const WebCore::FloatPoint&amp; point)
</del><ins>+bool PDFPlugin::performDictionaryLookupAtLocation(const FloatPoint&amp; point)
</ins><span class="cx"> {
</span><span class="cx">     IntPoint localPoint = convertFromRootViewToPlugin(roundedIntPoint(point));
</span><span class="cx">     PDFSelection* lookupSelection = [m_pdfLayerController getSelectionForWordAtPoint:convertFromPluginToPDFView(localPoint)];
</span><span class="lines">@@ -1835,7 +1413,7 @@
</span><span class="cx">     [m_pdfLayerController activateNextAnnotation:true];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PDFPlugin::notifySelectionChanged(PDFSelection *)
</del><ins>+void PDFPlugin::notifySelectionChanged(PDFSelection *selection)
</ins><span class="cx"> {
</span><span class="cx">     webFrame()-&gt;page()-&gt;didChangeSelection();
</span><span class="cx"> }
</span><span class="lines">@@ -1845,7 +1423,7 @@
</span><span class="cx">     return [[m_pdfLayerController currentSelection] string];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String PDFPlugin::getSelectionForWordAtPoint(const WebCore::FloatPoint&amp; point) const
</del><ins>+String PDFPlugin::getSelectionForWordAtPoint(const FloatPoint&amp; point) const
</ins><span class="cx"> {
</span><span class="cx">     IntPoint pointInView = convertFromPluginToPDFView(convertFromRootViewToPlugin(roundedIntPoint(point)));
</span><span class="cx">     PDFSelection *selectionForWord = [m_pdfLayerController getSelectionForWordAtPoint:pointInView];
</span><span class="lines">@@ -1854,7 +1432,7 @@
</span><span class="cx">     return [selectionForWord string];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool PDFPlugin::existingSelectionContainsPoint(const WebCore::FloatPoint&amp; locationInViewCoordinates) const
</del><ins>+bool PDFPlugin::existingSelectionContainsPoint(const FloatPoint&amp; locationInViewCoordinates) const
</ins><span class="cx"> {
</span><span class="cx">     PDFSelection *currentSelection = [m_pdfLayerController currentSelection];
</span><span class="cx">     if (!currentSelection)
</span><span class="lines">@@ -1887,7 +1465,8 @@
</span><span class="cx"> static NSPoint pointInLayoutSpaceForPointInWindowSpace(PDFLayerController* pdfLayerController, NSPoint pointInView)
</span><span class="cx"> {
</span><span class="cx">     CGPoint point = NSPointToCGPoint(pointInView);
</span><del>-    CGPoint scrollOffset = [pdfLayerController scrollPosition];
</del><ins>+
+    CGPoint scrollOffset = CGPointZero;
</ins><span class="cx">     CGFloat scaleFactor = [pdfLayerController contentScaleFactor];
</span><span class="cx"> 
</span><span class="cx">     scrollOffset.y = [pdfLayerController contentSizeRespectingZoom].height - NSRectToCGRect([pdfLayerController frame]).size.height - scrollOffset.y;
</span><span class="lines">@@ -1898,7 +1477,7 @@
</span><span class="cx">     return NSPointFromCGPoint(newPoint);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String PDFPlugin::lookupTextAtLocation(const WebCore::FloatPoint&amp; locationInViewCoordinates, WebHitTestResultData&amp; data, PDFSelection **selectionPtr, NSDictionary **options) const
</del><ins>+String PDFPlugin::lookupTextAtLocation(const FloatPoint&amp; locationInViewCoordinates, WebHitTestResultData&amp; data, PDFSelection **selectionPtr, NSDictionary **options) const
</ins><span class="cx"> {
</span><span class="cx">     PDFSelection*&amp; selection = *selectionPtr;
</span><span class="cx"> 
</span><span class="lines">@@ -1909,7 +1488,7 @@
</span><span class="cx">     IntPoint pointInPDFView = convertFromPluginToPDFView(convertFromRootViewToPlugin(roundedIntPoint(locationInViewCoordinates)));
</span><span class="cx">     selection = [m_pdfLayerController getSelectionForWordAtPoint:pointInPDFView];
</span><span class="cx">     if (!selection)
</span><del>-        return @&quot;&quot;;
</del><ins>+        return &quot;&quot;;
</ins><span class="cx"> 
</span><span class="cx">     NSPoint pointInLayoutSpace = pointInLayoutSpaceForPointInWindowSpace(m_pdfLayerController.get(), pointInPDFView);
</span><span class="cx"> 
</span><span class="lines">@@ -1937,7 +1516,7 @@
</span><span class="cx">     
</span><span class="cx">     NSString *lookupText = DictionaryLookup::stringForPDFSelection(selection, options);
</span><span class="cx">     if (!lookupText || !lookupText.length)
</span><del>-        return @&quot;&quot;;
</del><ins>+        return &quot;&quot;;
</ins><span class="cx"> 
</span><span class="cx">     [m_pdfLayerController setCurrentSelection:selection];
</span><span class="cx">     return lookupText;
</span><span class="lines">@@ -1947,7 +1526,7 @@
</span><span class="cx"> {
</span><span class="cx">     CGRect newRect = NSRectToCGRect(layoutSpaceRect);
</span><span class="cx">     CGFloat scaleFactor = pdfLayerController.contentScaleFactor;
</span><del>-    CGPoint scrollOffset = pdfLayerController.scrollPosition;
</del><ins>+    CGPoint scrollOffset = CGPointZero;
</ins><span class="cx"> 
</span><span class="cx">     scrollOffset.y = pdfLayerController.contentSizeRespectingZoom.height - NSRectToCGRect(pdfLayerController.frame).size.height - scrollOffset.y;
</span><span class="cx"> 
</span><span class="lines">@@ -1962,7 +1541,7 @@
</span><span class="cx">     return NSRectFromCGRect(newRect);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebCore::FloatRect PDFPlugin::viewRectForSelection(PDFSelection *selection) const
</del><ins>+FloatRect PDFPlugin::rectForSelectionInRootView(PDFSelection *selection) const
</ins><span class="cx"> {
</span><span class="cx">     PDFPage *currentPage = nil;
</span><span class="cx">     NSArray* pages = selection.pages;
</span><span class="lines">@@ -1978,14 +1557,9 @@
</span><span class="cx"> 
</span><span class="cx">     rectInView.origin = convertFromPDFViewToRootView(IntPoint(rectInView.origin));
</span><span class="cx"> 
</span><del>-    return WebCore::FloatRect(rectInView);
</del><ins>+    return FloatRect(rectInView);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-CGFloat PDFPlugin::scaleFactor() const
-{
-    return [m_pdfLayerController contentScaleFactor];
-}
-
</del><span class="cx"> void PDFPlugin::performWebSearch(NSString *string)
</span><span class="cx"> {
</span><span class="cx">     webFrame()-&gt;page()-&gt;send(Messages::WebPageProxy::SearchTheWeb(string));
</span><span class="lines">@@ -1996,65 +1570,208 @@
</span><span class="cx">     webFrame()-&gt;page()-&gt;send(Messages::WebPageProxy::SearchWithSpotlight(string));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool PDFPlugin::handleWheelEvent(const WebWheelEvent&amp; event)
</del><ins>+NSData *PDFPlugin::liveData() const
</ins><span class="cx"> {
</span><del>-    PDFDisplayMode displayMode = [m_pdfLayerController displayMode];
</del><ins>+    if (m_activeAnnotation)
+        m_activeAnnotation-&gt;commit();
</ins><span class="cx"> 
</span><del>-    if (displayMode == kPDFDisplaySinglePageContinuous || displayMode == kPDFDisplayTwoUpContinuous)
-        return ScrollableArea::handleWheelEvent(platform(event));
</del><ins>+    // Save data straight from the resource instead of PDFKit if the document is
+    // untouched by the user, so that PDFs which PDFKit can't display will still be downloadable.
+    if (m_pdfDocumentWasMutated)
+        return [m_pdfDocument dataRepresentation];
+    
+    return rawData();
+}
</ins><span class="cx"> 
</span><del>-    NSUInteger currentPageIndex = [m_pdfLayerController currentPageIndex];
-    bool inFirstPage = !currentPageIndex;
-    bool inLastPage = [m_pdfLayerController lastPageIndex] == currentPageIndex;
</del><ins>+NSObject *PDFPlugin::accessibilityObject() const
+{
+    return m_accessibilityObject.get();
+}
</ins><span class="cx"> 
</span><del>-    bool atScrollTop = !scrollPosition().y();
-    bool atScrollBottom = scrollPosition().y() == maximumScrollPosition().y();
</del><ins>+void PDFPlugin::scrollToPoint(IntPoint scrollPoint)
+{
+    Frame* frame = pluginView()-&gt;frame();
+    float scale = frame-&gt;page()-&gt;pageScaleFactor();
+    scrollPoint.scale(scale, scale);
+    frame-&gt;view()-&gt;scrollToOffsetWithoutAnimation(scrollPoint);
+}
</ins><span class="cx"> 
</span><del>-    bool inMomentumScroll = event.momentumPhase() != WebWheelEvent::PhaseNone;
</del><ins>+float PDFPlugin::scaleFactor() const
+{
+    Frame* frame = pluginView()-&gt;frame();
+    return frame-&gt;page()-&gt;pageScaleFactor();
+}
</ins><span class="cx"> 
</span><del>-    int scrollMagnitudeThresholdForPageFlip = defaultScrollMagnitudeThresholdForPageFlip;
-
-    // Imprecise input devices should have a lower threshold so that &quot;clicky&quot; scroll wheels can flip pages.
-    if (!event.hasPreciseScrollingDeltas())
-        scrollMagnitudeThresholdForPageFlip = 0;
-
-    if (atScrollBottom &amp;&amp; !inLastPage &amp;&amp; event.delta().height() &lt; 0) {
-        if (event.delta().height() &lt;= -scrollMagnitudeThresholdForPageFlip &amp;&amp; !inMomentumScroll)
-            [m_pdfLayerController gotoNextPage];
-        return true;
</del><ins>+void PDFPlugin::zoomIn()
+{
+    if (webFrame()-&gt;isMainFrame() &amp;&amp; isFullFramePlugin()) {
+        WebPage* page = webFrame()-&gt;page();
+        page-&gt;scalePage(page-&gt;pageScaleFactor() * zoomButtonScaleMultiplier, IntPoint());
+    } else {
+        [m_pdfLayerController setContentScaleFactor:[m_pdfLayerController contentScaleFactor] * zoomButtonScaleMultiplier];
+        calculateSizes();
</ins><span class="cx">     }
</span><ins>+}
</ins><span class="cx"> 
</span><del>-    if (atScrollTop &amp;&amp; !inFirstPage &amp;&amp; event.delta().height() &gt; 0) {
-        if (event.delta().height() &gt;= scrollMagnitudeThresholdForPageFlip &amp;&amp; !inMomentumScroll) {
-            [CATransaction begin];
-            [m_pdfLayerController gotoPreviousPage];
-            scrollToOffsetWithoutAnimation(maximumScrollPosition());
-            [CATransaction commit];
-        }
-        return true;
</del><ins>+void PDFPlugin::zoomOut()
+{
+    if (webFrame()-&gt;isMainFrame() &amp;&amp; isFullFramePlugin()) {
+        WebPage* page = webFrame()-&gt;page();
+        page-&gt;scalePage(page-&gt;pageScaleFactor() / zoomButtonScaleMultiplier, IntPoint());
+    } else {
+        [m_pdfLayerController setContentScaleFactor:[m_pdfLayerController contentScaleFactor] / zoomButtonScaleMultiplier];
+        calculateSizes();
</ins><span class="cx">     }
</span><ins>+}
</ins><span class="cx"> 
</span><del>-    return ScrollableArea::handleWheelEvent(platform(event));
</del><ins>+PDFPlugin::HUD::HUD(PDFPlugin&amp; plugin)
+    : m_overlay(PageOverlay::create(*this))
+    , m_plugin(plugin)
+{
+    WebFrame* webFrame = plugin.webFrame();
+
+    // In order to avoid the overlay lagging behind main-frame scrolling, we need
+    // to force synchronous scrolling for the whole page if we have a HUD in a subframe PDF.
+    m_overlay-&gt;setNeedsSynchronousScrolling(!webFrame-&gt;isMainFrame());
+
+    MainFrame&amp; mainFrame = webFrame-&gt;coreFrame()-&gt;mainFrame();
+    mainFrame.pageOverlayController().installPageOverlay(m_overlay.ptr(), PageOverlay::FadeMode::DoNotFade);
+    m_overlay-&gt;setNeedsDisplay();
+
+    RefPtr&lt;PlatformCALayer&gt; platformCALayer = downcast&lt;GraphicsLayerCA&gt;(m_overlay-&gt;layer()).platformCALayer();
+    platformCALayer-&gt;setOpacity(0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-NSData *PDFPlugin::liveData() const
</del><ins>+PDFPlugin::HUD::~HUD()
</ins><span class="cx"> {
</span><del>-    if (m_activeAnnotation)
-        m_activeAnnotation-&gt;commit();
</del><ins>+    MainFrame&amp; mainFrame = m_plugin.webFrame()-&gt;coreFrame()-&gt;mainFrame();
+    mainFrame.pageOverlayController().uninstallPageOverlay(m_overlay.ptr(), PageOverlay::FadeMode::DoNotFade);
+}
</ins><span class="cx"> 
</span><del>-    // Save data straight from the resource instead of PDFKit if the document is
-    // untouched by the user, so that PDFs which PDFKit can't display will still be downloadable.
-    if (m_pdfDocumentWasMutated)
-        return [m_pdfDocument dataRepresentation];
-    
-    return rawData();
</del><ins>+void PDFPlugin::HUD::pageOverlayDestroyed(PageOverlay&amp;)
+{
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-NSObject *PDFPlugin::accessibilityObject() const
</del><ins>+void PDFPlugin::HUD::willMoveToPage(PageOverlay&amp;, Page* page)
</ins><span class="cx"> {
</span><del>-    return m_accessibilityObject.get();
</del><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PDFPlugin::HUD::didMoveToPage(PageOverlay&amp;, Page*)
+{
+}
+
+IntRect PDFPlugin::HUD::frameInRootView() const
+{
+    // FIXME: These should come from PDFKit.
+    const int HUDWidth = 236;
+    const int HUDHeight = 72;
+    const int HUDYOffset = 50;
+
+    FrameView* frameView = m_plugin.webFrame()-&gt;coreFrame()-&gt;view();
+    IntRect frameRectInRootView = frameView-&gt;convertToRootView(frameView-&gt;boundsRect());
+    FloatRect HUDRect(frameRectInRootView.x() + (frameRectInRootView.width() / 2 - (HUDWidth / 2)), frameRectInRootView.y() + (frameRectInRootView.height() - HUDYOffset - HUDHeight), HUDWidth, HUDHeight);
+    return enclosingIntRect(HUDRect);
+}
+
+bool PDFPlugin::HUD::containsPointInRootView(IntPoint point)
+{
+    if (m_plugin.isLocked())
+        return false;
+
+    return frameInRootView().contains(point);
+}
+
+void PDFPlugin::HUD::drawRect(PageOverlay&amp;, GraphicsContext&amp; context, const IntRect&amp; dirtyRect)
+{
+    IntRect frameInRootView = this-&gt;frameInRootView();
+
+    context.translate(IntSize(frameInRootView.x(), frameInRootView.y() + frameInRootView.height()));
+    context.scale(FloatSize(1, -1));
+
+    IntRect localRect(IntPoint(), frameInRootView.size());
+    context.clip(localRect);
+
+    [m_plugin.pdfLayerController() drawHUDInContext:context.platformContext()];
+}
+
+void PDFPlugin::HUD::invalidate()
+{
+    m_overlay-&gt;setNeedsDisplay();
+}
+
+void PDFPlugin::HUD::setVisible(bool visible, AnimateVisibilityTransition animateTransition)
+{
+    if (visible == m_visible)
+        return;
+
+    m_visible = visible;
+
+    float toValue = m_visible ? 0.75 : 0;
+    RefPtr&lt;PlatformCALayer&gt; platformCALayer = downcast&lt;GraphicsLayerCA&gt;(m_overlay-&gt;layer()).platformCALayer();
+
+    if (animateTransition == AnimateVisibilityTransition::No) {
+        platformCALayer-&gt;removeAnimationForKey(&quot;HUDFade&quot;);
+        platformCALayer-&gt;setOpacity(toValue);
+        return;
+    }
+
+    float duration = m_visible ? 0.25 : 0.5;
+
+    RetainPtr&lt;CABasicAnimation&gt; fadeAnimation = [CABasicAnimation animationWithKeyPath:@&quot;opacity&quot;];
+    [fadeAnimation setDuration:duration];
+    [fadeAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
+    [fadeAnimation setDelegate:[[[WKPDFHUDAnimationDelegate alloc] initWithAnimationCompletionHandler:[platformCALayer, toValue] (bool completed) {
+        if (completed)
+            platformCALayer-&gt;setOpacity(toValue);
+
+    }] autorelease]];
+    [fadeAnimation setFromValue:@(((CALayer *)platformCALayer-&gt;platformLayer().presentationLayer).opacity)];
+    [fadeAnimation setToValue:@(toValue)];
+
+    RefPtr&lt;PlatformCAAnimation&gt; animation = PlatformCAAnimationCocoa::create(fadeAnimation.get());
+    platformCALayer-&gt;removeAnimationForKey(&quot;HUDFade&quot;);
+    platformCALayer-&gt;addAnimationForKey(&quot;HUDFade&quot;, *animation);
+}
+
+bool PDFPlugin::HUD::mouseEvent(PageOverlay&amp;, const PlatformMouseEvent&amp; event)
+{
+    if (m_plugin.isLocked())
+        return false;
+
+    // We don't want the HUD to appear when dragging past it, or disappear when dragging from a button,
+    // so don't update visibility while any mouse buttons are pressed.
+    if (event.button() == MouseButton::NoButton)
+        setVisible(containsPointInRootView(event.position()), AnimateVisibilityTransition::Yes);
+
+    if (!m_visible)
+        return false;
+
+    if (event.button() != MouseButton::LeftButton)
+        return false;
+
+    IntPoint positionInRootViewCoordinates(event.position());
+    IntRect HUDRectInRootViewCoordinates = frameInRootView();
+
+    auto eventWithType = [&amp;](NSEventType eventType) -&gt; NSEvent * {
+        return [NSEvent mouseEventWithType:eventType location:positionInRootViewCoordinates modifierFlags:0 timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:event.clickCount() pressure:0];
+    };
+
+    auto pdfLayerController = m_plugin.pdfLayerController();
+
+    switch (event.type()) {
+    case PlatformEvent::MouseMoved:
+        return [pdfLayerController mouseDragged:eventWithType(NSLeftMouseDragged) inHUDWithBounds:HUDRectInRootViewCoordinates];
+    case PlatformEvent::MousePressed:
+        return [pdfLayerController mouseDown:eventWithType(NSLeftMouseDown) inHUDWithBounds:HUDRectInRootViewCoordinates];
+    case PlatformEvent::MouseReleased:
+        return [pdfLayerController mouseUp:eventWithType(NSLeftMouseUp) inHUDWithBounds:HUDRectInRootViewCoordinates];
+    default:
+        break;
+    }
+
+    return false;
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(PDFKIT_PLUGIN)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFPDFPluginAnnotationmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginAnnotation.mm (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginAnnotation.mm        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginAnnotation.mm        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> #if ENABLE(PDFKIT_PLUGIN)
</span><span class="cx"> 
</span><span class="cx"> #import &quot;PDFKitImports.h&quot;
</span><del>-#import &quot;PDFLayerControllerDetails.h&quot;
</del><ins>+#import &quot;PDFLayerControllerSPI.h&quot;
</ins><span class="cx"> #import &quot;PDFPlugin.h&quot;
</span><span class="cx"> #import &quot;PDFPluginChoiceAnnotation.h&quot;
</span><span class="cx"> #import &quot;PDFPluginTextAnnotation.h&quot;
</span><span class="lines">@@ -98,14 +98,19 @@
</span><span class="cx"> void PDFPluginAnnotation::updateGeometry()
</span><span class="cx"> {
</span><span class="cx">     IntSize documentSize(m_pdfLayerController.contentSizeRespectingZoom);
</span><del>-    IntPoint scrollPosition(m_pdfLayerController.scrollPosition);
</del><span class="cx">     NSRect annotationRect = NSRectFromCGRect([m_pdfLayerController boundsForAnnotation:m_annotation.get()]);
</span><span class="cx"> 
</span><span class="cx">     StyledElement* styledElement = static_cast&lt;StyledElement*&gt;(element());
</span><span class="cx">     styledElement-&gt;setInlineStyleProperty(CSSPropertyWidth, annotationRect.size.width, CSSPrimitiveValue::CSS_PX);
</span><span class="cx">     styledElement-&gt;setInlineStyleProperty(CSSPropertyHeight, annotationRect.size.height, CSSPrimitiveValue::CSS_PX);
</span><ins>+#if !USE(DEPRECATED_PDF_PLUGIN)
+    styledElement-&gt;setInlineStyleProperty(CSSPropertyLeft, annotationRect.origin.x, CSSPrimitiveValue::CSS_PX);
+    styledElement-&gt;setInlineStyleProperty(CSSPropertyTop, documentSize.height() - annotationRect.origin.y - annotationRect.size.height, CSSPrimitiveValue::CSS_PX);
+#else
+    IntPoint scrollPosition(m_pdfLayerController.scrollPosition);
</ins><span class="cx">     styledElement-&gt;setInlineStyleProperty(CSSPropertyLeft, annotationRect.origin.x - scrollPosition.x(), CSSPrimitiveValue::CSS_PX);
</span><span class="cx">     styledElement-&gt;setInlineStyleProperty(CSSPropertyTop, documentSize.height() - annotationRect.origin.y - annotationRect.size.height - scrollPosition.y(), CSSPrimitiveValue::CSS_PX);
</span><ins>+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool PDFPluginAnnotation::handleEvent(Event* event)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFPDFPluginChoiceAnnotationmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> #import &quot;PDFPluginChoiceAnnotation.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #import &quot;PDFKitImports.h&quot;
</span><del>-#import &quot;PDFLayerControllerDetails.h&quot;
</del><ins>+#import &quot;PDFLayerControllerSPI.h&quot;
</ins><span class="cx"> #import &lt;PDFKit/PDFKit.h&gt;
</span><span class="cx"> #import &lt;WebCore/CSSPrimitiveValue.h&gt;
</span><span class="cx"> #import &lt;WebCore/CSSPropertyNames.h&gt;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFPDFPluginPasswordFieldmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginPasswordField.mm (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginPasswordField.mm        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginPasswordField.mm        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> #if ENABLE(PDFKIT_PLUGIN)
</span><span class="cx"> 
</span><span class="cx"> #import &quot;PDFKitImports.h&quot;
</span><del>-#import &quot;PDFLayerControllerDetails.h&quot;
</del><ins>+#import &quot;PDFLayerControllerSPI.h&quot;
</ins><span class="cx"> #import &quot;PDFPlugin.h&quot;
</span><span class="cx"> #import &lt;PDFKit/PDFKit.h&gt;
</span><span class="cx"> #import &lt;WebCore/Event.h&gt;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFPDFPluginTextAnnotationmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> #import &quot;PDFAnnotationTextWidgetDetails.h&quot;
</span><span class="cx"> #import &quot;PDFKitImports.h&quot;
</span><del>-#import &quot;PDFLayerControllerDetails.h&quot;
</del><ins>+#import &quot;PDFLayerControllerSPI.h&quot;
</ins><span class="cx"> #import &quot;PDFPlugin.h&quot;
</span><span class="cx"> #import &lt;PDFKit/PDFKit.h&gt;
</span><span class="cx"> #import &lt;WebCore/CSSPrimitiveValue.h&gt;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPluginh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -222,10 +222,10 @@
</span><span class="cx"> 
</span><span class="cx">     // Ask the plug-in whether it wants URLs and files dragged onto it to cause navigation.
</span><span class="cx">     virtual bool shouldAllowNavigationFromDrags() = 0;
</span><del>-    
</del><ins>+
</ins><span class="cx">     // Ask the plug-in whether it wants to override full-page zoom.
</span><del>-    virtual bool handlesPageScaleFactor() = 0;
-    
</del><ins>+    virtual bool handlesPageScaleFactor() const = 0;
+
</ins><span class="cx">     // Tells the plug-in about focus changes.
</span><span class="cx">     virtual void setFocus(bool) = 0;
</span><span class="cx"> 
</span><span class="lines">@@ -297,6 +297,10 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void mutedStateChanged(bool) { }
</span><span class="cx"> 
</span><ins>+    virtual bool canCreateTransientPaintingSnapshot() const { return true; }
+
+    virtual bool requiresUnifiedScaleFactor() const { return false; }
+
</ins><span class="cx"> protected:
</span><span class="cx">     Plugin(PluginType);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPluginProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -458,7 +458,7 @@
</span><span class="cx">     return enabled;
</span><span class="cx"> }
</span><span class="cx">     
</span><del>-bool PluginProxy::handlesPageScaleFactor()
</del><ins>+bool PluginProxy::handlesPageScaleFactor() const
</ins><span class="cx"> {
</span><span class="cx">     if (m_waitingOnAsynchronousInitialization)
</span><span class="cx">         return false;
</span><span class="lines">@@ -470,6 +470,18 @@
</span><span class="cx">     return handled;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool PluginProxy::requiresUnifiedScaleFactor() const
+{
+    if (m_waitingOnAsynchronousInitialization)
+        return false;
+
+    bool required = false;
+    if (!m_connection-&gt;connection()-&gt;sendSync(Messages::PluginControllerProxy::RequiresUnifiedScaleFactor(), Messages::PluginControllerProxy::RequiresUnifiedScaleFactor::Reply(required), m_pluginInstanceID))
+        return false;
+    
+    return required;
+}
+
</ins><span class="cx"> NPObject* PluginProxy::pluginScriptableNPObject()
</span><span class="cx"> {
</span><span class="cx">     // Sending the synchronous Messages::PluginControllerProxy::GetPluginScriptableNPObject message can cause us to dispatch an
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPluginProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -111,7 +111,8 @@
</span><span class="cx">     virtual bool shouldAllowScripting() override { return true; }
</span><span class="cx">     virtual bool shouldAllowNavigationFromDrags() override { return false; }
</span><span class="cx">     
</span><del>-    virtual bool handlesPageScaleFactor() override;
</del><ins>+    virtual bool handlesPageScaleFactor() const override;
+    virtual bool requiresUnifiedScaleFactor() const override;
</ins><span class="cx">     
</span><span class="cx">     virtual NPObject* pluginScriptableNPObject() override;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPluginViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -521,6 +521,14 @@
</span><span class="cx">     return m_plugin-&gt;handlesPageScaleFactor();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool PluginView::requiresUnifiedScaleFactor() const
+{
+    if (!m_plugin || !m_isInitialized)
+        return false;
+
+    return m_plugin-&gt;requiresUnifiedScaleFactor();
+}
+
</ins><span class="cx"> void PluginView::webPageDestroyed()
</span><span class="cx"> {
</span><span class="cx">     m_webPage = 0;
</span><span class="lines">@@ -1863,6 +1871,9 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (!m_plugin-&gt;canCreateTransientPaintingSnapshot())
+        return false;
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPluginViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -95,6 +95,7 @@
</span><span class="cx">     void setPageScaleFactor(double scaleFactor, WebCore::IntPoint origin);
</span><span class="cx">     double pageScaleFactor() const;
</span><span class="cx">     bool handlesPageScaleFactor() const;
</span><ins>+    bool requiresUnifiedScaleFactor() const;
</ins><span class="cx"> 
</span><span class="cx">     void pageScaleFactorDidChange();
</span><span class="cx">     void topContentInsetDidChange();
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebFrameLoaderClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -458,7 +458,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Notify the UIProcess.
</span><span class="cx"> 
</span><del>-    webPage-&gt;send(Messages::WebPageProxy::DidCommitLoadForFrame(m_frame-&gt;frameID(), documentLoader.navigationID(), documentLoader.response().mimeType(), m_frameHasCustomContentProvider, static_cast&lt;uint32_t&gt;(m_frame-&gt;coreFrame()-&gt;loader().loadType()), documentLoader.response().certificateInfo(), m_frame-&gt;coreFrame()-&gt;document()-&gt;isPluginDocument(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
</del><ins>+    webPage-&gt;send(Messages::WebPageProxy::DidCommitLoadForFrame(m_frame-&gt;frameID(), documentLoader.navigationID(), documentLoader.response().mimeType(), m_frameHasCustomContentProvider, m_frame-&gt;handlesPageScaleGesture(), static_cast&lt;uint32_t&gt;(m_frame-&gt;coreFrame()-&gt;loader().loadType()), documentLoader.response().certificateInfo(), m_frame-&gt;coreFrame()-&gt;document()-&gt;isPluginDocument(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
</ins><span class="cx">     webPage-&gt;didCommitLoad(m_frame);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebFramecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.cpp        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -514,6 +514,16 @@
</span><span class="cx">     return pluginView &amp;&amp; pluginView-&gt;handlesPageScaleFactor();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool WebFrame::requiresUnifiedScaleFactor() const
+{
+    if (!m_coreFrame-&gt;document()-&gt;isPluginDocument())
+        return 0;
+
+    PluginDocument* pluginDocument = static_cast&lt;PluginDocument*&gt;(m_coreFrame-&gt;document());
+    PluginView* pluginView = static_cast&lt;PluginView*&gt;(pluginDocument-&gt;pluginWidget());
+    return pluginView &amp;&amp; pluginView-&gt;requiresUnifiedScaleFactor();
+}
+
</ins><span class="cx"> void WebFrame::setAccessibleName(const String&amp; accessibleName)
</span><span class="cx"> {
</span><span class="cx">     if (!AXObjectCache::accessibilityEnabled())
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebFrameh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.h (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.h        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebFrame.h        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -113,6 +113,7 @@
</span><span class="cx">     bool containsAnyFormControls() const;
</span><span class="cx">     void stopLoading();
</span><span class="cx">     bool handlesPageScaleGesture() const;
</span><ins>+    bool requiresUnifiedScaleFactor() const;
</ins><span class="cx">     void setAccessibleName(const String&amp;);
</span><span class="cx"> 
</span><span class="cx">     static WebFrame* frameForContext(JSContextRef);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -1341,6 +1341,13 @@
</span><span class="cx"> 
</span><span class="cx"> double WebPage::textZoomFactor() const
</span><span class="cx"> {
</span><ins>+    PluginView* pluginView = pluginViewForFrame(&amp;m_page-&gt;mainFrame());
+    if (pluginView &amp;&amp; pluginView-&gt;requiresUnifiedScaleFactor()) {
+        if (pluginView-&gt;handlesPageScaleFactor())
+            return pluginView-&gt;pageScaleFactor();
+        return pageScaleFactor();
+    }
+
</ins><span class="cx">     Frame* frame = m_mainFrame-&gt;coreFrame();
</span><span class="cx">     if (!frame)
</span><span class="cx">         return 1;
</span><span class="lines">@@ -1350,8 +1357,13 @@
</span><span class="cx"> void WebPage::setTextZoomFactor(double zoomFactor)
</span><span class="cx"> {
</span><span class="cx">     PluginView* pluginView = pluginViewForFrame(&amp;m_page-&gt;mainFrame());
</span><del>-    if (pluginView &amp;&amp; pluginView-&gt;handlesPageScaleFactor())
</del><ins>+    if (pluginView &amp;&amp; pluginView-&gt;requiresUnifiedScaleFactor()) {
+        if (pluginView-&gt;handlesPageScaleFactor())
+            pluginView-&gt;setPageScaleFactor(zoomFactor, IntPoint());
+        else
+            scalePage(zoomFactor, IntPoint());
</ins><span class="cx">         return;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     Frame* frame = m_mainFrame-&gt;coreFrame();
</span><span class="cx">     if (!frame)
</span><span class="lines">@@ -1362,8 +1374,11 @@
</span><span class="cx"> double WebPage::pageZoomFactor() const
</span><span class="cx"> {
</span><span class="cx">     PluginView* pluginView = pluginViewForFrame(&amp;m_page-&gt;mainFrame());
</span><del>-    if (pluginView &amp;&amp; pluginView-&gt;handlesPageScaleFactor())
-        return pluginView-&gt;pageScaleFactor();
</del><ins>+    if (pluginView &amp;&amp; pluginView-&gt;requiresUnifiedScaleFactor()) {
+        if (pluginView-&gt;handlesPageScaleFactor())
+            return pluginView-&gt;pageScaleFactor();
+        return pageScaleFactor();
+    }
</ins><span class="cx"> 
</span><span class="cx">     Frame* frame = m_mainFrame-&gt;coreFrame();
</span><span class="cx">     if (!frame)
</span><span class="lines">@@ -1374,8 +1389,11 @@
</span><span class="cx"> void WebPage::setPageZoomFactor(double zoomFactor)
</span><span class="cx"> {
</span><span class="cx">     PluginView* pluginView = pluginViewForFrame(&amp;m_page-&gt;mainFrame());
</span><del>-    if (pluginView &amp;&amp; pluginView-&gt;handlesPageScaleFactor()) {
-        pluginView-&gt;setPageScaleFactor(zoomFactor, IntPoint());
</del><ins>+    if (pluginView &amp;&amp; pluginView-&gt;requiresUnifiedScaleFactor()) {
+        if (pluginView-&gt;handlesPageScaleFactor())
+            pluginView-&gt;setPageScaleFactor(zoomFactor, IntPoint());
+        else
+            scalePage(zoomFactor, IntPoint());
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -1388,8 +1406,11 @@
</span><span class="cx"> void WebPage::setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
</span><span class="cx"> {
</span><span class="cx">     PluginView* pluginView = pluginViewForFrame(&amp;m_page-&gt;mainFrame());
</span><del>-    if (pluginView &amp;&amp; pluginView-&gt;handlesPageScaleFactor()) {
-        pluginView-&gt;setPageScaleFactor(pageZoomFactor, IntPoint());
</del><ins>+    if (pluginView &amp;&amp; pluginView-&gt;requiresUnifiedScaleFactor()) {
+        if (pluginView-&gt;handlesPageScaleFactor())
+            pluginView-&gt;setPageScaleFactor(pageZoomFactor, IntPoint());
+        else
+            scalePage(pageZoomFactor, IntPoint());
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (191921 => 191922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2015-11-03 00:14:36 UTC (rev 191921)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2015-11-03 00:25:04 UTC (rev 191922)
</span><span class="lines">@@ -588,7 +588,7 @@
</span><span class="cx">     if (!selection.string.length)
</span><span class="cx">         return dictionaryPopupInfo;
</span><span class="cx"> 
</span><del>-    NSRect rangeRect = pdfPlugin.viewRectForSelection(selection);
</del><ins>+    NSRect rangeRect = pdfPlugin.rectForSelectionInRootView(selection);
</ins><span class="cx"> 
</span><span class="cx">     NSAttributedString *nsAttributedString = selection.attributedString;
</span><span class="cx">     
</span></span></pre>
</div>
</div>

</body>
</html>