Changeset 266075 in webkit
- Timestamp:
- Aug 24, 2020, 11:06:01 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/editing/TextManipulationController.cpp (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r266074 r266075 1 2020-08-24 Sihui Liu <sihui_liu@apple.com> 2 3 Text manipulation should not manipulate nodes out of paragraph range 4 https://bugs.webkit.org/show_bug.cgi?id=215406 5 6 Reviewed by Wenson Hsieh. 7 8 TextManipulationController currently does not set correct start path for insertion. Therefore, it does not mark 9 the nodes on the start path but out of range correctly, and may change position of those nodes by mistake. For 10 example, in the newly added test, text node "zero" can be moved around even though it is not in range. 11 12 API test: TextManipulation.CompleteTextManipulationShouldOnlyChangeNodesInParagraphRange 13 14 * editing/TextManipulationController.cpp: 15 (WebCore::TextManipulationController::replace): 16 1 17 2020-08-24 Devin Rousso <drousso@apple.com> 2 18 -
trunk/Source/WebCore/editing/TextManipulationController.cpp
r265561 r266075 830 830 831 831 HashSet<Ref<Node>> reusedOriginalNodes; 832 Vector<NodeEntry> lastTopDownPath;833 832 Vector<NodeInsertion> insertions; 833 auto startTopDownPath = getPath(commonAncestor.get(), firstContentNode.get()); 834 while (!startTopDownPath.isEmpty()) { 835 auto lastNode = startTopDownPath.last(); 836 ASSERT(is<ContainerNode>(lastNode.get())); 837 if (!downcast<ContainerNode>(lastNode.get()).hasOneChild()) 838 break; 839 nodesToRemove.add(startTopDownPath.takeLast()); 840 } 841 auto lastTopDownPath = startTopDownPath.map([&](auto node) -> NodeEntry { 842 reusedOriginalNodes.add(node.copyRef()); 843 return { node, node }; 844 }); 845 834 846 for (size_t index = 0; index < replacementTokens.size(); ++index) { 835 847 auto& replacementToken = replacementTokens[index]; -
trunk/Tools/ChangeLog
r266063 r266075 1 2020-08-24 Sihui Liu <sihui_liu@apple.com> 2 3 Text manipulationshould not manipulate nodes out of paragraph range 4 https://bugs.webkit.org/show_bug.cgi?id=215406 5 6 Reviewed by Wenson Hsieh. 7 8 * TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm: 9 (TestWebKitAPI::TEST): 10 1 11 2020-08-24 Aditya Keerthi <akeerthi@apple.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm
r265561 r266075 3132 3132 } 3133 3133 3134 TEST(TextManipulation, CompleteTextManipulationShouldOnlyChangeNodesInParagraphRange) 3135 { 3136 auto delegate = adoptNS([[TextManipulationDelegate alloc] init]); 3137 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]); 3138 [webView _setTextManipulationDelegate:delegate.get()]; 3139 [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html>" 3140 "<head>" 3141 "<style>" 3142 "span { white-space:pre; }" 3143 "</style>" 3144 "</head>" 3145 "<body>" 3146 "<span>zero <b>two four</b></span>" 3147 "one" 3148 "<i>three</i>" 3149 "</body>"]; 3150 3151 done = false; 3152 [webView _startTextManipulationsWithConfiguration:nil completion:^{ 3153 done = true; 3154 }]; 3155 TestWebKitAPI::Util::run(&done); 3156 3157 auto *items = [delegate items]; 3158 EXPECT_EQ(items.count, 2UL); 3159 EXPECT_EQ(items[0].tokens.count, 2UL); 3160 EXPECT_WK_STREQ("zero", items[0].tokens[0].content); 3161 EXPECT_WK_STREQ(" \n", items[0].tokens[1].content); 3162 EXPECT_EQ(items[1].tokens.count, 3UL); 3163 EXPECT_WK_STREQ("two four", items[1].tokens[0].content); 3164 EXPECT_WK_STREQ("one", items[1].tokens[1].content); 3165 EXPECT_WK_STREQ("three", items[1].tokens[2].content); 3166 3167 done = false; 3168 [webView _completeTextManipulationForItems:@[(_WKTextManipulationItem *)createItem(items[1].identifier, { 3169 { items[1].tokens[1].identifier, @"one" }, 3170 { items[1].tokens[0].identifier, @"two" }, 3171 { items[1].tokens[2].identifier, @"three" }, 3172 { items[1].tokens[0].identifier, @"four" } 3173 }).get()] completion:^(NSArray<NSError *> *errors) { 3174 EXPECT_EQ(errors, nil); 3175 done = true; 3176 }]; 3177 TestWebKitAPI::Util::run(&done); 3178 EXPECT_WK_STREQ("<span>zero \n</span>one<span><b>two</b></span><i>three</i><span><b>four</b></span>", 3179 [webView stringByEvaluatingJavaScript:@"document.body.innerHTML"]); 3180 } 3181 3134 3182 TEST(TextManipulation, TextManipulationTokenDebugDescription) 3135 3183 {
Note:
See TracChangeset
for help on using the changeset viewer.