Title: [217284] trunk
- Revision
- 217284
- Author
- wenson_hs...@apple.com
- Date
- 2017-05-23 11:27:21 -0700 (Tue, 23 May 2017)
Log Message
Multiple links should be inserted separately when performing data interaction
https://bugs.webkit.org/show_bug.cgi?id=172489
<rdar://problem/31510832>
Reviewed by Dan Bernstein.
Source/WebCore:
In WebContentReader, URLs are currently always inserted inline. When inserting multiple items, this causes
adjacent links to be inserted on a single line with no break, which is undesirable. To address this, when
appending links from additional items to the existing document fragment in WebContentReader, insert a new space
prior to inserting the anchor element.
New unit test: DataInteractionTests.ExternalSourceMultipleURLsToContentEditable
* editing/ios/EditorIOS.mm:
(WebCore::Editor::WebContentReader::addFragment):
Tweak to add all children of the new fragment, rather than just the first child.
(WebCore::Editor::WebContentReader::readURL):
Tools:
Adds a new test that performs data interaction in a contenteditable with multiple items containing URLs.
* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(TestWebKitAPI::TEST):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (217283 => 217284)
--- trunk/Source/WebCore/ChangeLog 2017-05-23 18:20:34 UTC (rev 217283)
+++ trunk/Source/WebCore/ChangeLog 2017-05-23 18:27:21 UTC (rev 217284)
@@ -1,3 +1,25 @@
+2017-05-23 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Multiple links should be inserted separately when performing data interaction
+ https://bugs.webkit.org/show_bug.cgi?id=172489
+ <rdar://problem/31510832>
+
+ Reviewed by Dan Bernstein.
+
+ In WebContentReader, URLs are currently always inserted inline. When inserting multiple items, this causes
+ adjacent links to be inserted on a single line with no break, which is undesirable. To address this, when
+ appending links from additional items to the existing document fragment in WebContentReader, insert a new space
+ prior to inserting the anchor element.
+
+ New unit test: DataInteractionTests.ExternalSourceMultipleURLsToContentEditable
+
+ * editing/ios/EditorIOS.mm:
+ (WebCore::Editor::WebContentReader::addFragment):
+
+ Tweak to add all children of the new fragment, rather than just the first child.
+
+ (WebCore::Editor::WebContentReader::readURL):
+
2017-05-23 Sam Weinig <s...@webkit.org>
[WebIDL] Remove some unnecessary specialization for enum types
Modified: trunk/Source/WebCore/editing/ios/EditorIOS.mm (217283 => 217284)
--- trunk/Source/WebCore/editing/ios/EditorIOS.mm 2017-05-23 18:20:34 UTC (rev 217283)
+++ trunk/Source/WebCore/editing/ios/EditorIOS.mm 2017-05-23 18:27:21 UTC (rev 217284)
@@ -244,11 +244,18 @@
void Editor::WebContentReader::addFragment(RefPtr<DocumentFragment>&& newFragment)
{
- if (fragment) {
- if (newFragment && newFragment->firstChild())
- fragment->appendChild(*newFragment->firstChild());
- } else
+ if (!newFragment)
+ return;
+
+ if (!fragment) {
fragment = WTFMove(newFragment);
+ return;
+ }
+
+ while (auto* firstChild = newFragment->firstChild()) {
+ if (fragment->appendChild(*firstChild).hasException())
+ break;
+ }
}
bool Editor::WebContentReader::readWebArchive(SharedBuffer* buffer)
@@ -337,6 +344,8 @@
anchor->appendChild(frame.document()->createTextNode(linkText));
auto newFragment = frame.document()->createDocumentFragment();
+ if (fragment)
+ newFragment->appendChild(Text::create(*frame.document(), { &space, 1 }));
newFragment->appendChild(anchor);
addFragment(WTFMove(newFragment));
return true;
Modified: trunk/Tools/ChangeLog (217283 => 217284)
--- trunk/Tools/ChangeLog 2017-05-23 18:20:34 UTC (rev 217283)
+++ trunk/Tools/ChangeLog 2017-05-23 18:27:21 UTC (rev 217284)
@@ -1,3 +1,16 @@
+2017-05-23 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Multiple links should be inserted separately when performing data interaction
+ https://bugs.webkit.org/show_bug.cgi?id=172489
+ <rdar://problem/31510832>
+
+ Reviewed by Dan Bernstein.
+
+ Adds a new test that performs data interaction in a contenteditable with multiple items containing URLs.
+
+ * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
+ (TestWebKitAPI::TEST):
+
2017-05-23 Tim Horton <timothy_hor...@apple.com>
REGRESSION: API test WebKit2.WKObject is failing
Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm (217283 => 217284)
--- trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm 2017-05-23 18:20:34 UTC (rev 217283)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm 2017-05-23 18:27:21 UTC (rev 217284)
@@ -485,6 +485,29 @@
EXPECT_WK_STREQ("image/jpeg, text/html, text/html", outputValue.UTF8String);
}
+TEST(DataInteractionTests, ExternalSourceMultipleURLsToContentEditable)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+ [webView synchronouslyLoadTestPageNamed:@"autofocus-contenteditable"];
+ [webView stringByEvaluatingJavaScript:@"getSelection().removeAllRanges()"];
+
+ auto dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
+ auto firstItem = adoptNS([[UIItemProvider alloc] init]);
+ [firstItem registerObject:[NSURL URLWithString:@"https://www.apple.com/iphone/"] visibility:UIItemProviderRepresentationOptionsVisibilityAll];
+ auto secondItem = adoptNS([[UIItemProvider alloc] init]);
+ [secondItem registerObject:[NSURL URLWithString:@"https://www.apple.com/mac/"] visibility:UIItemProviderRepresentationOptionsVisibilityAll];
+ auto thirdItem = adoptNS([[UIItemProvider alloc] init]);
+ [thirdItem registerObject:[NSURL URLWithString:@"https://webkit.org/"] visibility:UIItemProviderRepresentationOptionsVisibilityAll];
+ [dataInteractionSimulator setExternalItemProviders:@[ firstItem.get(), secondItem.get(), thirdItem.get() ]];
+ [dataInteractionSimulator runFrom:CGPointMake(300, 400) to:CGPointMake(100, 300)];
+
+ NSArray *separatedLinks = [[webView stringByEvaluatingJavaScript:@"editor.textContent"] componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ EXPECT_EQ(3UL, separatedLinks.count);
+ EXPECT_WK_STREQ("https://www.apple.com/iphone/", separatedLinks[0]);
+ EXPECT_WK_STREQ("https://www.apple.com/mac/", separatedLinks[1]);
+ EXPECT_WK_STREQ("https://webkit.org/", separatedLinks[2]);
+}
+
TEST(DataInteractionTests, RespectsExternalSourceFidelityRankings)
{
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes