Title: [265461] branches/safari-610.1.25.10-branch
Revision
265461
Author
[email protected]
Date
2020-08-10 16:47:31 -0700 (Mon, 10 Aug 2020)

Log Message

Cherry-pick r265188. rdar://problem/66643973

    Table data is incorrectly translated in some articles on en.wikipedia.org
    https://bugs.webkit.org/show_bug.cgi?id=215071
    <rdar://problem/66354013>

    Reviewed by Darin Adler.

    Source/WebCore:

    Text in table cells sometimes end up in adjacent cells after translation, since adjacent cells are currently
    extracted as different tokens in a single item; mitigate this by splitting text in table cells into different
    text manipulation items instead.

    Test: TextManipulation.StartTextManipulationExtractsTableCellsAsSeparateItems

    * editing/TextManipulationController.cpp:
    (WebCore::isEnclosingItemBoundaryElement):

    Tools:

    Add a new API test to exercise the change.

    * TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:
    (TestWebKitAPI::TEST):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265188 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-610.1.25.10-branch/Source/WebCore/ChangeLog (265460 => 265461)


--- branches/safari-610.1.25.10-branch/Source/WebCore/ChangeLog	2020-08-10 23:16:30 UTC (rev 265460)
+++ branches/safari-610.1.25.10-branch/Source/WebCore/ChangeLog	2020-08-10 23:47:31 UTC (rev 265461)
@@ -1,3 +1,51 @@
+2020-08-10  Alan Coon  <[email protected]>
+
+        Cherry-pick r265188. rdar://problem/66643973
+
+    Table data is incorrectly translated in some articles on en.wikipedia.org
+    https://bugs.webkit.org/show_bug.cgi?id=215071
+    <rdar://problem/66354013>
+    
+    Reviewed by Darin Adler.
+    
+    Source/WebCore:
+    
+    Text in table cells sometimes end up in adjacent cells after translation, since adjacent cells are currently
+    extracted as different tokens in a single item; mitigate this by splitting text in table cells into different
+    text manipulation items instead.
+    
+    Test: TextManipulation.StartTextManipulationExtractsTableCellsAsSeparateItems
+    
+    * editing/TextManipulationController.cpp:
+    (WebCore::isEnclosingItemBoundaryElement):
+    
+    Tools:
+    
+    Add a new API test to exercise the change.
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:
+    (TestWebKitAPI::TEST):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265188 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-08-02  Wenson Hsieh  <[email protected]>
+
+            Table data is incorrectly translated in some articles on en.wikipedia.org
+            https://bugs.webkit.org/show_bug.cgi?id=215071
+            <rdar://problem/66354013>
+
+            Reviewed by Darin Adler.
+
+            Text in table cells sometimes end up in adjacent cells after translation, since adjacent cells are currently
+            extracted as different tokens in a single item; mitigate this by splitting text in table cells into different
+            text manipulation items instead.
+
+            Test: TextManipulation.StartTextManipulationExtractsTableCellsAsSeparateItems
+
+            * editing/TextManipulationController.cpp:
+            (WebCore::isEnclosingItemBoundaryElement):
+
 2020-08-06  Alan Coon  <[email protected]>
 
         Cherry-pick r265318. rdar://problem/66630841

Modified: branches/safari-610.1.25.10-branch/Source/WebCore/editing/TextManipulationController.cpp (265460 => 265461)


--- branches/safari-610.1.25.10-branch/Source/WebCore/editing/TextManipulationController.cpp	2020-08-10 23:16:30 UTC (rev 265460)
+++ branches/safari-610.1.25.10-branch/Source/WebCore/editing/TextManipulationController.cpp	2020-08-10 23:47:31 UTC (rev 265461)
@@ -320,6 +320,9 @@
         }
     }
 
+    if (element.hasTagName(HTMLNames::tdTag) && displayType == DisplayType::TableCell)
+        return true;
+
     if (element.hasTagName(HTMLNames::spanTag) && displayType == DisplayType::InlineBlock)
         return true;
 

Modified: branches/safari-610.1.25.10-branch/Tools/ChangeLog (265460 => 265461)


--- branches/safari-610.1.25.10-branch/Tools/ChangeLog	2020-08-10 23:16:30 UTC (rev 265460)
+++ branches/safari-610.1.25.10-branch/Tools/ChangeLog	2020-08-10 23:47:31 UTC (rev 265461)
@@ -1,3 +1,47 @@
+2020-08-10  Alan Coon  <[email protected]>
+
+        Cherry-pick r265188. rdar://problem/66643973
+
+    Table data is incorrectly translated in some articles on en.wikipedia.org
+    https://bugs.webkit.org/show_bug.cgi?id=215071
+    <rdar://problem/66354013>
+    
+    Reviewed by Darin Adler.
+    
+    Source/WebCore:
+    
+    Text in table cells sometimes end up in adjacent cells after translation, since adjacent cells are currently
+    extracted as different tokens in a single item; mitigate this by splitting text in table cells into different
+    text manipulation items instead.
+    
+    Test: TextManipulation.StartTextManipulationExtractsTableCellsAsSeparateItems
+    
+    * editing/TextManipulationController.cpp:
+    (WebCore::isEnclosingItemBoundaryElement):
+    
+    Tools:
+    
+    Add a new API test to exercise the change.
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:
+    (TestWebKitAPI::TEST):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265188 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-08-02  Wenson Hsieh  <[email protected]>
+
+            Table data is incorrectly translated in some articles on en.wikipedia.org
+            https://bugs.webkit.org/show_bug.cgi?id=215071
+            <rdar://problem/66354013>
+
+            Reviewed by Darin Adler.
+
+            Add a new API test to exercise the change.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:
+            (TestWebKitAPI::TEST):
+
 2020-08-05  Russell Epstein  <[email protected]>
 
         Revert r265115. rdar://problem/66552761

Modified: branches/safari-610.1.25.10-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm (265460 => 265461)


--- branches/safari-610.1.25.10-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm	2020-08-10 23:16:30 UTC (rev 265460)
+++ branches/safari-610.1.25.10-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm	2020-08-10 23:47:31 UTC (rev 265461)
@@ -1146,6 +1146,47 @@
     EXPECT_WK_STREQ("World", items[1].tokens[0].content);
 }
 
+TEST(TextManipulation, StartTextManipulationExtractsTableCellsAsSeparateItems)
+{
+    auto delegate = adoptNS([[TextManipulationDelegate alloc] init]);
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
+    [webView _setTextManipulationDelegate:delegate.get()];
+
+    [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html>"
+        "<html>"
+        "<head>"
+        "  <style>"
+        "    td { border: solid 1px tomato; }"
+        "  </style>"
+        "</head>"
+        "<body>"
+        "  <table>"
+        "    <tbody>"
+        "      <tr>"
+        "        <td>Foo</td>"
+        "        <td>Bar</td>"
+        "        <td>Baz</td>"
+        "      </tr>"
+        "    </tbody>"
+        "  </table>"
+        "</body>"];
+
+    done = false;
+    [webView _startTextManipulationsWithConfiguration:nil completion:^{
+        done = true;
+    }];
+    TestWebKitAPI::Util::run(&done);
+
+    auto items = [delegate items];
+    EXPECT_EQ(items.count, 3UL);
+    EXPECT_EQ(items[0].tokens.count, 1UL);
+    EXPECT_WK_STREQ("Foo", items[0].tokens[0].content);
+    EXPECT_EQ(items[1].tokens.count, 1UL);
+    EXPECT_WK_STREQ("Bar", items[1].tokens[0].content);
+    EXPECT_EQ(items[2].tokens.count, 1UL);
+    EXPECT_WK_STREQ("Baz", items[2].tokens[0].content);
+}
+
 struct Token {
     NSString *identifier;
     NSString *content;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to