<!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>[197916] 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/197916">197916</a></dd>
<dt>Author</dt> <dd>enrica@apple.com</dd>
<dt>Date</dt> <dd>2016-03-09 18:05:49 -0800 (Wed, 09 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Retrieve additional context for some data detector link for preview and action menu.
https://bugs.webkit.org/show_bug.cgi?id=155278
rdar://problem/24884951

Reviewed by Tim Horton.

Source/WebCore:

Adding helper function to compute a range by moving by a number of characters
from a given position and direction.
Adding function to check if the given data detector link element requires
an extended context.

* editing/VisibleUnits.cpp:
(WebCore::rangeExpandedByCharactersInDirectionAtWordBoundary):
* editing/VisibleUnits.h:
* editing/cocoa/DataDetection.h:
* editing/cocoa/DataDetection.mm:
(WebCore::DataDetection::requiresExtendedContext):

Source/WebKit2:

Data detector results for items like calendar events, can be augmented
retrieving the text surrounding the link.

* Platform/spi/ios/DataDetectorsUISPI.h:
* Shared/ios/InteractionInformationAtPosition.h:
* Shared/ios/InteractionInformationAtPosition.mm:
(WebKit::InteractionInformationAtPosition::encode):
(WebKit::InteractionInformationAtPosition::decode):
* UIProcess/ios/WKActionSheetAssistant.mm:
(-[WKActionSheetAssistant showDataDetectorsSheet]):
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _dataForPreviewItemController:atPosition:type:]):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getPositionInformation):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreeditingVisibleUnitscpp">trunk/Source/WebCore/editing/VisibleUnits.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingVisibleUnitsh">trunk/Source/WebCore/editing/VisibleUnits.h</a></li>
<li><a href="#trunkSourceWebCoreeditingcocoaDataDetectionh">trunk/Source/WebCore/editing/cocoa/DataDetection.h</a></li>
<li><a href="#trunkSourceWebCoreeditingcocoaDataDetectionmm">trunk/Source/WebCore/editing/cocoa/DataDetection.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PlatformspiiosDataDetectorsUISPIh">trunk/Source/WebKit2/Platform/spi/ios/DataDetectorsUISPI.h</a></li>
<li><a href="#trunkSourceWebKit2SharediosInteractionInformationAtPositionh">trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.h</a></li>
<li><a href="#trunkSourceWebKit2SharediosInteractionInformationAtPositionmm">trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKActionSheetAssistantmm">trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm">trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (197915 => 197916)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-10 02:04:20 UTC (rev 197915)
+++ trunk/Source/WebCore/ChangeLog        2016-03-10 02:05:49 UTC (rev 197916)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-03-09  Enrica Casucci  &lt;enrica@apple.com&gt;
+
+        Retrieve additional context for some data detector link for preview and action menu.
+        https://bugs.webkit.org/show_bug.cgi?id=155278
+        rdar://problem/24884951
+
+        Reviewed by Tim Horton.
+
+        Adding helper function to compute a range by moving by a number of characters
+        from a given position and direction.
+        Adding function to check if the given data detector link element requires
+        an extended context.
+
+        * editing/VisibleUnits.cpp:
+        (WebCore::rangeExpandedByCharactersInDirectionAtWordBoundary):
+        * editing/VisibleUnits.h:
+        * editing/cocoa/DataDetection.h:
+        * editing/cocoa/DataDetection.mm:
+        (WebCore::DataDetection::requiresExtendedContext):
+
</ins><span class="cx"> 2016-03-09  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix the Windows build after &lt;https://trac.webkit.org/changeset/197905&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingVisibleUnitscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (197915 => 197916)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/VisibleUnits.cpp        2016-03-10 02:04:20 UTC (rev 197915)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp        2016-03-10 02:05:49 UTC (rev 197916)
</span><span class="lines">@@ -1983,6 +1983,25 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+PassRefPtr&lt;Range&gt; rangeExpandedByCharactersInDirectionAtWordBoundary(const VisiblePosition&amp; position, int numberOfCharactersToExpand, SelectionDirection direction)
+{
+    Position start = position.deepEquivalent();
+    Position end = position.deepEquivalent();
+    for (int i = 0; i &lt; numberOfCharactersToExpand; ++i) {
+        if (direction == DirectionBackward)
+            start = start.previous(Character);
+        else
+            end = end.next(Character);
+    }
+    
+    if (direction == DirectionBackward &amp;&amp; !atBoundaryOfGranularity(start, WordGranularity, DirectionBackward))
+        start = startOfWord(start).deepEquivalent();
+    if (direction == DirectionForward &amp;&amp; !atBoundaryOfGranularity(end, WordGranularity, DirectionForward))
+        end = endOfWord(end).deepEquivalent();
+
+    return makeRange(start, end);
+}    
+
</ins><span class="cx"> PassRefPtr&lt;Range&gt; rangeExpandedAroundPositionByCharacters(const VisiblePosition&amp; position, int numberOfCharactersToExpand)
</span><span class="cx"> {
</span><span class="cx">     Position start = position.deepEquivalent();
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingVisibleUnitsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/VisibleUnits.h (197915 => 197916)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/VisibleUnits.h        2016-03-10 02:04:20 UTC (rev 197915)
+++ trunk/Source/WebCore/editing/VisibleUnits.h        2016-03-10 02:05:49 UTC (rev 197916)
</span><span class="lines">@@ -108,6 +108,7 @@
</span><span class="cx"> WEBCORE_EXPORT VisiblePosition closestWordBoundaryForPosition(const VisiblePosition&amp; position);
</span><span class="cx"> WEBCORE_EXPORT void charactersAroundPosition(const VisiblePosition&amp;, UChar32&amp; oneAfter, UChar32&amp; oneBefore, UChar32&amp; twoBefore);
</span><span class="cx"> WEBCORE_EXPORT PassRefPtr&lt;Range&gt; rangeExpandedAroundPositionByCharacters(const VisiblePosition&amp;, int numberOfCharactersToExpand);
</span><ins>+WEBCORE_EXPORT PassRefPtr&lt;Range&gt; rangeExpandedByCharactersInDirectionAtWordBoundary(const VisiblePosition&amp;, int numberOfCharactersToExpand, SelectionDirection);
</ins><span class="cx"> 
</span><span class="cx"> // helper function
</span><span class="cx"> enum BoundarySearchContextAvailability { DontHaveMoreContext, MayHaveMoreContext };
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingcocoaDataDetectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/cocoa/DataDetection.h (197915 => 197916)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/cocoa/DataDetection.h        2016-03-10 02:04:20 UTC (rev 197915)
+++ trunk/Source/WebCore/editing/cocoa/DataDetection.h        2016-03-10 02:05:49 UTC (rev 197916)
</span><span class="lines">@@ -60,6 +60,7 @@
</span><span class="cx">     WEBCORE_EXPORT static bool isDataDetectorLink(Element*);
</span><span class="cx">     WEBCORE_EXPORT static String dataDetectorIdentifier(Element*);
</span><span class="cx">     WEBCORE_EXPORT static bool shouldCancelDefaultAction(Element*);
</span><ins>+    WEBCORE_EXPORT static bool requiresExtendedContext(Element*);
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingcocoaDataDetectionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/cocoa/DataDetection.mm (197915 => 197916)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/cocoa/DataDetection.mm        2016-03-10 02:04:20 UTC (rev 197915)
+++ trunk/Source/WebCore/editing/cocoa/DataDetection.mm        2016-03-10 02:05:49 UTC (rev 197916)
</span><span class="lines">@@ -56,6 +56,11 @@
</span><span class="cx">     return element-&gt;getAttribute(dataDetectorsURLScheme) == &quot;true&quot;;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool DataDetection::requiresExtendedContext(Element* element)
+{
+    return element-&gt;getAttribute(dataDetectorsAttributeTypeKey) == &quot;calendar-event&quot;;
+}
+
</ins><span class="cx"> String DataDetection::dataDetectorIdentifier(Element* element)
</span><span class="cx"> {
</span><span class="cx">     return element-&gt;getAttribute(dataDetectorsAttributeResultKey);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (197915 => 197916)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-03-10 02:04:20 UTC (rev 197915)
+++ trunk/Source/WebKit2/ChangeLog        2016-03-10 02:05:49 UTC (rev 197916)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2016-03-09  Enrica Casucci  &lt;enrica@apple.com&gt;
+
+        Retrieve additional context for some data detector link for preview and action menu.
+        https://bugs.webkit.org/show_bug.cgi?id=155278
+        rdar://problem/24884951
+
+        Reviewed by Tim Horton.
+
+        Data detector results for items like calendar events, can be augmented
+        retrieving the text surrounding the link.
+
+        * Platform/spi/ios/DataDetectorsUISPI.h:
+        * Shared/ios/InteractionInformationAtPosition.h:
+        * Shared/ios/InteractionInformationAtPosition.mm:
+        (WebKit::InteractionInformationAtPosition::encode):
+        (WebKit::InteractionInformationAtPosition::decode):
+        * UIProcess/ios/WKActionSheetAssistant.mm:
+        (-[WKActionSheetAssistant showDataDetectorsSheet]):
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _dataForPreviewItemController:atPosition:type:]):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getPositionInformation):
+
</ins><span class="cx"> 2016-03-09  Gavin Barraclough  &lt;barraclough@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Last opened tab does not receive SetHiddenPageTimerThrottlingIncreaseLimit message
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformspiiosDataDetectorsUISPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/spi/ios/DataDetectorsUISPI.h (197915 => 197916)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/spi/ios/DataDetectorsUISPI.h        2016-03-10 02:04:20 UTC (rev 197915)
+++ trunk/Source/WebKit2/Platform/spi/ios/DataDetectorsUISPI.h        2016-03-10 02:05:49 UTC (rev 197916)
</span><span class="lines">@@ -63,3 +63,5 @@
</span><span class="cx"> 
</span><span class="cx"> SOFT_LINK_PRIVATE_FRAMEWORK(DataDetectorsUI)
</span><span class="cx"> SOFT_LINK_CLASS(DataDetectorsUI, DDDetectionController)
</span><ins>+SOFT_LINK_CONSTANT(DataDetectorsUI, kDataDetectorsLeadingText, const NSString *)
+SOFT_LINK_CONSTANT(DataDetectorsUI, kDataDetectorsTrailingText, const NSString *)
</ins></span></pre></div>
<a id="trunkSourceWebKit2SharediosInteractionInformationAtPositionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.h (197915 => 197916)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.h        2016-03-10 02:04:20 UTC (rev 197915)
+++ trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.h        2016-03-10 02:05:49 UTC (rev 197916)
</span><span class="lines">@@ -56,6 +56,8 @@
</span><span class="cx">     String title;
</span><span class="cx">     WebCore::IntRect bounds;
</span><span class="cx">     RefPtr&lt;ShareableBitmap&gt; image;
</span><ins>+    String textBefore;
+    String textAfter;
</ins><span class="cx"> 
</span><span class="cx">     WebCore::TextIndicatorData linkIndicator;
</span><span class="cx"> #if ENABLE(DATA_DETECTION)
</span></span></pre></div>
<a id="trunkSourceWebKit2SharediosInteractionInformationAtPositionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.mm (197915 => 197916)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.mm        2016-03-10 02:04:20 UTC (rev 197915)
+++ trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.mm        2016-03-10 02:05:49 UTC (rev 197916)
</span><span class="lines">@@ -55,6 +55,8 @@
</span><span class="cx">     encoder &lt;&lt; imageURL;
</span><span class="cx">     encoder &lt;&lt; title;
</span><span class="cx">     encoder &lt;&lt; bounds;
</span><ins>+    encoder &lt;&lt; textBefore;
+    encoder &lt;&lt; textAfter;
</ins><span class="cx">     encoder &lt;&lt; linkIndicator;
</span><span class="cx"> 
</span><span class="cx">     ShareableBitmap::Handle handle;
</span><span class="lines">@@ -120,6 +122,12 @@
</span><span class="cx">     if (!decoder.decode(result.bounds))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    if (!decoder.decode(result.textBefore))
+        return false;
+    
+    if (!decoder.decode(result.textAfter))
+        return false;
+    
</ins><span class="cx">     if (!decoder.decode(result.linkIndicator))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKActionSheetAssistantmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm (197915 => 197916)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm        2016-03-10 02:04:20 UTC (rev 197915)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm        2016-03-10 02:05:49 UTC (rev 197916)
</span><span class="lines">@@ -436,11 +436,22 @@
</span><span class="cx">     if ([controller respondsToSelector:@selector(actionsForURL:identifier:selectedText:results:context:)]) {
</span><span class="cx">         NSDictionary *context = nil;
</span><span class="cx">         NSString *textAtSelection = nil;
</span><ins>+        RetainPtr&lt;NSMutableDictionary&gt; extendedContext;
</ins><span class="cx"> 
</span><span class="cx">         if ([delegate respondsToSelector:@selector(dataDetectionContextForActionSheetAssistant:)])
</span><span class="cx">             context = [delegate dataDetectionContextForActionSheetAssistant:self];
</span><span class="cx">         if ([delegate respondsToSelector:@selector(selectedTextForActionSheetAssistant:)])
</span><span class="cx">             textAtSelection = [delegate selectedTextForActionSheetAssistant:self];
</span><ins>+        if (!positionInformation.textBefore.isEmpty() || !positionInformation.textAfter.isEmpty()) {
+            extendedContext = adoptNS([@{
+                getkDataDetectorsLeadingText() : positionInformation.textBefore,
+                getkDataDetectorsTrailingText() : positionInformation.textAfter,
+            } mutableCopy]);
+            
+            if (context)
+                [extendedContext addEntriesFromDictionary:context];
+            context = extendedContext.get();
+        }
</ins><span class="cx">         dataDetectorsActions = [controller actionsForURL:targetURL identifier:positionInformation.dataDetectorIdentifier selectedText:textAtSelection results:positionInformation.dataDetectorResults.get() context:context];
</span><span class="cx">     } else
</span><span class="cx">         dataDetectorsActions = [controller actionsForAnchor:nil url:targetURL forFrame:nil];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (197915 => 197916)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2016-03-10 02:04:20 UTC (rev 197915)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2016-03-10 02:05:49 UTC (rev 197916)
</span><span class="lines">@@ -3829,9 +3829,20 @@
</span><span class="cx">             DDDetectionController *controller = [getDDDetectionControllerClass() sharedController];
</span><span class="cx">             if ([controller respondsToSelector:@selector(resultForURL:identifier:selectedText:results:context:extendedContext:)]) {
</span><span class="cx">                 NSDictionary *newContext = nil;
</span><ins>+                RetainPtr&lt;NSMutableDictionary&gt; extendedContext;
</ins><span class="cx">                 DDResultRef ddResult = [controller resultForURL:dataForPreview[UIPreviewDataLink] identifier:_positionInformation.dataDetectorIdentifier selectedText:[self selectedText] results:_positionInformation.dataDetectorResults.get() context:context extendedContext:&amp;newContext];
</span><span class="cx">                 if (ddResult)
</span><span class="cx">                     dataForPreview[UIPreviewDataDDResult] = (__bridge id)ddResult;
</span><ins>+                if (!_positionInformation.textBefore.isEmpty() || !_positionInformation.textAfter.isEmpty()) {
+                    extendedContext = adoptNS([@{
+                        getkDataDetectorsLeadingText() : _positionInformation.textBefore,
+                        getkDataDetectorsTrailingText() : _positionInformation.textAfter,
+                    } mutableCopy]);
+                    
+                    if (newContext)
+                        [extendedContext addEntriesFromDictionary:newContext];
+                    newContext = extendedContext.get();
+                }
</ins><span class="cx">                 if (newContext)
</span><span class="cx">                     dataForPreview[UIPreviewDataDDContext] = newContext;
</span><span class="cx">             }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (197915 => 197916)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2016-03-10 02:04:20 UTC (rev 197915)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2016-03-10 02:05:49 UTC (rev 197916)
</span><span class="lines">@@ -2200,8 +2200,15 @@
</span><span class="cx"> #if ENABLE(DATA_DETECTION)
</span><span class="cx">                     info.isDataDetectorLink = DataDetection::isDataDetectorLink(element);
</span><span class="cx">                     if (info.isDataDetectorLink) {
</span><ins>+                        const int dataDetectionExtendedContextLength = 350;
</ins><span class="cx">                         info.dataDetectorIdentifier = DataDetection::dataDetectorIdentifier(element);
</span><span class="cx">                         info.dataDetectorResults = element-&gt;document().frame()-&gt;dataDetectionResults();
</span><ins>+                        if (DataDetection::requiresExtendedContext(element)) {
+                            RefPtr&lt;Range&gt; linkRange = Range::create(element-&gt;document());
+                            linkRange-&gt;selectNodeContents(element, ASSERT_NO_EXCEPTION);
+                            info.textBefore = plainTextReplacingNoBreakSpace(rangeExpandedByCharactersInDirectionAtWordBoundary(linkRange-&gt;startPosition(), dataDetectionExtendedContextLength, DirectionBackward).get(), TextIteratorDefaultBehavior, true);
+                            info.textAfter = plainTextReplacingNoBreakSpace(rangeExpandedByCharactersInDirectionAtWordBoundary(linkRange-&gt;endPosition(), dataDetectionExtendedContextLength, DirectionForward).get(), TextIteratorDefaultBehavior, true);
+                        }
</ins><span class="cx">                     }
</span><span class="cx"> #endif
</span><span class="cx">                 } else if (element-&gt;renderer() &amp;&amp; element-&gt;renderer()-&gt;isRenderImage()) {
</span></span></pre>
</div>
</div>

</body>
</html>