Changeset 221343 in webkit
- Timestamp:
- Aug 29, 2017, 10:09:23 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r221336 r221343 1 2017-08-29 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 REGRESSION(r210287) On drop, event.dataTransfer.getData("text") returns an empty string when dragging an image 4 https://bugs.webkit.org/show_bug.cgi?id=170637 5 <rdar://problem/31347248> 6 7 Reviewed by Ryosuke Niwa. 8 9 Adds a new test to verify that upon dropping an image enclosed within an anchor, DataTransfer.getData() can be 10 used to grab the href of the enclosing anchor. 11 12 * TestExpectations: 13 * editing/pasteboard/drag-drop-href-as-text-data-expected.txt: Added. 14 * editing/pasteboard/drag-drop-href-as-text-data.html: Added. 15 * platform/mac-wk1/TestExpectations: 16 1 17 2017-08-29 Devin Rousso <webkit@devinrousso.com> 2 18 -
trunk/LayoutTests/TestExpectations
r221170 r221343 64 64 fast/events/autoscroll-when-zoomed.html [ Skip ] 65 65 fast/events/autoscroll-main-document.html [ Skip ] 66 67 # Drag and drop via EventSender is only supported on Mac WK1 68 editing/pasteboard/drag-drop-href-as-text-data.html [ Skip ] 66 69 67 70 # Only iOS supports QuickLook -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r221234 r221343 7 7 8 8 fast/forms/attributed-strings.html [ Pass ] 9 editing/pasteboard/drag-drop-href-as-text-data.html [ Pass ] 9 10 10 11 #////////////////////////////////////////////////////////////////////////////////////////// -
trunk/Source/WebCore/ChangeLog
r221342 r221343 1 2017-08-29 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 REGRESSION(r210287) On drop, event.dataTransfer.getData("text") returns an empty string when dragging an image 4 https://bugs.webkit.org/show_bug.cgi?id=170637 5 <rdar://problem/31347248> 6 7 Reviewed by Ryosuke Niwa. 8 9 In r210287, the behavior of DragData::containsFiles was changed to return true if NSFilesPromisePboardType is 10 present in the pasteboard. This means that we will consider images dragged from web content, for which we add 11 the NSFilesPromisePboardType UTI, as containing files on the pasteboard; this, in turn, means we'll initialize 12 the DataTransfer upon drop with m_forFileDrag set to true. Due to early returns in getData() and setData() to 13 deny data access when dropping a dragged file, this means the page won't ever get access to the URL in the 14 pasteboard due to the presence of the NSFilesPromisePboardType UTI. 15 16 To fix this, we replace the early m_forFileDrag returns in getData and setData, instead early returning the null 17 string if there are any file URLs present on the pasteboard (determined via readFilenames() retrieving a non- 18 empty result). 19 20 Test: editing/pasteboard/drag-drop-href-as-text-data.html 21 22 * dom/DataTransfer.cpp: 23 (WebCore::DataTransfer::DataTransfer): 24 (WebCore::DataTransfer::getData const): 25 (WebCore::DataTransfer::setData): 26 27 Rather than bail upon forFileDrag() (formerly, m_forFileDrag) being true, bail if there are any file URLs 28 present on the pasteboard. It seems like this was the intention of the early return in the first place, to 29 prevent the page from being able to ask for a real file URL when dragging a file. 30 31 (WebCore::DataTransfer::files const): 32 (WebCore::DataTransfer::setDragImage): 33 (WebCore::DataTransfer::setDropEffect): 34 (WebCore::DataTransfer::setEffectAllowed): 35 36 Swap m_forDrag and m_forFileDrag with forDrag() and forFileDrag(), respectively. 37 38 * dom/DataTransfer.h: 39 (WebCore::DataTransfer::forDrag const): 40 (WebCore::DataTransfer::forFileDrag const): 41 42 Instead of caching two bools to represent state (m_forDrag and m_forFileDrag), just remember the DataTransfer's 43 m_type and turn the flags into const helpers that check for the value of m_type. 44 1 45 2017-08-29 Youenn Fablet <youenn@apple.com> 2 46 -
trunk/Source/WebCore/dom/DataTransfer.cpp
r221067 r221343 62 62 , m_pasteboard(WTFMove(pasteboard)) 63 63 #if ENABLE(DRAG_SUPPORT) 64 , m_forDrag(type == Type::DragAndDropData || type == Type::DragAndDropFiles) 65 , m_forFileDrag(type == Type::DragAndDropFiles) 64 , m_type(type) 66 65 , m_dropEffect(ASCIILiteral("uninitialized")) 67 66 , m_effectAllowed(ASCIILiteral("uninitialized")) … … 138 137 139 138 #if ENABLE(DRAG_SUPPORT) 140 if ( m_forFileDrag)141 return String();139 if (forFileDrag() && m_pasteboard->readFilenames().size()) 140 return { }; 142 141 #endif 143 142 … … 151 150 152 151 #if ENABLE(DRAG_SUPPORT) 153 if ( m_forFileDrag)152 if (forFileDrag() && m_pasteboard->readFilenames().size()) 154 153 return; 155 154 #endif … … 188 187 189 188 #if ENABLE(DRAG_SUPPORT) 190 if ( m_forDrag && !m_forFileDrag) {189 if (forDrag() && !forFileDrag()) { 191 190 ASSERT(m_fileList->isEmpty()); 192 191 return *m_fileList; … … 267 266 void DataTransfer::setDragImage(Element* element, int x, int y) 268 267 { 269 if (! m_forDrag|| !canWriteData())268 if (!forDrag() || !canWriteData()) 270 269 return; 271 270 … … 423 422 void DataTransfer::setDropEffect(const String& effect) 424 423 { 425 if (! m_forDrag)424 if (!forDrag()) 426 425 return; 427 426 … … 444 443 void DataTransfer::setEffectAllowed(const String& effect) 445 444 { 446 if (! m_forDrag)445 if (!forDrag()) 447 446 return; 448 447 -
trunk/Source/WebCore/dom/DataTransfer.h
r220951 r221343 99 99 DataTransfer(StoreMode, std::unique_ptr<Pasteboard>, Type = Type::CopyAndPaste); 100 100 101 #if ENABLE(DRAG_SUPPORT) 102 bool forDrag() const { return m_type == Type::DragAndDropData || m_type == Type::DragAndDropFiles; } 103 bool forFileDrag() const { return m_type == Type::DragAndDropFiles; } 104 #endif 105 101 106 StoreMode m_storeMode; 102 107 std::unique_ptr<Pasteboard> m_pasteboard; … … 106 111 107 112 #if ENABLE(DRAG_SUPPORT) 108 bool m_forDrag; 109 bool m_forFileDrag; 113 Type m_type; 110 114 String m_dropEffect; 111 115 String m_effectAllowed;
Note:
See TracChangeset
for help on using the changeset viewer.