Title: [198684] trunk/Source/WebCore
Revision
198684
Author
[email protected]
Date
2016-03-25 12:32:53 -0700 (Fri, 25 Mar 2016)

Log Message

Data Detection creates multiple links even when the detected content is within the same node.
https://bugs.webkit.org/show_bug.cgi?id=155860
rdar://problem/25319579

Reviewed by Tim Horton.

If the detected content spans over multiple query fragments,
we need to check if consecutive fragments are all within the
same node. This way we can avoid creating multiple ranges and
consequntly more links.

* editing/cocoa/DataDetection.mm:
(WebCore::DataDetection::detectContentInRange):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (198683 => 198684)


--- trunk/Source/WebCore/ChangeLog	2016-03-25 19:25:05 UTC (rev 198683)
+++ trunk/Source/WebCore/ChangeLog	2016-03-25 19:32:53 UTC (rev 198684)
@@ -1,3 +1,19 @@
+2016-03-24  Enrica Casucci  <[email protected]>
+
+        Data Detection creates multiple links even when the detected content is within the same node.
+        https://bugs.webkit.org/show_bug.cgi?id=155860
+        rdar://problem/25319579
+
+        Reviewed by Tim Horton.
+
+        If the detected content spans over multiple query fragments,
+        we need to check if consecutive fragments are all within the
+        same node. This way we can avoid creating multiple ranges and
+        consequntly more links.
+
+        * editing/cocoa/DataDetection.mm:
+        (WebCore::DataDetection::detectContentInRange):
+
 2016-03-23  Dave Hyatt  <[email protected]>
 
         Implement the allow-end value of the hanging-punctuation CSS property.

Modified: trunk/Source/WebCore/editing/cocoa/DataDetection.mm (198683 => 198684)


--- trunk/Source/WebCore/editing/cocoa/DataDetection.mm	2016-03-25 19:25:05 UTC (rev 198683)
+++ trunk/Source/WebCore/editing/cocoa/DataDetection.mm	2016-03-25 19:32:53 UTC (rev 198684)
@@ -518,10 +518,13 @@
                 iteratorCount++;
             }
             currentRange = iterator.range();
-            if (fragmentIndex == queryRange.end.queryIndex)
-                fragmentRanges.append(Range::create(currentRange->ownerDocument(), &currentRange->startContainer(), currentRange->startOffset(), &currentRange->endContainer(), currentRange->startOffset() + queryRange.end.offset));
-            else
-                fragmentRanges.append(currentRange);
+            RefPtr<Range> fragmentRange = (fragmentIndex == queryRange.end.queryIndex) ?  Range::create(currentRange->ownerDocument(), &currentRange->startContainer(), currentRange->startOffset(), &currentRange->endContainer(), currentRange->startOffset() + queryRange.end.offset) : currentRange;
+            RefPtr<Range> previousRange = fragmentRanges.last();
+            if (&previousRange->startContainer() == &fragmentRange->startContainer()) {
+                fragmentRange = Range::create(currentRange->ownerDocument(), &previousRange->startContainer(), previousRange->startOffset(), &fragmentRange->endContainer(), fragmentRange->endOffset());
+                fragmentRanges.last() = fragmentRange;
+            } else
+                fragmentRanges.append(fragmentRange);
         }
         allResultRanges.append(fragmentRanges);
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to