Changeset 228353 in webkit
- Timestamp:
- Feb 9, 2018 9:43:33 PM (6 years ago)
- Location:
- branches/safari-605-branch
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-605-branch/LayoutTests/ChangeLog
r228344 r228353 1 2018-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 1 19 2018-02-09 Ryan Haddad <ryanhaddad@apple.com> 2 20 -
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.1 If we drag files onto an editable area, then attachments should not be inserted into the editable area since attachment elements are disabled. 2 2 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". … … 7 7 PASS document.createElement("attachment") instanceof HTMLUnknownElement is true 8 8 PASS editable.querySelector("attachment") is null 9 PASS editable.textContent is "" 9 10 PASS successfullyParsed is true 10 11 -
branches/safari-605-branch/LayoutTests/editing/pasteboard/drag-files-to-editable-element-as-URLs.html
r221944 r228353 7 7 <script src="../../resources/js-test-pre.js"></script> 8 8 <script> 9 description('If we drag files onto an editable area, then attachments should be inserted into the editable area.');9 description('If we drag files onto an editable area, then attachments should not be inserted into the editable area since attachment elements are disabled.'); 10 10 11 11 var editable = document.getElementById("editable"); … … 15 15 shouldBeTrue('document.createElement("attachment") instanceof HTMLUnknownElement'); 16 16 shouldBe('editable.querySelector("attachment")', 'null'); 17 shouldBe('editable.textContent', '""'); 17 18 editable.innerHTML = ''; 18 19 } -
branches/safari-605-branch/Source/WebCore/ChangeLog
r228286 r228353 1 2018-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 1 39 2018-02-08 Jason Marcell <jmarcell@apple.com> 2 40 -
branches/safari-605-branch/Source/WebCore/editing/WebContentReader.cpp
r226396 r228353 32 32 namespace WebCore { 33 33 34 DocumentFragment& WebContentReader::ensureFragment()35 {36 ASSERT(frame.document());37 if (!fragment)38 fragment = frame.document()->createDocumentFragment();39 return *fragment;40 }41 42 34 void WebContentReader::addFragment(Ref<DocumentFragment>&& newFragment) 43 35 { -
branches/safari-605-branch/Source/WebCore/editing/WebContentReader.h
r226396 r228353 64 64 } 65 65 66 DocumentFragment& ensureFragment();67 66 void addFragment(Ref<DocumentFragment>&&); 68 67 -
branches/safari-605-branch/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm
r227404 r228353 616 616 617 617 auto& document = *frame.document(); 618 bool readAnyFilePath = false; 619 for (auto& path : paths) { 618 if (!fragment) 619 fragment = document.createDocumentFragment(); 620 620 621 #if ENABLE(ATTACHMENT_ELEMENT) 621 if (RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled()) { 622 if (RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled()) { 623 for (auto& path : paths) { 622 624 auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document); 623 625 attachment->setUniqueIdentifier(createCanonicalUUIDString()); 624 626 attachment->setFile(File::create(path), HTMLAttachmentElement::UpdateDisplayAttributes::Yes); 625 ensureFragment().appendChild(attachment); 626 readAnyFilePath = true; 627 continue; 627 fragment->appendChild(attachment); 628 628 } 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 1 2018-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 1 19 2018-02-09 Ryan Haddad <ryanhaddad@apple.com> 2 20 -
branches/safari-605-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteImage.mm
r226173 r228353 141 141 EXPECT_WK_STREQ("image/gif", [webView stringByEvaluatingJavaScript:@"file = dataTransfer.files[0]; file.type"]); 142 142 EXPECT_WK_STREQ("sunset-in-cupertino-400px.gif", [webView stringByEvaluatingJavaScript:@"file.name"]); 143 EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"editor.textContent"]); 143 144 144 145 [webView stringByEvaluatingJavaScript:@"insertFileAsImage(file)"]; … … 162 163 EXPECT_WK_STREQ("image/jpeg", [webView stringByEvaluatingJavaScript:@"file = dataTransfer.files[0]; file.type"]); 163 164 EXPECT_WK_STREQ("sunset-in-cupertino-600px.jpg", [webView stringByEvaluatingJavaScript:@"file.name"]); 165 EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"editor.textContent"]); 164 166 165 167 [webView stringByEvaluatingJavaScript:@"insertFileAsImage(file)"]; … … 183 185 EXPECT_WK_STREQ("image/png", [webView stringByEvaluatingJavaScript:@"file = dataTransfer.files[0]; file.type"]); 184 186 EXPECT_WK_STREQ("sunset-in-cupertino-200px.png", [webView stringByEvaluatingJavaScript:@"file.name"]); 187 EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"editor.textContent"]); 185 188 186 189 [webView stringByEvaluatingJavaScript:@"insertFileAsImage(file)"]; … … 204 207 EXPECT_WK_STREQ("image/tiff", [webView stringByEvaluatingJavaScript:@"file = dataTransfer.files[0]; file.type"]); 205 208 EXPECT_WK_STREQ("sunset-in-cupertino-100px.tiff", [webView stringByEvaluatingJavaScript:@"file.name"]); 209 EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"editor.textContent"]); 206 210 207 211 [webView stringByEvaluatingJavaScript:@"insertFileAsImage(file)"];
Note: See TracChangeset
for help on using the changeset viewer.