<!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>[179792] trunk</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/179792">179792</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2015-02-07 18:43:40 -0800 (Sat, 07 Feb 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add some dictionary lookup tests
https://bugs.webkit.org/show_bug.cgi?id=141355

Reviewed by Darin Adler.

Tests: platform/mac/editing/dictionary-lookup/dictionary-lookup-input.html
       platform/mac/editing/dictionary-lookup/dictionary-lookup-inside-selection.html
       platform/mac/editing/dictionary-lookup/dictionary-lookup-outside-selection.html
       platform/mac/editing/dictionary-lookup/dictionary-lookup-rtl.html
       platform/mac/editing/dictionary-lookup/dictionary-lookup.html

* WebCore.exp.in:
Remove an unneeded export.

* editing/mac/DictionaryLookup.h:
Use OBJC_CLASS instead of @class so that this can be included in pure-C++ files.

* testing/Internals.cpp:
(WebCore::Internals::rangeForDictionaryLookupAtLocation):
* testing/Internals.h:
* testing/Internals.idl:
Expose rangeForDictionaryLookupAtHitTestResult fairly directly to JavaScript.

* platform/mac/editing/dictionary-lookup/dictionary-lookup-expected.txt: Added.
* platform/mac/editing/dictionary-lookup/dictionary-lookup-input-expected.txt: Added.
* platform/mac/editing/dictionary-lookup/dictionary-lookup-input.html: Added.
* platform/mac/editing/dictionary-lookup/dictionary-lookup-inside-selection-expected.txt: Added.
* platform/mac/editing/dictionary-lookup/dictionary-lookup-inside-selection.html: Added.
* platform/mac/editing/dictionary-lookup/dictionary-lookup-outside-selection-expected.txt: Added.
* platform/mac/editing/dictionary-lookup/dictionary-lookup-outside-selection.html: Added.
* platform/mac/editing/dictionary-lookup/dictionary-lookup-rtl-expected.txt: Added.
* platform/mac/editing/dictionary-lookup/dictionary-lookup-rtl.html: Added.
* platform/mac/editing/dictionary-lookup/dictionary-lookup.html: Added.
* platform/mac/editing/dictionary-lookup/lookup-test.js: Added.
(runTest):
Add tests for various cases that we've had trouble with in the past.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreeditingmacDictionaryLookuph">trunk/Source/WebCore/editing/mac/DictionaryLookup.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/platform/mac/editing/dictionary-lookup/</li>
<li><a href="#trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookupexpectedtxt">trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookupinputexpectedtxt">trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-input-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookupinputhtml">trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-input.html</a></li>
<li><a href="#trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookupinsideselectionexpectedtxt">trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-inside-selection-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookupinsideselectionhtml">trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-inside-selection.html</a></li>
<li><a href="#trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookupoutsideselectionexpectedtxt">trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-outside-selection-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookupoutsideselectionhtml">trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-outside-selection.html</a></li>
<li><a href="#trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookuprtlexpectedtxt">trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-rtl-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookuprtlhtml">trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-rtl.html</a></li>
<li><a href="#trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookuphtml">trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup.html</a></li>
<li><a href="#trunkLayoutTestsplatformmaceditingdictionarylookuplookuptestjs">trunk/LayoutTests/platform/mac/editing/dictionary-lookup/lookup-test.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (179791 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-02-08 02:28:48 UTC (rev 179791)
+++ trunk/LayoutTests/ChangeLog        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2015-02-07  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Add some dictionary lookup tests
+        https://bugs.webkit.org/show_bug.cgi?id=141355
+
+        Reviewed by Darin Adler.
+
+        * platform/mac/editing/dictionary-lookup/dictionary-lookup-expected.txt: Added.
+        * platform/mac/editing/dictionary-lookup/dictionary-lookup-input-expected.txt: Added.
+        * platform/mac/editing/dictionary-lookup/dictionary-lookup-input.html: Added.
+        * platform/mac/editing/dictionary-lookup/dictionary-lookup-inside-selection-expected.txt: Added.
+        * platform/mac/editing/dictionary-lookup/dictionary-lookup-inside-selection.html: Added.
+        * platform/mac/editing/dictionary-lookup/dictionary-lookup-outside-selection-expected.txt: Added.
+        * platform/mac/editing/dictionary-lookup/dictionary-lookup-outside-selection.html: Added.
+        * platform/mac/editing/dictionary-lookup/dictionary-lookup-rtl-expected.txt: Added.
+        * platform/mac/editing/dictionary-lookup/dictionary-lookup-rtl.html: Added.
+        * platform/mac/editing/dictionary-lookup/dictionary-lookup.html: Added.
+        * platform/mac/editing/dictionary-lookup/lookup-test.js: Added.
+        (runTest):
+        Add tests for various cases that we've had trouble with in the past.
+
</ins><span class="cx"> 2015-02-07  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed gardening.
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookupexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-expected.txt (0 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-expected.txt        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+Some text to look up.
+I love New York.
+Some text to look up.
+
+Lookup string for normal text: 'look'.
+Lookup string for title-case phrase: 'New York'.
+Lookup string for unselectable text: 'null'.
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookupinputexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-input-expected.txt (0 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-input-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-input-expected.txt        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+
+
+Some text to look up.
+
+Lookup string for input type=text field: 'withaverylongwordinthemiddle'.
+Lookup string for password field: 'null'.
+Lookup string for contentEditable div: 'look'.
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookupinputhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-input.html (0 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-input.html                                (rev 0)
+++ trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-input.html        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;lookup-test.js&quot;&gt;&lt;/script&gt;&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+&lt;!-- Text input fields should be available to look up as usual. --&gt;
+&lt;input type=&quot;text&quot; class=&quot;lookupInCenter&quot; data-name=&quot;input type=text field&quot; value=&quot;Text withaverylongwordinthemiddle to hit.&quot;&gt;&lt;/input&gt;&lt;br/&gt;
+&lt;!-- Password fields should not be available to look up. --&gt;
+&lt;input type=&quot;password&quot; class=&quot;lookupInCenter&quot; data-name=&quot;password field&quot; value=&quot;some very long password string&quot;&gt;&lt;/input&gt;&lt;br/&gt;
+&lt;!-- contentEditable areas should be available to look up as usual. --&gt;
+&lt;div contenteditable&gt;Some text to &lt;span class=&quot;lookupInCenter&quot; data-name=&quot;contentEditable div&quot;&gt;look&lt;/span&gt; up.&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookupinsideselectionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-inside-selection-expected.txt (0 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-inside-selection-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-inside-selection-expected.txt        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+Some text to not look up. This part is all selected, and should be taken as a unit when looked up.
+
+Lookup string for inside selected text: 'This part is all selected, and should be taken as a unit when looked up.'.
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookupinsideselectionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-inside-selection.html (0 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-inside-selection.html                                (rev 0)
+++ trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-inside-selection.html        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+    &lt;script type=&quot;text/javascript&quot; src=&quot;lookup-test.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+window.onload = function () {
+    var selection = window.getSelection();
+    var range = document.createRange();
+    range.selectNode(document.getElementById(&quot;select&quot;));
+    selection.addRange(range);
+
+    runTest();
+}
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;!-- The hit word is inside the selection, so the whole selection should be looked up. --&gt;
+&lt;div&gt;Some text to not look up. &lt;span id=&quot;select&quot;&gt;This part is all selected, and should be taken as a &lt;span class=&quot;lookupInCenter&quot; data-name=&quot;inside selected text&quot;&gt;unit&lt;/span&gt; when looked up.&lt;/span&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookupoutsideselectionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-outside-selection-expected.txt (0 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-outside-selection-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-outside-selection-expected.txt        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+Some text to look up. This part is all selected, but the hit word is elsewhere so that doesn't matter.
+
+Lookup string for outside selected text: 'text'.
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookupoutsideselectionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-outside-selection.html (0 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-outside-selection.html                                (rev 0)
+++ trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-outside-selection.html        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+    &lt;script type=&quot;text/javascript&quot; src=&quot;lookup-test.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+window.onload = function () {
+    var selection = window.getSelection();
+    var range = document.createRange();
+    range.selectNode(document.getElementById(&quot;select&quot;));
+    selection.addRange(range);
+
+    runTest();
+}
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;!-- The hit word is outside the selection, so the selection should be ignored. --&gt;
+&lt;div&gt;Some &lt;span class=&quot;lookupInCenter&quot; data-name=&quot;outside selected text&quot;&gt;text&lt;/span&gt; to look up. &lt;span id=&quot;select&quot;&gt;This part is all selected, but the hit word is elsewhere so that doesn't matter.&lt;/span&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookuprtlexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-rtl-expected.txt (0 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-rtl-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-rtl-expected.txt        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+عذراً الصفحة المطلوبة غير موجودة.
+
+Lookup string for right-to-left text: 'المطلوبة'.
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookuprtlhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-rtl.html (0 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-rtl.html                                (rev 0)
+++ trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup-rtl.html        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+    &lt;script type=&quot;text/javascript&quot; src=&quot;lookup-test.js&quot;&gt;&lt;/script&gt;
+    &lt;meta charset=&quot;UTF-8&quot;&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+&lt;div dir=&quot;RTL&quot;&gt;عذراً الصفحة &lt;span class=&quot;lookupInCenter&quot; data-name=&quot;right-to-left text&quot;&gt;المطلوبة&lt;/span&gt; غير موجودة.&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaceditingdictionarylookupdictionarylookuphtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup.html (0 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup.html                                (rev 0)
+++ trunk/LayoutTests/platform/mac/editing/dictionary-lookup/dictionary-lookup.html        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;lookup-test.js&quot;&gt;&lt;/script&gt;&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+&lt;!-- Plain text should be available to look up. --&gt;
+&lt;div&gt;Some text to &lt;span class=&quot;lookupInCenter&quot; data-name=&quot;normal text&quot;&gt;look&lt;/span&gt; up.&lt;/div&gt;
+&lt;!-- Title-case phrases should be looked up as a unit. --&gt;
+&lt;div&gt;I love &lt;span class=&quot;lookupInCenter&quot; data-name=&quot;title-case phrase&quot;&gt;New&lt;/span&gt; York.&lt;/div&gt;
+&lt;!-- Unselectable text should not be looked up. --&gt;
+&lt;div style=&quot;-webkit-user-select: none;&quot;&gt;Some text to &lt;span class=&quot;lookupInCenter&quot; data-name=&quot;unselectable text&quot;&gt;look&lt;/span&gt; up.&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaceditingdictionarylookuplookuptestjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/editing/dictionary-lookup/lookup-test.js (0 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/editing/dictionary-lookup/lookup-test.js                                (rev 0)
+++ trunk/LayoutTests/platform/mac/editing/dictionary-lookup/lookup-test.js        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+function runTest() {
+    if (!window.testRunner || !internals) {
+        document.body.innerHTML += &quot;&lt;br/&gt;ERROR: This test cannot be run interactively.&quot;;
+        return;
+    }
+
+    testRunner.dumpAsText();
+
+    var targets = document.getElementsByClassName(&quot;lookupInCenter&quot;);
+    Array.prototype.forEach.call(targets, function(target) {
+        var spanRects = target.getClientRects();
+
+        if (spanRects.count &gt; 1) {
+            document.body.innerHTML += &quot;&lt;br/&gt;ERROR: More than one rect for hit word.&quot;
+            return;
+        }
+
+        var rect = spanRects[0];
+        var x = rect.left + rect.width / 2;
+        var y = rect.top + rect.height / 2;
+
+        var lookupRange = internals.rangeForDictionaryLookupAtLocation(x, y);
+        
+        document.body.innerHTML += &quot;&lt;br/&gt;Lookup string for &quot; + target.dataset[&quot;name&quot;] + &quot;: '&quot; + lookupRange + &quot;'.&quot;;
+    });
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (179791 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-02-08 02:28:48 UTC (rev 179791)
+++ trunk/Source/WebCore/ChangeLog        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2015-02-07  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Add some dictionary lookup tests
+        https://bugs.webkit.org/show_bug.cgi?id=141355
+
+        Reviewed by Darin Adler.
+
+        Tests: platform/mac/editing/dictionary-lookup/dictionary-lookup-input.html
+               platform/mac/editing/dictionary-lookup/dictionary-lookup-inside-selection.html
+               platform/mac/editing/dictionary-lookup/dictionary-lookup-outside-selection.html
+               platform/mac/editing/dictionary-lookup/dictionary-lookup-rtl.html
+               platform/mac/editing/dictionary-lookup/dictionary-lookup.html
+
+        * WebCore.exp.in:
+        Remove an unneeded export.
+
+        * editing/mac/DictionaryLookup.h:
+        Use OBJC_CLASS instead of @class so that this can be included in pure-C++ files.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::rangeForDictionaryLookupAtLocation):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+        Expose rangeForDictionaryLookupAtHitTestResult fairly directly to JavaScript.
+
</ins><span class="cx"> 2015-02-07  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add Vector::removeFirstMatching() / removeAllMatching() methods taking lambda functions
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (179791 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2015-02-08 02:28:48 UTC (rev 179791)
+++ trunk/Source/WebCore/WebCore.exp.in        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -2454,7 +2454,6 @@
</span><span class="cx"> __ZN7WebCore36rangeForDictionaryLookupForSelectionERKNS_16VisibleSelectionEPP12NSDictionary
</span><span class="cx"> __ZN7WebCore37contextMenuItemTagTransformationsMenuEv
</span><span class="cx"> __ZN7WebCore38contextMenuItemTagWritingDirectionMenuEv
</span><del>-__ZN7WebCore39rangeExpandedAroundPositionByCharactersERKNS_15VisiblePositionEi
</del><span class="cx"> __ZN7WebCore39rangeForDictionaryLookupAtHitTestResultERKNS_13HitTestResultEPP12NSDictionary
</span><span class="cx"> __ZN7WebCore42contextMenuItemTagCheckGrammarWithSpellingEv
</span><span class="cx"> __ZN7WebCore42contextMenuItemTagCheckSpellingWhileTypingEv
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingmacDictionaryLookuph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/mac/DictionaryLookup.h (179791 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/mac/DictionaryLookup.h        2015-02-08 02:28:48 UTC (rev 179791)
+++ trunk/Source/WebCore/editing/mac/DictionaryLookup.h        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &lt;wtf/PassRefPtr.h&gt;
</span><span class="cx"> 
</span><del>-@class NSDictionary;
</del><ins>+OBJC_CLASS NSDictionary;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (179791 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2015-02-08 02:28:48 UTC (rev 179791)
+++ trunk/Source/WebCore/testing/Internals.cpp        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -166,6 +166,10 @@
</span><span class="cx"> #include &quot;MockMediaPlayerMediaSource.h&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC)
+#include &quot;DictionaryLookup.h&quot;
+#endif
+
</ins><span class="cx"> using JSC::CodeBlock;
</span><span class="cx"> using JSC::FunctionExecutable;
</span><span class="cx"> using JSC::JSFunction;
</span><span class="lines">@@ -1086,6 +1090,28 @@
</span><span class="cx">     return TextIterator::subrange(range, rangeLocation, rangeLength);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr&lt;Range&gt; Internals::rangeForDictionaryLookupAtLocation(int x, int y, ExceptionCode&amp; ec)
+{
+#if PLATFORM(MAC)
+    Document* document = contextDocument();
+    if (!document || !document-&gt;frame()) {
+        ec = INVALID_ACCESS_ERR;
+        return nullptr;
+    }
+
+    document-&gt;updateLayoutIgnorePendingStylesheets();
+    
+    HitTestResult result = document-&gt;frame()-&gt;mainFrame().eventHandler().hitTestResultAtPoint(IntPoint(x, y));
+    NSDictionary *options = nullptr;
+    return rangeForDictionaryLookupAtHitTestResult(result, &amp;options);
+#else
+    UNUSED_PARAM(x);
+    UNUSED_PARAM(y);
+    ec = INVALID_ACCESS_ERR;
+    return nullptr;
+#endif
+}
+
</ins><span class="cx"> void Internals::setDelegatesScrolling(bool enabled, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     Document* document = contextDocument();
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (179791 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h        2015-02-08 02:28:48 UTC (rev 179791)
+++ trunk/Source/WebCore/testing/Internals.h        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -162,6 +162,7 @@
</span><span class="cx">     unsigned lengthFromRange(Element* scope, const Range*, ExceptionCode&amp;);
</span><span class="cx">     String rangeAsText(const Range*, ExceptionCode&amp;);
</span><span class="cx">     PassRefPtr&lt;Range&gt; subrange(Range* range, int rangeLocation, int rangeLength, ExceptionCode&amp;);
</span><ins>+    RefPtr&lt;Range&gt; rangeForDictionaryLookupAtLocation(int x, int y, ExceptionCode&amp;);
</ins><span class="cx"> 
</span><span class="cx">     void setDelegatesScrolling(bool enabled, ExceptionCode&amp;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (179791 => 179792)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl        2015-02-08 02:28:48 UTC (rev 179791)
+++ trunk/Source/WebCore/testing/Internals.idl        2015-02-08 02:43:40 UTC (rev 179792)
</span><span class="lines">@@ -124,6 +124,7 @@
</span><span class="cx">     [RaisesException] unsigned long lengthFromRange(Element scope, Range range);
</span><span class="cx">     [RaisesException] DOMString rangeAsText(Range range);
</span><span class="cx">     [RaisesException] Range subrange(Range range, long rangeLocation, long rangeLength);
</span><ins>+    [RaisesException] Range rangeForDictionaryLookupAtLocation(long x, long y);
</ins><span class="cx"> 
</span><span class="cx">     [RaisesException] void setDelegatesScrolling(boolean enabled);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>