Title: [231396] trunk
Revision
231396
Author
wenson_hs...@apple.com
Date
2018-05-04 21:39:52 -0700 (Fri, 04 May 2018)

Log Message

[iOS] Multiple links in Mail are dropped in a single line, and are difficult to tell apart
https://bugs.webkit.org/show_bug.cgi?id=185289
<rdar://problem/35756912>

Reviewed by Tim Horton and Darin Adler.

Source/WebCore:

When inserting multiple URLs as individual items in a single drop, we currently separate each item with a space
(see r217284). However, it still seems difficult to tell dropped links apart. This patch makes some slight
tweaks to WebContentReader::readURL so that it inserts line breaks before dropped URLs, if the dropped URL isn't
the first item to be inserted in the resulting document fragment.

Augments existing API tests in DataInteractionTests.

* editing/ios/WebContentReaderIOS.mm:

Additionally remove some extraneous header imports from this implementation file.

(WebCore::WebContentReader::readURL):

Tools:

Augment and rebaseline some iOS drag-and-drop API tests that handle dropping URLs as a part of multi-item drop
sessions.

* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (231395 => 231396)


--- trunk/Source/WebCore/ChangeLog	2018-05-05 02:11:53 UTC (rev 231395)
+++ trunk/Source/WebCore/ChangeLog	2018-05-05 04:39:52 UTC (rev 231396)
@@ -1,3 +1,24 @@
+2018-05-04  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS] Multiple links in Mail are dropped in a single line, and are difficult to tell apart
+        https://bugs.webkit.org/show_bug.cgi?id=185289
+        <rdar://problem/35756912>
+
+        Reviewed by Tim Horton and Darin Adler.
+
+        When inserting multiple URLs as individual items in a single drop, we currently separate each item with a space
+        (see r217284). However, it still seems difficult to tell dropped links apart. This patch makes some slight
+        tweaks to WebContentReader::readURL so that it inserts line breaks before dropped URLs, if the dropped URL isn't
+        the first item to be inserted in the resulting document fragment.
+
+        Augments existing API tests in DataInteractionTests.
+
+        * editing/ios/WebContentReaderIOS.mm:
+
+        Additionally remove some extraneous header imports from this implementation file.
+
+        (WebCore::WebContentReader::readURL):
+
 2018-05-02  Dean Jackson  <d...@apple.com>
 
         Use IOSurfaces for CoreImage operations where possible

Modified: trunk/Source/WebCore/editing/ios/WebContentReaderIOS.mm (231395 => 231396)


--- trunk/Source/WebCore/editing/ios/WebContentReaderIOS.mm	2018-05-05 02:11:53 UTC (rev 231395)
+++ trunk/Source/WebCore/editing/ios/WebContentReaderIOS.mm	2018-05-05 04:39:52 UTC (rev 231396)
@@ -28,24 +28,14 @@
 
 #if PLATFORM(IOS)
 
-#import "ArchiveResource.h"
 #import "Document.h"
 #import "DocumentFragment.h"
-#import "DocumentLoader.h"
 #import "Editor.h"
 #import "EditorClient.h"
-#import "FragmentScriptingPermission.h"
-#import "FrameLoader.h"
-#import "FrameLoaderClient.h"
 #import "HTMLAnchorElement.h"
+#import "HTMLBRElement.h"
 #import "HTMLNames.h"
-#import "LegacyWebArchive.h"
-#import "MIMETypeRegistry.h"
 #import "Text.h"
-#import "UTIUtilities.h"
-#import "markup.h"
-#import <MobileCoreServices/MobileCoreServices.h>
-#import <wtf/unicode/CharacterNames.h>
 
 namespace WebCore {
 
@@ -63,15 +53,16 @@
     if ([(NSURL *)url isFileURL])
         return false;
 
-    auto anchor = HTMLAnchorElement::create(*frame.document());
+    auto document = makeRef(*frame.document());
+    auto anchor = HTMLAnchorElement::create(document.get());
     anchor->setAttributeWithoutSynchronization(HTMLNames::hrefAttr, url.string());
 
     String linkText = title.length() ? title : String([[(NSURL *)url absoluteString] precomposedStringWithCanonicalMapping]);
-    anchor->appendChild(frame.document()->createTextNode(linkText));
+    anchor->appendChild(document->createTextNode(linkText));
 
-    auto newFragment = frame.document()->createDocumentFragment();
+    auto newFragment = document->createDocumentFragment();
     if (fragment)
-        newFragment->appendChild(Text::create(*frame.document(), { &space, 1 }));
+        newFragment->appendChild(HTMLBRElement::create(document.get()));
     newFragment->appendChild(anchor);
     addFragment(WTFMove(newFragment));
     return true;

Modified: trunk/Tools/ChangeLog (231395 => 231396)


--- trunk/Tools/ChangeLog	2018-05-05 02:11:53 UTC (rev 231395)
+++ trunk/Tools/ChangeLog	2018-05-05 04:39:52 UTC (rev 231396)
@@ -1,3 +1,17 @@
+2018-05-04  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS] Multiple links in Mail are dropped in a single line, and are difficult to tell apart
+        https://bugs.webkit.org/show_bug.cgi?id=185289
+        <rdar://problem/35756912>
+
+        Reviewed by Tim Horton and Darin Adler.
+
+        Augment and rebaseline some iOS drag-and-drop API tests that handle dropping URLs as a part of multi-item drop
+        sessions.
+
+        * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
+        (TestWebKitAPI::TEST):
+
 2018-05-04  Timothy Hatcher  <timo...@apple.com>
 
         Deprecate legacy WebView and friends

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm (231395 => 231396)


--- trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm	2018-05-05 02:11:53 UTC (rev 231395)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm	2018-05-05 04:39:52 UTC (rev 231396)
@@ -856,11 +856,17 @@
     [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]);
+    NSArray *droppedURLs = [webView objectByEvaluatingJavaScript:@"Array.from(editor.querySelectorAll('a')).map(a => a.href)"];
+    EXPECT_EQ(3UL, droppedURLs.count);
+    EXPECT_WK_STREQ("https://www.apple.com/iphone/", droppedURLs[0]);
+    EXPECT_WK_STREQ("https://www.apple.com/mac/", droppedURLs[1]);
+    EXPECT_WK_STREQ("https://webkit.org/", droppedURLs[2]);
+
+    NSArray *linksSeparatedByLine = [[webView objectByEvaluatingJavaScript:@"editor.innerText"] componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
+    EXPECT_EQ(3UL, linksSeparatedByLine.count);
+    EXPECT_WK_STREQ("https://www.apple.com/iphone/", linksSeparatedByLine[0]);
+    EXPECT_WK_STREQ("https://www.apple.com/mac/", linksSeparatedByLine[1]);
+    EXPECT_WK_STREQ("https://webkit.org/", linksSeparatedByLine[2]);
 }
 
 TEST(DataInteractionTests, RespectsExternalSourceFidelityRankings)
@@ -1466,7 +1472,7 @@
         @0.33: [NSValue valueWithCGPoint:CGPointMake(50, 150)],
         @0.66: [NSValue valueWithCGPoint:CGPointMake(50, 250)]
     }];
-    EXPECT_WK_STREQ("ABCD A link", [webView stringByEvaluatingJavaScript:@"editor.textContent"]);
+    EXPECT_WK_STREQ("ABCDA link", [webView stringByEvaluatingJavaScript:@"editor.textContent"]);
     EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!!editor.querySelector('img')"]);
     EXPECT_WK_STREQ("https://www.apple.com/", [webView stringByEvaluatingJavaScript:@"editor.querySelector('a').href"]);
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to