<!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>[238697] 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/238697">238697</a></dd>
<dt>Author</dt> <dd>megan_gardner@apple.com</dd>
<dt>Date</dt> <dd>2018-11-29 14:59:07 -0800 (Thu, 29 Nov 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move Lookup Code for better cross platform usage
https://bugs.webkit.org/show_bug.cgi?id=191732

Reviewed by Alex Christensen.

Source/WebCore:

Not currenlty testable

DictionaryLookup uses Reveal now, which is slated to be cross-platform.
That patch gates the parts of DictionaryLookup that currently do not have
an available implementation on iOS. Once Reveal is ready, this code will be
replaced or expanded upon, as appropriate.

* editing/mac/DictionaryLookup.h:
* editing/mac/DictionaryLookup.mm:
(WebCore::showPopupOrCreateAnimationController):
(WebCore::DictionaryLookup::showPopup):
(WebCore::DictionaryLookup::hidePopup):
(WebCore::DictionaryLookup::animationControllerForPopup):

Source/WebCore/PAL:

* pal/spi/mac/LookupSPI.h:
* pal/spi/mac/RevealSPI.h:

Source/WebKit:

Lookup is being replaced by Reveal. This framework should work on all platforms.
The patch moves the code that we expect will be needed for all platforms to the more
general cocoa area. This patch changes no funcationality, and should not change
anything currently. This work will be build on later when Reveal is ready to support
multiple platforms.

* Platform/spi/ios/UIKitSPI.h:
* UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::performDictionaryLookupAtLocation):
(WebKit::WebPageProxy::performDictionaryLookupOfCurrentSelection):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setupInteraction]):
(-[WKContentView cleanupInteraction]):
(-[WKContentView _removeDefaultGestureRecognizers]):
(-[WKContentView _addDefaultGestureRecognizers]):
(-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
(-[WKContentView _lookupGestureRecognized:]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::performDictionaryLookupAtLocation): Deleted.
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::performDictionaryLookupAtLocation): Deleted.
(WebKit::WebPageProxy::performDictionaryLookupOfCurrentSelection): Deleted.
* WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::performDictionaryLookupAtLocation):
(WebKit::WebPage::performDictionaryLookupForSelection):
(WebKit::WebPage::performDictionaryLookupOfCurrentSelection):
(WebKit::WebPage::performDictionaryLookupForRange):
(WebKit::WebPage::dictionaryPopupInfoForRange):
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::performDictionaryLookupAtLocation): Deleted.
(WebKit::WebPage::performDictionaryLookupForSelection): Deleted.
(WebKit::WebPage::performDictionaryLookupForRange): Deleted.
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::performDictionaryLookupAtLocation): Deleted.
(WebKit::WebPage::performDictionaryLookupForSelection): Deleted.
(WebKit::WebPage::performDictionaryLookupOfCurrentSelection): Deleted.
(WebKit::WebPage::dictionaryPopupInfoForRange): Deleted.
(WebKit::WebPage::performDictionaryLookupForRange): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePALChangeLog">trunk/Source/WebCore/PAL/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePALPALxcodeprojprojectpbxproj">trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorePALpalspimacLookupSPIh">trunk/Source/WebCore/PAL/pal/spi/mac/LookupSPI.h</a></li>
<li><a href="#trunkSourceWebCoreSourcesCocoatxt">trunk/Source/WebCore/SourcesCocoa.txt</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreeditingcocoaWebContentReaderCocoamm">trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm</a></li>
<li><a href="#trunkSourceWebCoreeditingmacDictionaryLookuph">trunk/Source/WebCore/editing/mac/DictionaryLookup.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitPlatformspiiosUIKitSPIh">trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaWebPageProxyCocoamm">trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosWKContentViewInteractionh">trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosWebPageProxyIOSmm">trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessmacWebPageProxyMacmm">trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageCocoaWebPageCocoamm">trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagemessagesin">trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageiosWebPageIOSmm">trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPagemacWebPageMacmm">trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorePALpalspicocoaRevealSPIh">trunk/Source/WebCore/PAL/pal/spi/cocoa/RevealSPI.h</a></li>
<li><a href="#trunkSourceWebCoreeditingcocoaDictionaryLookupmm">trunk/Source/WebCore/editing/cocoa/DictionaryLookup.mm</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorePALpalspimacRevealSPIh">trunk/Source/WebCore/PAL/pal/spi/mac/RevealSPI.h</a></li>
<li><a href="#trunkSourceWebCoreeditingmacDictionaryLookupmm">trunk/Source/WebCore/editing/mac/DictionaryLookup.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebCore/ChangeLog      2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2018-11-29  Megan Gardner  <megan_gardner@apple.com>
+
+        Move Lookup Code for better cross platform usage
+        https://bugs.webkit.org/show_bug.cgi?id=191732
+
+        Reviewed by Alex Christensen.
+
+        Not currenlty testable
+
+        DictionaryLookup uses Reveal now, which is slated to be cross-platform.
+        That patch gates the parts of DictionaryLookup that currently do not have
+        an available implementation on iOS. Once Reveal is ready, this code will be
+        replaced or expanded upon, as appropriate.
+
+        * editing/mac/DictionaryLookup.h:
+        * editing/mac/DictionaryLookup.mm:
+        (WebCore::showPopupOrCreateAnimationController):
+        (WebCore::DictionaryLookup::showPopup):
+        (WebCore::DictionaryLookup::hidePopup):
+        (WebCore::DictionaryLookup::animationControllerForPopup):
+
</ins><span class="cx"> 2018-11-29  Joseph Pecoraro  <pecoraro@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [Cocoa] Move ServerTimingParser.* into a better group in the Xcode project
</span></span></pre></div>
<a id="trunkSourceWebCorePALChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PAL/ChangeLog (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PAL/ChangeLog       2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebCore/PAL/ChangeLog  2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2018-11-29  Megan Gardner  <megan_gardner@apple.com>
+
+        Move Lookup Code for better cross platform usage
+        https://bugs.webkit.org/show_bug.cgi?id=191732
+
+        Reviewed by Alex Christensen.
+
+        * pal/spi/mac/LookupSPI.h:
+        * pal/spi/mac/RevealSPI.h:
+
</ins><span class="cx"> 2018-11-29  Eric Carlson  <eric.carlson@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [iOS] Tell AirPlay picker when a file has video
</span></span></pre></div>
<a id="trunkSourceWebCorePALPALxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj   2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj      2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -406,6 +406,7 @@
</span><span class="cx">                          0C2DA1391F3BEB4900DBC317 /* PassKitSPI.h */,
</span><span class="cx">                          0C2DA13A1F3BEB4900DBC317 /* pthreadSPI.h */,
</span><span class="cx">                          0C2DA13B1F3BEB4900DBC317 /* QuartzCoreSPI.h */,
</span><ins>+                               442956CC218A72DE0080DB54 /* RevealSPI.h */,
</ins><span class="cx">                           570AB8F020AE2E8D00B8BE87 /* SecKeyProxySPI.h */,
</span><span class="cx">                          0C2DA13C1F3BEB4900DBC317 /* ServersSPI.h */,
</span><span class="cx">                          0C2DA12B1F3BEB4900DBC317 /* URLFormattingSPI.h */,
</span><span class="lines">@@ -471,7 +472,6 @@
</span><span class="cx">                          0C7785861F45130F00F4EBB6 /* QTKitSPI.h */,
</span><span class="cx">                          A102658A1F56748C00B4C844 /* QuickDrawSPI.h */,
</span><span class="cx">                          0C7785871F45130F00F4EBB6 /* QuickLookMacSPI.h */,
</span><del>-                               442956CC218A72DE0080DB54 /* RevealSPI.h */,
</del><span class="cx">                           A1175B481F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h */,
</span><span class="cx">                          0C7785881F45130F00F4EBB6 /* TUCallSPI.h */,
</span><span class="cx">                  );
</span></span></pre></div>
<a id="trunkSourceWebCorePALpalspicocoaRevealSPIhfromrev238696trunkSourceWebCorePALpalspimacRevealSPIh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/PAL/pal/spi/cocoa/RevealSPI.h (from rev 238696, trunk/Source/WebCore/PAL/pal/spi/mac/RevealSPI.h) (0 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PAL/pal/spi/cocoa/RevealSPI.h                               (rev 0)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/RevealSPI.h  2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -0,0 +1,89 @@
</span><ins>+/*
+ * Copyright (C) 2018 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. ``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
+ * 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 <objc/runtime.h>
+#if PLATFORM(MAC)
+#import <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h>
+#endif // PLATFORM(MAC)
+#import <wtf/SoftLinking.h>
+
+SOFT_LINK_PRIVATE_FRAMEWORK(Reveal)
+SOFT_LINK_PRIVATE_FRAMEWORK(RevealCore)
+SOFT_LINK_CLASS_OPTIONAL(Reveal, RVPresenter)
+SOFT_LINK_CLASS_OPTIONAL(Reveal, RVPresentingContext)
+SOFT_LINK_CLASS_OPTIONAL(RevealCore, RVItem)
+SOFT_LINK_CLASS_OPTIONAL(RevealCore, RVSelection)
+
+#if ENABLE(REVEAL)
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#if PLATFORM(MAC)
+#import <Reveal/RVPresenter.h>
+#import <Reveal/Reveal.h>
+#endif // PLATFORM(MAC)
+#import <RevealCore/RVSelection.h>
+#import <RevealCore/RevealCore.h>
+
+#else // USE(APPLE_INTERNAL_SDK)
+
+
+@protocol RVPresenterHighlightDelegate;
+
+@interface RVItem : NSObject <NSSecureCoding>
+- (instancetype)initWithText:(NSString *)text selectedRange:(NSRange)selectedRange NS_DESIGNATED_INITIALIZER;
+@end
+
+@interface RVSelection : NSObject
++ (NSRange)revealRangeAtIndex:(NSUInteger)clickIndex selectedRanges:(NSArray <NSValue *> *)selectedRanges shouldUpdateSelection:(BOOL *)shouldUpdateSelection;
+@end
+
+#if PLATFORM(MAC)
+@interface RVPresentingContext : NSObject
+- (instancetype)initWithPointerLocationInView:(NSPoint)pointerLocationInView inView:(NSView *)view highlightDelegate:(id<RVPresenterHighlightDelegate>)highlightDelegate;
+@end
+#endif
+
+@protocol RVPresenterHighlightDelegate <NSObject>
+@required
+- (NSArray <NSValue *> *)revealContext:(RVPresentingContext *)context rectsForItem:(RVItem *)item;
+@optional
+- (void)revealContext:(RVPresentingContext *)context stopHighlightingItem:(RVItem *)item;
+- (void)revealContext:(RVPresentingContext *)context drawRectsForItem:(RVItem *)item;
+@end
+
+@interface RVDocumentContext : NSObject < NSSecureCoding >
+@end
+
+@interface RVPresenter : NSObject
+#if PLATFORM(MAC)
+- (id<NSImmediateActionAnimationController>)animationControllerForItem:(RVItem *)item documentContext:(RVDocumentContext *)documentContext presentingContext:(RVPresentingContext *)presentingContext options:(NSDictionary *)options;
+#endif // PLATFORM(MAC)
+- (BOOL)revealItem:(RVItem *)item documentContext:(RVDocumentContext *)documentContext presentingContext:(RVPresentingContext *)presentingContext options:(NSDictionary *)options;
+@end
+
+#endif // !USE(APPLE_INTERNAL_SDK)
+
+#endif // ENABLE(REVEAL)
</ins></span></pre></div>
<a id="trunkSourceWebCorePALpalspimacLookupSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PAL/pal/spi/mac/LookupSPI.h (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PAL/pal/spi/mac/LookupSPI.h 2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/LookupSPI.h    2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -23,12 +23,13 @@
</span><span class="cx">  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
</span><span class="cx">  */
</span><span class="cx"> 
</span><ins>+
+#if PLATFORM(MAC)
+
</ins><span class="cx"> #import <objc/runtime.h>
</span><span class="cx"> #import <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h>
</span><span class="cx"> #import <wtf/SoftLinking.h>
</span><span class="cx"> 
</span><del>-#if PLATFORM(MAC)
-
</del><span class="cx"> SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(Lookup)
</span><span class="cx"> SOFT_LINK_CLASS_OPTIONAL(Lookup, LULookupDefinitionModule)
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorePALpalspimacRevealSPIh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/PAL/pal/spi/mac/RevealSPI.h (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PAL/pal/spi/mac/RevealSPI.h 2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/RevealSPI.h    2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -1,60 +0,0 @@
</span><del>-/*
- * Copyright (C) 2018 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. ``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
- * 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 <objc/runtime.h>
-#import <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h>
-#import <wtf/SoftLinking.h>
-
-SOFT_LINK_PRIVATE_FRAMEWORK(Reveal)
-SOFT_LINK_PRIVATE_FRAMEWORK(RevealCore)
-SOFT_LINK_CLASS_OPTIONAL(Reveal, RVPresenter)
-SOFT_LINK_CLASS_OPTIONAL(Reveal, RVPresentingContext)
-SOFT_LINK_CLASS_OPTIONAL(RevealCore, RVItem)
-SOFT_LINK_CLASS_OPTIONAL(RevealCore, RVSelection)
-
-#if USE(APPLE_INTERNAL_SDK)
-
-#import <Reveal/RVPresenter.h>
-#import <Reveal/Reveal.h>
-#import <RevealCore/RVSelection.h>
-#import <RevealCore/RevealCore.h>
-
-
-#else
-
-@interface RVItem : NSObject <NSSecureCoding>
-- (instancetype)initWithText:(NSString *)text selectedRange:(NSRange)selectedRange NS_DESIGNATED_INITIALIZER;
-@end
-
-@interface RVSelection : NSObject
-+ (NSRange)revealRangeAtIndex:(NSUInteger)clickIndex selectedRanges:(NSArray <NSValue *> *)selectedRanges shouldUpdateSelection:(BOOL *)shouldUpdateSelection;
-@end
-
-@interface RVPresenter : NSObject
-- (id<NSImmediateActionAnimationController>)animationControllerForItem:(RVItem *)item documentContext:(RVDocumentContext *)documentContext presentingContext:(RVPresentingContext *)presentingContext options:(NSDictionary *)options;
-- (BOOL)revealItem:(RVItem *)item documentContext:(RVDocumentContext *)documentContext presentingContext:(RVPresentingContext *)presentingContext options:(NSDictionary *)options;
-@end
-
-#endif // !USE(APPLE_INTERNAL_SDK)
</del></span></pre></div>
<a id="trunkSourceWebCoreSourcesCocoatxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/SourcesCocoa.txt (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/SourcesCocoa.txt    2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebCore/SourcesCocoa.txt       2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -77,6 +77,7 @@
</span><span class="cx"> editing/SmartReplaceCF.cpp
</span><span class="cx"> 
</span><span class="cx"> editing/cocoa/DataDetection.mm
</span><ins>+editing/cocoa/DictionaryLookup.mm
</ins><span class="cx"> editing/cocoa/EditorCocoa.mm
</span><span class="cx"> editing/cocoa/FontAttributeChangesCocoa.mm
</span><span class="cx"> editing/cocoa/FontAttributesCocoa.mm
</span><span class="lines">@@ -90,7 +91,6 @@
</span><span class="cx"> editing/ios/EditorIOS.mm
</span><span class="cx"> 
</span><span class="cx"> editing/mac/AlternativeTextUIController.mm
</span><del>-editing/mac/DictionaryLookup.mm
</del><span class="cx"> editing/mac/DictionaryLookupLegacy.mm
</span><span class="cx"> editing/mac/EditorMac.mm
</span><span class="cx"> editing/mac/FrameSelectionMac.mm
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -20520,6 +20520,7 @@
</span><span class="cx">                  children = (
</span><span class="cx">                          C5227DEF1C3C6DD700F5ED54 /* DataDetection.h */,
</span><span class="cx">                          C5227DF01C3C6DD700F5ED54 /* DataDetection.mm */,
</span><ins>+                               937FF3D61A10131B008EBA31 /* DictionaryLookup.mm */,
</ins><span class="cx">                           9B55EEE81B3E8898005342BC /* EditorCocoa.mm */,
</span><span class="cx">                          F42CEB54214031EE002DCA72 /* FontAttributeChangesCocoa.mm */,
</span><span class="cx">                          F48D2A752156FE5700C6752B /* FontAttributesCocoa.mm */,
</span><span class="lines">@@ -26228,7 +26229,6 @@
</span><span class="cx">                          CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */,
</span><span class="cx">                          CE7B2DB01586ABAD0098B3FA /* AlternativeTextUIController.mm */,
</span><span class="cx">                          937FF3D41A1012D6008EBA31 /* DictionaryLookup.h */,
</span><del>-                               937FF3D61A10131B008EBA31 /* DictionaryLookup.mm */,
</del><span class="cx">                           442956CA218A6D300080DB54 /* DictionaryLookupLegacy.mm */,
</span><span class="cx">                          ED501DC50B249F2900AE18D9 /* EditorMac.mm */,
</span><span class="cx">                          4A8C96EA0BE69032004EEFF0 /* FrameSelectionMac.mm */,
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingcocoaDictionaryLookupmmfromrev238696trunkSourceWebCoreeditingmacDictionaryLookupmm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/editing/cocoa/DictionaryLookup.mm (from rev 238696, trunk/Source/WebCore/editing/mac/DictionaryLookup.mm) (0 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/cocoa/DictionaryLookup.mm                           (rev 0)
+++ trunk/Source/WebCore/editing/cocoa/DictionaryLookup.mm      2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -0,0 +1,433 @@
</span><ins>+/*
+ * Copyright (C) 2014-2018 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 "DictionaryLookup.h"
+
+#if PLATFORM(COCOA)
+
+#if ENABLE(REVEAL)
+
+#import "Document.h"
+#import "Editing.h"
+#import "FocusController.h"
+#import "Frame.h"
+#import "FrameSelection.h"
+#import "HTMLConverter.h"
+#import "HitTestResult.h"
+#import "NotImplemented.h"
+#import "Page.h"
+#import "Range.h"
+#import "RenderObject.h"
+#import "TextIterator.h"
+#import "VisiblePosition.h"
+#import "VisibleSelection.h"
+#import "VisibleUnits.h"
+#import <pal/spi/cocoa/RevealSPI.h>
+#import <pal/spi/mac/LookupSPI.h>
+#import <wtf/BlockObjCExceptions.h>
+#import <wtf/RefPtr.h>
+
+#if !PLATFORM(WATCH)
+
+#import <PDFKit/PDFKit.h>
+
+#endif // !PLATFORM(WATCH)
+
+#if PLATFORM(MAC)
+
+@interface WebRevealHighlight <RVPresenterHighlightDelegate> : NSObject {
+@private
+    Function<void()> _clearTextIndicator;
+    NSRect _highlightRect;
+    BOOL _useDefaultHighlight;
+    NSAttributedString *_attributedString;
+}
+
+@property (nonatomic, readonly) NSRect highlightRect;
+@property (nonatomic, readonly) BOOL useDefaultHighlight;
+@property (nonatomic, readonly) NSAttributedString *attributedString;
+
+- (instancetype)initWithHighlightRect:(NSRect)highlightRect useDefaultHighlight:(BOOL)useDefaultHighlight attributedString:(NSAttributedString *) attributedString;
+- (void)setClearTextIndicator:(Function<void()>&&)clearTextIndicator;
+
+@end
+
+@implementation WebRevealHighlight
+
+@synthesize highlightRect=_highlightRect;
+@synthesize useDefaultHighlight=_useDefaultHighlight;
+@synthesize attributedString=_attributedString;
+
+- (instancetype)initWithHighlightRect:(NSRect)highlightRect useDefaultHighlight:(BOOL)useDefaultHighlight attributedString:(NSAttributedString *) attributedString
+{
+    if (!(self = [super init]))
+        return nil;
+    
+    _highlightRect = highlightRect;
+    _useDefaultHighlight = useDefaultHighlight;
+    _attributedString = attributedString;
+    
+    return self;
+}
+
+- (void)setClearTextIndicator:(Function<void()>&&)clearTextIndicator
+{
+    _clearTextIndicator = WTFMove(clearTextIndicator);
+}
+
+- (NSArray<NSValue *> *)revealContext:(RVPresentingContext *)context rectsForItem:(RVItem *)item
+{
+    UNUSED_PARAM(context);
+    UNUSED_PARAM(item);
+    return @[[NSValue valueWithRect:self.highlightRect]];
+}
+
+- (void)revealContext:(RVPresentingContext *)context drawRectsForItem:(RVItem *)item
+{
+    UNUSED_PARAM(item);
+    
+    for (NSValue *rectVal in context.itemRectsInView) {
+        NSRect rect = rectVal.rectValue;
+
+        // Get current font attributes from the attributed string above, and add paragraph style attribute in order to center text.
+        RetainPtr<NSMutableDictionary> attributes = adoptNS([[NSMutableDictionary alloc] initWithDictionary:[self.attributedString fontAttributesInRange:NSMakeRange(0, [self.attributedString length])]]);
+        RetainPtr<NSMutableParagraphStyle> paragraph = adoptNS([[NSMutableParagraphStyle alloc] init]);
+        [paragraph setAlignment:NSTextAlignmentCenter];
+        [attributes setObject:paragraph.get() forKey:NSParagraphStyleAttributeName];
+    
+        RetainPtr<NSAttributedString> string = adoptNS([[NSAttributedString alloc] initWithString:[self.attributedString string] attributes:attributes.get()]);
+        [string drawInRect:rect];
+    }
+}
+
+- (BOOL)revealContext:(RVPresentingContext *)context shouldUseDefaultHighlightForItem:(RVItem *)item
+{
+    UNUSED_PARAM(context);
+    UNUSED_PARAM(item);
+    return self.useDefaultHighlight;
+}
+
+- (void)revealContext:(RVPresentingContext *)context stopHighlightingItem:(RVItem *)item
+{
+    UNUSED_PARAM(context);
+    UNUSED_PARAM(item);
+    auto block = WTFMove(_clearTextIndicator);
+    if (block)
+        block();
+}
+
+@end
+
+#endif // PLATFORM(MAC)
+
+#endif // ENABLE(REVEAL)
+
+namespace WebCore {
+
+#if ENABLE(REVEAL)
+
+std::tuple<RefPtr<Range>, NSDictionary *> DictionaryLookup::rangeForSelection(const VisibleSelection& selection)
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    
+    if (!getRVItemClass())
+        return { nullptr, nil };
+    
+    auto selectedRange = selection.toNormalizedRange();
+    if (!selectedRange)
+        return { nullptr, nil };
+
+    // Since we already have the range we want, we just need to grab the returned options.
+    auto selectionStart = selection.visibleStart();
+    auto selectionEnd = selection.visibleEnd();
+
+    // As context, we are going to use the surrounding paragraphs of text.
+    auto paragraphStart = startOfParagraph(selectionStart);
+    auto paragraphEnd = endOfParagraph(selectionEnd);
+
+    int lengthToSelectionStart = TextIterator::rangeLength(makeRange(paragraphStart, selectionStart).get());
+    int lengthToSelectionEnd = TextIterator::rangeLength(makeRange(paragraphStart, selectionEnd).get());
+    NSRange rangeToPass = NSMakeRange(lengthToSelectionStart, lengthToSelectionEnd - lengthToSelectionStart);
+    
+    RefPtr<Range> fullCharacterRange = makeRange(paragraphStart, paragraphEnd);
+    String itemString = plainText(fullCharacterRange.get());
+    RetainPtr<RVItem> item = adoptNS([allocRVItemInstance() initWithText:itemString selectedRange:rangeToPass]);
+    NSRange highlightRange = item.get().highlightRange;
+    
+    return { TextIterator::subrange(*fullCharacterRange, highlightRange.location, highlightRange.length), nil };
+    
+    END_BLOCK_OBJC_EXCEPTIONS;
+    
+    return { nullptr, nil };
+}
+
+std::tuple<RefPtr<Range>, NSDictionary *> DictionaryLookup::rangeAtHitTestResult(const HitTestResult& hitTestResult)
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    
+    if (!getRVItemClass())
+        return { nullptr, nil };
+    
+    auto* node = hitTestResult.innerNonSharedNode();
+    if (!node || !node->renderer())
+        return { nullptr, nil };
+
+    auto* frame = node->document().frame();
+    if (!frame)
+        return { nullptr, nil };
+
+    // Don't do anything if there is no character at the point.
+    auto framePoint = hitTestResult.roundedPointInInnerNodeFrame();
+    if (!frame->rangeForPoint(framePoint))
+        return { nullptr, nil };
+
+    auto position = frame->visiblePositionForPoint(framePoint);
+    if (position.isNull())
+        position = firstPositionInOrBeforeNode(node);
+
+    auto selection = frame->page()->focusController().focusedOrMainFrame().selection().selection();
+    NSRange selectionRange;
+    int hitIndex;
+    RefPtr<Range> fullCharacterRange;
+    
+    if (selection.selectionType() == VisibleSelection::RangeSelection) {
+        auto selectionStart = selection.visibleStart();
+        auto selectionEnd = selection.visibleEnd();
+        
+        // As context, we are going to use the surrounding paragraphs of text.
+        auto paragraphStart = startOfParagraph(selectionStart);
+        auto paragraphEnd = endOfParagraph(selectionEnd);
+        
+        auto rangeToSelectionStart = makeRange(paragraphStart, selectionStart);
+        auto rangeToSelectionEnd = makeRange(paragraphStart, selectionEnd);
+        
+        fullCharacterRange = makeRange(paragraphStart, paragraphEnd);
+        
+        selectionRange = NSMakeRange(TextIterator::rangeLength(rangeToSelectionStart.get()), TextIterator::rangeLength(makeRange(selectionStart, selectionEnd).get()));
+        
+        hitIndex = TextIterator::rangeLength(makeRange(paragraphStart, position).get());
+    } else {
+        VisibleSelection selectionAccountingForLineRules { position };
+        selectionAccountingForLineRules.expandUsingGranularity(WordGranularity);
+        position = selectionAccountingForLineRules.start();
+        // As context, we are going to use 250 characters of text before and after the point.
+        fullCharacterRange = rangeExpandedAroundPositionByCharacters(position, 250);
+        
+        if (!fullCharacterRange)
+            return { nullptr, nil };
+        
+        selectionRange = NSMakeRange(NSNotFound, 0);
+        hitIndex = TextIterator::rangeLength(makeRange(fullCharacterRange->startPosition(), position).get());
+    }
+    
+    NSRange selectedRange = [getRVSelectionClass() revealRangeAtIndex:hitIndex selectedRanges:@[[NSValue valueWithRange:selectionRange]] shouldUpdateSelection:nil];
+    
+    String itemString = plainText(fullCharacterRange.get());
+    RetainPtr<RVItem> item = adoptNS([allocRVItemInstance() initWithText:itemString selectedRange:selectedRange]);
+    NSRange highlightRange = item.get().highlightRange;
+
+    if (highlightRange.location == NSNotFound || !highlightRange.length)
+        return { nullptr, nil };
+    
+    return { TextIterator::subrange(*fullCharacterRange, highlightRange.location, highlightRange.length), nil };
+    
+    END_BLOCK_OBJC_EXCEPTIONS;
+    
+    return { nullptr, nil };
+    
+}
+    
+#if !PLATFORM(WATCH)
+
+static void expandSelectionByCharacters(PDFSelection *selection, NSInteger numberOfCharactersToExpand, NSInteger& charactersAddedBeforeStart, NSInteger& charactersAddedAfterEnd)
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+
+    size_t originalLength = selection.string.length;
+    [selection extendSelectionAtStart:numberOfCharactersToExpand];
+    
+    charactersAddedBeforeStart = selection.string.length - originalLength;
+    
+    [selection extendSelectionAtEnd:numberOfCharactersToExpand];
+    charactersAddedAfterEnd = selection.string.length - originalLength - charactersAddedBeforeStart;
+
+    END_BLOCK_OBJC_EXCEPTIONS;
+}
+
+std::tuple<NSString *, NSDictionary *> DictionaryLookup::stringForPDFSelection(PDFSelection *selection)
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    
+    if (!getRVItemClass())
+        return { nullptr, nil };
+
+    // Don't do anything if there is no character at the point.
+    if (!selection || !selection.string.length)
+        return { @"", nil };
+
+    RetainPtr<PDFSelection> selectionForLookup = adoptNS([selection copy]);
+
+    // As context, we are going to use 250 characters of text before and after the point.
+    auto originalLength = [selectionForLookup string].length;
+    NSInteger charactersAddedBeforeStart = 0;
+    NSInteger charactersAddedAfterEnd = 0;
+    expandSelectionByCharacters(selectionForLookup.get(), 250, charactersAddedBeforeStart, charactersAddedAfterEnd);
+
+    auto fullPlainTextString = [selectionForLookup string];
+    auto rangeToPass = NSMakeRange(charactersAddedBeforeStart, 0);
+
+    RetainPtr<RVItem> item = adoptNS([allocRVItemInstance() initWithText:fullPlainTextString selectedRange:rangeToPass]);
+    NSRange extractedRange = item.get().highlightRange;
+    
+    if (extractedRange.location == NSNotFound)
+        return { selection.string, nil };
+
+    NSInteger lookupAddedBefore = rangeToPass.location - extractedRange.location;
+    NSInteger lookupAddedAfter = (extractedRange.location + extractedRange.length) - (rangeToPass.location + originalLength);
+
+    [selection extendSelectionAtStart:lookupAddedBefore];
+    [selection extendSelectionAtEnd:lookupAddedAfter];
+
+    ASSERT([selection.string isEqualToString:[fullPlainTextString substringWithRange:extractedRange]]);
+    return { selection.string, nil };
+
+    END_BLOCK_OBJC_EXCEPTIONS;
+
+    return { @"", nil };
+}
+    
+#endif // !PLATFORM(WATCH)
+
+static WKRevealController showPopupOrCreateAnimationController(bool createAnimationController, const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback, WTF::Function<void()>&& clearTextIndicator)
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    
+#if PLATFORM(MAC)
+    
+    if (!getRVItemClass() || !getRVPresenterClass())
+        return nil;
+
+    RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([[NSMutableDictionary alloc] init]);
+    if (NSDictionary *options = dictionaryPopupInfo.options.get())
+        [mutableOptions addEntriesFromDictionary:options];
+
+    auto textIndicator = TextIndicator::create(dictionaryPopupInfo.textIndicator);
+    
+    RetainPtr<RVPresenter> presenter = adoptNS([allocRVPresenterInstance() init]);
+    
+    NSRect highlightRect;
+    NSPoint pointerLocation;
+    
+    if (textIndicator.get().contentImage()) {
+        textIndicatorInstallationCallback(textIndicator.get());
+
+        FloatRect firstTextRectInViewCoordinates = textIndicator.get().textRectsInBoundingRectCoordinates()[0];
+        FloatRect textBoundingRectInViewCoordinates = textIndicator.get().textBoundingRectInRootViewCoordinates();
+        FloatRect selectionBoundingRectInViewCoordinates = textIndicator.get().selectionRectInRootViewCoordinates();
+        
+        if (rootViewToViewConversionCallback) {
+            textBoundingRectInViewCoordinates = rootViewToViewConversionCallback(textBoundingRectInViewCoordinates);
+            selectionBoundingRectInViewCoordinates = rootViewToViewConversionCallback(selectionBoundingRectInViewCoordinates);
+        }
+        
+        firstTextRectInViewCoordinates.moveBy(textBoundingRectInViewCoordinates.location());
+        highlightRect = selectionBoundingRectInViewCoordinates;
+        pointerLocation = firstTextRectInViewCoordinates.location();
+        
+    } else {
+        NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
+        
+        highlightRect = textIndicator->selectionRectInRootViewCoordinates();
+        pointerLocation = [view convertPoint:textBaselineOrigin toView:nil];
+    }
+    
+    RetainPtr<WebRevealHighlight> webHighlight =  adoptNS([[WebRevealHighlight alloc] initWithHighlightRect: highlightRect useDefaultHighlight:!textIndicator.get().contentImage() attributedString:dictionaryPopupInfo.attributedString.get()]);
+    RetainPtr<RVPresentingContext> context = adoptNS([allocRVPresentingContextInstance() initWithPointerLocationInView:pointerLocation inView:view highlightDelegate:(id<RVPresenterHighlightDelegate>) webHighlight.get()]);
+    
+    RetainPtr<RVItem> item = adoptNS([allocRVItemInstance() initWithText:dictionaryPopupInfo.attributedString.get().string selectedRange:NSMakeRange(0, 0)]);
+    
+    [webHighlight setClearTextIndicator:[webHighlight = WTFMove(webHighlight), clearTextIndicator = WTFMove(clearTextIndicator)] {
+        if (clearTextIndicator)
+            clearTextIndicator();
+    }];
+    
+    if (createAnimationController)
+        return [presenter animationControllerForItem:item.get() documentContext:nil presentingContext:context.get() options:nil];
+    [presenter revealItem:item.get() documentContext:nil presentingContext:context.get() options:nil];
+    return nil;
+    
+#else // PLATFORM(MAC)
+    
+    UNUSED_PARAM(createAnimationController);
+    UNUSED_PARAM(dictionaryPopupInfo);
+    UNUSED_PARAM(view);
+    UNUSED_PARAM(textIndicatorInstallationCallback);
+    UNUSED_PARAM(rootViewToViewConversionCallback);
+    UNUSED_PARAM(clearTextIndicator);
+    
+    return nil;
+#endif // PLATFORM(MAC)
+    
+    END_BLOCK_OBJC_EXCEPTIONS;
+    
+}
+
+void DictionaryLookup::showPopup(const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback, WTF::Function<void()>&& clearTextIndicator)
+{
+    showPopupOrCreateAnimationController(false, dictionaryPopupInfo, view, textIndicatorInstallationCallback, rootViewToViewConversionCallback, WTFMove(clearTextIndicator));
+}
+
+void DictionaryLookup::hidePopup()
+{
+    notImplemented();
+}
+
+#if PLATFORM(MAC)
+
+WKRevealController DictionaryLookup::animationControllerForPopup(const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback, WTF::Function<void()>&& clearTextIndicator)
+{
+    return showPopupOrCreateAnimationController(true, dictionaryPopupInfo, view, textIndicatorInstallationCallback, rootViewToViewConversionCallback, WTFMove(clearTextIndicator));
+}
+
+#endif // PLATFORM(MAC)
+
+#elif PLATFORM(IOS_FAMILY) // ENABLE(REVEAL)
+
+std::tuple<RefPtr<Range>, NSDictionary *> DictionaryLookup::rangeForSelection(const VisibleSelection&)
+{
+    return { nullptr, nil };
+}
+
+std::tuple<RefPtr<Range>, NSDictionary *> DictionaryLookup::rangeAtHitTestResult(const HitTestResult&)
+{
+    return { nullptr, nil };
+}
+
+#endif // ENABLE(REVEAL)
+
+} // namespace WebCore
+
+#endif // PLATFORM(COCOA)
</ins></span></pre></div>
<a id="trunkSourceWebCoreeditingcocoaWebContentReaderCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm      2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm 2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -34,6 +34,8 @@
</span><span class="cx"> #import "Document.h"
</span><span class="cx"> #import "DocumentFragment.h"
</span><span class="cx"> #import "DocumentLoader.h"
</span><ins>+#import "Editor.h"
+#import "EditorClient.h"
</ins><span class="cx"> #import "File.h"
</span><span class="cx"> #import "FileSystem.h"
</span><span class="cx"> #import "Frame.h"
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingmacDictionaryLookuph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/mac/DictionaryLookup.h (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/mac/DictionaryLookup.h      2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebCore/editing/mac/DictionaryLookup.h 2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -23,15 +23,25 @@
</span><span class="cx">  * THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-#if PLATFORM(MAC)
</del><ins>+#pragma once
</ins><span class="cx"> 
</span><ins>+#if PLATFORM(COCOA)
+
</ins><span class="cx"> #include "DictionaryPopupInfo.h"
</span><del>-#include <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h>
</del><ins>+#if PLATFORM(MAC)
+#import <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h>
+#endif // PLATFORM(MAC)
</ins><span class="cx"> #include <wtf/Function.h>
</span><span class="cx"> 
</span><span class="cx"> OBJC_CLASS NSView;
</span><span class="cx"> OBJC_CLASS PDFSelection;
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC)
+typedef id <NSImmediateActionAnimationController> WKRevealController;
+#else
+typedef id WKRevealController;
+#endif // PLATFORM(MAC)
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class HitTestResult;
</span><span class="lines">@@ -48,8 +58,11 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT static void showPopup(const DictionaryPopupInfo&, NSView *, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback = nullptr, WTF::Function<void()>&& clearTextIndicator = nullptr);
</span><span class="cx">     WEBCORE_EXPORT static void hidePopup();
</span><del>-
-    WEBCORE_EXPORT static id <NSImmediateActionAnimationController> animationControllerForPopup(const DictionaryPopupInfo&, NSView *, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback = nullptr, WTF::Function<void()>&& clearTextIndicator = nullptr);
</del><ins>+    
+#if PLATFORM(MAC)
+    WEBCORE_EXPORT static WKRevealController animationControllerForPopup(const DictionaryPopupInfo&, NSView *, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback = nullptr, WTF::Function<void()>&& clearTextIndicator = nullptr);
+#endif // PLATFORM(MAC)
+    
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingmacDictionaryLookupmm"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/editing/mac/DictionaryLookup.mm (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/mac/DictionaryLookup.mm     2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebCore/editing/mac/DictionaryLookup.mm        2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -1,388 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014-2018 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 "DictionaryLookup.h"
-
-#if PLATFORM(MAC) && ENABLE(REVEAL)
-
-#import "Document.h"
-#import "Editing.h"
-#import "FocusController.h"
-#import "Frame.h"
-#import "FrameSelection.h"
-#import "HTMLConverter.h"
-#import "HitTestResult.h"
-#import "Page.h"
-#import "Range.h"
-#import "RenderObject.h"
-#import "TextIterator.h"
-#import "VisiblePosition.h"
-#import "VisibleSelection.h"
-#import "VisibleUnits.h"
-#import <PDFKit/PDFKit.h>
-#import <pal/spi/mac/LookupSPI.h>
-#import <pal/spi/mac/NSImmediateActionGestureRecognizerSPI.h>
-#import <pal/spi/mac/RevealSPI.h>
-#import <wtf/BlockObjCExceptions.h>
-#import <wtf/RefPtr.h>
-
-@interface WebRevealHighlight <RVPresenterHighlightDelegate> : NSObject {
-@private
-    Function<void()> _clearTextIndicator;
-    NSRect _highlightRect;
-    BOOL _useDefaultHighlight;
-    NSAttributedString *_attributedString;
-}
-
-@property (nonatomic, readonly) NSRect highlightRect;
-@property (nonatomic, readonly) BOOL useDefaultHighlight;
-@property (nonatomic, readonly) NSAttributedString *attributedString;
-
-- (instancetype)initWithHighlightRect:(NSRect)highlightRect useDefaultHighlight:(BOOL)useDefaultHighlight attributedString:(NSAttributedString *) attributedString;
-- (void)setClearTextIndicator:(Function<void()>&&)clearTextIndicator;
-
-@end
-
-@implementation WebRevealHighlight
-
-@synthesize highlightRect=_highlightRect;
-@synthesize useDefaultHighlight=_useDefaultHighlight;
-@synthesize attributedString=_attributedString;
-
-- (instancetype)initWithHighlightRect:(NSRect)highlightRect useDefaultHighlight:(BOOL)useDefaultHighlight attributedString:(NSAttributedString *) attributedString
-{
-    if (!(self = [super init]))
-        return nil;
-    
-    _highlightRect = highlightRect;
-    _useDefaultHighlight = useDefaultHighlight;
-    _attributedString = attributedString;
-    
-    return self;
-}
-
-- (void)setClearTextIndicator:(Function<void()>&&)clearTextIndicator
-{
-    _clearTextIndicator = WTFMove(clearTextIndicator);
-}
-
-- (NSArray<NSValue *> *)revealContext:(RVPresentingContext *)context rectsForItem:(RVItem *)item
-{
-    UNUSED_PARAM(context);
-    UNUSED_PARAM(item);
-    return @[[NSValue valueWithRect:self.highlightRect]];
-}
-
-- (void)revealContext:(RVPresentingContext *)context drawRectsForItem:(RVItem *)item
-{
-    UNUSED_PARAM(item);
-    
-    for (NSValue *rectVal in context.itemRectsInView) {
-        NSRect rect = rectVal.rectValue;
-
-        // Get current font attributes from the attributed string above, and add paragraph style attribute in order to center text.
-        RetainPtr<NSMutableDictionary> attributes = adoptNS([[NSMutableDictionary alloc] initWithDictionary:[self.attributedString fontAttributesInRange:NSMakeRange(0, [self.attributedString length])]]);
-        RetainPtr<NSMutableParagraphStyle> paragraph = adoptNS([[NSMutableParagraphStyle alloc] init]);
-        [paragraph setAlignment:NSTextAlignmentCenter];
-        [attributes setObject:paragraph.get() forKey:NSParagraphStyleAttributeName];
-    
-        RetainPtr<NSAttributedString> string = adoptNS([[NSAttributedString alloc] initWithString:[self.attributedString string] attributes:attributes.get()]);
-        [string drawInRect:rect];
-    }
-}
-
-- (BOOL)revealContext:(RVPresentingContext *)context shouldUseDefaultHighlightForItem:(RVItem *)item
-{
-    UNUSED_PARAM(context);
-    UNUSED_PARAM(item);
-    return self.useDefaultHighlight;
-}
-
-- (void)revealContext:(RVPresentingContext *)context stopHighlightingItem:(RVItem *)item
-{
-    UNUSED_PARAM(context);
-    UNUSED_PARAM(item);
-    auto block = WTFMove(_clearTextIndicator);
-    if (block)
-        block();
-}
-
-@end
-
-namespace WebCore {
-
-std::tuple<RefPtr<Range>, NSDictionary *> DictionaryLookup::rangeForSelection(const VisibleSelection& selection)
-{
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    
-    if (!getRVItemClass())
-        return { nullptr, nil };
-    
-    auto selectedRange = selection.toNormalizedRange();
-    if (!selectedRange)
-        return { nullptr, nil };
-
-    // Since we already have the range we want, we just need to grab the returned options.
-    auto selectionStart = selection.visibleStart();
-    auto selectionEnd = selection.visibleEnd();
-
-    // As context, we are going to use the surrounding paragraphs of text.
-    auto paragraphStart = startOfParagraph(selectionStart);
-    auto paragraphEnd = endOfParagraph(selectionEnd);
-
-    int lengthToSelectionStart = TextIterator::rangeLength(makeRange(paragraphStart, selectionStart).get());
-    int lengthToSelectionEnd = TextIterator::rangeLength(makeRange(paragraphStart, selectionEnd).get());
-    NSRange rangeToPass = NSMakeRange(lengthToSelectionStart, lengthToSelectionEnd - lengthToSelectionStart);
-    
-    RefPtr<Range> fullCharacterRange = makeRange(paragraphStart, paragraphEnd);
-    String itemString = plainText(fullCharacterRange.get());
-    RetainPtr<RVItem> item = adoptNS([allocRVItemInstance() initWithText:itemString selectedRange:rangeToPass]);
-    NSRange highlightRange = item.get().highlightRange;
-    
-    return { TextIterator::subrange(*fullCharacterRange, highlightRange.location, highlightRange.length), nil };
-    
-    END_BLOCK_OBJC_EXCEPTIONS;
-    
-    return { nullptr, nil };
-}
-
-std::tuple<RefPtr<Range>, NSDictionary *> DictionaryLookup::rangeAtHitTestResult(const HitTestResult& hitTestResult)
-{
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    
-    if (!getRVItemClass())
-        return { nullptr, nil };
-    
-    auto* node = hitTestResult.innerNonSharedNode();
-    if (!node || !node->renderer())
-        return { nullptr, nil };
-
-    auto* frame = node->document().frame();
-    if (!frame)
-        return { nullptr, nil };
-
-    // Don't do anything if there is no character at the point.
-    auto framePoint = hitTestResult.roundedPointInInnerNodeFrame();
-    if (!frame->rangeForPoint(framePoint))
-        return { nullptr, nil };
-
-    auto position = frame->visiblePositionForPoint(framePoint);
-    if (position.isNull())
-        position = firstPositionInOrBeforeNode(node);
-
-    auto selection = frame->page()->focusController().focusedOrMainFrame().selection().selection();
-    NSRange selectionRange;
-    int hitIndex;
-    RefPtr<Range> fullCharacterRange;
-    
-    if (selection.selectionType() == VisibleSelection::RangeSelection) {
-        auto selectionStart = selection.visibleStart();
-        auto selectionEnd = selection.visibleEnd();
-        
-        // As context, we are going to use the surrounding paragraphs of text.
-        auto paragraphStart = startOfParagraph(selectionStart);
-        auto paragraphEnd = endOfParagraph(selectionEnd);
-        
-        auto rangeToSelectionStart = makeRange(paragraphStart, selectionStart);
-        auto rangeToSelectionEnd = makeRange(paragraphStart, selectionEnd);
-        
-        fullCharacterRange = makeRange(paragraphStart, paragraphEnd);
-        
-        selectionRange = NSMakeRange(TextIterator::rangeLength(rangeToSelectionStart.get()), TextIterator::rangeLength(makeRange(selectionStart, selectionEnd).get()));
-        
-        hitIndex = TextIterator::rangeLength(makeRange(paragraphStart, position).get());
-    } else {
-        VisibleSelection selectionAccountingForLineRules { position };
-        selectionAccountingForLineRules.expandUsingGranularity(WordGranularity);
-        position = selectionAccountingForLineRules.start();
-        // As context, we are going to use 250 characters of text before and after the point.
-        fullCharacterRange = rangeExpandedAroundPositionByCharacters(position, 250);
-        
-        if (!fullCharacterRange)
-            return { nullptr, nil };
-        
-        selectionRange = NSMakeRange(NSNotFound, 0);
-        hitIndex = TextIterator::rangeLength(makeRange(fullCharacterRange->startPosition(), position).get());
-    }
-    
-    NSRange selectedRange = [getRVSelectionClass() revealRangeAtIndex:hitIndex selectedRanges:@[[NSValue valueWithRange:selectionRange]] shouldUpdateSelection:nil];
-    
-    String itemString = plainText(fullCharacterRange.get());
-    RetainPtr<RVItem> item = adoptNS([allocRVItemInstance() initWithText:itemString selectedRange:selectedRange]);
-    NSRange highlightRange = item.get().highlightRange;
-
-    if (highlightRange.location == NSNotFound || !highlightRange.length)
-        return { nullptr, nil };
-    
-    return { TextIterator::subrange(*fullCharacterRange, highlightRange.location, highlightRange.length), nil };
-    
-    END_BLOCK_OBJC_EXCEPTIONS;
-    
-    return { nullptr, nil };
-    
-}
-
-static void expandSelectionByCharacters(PDFSelection *selection, NSInteger numberOfCharactersToExpand, NSInteger& charactersAddedBeforeStart, NSInteger& charactersAddedAfterEnd)
-{
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
-    size_t originalLength = selection.string.length;
-    [selection extendSelectionAtStart:numberOfCharactersToExpand];
-    
-    charactersAddedBeforeStart = selection.string.length - originalLength;
-    
-    [selection extendSelectionAtEnd:numberOfCharactersToExpand];
-    charactersAddedAfterEnd = selection.string.length - originalLength - charactersAddedBeforeStart;
-
-    END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-std::tuple<NSString *, NSDictionary *> DictionaryLookup::stringForPDFSelection(PDFSelection *selection)
-{
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    
-    if (!getRVItemClass())
-        return { nullptr, nil };
-
-    // Don't do anything if there is no character at the point.
-    if (!selection || !selection.string.length)
-        return { @"", nil };
-
-    RetainPtr<PDFSelection> selectionForLookup = adoptNS([selection copy]);
-
-    // As context, we are going to use 250 characters of text before and after the point.
-    auto originalLength = [selectionForLookup string].length;
-    NSInteger charactersAddedBeforeStart = 0;
-    NSInteger charactersAddedAfterEnd = 0;
-    expandSelectionByCharacters(selectionForLookup.get(), 250, charactersAddedBeforeStart, charactersAddedAfterEnd);
-
-    auto fullPlainTextString = [selectionForLookup string];
-    auto rangeToPass = NSMakeRange(charactersAddedBeforeStart, 0);
-
-    RetainPtr<RVItem> item = adoptNS([allocRVItemInstance() initWithText:fullPlainTextString selectedRange:rangeToPass]);
-    NSRange extractedRange = item.get().highlightRange;
-    
-    if (extractedRange.location == NSNotFound)
-        return { selection.string, nil };
-
-    NSInteger lookupAddedBefore = rangeToPass.location - extractedRange.location;
-    NSInteger lookupAddedAfter = (extractedRange.location + extractedRange.length) - (rangeToPass.location + originalLength);
-
-    [selection extendSelectionAtStart:lookupAddedBefore];
-    [selection extendSelectionAtEnd:lookupAddedAfter];
-
-    ASSERT([selection.string isEqualToString:[fullPlainTextString substringWithRange:extractedRange]]);
-    return { selection.string, nil };
-
-    END_BLOCK_OBJC_EXCEPTIONS;
-
-    return { @"", nil };
-}
-
-static id <NSImmediateActionAnimationController> showPopupOrCreateAnimationController(bool createAnimationController, const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback, WTF::Function<void()>&& clearTextIndicator)
-{
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    
-    if (!getRVItemClass())
-        return nil;
-
-    RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([[NSMutableDictionary alloc] init]);
-    if (NSDictionary *options = dictionaryPopupInfo.options.get())
-        [mutableOptions addEntriesFromDictionary:options];
-
-    auto textIndicator = TextIndicator::create(dictionaryPopupInfo.textIndicator);
-    
-    RetainPtr<RVPresenter> presenter = adoptNS([allocRVPresenterInstance() init]);
-    
-    NSRect highlightRect;
-    NSPoint pointerLocation;
-    
-    if (textIndicator.get().contentImage()) {
-        textIndicatorInstallationCallback(textIndicator.get());
-
-        FloatRect firstTextRectInViewCoordinates = textIndicator.get().textRectsInBoundingRectCoordinates()[0];
-        FloatRect textBoundingRectInViewCoordinates = textIndicator.get().textBoundingRectInRootViewCoordinates();
-        FloatRect selectionBoundingRectInViewCoordinates = textIndicator.get().selectionRectInRootViewCoordinates();
-        
-        if (rootViewToViewConversionCallback) {
-            textBoundingRectInViewCoordinates = rootViewToViewConversionCallback(textBoundingRectInViewCoordinates);
-            selectionBoundingRectInViewCoordinates = rootViewToViewConversionCallback(selectionBoundingRectInViewCoordinates);
-        }
-        
-        firstTextRectInViewCoordinates.moveBy(textBoundingRectInViewCoordinates.location());
-        highlightRect = selectionBoundingRectInViewCoordinates;
-        pointerLocation = firstTextRectInViewCoordinates.location();
-        
-    } else {
-        NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
-        
-        highlightRect = textIndicator->selectionRectInRootViewCoordinates();
-        pointerLocation = [view convertPoint:textBaselineOrigin toView:nil];
-    }
-    
-    RetainPtr<WebRevealHighlight> webHighlight =  adoptNS([[WebRevealHighlight alloc] initWithHighlightRect: highlightRect useDefaultHighlight:!textIndicator.get().contentImage() attributedString:dictionaryPopupInfo.attributedString.get()]);
-    RetainPtr<RVPresentingContext> context = adoptNS([allocRVPresentingContextInstance() initWithPointerLocationInView:pointerLocation inView:view highlightDelegate:(id<RVPresenterHighlightDelegate>) webHighlight.get()]);
-    
-    RetainPtr<RVItem> item = adoptNS([allocRVItemInstance() initWithText:dictionaryPopupInfo.attributedString.get().string selectedRange:NSMakeRange(0, 0)]);
-    
-    [webHighlight setClearTextIndicator:[webHighlight = WTFMove(webHighlight), clearTextIndicator = WTFMove(clearTextIndicator)] {
-        if (clearTextIndicator)
-            clearTextIndicator();
-    }];
-    
-    if (createAnimationController)
-        return [presenter animationControllerForItem:item.get() documentContext:nil presentingContext:context.get() options:nil];
-    [presenter revealItem:item.get() documentContext:nil presentingContext:context.get() options:nil];
-    return nil;
-
-    END_BLOCK_OBJC_EXCEPTIONS;
-    return nil;
-}
-
-void DictionaryLookup::showPopup(const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback, WTF::Function<void()>&& clearTextIndicator)
-{
-    showPopupOrCreateAnimationController(false, dictionaryPopupInfo, view, textIndicatorInstallationCallback, rootViewToViewConversionCallback, WTFMove(clearTextIndicator));
-}
-
-void DictionaryLookup::hidePopup()
-{
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
-    if (!getLULookupDefinitionModuleClass())
-        return;
-    [getLULookupDefinitionModuleClass() hideDefinition];
-
-    END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-id <NSImmediateActionAnimationController> DictionaryLookup::animationControllerForPopup(const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, const WTF::Function<void(TextIndicator&)>& textIndicatorInstallationCallback, const WTF::Function<FloatRect(FloatRect)>& rootViewToViewConversionCallback, WTF::Function<void()>&& clearTextIndicator)
-{
-    return showPopupOrCreateAnimationController(true, dictionaryPopupInfo, view, textIndicatorInstallationCallback, rootViewToViewConversionCallback, WTFMove(clearTextIndicator));
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(MAC)
</del></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebKit/ChangeLog       2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -1,3 +1,51 @@
</span><ins>+2018-11-29  Megan Gardner  <megan_gardner@apple.com>
+
+        Move Lookup Code for better cross platform usage
+        https://bugs.webkit.org/show_bug.cgi?id=191732
+
+        Reviewed by Alex Christensen.
+
+        Lookup is being replaced by Reveal. This framework should work on all platforms.
+        The patch moves the code that we expect will be needed for all platforms to the more
+        general cocoa area. This patch changes no funcationality, and should not change
+        anything currently. This work will be build on later when Reveal is ready to support
+        multiple platforms.
+
+        * Platform/spi/ios/UIKitSPI.h:
+        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+        (WebKit::WebPageProxy::performDictionaryLookupAtLocation):
+        (WebKit::WebPageProxy::performDictionaryLookupOfCurrentSelection):
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView setupInteraction]):
+        (-[WKContentView cleanupInteraction]):
+        (-[WKContentView _removeDefaultGestureRecognizers]):
+        (-[WKContentView _addDefaultGestureRecognizers]):
+        (-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
+        (-[WKContentView _lookupGestureRecognized:]):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::performDictionaryLookupAtLocation): Deleted.
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::performDictionaryLookupAtLocation): Deleted.
+        (WebKit::WebPageProxy::performDictionaryLookupOfCurrentSelection): Deleted.
+        * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
+        (WebKit::WebPage::performDictionaryLookupAtLocation):
+        (WebKit::WebPage::performDictionaryLookupForSelection):
+        (WebKit::WebPage::performDictionaryLookupOfCurrentSelection):
+        (WebKit::WebPage::performDictionaryLookupForRange):
+        (WebKit::WebPage::dictionaryPopupInfoForRange):
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::performDictionaryLookupAtLocation): Deleted.
+        (WebKit::WebPage::performDictionaryLookupForSelection): Deleted.
+        (WebKit::WebPage::performDictionaryLookupForRange): Deleted.
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::performDictionaryLookupAtLocation): Deleted.
+        (WebKit::WebPage::performDictionaryLookupForSelection): Deleted.
+        (WebKit::WebPage::performDictionaryLookupOfCurrentSelection): Deleted.
+        (WebKit::WebPage::dictionaryPopupInfoForRange): Deleted.
+        (WebKit::WebPage::performDictionaryLookupForRange): Deleted.
+
</ins><span class="cx"> 2018-11-29  Zalan Bujtas  <zalan@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [ContentObservation] Decouple content change and DOM timer scheduling observation
</span></span></pre></div>
<a id="trunkSourceWebKitPlatformspiiosUIKitSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h  2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h     2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -733,6 +733,9 @@
</span><span class="cx">     bool isPotentialTap;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+@interface _UILookupGestureRecognizer : UIGestureRecognizer
+@end
+
</ins><span class="cx"> @class UIWebTouchEventsGestureRecognizer;
</span><span class="cx"> 
</span><span class="cx"> @protocol UIWebTouchEventsGestureRecognizerDelegate <NSObject>
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaWebPageProxyCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm    2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #import "PageClient.h"
</span><span class="cx"> #import "SafeBrowsingSPI.h"
</span><span class="cx"> #import "SafeBrowsingWarning.h"
</span><ins>+#import "WebPageMessages.h"
</ins><span class="cx"> #import "WebProcessProxy.h"
</span><span class="cx"> #import <WebCore/DragItem.h>
</span><span class="cx"> #import <WebCore/NotImplemented.h>
</span><span class="lines">@@ -189,5 +190,21 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(ATTACHMENT_ELEMENT)
</span><ins>+    
+void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint& point)
+{
+    if (!isValid())
+        return;
+    
+    process().send(Messages::WebPage::PerformDictionaryLookupAtLocation(point), m_pageID);
+}
</ins><span class="cx"> 
</span><ins>+void WebPageProxy::performDictionaryLookupOfCurrentSelection()
+{
+    if (!isValid())
+        return;
+    
+    process().send(Messages::WebPage::PerformDictionaryLookupOfCurrentSelection(), m_pageID);
</ins><span class="cx"> }
</span><ins>+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosWKContentViewInteractionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h     2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h        2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -87,6 +87,7 @@
</span><span class="cx"> class WebPageProxy;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+@class _UILookupGestureRecognizer;
</ins><span class="cx"> @class _UIHighlightView;
</span><span class="cx"> @class _UIWebHighlightLongPressGestureRecognizer;
</span><span class="cx"> @class UIHoverGestureRecognizer;
</span><span class="lines">@@ -215,6 +216,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOSMAC)
</span><span class="cx">     RetainPtr<UIHoverGestureRecognizer> _hoverGestureRecognizer;
</span><ins>+    RetainPtr<_UILookupGestureRecognizer> _lookupGestureRecognizer;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     RetainPtr<UIWKTextInteractionAssistant> _textSelectionAssistant;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm    2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm       2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -112,6 +112,7 @@
</span><span class="cx"> #if PLATFORM(IOSMAC)
</span><span class="cx"> #import "NativeWebMouseEvent.h"
</span><span class="cx"> #import <UIKit/UIHoverGestureRecognizer.h>
</span><ins>+#import <UIKit/_UILookupGestureRecognizer.h>
</ins><span class="cx"> #import <pal/spi/ios/GraphicsServicesSPI.h>
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -649,6 +650,11 @@
</span><span class="cx">     _hoverGestureRecognizer = adoptNS([[UIHoverGestureRecognizer alloc] initWithTarget:self action:@selector(_hoverGestureRecognizerChanged:)]);
</span><span class="cx">     [_hoverGestureRecognizer setDelegate:self];
</span><span class="cx">     [self addGestureRecognizer:_hoverGestureRecognizer.get()];
</span><ins>+    
+    _lookupGestureRecognizer = adoptNS([[_UILookupGestureRecognizer alloc] initWithTarget:self action:@selector(_lookupGestureRecognized:)]);
+    [_lookupGestureRecognizer setDelegate:self];
+    [self addGestureRecognizer:_lookupGestureRecognizer.get()];
+    
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     _singleTapGestureRecognizer = adoptNS([[WKSyntheticClickTapGestureRecognizer alloc] initWithTarget:self action:@selector(_singleTapCommited:)]);
</span><span class="lines">@@ -759,6 +765,9 @@
</span><span class="cx"> #if PLATFORM(IOSMAC)
</span><span class="cx">     [_hoverGestureRecognizer setDelegate:nil];
</span><span class="cx">     [self removeGestureRecognizer:_hoverGestureRecognizer.get()];
</span><ins>+    
+    [_lookupGestureRecognizer setDelegate:nil];
+    [self removeGestureRecognizer:_lookupGestureRecognizer.get()];
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     [_singleTapGestureRecognizer setDelegate:nil];
</span><span class="lines">@@ -846,6 +855,7 @@
</span><span class="cx">     [self removeGestureRecognizer:_stylusSingleTapGestureRecognizer.get()];
</span><span class="cx"> #if PLATFORM(IOSMAC)
</span><span class="cx">     [self removeGestureRecognizer:_hoverGestureRecognizer.get()];
</span><ins>+    [self removeGestureRecognizer:_lookupGestureRecognizer.get()];
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -861,6 +871,7 @@
</span><span class="cx">     [self addGestureRecognizer:_stylusSingleTapGestureRecognizer.get()];
</span><span class="cx"> #if PLATFORM(IOSMAC)
</span><span class="cx">     [self addGestureRecognizer:_hoverGestureRecognizer.get()];
</span><ins>+    [self addGestureRecognizer:_lookupGestureRecognizer.get()];
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1467,6 +1478,10 @@
</span><span class="cx"> 
</span><span class="cx">     if ([gestureRecognizer isKindOfClass:[UIHoverGestureRecognizer class]] || [otherGestureRecognizer isKindOfClass:[UIHoverGestureRecognizer class]])
</span><span class="cx">         return YES;
</span><ins>+    
+    if (([gestureRecognizer isKindOfClass:[_UILookupGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) || ([otherGestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]] && [gestureRecognizer isKindOfClass:[_UILookupGestureRecognizer class]]))
+        return YES;
+
</ins><span class="cx"> #endif
</span><span class="cx">     if (isSamePair(gestureRecognizer, otherGestureRecognizer, _highlightLongPressGestureRecognizer.get(), _textSelectionAssistant.get().forcePressGesture))
</span><span class="cx">         return YES;
</span><span class="lines">@@ -6057,6 +6072,12 @@
</span><span class="cx"> #endif // PLATFORM(WATCHOS)
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOSMAC)
</span><ins>+- (void)_lookupGestureRecognized:(UIGestureRecognizer *)gestureRecognizer
+{
+    NSPoint locationInViewCoordinates = [gestureRecognizer locationInView:self];
+    _page->performDictionaryLookupAtLocation(WebCore::FloatPoint(locationInViewCoordinates));
+}
+
</ins><span class="cx"> - (void)_hoverGestureRecognizerChanged:(UIGestureRecognizer *)gestureRecognizer
</span><span class="cx"> {
</span><span class="cx">     if (!_page->isValid())
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosWebPageProxyIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm     2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm        2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -121,11 +121,6 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint&)
-{
-    notImplemented();
-}
-
</del><span class="cx"> void WebPageProxy::gestureCallback(const WebCore::IntPoint& point, uint32_t gestureType, uint32_t gestureState, uint32_t flags, CallbackID callbackID)
</span><span class="cx"> {
</span><span class="cx">     auto callback = m_callbacks.take<GestureCallback>(callbackID);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessmacWebPageProxyMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm     2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm        2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -323,22 +323,6 @@
</span><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint& point)
-{
-    if (!isValid())
-        return;
-
-    process().send(Messages::WebPage::PerformDictionaryLookupAtLocation(point), m_pageID);
-}
-
-void WebPageProxy::performDictionaryLookupOfCurrentSelection()
-{
-    if (!isValid())
-        return;
-
-    process().send(Messages::WebPage::PerformDictionaryLookupOfCurrentSelection(), m_pageID);
-}
-
</del><span class="cx"> // Complex text input support for plug-ins.
</span><span class="cx"> void WebPageProxy::sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageCocoaWebPageCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm     2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm        2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -26,9 +26,20 @@
</span><span class="cx"> #import "config.h"
</span><span class="cx"> #import "WebPage.h"
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx"> #import "LoadParameters.h"
</span><ins>+#import "PluginView.h"
</ins><span class="cx"> #import "WebPageProxyMessages.h"
</span><ins>+#import <WebCore/DictionaryLookup.h>
+#import <WebCore/Editor.h>
+#import <WebCore/EventHandler.h>
+#import <WebCore/FocusController.h>
+#import <WebCore/HTMLConverter.h>
+#import <WebCore/HitTestResult.h>
+#import <WebCore/NodeRenderStyle.h>
</ins><span class="cx"> #import <WebCore/PlatformMediaSessionManager.h>
</span><ins>+#import <WebCore/RenderElement.h>
+#import <WebCore/RenderObject.h>
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> 
</span><span class="lines">@@ -59,7 +70,115 @@
</span><span class="cx"> 
</span><span class="cx">     send(Messages::WebPageProxy::NowPlayingInfoCallback(hasActiveSession, registeredAsNowPlayingApplication, title, duration, elapsedTime, uniqueIdentifier, callbackID));
</span><span class="cx"> }
</span><ins>+    
+void WebPage::performDictionaryLookupAtLocation(const FloatPoint& floatPoint)
+{
+    if (auto* pluginView = pluginViewForFrame(&m_page->mainFrame())) {
+        if (pluginView->performDictionaryLookupAtLocation(floatPoint))
+            return;
+    }
+    
+    // Find the frame the point is over.
+    HitTestResult result = m_page->mainFrame().eventHandler().hitTestResultAtPoint(m_page->mainFrame().view()->windowToContents(roundedIntPoint(floatPoint)));
+    RefPtr<Range> range;
+    NSDictionary *options;
+    std::tie(range, options) = DictionaryLookup::rangeAtHitTestResult(result);
+    if (!range)
+        return;
+    
+    auto* frame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document().frame() : &m_page->focusController().focusedOrMainFrame();
+    if (!frame)
+        return;
+    
+    performDictionaryLookupForRange(*frame, *range, options, TextIndicatorPresentationTransition::Bounce);
+}
</ins><span class="cx"> 
</span><ins>+void WebPage::performDictionaryLookupForSelection(Frame& frame, const VisibleSelection& selection, TextIndicatorPresentationTransition presentationTransition)
+{
+    RefPtr<Range> selectedRange;
+    NSDictionary *options;
+    std::tie(selectedRange, options) = DictionaryLookup::rangeForSelection(selection);
+    if (selectedRange)
+        performDictionaryLookupForRange(frame, *selectedRange, options, presentationTransition);
+}
+
+void WebPage::performDictionaryLookupOfCurrentSelection()
+{
+    auto& frame = m_page->focusController().focusedOrMainFrame();
+    performDictionaryLookupForSelection(frame, frame.selection().selection(), TextIndicatorPresentationTransition::BounceAndCrossfade);
+}
+    
+void WebPage::performDictionaryLookupForRange(Frame& frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition)
+{
+    send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfoForRange(frame, range, options, presentationTransition)));
+}
+
+DictionaryPopupInfo WebPage::dictionaryPopupInfoForRange(Frame& frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition)
+{
+    Editor& editor = frame.editor();
+    editor.setIsGettingDictionaryPopupInfo(true);
+    
+    DictionaryPopupInfo dictionaryPopupInfo;
+    if (range.text().stripWhiteSpace().isEmpty()) {
+        editor.setIsGettingDictionaryPopupInfo(false);
+        return dictionaryPopupInfo;
+    }
+    
+    Vector<FloatQuad> quads;
+    range.absoluteTextQuads(quads);
+    if (quads.isEmpty()) {
+        editor.setIsGettingDictionaryPopupInfo(false);
+        return dictionaryPopupInfo;
+    }
+    
+    IntRect rangeRect = frame.view()->contentsToWindow(quads[0].enclosingBoundingBox());
+    
+    const RenderStyle* style = range.startContainer().renderStyle();
+    float scaledAscent = style ? style->fontMetrics().ascent() * pageScaleFactor() : 0;
+    dictionaryPopupInfo.origin = FloatPoint(rangeRect.x(), rangeRect.y() + scaledAscent);
+    dictionaryPopupInfo.options = options;
+
+#if PLATFORM(MAC)
+
+    NSAttributedString *nsAttributedString = editingAttributedStringFromRange(range, IncludeImagesInAttributedString::No);
+    
+    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()];
+        if (font)
+            [scaledAttributes setObject:font forKey:NSFontAttributeName];
+        
+        [scaledNSAttributedString addAttributes:scaledAttributes.get() range:range];
+    }];
+
+#endif // PLATFORM(MAC)
+    
+    TextIndicatorOptions indicatorOptions = TextIndicatorOptionUseBoundingRectAndPaintAllContentForComplexRanges;
+    if (presentationTransition == TextIndicatorPresentationTransition::BounceAndCrossfade)
+        indicatorOptions |= TextIndicatorOptionIncludeSnapshotWithSelectionHighlight;
+    
+    RefPtr<TextIndicator> textIndicator = TextIndicator::createWithRange(range, indicatorOptions, presentationTransition);
+    if (!textIndicator) {
+        editor.setIsGettingDictionaryPopupInfo(false);
+        return dictionaryPopupInfo;
+    }
+    
+    dictionaryPopupInfo.textIndicator = textIndicator->data();
+#if PLATFORM(MAC)
+    dictionaryPopupInfo.attributedString = scaledNSAttributedString;
+#endif // PLATFORM(MAC)
+    
+    editor.setIsGettingDictionaryPopupInfo(false);
+    return dictionaryPopupInfo;
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif // PLATFORM(COCOA)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in       2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in  2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -191,6 +191,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     # Dictionary support.
</span><ins>+    PerformDictionaryLookupOfCurrentSelection()
</ins><span class="cx">     PerformDictionaryLookupAtLocation(WebCore::FloatPoint point)
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -199,10 +200,6 @@
</span><span class="cx">     RemoveDataDetectedLinks() -> (struct WebKit::DataDetectionResult result) Async
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(MAC)
-    PerformDictionaryLookupOfCurrentSelection()
-#endif
-
</del><span class="cx">     ChangeFont(WebCore::FontChanges changes)
</span><span class="cx">     ChangeFontAttributes(WebCore::FontAttributeChanges changes)
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm    2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -417,21 +417,6 @@
</span><span class="cx">     notImplemented();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPage::performDictionaryLookupAtLocation(const FloatPoint&)
-{
-    notImplemented();
-}
-
-void WebPage::performDictionaryLookupForSelection(Frame&, const VisibleSelection&, TextIndicatorPresentationTransition)
-{
-    notImplemented();
-}
-
-void WebPage::performDictionaryLookupForRange(Frame&, Range&, NSDictionary *, TextIndicatorPresentationTransition)
-{
-    notImplemented();
-}
-
</del><span class="cx"> bool WebPage::performNonEditingBehaviorForSelector(const String&, WebCore::KeyboardEvent*)
</span><span class="cx"> {
</span><span class="cx">     notImplemented();
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPagemacWebPageMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (238696 => 238697)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm 2018-11-29 22:56:04 UTC (rev 238696)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm    2018-11-29 22:59:07 UTC (rev 238697)
</span><span class="lines">@@ -389,103 +389,8 @@
</span><span class="cx">     send(Messages::WebPageProxy::FontAtSelectionCallback(fontName, fontSize, selectionHasMultipleFonts, callbackID));
</span><span class="cx"> }
</span><span class="cx">     
</span><del>-void WebPage::performDictionaryLookupAtLocation(const FloatPoint& floatPoint)
-{
-    if (auto* pluginView = pluginViewForFrame(&m_page->mainFrame())) {
-        if (pluginView->performDictionaryLookupAtLocation(floatPoint))
-            return;
-    }
</del><span class="cx"> 
</span><del>-    // Find the frame the point is over.
-    HitTestResult result = m_page->mainFrame().eventHandler().hitTestResultAtPoint(m_page->mainFrame().view()->windowToContents(roundedIntPoint(floatPoint)));
-    RefPtr<Range> range;
-    NSDictionary *options;
-    std::tie(range, options) = DictionaryLookup::rangeAtHitTestResult(result);
-    if (!range)
-        return;
</del><span class="cx"> 
</span><del>-    auto* frame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document().frame() : &m_page->focusController().focusedOrMainFrame();
-    if (!frame)
-        return;
-
-    performDictionaryLookupForRange(*frame, *range, options, TextIndicatorPresentationTransition::Bounce);
-}
-
-void WebPage::performDictionaryLookupForSelection(Frame& frame, const VisibleSelection& selection, TextIndicatorPresentationTransition presentationTransition)
-{
-    RefPtr<Range> selectedRange;
-    NSDictionary *options;
-    std::tie(selectedRange, options) = DictionaryLookup::rangeForSelection(selection);
-    if (selectedRange)
-        performDictionaryLookupForRange(frame, *selectedRange, options, presentationTransition);
-}
-
-void WebPage::performDictionaryLookupOfCurrentSelection()
-{
-    auto& frame = m_page->focusController().focusedOrMainFrame();
-    performDictionaryLookupForSelection(frame, frame.selection().selection(), TextIndicatorPresentationTransition::BounceAndCrossfade);
-}
-
-DictionaryPopupInfo WebPage::dictionaryPopupInfoForRange(Frame& frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition)
-{
-    Editor& editor = frame.editor();
-    editor.setIsGettingDictionaryPopupInfo(true);
-
-    DictionaryPopupInfo dictionaryPopupInfo;
-    if (range.text().stripWhiteSpace().isEmpty()) {
-        editor.setIsGettingDictionaryPopupInfo(false);
-        return dictionaryPopupInfo;
-    }
-
-    Vector<FloatQuad> quads;
-    range.absoluteTextQuads(quads);
-    if (quads.isEmpty()) {
-        editor.setIsGettingDictionaryPopupInfo(false);
-        return dictionaryPopupInfo;
-    }
-
-    IntRect rangeRect = frame.view()->contentsToWindow(quads[0].enclosingBoundingBox());
-
-    const RenderStyle* style = range.startContainer().renderStyle();
-    float scaledAscent = style ? style->fontMetrics().ascent() * pageScaleFactor() : 0;
-    dictionaryPopupInfo.origin = FloatPoint(rangeRect.x(), rangeRect.y() + scaledAscent);
-    dictionaryPopupInfo.options = options;
-
-    NSAttributedString *nsAttributedString = editingAttributedStringFromRange(range, IncludeImagesInAttributedString::No);
-
-    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()];
-        if (font)
-            [scaledAttributes setObject:font forKey:NSFontAttributeName];
-
-        [scaledNSAttributedString addAttributes:scaledAttributes.get() range:range];
-    }];
-
-    TextIndicatorOptions indicatorOptions = TextIndicatorOptionUseBoundingRectAndPaintAllContentForComplexRanges;
-    if (presentationTransition == TextIndicatorPresentationTransition::BounceAndCrossfade)
-        indicatorOptions |= TextIndicatorOptionIncludeSnapshotWithSelectionHighlight;
-
-    RefPtr<TextIndicator> textIndicator = TextIndicator::createWithRange(range, indicatorOptions, presentationTransition);
-    if (!textIndicator) {
-        editor.setIsGettingDictionaryPopupInfo(false);
-        return dictionaryPopupInfo;
-    }
-
-    dictionaryPopupInfo.textIndicator = textIndicator->data();
-    dictionaryPopupInfo.attributedString = scaledNSAttributedString;
-
-    editor.setIsGettingDictionaryPopupInfo(false);
-    return dictionaryPopupInfo;
-}
-
</del><span class="cx"> #if ENABLE(PDFKIT_PLUGIN)
</span><span class="cx"> 
</span><span class="cx"> DictionaryPopupInfo WebPage::dictionaryPopupInfoForSelectionInPDFPlugin(PDFSelection *selection, PDFPlugin& pdfPlugin, NSDictionary *options, WebCore::TextIndicatorPresentationTransition presentationTransition)
</span><span class="lines">@@ -539,11 +444,6 @@
</span><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void WebPage::performDictionaryLookupForRange(Frame& frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition)
-{
-    send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfoForRange(frame, range, options, presentationTransition)));
-}
-
</del><span class="cx"> bool WebPage::performNonEditingBehaviorForSelector(const String& selector, KeyboardEvent* event)
</span><span class="cx"> {
</span><span class="cx">     // First give accessibility a chance to handle the event.
</span></span></pre>
</div>
</div>

</body>
</html>