Changeset 228353 in webkit


Ignore:
Timestamp:
Feb 9, 2018 9:43:33 PM (6 years ago)
Author:
jmarcell@apple.com
Message:

Cherry-pick r228240. rdar://problem/37408894

Location:
branches/safari-605-branch
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-605-branch/LayoutTests/ChangeLog

    r228344 r228353  
     12018-02-09  Jason Marcell  <jmarcell@apple.com>
     2
     3        Cherry-pick r228240. rdar://problem/37408894
     4
     5    2018-02-07  Wenson Hsieh  <wenson_hsieh@apple.com>
     6
     7            REGRESSION(r226396): File paths are inserted when dropping image files
     8            https://bugs.webkit.org/show_bug.cgi?id=182557
     9            <rdar://problem/37294120>
     10
     11            Reviewed by Ryosuke Niwa.
     12
     13            Tweak an existing layout test that drops a file into a contenteditable, to check that no text is inserted into
     14            the editable element after dropping.
     15
     16            * editing/pasteboard/drag-files-to-editable-element-as-URLs-expected.txt:
     17            * editing/pasteboard/drag-files-to-editable-element-as-URLs.html:
     18
    1192018-02-09  Ryan Haddad  <ryanhaddad@apple.com>
    220
  • branches/safari-605-branch/LayoutTests/editing/pasteboard/drag-files-to-editable-element-as-URLs-expected.txt

    r221944 r228353  
    1 If we drag files onto an editable area, then attachments should be inserted into the editable area.
     1If we drag files onto an editable area, then attachments should not be inserted into the editable area since attachment elements are disabled.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
     
    77PASS document.createElement("attachment") instanceof HTMLUnknownElement is true
    88PASS editable.querySelector("attachment") is null
     9PASS editable.textContent is ""
    910PASS successfullyParsed is true
    1011
  • branches/safari-605-branch/LayoutTests/editing/pasteboard/drag-files-to-editable-element-as-URLs.html

    r221944 r228353  
    77<script src="../../resources/js-test-pre.js"></script>
    88<script>
    9 description('If we drag files onto an editable area, then attachments should be inserted into the editable area.');
     9description('If we drag files onto an editable area, then attachments should not be inserted into the editable area since attachment elements are disabled.');
    1010
    1111var editable = document.getElementById("editable");
     
    1515    shouldBeTrue('document.createElement("attachment") instanceof HTMLUnknownElement');
    1616    shouldBe('editable.querySelector("attachment")', 'null');
     17    shouldBe('editable.textContent', '""');
    1718    editable.innerHTML = '';
    1819}
  • branches/safari-605-branch/Source/WebCore/ChangeLog

    r228286 r228353  
     12018-02-09  Jason Marcell  <jmarcell@apple.com>
     2
     3        Cherry-pick r228240. rdar://problem/37408894
     4
     5    2018-02-07  Wenson Hsieh  <wenson_hsieh@apple.com>
     6
     7            REGRESSION(r226396): File paths are inserted when dropping image files
     8            https://bugs.webkit.org/show_bug.cgi?id=182557
     9            <rdar://problem/37294120>
     10
     11            Reviewed by Ryosuke Niwa.
     12
     13            Reverts unintended changes in <http://trac.webkit.org/r226396>. Before r226396, WebContentReader::readFilenames
     14            (a helper function in macOS-specific code) contained logic to create and insert attachment elements if
     15            ENABLE(ATTACHMENT_ELEMENT); otherwise, it would fall back to inserting the visible URL as a text node. Since we
     16            enable the attachment element on all Cocoa platforms via xcconfig files, this was effectively dead code.
     17
     18            However, when r226396 (which moved this out from macOS to Cocoa platform code) refactored this helper function,
     19            it also moved this chunk of code out of the !ENABLE(ATTACHMENT) conditional and into a PLATFORM(MAC) guard,
     20            which means that we now fall back to inserting file paths as text when attachment elements are disabled. To fix
     21            this, we simply remove the (previously) dead code.
     22
     23            A more subtle difference is that we no longer always return true from WebContentReader::readFilePaths. This
     24            means that when we drop files, we no longer skip over the early return in documentFragmentFromDragData when
     25            we've made a fragment, so we read the file path as a URL. To address this, we just restore the pre-macOS 10.13.4
     26            behavior of initializing the document fragment.
     27
     28            Test: modified editing/pasteboard/drag-files-to-editable-element-as-URLs.html.
     29
     30            * editing/WebContentReader.cpp:
     31            (WebCore::WebContentReader::ensureFragment): Deleted.
     32
     33            Remove this helper, as it was only used in WebContentReader::readFilePaths.
     34
     35            * editing/WebContentReader.h:
     36            * editing/cocoa/WebContentReaderCocoa.mm:
     37            (WebCore::WebContentReader::readFilePaths):
     38
    1392018-02-08  Jason Marcell  <jmarcell@apple.com>
    240
  • branches/safari-605-branch/Source/WebCore/editing/WebContentReader.cpp

    r226396 r228353  
    3232namespace WebCore {
    3333
    34 DocumentFragment& WebContentReader::ensureFragment()
    35 {
    36     ASSERT(frame.document());
    37     if (!fragment)
    38         fragment = frame.document()->createDocumentFragment();
    39     return *fragment;
    40 }
    41 
    4234void WebContentReader::addFragment(Ref<DocumentFragment>&& newFragment)
    4335{
  • branches/safari-605-branch/Source/WebCore/editing/WebContentReader.h

    r226396 r228353  
    6464    }
    6565
    66     DocumentFragment& ensureFragment();
    6766    void addFragment(Ref<DocumentFragment>&&);
    6867
  • branches/safari-605-branch/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm

    r227404 r228353  
    616616
    617617    auto& document = *frame.document();
    618     bool readAnyFilePath = false;
    619     for (auto& path : paths) {
     618    if (!fragment)
     619        fragment = document.createDocumentFragment();
     620
    620621#if ENABLE(ATTACHMENT_ELEMENT)
    621         if (RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled()) {
     622    if (RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled()) {
     623        for (auto& path : paths) {
    622624            auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document);
    623625            attachment->setUniqueIdentifier(createCanonicalUUIDString());
    624626            attachment->setFile(File::create(path), HTMLAttachmentElement::UpdateDisplayAttributes::Yes);
    625             ensureFragment().appendChild(attachment);
    626             readAnyFilePath = true;
    627             continue;
     627            fragment->appendChild(attachment);
    628628        }
    629 #endif
    630 #if PLATFORM(MAC)
    631         // FIXME: Does (and should) any macOS client depend on inserting file paths as plain text in web content?
    632         // If not, we should just remove this.
    633         auto paragraph = createDefaultParagraphElement(document);
    634         paragraph->appendChild(document.createTextNode(userVisibleString([NSURL fileURLWithPath:path])));
    635         ensureFragment().appendChild(paragraph);
    636         readAnyFilePath = true;
    637 #endif
    638     }
    639     return readAnyFilePath;
    640 }
    641 
    642 }
     629    }
     630#endif
     631
     632    return true;
     633}
     634
     635}
  • branches/safari-605-branch/Tools/ChangeLog

    r228344 r228353  
     12018-02-09  Jason Marcell  <jmarcell@apple.com>
     2
     3        Cherry-pick r228240. rdar://problem/37408894
     4
     5    2018-02-07  Wenson Hsieh  <wenson_hsieh@apple.com>
     6
     7            REGRESSION(r226396): File paths are inserted when dropping image files
     8            https://bugs.webkit.org/show_bug.cgi?id=182557
     9            <rdar://problem/37294120>
     10
     11            Reviewed by Ryosuke Niwa.
     12
     13            Tweak some image pasting API tests to ensure that file paths are not inserted when pasting images backed by
     14            file paths on disk.
     15
     16            * TestWebKitAPI/Tests/WebKitCocoa/PasteImage.mm:
     17            (TEST):
     18
    1192018-02-09  Ryan Haddad  <ryanhaddad@apple.com>
    220
  • branches/safari-605-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteImage.mm

    r226173 r228353  
    141141    EXPECT_WK_STREQ("image/gif", [webView stringByEvaluatingJavaScript:@"file = dataTransfer.files[0]; file.type"]);
    142142    EXPECT_WK_STREQ("sunset-in-cupertino-400px.gif", [webView stringByEvaluatingJavaScript:@"file.name"]);
     143    EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"editor.textContent"]);
    143144
    144145    [webView stringByEvaluatingJavaScript:@"insertFileAsImage(file)"];
     
    162163    EXPECT_WK_STREQ("image/jpeg", [webView stringByEvaluatingJavaScript:@"file = dataTransfer.files[0]; file.type"]);
    163164    EXPECT_WK_STREQ("sunset-in-cupertino-600px.jpg", [webView stringByEvaluatingJavaScript:@"file.name"]);
     165    EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"editor.textContent"]);
    164166
    165167    [webView stringByEvaluatingJavaScript:@"insertFileAsImage(file)"];
     
    183185    EXPECT_WK_STREQ("image/png", [webView stringByEvaluatingJavaScript:@"file = dataTransfer.files[0]; file.type"]);
    184186    EXPECT_WK_STREQ("sunset-in-cupertino-200px.png", [webView stringByEvaluatingJavaScript:@"file.name"]);
     187    EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"editor.textContent"]);
    185188
    186189    [webView stringByEvaluatingJavaScript:@"insertFileAsImage(file)"];
     
    204207    EXPECT_WK_STREQ("image/tiff", [webView stringByEvaluatingJavaScript:@"file = dataTransfer.files[0]; file.type"]);
    205208    EXPECT_WK_STREQ("sunset-in-cupertino-100px.tiff", [webView stringByEvaluatingJavaScript:@"file.name"]);
     209    EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"editor.textContent"]);
    206210
    207211    [webView stringByEvaluatingJavaScript:@"insertFileAsImage(file)"];
Note: See TracChangeset for help on using the changeset viewer.