Changeset 214697 in webkit


Ignore:
Timestamp:
Mar 31, 2017 4:33:24 PM (7 years ago)
Author:
aestes@apple.com
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.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r214694 r214697  
     12017-03-31  Andy Estes  <aestes@apple.com>
     2
     3        REGRESSION (r202472): Data Detection overwrites existing links in detected ranges
     4        https://bugs.webkit.org/show_bug.cgi?id=170365
     5        <rdar://problem/29205721>
     6
     7        Reviewed by Tim Horton.
     8
     9        r202472 changed the node traversal in searchForLinkRemovingExistingDDLinks() to only
     10        consider nodes that are descendants of startNode, but we need to traverse all nodes between
     11        startNode and endNode to find existing non-DD links.
     12
     13        As a result, we'd add a Data Detector link to the following snippet and make the original
     14        links un-clickable:
     15
     16            <a href='#'>tomorrow</a> <a href='#'>night</a>
     17
     18        Fix this by not specifying a stayWithin node when calling NodeTraversal::next(). The loop
     19        will terminate when we reach endNode.
     20
     21        Updated WebKit2.DataDetectionReferenceDate API test.
     22
     23        * editing/cocoa/DataDetection.mm:
     24        (WebCore::searchForLinkRemovingExistingDDLinks):
     25
    1262017-03-31  Eric Carlson  <eric.carlson@apple.com>
    227
  • trunk/Source/WebCore/editing/cocoa/DataDetection.mm

    r213355 r214697  
    275275{
    276276    didModifyDOM = false;
    277     for (Node* node = &startNode; node; node = NodeTraversal::next(*node, &startNode)) {
     277    for (Node* node = &startNode; node; node = NodeTraversal::next(*node)) {
    278278        if (is<HTMLAnchorElement>(*node)) {
    279279            auto& anchor = downcast<HTMLAnchorElement>(*node);
  • trunk/Tools/ChangeLog

    r214683 r214697  
     12017-03-31  Andy Estes  <aestes@apple.com>
     2
     3        REGRESSION (r202472): Data Detection overwrites existing links in detected ranges
     4        https://bugs.webkit.org/show_bug.cgi?id=170365
     5        <rdar://problem/29205721>
     6
     7        Reviewed by Tim Horton.
     8
     9        * TestWebKitAPI/Tests/WebKit2Cocoa/DataDetection.mm:
     10        (expectLinkCount): Changed to only query links with the x-apple-data-detectors attribute.
     11        (TEST): Re-enabled the test, which now passes.
     12
    1132017-03-31  Tim Horton  <timothy_horton@apple.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/DataDetection.mm

    r205976 r214697  
    6161    [webView _test_waitForDidFinishNavigation];
    6262
    63     [webView evaluateJavaScript:@"document.getElementsByTagName('a').length" completionHandler:^(id value, NSError *error) {
     63    [webView evaluateJavaScript:@"document.querySelectorAll('a[x-apple-data-detectors=true]').length" completionHandler:^(id value, NSError *error) {
    6464        EXPECT_EQ(linkCount, [value unsignedIntValue]);
    6565        ranScript = true;
     
    7070}
    7171
    72 TEST(WebKit2, DISABLED_DataDetectionReferenceDate)
     72TEST(WebKit2, DataDetectionReferenceDate)
    7373{
    7474    RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     
    8282    expectLinkCount(webView.get(), @"tomorrow at 6PM", 1);
    8383    expectLinkCount(webView.get(), @"yesterday at 6PM", 0);
     84    expectLinkCount(webView.get(), @"<a href='about:blank'>tomorrow at 6PM</a>", 0);
     85    expectLinkCount(webView.get(), @"<a href='about:blank'>tomorrow</a> at <a href='about:blank'>6PM</a>", 0);
     86
    8487
    8588    NSTimeInterval week = 60 * 60 * 24 * 7;
Note: See TracChangeset for help on using the changeset viewer.