<!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>[183277] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/183277">183277</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2015-04-24 12:33:10 -0700 (Fri, 24 Apr 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Immediate action not functional for embedded PDFs
https://bugs.webkit.org/show_bug.cgi?id=143952
<rdar://problem/19842365>
Reviewed by Tim Horton.
Source/WebCore:
Add a dictionary lookup method to allow us to retrieve
relevant information for PDFs.
* editing/mac/DictionaryLookup.mm:
(WebCore::dictionaryLookupForPDFSelection): Updated to properly handle cases
where the Lookup engine selects a smaller range than the initial automatic
selection performed on clicking.
Source/WebKit2:
Add a new method to retrieve appropriate dictionary lookup content and update the
hit test result with relevant dictionary content and the bounding rect of the
selection.
* WebProcess/Plugins/Netscape/NetscapePlugin.h: Add stub.
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp: Initialize plugin type.
* WebProcess/Plugins/PDF/PDFPlugin.h:
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::rectInWindowSpaceForRectInLayoutSpace): New helper function to
convert PDF 'in page' units to the equivalent view units.
(WebKit::PDFPlugin::PDFPlugin): Initialize plugin type.
(WebKit::PDFPlugin::viewRectForSelection): Query a provided PDFSelection for
its bounding rect and return the result in view units.
* WebProcess/Plugins/Plugin.h:
* WebProcess/Plugins/PluginProxy.cpp: Initialize plugin type.
* WebProcess/Plugins/PluginProxy.h: Add stub.
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::viewRectForSelection): Added.
* WebProcess/Plugins/PluginView.h:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::dictionaryPopupInfoForPDFSelectionInPluginView): Added.
(WebKit::textIndicatorTransitionForActionMenu): Added helper function.
(WebKit::WebPage::performActionMenuHitTestAtLocation): Update the hit test information
with relevant dictionary lookup content, and mark the result as a text node (if
appropriate).</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreeditingmacDictionaryLookupmm">trunk/Source/WebCore/editing/mac/DictionaryLookup.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsNetscapeNetscapePlugincpp">trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsNetscapeNetscapePluginh">trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPDFPDFPluginh">trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPDFPDFPluginmm">trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPlugincpp">trunk/Source/WebKit2/WebProcess/Plugins/Plugin.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPluginh">trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPluginProxycpp">trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPluginProxyh">trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPluginViewcpp">trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessPluginsPluginViewh">trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm">trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (183276 => 183277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-04-24 19:15:57 UTC (rev 183276)
+++ trunk/Source/WebCore/ChangeLog        2015-04-24 19:33:10 UTC (rev 183277)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2015-04-24 Brent Fulgham <bfulgham@apple.com>
+
+ Immediate action not functional for embedded PDFs
+ https://bugs.webkit.org/show_bug.cgi?id=143952
+ <rdar://problem/19842365>
+
+ Reviewed by Tim Horton.
+
+ Add a dictionary lookup method to allow us to retrieve
+ relevant information for PDFs.
+
+ * editing/mac/DictionaryLookup.mm:
+ (WebCore::dictionaryLookupForPDFSelection): Updated to properly handle cases
+ where the Lookup engine selects a smaller range than the initial automatic
+ selection performed on clicking.
+
</ins><span class="cx"> 2015-04-24 Simon Fraser <simon.fraser@apple.com>
</span><span class="cx">
</span><span class="cx"> Make it possible to map a secondary quad through TransformState
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingmacDictionaryLookupmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/mac/DictionaryLookup.mm (183276 => 183277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/mac/DictionaryLookup.mm        2015-04-24 19:15:57 UTC (rev 183276)
+++ trunk/Source/WebCore/editing/mac/DictionaryLookup.mm        2015-04-24 19:33:10 UTC (rev 183277)
</span><span class="lines">@@ -203,10 +203,8 @@
</span><span class="cx"> if (extractedRange.location == NSNotFound)
</span><span class="cx"> return selection.string;
</span><span class="cx">
</span><del>- NSInteger lookupAddedBefore = (extractedRange.location < rangeToPass.location) ? rangeToPass.location - extractedRange.location : 0;
- NSInteger lookupAddedAfter = 0;
- if ((extractedRange.location + extractedRange.length) > (rangeToPass.location + originalLength))
- lookupAddedAfter = (extractedRange.location + extractedRange.length) - (rangeToPass.location + originalLength);
</del><ins>+ NSInteger lookupAddedBefore = rangeToPass.location - extractedRange.location;
+ NSInteger lookupAddedAfter = (extractedRange.location + extractedRange.length) - (rangeToPass.location + originalLength);
</ins><span class="cx">
</span><span class="cx"> [selection extendSelectionAtStart:lookupAddedBefore];
</span><span class="cx"> [selection extendSelectionAtEnd:lookupAddedAfter];
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (183276 => 183277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-04-24 19:15:57 UTC (rev 183276)
+++ trunk/Source/WebKit2/ChangeLog        2015-04-24 19:33:10 UTC (rev 183277)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2015-04-24 Brent Fulgham <bfulgham@apple.com>
+
+ Immediate action not functional for embedded PDFs
+ https://bugs.webkit.org/show_bug.cgi?id=143952
+ <rdar://problem/19842365>
+
+ Reviewed by Tim Horton.
+
+ Add a new method to retrieve appropriate dictionary lookup content and update the
+ hit test result with relevant dictionary content and the bounding rect of the
+ selection.
+
+ * WebProcess/Plugins/Netscape/NetscapePlugin.h: Add stub.
+ * WebProcess/Plugins/Netscape/NetscapePlugin.cpp: Initialize plugin type.
+ * WebProcess/Plugins/PDF/PDFPlugin.h:
+ * WebProcess/Plugins/PDF/PDFPlugin.mm:
+ (WebKit::rectInWindowSpaceForRectInLayoutSpace): New helper function to
+ convert PDF 'in page' units to the equivalent view units.
+ (WebKit::PDFPlugin::PDFPlugin): Initialize plugin type.
+ (WebKit::PDFPlugin::viewRectForSelection): Query a provided PDFSelection for
+ its bounding rect and return the result in view units.
+ * WebProcess/Plugins/Plugin.h:
+ * WebProcess/Plugins/PluginProxy.cpp: Initialize plugin type.
+ * WebProcess/Plugins/PluginProxy.h: Add stub.
+ * WebProcess/Plugins/PluginView.cpp:
+ (WebKit::PluginView::viewRectForSelection): Added.
+ * WebProcess/Plugins/PluginView.h:
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::dictionaryPopupInfoForPDFSelectionInPluginView): Added.
+ (WebKit::textIndicatorTransitionForActionMenu): Added helper function.
+ (WebKit::WebPage::performActionMenuHitTestAtLocation): Update the hit test information
+ with relevant dictionary lookup content, and mark the result as a text node (if
+ appropriate).
+
</ins><span class="cx"> 2015-04-24 Jer Noble <jer.noble@apple.com>
</span><span class="cx">
</span><span class="cx"> [WK2] Only issue a isPlayingAudioDidChange() notification if the audio playing state actually changed.
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsNetscapeNetscapePlugincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (183276 => 183277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp        2015-04-24 19:15:57 UTC (rev 183276)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp        2015-04-24 19:33:10 UTC (rev 183277)
</span><span class="lines">@@ -58,7 +58,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule)
</span><del>- : m_nextRequestID(0)
</del><ins>+ : Plugin(NetscapePluginType)
+ , m_nextRequestID(0)
</ins><span class="cx"> , m_pluginModule(pluginModule)
</span><span class="cx"> , m_npWindow()
</span><span class="cx"> , m_isStarted(false)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsNetscapeNetscapePluginh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (183276 => 183277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h        2015-04-24 19:15:57 UTC (rev 183276)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h        2015-04-24 19:33:10 UTC (rev 183277)
</span><span class="lines">@@ -241,7 +241,6 @@
</span><span class="cx"> void setComplexTextInputEnabled(bool);
</span><span class="cx">
</span><span class="cx"> void updatePluginLayer();
</span><del>- String lookupTextAtLocation(const WebCore::FloatPoint&, WebHitTestResult::Data&, PDFSelection** selection, NSDictionary**) const override { return String(); }
</del><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> virtual void contentsScaleFactorChanged(float) override;
</span><span class="lines">@@ -401,6 +400,8 @@
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span><span class="cx">
</span><ins>+SPECIALIZE_TYPE_TRAITS_PLUGIN(NetscapePlugin, NetscapePluginType)
+
</ins><span class="cx"> #endif // ENABLE(NETSCAPE_PLUGIN_API)
</span><span class="cx">
</span><span class="cx"> #endif // NetscapePlugin_h
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFPDFPluginh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h (183276 => 183277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h        2015-04-24 19:15:57 UTC (rev 183276)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h        2015-04-24 19:33:10 UTC (rev 183277)
</span><span class="lines">@@ -104,6 +104,9 @@
</span><span class="cx">
</span><span class="cx"> bool showContextMenuAtPoint(const WebCore::IntPoint&);
</span><span class="cx">
</span><ins>+ String lookupTextAtLocation(const WebCore::FloatPoint&, WebHitTestResult::Data&, PDFSelection **, NSDictionary **) const;
+ WebCore::FloatRect viewRectForSelection(PDFSelection *) const;
+
</ins><span class="cx"> private:
</span><span class="cx"> explicit PDFPlugin(WebFrame*);
</span><span class="cx">
</span><span class="lines">@@ -170,7 +173,6 @@
</span><span class="cx"> String getSelectionString() const override;
</span><span class="cx"> String getSelectionForWordAtPoint(const WebCore::FloatPoint&) const override;
</span><span class="cx"> bool existingSelectionContainsPoint(const WebCore::FloatPoint&) const override;
</span><del>- String lookupTextAtLocation(const WebCore::FloatPoint&, WebHitTestResult::Data&, PDFSelection **, NSDictionary **) const override;
</del><span class="cx">
</span><span class="cx"> virtual bool shouldAllowScripting() override { return false; }
</span><span class="cx"> virtual bool shouldAllowNavigationFromDrags() override { return true; }
</span><span class="lines">@@ -308,6 +310,8 @@
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span><span class="cx">
</span><ins>+SPECIALIZE_TYPE_TRAITS_PLUGIN(PDFPlugin, PDFPluginType)
+
</ins><span class="cx"> #endif // ENABLE(PDFKIT_PLUGIN)
</span><span class="cx">
</span><span class="cx"> #endif // PDFPlugin_h
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPDFPDFPluginmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm (183276 => 183277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm        2015-04-24 19:15:57 UTC (rev 183276)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm        2015-04-24 19:33:10 UTC (rev 183277)
</span><span class="lines">@@ -395,6 +395,7 @@
</span><span class="cx">
</span><span class="cx"> @interface PDFViewLayout
</span><span class="cx"> - (NSPoint)convertPoint:(NSPoint)point toPage:(PDFPage *)page forScaleFactor:(CGFloat)scaleFactor;
</span><ins>+- (NSRect)convertRect:(NSRect)rect fromPage:(PDFPage *) page forScaleFactor:(CGFloat) scaleFactor;
</ins><span class="cx"> - (PDFPage *)pageNearestPoint:(NSPoint)point currentPage:(PDFPage *)currentPage;
</span><span class="cx"> @end
</span><span class="cx">
</span><span class="lines">@@ -504,7 +505,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PDFPlugin::PDFPlugin(WebFrame* frame)
</span><del>- : m_frame(frame)
</del><ins>+ : Plugin(PDFPluginType)
+ , m_frame(frame)
</ins><span class="cx"> , m_isPostScript(false)
</span><span class="cx"> , m_pdfDocumentWasMutated(false)
</span><span class="cx"> , m_containerLayer(adoptNS([[CALayer alloc] init]))
</span><span class="lines">@@ -1933,6 +1935,38 @@
</span><span class="cx"> return lookupText;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+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::viewRectForSelection(PDFSelection *selection) const
+{
+ PDFPage *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);
+}
+
</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></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPlugincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/Plugin.cpp (183276 => 183277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/Plugin.cpp        2015-04-24 19:15:57 UTC (rev 183276)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Plugin.cpp        2015-04-24 19:33:10 UTC (rev 183277)
</span><span class="lines">@@ -76,8 +76,9 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-Plugin::Plugin()
- : m_pluginController(0)
</del><ins>+Plugin::Plugin(PluginType type)
+ : m_type(type)
+ , m_pluginController(0)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPluginh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h (183276 => 183277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h        2015-04-24 19:15:57 UTC (rev 183276)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h        2015-04-24 19:33:10 UTC (rev 183277)
</span><span class="lines">@@ -74,6 +74,12 @@
</span><span class="cx">
</span><span class="cx"> class PluginController;
</span><span class="cx">
</span><ins>+enum PluginType {
+ PluginProxyType,
+ NetscapePluginType,
+ PDFPluginType,
+};
+
</ins><span class="cx"> class Plugin : public ThreadSafeRefCounted<Plugin> {
</span><span class="cx"> public:
</span><span class="cx"> struct Parameters {
</span><span class="lines">@@ -105,6 +111,8 @@
</span><span class="cx">
</span><span class="cx"> virtual ~Plugin();
</span><span class="cx">
</span><ins>+ PluginType type() const { return m_type; }
+
</ins><span class="cx"> private:
</span><span class="cx">
</span><span class="cx"> // Initializes the plug-in. If the plug-in fails to initialize this should return false.
</span><span class="lines">@@ -282,21 +290,25 @@
</span><span class="cx"> virtual String getSelectionString() const = 0;
</span><span class="cx"> virtual String getSelectionForWordAtPoint(const WebCore::FloatPoint&) const = 0;
</span><span class="cx"> virtual bool existingSelectionContainsPoint(const WebCore::FloatPoint&) const = 0;
</span><del>-#if PLATFORM(COCOA)
- virtual String lookupTextAtLocation(const WebCore::FloatPoint&, WebHitTestResult::Data&, PDFSelection**, NSDictionary**) const = 0;
-#endif
</del><span class="cx">
</span><span class="cx"> virtual WebCore::AudioHardwareActivityType audioHardwareActivity() const { return WebCore::AudioHardwareActivityType::Unknown; }
</span><span class="cx">
</span><span class="cx"> virtual void mutedStateChanged(bool) { }
</span><span class="cx">
</span><span class="cx"> protected:
</span><del>- Plugin();
</del><ins>+ Plugin(PluginType);
</ins><span class="cx">
</span><ins>+ PluginType m_type;
+
</ins><span class="cx"> private:
</span><span class="cx"> PluginController* m_pluginController;
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span><span class="cx">
</span><ins>+#define SPECIALIZE_TYPE_TRAITS_PLUGIN(ToValueTypeName, SpecificPluginType) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebKit::ToValueTypeName) \
+static bool isType(const WebKit::Plugin& plugin) { return plugin.type() == WebKit::SpecificPluginType; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
</ins><span class="cx"> #endif // Plugin_h
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPluginProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp (183276 => 183277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp        2015-04-24 19:15:57 UTC (rev 183276)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp        2015-04-24 19:33:10 UTC (rev 183277)
</span><span class="lines">@@ -62,7 +62,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PluginProxy::PluginProxy(uint64_t pluginProcessToken, bool isRestartedProcess)
</span><del>- : m_pluginProcessToken(pluginProcessToken)
</del><ins>+ : Plugin(PluginProxyType)
+ , m_pluginProcessToken(pluginProcessToken)
</ins><span class="cx"> , m_pluginInstanceID(generatePluginInstanceID())
</span><span class="cx"> , m_pluginBackingStoreContainsValidData(false)
</span><span class="cx"> , m_isStarted(false)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPluginProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h (183276 => 183277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h        2015-04-24 19:15:57 UTC (rev 183276)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h        2015-04-24 19:33:10 UTC (rev 183277)
</span><span class="lines">@@ -123,7 +123,6 @@
</span><span class="cx"> virtual uint64_t pluginComplexTextInputIdentifier() const override;
</span><span class="cx"> virtual void sendComplexTextInput(const String& textInput) override;
</span><span class="cx"> virtual void setLayerHostingMode(LayerHostingMode) override;
</span><del>- String lookupTextAtLocation(const WebCore::FloatPoint&, WebHitTestResult::Data&, PDFSelection**, NSDictionary**) const override { return String(); }
</del><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> virtual void contentsScaleFactorChanged(float) override;
</span><span class="lines">@@ -237,6 +236,8 @@
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span><span class="cx">
</span><ins>+SPECIALIZE_TYPE_TRAITS_PLUGIN(PluginProxy, PluginProxyType)
+
</ins><span class="cx"> #endif // ENABLE(NETSCAPE_PLUGIN_API)
</span><span class="cx">
</span><span class="cx"> #endif // PluginProxy_h
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPluginViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (183276 => 183277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp        2015-04-24 19:15:57 UTC (rev 183276)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp        2015-04-24 19:33:10 UTC (rev 183277)
</span><span class="lines">@@ -1009,16 +1009,6 @@
</span><span class="cx"> return m_plugin->existingSelectionContainsPoint(point);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if PLATFORM(COCOA)
-String PluginView::lookupTextAtLocation(const WebCore::FloatPoint& point, WebHitTestResult::Data& data, PDFSelection **selection, NSDictionary **options) const
-{
- if (!m_isInitialized || !m_plugin)
- return String();
-
- return m_plugin->lookupTextAtLocation(point, data, selection, options);
-}
-#endif
-
</del><span class="cx"> void PluginView::notifyWidget(WidgetNotification notification)
</span><span class="cx"> {
</span><span class="cx"> switch (notification) {
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessPluginsPluginViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h (183276 => 183277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h        2015-04-24 19:15:57 UTC (rev 183276)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h        2015-04-24 19:33:10 UTC (rev 183277)
</span><span class="lines">@@ -89,11 +89,11 @@
</span><span class="cx"> bool sendComplexTextInput(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
</span><span class="cx"> RetainPtr<PDFDocument> pdfDocumentForPrinting() const { return m_plugin->pdfDocumentForPrinting(); }
</span><span class="cx"> NSObject *accessibilityObject() const;
</span><del>- String lookupTextAtLocation(const WebCore::FloatPoint&, WebHitTestResult::Data&, PDFSelection**, NSDictionary**) const;
</del><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> WebCore::HTMLPlugInElement* pluginElement() const { return m_pluginElement.get(); }
</span><span class="cx"> const Plugin::Parameters& initialParameters() const { return m_parameters; }
</span><ins>+ Plugin* plugin() const { return m_plugin.get(); }
</ins><span class="cx">
</span><span class="cx"> // FIXME: Remove this; nobody should have to know about the plug-in view's renderer except the plug-in view itself.
</span><span class="cx"> WebCore::RenderBoxModelObject* renderer() const;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (183276 => 183277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2015-04-24 19:15:57 UTC (rev 183276)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2015-04-24 19:33:10 UTC (rev 183277)
</span><span class="lines">@@ -146,6 +146,7 @@
</span><span class="cx"> class DrawingArea;
</span><span class="cx"> class InjectedBundleBackForwardList;
</span><span class="cx"> class NotificationPermissionRequestManager;
</span><ins>+class PDFPlugin;
</ins><span class="cx"> class PageBanner;
</span><span class="cx"> class PluginView;
</span><span class="cx"> class VisibleContentRectUpdateInfo;
</span><span class="lines">@@ -1013,6 +1014,9 @@
</span><span class="cx"> void performDictionaryLookupOfCurrentSelection();
</span><span class="cx"> void performDictionaryLookupForRange(WebCore::Frame*, WebCore::Range&, NSDictionary *options, WebCore::TextIndicatorPresentationTransition);
</span><span class="cx"> DictionaryPopupInfo dictionaryPopupInfoForRange(WebCore::Frame* frame, WebCore::Range& range, NSDictionary **options, WebCore::TextIndicatorPresentationTransition presentationTransition);
</span><ins>+#if ENABLE(PDFKIT_PLUGIN)
+ DictionaryPopupInfo dictionaryPopupInfoForPDFSelectionInPluginView(PDFSelection *, PDFPlugin&, NSDictionary **options, WebCore::TextIndicatorPresentationTransition);
+#endif
</ins><span class="cx">
</span><span class="cx"> void windowAndViewFramesChanged(const WebCore::FloatRect& windowFrameInScreenCoordinates, const WebCore::FloatRect& windowFrameInUnflippedScreenCoordinates, const WebCore::FloatRect& viewFrameInWindowCoordinates, const WebCore::FloatPoint& accessibilityViewCoordinates);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (183276 => 183277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2015-04-24 19:15:57 UTC (rev 183276)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2015-04-24 19:33:10 UTC (rev 183277)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #import "EditorState.h"
</span><span class="cx"> #import "InjectedBundleHitTestResult.h"
</span><span class="cx"> #import "PDFKitImports.h"
</span><ins>+#import "PDFPlugin.h"
</ins><span class="cx"> #import "PageBanner.h"
</span><span class="cx"> #import "PluginView.h"
</span><span class="cx"> #import "PrintInfo.h"
</span><span class="lines">@@ -586,6 +587,49 @@
</span><span class="cx"> return dictionaryPopupInfo;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(PDFKIT_PLUGIN)
+DictionaryPopupInfo WebPage::dictionaryPopupInfoForPDFSelectionInPluginView(PDFSelection *selection, PDFPlugin& pdfPlugin, NSDictionary **options, WebCore::TextIndicatorPresentationTransition presentationTransition)
+{
+ DictionaryPopupInfo dictionaryPopupInfo;
+ if (!selection.string.length)
+ return dictionaryPopupInfo;
+
+ NSRect rangeRect = pdfPlugin.viewRectForSelection(selection);
+
+ dictionaryPopupInfo.origin = rangeRect.origin;
+ dictionaryPopupInfo.options = (CFDictionaryRef)*options;
+
+ NSAttributedString *nsAttributedString = selection.attributedString;
+
+ RetainPtr<NSMutableAttributedString> scaledNSAttributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[nsAttributedString string]]);
+
+ NSFontManager *fontManager = [NSFontManager sharedFontManager];
+
+ [nsAttributedString enumerateAttributesInRange:NSMakeRange(0, [nsAttributedString length]) options:0 usingBlock:^(NSDictionary *attributes, NSRange range, BOOL *stop) {
+ RetainPtr<NSMutableDictionary> scaledAttributes = adoptNS([attributes mutableCopy]);
+
+ NSFont *font = [scaledAttributes objectForKey:NSFontAttributeName];
+ if (font) {
+ font = [fontManager convertFont:font toSize:[font pointSize] * pageScaleFactor()];
+ [scaledAttributes setObject:font forKey:NSFontAttributeName];
+ }
+
+ [scaledNSAttributedString addAttributes:scaledAttributes.get() range:range];
+ }];
+
+ TextIndicatorData dataForSelection;
+ dataForSelection.selectionRectInRootViewCoordinates = rangeRect;
+ dataForSelection.textBoundingRectInRootViewCoordinates = rangeRect;
+ dataForSelection.contentImageScaleFactor = 1.0;
+ dataForSelection.presentationTransition = presentationTransition;
+
+ dictionaryPopupInfo.textIndicator = dataForSelection;
+ dictionaryPopupInfo.attributedString.string = scaledNSAttributedString;
+
+ return dictionaryPopupInfo;
+}
+#endif
+
</ins><span class="cx"> void WebPage::performDictionaryLookupForRange(Frame* frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition)
</span><span class="cx"> {
</span><span class="cx"> DictionaryPopupInfo dictionaryPopupInfo = dictionaryPopupInfoForRange(frame, range, &options, presentationTransition);
</span><span class="lines">@@ -1013,6 +1057,15 @@
</span><span class="cx"> return forImmediateAction ? TextIndicatorPresentationTransition::FadeIn : TextIndicatorPresentationTransition::Bounce;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(PDFKIT_PLUGIN)
+static TextIndicatorPresentationTransition textIndicatorTransitionForActionMenu(bool forImmediateAction, bool forDataDetectors)
+{
+ if (forDataDetectors && !forImmediateAction)
+ return forImmediateAction ? TextIndicatorPresentationTransition::Crossfade : TextIndicatorPresentationTransition::BounceAndCrossfade;
+ return forImmediateAction ? TextIndicatorPresentationTransition::FadeIn : TextIndicatorPresentationTransition::Bounce;
+}
+#endif
+
</ins><span class="cx"> void WebPage::performActionMenuHitTestAtLocation(WebCore::FloatPoint locationInViewCoordinates, bool forImmediateAction)
</span><span class="cx"> {
</span><span class="cx"> layoutIfNeeded();
</span><span class="lines">@@ -1106,11 +1159,14 @@
</span><span class="cx"> // See if we have a PDF
</span><span class="cx"> if (element && is<HTMLPlugInImageElement>(*element)) {
</span><span class="cx"> HTMLPlugInImageElement& pluginImageElement = downcast<HTMLPlugInImageElement>(*element);
</span><del>- if (PluginView* pluginView = reinterpret_cast<PluginView*>(pluginImageElement.pluginWidget())) {
</del><ins>+ PluginView* pluginView = reinterpret_cast<PluginView*>(pluginImageElement.pluginWidget());
+ Plugin* plugin = pluginView ? pluginView->plugin() : nullptr;
+ if (is<PDFPlugin>(plugin)) {
+ PDFPlugin* pdfPugin = downcast<PDFPlugin>(plugin);
</ins><span class="cx"> // FIXME: We don't have API to identify images inside PDFs based on position.
</span><span class="cx"> NSDictionary *options = nil;
</span><span class="cx"> PDFSelection *selection = nil;
</span><del>- String selectedText = pluginView->lookupTextAtLocation(locationInContentCoordinates, actionMenuResult, &selection, &options);
</del><ins>+ String selectedText = pdfPugin->lookupTextAtLocation(locationInContentCoordinates, actionMenuResult, &selection, &options);
</ins><span class="cx"> if (!selectedText.isEmpty()) {
</span><span class="cx"> if (element->document().isPluginDocument()) {
</span><span class="cx"> // FIXME(144030): Focus does not seem to get set to the PDF when invoking the menu.
</span><span class="lines">@@ -1119,8 +1175,11 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> actionMenuResult.lookupText = selectedText;
</span><ins>+ actionMenuResult.isTextNode = true;
</ins><span class="cx"> actionMenuResult.isSelected = true;
</span><span class="cx"> actionMenuResult.allowsCopy = true;
</span><ins>+
+ actionMenuResult.dictionaryPopupInfo = dictionaryPopupInfoForPDFSelectionInPluginView(selection, *pdfPugin, &options, textIndicatorTransitionForActionMenu(forImmediateAction, false));
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>