Changeset 228240 in webkit
- Timestamp:
- Feb 7, 2018 1:31:15 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r228239 r228240 1 2018-02-07 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 REGRESSION(r226396): File paths are inserted when dropping image files 4 https://bugs.webkit.org/show_bug.cgi?id=182557 5 <rdar://problem/37294120> 6 7 Reviewed by Ryosuke Niwa. 8 9 Tweak an existing layout test that drops a file into a contenteditable, to check that no text is inserted into 10 the editable element after dropping. 11 12 * editing/pasteboard/drag-files-to-editable-element-as-URLs-expected.txt: 13 * editing/pasteboard/drag-files-to-editable-element-as-URLs.html: 14 1 15 2018-02-07 John Wilander <wilander@apple.com> 2 16 -
trunk/LayoutTests/editing/pasteboard/drag-files-to-editable-element-as-URLs-expected.txt
r221944 r228240 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 -
trunk/LayoutTests/editing/pasteboard/drag-files-to-editable-element-as-URLs.html
r221944 r228240 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 } -
trunk/Source/WebCore/ChangeLog
r228239 r228240 1 2018-02-07 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 REGRESSION(r226396): File paths are inserted when dropping image files 4 https://bugs.webkit.org/show_bug.cgi?id=182557 5 <rdar://problem/37294120> 6 7 Reviewed by Ryosuke Niwa. 8 9 Reverts unintended changes in <http://trac.webkit.org/r226396>. Before r226396, WebContentReader::readFilenames 10 (a helper function in macOS-specific code) contained logic to create and insert attachment elements if 11 ENABLE(ATTACHMENT_ELEMENT); otherwise, it would fall back to inserting the visible URL as a text node. Since we 12 enable the attachment element on all Cocoa platforms via xcconfig files, this was effectively dead code. 13 14 However, when r226396 (which moved this out from macOS to Cocoa platform code) refactored this helper function, 15 it also moved this chunk of code out of the !ENABLE(ATTACHMENT) conditional and into a PLATFORM(MAC) guard, 16 which means that we now fall back to inserting file paths as text when attachment elements are disabled. To fix 17 this, we simply remove the (previously) dead code. 18 19 A more subtle difference is that we no longer always return true from WebContentReader::readFilePaths. This 20 means that when we drop files, we no longer skip over the early return in documentFragmentFromDragData when 21 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 22 behavior of initializing the document fragment. 23 24 Test: modified editing/pasteboard/drag-files-to-editable-element-as-URLs.html. 25 26 * editing/WebContentReader.cpp: 27 (WebCore::WebContentReader::ensureFragment): Deleted. 28 29 Remove this helper, as it was only used in WebContentReader::readFilePaths. 30 31 * editing/WebContentReader.h: 32 * editing/cocoa/WebContentReaderCocoa.mm: 33 (WebCore::WebContentReader::readFilePaths): 34 1 35 2018-02-07 John Wilander <wilander@apple.com> 2 36 -
trunk/Source/WebCore/editing/WebContentReader.cpp
r226396 r228240 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 { -
trunk/Source/WebCore/editing/WebContentReader.h
r226396 r228240 64 64 } 65 65 66 DocumentFragment& ensureFragment();67 66 void addFragment(Ref<DocumentFragment>&&); 68 67 -
trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm
r227351 r228240 650 650 651 651 auto& document = *frame.document(); 652 bool readAnyFilePath = false; 653 for (auto& path : paths) { 652 if (!fragment) 653 fragment = document.createDocumentFragment(); 654 654 655 #if ENABLE(ATTACHMENT_ELEMENT) 655 if (RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled()) { 656 if (RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled()) { 657 for (auto& path : paths) { 656 658 auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document); 657 659 attachment->setFile(File::create(path), HTMLAttachmentElement::UpdateDisplayAttributes::Yes); 658 ensureFragment().appendChild(attachment); 659 readAnyFilePath = true; 660 continue; 661 } 662 #endif 663 #if PLATFORM(MAC) 664 // FIXME: Does (and should) any macOS client depend on inserting file paths as plain text in web content? 665 // If not, we should just remove this. 666 auto paragraph = createDefaultParagraphElement(document); 667 paragraph->appendChild(document.createTextNode(userVisibleString([NSURL fileURLWithPath:path]))); 668 ensureFragment().appendChild(paragraph); 669 readAnyFilePath = true; 670 #endif 671 } 672 return readAnyFilePath; 673 } 674 675 } 660 fragment->appendChild(attachment); 661 } 662 } 663 #endif 664 665 return true; 666 } 667 668 } -
trunk/Tools/ChangeLog
r228225 r228240 1 2018-02-07 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 REGRESSION(r226396): File paths are inserted when dropping image files 4 https://bugs.webkit.org/show_bug.cgi?id=182557 5 <rdar://problem/37294120> 6 7 Reviewed by Ryosuke Niwa. 8 9 Tweak some image pasting API tests to ensure that file paths are not inserted when pasting images backed by 10 file paths on disk. 11 12 * TestWebKitAPI/Tests/WebKitCocoa/PasteImage.mm: 13 (TEST): 14 1 15 2018-02-07 Ms2ger <Ms2ger@igalia.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteImage.mm
r226173 r228240 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.