Title: [262780] trunk
- Revision
- 262780
- Author
- [email protected]
- Date
- 2020-06-09 00:11:12 -0700 (Tue, 09 Jun 2020)
Log Message
TextManipulationController range of paragraph may be wrong after r262601
https://bugs.webkit.org/show_bug.cgi?id=212874
Reviewed by Wenson Hsieh.
Source/WebCore:
Start and end position of item are not properly set in r262601.
Test: TextManipulation.CompleteTextManipulationSuccedsWhenContentOutOfParagraphIsAdded
* editing/TextManipulationController.cpp:
(WebCore::TextManipulationController::addItemIfPossible):
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:
(TestWebKitAPI::TEST):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (262779 => 262780)
--- trunk/Source/WebCore/ChangeLog 2020-06-09 07:06:55 UTC (rev 262779)
+++ trunk/Source/WebCore/ChangeLog 2020-06-09 07:11:12 UTC (rev 262780)
@@ -1,3 +1,17 @@
+2020-06-09 Sihui Liu <[email protected]>
+
+ TextManipulationController range of paragraph may be wrong after r262601
+ https://bugs.webkit.org/show_bug.cgi?id=212874
+
+ Reviewed by Wenson Hsieh.
+
+ Start and end position of item are not properly set in r262601.
+
+ Test: TextManipulation.CompleteTextManipulationSuccedsWhenContentOutOfParagraphIsAdded
+
+ * editing/TextManipulationController.cpp:
+ (WebCore::TextManipulationController::addItemIfPossible):
+
2020-06-08 Sihui Liu <[email protected]>
TextManipulation should only convert text from Node's text content to tokens
Modified: trunk/Source/WebCore/editing/TextManipulationController.cpp (262779 => 262780)
--- trunk/Source/WebCore/editing/TextManipulationController.cpp 2020-06-09 07:06:55 UTC (rev 262779)
+++ trunk/Source/WebCore/editing/TextManipulationController.cpp 2020-06-09 07:11:12 UTC (rev 262780)
@@ -398,8 +398,9 @@
if (index == end)
return;
- auto startPosition = firstPositionInOrBeforeNode(units.first().node.ptr());
- auto endPosition = positionAfterNode(units.last().node.ptr());
+ ASSERT(end);
+ auto startPosition = firstPositionInOrBeforeNode(units[index].node.ptr());
+ auto endPosition = positionAfterNode(units[end - 1].node.ptr());
Vector<ManipulationToken> tokens;
for (; index < end; ++index)
tokens.appendVector(WTFMove(units[index].tokens));
Modified: trunk/Tools/ChangeLog (262779 => 262780)
--- trunk/Tools/ChangeLog 2020-06-09 07:06:55 UTC (rev 262779)
+++ trunk/Tools/ChangeLog 2020-06-09 07:11:12 UTC (rev 262780)
@@ -1,3 +1,13 @@
+2020-06-09 Sihui Liu <[email protected]>
+
+ TextManipulationController range of paragraph may be wrong after r262601
+ https://bugs.webkit.org/show_bug.cgi?id=212874
+
+ Reviewed by Wenson Hsieh.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:
+ (TestWebKitAPI::TEST):
+
2020-06-08 Sihui Liu <[email protected]>
TextManipulation should only convert text from Node's text content to tokens
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm (262779 => 262780)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm 2020-06-09 07:06:55 UTC (rev 262779)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm 2020-06-09 07:11:12 UTC (rev 262780)
@@ -1923,6 +1923,49 @@
EXPECT_WK_STREQ("<p>hello, world \n bye</p><div>end</div>", [webView stringByEvaluatingJavaScript:@"document.body.innerHTML"]);
}
+TEST(TextManipulation, CompleteTextManipulationSuccedsWhenContentOutOfParagraphIsAdded)
+{
+ auto delegate = adoptNS([[TextManipulationDelegate alloc] init]);
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
+ [webView _setTextManipulationDelegate:delegate.get()];
+
+ [webView synchronouslyLoadHTMLString:@"<p style='white-space:pre;background-color:blue;'><span>hello world</span><u> </u></p>"];
+
+ RetainPtr<_WKTextManipulationConfiguration> configuration = adoptNS([[_WKTextManipulationConfiguration alloc] init]);
+ done = false;
+ [webView _startTextManipulationsWithConfiguration:configuration.get() completion:^{
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+
+ auto *items = [delegate items];
+ EXPECT_EQ(items.count, 1UL);
+ EXPECT_EQ(items[0].tokens.count, 1UL);
+ EXPECT_WK_STREQ("hello world", items[0].tokens[0].content);
+
+ done = false;
+ delegate.get().itemCallback = ^(_WKTextManipulationItem *item) {
+ if (items.count == 2)
+ done = true;
+ };
+
+ [webView stringByEvaluatingJavaScript:@"var element = document.createElement('span');"
+ "element.innerHTML='inserted';"
+ "document.querySelector('u').before(element)"];
+ TestWebKitAPI::Util::run(&done);
+
+ done = false;
+ [webView _completeTextManipulationForItems:@[
+ createItem(items[0].identifier, {{ items[0].tokens[0].identifier, @"Hello World" }}).autorelease(),
+ ] completion:^(NSArray<NSError *> *errors) {
+ EXPECT_EQ(errors, nil);
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+
+ EXPECT_WK_STREQ("<p style=\"white-space:pre;background-color:blue;\"><span>Hello World</span><span>inserted</span><u> </u></p>", [webView stringByEvaluatingJavaScript:@"document.body.innerHTML"]);
+}
+
TEST(TextManipulation, CompleteTextManipulationFailWhenDocumentHasBeenNavigatedAway)
{
auto delegate = adoptNS([[TextManipulationDelegate alloc] init]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes