Changeset 231396 in webkit


Ignore:
Timestamp:
May 4, 2018 9:39:52 PM (6 years ago)
Author:
Wenson Hsieh
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):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r231394 r231396  
     12018-05-04  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS] Multiple links in Mail are dropped in a single line, and are difficult to tell apart
     4        https://bugs.webkit.org/show_bug.cgi?id=185289
     5        <rdar://problem/35756912>
     6
     7        Reviewed by Tim Horton and Darin Adler.
     8
     9        When inserting multiple URLs as individual items in a single drop, we currently separate each item with a space
     10        (see r217284). However, it still seems difficult to tell dropped links apart. This patch makes some slight
     11        tweaks to WebContentReader::readURL so that it inserts line breaks before dropped URLs, if the dropped URL isn't
     12        the first item to be inserted in the resulting document fragment.
     13
     14        Augments existing API tests in DataInteractionTests.
     15
     16        * editing/ios/WebContentReaderIOS.mm:
     17
     18        Additionally remove some extraneous header imports from this implementation file.
     19
     20        (WebCore::WebContentReader::readURL):
     21
    1222018-05-02  Dean Jackson  <dino@apple.com>
    223
  • trunk/Source/WebCore/editing/ios/WebContentReaderIOS.mm

    r228531 r231396  
    2929#if PLATFORM(IOS)
    3030
    31 #import "ArchiveResource.h"
    3231#import "Document.h"
    3332#import "DocumentFragment.h"
    34 #import "DocumentLoader.h"
    3533#import "Editor.h"
    3634#import "EditorClient.h"
    37 #import "FragmentScriptingPermission.h"
    38 #import "FrameLoader.h"
    39 #import "FrameLoaderClient.h"
    4035#import "HTMLAnchorElement.h"
     36#import "HTMLBRElement.h"
    4137#import "HTMLNames.h"
    42 #import "LegacyWebArchive.h"
    43 #import "MIMETypeRegistry.h"
    4438#import "Text.h"
    45 #import "UTIUtilities.h"
    46 #import "markup.h"
    47 #import <MobileCoreServices/MobileCoreServices.h>
    48 #import <wtf/unicode/CharacterNames.h>
    4939
    5040namespace WebCore {
     
    6454        return false;
    6555
    66     auto anchor = HTMLAnchorElement::create(*frame.document());
     56    auto document = makeRef(*frame.document());
     57    auto anchor = HTMLAnchorElement::create(document.get());
    6758    anchor->setAttributeWithoutSynchronization(HTMLNames::hrefAttr, url.string());
    6859
    6960    String linkText = title.length() ? title : String([[(NSURL *)url absoluteString] precomposedStringWithCanonicalMapping]);
    70     anchor->appendChild(frame.document()->createTextNode(linkText));
     61    anchor->appendChild(document->createTextNode(linkText));
    7162
    72     auto newFragment = frame.document()->createDocumentFragment();
     63    auto newFragment = document->createDocumentFragment();
    7364    if (fragment)
    74         newFragment->appendChild(Text::create(*frame.document(), { &space, 1 }));
     65        newFragment->appendChild(HTMLBRElement::create(document.get()));
    7566    newFragment->appendChild(anchor);
    7667    addFragment(WTFMove(newFragment));
  • trunk/Tools/ChangeLog

    r231383 r231396  
     12018-05-04  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS] Multiple links in Mail are dropped in a single line, and are difficult to tell apart
     4        https://bugs.webkit.org/show_bug.cgi?id=185289
     5        <rdar://problem/35756912>
     6
     7        Reviewed by Tim Horton and Darin Adler.
     8
     9        Augment and rebaseline some iOS drag-and-drop API tests that handle dropping URLs as a part of multi-item drop
     10        sessions.
     11
     12        * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
     13        (TestWebKitAPI::TEST):
     14
    1152018-05-04  Timothy Hatcher  <timothy@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm

    r229811 r231396  
    857857    [dataInteractionSimulator runFrom:CGPointMake(300, 400) to:CGPointMake(100, 300)];
    858858
    859     NSArray *separatedLinks = [[webView stringByEvaluatingJavaScript:@"editor.textContent"] componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    860     EXPECT_EQ(3UL, separatedLinks.count);
    861     EXPECT_WK_STREQ("https://www.apple.com/iphone/", separatedLinks[0]);
    862     EXPECT_WK_STREQ("https://www.apple.com/mac/", separatedLinks[1]);
    863     EXPECT_WK_STREQ("https://webkit.org/", separatedLinks[2]);
     859    NSArray *droppedURLs = [webView objectByEvaluatingJavaScript:@"Array.from(editor.querySelectorAll('a')).map(a => a.href)"];
     860    EXPECT_EQ(3UL, droppedURLs.count);
     861    EXPECT_WK_STREQ("https://www.apple.com/iphone/", droppedURLs[0]);
     862    EXPECT_WK_STREQ("https://www.apple.com/mac/", droppedURLs[1]);
     863    EXPECT_WK_STREQ("https://webkit.org/", droppedURLs[2]);
     864
     865    NSArray *linksSeparatedByLine = [[webView objectByEvaluatingJavaScript:@"editor.innerText"] componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
     866    EXPECT_EQ(3UL, linksSeparatedByLine.count);
     867    EXPECT_WK_STREQ("https://www.apple.com/iphone/", linksSeparatedByLine[0]);
     868    EXPECT_WK_STREQ("https://www.apple.com/mac/", linksSeparatedByLine[1]);
     869    EXPECT_WK_STREQ("https://webkit.org/", linksSeparatedByLine[2]);
    864870}
    865871
     
    14671473        @0.66: [NSValue valueWithCGPoint:CGPointMake(50, 250)]
    14681474    }];
    1469     EXPECT_WK_STREQ("ABCD A link", [webView stringByEvaluatingJavaScript:@"editor.textContent"]);
     1475    EXPECT_WK_STREQ("ABCDA link", [webView stringByEvaluatingJavaScript:@"editor.textContent"]);
    14701476    EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!!editor.querySelector('img')"]);
    14711477    EXPECT_WK_STREQ("https://www.apple.com/", [webView stringByEvaluatingJavaScript:@"editor.querySelector('a').href"]);
Note: See TracChangeset for help on using the changeset viewer.