<!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>[175661] branches/safari-600.3-branch/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/175661">175661</a></dd>
<dt>Author</dt> <dd>dburkart@apple.com</dd>
<dt>Date</dt> <dd>2014-11-05 20:24:18 -0800 (Wed, 05 Nov 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/175498">r175498</a>. rdar://problem/18742371</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6003branchSourceWebKit2ChangeLog">branches/safari-600.3-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2SharedAPIcWKActionMenuItemTypesh">branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2SharedAPIcWKActionMenuTypesh">branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2SharedmacActionMenuHitTestResulth">branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2SharedmacActionMenuHitTestResultmm">branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.mm</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2UIProcessWebPageProxyh">branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2UIProcessmacWKActionMenuControllermm">branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2WebProcessWebPageWebPageh">branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#branchessafari6003branchSourceWebKit2WebProcessWebPagemacWebPageMacmm">branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6003branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (175660 => 175661)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog        2014-11-06 04:12:28 UTC (rev 175660)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog        2014-11-06 04:24:18 UTC (rev 175661)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2014-11-03  Beth Dakin  &lt;bdakin@apple.com&gt;
+
+        Implement action menus for editable text with spelling suggestions
+        https://bugs.webkit.org/show_bug.cgi?id=138333
+        -and corresponding-
+        rdar://problem/18742371
+
+        Reviewed by Tim Horton.
+
+        New types.
+        * Shared/API/c/WKActionMenuItemTypes.h:
+        * Shared/API/c/WKActionMenuTypes.h:
+
+        ActionMenuHitTestResult now stores the String result of the lookup.
+        * Shared/mac/ActionMenuHitTestResult.h:
+        * Shared/mac/ActionMenuHitTestResult.mm:
+        (WebKit::ActionMenuHitTestResult::encode):
+        (WebKit::ActionMenuHitTestResult::decode):
+
+        Make getGuessesForWord() public so we can call it from WKActionMenuController.
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/mac/WKActionMenuController.mm:
+
+        Select the text for all types of text menus.
+        (-[WKActionMenuController isMenuForTextContent]):
+        (-[WKActionMenuController willOpenMenu:withEvent:]):
+
+        Spelling suggestions are presented in a sub-menu and will replace the selection 
+        when chosen.
+        (-[WKActionMenuController _defaultMenuItemsForEditableTextWithSuggestions:]):
+        (-[WKActionMenuController _changeSelectionToSuggestion:]):
+        (-[WKActionMenuController _createActionMenuItemForTag:]):
+        (-[WKActionMenuController _defaultMenuItems:]):
+
+        New function to store the lookupText as a String on the ActionMenuHitTestResult.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::performActionMenuHitTestAtLocation):
+        (WebKit::WebPage::lookupTextAtLocation):
+
</ins><span class="cx"> 2014-10-29  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Rename WebPageProxy::activeActionMenuHitTestResult to lastMouseMoveHitTestResult
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2SharedAPIcWKActionMenuItemTypesh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h (175660 => 175661)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h        2014-11-06 04:12:28 UTC (rev 175660)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h        2014-11-06 04:24:18 UTC (rev 175661)
</span><span class="lines">@@ -43,7 +43,8 @@
</span><span class="cx">     kWKContextActionItemTagShareImage,
</span><span class="cx">     kWKContextActionItemTagCopyText,
</span><span class="cx">     kWKContextActionItemTagLookupText,
</span><del>-    kWKContextActionItemTagPaste
</del><ins>+    kWKContextActionItemTagPaste,
+    kWKContextActionItemTagTextSuggestions
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #ifdef __cplusplus
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2SharedAPIcWKActionMenuTypesh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h (175660 => 175661)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h        2014-11-06 04:12:28 UTC (rev 175660)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/API/c/WKActionMenuTypes.h        2014-11-06 04:24:18 UTC (rev 175661)
</span><span class="lines">@@ -38,7 +38,8 @@
</span><span class="cx">     kWKActionMenuImage,
</span><span class="cx">     kWKActionMenuDataDetectedItem,
</span><span class="cx">     kWKActionMenuReadOnlyText,
</span><del>-    kWKActionMenuEditableText
</del><ins>+    kWKActionMenuEditableText,
+    kWKActionMenuEditableTextWithSuggestions
</ins><span class="cx"> };
</span><span class="cx"> typedef uint32_t _WKActionMenuType;
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2SharedmacActionMenuHitTestResulth"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h (175660 => 175661)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h        2014-11-06 04:12:28 UTC (rev 175660)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h        2014-11-06 04:24:18 UTC (rev 175661)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;ShareableBitmap.h&quot;
</span><span class="cx"> #include &quot;WebHitTestResult.h&quot;
</span><span class="cx"> #include &lt;WebCore/FloatRect.h&gt;
</span><ins>+#include &lt;wtf/text/WTFString.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> OBJC_CLASS DDActionContext;
</span><span class="cx"> 
</span><span class="lines">@@ -46,6 +47,7 @@
</span><span class="cx">     WebCore::FloatPoint hitTestLocationInViewCooordinates;
</span><span class="cx">     WebHitTestResult::Data hitTestResult;
</span><span class="cx"> 
</span><ins>+    String lookupText;
</ins><span class="cx">     RefPtr&lt;ShareableBitmap&gt; image;
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;DDActionContext&gt; actionContext;
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2SharedmacActionMenuHitTestResultmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.mm (175660 => 175661)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.mm        2014-11-06 04:12:28 UTC (rev 175660)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.mm        2014-11-06 04:24:18 UTC (rev 175661)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> {
</span><span class="cx">     encoder &lt;&lt; hitTestLocationInViewCooordinates;
</span><span class="cx">     encoder &lt;&lt; hitTestResult;
</span><ins>+    encoder &lt;&lt; lookupText;
</ins><span class="cx"> 
</span><span class="cx">     ShareableBitmap::Handle handle;
</span><span class="cx"> 
</span><span class="lines">@@ -70,6 +71,9 @@
</span><span class="cx">     if (!decoder.decode(actionMenuHitTestResult.hitTestResult))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    if (!decoder.decode(actionMenuHitTestResult.lookupText))
+        return false;
+
</ins><span class="cx">     ShareableBitmap::Handle handle;
</span><span class="cx">     if (!decoder.decode(handle))
</span><span class="cx">         return false;
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.h (175660 => 175661)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.h        2014-11-06 04:12:28 UTC (rev 175660)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.h        2014-11-06 04:24:18 UTC (rev 175661)
</span><span class="lines">@@ -919,6 +919,11 @@
</span><span class="cx">     void selectLookupTextAtLocation(WebCore::FloatPoint);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if USE(UNIFIED_TEXT_CHECKING)
+    void checkTextOfParagraph(const String&amp; text, uint64_t checkingTypes, Vector&lt;WebCore::TextCheckingResult&gt;&amp; results);
+#endif
+    void getGuessesForWord(const String&amp; word, const String&amp; context, Vector&lt;String&gt;&amp; guesses);
+
</ins><span class="cx"> private:
</span><span class="cx">     WebPageProxy(PageClient&amp;, WebProcessProxy&amp;, uint64_t pageID, const WebPageConfiguration&amp;);
</span><span class="cx">     void platformInitialize();
</span><span class="lines">@@ -1145,15 +1150,11 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     // Spelling and grammar.
</span><del>-#if USE(UNIFIED_TEXT_CHECKING)
-    void checkTextOfParagraph(const String&amp; text, uint64_t checkingTypes, Vector&lt;WebCore::TextCheckingResult&gt;&amp; results);
-#endif
</del><span class="cx">     void checkSpellingOfString(const String&amp; text, int32_t&amp; misspellingLocation, int32_t&amp; misspellingLength);
</span><span class="cx">     void checkGrammarOfString(const String&amp; text, Vector&lt;WebCore::GrammarDetail&gt;&amp;, int32_t&amp; badGrammarLocation, int32_t&amp; badGrammarLength);
</span><span class="cx">     void spellingUIIsShowing(bool&amp;);
</span><span class="cx">     void updateSpellingUIWithMisspelledWord(const String&amp; misspelledWord);
</span><span class="cx">     void updateSpellingUIWithGrammarString(const String&amp; badGrammarPhrase, const WebCore::GrammarDetail&amp;);
</span><del>-    void getGuessesForWord(const String&amp; word, const String&amp; context, Vector&lt;String&gt;&amp; guesses);
</del><span class="cx">     void learnWord(const String&amp; word);
</span><span class="cx">     void ignoreWord(const String&amp; word);
</span><span class="cx">     void requestCheckingOfString(uint64_t requestID, const WebCore::TextCheckingRequestData&amp;);
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2UIProcessmacWKActionMenuControllermm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm (175660 => 175661)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm        2014-11-06 04:12:28 UTC (rev 175660)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm        2014-11-06 04:24:18 UTC (rev 175661)
</span><span class="lines">@@ -110,12 +110,17 @@
</span><span class="cx">     [self _updateActionMenuItemsForStage:MenuUpdateStage::PrepareForMenu];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (BOOL)isMenuForTextContent
+{
+    return _type == kWKActionMenuReadOnlyText || _type == kWKActionMenuEditableText || _type == kWKActionMenuEditableTextWithSuggestions;
+}
+
</ins><span class="cx"> - (void)willOpenMenu:(NSMenu *)menu withEvent:(NSEvent *)event
</span><span class="cx"> {
</span><span class="cx">     if (menu != _wkView.actionMenu)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (_type != kWKActionMenuReadOnlyText &amp;&amp; _type != kWKActionMenuEditableText)
</del><ins>+    if (![self isMenuForTextContent])
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     // Action menus for text should highlight the text so that it is clear what the action menu actions
</span><span class="lines">@@ -338,21 +343,65 @@
</span><span class="cx">     return @[ copyTextItem.get(), lookupTextItem.get(), pasteItem.get() ];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>--(void)_copySelection:(id)sender
</del><ins>+- (NSArray *)_defaultMenuItemsForEditableTextWithSuggestions
</ins><span class="cx"> {
</span><ins>+    if (_hitTestResult.lookupText.isEmpty())
+        return @[ ];
+
+    Vector&lt;TextCheckingResult&gt; results;
+    _page-&gt;checkTextOfParagraph(_hitTestResult.lookupText, NSTextCheckingTypeSpelling, results);
+    if (results.isEmpty())
+        return @[ ];
+
+    Vector&lt;String&gt; guesses;
+    _page-&gt;getGuessesForWord(_hitTestResult.lookupText, String(), guesses);
+    if (guesses.isEmpty())
+        return @[ ];
+
+    RetainPtr&lt;NSMenu&gt; spellingSubMenu = adoptNS([[NSMenu alloc] init]);
+    for (const auto&amp; guess : guesses) {
+        RetainPtr&lt;NSMenuItem&gt; item = adoptNS([[NSMenuItem alloc] initWithTitle:guess action:@selector(_changeSelectionToSuggestion:) keyEquivalent:@&quot;&quot;]);
+        [item setRepresentedObject:guess];
+        [item setTarget:self];
+        [spellingSubMenu addItem:item.get()];
+    }
+
+    RetainPtr&lt;NSMenuItem&gt; copyTextItem = [self _createActionMenuItemForTag:kWKContextActionItemTagCopyText];
+    RetainPtr&lt;NSMenuItem&gt; lookupTextItem = [self _createActionMenuItemForTag:kWKContextActionItemTagLookupText];
+    RetainPtr&lt;NSMenuItem&gt; pasteItem = [self _createActionMenuItemForTag:kWKContextActionItemTagPaste];
+    RetainPtr&lt;NSMenuItem&gt; textSuggestionsItem = [self _createActionMenuItemForTag:kWKContextActionItemTagTextSuggestions];
+
+    [textSuggestionsItem setSubmenu:spellingSubMenu.get()];
+
+    return @[ copyTextItem.get(), lookupTextItem.get(), pasteItem.get(), textSuggestionsItem.get() ];
+}
+
+- (void)_copySelection:(id)sender
+{
</ins><span class="cx">     _page-&gt;executeEditCommand(&quot;copy&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>--(void)_paste:(id)sender
</del><ins>+- (void)_paste:(id)sender
</ins><span class="cx"> {
</span><span class="cx">     _page-&gt;executeEditCommand(&quot;paste&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>--(void)_lookupText:(id)sender
</del><ins>+- (void)_lookupText:(id)sender
</ins><span class="cx"> {
</span><span class="cx">     _page-&gt;performDictionaryLookupOfCurrentSelection();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_changeSelectionToSuggestion:(id)sender
+{
+    NSString *selectedCorrection = [sender representedObject];
+    if (!selectedCorrection)
+        return;
+
+    ASSERT([selectedCorrection isKindOfClass:[NSString class]]);
+
+    _page-&gt;changeSpellingToWord(selectedCorrection);
+}
+
</ins><span class="cx"> #pragma mark NSMenuDelegate implementation
</span><span class="cx"> 
</span><span class="cx"> - (void)menuNeedsUpdate:(NSMenu *)menu
</span><span class="lines">@@ -468,6 +517,11 @@
</span><span class="cx">         image = [NSImage imageNamed:@&quot;NSActionMenuPaste&quot;];
</span><span class="cx">         break;
</span><span class="cx"> 
</span><ins>+    case kWKContextActionItemTagTextSuggestions:
+        title = @&quot;Suggestions&quot;;
+        image = [NSImage imageNamed:@&quot;NSActionMenuSpelling&quot;];
+        break;
+
</ins><span class="cx">     default:
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         return nil;
</span><span class="lines">@@ -530,6 +584,12 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (hitTestResult-&gt;isContentEditable()) {
</span><ins>+            NSArray *editableTextWithSuggestions = [self _defaultMenuItemsForEditableTextWithSuggestions];
+            if (editableTextWithSuggestions.count) {
+                _type = kWKActionMenuEditableTextWithSuggestions;
+                return editableTextWithSuggestions;
+            }
+
</ins><span class="cx">             _type = kWKActionMenuEditableText;
</span><span class="cx">             return [self _defaultMenuItemsForEditableText];
</span><span class="cx">         }
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h (175660 => 175661)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-11-06 04:12:28 UTC (rev 175660)
+++ branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-11-06 04:24:18 UTC (rev 175661)
</span><span class="lines">@@ -1041,6 +1041,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     void performActionMenuHitTestAtLocation(WebCore::FloatPoint);
</span><ins>+    PassRefPtr&lt;WebCore::Range&gt; lookupTextAtLocation(WebCore::FloatPoint);
</ins><span class="cx">     void selectLookupTextAtLocation(WebCore::FloatPoint);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6003branchSourceWebKit2WebProcessWebPagemacWebPageMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (175660 => 175661)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2014-11-06 04:12:28 UTC (rev 175660)
+++ branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2014-11-06 04:24:18 UTC (rev 175661)
</span><span class="lines">@@ -1147,6 +1147,9 @@
</span><span class="cx">     actionMenuResult.hitTestLocationInViewCooordinates = locationInViewCooordinates;
</span><span class="cx">     actionMenuResult.hitTestResult = WebHitTestResult::Data(hitTestResult);
</span><span class="cx"> 
</span><ins>+    RefPtr&lt;WebCore::Range&gt; lookupRange = lookupTextAtLocation(locationInViewCooordinates);
+    actionMenuResult.lookupText = lookupRange ? lookupRange-&gt;text() : String();
+
</ins><span class="cx">     if (Image* image = hitTestResult.image()) {
</span><span class="cx">         actionMenuResult.image = ShareableBitmap::createShareable(IntSize(image-&gt;size()), ShareableBitmap::SupportsAlpha);
</span><span class="cx">         if (actionMenuResult.image)
</span><span class="lines">@@ -1167,6 +1170,18 @@
</span><span class="cx">     send(Messages::WebPageProxy::DidPerformActionMenuHitTest(actionMenuResult, InjectedBundleUserMessageEncoder(userData.get())));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+PassRefPtr&lt;WebCore::Range&gt; WebPage::lookupTextAtLocation(FloatPoint locationInViewCooordinates)
+{
+    MainFrame&amp; mainFrame = corePage()-&gt;mainFrame();
+    if (!mainFrame.view() || !mainFrame.view()-&gt;renderView())
+        return nullptr;
+
+    IntPoint point = roundedIntPoint(locationInViewCooordinates);
+    HitTestResult result = mainFrame.eventHandler().hitTestResultAtPoint(m_page-&gt;mainFrame().view()-&gt;windowToContents(point), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowChildFrameContent | HitTestRequest::IgnoreClipping);
+    NSDictionary *options = nil;
+    return rangeForDictionaryLookupAtHitTestResult(result, &amp;options);
+}
+
</ins><span class="cx"> void WebPage::selectLookupTextAtLocation(FloatPoint locationInWindowCooordinates)
</span><span class="cx"> {
</span><span class="cx">     MainFrame&amp; mainFrame = corePage()-&gt;mainFrame();
</span></span></pre>
</div>
</div>

</body>
</html>