Changeset 45168 in webkit
- Timestamp:
- Jun 25, 2009 2:24:33 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r45143 r45168 427 427 * fast/dom/resources/event-attribute-availability.js: 428 428 429 2009-05-21 Eric Seidel <eric@webkit.org> 430 431 Reviewed by Maciej Stachowiak. 432 433 Expose files in the clipboard in ondrop events. 434 https://bugs.webkit.org/show_bug.cgi?id=25916 435 436 File.fileSize subtests fail due to limitations of DRT during http tests: 437 https://bugs.webkit.org/show_bug.cgi?id=25909 438 439 Directory subtests fail until correct of directory File tests is decided by: 440 https://bugs.webkit.org/show_bug.cgi?id=25879 441 442 * http/tests/security/clipboard/clipboard-file-access-expected.txt: Added. 443 * http/tests/security/clipboard/clipboard-file-access.html: Added. 444 * http/tests/security/clipboard/resources/TEMPLATE.html: Added. 445 * http/tests/security/clipboard/resources/apple.gif: Copied from LayoutTests/editing/pasteboard/resources/apple.gif. 446 * http/tests/security/clipboard/resources/clipboard-file-access.js: Added. 447 (var): 448 (moveMouseToCenterOfElement): 449 (dragFilesOntoDragTarget): 450 (fileListShouldBe): 451 (draggingPathsShouldResultInFiles): 452 (runTest): 453 * http/tests/security/clipboard/resources/mozilla.gif: Copied from LayoutTests/editing/pasteboard/resources/mozilla.gif. 454 429 455 2009-06-22 David Levin <levin@chromium.org> 430 456 -
trunk/WebCore/ChangeLog
r45165 r45168 1 2009-05-21 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Maciej Stachowiak. 4 5 Expose files in the clipboard in ondrop events 6 https://bugs.webkit.org/show_bug.cgi?id=25916 7 8 Make it possible for applications like gmail to implement 9 drag and drop of attachments onto email messages. 10 11 This patch exposes an event.dataTransfer.files accessor 12 on the drop event. No information is exposed during dragover. 13 This follows the HTML 5 drag and drop security model: 14 http://www.w3.org/TR/html5/editing.html#security-risks-in-the-drag-and-drop-model 15 The test http/tests/security/clipboard/clipboard-file-access.html 16 verifies this behavior. 17 18 Internet Explorer shows historical documentation of supporting 19 getData('File') as a way of exposing files on the pasteboard. The current version of their docs: 20 http://msdn.microsoft.com/en-us/library/ms537658(VS.85).aspx 21 has removed this reference (as far as I can tell IE never implemented it) 22 I have a printed copy of that URL from 2008 on my desk describing getData('File') in IE. 23 IE does not follow the HTML5 clipboard security model and always allows access to the full clipboard, even on dragover. 24 25 I choose not to use IE's getData('File') and instead added .files 26 so that the accessor could have a type, matching WebKit's existing 27 .files accessor on HTMLInputElement. 28 29 Mozilla has equivalent file access: 30 event.dataTransfer.mozGetDataAt("application/x-moz-file", 0); 31 which also does not return a typed value. 32 https://developer.mozilla.org/En/DragDrop/Recommended_Drag_Types#Dragging_Files 33 34 This is only implemented for Mac WebKit. All other platforms (including Apple's Win WebKit) 35 have incomplete Clipboard implementations and will require experts from those platforms 36 to add this functionality. Right now they all have Clipboard*::files() methods which call notImplemented(); 37 38 Test: http/tests/security/clipboard/clipboard-file-access.html 39 40 * dom/Clipboard.h: 41 * dom/Clipboard.idl: 42 * platform/chromium/ClipboardChromium.cpp: 43 (WebCore::ClipboardChromium::files): 44 * platform/chromium/ClipboardChromium.h: 45 * platform/gtk/ClipboardGtk.cpp: 46 (WebCore::ClipboardGtk::files): 47 * platform/gtk/ClipboardGtk.h: 48 * platform/mac/ClipboardMac.h: 49 * platform/mac/ClipboardMac.mm: 50 (WebCore::absoluteURLsFromPasteboardFilenames): 51 (WebCore::absoluteURLsFromPasteboard): 52 (WebCore::ClipboardMac::files): 53 * platform/qt/ClipboardQt.cpp: 54 (WebCore::ClipboardQt::files): 55 * platform/qt/ClipboardQt.h: 56 * platform/win/ClipboardWin.cpp: 57 (WebCore::ClipboardWin::files): 58 * platform/win/ClipboardWin.h: 59 * platform/wx/ClipboardWx.cpp: 60 (WebCore::ClipboardWx::files): 61 * platform/wx/ClipboardWx.h: 62 1 63 2009-06-25 Eric Seidel <eric@webkit.org> 2 64 -
trunk/WebCore/dom/Clipboard.h
r45087 r45168 34 34 namespace WebCore { 35 35 36 class FileList; 37 36 38 // State available during IE's events for drag and drop and copy/paste 37 39 class Clipboard : public RefCounted<Clipboard> { … … 54 56 // extensions beyond IE's API 55 57 virtual HashSet<String> types() const = 0; 56 58 virtual PassRefPtr<FileList> files() const = 0; 59 57 60 IntPoint dragLocation() const { return m_dragLoc; } 58 61 CachedImage* dragImage() const { return m_dragImage.get(); } -
trunk/WebCore/dom/Clipboard.idl
r30735 r45168 35 35 attribute [ConvertNullStringTo=Undefined] DOMString effectAllowed; 36 36 readonly attribute [CustomGetter] Array types; 37 readonly attribute FileList files; 37 38 38 39 [Custom] void clearData(in [Optional] DOMString type) -
trunk/WebCore/platform/chromium/ClipboardChromium.cpp
r42156 r45168 176 176 } 177 177 178 PassRefPtr<FileList> ClipboardChromium::files() const 179 { 180 notImplemented(); 181 return 0; 182 } 183 178 184 void ClipboardChromium::setDragImage(CachedImage* image, Node* node, const IntPoint& loc) 179 185 { -
trunk/WebCore/platform/chromium/ClipboardChromium.h
r43335 r45168 60 60 61 61 // extensions beyond IE's API 62 HashSet<String> types() const; 62 virtual HashSet<String> types() const; 63 virtual PassRefPtr<FileList> files() const; 63 64 64 65 void setDragImage(CachedImage*, const IntPoint&); -
trunk/WebCore/platform/gtk/ClipboardGtk.cpp
r34544 r45168 70 70 } 71 71 72 PassRefPtr<FileList> ClipboardGtk::files() const 73 { 74 notImplemented(); 75 return 0; 76 } 77 72 78 IntPoint ClipboardGtk::dragLocation() const 73 79 { -
trunk/WebCore/platform/gtk/ClipboardGtk.h
r34544 r45168 48 48 bool setData(const String&, const String&); 49 49 50 HashSet<String> types() const; 50 virtual HashSet<String> types() const; 51 virtual PassRefPtr<FileList> files() const; 52 51 53 IntPoint dragLocation() const; 52 54 CachedImage* dragImage() const; -
trunk/WebCore/platform/mac/ClipboardMac.h
r34544 r45168 42 42 43 43 class Frame; 44 class FileList; 44 45 45 46 class ClipboardMac : public Clipboard, public CachedResourceClient { … … 61 62 // extensions beyond IE's API 62 63 virtual HashSet<String> types() const; 64 virtual PassRefPtr<FileList> files() const; 63 65 64 66 void setDragImage(CachedImage*, const IntPoint&); -
trunk/WebCore/platform/mac/ClipboardMac.mm
r43852 r45168 32 32 #import "Editor.h" 33 33 #import "FoundationExtras.h" 34 #import "FileList.h" 34 35 #import "Frame.h" 35 36 #import "Image.h" … … 140 141 } 141 142 142 static NSArray *absoluteURLsFromPasteboardFilenames(NSPasteboard* pasteboard, bool onlyFirstURL )143 static NSArray *absoluteURLsFromPasteboardFilenames(NSPasteboard* pasteboard, bool onlyFirstURL = false) 143 144 { 144 145 NSArray *fileList = [pasteboard propertyListForType:NSFilenamesPboardType]; … … 164 165 } 165 166 166 static NSArray *absoluteURLsFromPasteboard(NSPasteboard* pasteboard, bool onlyFirstURL )167 static NSArray *absoluteURLsFromPasteboard(NSPasteboard* pasteboard, bool onlyFirstURL = false) 167 168 { 168 169 // NOTE: We must always check [availableTypes containsObject:] before accessing pasteboard data … … 273 274 } 274 275 return result; 276 } 277 278 // FIXME: We could cache the computed fileList if necessary 279 // Currently each access gets a new copy, setData() modifications to the 280 // clipboard are not reflected in any FileList objects the page has accessed and stored 281 PassRefPtr<FileList> ClipboardMac::files() const 282 { 283 if (policy() != ClipboardReadable) 284 return FileList::create(); 285 286 NSArray *absoluteURLs = absoluteURLsFromPasteboard(m_pasteboard.get()); 287 NSUInteger count = [absoluteURLs count]; 288 289 RefPtr<FileList> fileList = FileList::create(); 290 for (NSUInteger x = 0; x < count; x++) { 291 NSURL *absoluteURL = [NSURL URLWithString:[absoluteURLs objectAtIndex:x]]; 292 ASSERT([absoluteURL isFileURL]); 293 fileList->append(File::create([absoluteURL path])); 294 } 295 return fileList.release(); // We will always return a FileList, sometimes empty 275 296 } 276 297 -
trunk/WebCore/platform/qt/ClipboardQt.cpp
r44802 r45168 179 179 } 180 180 181 PassRefPtr<FileList> ClipboardQt::files() const 182 { 183 notImplemented(); 184 return 0; 185 } 186 181 187 void ClipboardQt::setDragImage(CachedImage* image, const IntPoint& point) 182 188 { -
trunk/WebCore/platform/qt/ClipboardQt.h
r34544 r45168 57 57 58 58 // extensions beyond IE's API 59 HashSet<String> types() const; 60 59 virtual HashSet<String> types() const; 60 virtual PassRefPtr<FileList> files() const; 61 61 62 void setDragImage(CachedImage*, const IntPoint&); 62 63 void setDragImageElement(Node*, const IntPoint&); -
trunk/WebCore/platform/win/ClipboardWin.cpp
r45087 r45168 581 581 } 582 582 583 PassRefPtr<FileList> ClipboardWin::files() const 584 { 585 notImplemented(); 586 return 0; 587 } 588 583 589 void ClipboardWin::setDragImage(CachedImage* image, Node *node, const IntPoint &loc) 584 590 { -
trunk/WebCore/platform/win/ClipboardWin.h
r44995 r45168 58 58 59 59 // extensions beyond IE's API 60 HashSet<String> types() const; 60 virtual HashSet<String> types() const; 61 virtual PassRefPtr<FileList> files() const; 61 62 62 63 void setDragImage(CachedImage*, const IntPoint&); -
trunk/WebCore/platform/wx/ClipboardWx.cpp
r29663 r45168 71 71 } 72 72 73 PassRefPtr<FileList> ClipboardWx::files() const 74 { 75 notImplemented(); 76 return 0; 77 } 78 73 79 IntPoint ClipboardWx::dragLocation() const 74 80 { -
trunk/WebCore/platform/wx/ClipboardWx.h
r34544 r45168 47 47 48 48 // extensions beyond IE's API 49 HashSet<String> types() const; 49 virtual HashSet<String> types() const; 50 virtual PassRefPtr<FileList> files() const; 50 51 51 52 IntPoint dragLocation() const;
Note: See TracChangeset
for help on using the changeset viewer.