<!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 <timothy_horton@apple.com>
+
+ 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 <achristensen@webkit.org>
</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(<PDFKit/PDFLayerControllerVersioningPriv.h>)
-#import <PDFKit/PDFLayerControllerVersioningPriv.h>
-#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 = "<group>"; };
</span><span class="cx">                 29CD55A8128E294F00133C85 /* WKAccessibilityWebPageObjectBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKAccessibilityWebPageObjectBase.h; sourceTree = "<group>"; };
</span><span class="cx">                 29CD55A9128E294F00133C85 /* WKAccessibilityWebPageObjectBase.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKAccessibilityWebPageObjectBase.mm; sourceTree = "<group>"; };
</span><del>-                2D0035221BC7414800DA8716 /* DeprecatedPDFPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DeprecatedPDFPlugin.h; path = PDF/DeprecatedPDFPlugin.h; sourceTree = "<group>"; };
-                2D0035231BC7414800DA8716 /* DeprecatedPDFPlugin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DeprecatedPDFPlugin.mm; path = PDF/DeprecatedPDFPlugin.mm; sourceTree = "<group>"; };
</del><ins>+                2D0035221BC7414800DA8716 /* PDFPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPlugin.h; path = PDF/PDFPlugin.h; sourceTree = "<group>"; };
+                2D0035231BC7414800DA8716 /* PDFPlugin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPlugin.mm; path = PDF/PDFPlugin.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 2D10875E1D2C573E00B85F82 /* LoadParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadParameters.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 2D10875F1D2C573E00B85F82 /* LoadParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadParameters.h; sourceTree = "<group>"; };
</span><span class="cx">                 2D1087621D2C641B00B85F82 /* LoadParametersCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadParametersCocoa.mm; sourceTree = "<group>"; };
</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 = "<group>"; };
</span><span class="cx">                 2D2ADF0516362DC700197E47 /* PDFPluginTextAnnotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPluginTextAnnotation.h; path = PDF/PDFPluginTextAnnotation.h; sourceTree = "<group>"; };
</span><span class="cx">                 2D2ADF0616362DC700197E47 /* PDFPluginTextAnnotation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPluginTextAnnotation.mm; path = PDF/PDFPluginTextAnnotation.mm; sourceTree = "<group>"; };
</span><del>-                2D2ADF0C16363DEC00197E47 /* DeprecatedPDFLayerControllerSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DeprecatedPDFLayerControllerSPI.h; path = PDF/DeprecatedPDFLayerControllerSPI.h; sourceTree = "<group>"; };
</del><ins>+                2D2ADF0C16363DEC00197E47 /* PDFLayerControllerSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PDFLayerControllerSPI.h; path = PDF/PDFLayerControllerSPI.h; sourceTree = "<group>"; };
</ins><span class="cx">                 2D2ADF0D16364D8200197E47 /* PDFPluginChoiceAnnotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPluginChoiceAnnotation.h; path = PDF/PDFPluginChoiceAnnotation.h; sourceTree = "<group>"; };
</span><span class="cx">                 2D2ADF0E16364D8200197E47 /* PDFPluginChoiceAnnotation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPluginChoiceAnnotation.mm; path = PDF/PDFPluginChoiceAnnotation.mm; sourceTree = "<group>"; };
</span><del>-                2D3494631BCC23BF0064F0BE /* PDFLayerControllerSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PDFLayerControllerSPI.h; path = PDF/PDFLayerControllerSPI.h; sourceTree = "<group>"; };
</del><span class="cx">                 2D3A65D81A7C3A1F00CAC637 /* WKNavigationActionRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKNavigationActionRef.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 2D3A65D91A7C3A1F00CAC637 /* WKNavigationActionRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNavigationActionRef.h; sourceTree = "<group>"; };
</span><span class="cx">                 2D3A65DC1A7C3A7D00CAC637 /* WKNavigationResponseRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKNavigationResponseRef.cpp; sourceTree = "<group>"; };
</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 = "<group>"; };
</span><span class="cx">                 2D819B9F1862800E001F03D1 /* ViewGestureGeometryCollectorMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewGestureGeometryCollectorMessageReceiver.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 2D819BA01862800E001F03D1 /* ViewGestureGeometryCollectorMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewGestureGeometryCollectorMessages.h; sourceTree = "<group>"; };
</span><del>-                2D870D0D1622B7F9000A3F20 /* PDFPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFPlugin.h; path = PDF/PDFPlugin.h; sourceTree = "<group>"; };
-                2D870D0E1622B7F9000A3F20 /* PDFPlugin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPlugin.mm; path = PDF/PDFPlugin.mm; sourceTree = "<group>"; };
</del><span class="cx">                 2D8710141828415D0018FA01 /* PlatformCALayerRemoteCustom.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformCALayerRemoteCustom.mm; sourceTree = "<group>"; };
</span><span class="cx">                 2D8710151828415D0018FA01 /* PlatformCALayerRemoteCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCALayerRemoteCustom.h; sourceTree = "<group>"; };
</span><span class="cx">                 2D87861B1BDB54BF00D02ABB /* _WKUserStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKUserStyleSheet.h; sourceTree = "<group>"; };
</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) && USE(DEPRECATED_PDF_PLUGIN)
-
-#import <PDFKit/PDFKit.h>
-
-@class CPReadingModel;
-@class PDFViewLayout;
-
-typedef NS_ENUM(NSInteger, PDFLayerControllerCursorType) {
- kPDFLayerControllerCursorTypePointer = 0,
- kPDFLayerControllerCursorTypeHand,
- kPDFLayerControllerCursorTypeIBeam,
-};
-
-@protocol PDFLayerControllerDelegate <NSObject>
-
-- (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<PDFLayerControllerDelegate> 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 "PDFKitImports.h"
-
-#if ENABLE(PDFKIT_PLUGIN) && USE(DEPRECATED_PDF_PLUGIN)
-
-#include "Plugin.h"
-#include "WebEvent.h"
-#include "WebHitTestResultData.h"
-#include <WebCore/AffineTransform.h>
-#include <WebCore/FindOptions.h>
-#include <WebCore/ScrollableArea.h>
-#include <wtf/RetainPtr.h>
-
-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<PDFPlugin> 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& password);
-
- WebCore::FloatRect convertFromPDFViewToScreen(const WebCore::FloatRect&) const;
- WebCore::IntRect boundsOnScreen() const;
-
- bool showContextMenuAtPoint(const WebCore::IntPoint&);
-
- String lookupTextAtLocation(const WebCore::FloatPoint&, WebHitTestResultData&, 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&) override;
- void destroy() override;
- void paint(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRectInWindowCoordinates) override { }
- void updateControlTints(WebCore::GraphicsContext&) override;
- bool supportsSnapshotting() const override { return true; }
- RefPtr<ShareableBitmap> snapshot() override;
- PlatformLayer* pluginLayer() override;
- bool isTransparent() override { return false; }
- bool wantsWheelEvents() override { return true; }
- void geometryDidChange(const WebCore::IntSize& pluginSize, const WebCore::IntRect& clipRect, const WebCore::AffineTransform& 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& result) override;
- void streamWillSendRequest(uint64_t streamID, const WebCore::URL& requestURL, const WebCore::URL& responseURL, int responseStatus) override { }
- void streamDidReceiveResponse(uint64_t streamID, const WebCore::URL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers, const String& 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& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const WTF::String& mimeType, const WTF::String& headers, const String& suggestedFileName) override;
- void manualStreamDidReceiveData(const char* bytes, int length) override;
- void manualStreamDidFinishLoading() override;
- void manualStreamDidFail(bool wasCancelled) override;
- bool handleMouseEvent(const WebMouseEvent&) override;
- bool handleWheelEvent(const WebWheelEvent&) override;
- bool handleMouseEnterEvent(const WebMouseEvent&) override;
- bool handleMouseLeaveEvent(const WebMouseEvent&) override;
- bool handleContextMenuEvent(const WebMouseEvent&) override;
- bool handleKeyboardEvent(const WebKeyboardEvent&) override;
- bool handleEditingCommand(const String& commandName, const String& argument) override;
- bool isEditingCommandEnabled(const String&) 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& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates) override { }
- void windowVisibilityChanged(bool) override { }
- uint64_t pluginComplexTextInputIdentifier() const override { return 0; }
- void sendComplexTextInput(const String& 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& formValue) override { return false; }
- bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity) override;
- RefPtr<WebCore::SharedBuffer> liveResourceData() const override;
- void willDetatchRenderer() override;
-
- bool isBeingAsynchronouslyInitialized() const override { return false; }
-
- RetainPtr<PDFDocument> pdfDocumentForPrinting() const override { return m_pdfDocument; }
- NSObject *accessibilityObject() const override;
-
- unsigned countFindMatches(const String& target, WebCore::FindOptions, unsigned maxMatchCount) override;
- bool findString(const String& target, WebCore::FindOptions, unsigned maxMatchCount) override;
-
- PDFSelection *nextMatchForString(const String& target, BOOL searchForward, BOOL caseSensitive, BOOL wrapSearch, PDFSelection *initialSelection, BOOL startInSelection);
-
- bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&) override;
- String getSelectionString() const override;
- String getSelectionForWordAtPoint(const WebCore::FloatPoint&) const override;
- bool existingSelectionContainsPoint(const WebCore::FloatPoint&) 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&) override;
- void invalidateScrollbarRect(WebCore::Scrollbar&, const WebCore::IntRect&) override;
- void invalidateScrollCornerRect(const WebCore::IntRect&) 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&, const WebCore::IntRect& scrollbarRect) const override;
- WebCore::IntRect convertFromContainingViewToScrollbar(const WebCore::Scrollbar&, const WebCore::IntRect& parentRect) const override;
- WebCore::IntPoint convertFromScrollbarToContainingView(const WebCore::Scrollbar&, const WebCore::IntPoint& scrollbarPoint) const override;
- WebCore::IntPoint convertFromContainingViewToScrollbar(const WebCore::Scrollbar&, const WebCore::IntPoint& parentPoint) const override;
- bool forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const override;
-
- // PDFPlugin functions.
- void updateScrollbars();
- Ref<WebCore::Scrollbar> createScrollbar(WebCore::ScrollbarOrientation);
- void destroyScrollbar(WebCore::ScrollbarOrientation);
- void pdfDocumentDidLoad();
- void addArchiveResource();
- void computePageBoxes();
- void calculateSizes();
- void runScriptsInPDFDocument();
-
- NSEvent *nsEventForWebMouseEvent(const WebMouseEvent&);
- WebCore::IntPoint convertFromPluginToPDFView(const WebCore::IntPoint&) const;
- WebCore::IntPoint convertFromRootViewToPlugin(const WebCore::IntPoint&) const;
- WebCore::IntPoint convertFromPDFViewToRootView(const WebCore::IntPoint&) const;
-
- bool supportsForms();
- bool isFullFramePlugin() const;
-
- void updatePageAndDeviceScaleFactors();
-
- void createPasswordEntryForm();
-
- RetainPtr<PDFDocument> pdfDocument() const { return m_pdfDocument; }
- void setPDFDocument(RetainPtr<PDFDocument> 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 < 101300
- enum UpdateCursorMode {
- UpdateIfNeeded,
- ForceUpdate
- };
-
- enum HitTestResult {
- None,
- Text
- };
-
- void updateCursor(const WebMouseEvent&, 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<CALayer> m_containerLayer;
- RetainPtr<CALayer> m_contentLayer;
- RetainPtr<CALayer> m_horizontalScrollbarLayer;
- RetainPtr<CALayer> m_verticalScrollbarLayer;
- RetainPtr<CALayer> m_scrollCornerLayer;
- RetainPtr<PDFLayerController> m_pdfLayerController;
- RetainPtr<WKPDFPluginAccessibilityObject> m_accessibilityObject;
-
- RefPtr<PDFPluginAnnotation> m_activeAnnotation;
- RefPtr<PDFPluginPasswordField> m_passwordField;
- RefPtr<WebCore::Element> 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 < 101300
- HitTestResult m_lastHitTestResult;
-#endif
-
- RetainPtr<WKPDFLayerControllerDelegate> m_pdfLayerControllerDelegate;
-
- WebCore::IntSize m_size;
-
- WebCore::URL m_sourceURL;
-
- String m_suggestedFilename;
- RetainPtr<CFMutableDataRef> m_data;
-
- RetainPtr<PDFDocument> m_pdfDocument;
- Vector<WebCore::IntRect> m_pageBoxes;
- WebCore::IntSize m_pdfDocumentSize; // All pages, including gaps.
-
- RefPtr<WebCore::Scrollbar> m_horizontalScrollbar;
- RefPtr<WebCore::Scrollbar> 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 "config.h"
-#import "DeprecatedPDFPlugin.h"
-
-#if ENABLE(PDFKIT_PLUGIN) && USE(DEPRECATED_PDF_PLUGIN)
-
-#import "ArgumentCoders.h"
-#import "DataReference.h"
-#import "PDFAnnotationTextWidgetDetails.h"
-#import "PDFLayerControllerSPI.h"
-#import "PDFPluginAnnotation.h"
-#import "PDFPluginPasswordField.h"
-#import "PluginView.h"
-#import "WKAccessibilityWebPageObjectMac.h"
-#import "WKPageFindMatchesClient.h"
-#import "WebCoreArgumentCoders.h"
-#import "WebEvent.h"
-#import "WebEventConversion.h"
-#import "WebPage.h"
-#import "WebPageProxyMessages.h"
-#import "WebPasteboardProxyMessages.h"
-#import "WebProcess.h"
-#import <JavaScriptCore/JSContextRef.h>
-#import <JavaScriptCore/JSObjectRef.h>
-#import <JavaScriptCore/JSStringRef.h>
-#import <JavaScriptCore/JSStringRefCF.h>
-#import <PDFKit/PDFKit.h>
-#import <QuartzCore/QuartzCore.h>
-#import <WebCore/ArchiveResource.h>
-#import <WebCore/Chrome.h>
-#import <WebCore/Cursor.h>
-#import <WebCore/DictionaryLookup.h>
-#import <WebCore/DocumentLoader.h>
-#import <WebCore/EventNames.h>
-#import <WebCore/FocusController.h>
-#import <WebCore/FormState.h>
-#import <WebCore/Frame.h>
-#import <WebCore/FrameLoader.h>
-#import <WebCore/FrameView.h>
-#import <WebCore/GraphicsContext.h>
-#import <WebCore/HTMLElement.h>
-#import <WebCore/HTMLFormElement.h>
-#import <WebCore/HTMLPlugInElement.h>
-#import <WebCore/LocalizedStrings.h>
-#import <WebCore/MainFrame.h>
-#import <WebCore/MouseEvent.h>
-#import <WebCore/Page.h>
-#import <WebCore/Pasteboard.h>
-#import <WebCore/PluginData.h>
-#import <WebCore/PluginDocument.h>
-#import <WebCore/RenderBoxModelObject.h>
-#import <WebCore/ScrollAnimator.h>
-#import <WebCore/ScrollbarTheme.h>
-#import <WebCore/Settings.h>
-#import <WebCore/UUID.h>
-#import <WebCore/WheelEventTestTrigger.h>
-#import <WebKitSystemInterface.h>
-#import <wtf/CurrentTime.h>
-
-using namespace WebCore;
-
-// Set overflow: hidden on the annotation container so <input> 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 =
-"#annotationContainer {"
-" overflow: hidden; "
-" position: absolute; "
-" pointer-events: none; "
-" top: 0; "
-" left: 0; "
-" right: 0; "
-" bottom: 0; "
-" display: -webkit-box; "
-" -webkit-box-align: center; "
-" -webkit-box-pack: center; "
-"} "
-".annotation { "
-" position: absolute; "
-" pointer-events: auto; "
-"} "
-"textarea.annotation { "
-" resize: none; "
-"} "
-"input.annotation[type='password'] { "
-" position: static; "
-" width: 200px; "
-" margin-top: 100px; "
-"} ";
-
-// In non-continuous modes, a single scroll event with a magnitude of >= 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->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->boundsOnScreen().location()];
-
- return 0;
-}
-
-- (id)accessibilityAttributeValue:(NSString *)attribute forParameter:(id)parameter
-{
- if ([attribute isEqualToString:NSAccessibilityBoundsForRangeParameterizedAttribute]) {
- NSRect boundsInPDFViewCoordinates = [[_pdfLayerController accessibilityBoundsForRangeAttributeForParameter:parameter] rectValue];
- NSRect boundsInScreenCoordinates = _pdfPlugin->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->showContextMenuAtPoint(IntRect(IntPoint(), _pdfPlugin->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<CAAction>)actionForKey:(NSString *)key
-{
- return nil;
-}
-
-- (void)drawInContext:(CGContextRef)ctx
-{
- _pdfPlugin->paintControlForLayerInContext(self, ctx);
-}
-
-@end
-
-@interface WKPDFLayerControllerDelegate : NSObject<PDFLayerControllerDelegate> {
- 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->notifyScrollPositionChanged(IntPoint(newPosition));
-}
-
-- (void)writeItemsToPasteboard:(NSArray *)items withTypes:(NSArray *)types
-{
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- _pdfPlugin->writeItemsToPasteboard(NSGeneralPboard, items, types);
-#pragma clang diagnostic pop
-}
-
-- (void)showDefinitionForAttributedString:(NSAttributedString *)string atPoint:(CGPoint)point
-{
- _pdfPlugin->showDefinitionForAttributedString(string, point);
-}
-
-- (void)performWebSearch:(NSString *)string
-{
- _pdfPlugin->performWebSearch(string);
-}
-
-- (void)performSpotlightSearch:(NSString *)string
-{
- _pdfPlugin->performSpotlightSearch(string);
-}
-
-- (void)openWithNativeApplication
-{
- _pdfPlugin->openWithNativeApplication();
-}
-
-- (void)saveToPDF
-{
- _pdfPlugin->saveToPDF();
-}
-
-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController clickedLinkWithURL:(NSURL *)url
-{
- _pdfPlugin->clickedLink(url);
-}
-
-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeActiveAnnotation:(PDFAnnotation *)annotation
-{
- _pdfPlugin->setActiveAnnotation(annotation);
-}
-
-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeContentScaleFactor:(CGFloat)scaleFactor
-{
- _pdfPlugin->notifyContentScaleFactorChanged(scaleFactor);
-}
-
-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeDisplayMode:(int)mode
-{
- _pdfPlugin->notifyDisplayModeChanged(mode);
-}
-
-- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeSelection:(PDFSelection *)selection
-{
- _pdfPlugin->notifySelectionChanged(selection);
-}
-
-- (void)setMouseCursor:(PDFLayerControllerCursorType)cursorType
-{
- _pdfPlugin->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 = "application/postscript";
-const uint64_t pdfDocumentRequestID = 1; // PluginController supports loading multiple streams, but we only need one for PDF.
-
-static void appendValuesInPDFNameSubtreeToVector(CGPDFDictionaryRef subtree, Vector<CGPDFObjectRef>& values)
-{
- CGPDFArrayRef names;
- if (CGPDFDictionaryGetArray(subtree, "Names", &names)) {
- size_t nameCount = CGPDFArrayGetCount(names) / 2;
- for (size_t i = 0; i < nameCount; ++i) {
- CGPDFObjectRef object;
- CGPDFArrayGetObject(names, 2 * i + 1, &object);
- values.append(object);
- }
- return;
- }
-
- CGPDFArrayRef kids;
- if (!CGPDFDictionaryGetArray(subtree, "Kids", &kids))
- return;
-
- size_t kidCount = CGPDFArrayGetCount(kids);
- for (size_t i = 0; i < kidCount; ++i) {
- CGPDFDictionaryRef kid;
- if (!CGPDFArrayGetDictionary(kids, i, &kid))
- continue;
- appendValuesInPDFNameSubtreeToVector(kid, values);
- }
-}
-
-static void getAllValuesInPDFNameTree(CGPDFDictionaryRef tree, Vector<CGPDFObjectRef>& allValues)
-{
- appendValuesInPDFNameSubtreeToVector(tree, allValues);
-}
-
-static void getAllScriptsInPDFDocument(CGPDFDocumentRef pdfDocument, Vector<RetainPtr<CFStringRef>>& 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, "Names", &namesDictionary))
- return;
-
- // Get the document-level "JavaScript" name tree.
- CGPDFDictionaryRef javaScriptNameTree;
- if (!CGPDFDictionaryGetDictionary(namesDictionary, "JavaScript", &javaScriptNameTree))
- return;
-
- // The names are arbitrary. We are only interested in the values.
- Vector<CGPDFObjectRef> objects;
- getAllValuesInPDFNameTree(javaScriptNameTree, objects);
- size_t objectCount = objects.size();
-
- for (size_t i = 0; i < objectCount; ++i) {
- CGPDFDictionaryRef javaScriptAction;
- if (!CGPDFObjectGetValue(reinterpret_cast<CGPDFObjectRef>(objects[i]), kCGPDFObjectTypeDictionary, &javaScriptAction))
- continue;
-
- // A JavaScript action must have an action type of "JavaScript".
- const char* actionType;
- if (!CGPDFDictionaryGetName(javaScriptAction, "S", &actionType) || strcmp(actionType, "JavaScript"))
- continue;
-
- const UInt8* bytes = 0;
- CFIndex length;
- CGPDFStreamRef stream;
- CGPDFStringRef string;
- RetainPtr<CFDataRef> data;
- if (CGPDFDictionaryGetStream(javaScriptAction, "JS", &stream)) {
- CGPDFDataFormat format;
- data = adoptCF(CGPDFStreamCopyData(stream, &format));
- if (!data)
- continue;
- bytes = CFDataGetBytePtr(data.get());
- length = CFDataGetLength(data.get());
- } else if (CGPDFDictionaryGetString(javaScriptAction, "JS", &string)) {
- bytes = CGPDFStringGetBytePtr(string);
- length = CGPDFStringGetLength(string);
- }
- if (!bytes)
- continue;
-
- CFStringEncoding encoding = (length > 1 && bytes[0] == 0xFE && bytes[1] == 0xFF) ? kCFStringEncodingUnicode : kCFStringEncodingUTF8;
- RetainPtr<CFStringRef> script = adoptCF(CFStringCreateWithBytes(kCFAllocatorDefault, bytes, length, encoding, true));
- if (!script)
- continue;
-
- scripts.append(script);
- }
-}
-
-namespace WebKit {
-
-using namespace HTMLNames;
-
-Ref<PDFPlugin> 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()->coreFrame()->document();
- m_annotationContainer = document->createElement(divTag, false);
- m_annotationContainer->setAttributeWithoutSynchronization(idAttr, AtomicString("annotationContainer", AtomicString::ConstructFromLiteral));
-
- auto annotationStyleElement = document->createElement(styleTag, false);
- annotationStyleElement->setTextContent(annotationStyle);
-
- m_annotationContainer->appendChild(annotationStyleElement);
- document->bodyOrFrameset()->appendChild(*m_annotationContainer);
- }
-
- m_accessibilityObject = adoptNS([[WKPDFPluginAccessibilityObject alloc] initWithPDFPlugin:this]);
- [m_accessibilityObject setPdfLayerController:m_pdfLayerController.get()];
- [m_accessibilityObject setParent:webFrame()->page()->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 = "application/pdf";
- pdfMimeClassInfo.desc = pdfDocumentTypeDescription();
- pdfMimeClassInfo.extensions.append("pdf");
- info.mimes.append(pdfMimeClassInfo);
-
- MimeClassInfo textPDFMimeClassInfo;
- textPDFMimeClassInfo.type = "text/pdf";
- textPDFMimeClassInfo.desc = pdfDocumentTypeDescription();
- textPDFMimeClassInfo.extensions.append("pdf");
- info.mimes.append(textPDFMimeClassInfo);
-
- MimeClassInfo postScriptMimeClassInfo;
- postScriptMimeClassInfo.type = postScriptMIMEType;
- postScriptMimeClassInfo.desc = postScriptDocumentTypeDescription();
- postScriptMimeClassInfo.extensions.append("ps");
- info.mimes.append(postScriptMimeClassInfo);
-
- return info;
-}
-
-void PDFPlugin::updateScrollbars()
-{
- bool hadScrollbars = m_horizontalScrollbar || m_verticalScrollbar;
-
- if (m_horizontalScrollbar) {
- if (m_size.width() >= m_pdfDocumentSize.width())
- destroyScrollbar(HorizontalScrollbar);
- } else if (m_size.width() < m_pdfDocumentSize.width())
- m_horizontalScrollbar = createScrollbar(HorizontalScrollbar);
-
- if (m_verticalScrollbar) {
- if (m_size.height() >= m_pdfDocumentSize.height())
- destroyScrollbar(VerticalScrollbar);
- } else if (m_size.height() < 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->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
- m_horizontalScrollbar->setProportion(m_size.width() - scrollbarSpace.width(), m_pdfDocumentSize.width());
- IntRect scrollbarRect(pluginView()->x(), pluginView()->y() + m_size.height() - m_horizontalScrollbar->height(), m_size.width(), m_horizontalScrollbar->height());
- if (m_verticalScrollbar)
- scrollbarRect.contract(m_verticalScrollbar->width(), 0);
- m_horizontalScrollbar->setFrameRect(scrollbarRect);
- }
- if (m_verticalScrollbar) {
- m_verticalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
- m_verticalScrollbar->setProportion(m_size.height() - scrollbarSpace.height(), m_pdfDocumentSize.height());
- IntRect scrollbarRect(IntRect(pluginView()->x() + m_size.width() - m_verticalScrollbar->width(), pluginView()->y(), m_verticalScrollbar->width(), m_size.height()));
- if (m_horizontalScrollbar)
- scrollbarRect.contract(0, m_horizontalScrollbar->height());
- m_verticalScrollbar->setFrameRect(scrollbarRect);
- }
-
- FrameView* frameView = m_frame->coreFrame()->view();
- if (!frameView)
- return;
-
- bool hasScrollbars = m_horizontalScrollbar || m_verticalScrollbar;
- if (hadScrollbars != hasScrollbars) {
- if (hasScrollbars)
- frameView->addScrollableArea(this);
- else
- frameView->removeScrollableArea(this);
-
- frameView->setNeedsLayout();
- }
-
- if (m_verticalScrollbarLayer) {
- m_verticalScrollbarLayer.get().frame = verticalScrollbar()->frameRect();
- [m_verticalScrollbarLayer setNeedsDisplay];
- }
-
- if (m_horizontalScrollbarLayer) {
- m_horizontalScrollbarLayer.get().frame = horizontalScrollbar()->frameRect();
- [m_horizontalScrollbarLayer setNeedsDisplay];
- }
-
- if (m_scrollCornerLayer) {
- m_scrollCornerLayer.get().frame = scrollCornerRect();
- [m_scrollCornerLayer setNeedsDisplay];
- }
-}
-
-PluginView* PDFPlugin::pluginView()
-{
- return static_cast<PluginView*>(controller());
-}
-
-const PluginView* PDFPlugin::pluginView() const
-{
- return static_cast<const PluginView*>(controller());
-}
-
-Ref<Scrollbar> 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()->coreFrame()) {
- if (Page* page = frame->page()) {
- if (page->expectsWheelEventTriggers())
- scrollAnimator().setWheelEventTestTrigger(page->testTrigger());
- }
- }
- pluginView()->frame()->view()->addChild(widget);
- return widget;
-}
-
-void PDFPlugin::destroyScrollbar(ScrollbarOrientation orientation)
-{
- RefPtr<Scrollbar>& scrollbar = orientation == HorizontalScrollbar ? m_horizontalScrollbar : m_verticalScrollbar;
- if (!scrollbar)
- return;
-
- willRemoveScrollbar(scrollbar.get(), orientation);
- scrollbar->removeFromParent();
- scrollbar = nullptr;
-
- if (orientation == HorizontalScrollbar) {
- [m_horizontalScrollbarLayer removeFromSuperlayer];
- m_horizontalScrollbarLayer = 0;
- } else {
- [m_verticalScrollbarLayer removeFromSuperlayer];
- m_verticalScrollbarLayer = 0;
- }
-}
-
-IntRect PDFPlugin::convertFromScrollbarToContainingView(const Scrollbar& scrollbar, const IntRect& scrollbarRect) const
-{
- IntRect rect = scrollbarRect;
- rect.move(scrollbar.location() - pluginView()->location());
-
- return pluginView()->frame()->view()->convertFromRendererToContainingView(pluginView()->pluginElement()->renderer(), rect);
-}
-
-IntRect PDFPlugin::convertFromContainingViewToScrollbar(const Scrollbar& scrollbar, const IntRect& parentRect) const
-{
- IntRect rect = pluginView()->frame()->view()->convertFromContainingViewToRenderer(pluginView()->pluginElement()->renderer(), parentRect);
- rect.move(pluginView()->location() - scrollbar.location());
-
- return rect;
-}
-
-IntPoint PDFPlugin::convertFromScrollbarToContainingView(const Scrollbar& scrollbar, const IntPoint& scrollbarPoint) const
-{
- IntPoint point = scrollbarPoint;
- point.move(scrollbar.location() - pluginView()->location());
-
- return pluginView()->frame()->view()->convertFromRendererToContainingView(pluginView()->pluginElement()->renderer(), point);
-}
-
-IntPoint PDFPlugin::convertFromContainingViewToScrollbar(const Scrollbar& scrollbar, const IntPoint& parentPoint) const
-{
- IntPoint point = pluginView()->frame()->view()->convertFromContainingViewToRenderer(pluginView()->pluginElement()->renderer(), parentPoint);
- point.move(pluginView()->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->isOverlayScrollbar()) {
- ASSERT(m_verticalScrollbar->isOverlayScrollbar());
- return IntRect();
- }
- return IntRect(pluginView()->width() - m_verticalScrollbar->width(), pluginView()->height() - m_horizontalScrollbar->height(), m_verticalScrollbar->width(), m_horizontalScrollbar->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()->frameRect();
-}
-
-int PDFPlugin::scrollSize(ScrollbarOrientation orientation) const
-{
- Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_horizontalScrollbar : m_verticalScrollbar).get();
- return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0;
-}
-
-bool PDFPlugin::isActive() const
-{
- if (Frame* coreFrame = m_frame->coreFrame()) {
- if (Page* page = coreFrame->page())
- return page->focusController().isActive();
- }
-
- return false;
-}
-
-bool PDFPlugin::forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const
-{
- if (Frame* coreFrame = m_frame->coreFrame()) {
- if (Page* page = coreFrame->page())
- return page->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 = @{ @"Content-Disposition": (NSString *)m_suggestedFilename, @"Content-Type" : @"application/pdf" };
- RetainPtr<NSURLResponse> response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:m_sourceURL statusCode:200 HTTPVersion:(NSString*)kCFHTTPVersion1_1 headerFields:headers]);
- ResourceResponse synthesizedResponse(response.get());
-
- RefPtr<ArchiveResource> resource = ArchiveResource::create(SharedBuffer::wrapCFData(m_data.get()), m_sourceURL, "application/pdf", String(), String(), synthesizedResponse);
- pluginView()->frame()->document()->loader()->addArchiveResource(resource.releaseNonNull());
-}
-
-static void jsPDFDocInitialize(JSContextRef ctx, JSObjectRef object)
-{
- PDFPlugin* pdfView = static_cast<PDFPlugin*>(JSObjectGetPrivate(object));
- pdfView->ref();
-}
-
-static void jsPDFDocFinalize(JSObjectRef object)
-{
- PDFPlugin* pdfView = static_cast<PDFPlugin*>(JSObjectGetPrivate(object));
- pdfView->deref();
-}
-
-JSValueRef PDFPlugin::jsPDFDocPrint(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
-{
- PDFPlugin* pdfView = static_cast<PDFPlugin*>(JSObjectGetPrivate(thisObject));
-
- WebFrame* frame = pdfView->m_frame;
- if (!frame)
- return JSValueMakeUndefined(ctx);
-
- Frame* coreFrame = frame->coreFrame();
- if (!coreFrame)
- return JSValueMakeUndefined(ctx);
-
- Page* page = coreFrame->page();
- if (!page)
- return JSValueMakeUndefined(ctx);
-
- page->chrome().print(*coreFrame);
-
- return JSValueMakeUndefined(ctx);
-}
-
-JSObjectRef PDFPlugin::makeJSPDFDoc(JSContextRef ctx)
-{
- static JSStaticFunction jsPDFDocStaticFunctions[] = {
- { "print", jsPDFDocPrint, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
- { 0, 0, 0 },
- };
-
- static JSClassDefinition jsPDFDocClassDefinition = {
- 0,
- kJSClassAttributeNone,
- "Doc",
- 0,
- 0,
- jsPDFDocStaticFunctions,
- jsPDFDocInitialize, jsPDFDocFinalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
-
- static JSClassRef jsPDFDocClass = JSClassCreate(&jsPDFDocClassDefinition);
-
- return JSObjectMake(ctx, jsPDFDocClass, this);
-}
-
-static RetainPtr<CFMutableDataRef> convertPostScriptDataToPDF(RetainPtr<CFDataRef> 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<CGPSConverterRef> converter = adoptCF(CGPSConverterCreate(0, &callbacks, 0));
- RetainPtr<CGDataProviderRef> provider = adoptCF(CGDataProviderCreateWithCFData(postScriptData.get()));
- RetainPtr<CFMutableDataRef> pdfData = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, 0));
- RetainPtr<CGDataConsumerRef> 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 + ".pdf");
- m_data = convertPostScriptDataToPDF(m_data);
-}
-
-void PDFPlugin::pdfDocumentDidLoad()
-{
- addArchiveResource();
-
- RetainPtr<PDFDocument> document = adoptNS([[pdfDocumentClass() alloc] initWithData:rawData()]);
-
- setPDFDocument(document);
-
- updatePageAndDeviceScaleFactors();
-
- [m_pdfLayerController setFrameSize:size()];
- m_pdfLayerController.get().document = document.get();
-
- if (handlesPageScaleFactor())
- pluginView()->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&, uint32_t, uint32_t, const String& mimeType, const String&, const String& 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<const UInt8*>(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& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers, const String& 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<const UInt8*>(bytes), length);
-}
-
-void PDFPlugin::manualStreamDidFinishLoading()
-{
- convertPostScriptDataIfNeeded();
- pdfDocumentDidLoad();
-}
-
-void PDFPlugin::manualStreamDidFail(bool)
-{
- m_data.clear();
-}
-
-void PDFPlugin::runScriptsInPDFDocument()
-{
- Vector<RetainPtr<CFStringRef>> 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 < 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->attach(m_annotationContainer.get());
-}
-
-void PDFPlugin::attemptToUnlockPDF(const String& password)
-{
- [m_pdfLayerController attemptToUnlockWithPassword:password];
-
- if (![pdfDocument() isLocked]) {
- m_passwordField = nullptr;
-
- calculateSizes();
- updateScrollbars();
- }
-}
-
-void PDFPlugin::updatePageAndDeviceScaleFactors()
-{
- double newScaleFactor = controller()->contentsScaleFactor();
- if (!handlesPageScaleFactor())
- newScaleFactor *= webFrame()->page()->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 < 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& parameters)
-{
- m_sourceURL = parameters.url;
- if (!parameters.shouldUseManualLoader && !parameters.url.isEmpty())
- controller()->loadURL(pdfDocumentRequestID, "GET", parameters.url.string(), String(), HTTPHeaderMap(), Vector<uint8_t>(), false);
-
- controller()->didInitializePlugin();
- return true;
-}
-
-void PDFPlugin::willDetatchRenderer()
-{
- if (webFrame()) {
- if (FrameView* frameView = webFrame()->coreFrame()->view())
- frameView->removeScrollableArea(this);
- }
-}
-
-void PDFPlugin::destroy()
-{
- m_pdfLayerController.get().delegate = 0;
-
- if (webFrame()) {
- if (FrameView* frameView = webFrame()->coreFrame()->view())
- frameView->removeScrollableArea(this);
- }
-
- m_activeAnnotation = nullptr;
- m_annotationContainer = nullptr;
-
- destroyScrollbar(HorizontalScrollbar);
- destroyScrollbar(VerticalScrollbar);
-
- [m_scrollCornerLayer removeFromSuperlayer];
- [m_contentLayer removeFromSuperlayer];
-}
-
-void PDFPlugin::updateControlTints(GraphicsContext& graphicsContext)
-{
- ASSERT(graphicsContext.updatingControlTints());
-
- if (m_horizontalScrollbar)
- m_horizontalScrollbar->invalidate();
- if (m_verticalScrollbar)
- m_verticalScrollbar->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->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->x(), -scrollbar->y());
- scrollbar->paint(graphicsContext, scrollbar->frameRect());
-}
-
-RefPtr<ShareableBitmap> PDFPlugin::snapshot()
-{
- if (size().isEmpty())
- return nullptr;
-
- float contentsScaleFactor = controller()->contentsScaleFactor();
- IntSize backingStoreSize = size();
- backingStoreSize.scale(contentsScaleFactor);
-
- RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha);
- auto context = bitmap->createGraphicsContext();
-
- context->scale(FloatSize(contentsScaleFactor, -contentsScaleFactor));
- context->translate(-m_scrollOffset.width(), -m_pdfDocumentSize.height() + m_scrollOffset.height());
-
- [m_pdfLayerController snapshotInContext:context->platformContext()];
-
- return bitmap;
-}
-
-PlatformLayer* PDFPlugin::pluginLayer()
-{
- return m_containerLayer.get();
-}
-
-IntPoint PDFPlugin::convertFromPluginToPDFView(const IntPoint& point) const
-{
- return IntPoint(point.x(), size().height() - point.y());
-}
-
-IntPoint PDFPlugin::convertFromRootViewToPlugin(const IntPoint& point) const
-{
- return m_rootViewToPluginTransform.mapPoint(point);
-}
-
-IntPoint PDFPlugin::convertFromPDFViewToRootView(const IntPoint& point) const
-{
- IntPoint pointInPluginCoordinates(point.x(), size().height() - point.y());
- return m_rootViewToPluginTransform.inverse().value_or(AffineTransform()).mapPoint(pointInPluginCoordinates);
-}
-
-FloatRect PDFPlugin::convertFromPDFViewToScreen(const FloatRect& rect) const
-{
- FrameView* frameView = webFrame()->coreFrame()->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->contentsToScreen(enclosingIntRect(rectInRootViewCoordinates));
-}
-
-IntRect PDFPlugin::boundsOnScreen() const
-{
- FrameView* frameView = webFrame()->coreFrame()->view();
-
- if (!frameView)
- return IntRect();
-
- FloatRect bounds = FloatRect(FloatPoint(), size());
- FloatRect rectInRootViewCoordinates = m_rootViewToPluginTransform.inverse().value_or(AffineTransform()).mapRect(bounds);
- return frameView->contentsToScreen(enclosingIntRect(rectInRootViewCoordinates));
-}
-
-void PDFPlugin::geometryDidChange(const IntSize& pluginSize, const IntRect&, const AffineTransform& pluginToRootViewTransform)
-{
- if (size() == pluginSize && pluginView()->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()->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->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&)
-{
- ASSERT_NOT_REACHED();
-}
-
-
-static NSUInteger modifierFlagsFromWebEvent(const WebEvent& event)
-{
- return (event.shiftKey() ? NSEventModifierFlagShift : 0)
- | (event.controlKey() ? NSEventModifierFlagControl : 0)
- | (event.altKey() ? NSEventModifierFlagOption : 0)
- | (event.metaKey() ? NSEventModifierFlagCommand : 0);
-}
-
-static bool getEventTypeFromWebEvent(const WebEvent& event, NSEventType& eventType)
-{
- switch (event.type()) {
- case WebEvent::KeyDown:
- eventType = NSEventTypeKeyDown;
- return true;
- case WebEvent::KeyUp:
- eventType = NSEventTypeKeyUp;
- return true;
- case WebEvent::MouseDown:
- switch (static_cast<const WebMouseEvent&>(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<const WebMouseEvent&>(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<const WebMouseEvent&>(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& 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 < 101300
-void PDFPlugin::updateCursor(const WebMouseEvent& event, UpdateCursorMode mode)
-{
- HitTestResult hitTestResult = None;
-
- PDFSelection *selectionUnderMouse = [m_pdfLayerController getSelectionForWordAtPoint:convertFromPluginToPDFView(event.position())];
- if (selectionUnderMouse && [[selectionUnderMouse string] length])
- hitTestResult = Text;
-
- if (hitTestResult == m_lastHitTestResult && mode == UpdateIfNeeded)
- return;
-
- webFrame()->page()->send(Messages::WebPageProxy::SetCursor(hitTestResult == Text ? iBeamCursor() : pointerCursor()));
- m_lastHitTestResult = hitTestResult;
-}
-#endif
-
-bool PDFPlugin::handleMouseEvent(const WebMouseEvent& event)
-{
- PlatformMouseEvent platformEvent = platform(event);
- IntPoint mousePosition = convertFromRootViewToPlugin(event.position());
-
- m_lastMouseEvent = event;
-
- RefPtr<Scrollbar> targetScrollbar;
- RefPtr<Scrollbar> 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 && 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 && event.controlKey()))
- return true;
-
- NSEvent *nsEvent = nsEventForWebMouseEvent(event);
-
- switch (event.type()) {
- case WebEvent::MouseMove:
- mouseMovedInContentArea();
-#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
- updateCursor(event);
-#endif
-
- if (targetScrollbar) {
- if (!targetScrollbarForLastMousePosition) {
- targetScrollbar->mouseEntered();
- return true;
- }
- return targetScrollbar->mouseMoved(platformEvent);
- }
-
- if (!targetScrollbar && targetScrollbarForLastMousePosition)
- targetScrollbarForLastMousePosition->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->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->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& event)
-{
- mouseEnteredContentArea();
-#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
- updateCursor(event, ForceUpdate);
-#endif
- return false;
-}
-
-bool PDFPlugin::handleMouseLeaveEvent(const WebMouseEvent&)
-{
- mouseExitedContentArea();
- return false;
-}
-
-bool PDFPlugin::showContextMenuAtPoint(const IntPoint& point)
-{
- FrameView* frameView = webFrame()->coreFrame()->view();
- IntPoint contentsPoint = frameView->contentsToRootView(point);
- WebMouseEvent event(WebEvent::MouseDown, WebMouseEvent::RightButton, contentsPoint, contentsPoint, 0, 0, 0, 1, static_cast<WebEvent::Modifiers>(0), monotonicallyIncreasingTime(), WebCore::ForceAtClick);
- return handleContextMenuEvent(event);
-}
-
-bool PDFPlugin::handleContextMenuEvent(const WebMouseEvent& event)
-{
- FrameView* frameView = webFrame()->coreFrame()->view();
- IntPoint point = frameView->contentsToScreen(IntRect(frameView->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& 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& commandName, const String& argument)
-{
- if (commandName == "copy")
- [m_pdfLayerController copySelection];
- else if (commandName == "selectAll")
- [m_pdfLayerController selectAll];
- else if (commandName == "takeFindStringFromSelection") {
- NSString *string = [m_pdfLayerController currentSelection].string;
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- if (string.length)
- writeItemsToPasteboard(NSFindPboard, @[ [string dataUsingEncoding:NSUTF8StringEncoding] ], @[ NSPasteboardTypeString ]);
-#pragma clang diagnostic pop
- }
-
- return true;
-}
-
-bool PDFPlugin::isEditingCommandEnabled(const String& commandName)
-{
- if (commandName == "copy" || commandName == "takeFindStringFromSelection")
- return [m_pdfLayerController currentSelection];
-
- if (commandName == "selectAll")
- return true;
-
- return false;
-}
-
-void PDFPlugin::setScrollOffset(const ScrollOffset& offset)
-{
- m_scrollOffset = IntSize(offset.x(), offset.y());
-
- [CATransaction begin];
- [m_pdfLayerController setScrollPosition:offset];
-
- if (m_activeAnnotation)
- m_activeAnnotation->updateGeometry();
-
- [CATransaction commit];
-}
-
-void PDFPlugin::invalidateScrollbarRect(Scrollbar& scrollbar, const IntRect& rect)
-{
- if (&scrollbar == horizontalScrollbar())
- [m_horizontalScrollbarLayer setNeedsDisplay];
- else if (&scrollbar == verticalScrollbar())
- [m_verticalScrollbarLayer setNeedsDisplay];
-}
-
-void PDFPlugin::invalidateScrollCornerRect(const IntRect& rect)
-{
- [m_scrollCornerLayer setNeedsDisplay];
-}
-
-bool PDFPlugin::isFullFramePlugin() const
-{
- // <object> or <embed> 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()->coreFrame()->document();
- return document->isPluginDocument() && static_cast<PluginDocument*>(document)->pluginWidget() == pluginView();
-}
-
-bool PDFPlugin::handlesPageScaleFactor() const
-{
- return webFrame()->isMainFrame() && isFullFramePlugin();
-}
-
-void PDFPlugin::clickedLink(NSURL *url)
-{
- URL coreURL = url;
- if (protocolIsJavaScript(coreURL))
- return;
-
- Frame* frame = webFrame()->coreFrame();
-
- RefPtr<Event> coreEvent;
- if (m_lastMouseEvent.type() != WebEvent::NoType)
- coreEvent = MouseEvent::create(eventNames().clickEvent, frame->document()->defaultView(), platform(m_lastMouseEvent), 0, 0);
-
- frame->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->commit();
-
- if (annotation) {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- if ([annotation isKindOfClass:pdfAnnotationTextWidgetClass()] && static_cast<PDFAnnotationTextWidget *>(annotation).isReadOnly) {
- m_activeAnnotation = nullptr;
- return;
- }
-#pragma clang diagnostic pop
-
- m_activeAnnotation = PDFPluginAnnotation::create(annotation, m_pdfLayerController.get(), this);
- m_activeAnnotation->attach(m_annotationContainer.get());
- } else
- m_activeAnnotation = nullptr;
-}
-
-bool PDFPlugin::supportsForms()
-{
- // FIXME: We support forms for full-main-frame and <iframe> PDFs, but not <embed> or <object>, 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()->setPageScaleFactor(scaleFactor, IntPoint());
-
- calculateSizes();
- updateScrollbars();
-}
-
-void PDFPlugin::notifyDisplayModeChanged(int)
-{
- calculateSizes();
- updateScrollbars();
-}
-
-RefPtr<SharedBuffer> 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()->page()->savePDFToFileInDownloadsFolder(m_suggestedFilename, webFrame()->url(), static_cast<const unsigned char *>([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()->page()->savePDFToTemporaryFolderAndOpenWithNativeApplication(m_suggestedFilename, webFrame()->url(), static_cast<const unsigned char *>([data bytes]), [data length], m_temporaryPDFUUID);
- return;
- }
-
- webFrame()->page()->send(Messages::WebPageProxy::OpenPDFFromTemporaryFolderWithNativeApplication(m_temporaryPDFUUID));
-}
-
-void PDFPlugin::writeItemsToPasteboard(NSString *pasteboardName, NSArray *items, NSArray *types)
-{
- Vector<String> pasteboardTypes;
-
- for (NSString *type in types)
- pasteboardTypes.append(type);
-
- uint64_t newChangeCount;
- auto& webProcess = WebProcess::singleton();
- webProcess.parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::SetPasteboardTypes(pasteboardName, pasteboardTypes),
- Messages::WebPasteboardProxy::SetPasteboardTypes::Reply(newChangeCount), 0);
-
- for (NSUInteger i = 0, count = items.count; i < 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<NSString> plainTextString = adoptNS([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
- webProcess.parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::SetPasteboardStringForType(pasteboardName, type, plainTextString.get()), Messages::WebPasteboardProxy::SetPasteboardStringForType::Reply(newChangeCount), 0);
- } else {
- RefPtr<SharedBuffer> buffer = SharedBuffer::wrapNSData(data);
-
- if (!buffer)
- continue;
-
- SharedMemory::Handle handle;
- RefPtr<SharedMemory> sharedMemory = SharedMemory::allocate(buffer->size());
- memcpy(sharedMemory->data(), buffer->data(), buffer->size());
- sharedMemory->createHandle(handle, SharedMemory::Protection::ReadOnly);
- webProcess.parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::SetPasteboardBufferForType(pasteboardName, type, handle, buffer->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()->page()->send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfo));
-}
-
-unsigned PDFPlugin::countFindMatches(const String& target, WebCore::FindOptions options, unsigned maxMatchCount)
-{
- if (!target.length())
- return 0;
-
- int nsOptions = (options & FindOptionsCaseInsensitive) ? NSCaseInsensitiveSearch : 0;
-
- return [[pdfDocument() findString:target withOptions:nsOptions] count];
-}
-
-PDFSelection *PDFPlugin::nextMatchForString(const String& 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<PDFSelection> 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 >= 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 && [foundSelection isEqual:initialSelection])
- foundSelection = [document findString:target fromSelection:initialSelection withOptions:options];
-
- if (!foundSelection && wrapSearch) {
- auto emptySelection = adoptNS([[pdfSelectionClass() alloc] initWithDocument:document]);
- foundSelection = [document findString:target fromSelection:emptySelection.get() withOptions:options];
- }
-
- return foundSelection;
-}
-
-bool PDFPlugin::findString(const String& target, WebCore::FindOptions options, unsigned maxMatchCount)
-{
- BOOL searchForward = !(options & FindOptionsBackwards);
- BOOL caseSensitive = !(options & FindOptionsCaseInsensitive);
- BOOL wrapSearch = options & 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<unsigned>(kWKMoreThanMaximumMatchCount);
- } else {
- matchCount = countFindMatches(target, options, maxMatchCount);
- if (matchCount > maxMatchCount)
- matchCount = static_cast<unsigned>(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 > 0;
-}
-
-bool PDFPlugin::performDictionaryLookupAtLocation(const WebCore::FloatPoint& 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()->page()->didChangeSelection();
-}
-
-static const Cursor& 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()->page()->send(Messages::WebPageProxy::SetCursor(pdfLayerControllerCursorTypeToCursor(static_cast<PDFLayerControllerCursorType>(type))));
-}
-
-String PDFPlugin::getSelectionString() const
-{
- return [[m_pdfLayerController currentSelection] string];
-}
-
-String PDFPlugin::getSelectionForWordAtPoint(const WebCore::FloatPoint& 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& 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 >= 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& locationInViewCoordinates, WebHitTestResultData& data, PDFSelection **selectionPtr, NSDictionary **options) const
-{
- PDFSelection*& 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 "";
-
- 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 "-Wdeprecated-declarations"
- 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 "";
-
- [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()->page()->send(Messages::WebPageProxy::SearchTheWeb(string));
-}
-
-void PDFPlugin::performSpotlightSearch(NSString *string)
-{
- webFrame()->page()->send(Messages::WebPageProxy::SearchWithSpotlight(string));
-}
-
-bool PDFPlugin::handleWheelEvent(const WebWheelEvent& 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 "clicky" scroll wheels can flip pages.
- if (!event.hasPreciseScrollingDeltas())
- scrollMagnitudeThresholdForPageFlip = 0;
-
- if (atScrollBottom && !inLastPage && event.delta().height() < 0) {
- if (event.delta().height() <= -scrollMagnitudeThresholdForPageFlip && !inMomentumScroll)
- [m_pdfLayerController gotoNextPage];
- return true;
- }
-
- if (atScrollTop && !inFirstPage && event.delta().height() > 0) {
- if (event.delta().height() >= scrollMagnitudeThresholdForPageFlip && !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->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 "PDFKitImports.h"
-
</del><span class="cx"> #if ENABLE(PDFKIT_PLUGIN)
</span><del>-#if USE(DEPRECATED_PDF_PLUGIN)
</del><span class="cx">
</span><del>-#include "DeprecatedPDFLayerControllerSPI.h"
-
-#else // USE(DEPRECATED_PDF_PLUGIN)
-
</del><span class="cx"> #import <PDFKit/PDFKit.h>
</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 <NSObject>
</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<PDFLayerControllerDelegate> delegate;
-@property (retain) NSArray *searchMatches;
</del><ins>+@property (retain) id<PDFLayerControllerDelegate> 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 "PDFKitImports.h"
</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 "DeprecatedPDFPlugin.h"
-
-#else // USE(DEPRECATED_PDF_PLUGIN)
-
</del><span class="cx"> #include "Plugin.h"
</span><span class="cx"> #include "WebEvent.h"
</span><span class="cx"> #include "WebHitTestResultData.h"
</span><span class="cx"> #include <WebCore/AffineTransform.h>
</span><span class="cx"> #include <WebCore/FindOptions.h>
</span><del>-#include <WebCore/PageOverlay.h>
</del><span class="cx"> #include <WebCore/ScrollableArea.h>
</span><span class="cx"> #include <wtf/RetainPtr.h>
</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<PDFPlugin> 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& password);
</span><span class="cx">
</span><del>- WebCore::IntPoint convertFromPluginToPDFView(const WebCore::IntPoint&) const;
- WebCore::IntPoint convertFromRootViewToPlugin(const WebCore::IntPoint&) const;
- WebCore::IntPoint convertFromPDFViewToRootView(const WebCore::IntPoint&) const;
-
- WebCore::IntRect convertFromPDFViewToRootView(const WebCore::IntRect&) const;
</del><span class="cx"> WebCore::FloatRect convertFromPDFViewToScreen(const WebCore::FloatRect&) const;
</span><del>-
</del><span class="cx"> WebCore::IntRect boundsOnScreen() const;
</span><span class="cx">
</span><span class="cx"> bool showContextMenuAtPoint(const WebCore::IntPoint&);
</span><span class="lines">@@ -125,10 +110,9 @@
</span><span class="cx"> String lookupTextAtLocation(const WebCore::FloatPoint&, WebHitTestResultData&, 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&) override;
</span><span class="cx"> void destroy() override;
</span><del>- void paint(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRectInWindowCoordinates) override;
- void updateControlTints(WebCore::GraphicsContext&) override { }
- bool supportsSnapshotting() const override { return false; }
</del><ins>+ void paint(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRectInWindowCoordinates) override { }
+ void updateControlTints(WebCore::GraphicsContext&) override;
+ bool supportsSnapshotting() const override { return true; }
</ins><span class="cx"> RefPtr<ShareableBitmap> 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& pluginSize, const WebCore::IntRect& clipRect, const WebCore::AffineTransform& 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&) override;
</span><del>- bool handleWheelEvent(const WebWheelEvent&) override { return false; }
</del><ins>+ bool handleWheelEvent(const WebWheelEvent&) override;
</ins><span class="cx"> bool handleMouseEnterEvent(const WebMouseEvent&) override;
</span><span class="cx"> bool handleMouseLeaveEvent(const WebMouseEvent&) override;
</span><span class="cx"> bool handleContextMenuEvent(const WebMouseEvent&) override;
</span><del>- bool handleKeyboardEvent(const WebKeyboardEvent&) override { return false; }
</del><ins>+ bool handleKeyboardEvent(const WebKeyboardEvent&) override;
</ins><span class="cx"> bool handleEditingCommand(const String& commandName, const String& argument) override;
</span><span class="cx"> bool isEditingCommandEnabled(const String&) 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& windowFrameInScreenCoordinates, const WebCore::IntRect& 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& 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& 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<WebCore::SharedBuffer> 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<PDFDocument> 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&) override;
+ void invalidateScrollbarRect(WebCore::Scrollbar&, const WebCore::IntRect&) override;
+ void invalidateScrollCornerRect(const WebCore::IntRect&) 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&, const WebCore::IntRect& scrollbarRect) const override;
+ WebCore::IntRect convertFromContainingViewToScrollbar(const WebCore::Scrollbar&, const WebCore::IntRect& parentRect) const override;
+ WebCore::IntPoint convertFromScrollbarToContainingView(const WebCore::Scrollbar&, const WebCore::IntPoint& scrollbarPoint) const override;
+ WebCore::IntPoint convertFromContainingViewToScrollbar(const WebCore::Scrollbar&, const WebCore::IntPoint& parentPoint) const override;
+ bool forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const override;
+
</ins><span class="cx"> // PDFPlugin functions.
</span><ins>+ void updateScrollbars();
+ Ref<WebCore::Scrollbar> 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&);
</span><del>-
</del><ins>+ WebCore::IntPoint convertFromPluginToPDFView(const WebCore::IntPoint&) const;
+ WebCore::IntPoint convertFromRootViewToPlugin(const WebCore::IntPoint&) const;
+ WebCore::IntPoint convertFromPDFViewToRootView(const WebCore::IntPoint&) 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<PDFDocument> 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 < 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&, UpdateCursor = UpdateCursor::IfNeeded);
</del><ins>+ void updateCursor(const WebMouseEvent&, 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& 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&, WebCore::Page*) override;
- void didMoveToPage(WebCore::PageOverlay&, WebCore::Page*) override;
- void drawRect(WebCore::PageOverlay&, WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect) override;
- bool mouseEvent(WebCore::PageOverlay&, const WebCore::PlatformMouseEvent&) override;
-
- WebCore::IntRect frameInRootView() const;
-
- bool m_visible { false };
- Ref<WebCore::PageOverlay> m_overlay;
- PDFPlugin& m_plugin;
- };
-
- WebFrame* m_frame;
-
- bool m_isPostScript { false };
- bool m_pdfDocumentWasMutated { false };
- bool m_usingContinuousMode { true };
-
</del><ins>+ RetainPtr<CALayer> m_containerLayer;
+ RetainPtr<CALayer> m_contentLayer;
+ RetainPtr<CALayer> m_horizontalScrollbarLayer;
+ RetainPtr<CALayer> m_verticalScrollbarLayer;
+ RetainPtr<CALayer> m_scrollCornerLayer;
</ins><span class="cx"> RetainPtr<PDFLayerController> m_pdfLayerController;
</span><span class="cx"> RetainPtr<WKPDFPluginAccessibilityObject> m_accessibilityObject;
</span><del>-
</del><ins>+
</ins><span class="cx"> RefPtr<PDFPluginAnnotation> m_activeAnnotation;
</span><span class="cx"> RefPtr<PDFPluginPasswordField> m_passwordField;
</span><del>- RefPtr<WebCore::Element> m_passwordContainer;
</del><ins>+ RefPtr<WebCore::Element> 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 < 101300
</ins><span class="cx"> HitTestResult m_lastHitTestResult;
</span><del>-
</del><ins>+#endif
+
</ins><span class="cx"> RetainPtr<WKPDFLayerControllerDelegate> 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<CFMutableDataRef> m_data;
</span><span class="cx">
</span><span class="cx"> RetainPtr<PDFDocument> m_pdfDocument;
</span><ins>+ Vector<WebCore::IntRect> 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<WebCore::Scrollbar> m_horizontalScrollbar;
+ RefPtr<WebCore::Scrollbar> 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 "config.h"
</span><span class="cx"> #import "PDFPlugin.h"
</span><span class="cx">
</span><del>-#if ENABLE(PDFKIT_PLUGIN) && !USE(DEPRECATED_PDF_PLUGIN)
</del><ins>+#if ENABLE(PDFKIT_PLUGIN)
</ins><span class="cx">
</span><span class="cx"> #import "ArgumentCoders.h"
</span><span class="cx"> #import "DataReference.h"
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx"> #import <WebCore/Cursor.h>
</span><span class="cx"> #import <WebCore/DictionaryLookup.h>
</span><span class="cx"> #import <WebCore/DocumentLoader.h>
</span><ins>+#import <WebCore/EventNames.h>
</ins><span class="cx"> #import <WebCore/FocusController.h>
</span><span class="cx"> #import <WebCore/FormState.h>
</span><span class="cx"> #import <WebCore/Frame.h>
</span><span class="lines">@@ -61,7 +62,6 @@
</span><span class="cx"> #import <WebCore/FrameLoader.h>
</span><span class="cx"> #import <WebCore/FrameView.h>
</span><span class="cx"> #import <WebCore/GraphicsContext.h>
</span><del>-#import <WebCore/GraphicsLayerCA.h>
</del><span class="cx"> #import <WebCore/HTMLElement.h>
</span><span class="cx"> #import <WebCore/HTMLFormElement.h>
</span><span class="cx"> #import <WebCore/HTMLPlugInElement.h>
</span><span class="lines">@@ -69,32 +69,35 @@
</span><span class="cx"> #import <WebCore/MainFrame.h>
</span><span class="cx"> #import <WebCore/MouseEvent.h>
</span><span class="cx"> #import <WebCore/Page.h>
</span><del>-#import <WebCore/PageOverlayController.h>
</del><span class="cx"> #import <WebCore/Pasteboard.h>
</span><del>-#import <WebCore/PlatformCAAnimationCocoa.h>
</del><span class="cx"> #import <WebCore/PluginData.h>
</span><span class="cx"> #import <WebCore/PluginDocument.h>
</span><span class="cx"> #import <WebCore/RenderBoxModelObject.h>
</span><ins>+#import <WebCore/ScrollAnimator.h>
+#import <WebCore/ScrollbarTheme.h>
</ins><span class="cx"> #import <WebCore/Settings.h>
</span><span class="cx"> #import <WebCore/UUID.h>
</span><ins>+#import <WebCore/WheelEventTestTrigger.h>
</ins><span class="cx"> #import <WebKitSystemInterface.h>
</span><span class="cx"> #import <wtf/CurrentTime.h>
</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 <input> 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>-"body { "
-" background-color: rgb(146, 146, 146) !important;"
-"} "
-"#passwordContainer {"
-" display: -webkit-box; "
-" -webkit-box-align: center; "
-" -webkit-box-pack: center; "
-" position: fixed; "
</del><ins>+"#annotationContainer {"
+" overflow: hidden; "
+" position: absolute; "
+" pointer-events: none; "
</ins><span class="cx"> " top: 0; "
</span><span class="cx"> " left: 0; "
</span><span class="cx"> " right: 0; "
</span><span class="cx"> " bottom: 0; "
</span><ins>+" display: -webkit-box; "
+" -webkit-box-align: center; "
+" -webkit-box-pack: center; "
</ins><span class="cx"> "} "
</span><span class="cx"> ".annotation { "
</span><span class="cx"> " position: absolute; "
</span><span class="lines">@@ -109,7 +112,9 @@
</span><span class="cx"> " margin-top: 100px; "
</span><span class="cx"> "} ";
</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 >= 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<CAAction>)actionForKey:(NSString *)key
+{
+ return nil;
+}
+
+- (void)drawInContext:(CGContextRef)ctx
+{
+ _pdfPlugin->paintControlForLayerInContext(self, ctx);
+}
+
+@end
+
</ins><span class="cx"> @interface WKPDFLayerControllerDelegate : NSObject<PDFLayerControllerDelegate> {
</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->scrollToPoint(IntPoint(newPosition));
</del><ins>+ _pdfPlugin->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 "-Wdeprecated-declarations"
</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->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->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->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->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->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->clickedLink(url);
</span><span class="cx"> }
</span><span class="lines">@@ -341,6 +381,11 @@
</span><span class="cx"> _pdfPlugin->setActiveAnnotation(annotation);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeContentScaleFactor:(CGFloat)scaleFactor
+{
+ _pdfPlugin->notifyContentScaleFactorChanged(scaleFactor);
+}
+
</ins><span class="cx"> - (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeDisplayMode:(int)mode
</span><span class="cx"> {
</span><span class="cx"> _pdfPlugin->notifyDisplayModeChanged(mode);
</span><span class="lines">@@ -351,52 +396,13 @@
</span><span class="cx"> _pdfPlugin->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->invalidatePDFRect(enclosingIntRect(rect));
</del><ins>+ _pdfPlugin->notifyCursorChanged(cursorType);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)pdfLayerControllerInvalidateHUD:(PDFLayerController *)pdfLayerController
-{
- _pdfPlugin->invalidateHUD();
-}
-
-- (void)pdfLayerControllerZoomIn:(PDFLayerController *)pdfLayerController
-{
- _pdfPlugin->zoomIn();
-}
-
-- (void)pdfLayerControllerZoomOut:(PDFLayerController *)pdfLayerController
-{
- _pdfPlugin->zoomOut();
-}
-
</del><span class="cx"> @end
</span><span class="cx">
</span><del>-@interface WKPDFHUDAnimationDelegate : NSObject {
- std::function<void (bool)> _completionHandler;
-}
-@end
-
-@implementation WKPDFHUDAnimationDelegate
-
-- (id)initWithAnimationCompletionHandler:(std::function<void (bool)>)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()->coreFrame()->document();
</span><ins>+ m_annotationContainer = document->createElement(divTag, false);
+ m_annotationContainer->setAttributeWithoutSynchronization(idAttr, AtomicString("annotationContainer", AtomicString::ConstructFromLiteral));
</ins><span class="cx">
</span><del>- Ref<Element> annotationStyleElement = document->createElement(styleTag, false);
- annotationStyleElement->setTextContent(annotationStyle, ASSERT_NO_EXCEPTION);
</del><ins>+ auto annotationStyleElement = document->createElement(styleTag, false);
+ annotationStyleElement->setTextContent(annotationStyle);
</ins><span class="cx">
</span><del>- document->bodyOrFrameset()->appendChild(annotationStyleElement.get());
</del><ins>+ m_annotationContainer->appendChild(annotationStyleElement);
+ document->bodyOrFrameset()->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()->page()->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() >= m_pdfDocumentSize.width())
+ destroyScrollbar(HorizontalScrollbar);
+ } else if (m_size.width() < m_pdfDocumentSize.width())
+ m_horizontalScrollbar = createScrollbar(HorizontalScrollbar);
+
+ if (m_verticalScrollbar) {
+ if (m_size.height() >= m_pdfDocumentSize.height())
+ destroyScrollbar(VerticalScrollbar);
+ } else if (m_size.height() < 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->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
+ m_horizontalScrollbar->setProportion(m_size.width() - scrollbarSpace.width(), m_pdfDocumentSize.width());
+ IntRect scrollbarRect(pluginView()->x(), pluginView()->y() + m_size.height() - m_horizontalScrollbar->height(), m_size.width(), m_horizontalScrollbar->height());
+ if (m_verticalScrollbar)
+ scrollbarRect.contract(m_verticalScrollbar->width(), 0);
+ m_horizontalScrollbar->setFrameRect(scrollbarRect);
+ }
+ if (m_verticalScrollbar) {
+ m_verticalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
+ m_verticalScrollbar->setProportion(m_size.height() - scrollbarSpace.height(), m_pdfDocumentSize.height());
+ IntRect scrollbarRect(IntRect(pluginView()->x() + m_size.width() - m_verticalScrollbar->width(), pluginView()->y(), m_verticalScrollbar->width(), m_size.height()));
+ if (m_horizontalScrollbar)
+ scrollbarRect.contract(0, m_horizontalScrollbar->height());
+ m_verticalScrollbar->setFrameRect(scrollbarRect);
+ }
+
+ FrameView* frameView = m_frame->coreFrame()->view();
+ if (!frameView)
+ return;
+
+ bool hasScrollbars = m_horizontalScrollbar || m_verticalScrollbar;
+ if (hadScrollbars != hasScrollbars) {
+ if (hasScrollbars)
+ frameView->addScrollableArea(this);
+ else
+ frameView->removeScrollableArea(this);
+
+ frameView->setNeedsLayout();
+ }
+
+ if (m_verticalScrollbarLayer) {
+ m_verticalScrollbarLayer.get().frame = verticalScrollbar()->frameRect();
+ [m_verticalScrollbarLayer setNeedsDisplay];
+ }
+
+ if (m_horizontalScrollbarLayer) {
+ m_horizontalScrollbarLayer.get().frame = horizontalScrollbar()->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<PluginView*>(controller());
</span><span class="lines">@@ -573,6 +657,176 @@
</span><span class="cx"> return static_cast<const PluginView*>(controller());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+Ref<Scrollbar> 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()->coreFrame()) {
+ if (Page* page = frame->page()) {
+ if (page->expectsWheelEventTriggers())
+ scrollAnimator().setWheelEventTestTrigger(page->testTrigger());
+ }
+ }
+ pluginView()->frame()->view()->addChild(widget);
+ return widget;
+}
+
+void PDFPlugin::destroyScrollbar(ScrollbarOrientation orientation)
+{
+ RefPtr<Scrollbar>& scrollbar = orientation == HorizontalScrollbar ? m_horizontalScrollbar : m_verticalScrollbar;
+ if (!scrollbar)
+ return;
+
+ willRemoveScrollbar(scrollbar.get(), orientation);
+ scrollbar->removeFromParent();
+ scrollbar = nullptr;
+
+ if (orientation == HorizontalScrollbar) {
+ [m_horizontalScrollbarLayer removeFromSuperlayer];
+ m_horizontalScrollbarLayer = 0;
+ } else {
+ [m_verticalScrollbarLayer removeFromSuperlayer];
+ m_verticalScrollbarLayer = 0;
+ }
+}
+
+IntRect PDFPlugin::convertFromScrollbarToContainingView(const Scrollbar& scrollbar, const IntRect& scrollbarRect) const
+{
+ IntRect rect = scrollbarRect;
+ rect.move(scrollbar.location() - pluginView()->location());
+
+ return pluginView()->frame()->view()->convertFromRendererToContainingView(pluginView()->pluginElement()->renderer(), rect);
+}
+
+IntRect PDFPlugin::convertFromContainingViewToScrollbar(const Scrollbar& scrollbar, const IntRect& parentRect) const
+{
+ IntRect rect = pluginView()->frame()->view()->convertFromContainingViewToRenderer(pluginView()->pluginElement()->renderer(), parentRect);
+ rect.move(pluginView()->location() - scrollbar.location());
+
+ return rect;
+}
+
+IntPoint PDFPlugin::convertFromScrollbarToContainingView(const Scrollbar& scrollbar, const IntPoint& scrollbarPoint) const
+{
+ IntPoint point = scrollbarPoint;
+ point.move(scrollbar.location() - pluginView()->location());
+
+ return pluginView()->frame()->view()->convertFromRendererToContainingView(pluginView()->pluginElement()->renderer(), point);
+}
+
+IntPoint PDFPlugin::convertFromContainingViewToScrollbar(const Scrollbar& scrollbar, const IntPoint& parentPoint) const
+{
+ IntPoint point = pluginView()->frame()->view()->convertFromContainingViewToRenderer(pluginView()->pluginElement()->renderer(), parentPoint);
+ point.move(pluginView()->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->isOverlayScrollbar()) {
+ ASSERT(m_verticalScrollbar->isOverlayScrollbar());
+ return IntRect();
+ }
+ return IntRect(pluginView()->width() - m_verticalScrollbar->width(), pluginView()->height() - m_horizontalScrollbar->height(), m_verticalScrollbar->width(), m_horizontalScrollbar->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()->frameRect();
+}
+
+int PDFPlugin::scrollSize(ScrollbarOrientation orientation) const
+{
+ Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_horizontalScrollbar : m_verticalScrollbar).get();
+ return scrollbar ? (scrollbar->totalSize() - scrollbar->visibleSize()) : 0;
+}
+
+bool PDFPlugin::isActive() const
+{
+ if (Frame* coreFrame = m_frame->coreFrame()) {
+ if (Page* page = coreFrame->page())
+ return page->focusController().isActive();
+ }
+
+ return false;
+}
+
+bool PDFPlugin::forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const
+{
+ if (Frame* coreFrame = m_frame->coreFrame()) {
+ if (Page* page = coreFrame->page())
+ return page->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<ArchiveResource> resource = ArchiveResource::create(SharedBuffer::wrapCFData(m_data.get()), m_sourceURL, "application/pdf", String(), String(), synthesizedResponse);
</span><del>- pluginView()->frame()->document()->loader()->addArchiveResource(resource.release());
</del><ins>+ pluginView()->frame()->document()->loader()->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->chrome().print(coreFrame);
</del><ins>+ page->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()->coreFrame()->view()->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()->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&, uint32_t, uint32_t, const String& mimeType, const String&, const String& 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->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()->coreFrame()->document();
- m_passwordContainer = document->createElement(divTag, false);
- m_passwordContainer->setAttributeWithoutSynchronization(idAttr, AtomicString("passwordContainer", AtomicString::ConstructFromLiteral));
-
</del><span class="cx"> m_passwordField = PDFPluginPasswordField::create(m_pdfLayerController.get(), this);
</span><del>- m_passwordField->attach(m_passwordContainer.get());
- document->bodyOrFrameset()->appendChild(*m_passwordContainer);
</del><ins>+ m_passwordField->attach(m_annotationContainer.get());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PDFPlugin::attemptToUnlockPDF(const String& 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()->contentsScaleFactor();
+ if (!handlesPageScaleFactor())
+ newScaleFactor *= webFrame()->page()->pageScaleFactor();
</ins><span class="cx">
</span><del>- // We have to asynchronously update styles because we could be inside layout.
- RefPtr<PDFPlugin> reffedThis = this;
- dispatch_async(dispatch_get_main_queue(), [reffedThis] {
- reffedThis->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<PluginDocument>(*webFrame()->coreFrame()->document()).pluginElement();
</del><ins>+ updatePageAndDeviceScaleFactors();
+}
</ins><span class="cx">
</span><del>- if (isLocked()) {
- pluginElement->setInlineStyleProperty(CSSPropertyWidth, 100, CSSPrimitiveValue::CSS_PERCENTAGE);
- pluginElement->setInlineStyleProperty(CSSPropertyHeight, 100, CSSPrimitiveValue::CSS_PERCENTAGE);
</del><ins>+void PDFPlugin::computePageBoxes()
+{
+ size_t pageCount = CGPDFDocumentGetNumberOfPages([m_pdfDocument documentRef]);
+ for (size_t i = 0; i < 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->setInlineStyleProperty(CSSPropertyWidth, m_pdfDocumentSize.width(), CSSPrimitiveValue::CSS_PX);
- pluginElement->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& 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()->coreFrame()->view())
+ frameView->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()->coreFrame()->view())
+ frameView->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& context, const IntRect& dirtyRectInWindowCoordinates)
</del><ins>+void PDFPlugin::updateControlTints(GraphicsContext& 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->invalidate();
+ if (m_verticalScrollbar)
+ m_verticalScrollbar->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->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->x(), -scrollbar->y());
+ scrollbar->paint(graphicsContext, scrollbar->frameRect());
+}
+
</ins><span class="cx"> RefPtr<ShareableBitmap> PDFPlugin::snapshot()
</span><span class="cx"> {
</span><del>- return nullptr;
</del><ins>+ if (size().isEmpty())
+ return nullptr;
+
+ float contentsScaleFactor = controller()->contentsScaleFactor();
+ IntSize backingStoreSize = size();
+ backingStoreSize.scale(contentsScaleFactor);
+
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha);
+ auto context = bitmap->createGraphicsContext();
+
+ context->scale(FloatSize(contentsScaleFactor, -contentsScaleFactor));
+ context->translate(-m_scrollOffset.width(), -m_pdfDocumentSize.height() + m_scrollOffset.height());
+
+ [m_pdfLayerController snapshotInContext:context->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& 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& point) const
</span><span class="lines">@@ -887,8 +1203,8 @@
</span><span class="cx">
</span><span class="cx"> IntPoint PDFPlugin::convertFromPDFViewToRootView(const IntPoint& 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& 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->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->contentsToScreen(enclosingIntRect(rectInRootViewCoordinates));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PDFPlugin::geometryDidChange(const IntSize& pluginSize, const IntRect&, const AffineTransform& pluginToRootViewTransform)
</span><span class="cx"> {
</span><del>- m_pluginToRootViewTransform = pluginToRootViewTransform;
</del><ins>+ if (size() == pluginSize && pluginView()->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()->coreFrame()->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()->pageScaleFactor() - [m_pdfLayerController contentScaleFactor];
</ins><span class="cx">
</span><del>- [m_pdfLayerController setFrameSize:frameView->frameRect().size()];
- [m_pdfLayerController setVisibleRect:frameView->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->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& 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& event, NSEventType& 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<const WebMouseEvent&>(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& 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& event, UpdateCursor mode)
</del><ins>+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
+void PDFPlugin::updateCursor(const WebMouseEvent& 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 && [[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 && [[selectionUnderMouse string] length])
- hitTestResult = HitTestResult::Text;
- }
-
- if (hitTestResult == m_lastHitTestResult && mode == UpdateCursor::IfNeeded)
</del><ins>+ if (hitTestResult == m_lastHitTestResult && mode == UpdateIfNeeded)
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- const Cursor& cursor = [hitTestResult] {
- switch (hitTestResult) {
- case HitTestResult::None:
- return pointerCursor();
- case HitTestResult::Text:
- return iBeamCursor();
- case HitTestResult::HUD:
- return pointerCursor();
- };
- }();
-
- webFrame()->page()->send(Messages::WebPageProxy::SetCursor(cursor));
</del><ins>+ webFrame()->page()->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& 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<Scrollbar> targetScrollbar;
+ RefPtr<Scrollbar> 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 && 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 && 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 < 101300
</ins><span class="cx"> updateCursor(event);
</span><del>- [m_pdfLayerController mouseDragged:nsEvent];
- return true;
</del><ins>+#endif
+
+ if (targetScrollbar) {
+ if (!targetScrollbarForLastMousePosition) {
+ targetScrollbar->mouseEntered();
+ return true;
+ }
+ return targetScrollbar->mouseMoved(platformEvent);
+ }
+
+ if (!targetScrollbar && targetScrollbarForLastMousePosition)
+ targetScrollbarForLastMousePosition->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->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->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& event)
</span><span class="cx"> {
</span><del>- updateCursor(event, UpdateCursor::Force);
</del><ins>+ mouseEnteredContentArea();
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 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&)
</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()->coreFrame()->view();
</span><span class="cx"> IntPoint contentsPoint = frameView->contentsToRootView(point);
</span><del>- WebMouseEvent event(WebEvent::MouseDown, WebMouseEvent::RightButton, contentsPoint, contentsPoint, 0, 0, 0, 1, static_cast<WebEvent::Modifiers>(0), monotonicallyIncreasingTime(), ForceAtClick);
</del><ins>+ WebMouseEvent event(WebEvent::MouseDown, WebMouseEvent::RightButton, contentsPoint, contentsPoint, 0, 0, 0, 1, static_cast<WebEvent::Modifiers>(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& 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& commandName, const String& argument)
</span><span class="cx"> {
</span><span class="cx"> if (commandName == "copy")
</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& offset)
+{
+ m_scrollOffset = IntSize(offset.x(), offset.y());
+
+ [CATransaction begin];
+ [m_pdfLayerController setScrollPosition:offset];
+
+ if (m_activeAnnotation)
+ m_activeAnnotation->updateGeometry();
+
+ [CATransaction commit];
+}
+
+void PDFPlugin::invalidateScrollbarRect(Scrollbar& scrollbar, const IntRect& rect)
+{
+ if (&scrollbar == horizontalScrollbar())
+ [m_horizontalScrollbarLayer setNeedsDisplay];
+ else if (&scrollbar == verticalScrollbar())
+ [m_verticalScrollbarLayer setNeedsDisplay];
+}
+
+void PDFPlugin::invalidateScrollCornerRect(const IntRect& rect)
+{
+ [m_scrollCornerLayer setNeedsDisplay];
+}
+
</ins><span class="cx"> bool PDFPlugin::isFullFramePlugin() const
</span><span class="cx"> {
</span><span class="cx"> // <object> or <embed> 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->isPluginDocument() && static_cast<PluginDocument*>(document)->pluginWidget() == pluginView();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool PDFPlugin::handlesPageScaleFactor() const
+{
+ return webFrame()->isMainFrame() && 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->commit();
</span><span class="cx">
</span><span class="cx"> if (annotation) {
</span><ins>+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
</ins><span class="cx"> if ([annotation isKindOfClass:pdfAnnotationTextWidgetClass()] && static_cast<PDFAnnotationTextWidget *>(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()->coreFrame()->document();
- m_activeAnnotation->attach(document->bodyOrFrameset());
</del><ins>+ m_activeAnnotation->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()->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<SharedBuffer> 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()->page()->savePDFToTemporaryFolderAndOpenWithNativeApplication(m_suggestedFilename, webFrame()->url(), static_cast<const unsigned char *>([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<PDFSelection> 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 >= 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 && [foundSelection isEqual:initialSelection])
</span><span class="cx"> foundSelection = [document findString:target fromSelection:initialSelection withOptions:options];
</span><span class="cx">
</span><del>- if (!foundSelection && wrapSearch)
- foundSelection = [document findString:target fromSelection:nil withOptions:options];
</del><ins>+ if (!foundSelection && 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 > 0;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool PDFPlugin::performDictionaryLookupAtLocation(const FloatPoint& point)
</del><ins>+bool PDFPlugin::performDictionaryLookupAtLocation(const WebCore::FloatPoint& 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()->page()->didChangeSelection();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static const Cursor& 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()->page()->send(Messages::WebPageProxy::SetCursor(pdfLayerControllerCursorTypeToCursor(static_cast<PDFLayerControllerCursorType>(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& point) const
</del><ins>+String PDFPlugin::getSelectionForWordAtPoint(const WebCore::FloatPoint& 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& locationInViewCoordinates) const
</del><ins>+bool PDFPlugin::existingSelectionContainsPoint(const WebCore::FloatPoint& 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& locationInViewCoordinates, WebHitTestResultData& data, PDFSelection **selectionPtr, NSDictionary **options) const
</del><ins>+String PDFPlugin::lookupTextAtLocation(const WebCore::FloatPoint& locationInViewCoordinates, WebHitTestResultData& data, PDFSelection **selectionPtr, NSDictionary **options) const
</ins><span class="cx"> {
</span><span class="cx"> PDFSelection*& 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 "-Wdeprecated-declarations"
</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()->page()->send(Messages::WebPageProxy::SearchTheWeb(string));
</span><span class="lines">@@ -1560,204 +2049,65 @@
</span><span class="cx"> webFrame()->page()->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& event)
</ins><span class="cx"> {
</span><del>- if (m_activeAnnotation)
- m_activeAnnotation->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()->frame();
- float scale = frame->page()->pageScaleFactor();
- scrollPoint.scale(scale);
- frame->view()->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()->frame();
- return frame->page()->pageScaleFactor();
-}
</del><ins>+ bool inMomentumScroll = event.momentumPhase() != WebWheelEvent::PhaseNone;
</ins><span class="cx">
</span><del>-void PDFPlugin::zoomIn()
-{
- if (webFrame()->isMainFrame() && isFullFramePlugin()) {
- WebPage* page = webFrame()->page();
- page->scalePage(page->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 "clicky" scroll wheels can flip pages.
+ if (!event.hasPreciseScrollingDeltas())
+ scrollMagnitudeThresholdForPageFlip = 0;
+
+ if (atScrollBottom && !inLastPage && event.delta().height() < 0) {
+ if (event.delta().height() <= -scrollMagnitudeThresholdForPageFlip && !inMomentumScroll)
+ [m_pdfLayerController gotoNextPage];
+ return true;
</ins><span class="cx"> }
</span><del>-}
</del><span class="cx">
</span><del>-void PDFPlugin::zoomOut()
-{
- if (webFrame()->isMainFrame() && isFullFramePlugin()) {
- WebPage* page = webFrame()->page();
- page->scalePage(page->pageScaleFactor() / zoomButtonScaleMultiplier, IntPoint());
- } else {
- [m_pdfLayerController setContentScaleFactor:[m_pdfLayerController contentScaleFactor] / zoomButtonScaleMultiplier];
- calculateSizes();
</del><ins>+ if (atScrollTop && !inFirstPage && event.delta().height() > 0) {
+ if (event.delta().height() >= scrollMagnitudeThresholdForPageFlip && !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& 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->setNeedsSynchronousScrolling(!webFrame->isMainFrame());
-
- MainFrame& mainFrame = webFrame->coreFrame()->mainFrame();
- mainFrame.pageOverlayController().installPageOverlay(m_overlay.ptr(), PageOverlay::FadeMode::DoNotFade);
- m_overlay->setNeedsDisplay();
-
- RefPtr<PlatformCALayer> platformCALayer = downcast<GraphicsLayerCA>(m_overlay->layer()).platformCALayer();
- platformCALayer->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& mainFrame = m_plugin.webFrame()->coreFrame()->mainFrame();
- mainFrame.pageOverlayController().uninstallPageOverlay(m_overlay.ptr(), PageOverlay::FadeMode::DoNotFade);
-}
</del><ins>+ if (m_activeAnnotation)
+ m_activeAnnotation->commit();
</ins><span class="cx">
</span><del>-void PDFPlugin::HUD::willMoveToPage(PageOverlay&, 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&, 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()->coreFrame()->view();
- IntRect frameRectInRootView = frameView->convertToRootView(frameView->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&, GraphicsContext& context, const IntRect& dirtyRect)
-{
- IntRect frameInRootView = this->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->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<PlatformCALayer> platformCALayer = downcast<GraphicsLayerCA>(m_overlay->layer()).platformCALayer();
-
- if (animateTransition == AnimateVisibilityTransition::No) {
- platformCALayer->removeAnimationForKey("HUDFade");
- platformCALayer->setOpacity(toValue);
- return;
- }
-
- float duration = m_visible ? 0.25 : 0.5;
-
- RetainPtr<CABasicAnimation> fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
- [fadeAnimation setDuration:duration];
- [fadeAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
- [fadeAnimation setDelegate:[[[WKPDFHUDAnimationDelegate alloc] initWithAnimationCompletionHandler:[platformCALayer, toValue] (bool completed) {
- if (completed)
- platformCALayer->setOpacity(toValue);
-
- }] autorelease]];
- [fadeAnimation setFromValue:@(((CALayer *)platformCALayer->platformLayer().presentationLayer).opacity)];
- [fadeAnimation setToValue:@(toValue)];
-
- RefPtr<PlatformCAAnimation> animation = PlatformCAAnimationCocoa::create(fadeAnimation.get());
- platformCALayer->removeAnimationForKey("HUDFade");
- platformCALayer->addAnimationForKey("HUDFade", *animation);
-}
-
-bool PDFPlugin::HUD::mouseEvent(PageOverlay&, const PlatformMouseEvent& 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 = [&](NSEventType eventType) -> 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<StyledElement*>(element());
</span><span class="cx"> styledElement->setInlineStyleProperty(CSSPropertyWidth, annotationRect.size.width, CSSPrimitiveValue::CSS_PX);
</span><span class="cx"> styledElement->setInlineStyleProperty(CSSPropertyHeight, annotationRect.size.height, CSSPrimitiveValue::CSS_PX);
</span><del>-#if !USE(DEPRECATED_PDF_PLUGIN)
- styledElement->setInlineStyleProperty(CSSPropertyLeft, annotationRect.origin.x, CSSPrimitiveValue::CSS_PX);
- styledElement->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->setInlineStyleProperty(CSSPropertyLeft, annotationRect.origin.x - scrollPosition.x(), CSSPrimitiveValue::CSS_PX);
</span><span class="cx"> styledElement->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>