Title: [214937] trunk
Revision
214937
Author
[email protected]
Date
2017-04-05 01:24:48 -0700 (Wed, 05 Apr 2017)

Log Message

REGRESSION (r202472): Data Detection overwrites existing links in detected ranges
https://bugs.webkit.org/show_bug.cgi?id=170365
<rdar://problem/29205721>

Reviewed by Tim Horton.

Source/WebCore:

r202472 changed the node traversal in searchForLinkRemovingExistingDDLinks() to only
consider nodes that are descendants of startNode, but we need to traverse all nodes between
startNode and endNode to find existing non-DD links.

As a result, we'd add a Data Detector link to the following snippet and make the original
links un-clickable:

    <a href=''>tomorrow</a> <a href=''>night</a>

Fix this by not specifying a stayWithin node when calling NodeTraversal::next(). The loop
will terminate when we reach endNode.

Updated WebKit2.DataDetectionReferenceDate API test.

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

Tools:

* TestWebKitAPI/Tests/WebKit2Cocoa/DataDetection.mm:
(expectLinkCount): Changed to only query links with the x-apple-data-detectors attribute.
(TEST): Re-enabled the test, which now passes.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (214936 => 214937)


--- trunk/Source/WebCore/ChangeLog	2017-04-05 07:58:02 UTC (rev 214936)
+++ trunk/Source/WebCore/ChangeLog	2017-04-05 08:24:48 UTC (rev 214937)
@@ -1,3 +1,28 @@
+2017-04-05  Andy Estes  <[email protected]>
+
+        REGRESSION (r202472): Data Detection overwrites existing links in detected ranges
+        https://bugs.webkit.org/show_bug.cgi?id=170365
+        <rdar://problem/29205721>
+
+        Reviewed by Tim Horton.
+
+        r202472 changed the node traversal in searchForLinkRemovingExistingDDLinks() to only
+        consider nodes that are descendants of startNode, but we need to traverse all nodes between
+        startNode and endNode to find existing non-DD links.
+
+        As a result, we'd add a Data Detector link to the following snippet and make the original
+        links un-clickable:
+
+            <a href=''>tomorrow</a> <a href=''>night</a>
+
+        Fix this by not specifying a stayWithin node when calling NodeTraversal::next(). The loop
+        will terminate when we reach endNode.
+
+        Updated WebKit2.DataDetectionReferenceDate API test.
+
+        * editing/cocoa/DataDetection.mm:
+        (WebCore::searchForLinkRemovingExistingDDLinks):
+
 2017-04-04  Carlos Garcia Campos  <[email protected]>
 
         Move WebErrors from WebProcess to Shared and get rid of ErrorsGtk in WebCore

Modified: trunk/Source/WebCore/editing/cocoa/DataDetection.mm (214936 => 214937)


--- trunk/Source/WebCore/editing/cocoa/DataDetection.mm	2017-04-05 07:58:02 UTC (rev 214936)
+++ trunk/Source/WebCore/editing/cocoa/DataDetection.mm	2017-04-05 08:24:48 UTC (rev 214937)
@@ -274,7 +274,7 @@
 static bool searchForLinkRemovingExistingDDLinks(Node& startNode, Node& endNode, bool& didModifyDOM)
 {
     didModifyDOM = false;
-    for (Node* node = &startNode; node; node = NodeTraversal::next(*node, &startNode)) {
+    for (Node* node = &startNode; node; node = NodeTraversal::next(*node)) {
         if (is<HTMLAnchorElement>(*node)) {
             auto& anchor = downcast<HTMLAnchorElement>(*node);
             if (!equalIgnoringASCIICase(anchor.attributeWithoutSynchronization(x_apple_data_detectorsAttr), "true"))

Modified: trunk/Tools/ChangeLog (214936 => 214937)


--- trunk/Tools/ChangeLog	2017-04-05 07:58:02 UTC (rev 214936)
+++ trunk/Tools/ChangeLog	2017-04-05 08:24:48 UTC (rev 214937)
@@ -1,5 +1,17 @@
 2017-04-05  Andy Estes  <[email protected]>
 
+        REGRESSION (r202472): Data Detection overwrites existing links in detected ranges
+        https://bugs.webkit.org/show_bug.cgi?id=170365
+        <rdar://problem/29205721>
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/DataDetection.mm:
+        (expectLinkCount): Changed to only query links with the x-apple-data-detectors attribute.
+        (TEST): Re-enabled the test, which now passes.
+
+2017-04-05  Andy Estes  <[email protected]>
+
         [ios-simulator] API test WebKit2.WKWebProcessPlugInRangeHandle timing out
         https://bugs.webkit.org/show_bug.cgi?id=167594
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DataDetection.mm (214936 => 214937)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DataDetection.mm	2017-04-05 07:58:02 UTC (rev 214936)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DataDetection.mm	2017-04-05 08:24:48 UTC (rev 214937)
@@ -60,7 +60,7 @@
     [webView loadHTMLString:HTMLString baseURL:nil];
     [webView _test_waitForDidFinishNavigation];
 
-    [webView evaluateJavaScript:@"document.getElementsByTagName('a').length" completionHandler:^(id value, NSError *error) {
+    [webView evaluateJavaScript:@"document.querySelectorAll('a[x-apple-data-detectors=true]').length" completionHandler:^(id value, NSError *error) {
         EXPECT_EQ(linkCount, [value unsignedIntValue]);
         ranScript = true;
     }];
@@ -81,7 +81,10 @@
 
     expectLinkCount(webView.get(), @"tomorrow at 6PM", 1);
     expectLinkCount(webView.get(), @"yesterday at 6PM", 0);
+    expectLinkCount(webView.get(), @"<a href=''>tomorrow at 6PM</a>", 0);
+    expectLinkCount(webView.get(), @"<a href=''>tomorrow</a> at <a href=''>6PM</a>", 0);
 
+
     NSTimeInterval week = 60 * 60 * 24 * 7;
 
     [UIDelegate setReferenceDate:[NSDate dateWithTimeIntervalSinceNow:-week]];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to