<!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>[214001] trunk/Source/WebKit2</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/214001">214001</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2017-03-15 12:34:22 -0700 (Wed, 15 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Un-deprecate the original PDFPlugin
https://bugs.webkit.org/show_bug.cgi?id=169655

Reviewed by Anders Carlsson.

* Shared/mac/PDFKitImports.h:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h: Removed.
* WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h: Removed.
* WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm: Removed.
* WebProcess/Plugins/PDF/PDFLayerControllerSPI.h:
* WebProcess/Plugins/PDF/PDFPlugin.h:
* WebProcess/Plugins/PDF/PDFPlugin.mm:
* WebProcess/Plugins/PDF/PDFPluginAnnotation.mm:
The transition to the non-deprecated PDFPlugin never happened,
and we have a very different plan now.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedmacPDFKitImportsh">trunk/Source/WebKit2/Shared/mac/PDFKitImports.h</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPDFPDFLayerControllerSPIh">trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerSPI.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>
</ul>

<h3>Removed 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>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (214000 => 214001)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-03-15 19:34:00 UTC (rev 214000)
+++ trunk/Source/WebKit2/ChangeLog        2017-03-15 19:34:22 UTC (rev 214001)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2017-03-15  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Un-deprecate the original PDFPlugin
+        https://bugs.webkit.org/show_bug.cgi?id=169655
+
+        Reviewed by Anders Carlsson.
+
+        * Shared/mac/PDFKitImports.h:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h: Removed.
+        * WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h: Removed.
+        * WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm: Removed.
+        * WebProcess/Plugins/PDF/PDFLayerControllerSPI.h:
+        * WebProcess/Plugins/PDF/PDFPlugin.h:
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        * WebProcess/Plugins/PDF/PDFPluginAnnotation.mm:
+        The transition to the non-deprecated PDFPlugin never happened,
+        and we have a very different plan now.
+
</ins><span class="cx"> 2017-03-15  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Compiled content extensions should include the JSON source
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacPDFKitImportsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/PDFKitImports.h (214000 => 214001)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/PDFKitImports.h        2017-03-15 19:34:00 UTC (rev 214000)
+++ trunk/Source/WebKit2/Shared/mac/PDFKitImports.h        2017-03-15 19:34:22 UTC (rev 214001)
</span><span class="lines">@@ -28,12 +28,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> 
</span><del>-#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)
-
</del><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> NSString *pdfKitFrameworkPath();
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (214000 => 214001)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2017-03-15 19:34:00 UTC (rev 214000)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2017-03-15 19:34:22 UTC (rev 214001)
</span><span class="lines">@@ -618,7 +618,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><del>-                2D3494641BCC2EC30064F0BE /* DeprecatedPDFPlugin.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D0035231BC7414800DA8716 /* DeprecatedPDFPlugin.mm */; };
</del><ins>+                2D3494641BCC2EC30064F0BE /* PDFPlugin.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D0035231BC7414800DA8716 /* PDFPlugin.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">@@ -654,7 +654,6 @@
</span><span class="cx">                 2D819B9E18627EE9001F03D1 /* ViewGestureGeometryCollector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D819B99186275B3001F03D1 /* ViewGestureGeometryCollector.cpp */; };
</span><span class="cx">                 2D819BA11862800E001F03D1 /* ViewGestureGeometryCollectorMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D819B9F1862800E001F03D1 /* ViewGestureGeometryCollectorMessageReceiver.cpp */; };
</span><span class="cx">                 2D819BA21862800E001F03D1 /* ViewGestureGeometryCollectorMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D819BA01862800E001F03D1 /* ViewGestureGeometryCollectorMessages.h */; };
</span><del>-                2D870D1016234FFE000A3F20 /* PDFPlugin.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D870D0E1622B7F9000A3F20 /* PDFPlugin.mm */; };
</del><span class="cx">                 2D8710161828415D0018FA01 /* PlatformCALayerRemoteCustom.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D8710141828415D0018FA01 /* PlatformCALayerRemoteCustom.mm */; };
</span><span class="cx">                 2D8710171828415D0018FA01 /* PlatformCALayerRemoteCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D8710151828415D0018FA01 /* PlatformCALayerRemoteCustom.h */; };
</span><span class="cx">                 2D87861D1BDB54BF00D02ABB /* _WKUserStyleSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D87861B1BDB54BF00D02ABB /* _WKUserStyleSheet.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -2780,8 +2779,8 @@
</span><span class="cx">                 29AD3097164B4E210072DEA9 /* LegacyCustomProtocolManagerProxy.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LegacyCustomProtocolManagerProxy.messages.in; path = CustomProtocols/LegacyCustomProtocolManagerProxy.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 29CD55A8128E294F00133C85 /* WKAccessibilityWebPageObjectBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKAccessibilityWebPageObjectBase.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 29CD55A9128E294F00133C85 /* WKAccessibilityWebPageObjectBase.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKAccessibilityWebPageObjectBase.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                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;; };
</del><ins>+                2D0035221BC7414800DA8716 /* PDFPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPlugin.h; path = PDF/PDFPlugin.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                2D0035231BC7414800DA8716 /* PDFPlugin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPlugin.mm; path = PDF/PDFPlugin.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 2D10875E1D2C573E00B85F82 /* LoadParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadParameters.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D10875F1D2C573E00B85F82 /* LoadParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadParameters.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D1087621D2C641B00B85F82 /* LoadParametersCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadParametersCocoa.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -2801,10 +2800,9 @@
</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 /* DeprecatedPDFLayerControllerSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DeprecatedPDFLayerControllerSPI.h; path = PDF/DeprecatedPDFLayerControllerSPI.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><ins>+                2D2ADF0C16363DEC00197E47 /* 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">                 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><del>-                2D3494631BCC23BF0064F0BE /* PDFLayerControllerSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PDFLayerControllerSPI.h; path = PDF/PDFLayerControllerSPI.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><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">@@ -2843,8 +2841,6 @@
</span><span class="cx">                 2D819B9B186275B3001F03D1 /* ViewGestureGeometryCollector.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ViewGestureGeometryCollector.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D819B9F1862800E001F03D1 /* ViewGestureGeometryCollectorMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewGestureGeometryCollectorMessageReceiver.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D819BA01862800E001F03D1 /* ViewGestureGeometryCollectorMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewGestureGeometryCollectorMessages.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                2D870D0D1622B7F9000A3F20 /* PDFPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPlugin.h; path = PDF/PDFPlugin.h; sourceTree = &quot;&lt;group&gt;&quot;; };
-                2D870D0E1622B7F9000A3F20 /* PDFPlugin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPlugin.mm; path = PDF/PDFPlugin.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 2D8710141828415D0018FA01 /* PlatformCALayerRemoteCustom.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformCALayerRemoteCustom.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D8710151828415D0018FA01 /* PlatformCALayerRemoteCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCALayerRemoteCustom.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2D87861B1BDB54BF00D02ABB /* _WKUserStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKUserStyleSheet.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -7902,13 +7898,10 @@
</span><span class="cx">                 E199875B142BF9CF00BB2DE7 /* PDF */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><del>-                                2D2ADF0C16363DEC00197E47 /* DeprecatedPDFLayerControllerSPI.h */,
-                                2D0035221BC7414800DA8716 /* DeprecatedPDFPlugin.h */,
-                                2D0035231BC7414800DA8716 /* DeprecatedPDFPlugin.mm */,
</del><ins>+                                2D2ADF0C16363DEC00197E47 /* PDFLayerControllerSPI.h */,
+                                2D0035221BC7414800DA8716 /* PDFPlugin.h */,
+                                2D0035231BC7414800DA8716 /* PDFPlugin.mm */,
</ins><span class="cx">                                 3574B37F1665932C00859BB7 /* PDFAnnotationTextWidgetDetails.h */,
</span><del>-                                2D3494631BCC23BF0064F0BE /* PDFLayerControllerSPI.h */,
-                                2D870D0D1622B7F9000A3F20 /* PDFPlugin.h */,
-                                2D870D0E1622B7F9000A3F20 /* PDFPlugin.mm */,
</del><span class="cx">                                 2D2ADF021636243500197E47 /* PDFPluginAnnotation.h */,
</span><span class="cx">                                 2D2ADF031636243500197E47 /* PDFPluginAnnotation.mm */,
</span><span class="cx">                                 2D2ADF0D16364D8200197E47 /* PDFPluginChoiceAnnotation.h */,
</span><span class="lines">@@ -9711,7 +9704,7 @@
</span><span class="cx">                                 C55F91701C595F630029E92D /* DataDetectionResult.mm in Sources */,
</span><span class="cx">                                 1AC7537F183BE50F0072CB15 /* DataReference.cpp in Sources */,
</span><span class="cx">                                 BC032DA510F437D10058C15A /* Decoder.cpp in Sources */,
</span><del>-                                2D3494641BCC2EC30064F0BE /* DeprecatedPDFPlugin.mm in Sources */,
</del><ins>+                                2D3494641BCC2EC30064F0BE /* PDFPlugin.mm in Sources */,
</ins><span class="cx">                                 83891B6D1A68C30B0030F386 /* DiagnosticLoggingClient.mm in Sources */,
</span><span class="cx">                                 5C1427011C23F84C00D41183 /* Download.cpp in Sources */,
</span><span class="cx">                                 A1DF631218E0B7C8003A3E2A /* DownloadClient.mm in Sources */,
</span><span class="lines">@@ -9891,7 +9884,6 @@
</span><span class="cx">                                 1AC7537B183A9FDB0072CB15 /* PageLoadState.cpp in Sources */,
</span><span class="cx">                                 C574A58212E66681002DFE98 /* PasteboardTypes.mm in Sources */,
</span><span class="cx">                                 E19582D6153CC05400B60875 /* PDFKitImports.mm in Sources */,
</span><del>-                                2D870D1016234FFE000A3F20 /* PDFPlugin.mm in Sources */,
</del><span class="cx">                                 2D2ADF0B16362DDB00197E47 /* PDFPluginAnnotation.mm in Sources */,
</span><span class="cx">                                 2D2ADF1016364D8200197E47 /* PDFPluginChoiceAnnotation.mm in Sources */,
</span><span class="cx">                                 2D429BFD1721E2C700EC681F /* PDFPluginPasswordField.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFDeprecatedPDFLayerControllerSPIh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h (214000 => 214001)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h        2017-03-15 19:34:00 UTC (rev 214000)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h        2017-03-15 19:34:22 UTC (rev 214001)
</span><span class="lines">@@ -1,166 +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.
- */
-
-#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;
-
-typedef NS_ENUM(NSInteger, PDFLayerControllerCursorType) {
-    kPDFLayerControllerCursorTypePointer = 0,
-    kPDFLayerControllerCursorTypeHand,
-    kPDFLayerControllerCursorTypeIBeam,
-};
-
-@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;
-
-- (void)setMouseCursor:(PDFLayerControllerCursorType)cursorType;
-
-@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
</del></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFDeprecatedPDFPluginh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h (214000 => 214001)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h        2017-03-15 19:34:00 UTC (rev 214000)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h        2017-03-15 19:34:22 UTC (rev 214001)
</span><span class="lines">@@ -1,330 +0,0 @@
</span><del>-/*
- * 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 notifyCursorChanged(uint64_t /* PDFLayerControllerCursorType */);
-
-    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;
-
-    bool shouldPlaceBlockDirectionScrollbarOnLeft() const override { return false; }
-
-private:
-    explicit PDFPlugin(WebFrame*);
-
-    // Plugin functions.
-    bool initialize(const Parameters&amp;) override;
-    void destroy() override;
-    void paint(WebCore::GraphicsContext&amp;, const WebCore::IntRect&amp; dirtyRectInWindowCoordinates) override { }
-    void updateControlTints(WebCore::GraphicsContext&amp;) override;
-    bool supportsSnapshotting() const override { return true; }
-    RefPtr&lt;ShareableBitmap&gt; snapshot() override;
-    PlatformLayer* pluginLayer() override;
-    bool isTransparent() override { return false; }
-    bool wantsWheelEvents() override { return true; }
-    void geometryDidChange(const WebCore::IntSize&amp; pluginSize, const WebCore::IntRect&amp; clipRect, const WebCore::AffineTransform&amp; pluginToRootViewTransform) override;
-    void contentsScaleFactorChanged(float) override;
-    void visibilityDidChange(bool) override { }
-    void frameDidFinishLoading(uint64_t requestID) override;
-    void frameDidFail(uint64_t requestID, bool wasCancelled) override;
-    void didEvaluateJavaScript(uint64_t requestID, const String&amp; result) override;
-    void streamWillSendRequest(uint64_t streamID, const WebCore::URL&amp; requestURL, const WebCore::URL&amp; responseURL, int responseStatus) override { }
-    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;
-    void streamDidReceiveData(uint64_t streamID, const char* bytes, int length) override;
-    void streamDidFinishLoading(uint64_t streamID) override;
-    void streamDidFail(uint64_t streamID, bool wasCancelled) override;
-    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;
-    void manualStreamDidReceiveData(const char* bytes, int length) override;
-    void manualStreamDidFinishLoading() override;
-    void manualStreamDidFail(bool wasCancelled) override;
-    bool handleMouseEvent(const WebMouseEvent&amp;) override;
-    bool handleWheelEvent(const WebWheelEvent&amp;) override;
-    bool handleMouseEnterEvent(const WebMouseEvent&amp;) override;
-    bool handleMouseLeaveEvent(const WebMouseEvent&amp;) override;
-    bool handleContextMenuEvent(const WebMouseEvent&amp;) override;
-    bool handleKeyboardEvent(const WebKeyboardEvent&amp;) override;
-    bool handleEditingCommand(const String&amp; commandName, const String&amp; argument) override;
-    bool isEditingCommandEnabled(const String&amp;) override;
-    bool handlesPageScaleFactor() const override;
-    bool requiresUnifiedScaleFactor() const override { return true; }
-    void setFocus(bool) override { }
-    NPObject* pluginScriptableNPObject() override { return 0; }
-    void windowFocusChanged(bool) override { }
-    void windowAndViewFramesChanged(const WebCore::IntRect&amp; windowFrameInScreenCoordinates, const WebCore::IntRect&amp; viewFrameInWindowCoordinates) override { }
-    void windowVisibilityChanged(bool) override { }
-    uint64_t pluginComplexTextInputIdentifier() const override { return 0; }
-    void sendComplexTextInput(const String&amp; textInput) override { }
-    void setLayerHostingMode(LayerHostingMode) override { }
-    WebCore::Scrollbar* horizontalScrollbar() override { return m_horizontalScrollbar.get(); }
-    WebCore::Scrollbar* verticalScrollbar() override { return m_verticalScrollbar.get(); }
-    void storageBlockingStateChanged(bool) override { }
-    void privateBrowsingStateChanged(bool) override { }
-    bool getFormValue(String&amp; formValue) override { return false; }
-    bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity) override;
-    RefPtr&lt;WebCore::SharedBuffer&gt; liveResourceData() const override;
-    void willDetatchRenderer() override;
-
-    bool isBeingAsynchronouslyInitialized() const override { return false; }
-
-    RetainPtr&lt;PDFDocument&gt; pdfDocumentForPrinting() const override { return m_pdfDocument; }
-    NSObject *accessibilityObject() const override;
-
-    unsigned countFindMatches(const String&amp; target, WebCore::FindOptions, unsigned maxMatchCount) override;
-    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;
-
-    bool shouldAllowScripting() override { return false; }
-    bool shouldAllowNavigationFromDrags() override { return true; }
-    bool shouldAlwaysAutoStart() const override { return true; }
-
-    // ScrollableArea functions.
-    WebCore::IntRect scrollCornerRect() const override;
-    WebCore::ScrollableArea* enclosingScrollableArea() const override;
-    bool isScrollableOrRubberbandable() override { return true; }
-    bool hasScrollableOrRubberbandableAncestor() override { return true; }
-    WebCore::IntRect scrollableAreaBoundingBox(bool* = nullptr) const override;
-    void setScrollOffset(const WebCore::ScrollOffset&amp;) override;
-    void invalidateScrollbarRect(WebCore::Scrollbar&amp;, const WebCore::IntRect&amp;) override;
-    void invalidateScrollCornerRect(const WebCore::IntRect&amp;) override;
-    WebCore::IntPoint lastKnownMousePosition() const override { return m_lastMousePositionInPluginCoordinates; }
-    int scrollSize(WebCore::ScrollbarOrientation) const override;
-    bool isActive() const override;
-    bool isScrollCornerVisible() const override { return false; }
-    int scrollOffset(WebCore::ScrollbarOrientation) const override;
-    WebCore::ScrollPosition scrollPosition() const override;
-    WebCore::ScrollPosition minimumScrollPosition() const override;
-    WebCore::ScrollPosition maximumScrollPosition() const override;
-    WebCore::IntSize visibleSize() const override { return m_size; }
-    WebCore::IntSize contentsSize() const override { return m_pdfDocumentSize; }
-    WebCore::Scrollbar* horizontalScrollbar() const override { return m_horizontalScrollbar.get(); }
-    WebCore::Scrollbar* verticalScrollbar() const override { return m_verticalScrollbar.get(); }
-    bool shouldSuspendScrollAnimations() const override { return false; } // If we return true, ScrollAnimatorMac will keep cycling a timer forever, waiting for a good time to animate.
-    void scrollbarStyleChanged(WebCore::ScrollbarStyle, bool forceUpdate) override;
-    WebCore::IntRect convertFromScrollbarToContainingView(const WebCore::Scrollbar&amp;, const WebCore::IntRect&amp; scrollbarRect) const override;
-    WebCore::IntRect convertFromContainingViewToScrollbar(const WebCore::Scrollbar&amp;, const WebCore::IntRect&amp; parentRect) const override;
-    WebCore::IntPoint convertFromScrollbarToContainingView(const WebCore::Scrollbar&amp;, const WebCore::IntPoint&amp; scrollbarPoint) const override;
-    WebCore::IntPoint convertFromContainingViewToScrollbar(const WebCore::Scrollbar&amp;, const WebCore::IntPoint&amp; parentPoint) const override;
-    bool forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const override;
-
-    // PDFPlugin functions.
-    void updateScrollbars();
-    Ref&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; }
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 101300
-    enum UpdateCursorMode {
-        UpdateIfNeeded,
-        ForceUpdate
-    };
-
-    enum HitTestResult {
-        None,
-        Text
-    };
-
-    void updateCursor(const WebMouseEvent&amp;, UpdateCursorMode = UpdateIfNeeded);
-#endif
-
-    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;
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 101300
-    HitTestResult m_lastHitTestResult;
-#endif
-
-    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
</del></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFDeprecatedPDFPluginmm"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm (214000 => 214001)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm        2017-03-15 19:34:00 UTC (rev 214000)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm        2017-03-15 19:34:22 UTC (rev 214001)
</span><span class="lines">@@ -1,2113 +0,0 @@
</span><del>-/*
- * 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/EventNames.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
-{
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
-    _pdfPlugin-&gt;writeItemsToPasteboard(NSGeneralPboard, items, types);
-#pragma clang diagnostic pop
-}
-
-- (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);
-}
-
-- (void)setMouseCursor:(PDFLayerControllerCursorType)cursorType
-{
-    _pdfPlugin-&gt;notifyCursorChanged(cursorType);
-}
-
-@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;setAttributeWithoutSynchronization(idAttr, AtomicString(&quot;annotationContainer&quot;, AtomicString::ConstructFromLiteral));
-
-        auto annotationStyleElement = document-&gt;createElement(styleTag, false);
-        annotationStyleElement-&gt;setTextContent(annotationStyle);
-
-        m_annotationContainer-&gt;appendChild(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);
-
-    IntSize scrollbarSpace = scrollbarIntrusion();
-
-    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() - scrollbarSpace.width(), 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() - scrollbarSpace.height(), 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());
-}
-
-Ref&lt;Scrollbar&gt; PDFPlugin::createScrollbar(ScrollbarOrientation orientation)
-{
-    auto 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.ptr(), 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);
-    return widget;
-}
-
-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&amp; scrollbar, const IntRect&amp; scrollbarRect) const
-{
-    IntRect rect = scrollbarRect;
-    rect.move(scrollbar.location() - pluginView()-&gt;location());
-
-    return pluginView()-&gt;frame()-&gt;view()-&gt;convertFromRendererToContainingView(pluginView()-&gt;pluginElement()-&gt;renderer(), rect);
-}
-
-IntRect PDFPlugin::convertFromContainingViewToScrollbar(const Scrollbar&amp; 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.location());
-
-    return rect;
-}
-
-IntPoint PDFPlugin::convertFromScrollbarToContainingView(const Scrollbar&amp; scrollbar, const IntPoint&amp; scrollbarPoint) const
-{
-    IntPoint point = scrollbarPoint;
-    point.move(scrollbar.location() - pluginView()-&gt;location());
-
-    return pluginView()-&gt;frame()-&gt;view()-&gt;convertFromRendererToContainingView(pluginView()-&gt;pluginElement()-&gt;renderer(), point);
-}
-
-IntPoint PDFPlugin::convertFromContainingViewToScrollbar(const Scrollbar&amp; 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.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(bool*) 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::scrollOffset(ScrollbarOrientation orientation) const
-{
-    if (orientation == HorizontalScrollbar)
-        return m_scrollOffset.width();
-
-    if (orientation == VerticalScrollbar)
-        return m_scrollOffset.height();
-
-    ASSERT_NOT_REACHED();
-    return 0;
-}
-
-ScrollPosition PDFPlugin::scrollPosition() const
-{
-    return IntPoint(m_scrollOffset.width(), m_scrollOffset.height());
-}
-
-ScrollPosition PDFPlugin::minimumScrollPosition() const
-{
-    return IntPoint();
-}
-
-ScrollPosition PDFPlugin::maximumScrollPosition() const
-{
-    IntSize scrollbarSpace = scrollbarIntrusion();
-
-    IntPoint maximumOffset(m_pdfDocumentSize.width() - m_size.width() + scrollbarSpace.width(), m_pdfDocumentSize.height() - m_size.height() + scrollbarSpace.height());
-    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.releaseNonNull());
-}
-
-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 (equalIgnoringASCIICase(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 (equalIgnoringASCIICase(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::willDetatchRenderer()
-{
-    if (webFrame()) {
-        if (FrameView* frameView = webFrame()-&gt;coreFrame()-&gt;view())
-            frameView-&gt;removeScrollableArea(this);
-    }
-}
-
-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().value_or(AffineTransform()).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().value_or(AffineTransform()).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().value_or(AffineTransform()).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().value_or(AffineTransform());
-    [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() ? NSEventModifierFlagShift : 0)
-        | (event.controlKey() ? NSEventModifierFlagControl : 0)
-        | (event.altKey() ? NSEventModifierFlagOption : 0)
-        | (event.metaKey() ? NSEventModifierFlagCommand : 0);
-}
-    
-static bool getEventTypeFromWebEvent(const WebEvent&amp; event, NSEventType&amp; eventType)
-{
-    switch (event.type()) {
-    case WebEvent::KeyDown:
-        eventType = NSEventTypeKeyDown;
-        return true;
-    case WebEvent::KeyUp:
-        eventType = NSEventTypeKeyUp;
-        return true;
-    case WebEvent::MouseDown:
-        switch (static_cast&lt;const WebMouseEvent&amp;&gt;(event).button()) {
-        case WebMouseEvent::LeftButton:
-            eventType = NSEventTypeLeftMouseDown;
-            return true;
-        case WebMouseEvent::RightButton:
-            eventType = NSEventTypeRightMouseDown;
-            return true;
-        default:
-            return false;
-        }
-    case WebEvent::MouseUp:
-        switch (static_cast&lt;const WebMouseEvent&amp;&gt;(event).button()) {
-        case WebMouseEvent::LeftButton:
-            eventType = NSEventTypeLeftMouseUp;
-            return true;
-        case WebMouseEvent::RightButton:
-            eventType = NSEventTypeRightMouseUp;
-            return true;
-        default:
-            return false;
-        }
-    case WebEvent::MouseMove:
-        switch (static_cast&lt;const WebMouseEvent&amp;&gt;(event).button()) {
-        case WebMouseEvent::LeftButton:
-            eventType = NSEventTypeLeftMouseDragged;
-            return true;
-        case WebMouseEvent::RightButton:
-            eventType = NSEventTypeRightMouseDragged;
-            return true;
-        case WebMouseEvent::NoButton:
-            eventType = NSEventTypeMouseMoved;
-            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];
-}
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 101300
-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;
-}
-#endif
-
-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();
-#if __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 101300
-        updateCursor(event);
-#endif
-
-        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();
-#if __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 101300
-    updateCursor(event, ForceUpdate);
-#endif
-    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;
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
-        if (string.length)
-            writeItemsToPasteboard(NSFindPboard, @[ [string dataUsingEncoding:NSUTF8StringEncoding] ], @[ NSPasteboardTypeString ]);
-#pragma clang diagnostic pop
-    }
-
-    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 ScrollOffset&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&amp; scrollbar, const IntRect&amp; rect)
-{
-    if (&amp;scrollbar == horizontalScrollbar())
-        [m_horizontalScrollbarLayer setNeedsDisplay];
-    else if (&amp;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) {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
-        if ([annotation isKindOfClass:pdfAnnotationTextWidgetClass()] &amp;&amp; static_cast&lt;PDFAnnotationTextWidget *&gt;(annotation).isReadOnly) {
-            m_activeAnnotation = nullptr;
-            return;
-        }
-#pragma clang diagnostic pop
-
-        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();
-
-    RetainPtr&lt;PDFSelection&gt; selectionForInitialSearch = adoptNS([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.get() withOptions:options];
-
-    // 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) {
-        auto emptySelection = adoptNS([[pdfSelectionClass() alloc] initWithDocument:document]);
-        foundSelection = [document findString:target fromSelection:emptySelection.get() 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();
-}
-
-static const Cursor&amp; pdfLayerControllerCursorTypeToCursor(PDFLayerControllerCursorType type)
-{
-    switch (type) {
-    case kPDFLayerControllerCursorTypeHand:
-        return handCursor();
-    case kPDFLayerControllerCursorTypeIBeam:
-        return iBeamCursor();
-    case kPDFLayerControllerCursorTypePointer:
-    default:
-        return pointerCursor();
-    }
-}
-
-void PDFPlugin::notifyCursorChanged(uint64_t type)
-{
-    webFrame()-&gt;page()-&gt;send(Messages::WebPageProxy::SetCursor(pdfLayerControllerCursorTypeToCursor(static_cast&lt;PDFLayerControllerCursorType&gt;(type))));
-}
-
-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;
-
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
-        PDFAnnotationLink *linkAnnotation = (PDFAnnotationLink *)annotation;
-#pragma clang diagnostic pop
-        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)
</del></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFPDFLayerControllerSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h (214000 => 214001)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h        2017-03-15 19:34:00 UTC (rev 214000)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerSPI.h        2017-03-15 19:34:22 UTC (rev 214001)
</span><span class="lines">@@ -26,45 +26,37 @@
</span><span class="cx"> #ifndef PDFLayerControllerSPI_h
</span><span class="cx"> #define PDFLayerControllerSPI_h
</span><span class="cx"> 
</span><del>-#include &quot;PDFKitImports.h&quot;
-
</del><span class="cx"> #if ENABLE(PDFKIT_PLUGIN)
</span><del>-#if USE(DEPRECATED_PDF_PLUGIN)
</del><span class="cx"> 
</span><del>-#include &quot;DeprecatedPDFLayerControllerSPI.h&quot;
-
-#else // USE(DEPRECATED_PDF_PLUGIN)
-
</del><span class="cx"> #import &lt;PDFKit/PDFKit.h&gt;
</span><span class="cx"> 
</span><span class="cx"> @class CPReadingModel;
</span><span class="cx"> @class PDFViewLayout;
</span><span class="cx"> 
</span><ins>+typedef NS_ENUM(NSInteger, PDFLayerControllerCursorType) {
+    kPDFLayerControllerCursorTypePointer = 0,
+    kPDFLayerControllerCursorTypeHand,
+    kPDFLayerControllerCursorTypeIBeam,
+};
+
</ins><span class="cx"> @protocol PDFLayerControllerDelegate &lt;NSObject&gt;
</span><span class="cx"> 
</span><del>-@optional
</del><ins>+- (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;
</ins><span class="cx"> 
</span><del>-- (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;
-
</del><span class="cx"> - (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeActiveAnnotation:(PDFAnnotation *)annotation;
</span><del>-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didClickLinkWithURL:(NSURL *)url;
</del><ins>+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController clickedLinkWithURL:(NSURL *)url;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeContentScaleFactor:(CGFloat)scaleFactor;
</ins><span class="cx"> - (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeDisplayMode:(int)mode;
</span><span class="cx"> - (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeSelection:(PDFSelection *)selection;
</span><span class="cx"> 
</span><del>-- (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;
</del><ins>+- (void)setMouseCursor:(PDFLayerControllerCursorType)cursorType;
</ins><span class="cx"> 
</span><del>-- (NSColorSpace*)pdfLayerControllerColorSpace:(PDFLayerController *)pdfLayerController;
-
</del><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @interface PDFLayerController : NSObject
</span><span class="lines">@@ -72,74 +64,77 @@
</span><span class="cx"> 
</span><span class="cx"> @interface PDFLayerController ()
</span><span class="cx"> 
</span><ins>+@property (retain) CALayer *parentLayer;
</ins><span class="cx"> @property (retain) PDFDocument *document;
</span><del>-@property (assign) id&lt;PDFLayerControllerDelegate&gt; delegate;
-@property (retain) NSArray *searchMatches;
</del><ins>+@property (retain) id&lt;PDFLayerControllerDelegate&gt; delegate;
</ins><span class="cx"> 
</span><span class="cx"> - (void)setFrameSize:(CGSize)size;
</span><span class="cx"> 
</span><del>-- (void)setDisplayMode:(int)mode;
-- (int)displayMode;
-- (int)realDisplayMode;
</del><ins>+- (PDFDisplayMode)displayMode;
+- (void)setDisplayMode:(PDFDisplayMode)mode;
+- (void)setDisplaysPageBreaks:(BOOL)pageBreaks;
</ins><span class="cx"> 
</span><ins>+- (CGFloat)contentScaleFactor;
+- (void)setContentScaleFactor:(CGFloat)scaleFactor;
+
+- (CGFloat)deviceScaleFactor;
+- (void)setDeviceScaleFactor:(CGFloat)scaleFactor;
+
</ins><span class="cx"> - (CGSize)contentSize;
</span><span class="cx"> - (CGSize)contentSizeRespectingZoom;
</span><span class="cx"> 
</span><del>-- (CGFloat)contentScaleFactor;
-- (void)setContentScaleFactor:(CGFloat)contentScaleFactor;
</del><ins>+- (void)snapshotInContext:(CGContextRef)context;
</ins><span class="cx"> 
</span><del>-- (PDFViewLayout *)layout;
</del><ins>+- (void)magnifyWithMagnification:(CGFloat)magnification atPoint:(CGPoint)point immediately:(BOOL)immediately;
</ins><span class="cx"> 
</span><del>-- (void)drawInContext:(CGContextRef)context;
-- (void)drawHUDInContext:(CGContextRef)context;
</del><ins>+- (CGPoint)scrollPosition;
+- (void)setScrollPosition:(CGPoint)newPosition;
+- (void)scrollWithDelta:(CGSize)delta;
</ins><span class="cx"> 
</span><span class="cx"> - (void)mouseDown:(NSEvent *)event;
</span><ins>+- (void)rightMouseDown:(NSEvent *)event;
+- (void)mouseMoved:(NSEvent *)event;
</ins><span class="cx"> - (void)mouseUp:(NSEvent *)event;
</span><span class="cx"> - (void)mouseDragged:(NSEvent *)event;
</span><ins>+- (void)mouseEntered:(NSEvent *)event;
+- (void)mouseExited:(NSEvent *)event;
</ins><span class="cx"> 
</span><del>-- (BOOL)mouseDown:(NSEvent *)event inHUDWithBounds:(CGRect)bounds;
-- (BOOL)mouseUp:(NSEvent *)event inHUDWithBounds:(CGRect)bounds;
-- (BOOL)mouseDragged:(NSEvent *)event inHUDWithBounds:(CGRect)bounds;
-
</del><span class="cx"> - (NSMenu *)menuForEvent:(NSEvent *)event;
</span><span class="cx"> 
</span><del>-- (NSArray *)pageRects;
</del><ins>+- (NSArray *)findString:(NSString *)string caseSensitive:(BOOL)isCaseSensitive highlightMatches:(BOOL)shouldHighlightMatches;
</ins><span class="cx"> 
</span><del>-- (void)setVisibleRect:(CGRect)visibleRect;
-
-- (void)gotoSelection:(PDFSelection *)selection;
-- (void)gotoDestination:(PDFDestination *)destination;
-- (void)gotoRect:(CGRect)rect onPage:(PDFPage *)page;
-
</del><span class="cx"> - (PDFSelection *)currentSelection;
</span><span class="cx"> - (void)setCurrentSelection:(PDFSelection *)selection;
</span><del>-
-- (void)searchInDictionaryWithSelection:(PDFSelection *)selection;
</del><ins>+- (PDFSelection *)searchSelection;
+- (void)setSearchSelection:(PDFSelection *)selection;
+- (void)gotoSelection:(PDFSelection *)selection;
</ins><span class="cx"> - (PDFSelection *)getSelectionForWordAtPoint:(CGPoint)point;
</span><span class="cx"> - (NSArray *)rectsForSelectionInLayoutSpace:(PDFSelection *)selection;
</span><ins>+- (NSArray *)rectsForAnnotationInLayoutSpace:(PDFAnnotation *)annotation;
+- (PDFViewLayout *)layout;
+- (NSRect)frame;
</ins><span class="cx"> 
</span><del>-- (NSArray *)highlights;
-- (void)setHighlights:(NSArray*)highlights;
</del><ins>+- (PDFPage *)currentPage;
+- (NSUInteger)lastPageIndex;
+- (NSUInteger)currentPageIndex;
+- (void)gotoNextPage;
+- (void)gotoPreviousPage;
</ins><span class="cx"> 
</span><del>-- (PDFSelection *)searchSelection;
-- (NSArray *)searchMatches;
-- (void)setSearchSelection:(PDFSelection*)selection;
-- (NSArray *)findString:(NSString *)string caseSensitive:(BOOL)isCaseSensitive highlightMatches:(BOOL)shouldHighlightMatches;
-
</del><span class="cx"> - (void)copySelection;
</span><span class="cx"> - (void)selectAll;
</span><span class="cx"> 
</span><del>-- (PDFPage *)currentPage;
-- (NSUInteger)currentPageIndex;
</del><ins>+- (bool)keyDown:(NSEvent *)event;
</ins><span class="cx"> 
</span><del>-- (BOOL)documentIsLocked;
-- (void)attemptToUnlockWithPassword:(NSString *)password;
</del><ins>+- (void)setHUDEnabled:(BOOL)enabled;
+- (BOOL)hudEnabled;
</ins><span class="cx"> 
</span><span class="cx"> - (CGRect)boundsForAnnotation:(PDFAnnotation *)annotation;
</span><span class="cx"> - (void)activateNextAnnotation:(BOOL)previous;
</span><span class="cx"> 
</span><del>-- (NSRect)frame;
</del><ins>+- (void)attemptToUnlockWithPassword:(NSString *)password;
</ins><span class="cx"> 
</span><ins>+- (void)searchInDictionaryWithSelection:(PDFSelection *)selection;
+
</ins><span class="cx"> // Accessibility
</span><span class="cx"> 
</span><span class="cx"> - (CPReadingModel *)readingModel;
</span><span class="lines">@@ -166,7 +161,6 @@
</span><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span><del>-#endif // USE(DEPRECATED_PDF_PLUGIN)
-#endif // ENABLE(PDFPLUGIN)
</del><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> #endif // PDFLayerControllerSPI_h
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFPDFPluginh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h (214000 => 214001)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h        2017-03-15 19:34:00 UTC (rev 214000)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h        2017-03-15 19:34:22 UTC (rev 214001)
</span><span class="lines">@@ -29,18 +29,12 @@
</span><span class="cx"> #include &quot;PDFKitImports.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(PDFKIT_PLUGIN)
</span><del>-#if USE(DEPRECATED_PDF_PLUGIN)
</del><span class="cx"> 
</span><del>-#include &quot;DeprecatedPDFPlugin.h&quot;
-
-#else // USE(DEPRECATED_PDF_PLUGIN)
-
</del><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><del>-#include &lt;WebCore/PageOverlay.h&gt;
</del><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">@@ -74,7 +68,7 @@
</span><span class="cx"> class PluginView;
</span><span class="cx"> class WebFrame;
</span><span class="cx"> 
</span><del>-class PDFPlugin final : public Plugin {
</del><ins>+class PDFPlugin final : public Plugin, private WebCore::ScrollableArea {
</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">@@ -82,15 +76,18 @@
</span><span class="cx">     static WebCore::PluginInfo pluginInfo();
</span><span class="cx"> 
</span><span class="cx">     WebCore::IntSize size() const { return m_size; }
</span><del>-    float scaleFactor() const;
</del><span class="cx"> 
</span><span class="cx">     void didMutatePDFDocument() { m_pdfDocumentWasMutated = true; }
</span><span class="cx"> 
</span><ins>+    void paintControlForLayerInContext(CALayer *, CGContextRef);
</ins><span class="cx">     void setActiveAnnotation(PDFAnnotation *);
</span><del>-
</del><ins>+    
+    using ScrollableArea::notifyScrollPositionChanged;
+    void notifyContentScaleFactorChanged(CGFloat scaleFactor);
</ins><span class="cx">     void notifyDisplayModeChanged(int);
</span><span class="cx"> 
</span><span class="cx">     void notifySelectionChanged(PDFSelection *);
</span><ins>+    void notifyCursorChanged(uint64_t /* PDFLayerControllerCursorType */);
</ins><span class="cx"> 
</span><span class="cx">     void clickedLink(NSURL *);
</span><span class="cx">     void saveToPDF();
</span><span class="lines">@@ -99,25 +96,13 @@
</span><span class="cx">     void showDefinitionForAttributedString(NSAttributedString *, CGPoint);
</span><span class="cx">     void performWebSearch(NSString *);
</span><span class="cx">     void performSpotlightSearch(NSString *);
</span><del>-    void invalidatePDFRect(WebCore::IntRect);
-    void invalidateHUD();
-    void scrollToPoint(WebCore::IntPoint);
</del><span class="cx"> 
</span><del>-    void zoomIn();
-    void zoomOut();
-
</del><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><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;
-
-    WebCore::IntRect convertFromPDFViewToRootView(const WebCore::IntRect&amp;) const;
</del><span class="cx">     WebCore::FloatRect convertFromPDFViewToScreen(const WebCore::FloatRect&amp;) const;
</span><del>-
</del><span class="cx">     WebCore::IntRect boundsOnScreen() const;
</span><span class="cx">     
</span><span class="cx">     bool showContextMenuAtPoint(const WebCore::IntPoint&amp;);
</span><span class="lines">@@ -125,10 +110,9 @@
</span><span class="cx">     String lookupTextAtLocation(const WebCore::FloatPoint&amp;, WebHitTestResultData&amp;, PDFSelection **, NSDictionary **) const;
</span><span class="cx">     WebCore::FloatRect rectForSelectionInRootView(PDFSelection *) const;
</span><span class="cx"> 
</span><del>-    PDFLayerController *pdfLayerController() const { return m_pdfLayerController.get(); }
-    WebFrame* webFrame() const { return m_frame; }
</del><ins>+    CGFloat scaleFactor() const;
</ins><span class="cx"> 
</span><del>-    bool isLocked() const;
</del><ins>+    bool shouldPlaceBlockDirectionScrollbarOnLeft() const override { return false; }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     explicit PDFPlugin(WebFrame*);
</span><span class="lines">@@ -136,15 +120,15 @@
</span><span class="cx">     // Plugin functions.
</span><span class="cx">     bool initialize(const Parameters&amp;) override;
</span><span class="cx">     void destroy() override;
</span><del>-    void paint(WebCore::GraphicsContext&amp;, const WebCore::IntRect&amp; dirtyRectInWindowCoordinates) override;
-    void updateControlTints(WebCore::GraphicsContext&amp;) override { }
-    bool supportsSnapshotting() const override { return false; }
</del><ins>+    void paint(WebCore::GraphicsContext&amp;, const WebCore::IntRect&amp; dirtyRectInWindowCoordinates) override { }
+    void updateControlTints(WebCore::GraphicsContext&amp;) override;
+    bool supportsSnapshotting() const override { return true; }
</ins><span class="cx">     RefPtr&lt;ShareableBitmap&gt; snapshot() override;
</span><del>-    PlatformLayer* pluginLayer() override { return nullptr; }
</del><ins>+    PlatformLayer* pluginLayer() override;
</ins><span class="cx">     bool isTransparent() override { return false; }
</span><del>-    bool wantsWheelEvents() override { return false; }
</del><ins>+    bool wantsWheelEvents() override { return true; }
</ins><span class="cx">     void geometryDidChange(const WebCore::IntSize&amp; pluginSize, const WebCore::IntRect&amp; clipRect, const WebCore::AffineTransform&amp; pluginToRootViewTransform) override;
</span><del>-    void contentsScaleFactorChanged(float) override { }
</del><ins>+    void contentsScaleFactorChanged(float) override;
</ins><span class="cx">     void visibilityDidChange(bool) override { }
</span><span class="cx">     void frameDidFinishLoading(uint64_t requestID) override;
</span><span class="cx">     void frameDidFail(uint64_t requestID, bool wasCancelled) override;
</span><span class="lines">@@ -159,15 +143,17 @@
</span><span class="cx">     void manualStreamDidFinishLoading() override;
</span><span class="cx">     void manualStreamDidFail(bool wasCancelled) override;
</span><span class="cx">     bool handleMouseEvent(const WebMouseEvent&amp;) override;
</span><del>-    bool handleWheelEvent(const WebWheelEvent&amp;) override { return false; }
</del><ins>+    bool handleWheelEvent(const WebWheelEvent&amp;) override;
</ins><span class="cx">     bool handleMouseEnterEvent(const WebMouseEvent&amp;) override;
</span><span class="cx">     bool handleMouseLeaveEvent(const WebMouseEvent&amp;) override;
</span><span class="cx">     bool handleContextMenuEvent(const WebMouseEvent&amp;) override;
</span><del>-    bool handleKeyboardEvent(const WebKeyboardEvent&amp;) override { return false; }
</del><ins>+    bool handleKeyboardEvent(const WebKeyboardEvent&amp;) override;
</ins><span class="cx">     bool handleEditingCommand(const String&amp; commandName, const String&amp; argument) override;
</span><span class="cx">     bool isEditingCommandEnabled(const String&amp;) override;
</span><ins>+    bool handlesPageScaleFactor() const override;
+    bool requiresUnifiedScaleFactor() const override { return true; }
</ins><span class="cx">     void setFocus(bool) override { }
</span><del>-    NPObject* pluginScriptableNPObject() override { return nullptr; }
</del><ins>+    NPObject* pluginScriptableNPObject() override { return 0; }
</ins><span class="cx">     void windowFocusChanged(bool) override { }
</span><span class="cx">     void windowAndViewFramesChanged(const WebCore::IntRect&amp; windowFrameInScreenCoordinates, const WebCore::IntRect&amp; viewFrameInWindowCoordinates) override { }
</span><span class="cx">     void windowVisibilityChanged(bool) override { }
</span><span class="lines">@@ -174,17 +160,15 @@
</span><span class="cx">     uint64_t pluginComplexTextInputIdentifier() const override { return 0; }
</span><span class="cx">     void sendComplexTextInput(const String&amp; textInput) override { }
</span><span class="cx">     void setLayerHostingMode(LayerHostingMode) override { }
</span><del>-    WebCore::Scrollbar* horizontalScrollbar() override { return nullptr; }
-    WebCore::Scrollbar* verticalScrollbar() override { return nullptr; }
</del><ins>+    WebCore::Scrollbar* horizontalScrollbar() override { return m_horizontalScrollbar.get(); }
+    WebCore::Scrollbar* verticalScrollbar() override { return m_verticalScrollbar.get(); }
</ins><span class="cx">     void storageBlockingStateChanged(bool) override { }
</span><span class="cx">     void privateBrowsingStateChanged(bool) override { }
</span><span class="cx">     bool getFormValue(String&amp; formValue) override { return false; }
</span><del>-    bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity) override { return false; }
</del><ins>+    bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity) override;
</ins><span class="cx">     RefPtr&lt;WebCore::SharedBuffer&gt; liveResourceData() const override;
</span><ins>+    void willDetatchRenderer() override;
</ins><span class="cx"> 
</span><del>-    bool handlesPageScaleFactor() const override { return false; }
-    bool requiresUnifiedScaleFactor() const override { return true; }
-
</del><span class="cx">     bool isBeingAsynchronouslyInitialized() const override { return false; }
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;PDFDocument&gt; pdfDocumentForPrinting() const override { return m_pdfDocument; }
</span><span class="lines">@@ -203,21 +187,56 @@
</span><span class="cx">     bool shouldAllowScripting() override { return false; }
</span><span class="cx">     bool shouldAllowNavigationFromDrags() override { return true; }
</span><span class="cx">     bool shouldAlwaysAutoStart() const override { return true; }
</span><del>-    bool canCreateTransientPaintingSnapshot() const override { return false; }
</del><span class="cx"> 
</span><ins>+    // ScrollableArea functions.
+    WebCore::IntRect scrollCornerRect() const override;
+    WebCore::ScrollableArea* enclosingScrollableArea() const override;
+    bool isScrollableOrRubberbandable() override { return true; }
+    bool hasScrollableOrRubberbandableAncestor() override { return true; }
+    WebCore::IntRect scrollableAreaBoundingBox(bool* = nullptr) const override;
+    void setScrollOffset(const WebCore::ScrollOffset&amp;) override;
+    void invalidateScrollbarRect(WebCore::Scrollbar&amp;, const WebCore::IntRect&amp;) override;
+    void invalidateScrollCornerRect(const WebCore::IntRect&amp;) override;
+    WebCore::IntPoint lastKnownMousePosition() const override { return m_lastMousePositionInPluginCoordinates; }
+    int scrollSize(WebCore::ScrollbarOrientation) const override;
+    bool isActive() const override;
+    bool isScrollCornerVisible() const override { return false; }
+    int scrollOffset(WebCore::ScrollbarOrientation) const override;
+    WebCore::ScrollPosition scrollPosition() const override;
+    WebCore::ScrollPosition minimumScrollPosition() const override;
+    WebCore::ScrollPosition maximumScrollPosition() const override;
+    WebCore::IntSize visibleSize() const override { return m_size; }
+    WebCore::IntSize contentsSize() const override { return m_pdfDocumentSize; }
+    WebCore::Scrollbar* horizontalScrollbar() const override { return m_horizontalScrollbar.get(); }
+    WebCore::Scrollbar* verticalScrollbar() const override { return m_verticalScrollbar.get(); }
+    bool shouldSuspendScrollAnimations() const override { return false; } // If we return true, ScrollAnimatorMac will keep cycling a timer forever, waiting for a good time to animate.
+    void scrollbarStyleChanged(WebCore::ScrollbarStyle, bool forceUpdate) override;
+    WebCore::IntRect convertFromScrollbarToContainingView(const WebCore::Scrollbar&amp;, const WebCore::IntRect&amp; scrollbarRect) const override;
+    WebCore::IntRect convertFromContainingViewToScrollbar(const WebCore::Scrollbar&amp;, const WebCore::IntRect&amp; parentRect) const override;
+    WebCore::IntPoint convertFromScrollbarToContainingView(const WebCore::Scrollbar&amp;, const WebCore::IntPoint&amp; scrollbarPoint) const override;
+    WebCore::IntPoint convertFromContainingViewToScrollbar(const WebCore::Scrollbar&amp;, const WebCore::IntPoint&amp; parentPoint) const override;
+    bool forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const override;
+
</ins><span class="cx">     // PDFPlugin functions.
</span><ins>+    void updateScrollbars();
+    Ref&lt;WebCore::Scrollbar&gt; createScrollbar(WebCore::ScrollbarOrientation);
+    void destroyScrollbar(WebCore::ScrollbarOrientation);
</ins><span class="cx">     void pdfDocumentDidLoad();
</span><span class="cx">     void addArchiveResource();
</span><span class="cx">     void computePageBoxes();
</span><span class="cx">     void calculateSizes();
</span><del>-    void didCalculateSizes();
</del><span class="cx">     void runScriptsInPDFDocument();
</span><span class="cx"> 
</span><span class="cx">     NSEvent *nsEventForWebMouseEvent(const WebMouseEvent&amp;);
</span><del>-
</del><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;
+    
</ins><span class="cx">     bool supportsForms();
</span><span class="cx">     bool isFullFramePlugin() const;
</span><span class="cx"> 
</span><ins>+    void updatePageAndDeviceScaleFactors();
+
</ins><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">@@ -229,18 +248,21 @@
</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>-    enum class UpdateCursor {
-        IfNeeded,
-        Force
</del><ins>+    WebFrame* webFrame() const { return m_frame; }
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 101300
+    enum UpdateCursorMode {
+        UpdateIfNeeded,
+        ForceUpdate
</ins><span class="cx">     };
</span><span class="cx"> 
</span><del>-    enum class HitTestResult {
</del><ins>+    enum HitTestResult {
</ins><span class="cx">         None,
</span><del>-        Text,
-        HUD
</del><ins>+        Text
</ins><span class="cx">     };
</span><span class="cx"> 
</span><del>-    void updateCursor(const WebMouseEvent&amp;, UpdateCursor = UpdateCursor::IfNeeded);
</del><ins>+    void updateCursor(const WebMouseEvent&amp;, UpdateCursorMode = UpdateIfNeeded);
+#endif
</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="lines">@@ -247,48 +269,30 @@
</span><span class="cx"> 
</span><span class="cx">     void convertPostScriptDataIfNeeded();
</span><span class="cx"> 
</span><ins>+    // Regular plug-ins don't need access to view, but we add scrollbars to embedding FrameView for proper event handling.
</ins><span class="cx">     PluginView* pluginView();
</span><span class="cx">     const PluginView* pluginView() const;
</span><span class="cx"> 
</span><del>-    class HUD : public WebCore::PageOverlay::Client {
-    public:
-        explicit HUD(PDFPlugin&amp; plugin);
-        virtual ~HUD();
</del><ins>+    WebFrame* m_frame;
</ins><span class="cx"> 
</span><del>-        void invalidate();
-        bool containsPointInRootView(WebCore::IntPoint);
</del><ins>+    bool m_isPostScript;
+    bool m_pdfDocumentWasMutated;
</ins><span class="cx"> 
</span><del>-        enum class AnimateVisibilityTransition { No, Yes };
-        void setVisible(bool, AnimateVisibilityTransition);
</del><ins>+    WebCore::IntSize m_scrollOffset;
</ins><span class="cx"> 
</span><del>-    private:
-        void willMoveToPage(WebCore::PageOverlay&amp;, WebCore::Page*) override;
-        void didMoveToPage(WebCore::PageOverlay&amp;, WebCore::Page*) override;
-        void drawRect(WebCore::PageOverlay&amp;, WebCore::GraphicsContext&amp;, const WebCore::IntRect&amp; dirtyRect) override;
-        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;
-    };
-
-    WebFrame* m_frame;
-
-    bool m_isPostScript { false };
-    bool m_pdfDocumentWasMutated { false };
-    bool m_usingContinuousMode { true };
-
</del><ins>+    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;
</ins><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_passwordContainer;
</del><ins>+    RefPtr&lt;WebCore::Element&gt; m_annotationContainer;
</ins><span class="cx"> 
</span><span class="cx">     WebCore::AffineTransform m_rootViewToPluginTransform;
</span><del>-    WebCore::AffineTransform m_pluginToRootViewTransform;
</del><span class="cx">     WebMouseEvent m_lastMouseEvent;
</span><span class="cx">     WebCore::IntPoint m_lastMousePositionInPluginCoordinates;
</span><span class="cx"> 
</span><span class="lines">@@ -296,8 +300,10 @@
</span><span class="cx"> 
</span><span class="cx">     String m_lastFoundString;
</span><span class="cx"> 
</span><ins>+#if __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 101300
</ins><span class="cx">     HitTestResult m_lastHitTestResult;
</span><del>-    
</del><ins>+#endif
+
</ins><span class="cx">     RetainPtr&lt;WKPDFLayerControllerDelegate&gt; m_pdfLayerControllerDelegate;
</span><span class="cx"> 
</span><span class="cx">     WebCore::IntSize m_size;
</span><span class="lines">@@ -308,9 +314,11 @@
</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><ins>+    Vector&lt;WebCore::IntRect&gt; m_pageBoxes;
</ins><span class="cx">     WebCore::IntSize m_pdfDocumentSize; // All pages, including gaps.
</span><span class="cx"> 
</span><del>-    HUD m_HUD;
</del><ins>+    RefPtr&lt;WebCore::Scrollbar&gt; m_horizontalScrollbar;
+    RefPtr&lt;WebCore::Scrollbar&gt; m_verticalScrollbar;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span><span class="lines">@@ -317,7 +325,6 @@
</span><span class="cx"> 
</span><span class="cx"> SPECIALIZE_TYPE_TRAITS_PLUGIN(PDFPlugin, PDFPluginType)
</span><span class="cx"> 
</span><del>-#endif // USE(DEPRECATED_PDF_PLUGIN)
</del><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 (214000 => 214001)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm        2017-03-15 19:34:00 UTC (rev 214000)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm        2017-03-15 19:34:22 UTC (rev 214001)
</span><span class="lines">@@ -26,7 +26,7 @@
</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) &amp;&amp; !USE(DEPRECATED_PDF_PLUGIN)
</del><ins>+#if ENABLE(PDFKIT_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="lines">@@ -55,6 +55,7 @@
</span><span class="cx"> #import &lt;WebCore/Cursor.h&gt;
</span><span class="cx"> #import &lt;WebCore/DictionaryLookup.h&gt;
</span><span class="cx"> #import &lt;WebCore/DocumentLoader.h&gt;
</span><ins>+#import &lt;WebCore/EventNames.h&gt;
</ins><span class="cx"> #import &lt;WebCore/FocusController.h&gt;
</span><span class="cx"> #import &lt;WebCore/FormState.h&gt;
</span><span class="cx"> #import &lt;WebCore/Frame.h&gt;
</span><span class="lines">@@ -61,7 +62,6 @@
</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><del>-#import &lt;WebCore/GraphicsLayerCA.h&gt;
</del><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,32 +69,35 @@
</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><del>-#import &lt;WebCore/PageOverlayController.h&gt;
</del><span class="cx"> #import &lt;WebCore/Pasteboard.h&gt;
</span><del>-#import &lt;WebCore/PlatformCAAnimationCocoa.h&gt;
</del><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><ins>+#import &lt;WebCore/ScrollAnimator.h&gt;
+#import &lt;WebCore/ScrollbarTheme.h&gt;
</ins><span class="cx"> #import &lt;WebCore/Settings.h&gt;
</span><span class="cx"> #import &lt;WebCore/UUID.h&gt;
</span><ins>+#import &lt;WebCore/WheelEventTestTrigger.h&gt;
</ins><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><ins>+// 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.
</ins><span class="cx"> static const char* annotationStyle =
</span><del>-&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;
</del><ins>+&quot;#annotationContainer {&quot;
+&quot;    overflow: hidden; &quot;
+&quot;    position: absolute; &quot;
+&quot;    pointer-events: none; &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><ins>+&quot;    display: -webkit-box; &quot;
+&quot;    -webkit-box-align: center; &quot;
+&quot;    -webkit-box-pack: center; &quot;
</ins><span class="cx"> &quot;} &quot;
</span><span class="cx"> &quot;.annotation { &quot;
</span><span class="cx"> &quot;    position: absolute; &quot;
</span><span class="lines">@@ -109,7 +112,9 @@
</span><span class="cx"> &quot;    margin-top: 100px; &quot;
</span><span class="cx"> &quot;} &quot;;
</span><span class="cx"> 
</span><del>-const double zoomButtonScaleMultiplier = 1.18920;
</del><ins>+// 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;
</ins><span class="cx"> 
</span><span class="cx"> @interface WKPDFPluginAccessibilityObject : NSObject {
</span><span class="cx">     PDFLayerController *_pdfLayerController;
</span><span class="lines">@@ -271,6 +276,41 @@
</span><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+
+@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
+
</ins><span class="cx"> @interface WKPDFLayerControllerDelegate : NSObject&lt;PDFLayerControllerDelegate&gt; {
</span><span class="cx">     WebKit::PDFPlugin* _pdfPlugin;
</span><span class="cx"> }
</span><span class="lines">@@ -293,12 +333,12 @@
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController scrollToPoint:(CGPoint)newPosition
</del><ins>+- (void)updateScrollPosition:(CGPoint)newPosition
</ins><span class="cx"> {
</span><del>-    _pdfPlugin-&gt;scrollToPoint(IntPoint(newPosition));
</del><ins>+    _pdfPlugin-&gt;notifyScrollPositionChanged(IntPoint(newPosition));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController copyItems:(NSArray *)items withTypes:(NSArray *)types
</del><ins>+- (void)writeItemsToPasteboard:(NSArray *)items withTypes:(NSArray *)types
</ins><span class="cx"> {
</span><span class="cx"> #pragma clang diagnostic push
</span><span class="cx"> #pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
</span><span class="lines">@@ -306,32 +346,32 @@
</span><span class="cx"> #pragma clang diagnostic pop
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController showDefinitionForAttributedString:(NSAttributedString *)string atPoint:(CGPoint)point
</del><ins>+- (void)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)pdfLayerController:(PDFLayerController *)pdfLayerController performWebSearchForString:(NSString *)string
</del><ins>+- (void)performWebSearch:(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)pdfLayerController:(PDFLayerController *)pdfLayerController performSpotlightSearchForString:(NSString *)string
</del><ins>+- (void)performSpotlightSearch:(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)pdfLayerControllerOpenWithNativeApplication:(PDFLayerController *)pdfLayerController
</del><ins>+- (void)openWithNativeApplication
</ins><span class="cx"> {
</span><span class="cx">     _pdfPlugin-&gt;openWithNativeApplication();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)pdfLayerControllerSaveToPDF:(PDFLayerController *)pdfLayerController
</del><ins>+- (void)saveToPDF
</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 didClickLinkWithURL:(NSURL *)url
</del><ins>+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController clickedLinkWithURL:(NSURL *)url
</ins><span class="cx"> {
</span><span class="cx">     _pdfPlugin-&gt;clickedLink(url);
</span><span class="cx"> }
</span><span class="lines">@@ -341,6 +381,11 @@
</span><span class="cx">     _pdfPlugin-&gt;setActiveAnnotation(annotation);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeContentScaleFactor:(CGFloat)scaleFactor
+{
+    _pdfPlugin-&gt;notifyContentScaleFactorChanged(scaleFactor);
+}
+
</ins><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">@@ -351,52 +396,13 @@
</span><span class="cx">     _pdfPlugin-&gt;notifySelectionChanged(selection);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController invalidateRect:(CGRect)rect
</del><ins>+- (void)setMouseCursor:(PDFLayerControllerCursorType)cursorType
</ins><span class="cx"> {
</span><del>-    _pdfPlugin-&gt;invalidatePDFRect(enclosingIntRect(rect));
</del><ins>+    _pdfPlugin-&gt;notifyCursorChanged(cursorType);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)pdfLayerControllerInvalidateHUD:(PDFLayerController *)pdfLayerController
-{
-    _pdfPlugin-&gt;invalidateHUD();
-}
-
-- (void)pdfLayerControllerZoomIn:(PDFLayerController *)pdfLayerController
-{
-    _pdfPlugin-&gt;zoomIn();
-}
-
-- (void)pdfLayerControllerZoomOut:(PDFLayerController *)pdfLayerController
-{
-    _pdfPlugin-&gt;zoomOut();
-}
-
</del><span class="cx"> @end
</span><span class="cx"> 
</span><del>-@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 = WTFMove(completionHandler);
-
-    return self;
-}
-
-- (void)animationDidStop:(CAAnimation *)animation finished:(BOOL)flag
-{
-    _completionHandler(flag);
-}
-
-@end
-
</del><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">@@ -511,24 +517,35 @@
</span><span class="cx"> PDFPlugin::PDFPlugin(WebFrame* frame)
</span><span class="cx">     : Plugin(PDFPluginType)
</span><span class="cx">     , m_frame(frame)
</span><ins>+    , 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]))
</ins><span class="cx">     , m_pdfLayerController(adoptNS([[pdfLayerControllerClass() alloc] init]))
</span><span class="cx">     , m_pdfLayerControllerDelegate(adoptNS([[WKPDFLayerControllerDelegate alloc] initWithPDFPlugin:this]))
</span><del>-    , m_HUD(*this)
</del><span class="cx"> {
</span><del>-    [m_pdfLayerController setDelegate:m_pdfLayerControllerDelegate.get()];
</del><ins>+    m_pdfLayerController.get().delegate = m_pdfLayerControllerDelegate.get();
+    m_pdfLayerController.get().parentLayer = m_contentLayer.get();
</ins><span class="cx"> 
</span><span class="cx">     if (supportsForms()) {
</span><span class="cx">         Document* document = webFrame()-&gt;coreFrame()-&gt;document();
</span><ins>+        m_annotationContainer = document-&gt;createElement(divTag, false);
+        m_annotationContainer-&gt;setAttributeWithoutSynchronization(idAttr, AtomicString(&quot;annotationContainer&quot;, AtomicString::ConstructFromLiteral));
</ins><span class="cx"> 
</span><del>-        Ref&lt;Element&gt; annotationStyleElement = document-&gt;createElement(styleTag, false);
-        annotationStyleElement-&gt;setTextContent(annotationStyle, ASSERT_NO_EXCEPTION);
</del><ins>+        auto annotationStyleElement = document-&gt;createElement(styleTag, false);
+        annotationStyleElement-&gt;setTextContent(annotationStyle);
</ins><span class="cx"> 
</span><del>-        document-&gt;bodyOrFrameset()-&gt;appendChild(annotationStyleElement.get());
</del><ins>+        m_annotationContainer-&gt;appendChild(annotationStyleElement);
+        document-&gt;bodyOrFrameset()-&gt;appendChild(*m_annotationContainer);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_accessibilityObject = adoptNS([[WKPDFPluginAccessibilityObject alloc] initWithPDFPlugin:this]);
</span><span class="cx">     [m_accessibilityObject setPdfLayerController:m_pdfLayerController.get()];
</span><span class="cx">     [m_accessibilityObject setParent:webFrame()-&gt;page()-&gt;accessibilityRemoteObject()];
</span><ins>+
+    [m_containerLayer addSublayer:m_contentLayer.get()];
+    [m_containerLayer addSublayer:m_scrollCornerLayer.get()];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PDFPlugin::~PDFPlugin()
</span><span class="lines">@@ -563,6 +580,73 @@
</span><span class="cx">     return info;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+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);
+
+    IntSize scrollbarSpace = scrollbarIntrusion();
+
+    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() - scrollbarSpace.width(), 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() - scrollbarSpace.height(), 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];
+    }
+}
+
</ins><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">@@ -573,6 +657,176 @@
</span><span class="cx">     return static_cast&lt;const PluginView*&gt;(controller());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Ref&lt;Scrollbar&gt; PDFPlugin::createScrollbar(ScrollbarOrientation orientation)
+{
+    auto 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.ptr(), 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);
+    return widget;
+}
+
+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&amp; scrollbar, const IntRect&amp; scrollbarRect) const
+{
+    IntRect rect = scrollbarRect;
+    rect.move(scrollbar.location() - pluginView()-&gt;location());
+
+    return pluginView()-&gt;frame()-&gt;view()-&gt;convertFromRendererToContainingView(pluginView()-&gt;pluginElement()-&gt;renderer(), rect);
+}
+
+IntRect PDFPlugin::convertFromContainingViewToScrollbar(const Scrollbar&amp; 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.location());
+
+    return rect;
+}
+
+IntPoint PDFPlugin::convertFromScrollbarToContainingView(const Scrollbar&amp; scrollbar, const IntPoint&amp; scrollbarPoint) const
+{
+    IntPoint point = scrollbarPoint;
+    point.move(scrollbar.location() - pluginView()-&gt;location());
+
+    return pluginView()-&gt;frame()-&gt;view()-&gt;convertFromRendererToContainingView(pluginView()-&gt;pluginElement()-&gt;renderer(), point);
+}
+
+IntPoint PDFPlugin::convertFromContainingViewToScrollbar(const Scrollbar&amp; 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.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(bool*) 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::scrollOffset(ScrollbarOrientation orientation) const
+{
+    if (orientation == HorizontalScrollbar)
+        return m_scrollOffset.width();
+
+    if (orientation == VerticalScrollbar)
+        return m_scrollOffset.height();
+
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
+ScrollPosition PDFPlugin::scrollPosition() const
+{
+    return IntPoint(m_scrollOffset.width(), m_scrollOffset.height());
+}
+
+ScrollPosition PDFPlugin::minimumScrollPosition() const
+{
+    return IntPoint();
+}
+
+ScrollPosition PDFPlugin::maximumScrollPosition() const
+{
+    IntSize scrollbarSpace = scrollbarIntrusion();
+
+    IntPoint maximumOffset(m_pdfDocumentSize.width() - m_size.width() + scrollbarSpace.width(), m_pdfDocumentSize.height() - m_size.height() + scrollbarSpace.height());
+    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();
+}
+
</ins><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">@@ -583,7 +837,7 @@
</span><span class="cx">     ResourceResponse synthesizedResponse(response.get());
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;ArchiveResource&gt; resource = ArchiveResource::create(SharedBuffer::wrapCFData(m_data.get()), m_sourceURL, &quot;application/pdf&quot;, String(), String(), synthesizedResponse);
</span><del>-    pluginView()-&gt;frame()-&gt;document()-&gt;loader()-&gt;addArchiveResource(resource.release());
</del><ins>+    pluginView()-&gt;frame()-&gt;document()-&gt;loader()-&gt;addArchiveResource(resource.releaseNonNull());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void jsPDFDocInitialize(JSContextRef ctx, JSObjectRef object)
</span><span class="lines">@@ -614,7 +868,7 @@
</span><span class="cx">     if (!page)
</span><span class="cx">         return JSValueMakeUndefined(ctx);
</span><span class="cx"> 
</span><del>-    page-&gt;chrome().print(coreFrame);
</del><ins>+    page-&gt;chrome().print(*coreFrame);
</ins><span class="cx"> 
</span><span class="cx">     return JSValueMakeUndefined(ctx);
</span><span class="cx"> }
</span><span class="lines">@@ -674,24 +928,25 @@
</span><span class="cx"> 
</span><span class="cx">     setPDFDocument(document);
</span><span class="cx"> 
</span><del>-    [m_pdfLayerController setFrameSize:webFrame()-&gt;coreFrame()-&gt;view()-&gt;visibleContentRect().size()]; /// ???
-    [m_pdfLayerController setDocument:document.get()];
</del><ins>+    updatePageAndDeviceScaleFactors();
</ins><span class="cx"> 
</span><ins>+    [m_pdfLayerController setFrameSize:size()];
+    m_pdfLayerController.get().document = document.get();
+
+    if (handlesPageScaleFactor())
+        pluginView()-&gt;setPageScaleFactor([m_pdfLayerController contentScaleFactor], IntPoint());
+
+    notifyScrollPositionChanged(IntPoint([m_pdfLayerController scrollPosition]));
+
</ins><span class="cx">     calculateSizes();
</span><ins>+    updateScrollbars();
</ins><span class="cx"> 
</span><span class="cx">     runScriptsInPDFDocument();
</span><span class="cx"> 
</span><del>-    if (isLocked())
</del><ins>+    if ([document isLocked])
</ins><span class="cx">         createPasswordEntryForm();
</span><del>-
-    m_HUD.setVisible(!isLocked(), HUD::AnimateVisibilityTransition::No);
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool PDFPlugin::isLocked() const
-{
-    return [m_pdfDocument isLocked];
-}
-
</del><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">@@ -775,34 +1030,10 @@
</span><span class="cx">     JSGlobalContextRelease(ctx);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-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();
-}
-
</del><span class="cx"> void PDFPlugin::createPasswordEntryForm()
</span><span class="cx"> {
</span><del>-    if (!supportsForms())
-        return;
-
-    Document* document = webFrame()-&gt;coreFrame()-&gt;document();
-    m_passwordContainer = document-&gt;createElement(divTag, false);
-    m_passwordContainer-&gt;setAttributeWithoutSynchronization(idAttr, AtomicString(&quot;passwordContainer&quot;, AtomicString::ConstructFromLiteral));
-
</del><span class="cx">     m_passwordField = PDFPluginPasswordField::create(m_pdfLayerController.get(), this);
</span><del>-    m_passwordField-&gt;attach(m_passwordContainer.get());
-    document-&gt;bodyOrFrameset()-&gt;appendChild(*m_passwordContainer);
</del><ins>+    m_passwordField-&gt;attach(m_annotationContainer.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PDFPlugin::attemptToUnlockPDF(const String&amp; password)
</span><span class="lines">@@ -809,41 +1040,54 @@
</span><span class="cx"> {
</span><span class="cx">     [m_pdfLayerController attemptToUnlockWithPassword:password];
</span><span class="cx"> 
</span><del>-    if (!isLocked()) {
-        m_passwordContainer = nullptr;
</del><ins>+    if (![pdfDocument() isLocked]) {
</ins><span class="cx">         m_passwordField = nullptr;
</span><span class="cx"> 
</span><span class="cx">         calculateSizes();
</span><del>-
-        m_HUD.setVisible(true, HUD::AnimateVisibilityTransition::Yes);
</del><ins>+        updateScrollbars();
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PDFPlugin::calculateSizes()
</del><ins>+void PDFPlugin::updatePageAndDeviceScaleFactors()
</ins><span class="cx"> {
</span><del>-    setPDFDocumentSize(isLocked() ? IntSize() : IntSize([m_pdfLayerController contentSizeRespectingZoom]));
</del><ins>+    double newScaleFactor = controller()-&gt;contentsScaleFactor();
+    if (!handlesPageScaleFactor())
+        newScaleFactor *= webFrame()-&gt;page()-&gt;pageScaleFactor();
</ins><span class="cx"> 
</span><del>-    // 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();
-    });
</del><ins>+    if (newScaleFactor != [m_pdfLayerController deviceScaleFactor])
+        [m_pdfLayerController setDeviceScaleFactor:newScaleFactor];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PDFPlugin::didCalculateSizes()
</del><ins>+void PDFPlugin::contentsScaleFactorChanged(float)
</ins><span class="cx"> {
</span><del>-    HTMLPlugInElement* pluginElement = downcast&lt;PluginDocument&gt;(*webFrame()-&gt;coreFrame()-&gt;document()).pluginElement();
</del><ins>+    updatePageAndDeviceScaleFactors();
+}
</ins><span class="cx"> 
</span><del>-    if (isLocked()) {
-        pluginElement-&gt;setInlineStyleProperty(CSSPropertyWidth, 100, CSSPrimitiveValue::CSS_PERCENTAGE);
-        pluginElement-&gt;setInlineStyleProperty(CSSPropertyHeight, 100, CSSPrimitiveValue::CSS_PERCENTAGE);
</del><ins>+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));
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    pluginElement-&gt;setInlineStyleProperty(CSSPropertyWidth, m_pdfDocumentSize.width(), CSSPrimitiveValue::CSS_PX);
-    pluginElement-&gt;setInlineStyleProperty(CSSPropertyHeight, m_pdfDocumentSize.height(), CSSPrimitiveValue::CSS_PX);
</del><ins>+    // FIXME: This should come straight from PDFKit.
+    computePageBoxes();
</ins><span class="cx"> 
</span><del>-    // FIXME: Adopt the new scroll snap specification.
</del><ins>+    setPDFDocumentSize(IntSize([m_pdfLayerController contentSizeRespectingZoom]));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool PDFPlugin::initialize(const Parameters&amp; parameters)
</span><span class="lines">@@ -856,28 +1100,100 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PDFPlugin::willDetatchRenderer()
+{
+    if (webFrame()) {
+        if (FrameView* frameView = webFrame()-&gt;coreFrame()-&gt;view())
+            frameView-&gt;removeScrollableArea(this);
+    }
+}
+
</ins><span class="cx"> void PDFPlugin::destroy()
</span><span class="cx"> {
</span><del>-    [m_pdfLayerController setDelegate:nil];
</del><ins>+    m_pdfLayerController.get().delegate = 0;
</ins><span class="cx"> 
</span><ins>+    if (webFrame()) {
+        if (FrameView* frameView = webFrame()-&gt;coreFrame()-&gt;view())
+            frameView-&gt;removeScrollableArea(this);
+    }
+
</ins><span class="cx">     m_activeAnnotation = nullptr;
</span><ins>+    m_annotationContainer = nullptr;
+
+    destroyScrollbar(HorizontalScrollbar);
+    destroyScrollbar(VerticalScrollbar);
+    
+    [m_scrollCornerLayer removeFromSuperlayer];
+    [m_contentLayer removeFromSuperlayer];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PDFPlugin::paint(GraphicsContext&amp; context, const IntRect&amp; dirtyRectInWindowCoordinates)
</del><ins>+void PDFPlugin::updateControlTints(GraphicsContext&amp; graphicsContext)
</ins><span class="cx"> {
</span><del>-    context.scale(FloatSize(1, -1));
-    context.translate(0, -m_pdfDocumentSize.height());
-    [m_pdfLayerController drawInContext:context.platformContext()];
</del><ins>+    ASSERT(graphicsContext.updatingControlTints());
+
+    if (m_horizontalScrollbar)
+        m_horizontalScrollbar-&gt;invalidate();
+    if (m_verticalScrollbar)
+        m_verticalScrollbar-&gt;invalidate();
+    invalidateScrollCorner(scrollCornerRect());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+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());
+}
+
</ins><span class="cx"> RefPtr&lt;ShareableBitmap&gt; PDFPlugin::snapshot()
</span><span class="cx"> {
</span><del>-    return nullptr;
</del><ins>+    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;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+PlatformLayer* PDFPlugin::pluginLayer()
+{
+    return m_containerLayer.get();
+}
+
</ins><span class="cx"> IntPoint PDFPlugin::convertFromPluginToPDFView(const IntPoint&amp; point) const
</span><span class="cx"> {
</span><del>-    return IntPoint(point.x(), m_size.height() - point.y());
</del><ins>+    return IntPoint(point.x(), 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">@@ -887,8 +1203,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(), m_size.height() - point.y());
-    return m_pluginToRootViewTransform.mapPoint(pointInPluginCoordinates);
</del><ins>+    IntPoint pointInPluginCoordinates(point.x(), size().height() - point.y());
+    return m_rootViewToPluginTransform.inverse().value_or(AffineTransform()).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">@@ -898,8 +1214,8 @@
</span><span class="cx">     if (!frameView)
</span><span class="cx">         return FloatRect();
</span><span class="cx"> 
</span><del>-    FloatPoint originInPluginCoordinates(rect.x(), m_size.height() - rect.y() - rect.height());
-    FloatRect rectInRootViewCoordinates = m_pluginToRootViewTransform.mapRect(FloatRect(originInPluginCoordinates, rect.size()));
</del><ins>+    FloatPoint originInPluginCoordinates(rect.x(), size().height() - rect.y() - rect.height());
+    FloatRect rectInRootViewCoordinates = m_rootViewToPluginTransform.inverse().value_or(AffineTransform()).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">@@ -912,25 +1228,44 @@
</span><span class="cx">         return IntRect();
</span><span class="cx"> 
</span><span class="cx">     FloatRect bounds = FloatRect(FloatPoint(), size());
</span><del>-    FloatRect rectInRootViewCoordinates = m_pluginToRootViewTransform.mapRect(bounds);
</del><ins>+    FloatRect rectInRootViewCoordinates = m_rootViewToPluginTransform.inverse().value_or(AffineTransform()).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>-    m_pluginToRootViewTransform = pluginToRootViewTransform;
</del><ins>+    if (size() == pluginSize &amp;&amp; pluginView()-&gt;pageScaleFactor() == [m_pdfLayerController contentScaleFactor])
+        return;
+
+    m_size = pluginSize;
</ins><span class="cx">     m_rootViewToPluginTransform = pluginToRootViewTransform.inverse().value_or(AffineTransform());
</span><del>-    m_size = pluginSize;
</del><ins>+    [m_pdfLayerController setFrameSize:pluginSize];
</ins><span class="cx"> 
</span><del>-    FrameView* frameView = webFrame()-&gt;coreFrame()-&gt;view();
</del><ins>+    [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];
</ins><span class="cx"> 
</span><del>-    [m_pdfLayerController setFrameSize:frameView-&gt;frameRect().size()];
-    [m_pdfLayerController setVisibleRect:frameView-&gt;visibleContentRect()];
</del><ins>+        // 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();
+    } 
</ins><span class="cx"> 
</span><span class="cx">     calculateSizes();
</span><ins>+    updateScrollbars();
</ins><span class="cx"> 
</span><span class="cx">     if (m_activeAnnotation)
</span><span class="cx">         m_activeAnnotation-&gt;updateGeometry();
</span><ins>+
+    [m_contentLayer setSublayerTransform:transform];
+    [CATransaction commit];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PDFPlugin::frameDidFinishLoading(uint64_t)
</span><span class="lines">@@ -948,6 +1283,7 @@
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+    
</ins><span class="cx"> static NSUInteger modifierFlagsFromWebEvent(const WebEvent&amp; event)
</span><span class="cx"> {
</span><span class="cx">     return (event.shiftKey() ? NSEventModifierFlagShift : 0)
</span><span class="lines">@@ -959,6 +1295,12 @@
</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><ins>+    case WebEvent::KeyDown:
+        eventType = NSEventTypeKeyDown;
+        return true;
+    case WebEvent::KeyUp:
+        eventType = NSEventTypeKeyUp;
+        return true;
</ins><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">@@ -1003,12 +1345,13 @@
</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><ins>+
</ins><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 nullptr;
</del><ins>+        return 0;
</ins><span class="cx"> 
</span><span class="cx">     NSUInteger modifierFlags = modifierFlagsFromWebEvent(event);
</span><span class="cx"> 
</span><span class="lines">@@ -1015,68 +1358,121 @@
</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, UpdateCursor mode)
</del><ins>+#if __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 101300
+void PDFPlugin::updateCursor(const WebMouseEvent&amp; event, UpdateCursorMode mode)
</ins><span class="cx"> {
</span><del>-    // FIXME: Should have a hand for links, and something special for annotations.
</del><ins>+    HitTestResult hitTestResult = None;
</ins><span class="cx"> 
</span><del>-    HitTestResult hitTestResult = HitTestResult::None;
</del><ins>+    PDFSelection *selectionUnderMouse = [m_pdfLayerController getSelectionForWordAtPoint:convertFromPluginToPDFView(event.position())];
+    if (selectionUnderMouse &amp;&amp; [[selectionUnderMouse string] length])
+        hitTestResult = Text;
</ins><span class="cx"> 
</span><del>-    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)
</del><ins>+    if (hitTestResult == m_lastHitTestResult &amp;&amp; mode == UpdateIfNeeded)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    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));
</del><ins>+    webFrame()-&gt;page()-&gt;send(Messages::WebPageProxy::SetCursor(hitTestResult == Text ? iBeamCursor() : pointerCursor()));
</ins><span class="cx">     m_lastHitTestResult = hitTestResult;
</span><span class="cx"> }
</span><ins>+#endif
</ins><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><ins>+    IntPoint mousePosition = convertFromRootViewToPlugin(event.position());
</ins><span class="cx"> 
</span><span class="cx">     m_lastMouseEvent = event;
</span><span class="cx"> 
</span><del>-    if (isLocked())
</del><ins>+    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))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    if ([pdfDocument() isLocked])
+        return false;
+
</ins><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><del>-    if (event.button() != WebMouseEvent::LeftButton)
-        return false;
-
</del><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><ins>+        mouseMovedInContentArea();
+#if __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 101300
</ins><span class="cx">         updateCursor(event);
</span><del>-        [m_pdfLayerController mouseDragged:nsEvent];
-        return true;
</del><ins>+#endif
+
+        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;
</ins><span class="cx">     case WebEvent::MouseDown:
</span><del>-        [m_pdfLayerController mouseDown:nsEvent];
-        return true;
</del><ins>+        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;
</ins><span class="cx">     case WebEvent::MouseUp:
</span><del>-        [m_pdfLayerController mouseUp:nsEvent];
-        return true;
</del><ins>+        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;
</ins><span class="cx">     default:
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="lines">@@ -1086,12 +1482,16 @@
</span><span class="cx"> 
</span><span class="cx"> bool PDFPlugin::handleMouseEnterEvent(const WebMouseEvent&amp; event)
</span><span class="cx"> {
</span><del>-    updateCursor(event, UpdateCursor::Force);
</del><ins>+    mouseEnteredContentArea();
+#if __MAC_OS_X_VERSION_MIN_REQUIRED &lt; 101300
+    updateCursor(event, ForceUpdate);
+#endif
</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><ins>+    mouseExitedContentArea();
</ins><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx">     
</span><span class="lines">@@ -1099,7 +1499,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(), ForceAtClick);
</del><ins>+    WebMouseEvent event(WebEvent::MouseDown, WebMouseEvent::RightButton, contentsPoint, contentsPoint, 0, 0, 0, 1, static_cast&lt;WebEvent::Modifiers&gt;(0), monotonicallyIncreasingTime(), WebCore::ForceAtClick);
</ins><span class="cx">     return handleContextMenuEvent(event);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1115,7 +1515,28 @@
</span><span class="cx">     
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><ins>+
+bool PDFPlugin::handleKeyboardEvent(const WebKeyboardEvent&amp; event)
+{
+    NSEventType eventType;
+
+    if (!getEventTypeFromWebEvent(event, eventType))
+        return false;
+
+    NSUInteger modifierFlags = modifierFlagsFromWebEvent(event);
</ins><span class="cx">     
</span><ins>+    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;
+}
+    
</ins><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">@@ -1145,6 +1566,32 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PDFPlugin::setScrollOffset(const ScrollOffset&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&amp; scrollbar, const IntRect&amp; rect)
+{
+    if (&amp;scrollbar == horizontalScrollbar())
+        [m_horizontalScrollbarLayer setNeedsDisplay];
+    else if (&amp;scrollbar == verticalScrollbar())
+        [m_verticalScrollbarLayer setNeedsDisplay];
+}
+
+void PDFPlugin::invalidateScrollCornerRect(const IntRect&amp; rect)
+{
+    [m_scrollCornerLayer setNeedsDisplay];
+}
+
</ins><span class="cx"> bool PDFPlugin::isFullFramePlugin() const
</span><span class="cx"> {
</span><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="lines">@@ -1153,6 +1600,11 @@
</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><ins>+bool PDFPlugin::handlesPageScaleFactor() const
+{
+    return webFrame()-&gt;isMainFrame() &amp;&amp; isFullFramePlugin();
+}
+
</ins><span class="cx"> void PDFPlugin::clickedLink(NSURL *url)
</span><span class="cx"> {
</span><span class="cx">     URL coreURL = url;
</span><span class="lines">@@ -1177,14 +1629,16 @@
</span><span class="cx">         m_activeAnnotation-&gt;commit();
</span><span class="cx"> 
</span><span class="cx">     if (annotation) {
</span><ins>+#pragma clang diagnostic push
+#pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
</ins><span class="cx">         if ([annotation isKindOfClass:pdfAnnotationTextWidgetClass()] &amp;&amp; static_cast&lt;PDFAnnotationTextWidget *&gt;(annotation).isReadOnly) {
</span><span class="cx">             m_activeAnnotation = nullptr;
</span><span class="cx">             return;
</span><span class="cx">         }
</span><ins>+#pragma clang diagnostic pop
</ins><span class="cx"> 
</span><span class="cx">         m_activeAnnotation = PDFPluginAnnotation::create(annotation, m_pdfLayerController.get(), this);
</span><del>-        Document* document = webFrame()-&gt;coreFrame()-&gt;document();
-        m_activeAnnotation-&gt;attach(document-&gt;bodyOrFrameset());
</del><ins>+        m_activeAnnotation-&gt;attach(m_annotationContainer.get());
</ins><span class="cx">     } else
</span><span class="cx">         m_activeAnnotation = nullptr;
</span><span class="cx"> }
</span><span class="lines">@@ -1195,12 +1649,21 @@
</span><span class="cx">     return isFullFramePlugin();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PDFPlugin::notifyDisplayModeChanged(int mode)
</del><ins>+void PDFPlugin::notifyContentScaleFactorChanged(CGFloat scaleFactor)
</ins><span class="cx"> {
</span><del>-    m_usingContinuousMode = (mode == kPDFDisplaySinglePageContinuous || mode == kPDFDisplayTwoUpContinuous);
</del><ins>+    if (handlesPageScaleFactor())
+        pluginView()-&gt;setPageScaleFactor(scaleFactor, IntPoint());
+
</ins><span class="cx">     calculateSizes();
</span><ins>+    updateScrollbars();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PDFPlugin::notifyDisplayModeChanged(int)
+{
+    calculateSizes();
+    updateScrollbars();
+}
+
</ins><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">@@ -1232,7 +1695,7 @@
</span><span class="cx"> 
</span><span class="cx">         NSData *data = liveData();
</span><span class="cx"> 
</span><del>-        m_temporaryPDFUUID = createCanonicalUUIDString();
</del><ins>+        m_temporaryPDFUUID = WebCore::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">@@ -1315,7 +1778,7 @@
</span><span class="cx"> 
</span><span class="cx">     PDFDocument *document = pdfDocument().get();
</span><span class="cx"> 
</span><del>-    PDFSelection *selectionForInitialSearch = [initialSelection copy];
</del><ins>+    RetainPtr&lt;PDFSelection&gt; selectionForInitialSearch = adoptNS([initialSelection copy]);
</ins><span class="cx">     if (startInSelection) {
</span><span class="cx">         // Initially we want to include the selected text in the search. So we must modify the starting search
</span><span class="cx">         // selection to fit PDFDocument's search requirements: selection must have a length &gt;= 1, begin before
</span><span class="lines">@@ -1330,15 +1793,16 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    PDFSelection *foundSelection = [document findString:target fromSelection:selectionForInitialSearch withOptions:options];
-    [selectionForInitialSearch release];
</del><ins>+    PDFSelection *foundSelection = [document findString:target fromSelection:selectionForInitialSearch.get() withOptions:options];
</ins><span class="cx"> 
</span><span class="cx">     // If we first searched in the selection, and we found the selection, search again from just past the selection.
</span><span class="cx">     if (startInSelection &amp;&amp; [foundSelection isEqual:initialSelection])
</span><span class="cx">         foundSelection = [document findString:target fromSelection:initialSelection withOptions:options];
</span><span class="cx"> 
</span><del>-    if (!foundSelection &amp;&amp; wrapSearch)
-        foundSelection = [document findString:target fromSelection:nil withOptions:options];
</del><ins>+    if (!foundSelection &amp;&amp; wrapSearch) {
+        auto emptySelection = adoptNS([[pdfSelectionClass() alloc] initWithDocument:document]);
+        foundSelection = [document findString:target fromSelection:emptySelection.get() withOptions:options];
+    }
</ins><span class="cx"> 
</span><span class="cx">     return foundSelection;
</span><span class="cx"> }
</span><span class="lines">@@ -1382,7 +1846,7 @@
</span><span class="cx">     return matchCount &gt; 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool PDFPlugin::performDictionaryLookupAtLocation(const FloatPoint&amp; point)
</del><ins>+bool PDFPlugin::performDictionaryLookupAtLocation(const WebCore::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">@@ -1403,17 +1867,35 @@
</span><span class="cx">     [m_pdfLayerController activateNextAnnotation:true];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PDFPlugin::notifySelectionChanged(PDFSelection *selection)
</del><ins>+void PDFPlugin::notifySelectionChanged(PDFSelection *)
</ins><span class="cx"> {
</span><span class="cx">     webFrame()-&gt;page()-&gt;didChangeSelection();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static const Cursor&amp; pdfLayerControllerCursorTypeToCursor(PDFLayerControllerCursorType type)
+{
+    switch (type) {
+    case kPDFLayerControllerCursorTypeHand:
+        return handCursor();
+    case kPDFLayerControllerCursorTypeIBeam:
+        return iBeamCursor();
+    case kPDFLayerControllerCursorTypePointer:
+    default:
+        return pointerCursor();
+    }
+}
+
+void PDFPlugin::notifyCursorChanged(uint64_t type)
+{
+    webFrame()-&gt;page()-&gt;send(Messages::WebPageProxy::SetCursor(pdfLayerControllerCursorTypeToCursor(static_cast&lt;PDFLayerControllerCursorType&gt;(type))));
+}
+
</ins><span class="cx"> String PDFPlugin::getSelectionString() const
</span><span class="cx"> {
</span><span class="cx">     return [[m_pdfLayerController currentSelection] string];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String PDFPlugin::getSelectionForWordAtPoint(const FloatPoint&amp; point) const
</del><ins>+String PDFPlugin::getSelectionForWordAtPoint(const WebCore::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">@@ -1422,7 +1904,7 @@
</span><span class="cx">     return [selectionForWord string];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool PDFPlugin::existingSelectionContainsPoint(const FloatPoint&amp; locationInViewCoordinates) const
</del><ins>+bool PDFPlugin::existingSelectionContainsPoint(const WebCore::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">@@ -1455,8 +1937,7 @@
</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 = CGPointZero;
</del><ins>+    CGPoint scrollOffset = [pdfLayerController scrollPosition];
</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">@@ -1467,7 +1948,7 @@
</span><span class="cx">     return NSPointFromCGPoint(newPoint);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String PDFPlugin::lookupTextAtLocation(const FloatPoint&amp; locationInViewCoordinates, WebHitTestResultData&amp; data, PDFSelection **selectionPtr, NSDictionary **options) const
</del><ins>+String PDFPlugin::lookupTextAtLocation(const WebCore::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">@@ -1493,8 +1974,11 @@
</span><span class="cx">         NSRect bounds = annotation.bounds;
</span><span class="cx">         if (!NSPointInRect(pointInPageSpace, bounds))
</span><span class="cx">             continue;
</span><del>-        
</del><ins>+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
</ins><span class="cx">         PDFAnnotationLink *linkAnnotation = (PDFAnnotationLink *)annotation;
</span><ins>+#pragma clang diagnostic pop
</ins><span class="cx">         NSURL *url = linkAnnotation.URL;
</span><span class="cx">         if (!url)
</span><span class="cx">             continue;
</span><span class="lines">@@ -1516,7 +2000,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 = CGPointZero;
</del><ins>+    CGPoint scrollOffset = pdfLayerController.scrollPosition;
</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">@@ -1531,7 +2015,7 @@
</span><span class="cx">     return NSRectFromCGRect(newRect);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-FloatRect PDFPlugin::rectForSelectionInRootView(PDFSelection *selection) const
</del><ins>+WebCore::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">@@ -1547,9 +2031,14 @@
</span><span class="cx"> 
</span><span class="cx">     rectInView.origin = convertFromPDFViewToRootView(IntPoint(rectInView.origin));
</span><span class="cx"> 
</span><del>-    return FloatRect(rectInView);
</del><ins>+    return WebCore::FloatRect(rectInView);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+CGFloat PDFPlugin::scaleFactor() const
+{
+    return [m_pdfLayerController contentScaleFactor];
+}
+
</ins><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">@@ -1560,204 +2049,65 @@
</span><span class="cx">     webFrame()-&gt;page()-&gt;send(Messages::WebPageProxy::SearchWithSpotlight(string));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-NSData *PDFPlugin::liveData() const
</del><ins>+bool PDFPlugin::handleWheelEvent(const WebWheelEvent&amp; event)
</ins><span class="cx"> {
</span><del>-    if (m_activeAnnotation)
-        m_activeAnnotation-&gt;commit();
</del><ins>+    PDFDisplayMode displayMode = [m_pdfLayerController displayMode];
</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>+    if (displayMode == kPDFDisplaySinglePageContinuous || displayMode == kPDFDisplayTwoUpContinuous)
+        return ScrollableArea::handleWheelEvent(platform(event));
</ins><span class="cx"> 
</span><del>-NSObject *PDFPlugin::accessibilityObject() const
-{
-    return m_accessibilityObject.get();
-}
</del><ins>+    NSUInteger currentPageIndex = [m_pdfLayerController currentPageIndex];
+    bool inFirstPage = !currentPageIndex;
+    bool inLastPage = [m_pdfLayerController lastPageIndex] == currentPageIndex;
</ins><span class="cx"> 
</span><del>-void PDFPlugin::scrollToPoint(IntPoint scrollPoint)
-{
-    Frame* frame = pluginView()-&gt;frame();
-    float scale = frame-&gt;page()-&gt;pageScaleFactor();
-    scrollPoint.scale(scale);
-    frame-&gt;view()-&gt;scrollToOffsetWithoutAnimation(scrollPoint);
-}
</del><ins>+    bool atScrollTop = !scrollPosition().y();
+    bool atScrollBottom = scrollPosition().y() == maximumScrollPosition().y();
</ins><span class="cx"> 
</span><del>-float PDFPlugin::scaleFactor() const
-{
-    Frame* frame = pluginView()-&gt;frame();
-    return frame-&gt;page()-&gt;pageScaleFactor();
-}
</del><ins>+    bool inMomentumScroll = event.momentumPhase() != WebWheelEvent::PhaseNone;
</ins><span class="cx"> 
</span><del>-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();
</del><ins>+    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;
</ins><span class="cx">     }
</span><del>-}
</del><span class="cx"> 
</span><del>-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();
</del><ins>+    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;
</ins><span class="cx">     }
</span><del>-}
</del><span class="cx"> 
</span><del>-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);
</del><ins>+    return ScrollableArea::handleWheelEvent(platform(event));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-PDFPlugin::HUD::~HUD()
</del><ins>+NSData *PDFPlugin::liveData() const
</ins><span class="cx"> {
</span><del>-    MainFrame&amp; mainFrame = m_plugin.webFrame()-&gt;coreFrame()-&gt;mainFrame();
-    mainFrame.pageOverlayController().uninstallPageOverlay(m_overlay.ptr(), PageOverlay::FadeMode::DoNotFade);
-}
</del><ins>+    if (m_activeAnnotation)
+        m_activeAnnotation-&gt;commit();
</ins><span class="cx"> 
</span><del>-void PDFPlugin::HUD::willMoveToPage(PageOverlay&amp;, Page* page)
-{
</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><span class="cx"> 
</span><del>-void PDFPlugin::HUD::didMoveToPage(PageOverlay&amp;, Page*)
</del><ins>+NSObject *PDFPlugin::accessibilityObject() const
</ins><span class="cx"> {
</span><ins>+    return m_accessibilityObject.get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-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(NSEventTypeLeftMouseDragged) inHUDWithBounds:HUDRectInRootViewCoordinates];
-    case PlatformEvent::MousePressed:
-        return [pdfLayerController mouseDown:eventWithType(NSEventTypeLeftMouseDown) inHUDWithBounds:HUDRectInRootViewCoordinates];
-    case PlatformEvent::MouseReleased:
-        return [pdfLayerController mouseUp:eventWithType(NSEventTypeLeftMouseUp) inHUDWithBounds:HUDRectInRootViewCoordinates];
-    default:
-        break;
-    }
-
-    return false;
-}
-
</del><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 (214000 => 214001)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginAnnotation.mm        2017-03-15 19:34:00 UTC (rev 214000)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginAnnotation.mm        2017-03-15 19:34:22 UTC (rev 214001)
</span><span class="lines">@@ -104,14 +104,9 @@
</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><del>-#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
</del><span class="cx">     IntPoint scrollPosition(m_pdfLayerController.scrollPosition);
</span><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><del>-#endif
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool PDFPluginAnnotation::handleEvent(Event* event)
</span></span></pre>
</div>
</div>

</body>
</html>