Changeset 87499 in webkit
- Timestamp:
- May 27, 2011 5:37:48 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 9 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r87498 r87499 1 2011-05-26 Yael Aharon <yael.aharon@nokia.com> 2 3 Reviewed by Tony Chang. 4 5 webkit should implement the dropzone attribute 6 https://bugs.webkit.org/show_bug.cgi?id=58210 7 8 * fast/events/dropzone-001-expected.txt: Added. 9 * fast/events/dropzone-001.html: Added. 10 * fast/events/dropzone-002-expected.txt: Added. 11 * fast/events/dropzone-002.html: Added. 12 * fast/events/dropzone-003-expected.txt: Added. 13 * fast/events/dropzone-003.html: Added. 14 * fast/events/dropzone-004-expected.txt: Added. 15 * fast/events/dropzone-004.html: Added. 16 * fast/events/resources/dropzone.js: Added. 17 1 18 2011-05-27 Csaba Osztrogonác <ossy@webkit.org> 2 19 -
trunk/Source/WebCore/ChangeLog
r87494 r87499 1 2011-05-26 Yael Aharon <yael.aharon@nokia.com> 2 3 Reviewed by Tony Chang. 4 5 webkit should implement the dropzone attribute 6 https://bugs.webkit.org/show_bug.cgi?id=58210 7 8 Add support for dropzone attribute. 9 http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#the-dropzone-attribute 10 If a drag event was not canceled by JavaScript, look for an element with a dropzone attribute. 11 If there is such an element, and it matches the drag data store, set the action defined by that 12 element and continue processing the drag and drop operation. 13 14 Tests: fast/events/dropzone-001.html 15 fast/events/dropzone-002.html 16 fast/events/dropzone-003.html 17 fast/events/dropzone-004.html 18 19 * dom/Clipboard.cpp: 20 (WebCore::Clipboard::hasFileOfType): 21 (WebCore::Clipboard::hasStringOfType): 22 (WebCore::convertDropZoneOperationToDragOperation): 23 (WebCore::convertDragOperationToDropZoneOperation): 24 (WebCore::Clipboard::processDropZoneKeyword): 25 * dom/Clipboard.h: 26 * html/HTMLAttributeNames.in: 27 * html/HTMLElement.idl: 28 * page/EventHandler.cpp: 29 (WebCore::EventHandler::findDropZone): 30 (WebCore::EventHandler::updateDragAndDrop): 31 * page/EventHandler.h: 32 1 33 2011-05-27 Patrick Gansterer <paroga@webkit.org> 2 34 -
trunk/Source/WebCore/dom/Clipboard.cpp
r67973 r87499 28 28 29 29 #include "CachedImage.h" 30 #include "FileList.h" 30 31 #include "Frame.h" 31 32 #include "FrameLoader.h" … … 126 127 } 127 128 129 bool Clipboard::hasFileOfType(const String& type) const 130 { 131 if (m_policy != ClipboardReadable && m_policy != ClipboardTypesReadable) 132 return false; 133 134 RefPtr<FileList> fileList = files(); 135 if (fileList->isEmpty()) 136 return false; 137 138 for (unsigned int f = 0; f < fileList->length(); f++) { 139 if (equalIgnoringCase(fileList->item(f)->type(), type)) 140 return true; 141 } 142 return false; 143 } 144 145 bool Clipboard::hasStringOfType(const String& type) const 146 { 147 if (m_policy != ClipboardReadable && m_policy != ClipboardTypesReadable) 148 return false; 149 150 return types().contains(type); 151 } 152 128 153 void Clipboard::setDropEffect(const String &effect) 129 154 { … … 158 183 m_effectAllowed = effect; 159 184 } 185 186 DragOperation convertDropZoneOperationToDragOperation(const String& dragOperation) 187 { 188 if (dragOperation == "copy") 189 return DragOperationCopy; 190 if (dragOperation == "move") 191 return DragOperationMove; 192 if (dragOperation == "link") 193 return DragOperationLink; 194 return DragOperationNone; 195 } 196 197 String convertDragOperationToDropZoneOperation(DragOperation operation) 198 { 199 switch (operation) { 200 case DragOperationCopy: 201 return String("copy"); 202 case DragOperationMove: 203 return String("move"); 204 case DragOperationLink: 205 return String("link"); 206 default: 207 return String("copy"); 208 } 209 } 210 211 bool Clipboard::hasDropZoneType(const String& keyword) 212 { 213 if (keyword.length() < 3 || keyword[1] != ':') 214 return false; 215 216 switch (keyword[0]) { 217 case 'f': 218 return hasFileOfType(keyword.substring(2)); 219 case 's': 220 return hasStringOfType(keyword.substring(2)); 221 default: 222 return false; 223 } 224 } 160 225 161 226 } // namespace WebCore -
trunk/Source/WebCore/dom/Clipboard.h
r80536 r87499 47 47 DragAndDrop, 48 48 }; 49 49 50 static PassRefPtr<Clipboard> create(ClipboardAccessPolicy, DragData*, Frame*); 50 51 … … 93 94 void setDestinationOperation(DragOperation); 94 95 96 bool hasDropZoneType(const String&); 97 95 98 void setDragHasStarted() { m_dragStarted = true; } 96 99 … … 105 108 106 109 private: 110 bool hasFileOfType(const String&) const; 111 bool hasStringOfType(const String&) const; 112 107 113 ClipboardAccessPolicy m_policy; 108 114 String m_dropEffect; … … 117 123 }; 118 124 125 DragOperation convertDropZoneOperationToDragOperation(const String& dragOperation); 126 String convertDragOperationToDropZoneOperation(DragOperation); 127 119 128 } // namespace WebCore 120 129 -
trunk/Source/WebCore/html/HTMLAttributeNames.in
r87473 r87499 93 93 disabled 94 94 draggable 95 webkitdropzone 95 96 enctype 96 97 end -
trunk/Source/WebCore/html/HTMLElement.idl
r76301 r87499 36 36 attribute long tabIndex; 37 37 attribute boolean draggable; 38 attribute [Reflect] DOMString webkitdropzone; 38 39 attribute [Reflect] boolean hidden; 39 40 -
trunk/Source/WebCore/page/EventHandler.cpp
r87096 r87499 1790 1790 } 1791 1791 1792 static bool findDropZone(Node* target, Clipboard* clipboard) 1793 { 1794 Element* element = target->isElementNode() ? toElement(target) : target->parentElement(); 1795 for (; element; element = element->parentElement()) { 1796 bool matched = false; 1797 String dropZoneStr = element->fastGetAttribute(webkitdropzoneAttr); 1798 1799 if (dropZoneStr.isEmpty()) 1800 continue; 1801 1802 dropZoneStr.makeLower(); 1803 1804 SpaceSplitString keywords(dropZoneStr, false); 1805 if (keywords.isNull()) 1806 continue; 1807 1808 DragOperation dragOperation = DragOperationNone; 1809 for (unsigned int i = 0; i < keywords.size(); i++) { 1810 DragOperation op = convertDropZoneOperationToDragOperation(keywords[i]); 1811 if (op != DragOperationNone) { 1812 if (dragOperation == DragOperationNone) 1813 dragOperation = op; 1814 } else 1815 matched = matched || clipboard->hasDropZoneType(keywords[i].string()); 1816 1817 if (matched && dragOperation != DragOperationNone) 1818 break; 1819 } 1820 if (matched) { 1821 clipboard->setDropEffect(convertDragOperationToDropZoneOperation(dragOperation)); 1822 return true; 1823 } 1824 } 1825 return false; 1826 } 1827 1792 1828 bool EventHandler::updateDragAndDrop(const PlatformMouseEvent& event, Clipboard* clipboard) 1793 1829 { … … 1820 1856 } 1821 1857 accept = dispatchDragEvent(eventNames().dragenterEvent, newTarget, event, clipboard); 1858 if (!accept) 1859 accept = findDropZone(newTarget, clipboard); 1822 1860 } 1823 1861 … … 1838 1876 } 1839 1877 accept = dispatchDragEvent(eventNames().dragoverEvent, newTarget, event, clipboard); 1878 if (!accept) 1879 accept = findDropZone(newTarget, clipboard); 1840 1880 m_shouldOnlyFireDragOverEvent = false; 1841 1881 }
Note: See TracChangeset
for help on using the changeset viewer.