Changeset 69530 in webkit
- Timestamp:
- Oct 11, 2010 3:12:54 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r69528 r69530 1 2010-10-11 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Tony Chang. 4 5 [GTK] editing/pasteboard/dataTransfer-setData-getData.html fails on GTK+ 6 https://bugs.webkit.org/show_bug.cgi?id=47244 7 8 Unskip the freshly passing test and add a baseline which has a PASS for all 9 tests. 10 11 * platform/gtk/Skipped: Unskip passing test. 12 * platform/gtk/editing/pasteboard/dataTransfer-setData-getData-expected.txt: 13 1 14 2010-10-11 Martin Robinson <mrobinson@igalia.com> 2 15 -
trunk/LayoutTests/platform/gtk/editing/pasteboard/dataTransfer-setData-getData-expected.txt
r64082 r69530 6 6 --- Test set/get 'URL': 7 7 PASS getDataResultType is "string" 8 PASS getDataLines.length is 1 9 PASS getDataLines[0].replace(/\/$/, '') is "http://test.com" 8 PASS getDataResult is "http://test.com/" 9 --- Test set/get 'URL' with multiple URLs: 10 PASS getDataResultType is "string" 11 PASS getDataResult is "http://test.com/" 10 12 --- Test set/get 'text/uri-list': 11 13 PASS getDataResultType is "string" 12 PASS getDataLines.length is 2 13 PASS getDataLines[0].replace(/\/$/, '') is "http://test.com" 14 PASS getDataLines[1].replace(/\/$/, '') is "http://check.com" 14 PASS getDataResult is "http://test.com\r\nhttp://check.com" 15 --- Test set/get 'text/uri-list' using '\n': 16 PASS getDataResultType is "string" 17 PASS getDataResult is "http://test.com\nhttp://check.com" 15 18 --- Test set 'text/uri-list', get 'URL': 16 19 PASS getDataResultType is "string" 17 PASS getDataLines.length is 1 18 PASS getDataLines[0].replace(/\/$/, '') is "http://test.com" 20 PASS getDataResult is "http://test.com/" 21 --- Test set 'URL', get 'text/uri-list': 22 PASS getDataResultType is "string" 23 PASS getDataResult is "http://test.com\r\nhttp://check.com" 19 24 --- Test set 'text/uri-list', get 'URL', using only '\n': 20 25 PASS getDataResultType is "string" 21 PASS getDataLines.length is 1 22 PASS getDataLines[0].replace(/\/$/, '') is "http://test.com" 26 PASS getDataResult is "http://test.com/" 23 27 --- Test set/get 'text/uri-list' with comments: 24 28 PASS getDataResultType is "string" 25 PASS getDataLines.length is 2 26 PASS getDataLines[0].replace(/\/$/, '') is "http://test.com" 27 PASS getDataLines[1].replace(/\/$/, '') is "http://check.com" 29 PASS getDataResult is "# comment\r\nhttp://test.com\r\nhttp://check.com" 30 --- Test set 'text/uri-list', get 'URL' with comments: 31 PASS getDataResultType is "string" 32 PASS getDataResult is "http://test.com/" 33 --- Test set 'text/uri-list', get 'URL' with only comments: 34 PASS getDataResultType is "string" 35 PASS getDataResult is "" 28 36 --- Test set/get 'text/plain': 29 37 PASS getDataResultType is "string" 30 PASS getDataLines.length is 1 31 PASS getDataLines[0].replace(/\/$/, '') is "Lorem ipsum dolor sit amet." 38 PASS getDataResult is "Lorem ipsum dolor sit amet." 32 39 PASS successfullyParsed is true 33 40 -
trunk/WebCore/ChangeLog
r69529 r69530 1 2010-10-11 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Tony Chang. 4 5 [GTK] editing/pasteboard/dataTransfer-setData-getData.html fails on GTK+ 6 https://bugs.webkit.org/show_bug.cgi?id=47244 7 8 Store the URI list as a String in DataObjectGtk, so that non-URI elements 9 are preserved when getData(...) is called. This necessitates some other 10 changes, including adding a m_filenames member to DataObjectGtk to store 11 filenames extracted during setURIList(...). The logic in getData(...) has 12 also changed to set success = true no matter what to match the spec. A 13 followup patch will remove this parameter completely for all platforms. 14 15 * platform/gtk/ClipboardGtk.cpp: 16 (WebCore::ClipboardGtk::getData): Always succeed to match the HTML5 17 spec and Firefox. Simply return the uriList string from the DataObject 18 instead of reconstructing it from a vector of KURLs. 19 (WebCore::ClipboardGtk::setData): The DataObject now accepts a string 20 for the uriList parameter. 21 (WebCore::ClipboardGtk::types): Predicate the "Files" member on 22 DataObjectGtk::hasFilenames(). 23 (WebCore::ClipboardGtk::files): Update to reflect the change from 24 DataObjectGtk::files() to DataObjectGtk::filenames(). 25 * platform/gtk/DataObjectGtk.cpp: 26 (WebCore::DataObjectGtk::setURIList): Expanded this setter to find the 27 first valid URL to use as the m_url member and also extract a list of filenames 28 from the URI list. 29 (WebCore::DataObjectGtk::setURL): Updated to reflect changes to m_uriList. 30 (WebCore::DataObjectGtk::clear): Updated to reflect changes to m_uriList and 31 also leave a comment explaining why we do not clear filenames here. 32 * platform/gtk/DataObjectGtk.h: 33 (WebCore::DataObjectGtk::url): This implementation is now a simple getter. 34 (WebCore::DataObjectGtk::uriList): Ditto. 35 (WebCore::DataObjectGtk::filenames): Added. 36 (WebCore::DataObjectGtk::hasURL): Now a simple check. 37 (WebCore::DataObjectGtk::hasFilenames): Added. 38 (WebCore::DataObjectGtk::clearURIList): Simple setter. 39 (WebCore::DataObjectGtk::clearURL): Ditto. 40 * platform/gtk/DragDataGtk.cpp: 41 (WebCore::DragData::containsFiles): Updated to access DataObjectGtk::hasFilenames(). 42 (WebCore::DragData::asFilenames): Updated to access DataObjectGtk::filenames(). 43 * platform/gtk/PasteboardHelper.cpp: 44 (WebCore::PasteboardHelper::getClipboardContents): Use the uriList as a string now. 45 (WebCore::PasteboardHelper::fillSelectionData): Ditto. 46 (WebCore::PasteboardHelper::fillDataObjectFromDropData): Ditto. 47 1 48 2010-10-11 James Robinson <jamesr@chromium.org> 2 49 -
trunk/WebCore/platform/gtk/ClipboardGtk.cpp
r67973 r69530 140 140 } 141 141 142 static String joinURIList(Vector<KURL> uriList)143 {144 if (uriList.isEmpty())145 return String();146 147 String joined(uriList[0].string());148 for (size_t i = 1; i < uriList.size(); i++) {149 joined.append("\r\n");150 joined.append(uriList[i].string());151 }152 153 return joined;154 }155 156 142 String ClipboardGtk::getData(const String& typeString, bool& success) const 157 143 { 158 success = false; // Pessimism. 144 success = true; // According to http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html 145 // "The getData(format) method must return the data that is associated with the type format converted 146 // to ASCII lowercase, if any, and must return the empty string otherwise." Since success == false 147 // results in an 'undefined' return value, we always want to return success == true. This parameter 148 // should eventually be removed. 159 149 if (policy() != ClipboardReadable || !m_dataObject) 160 150 return String(); … … 164 154 165 155 ClipboardDataType type = dataObjectTypeFromHTMLClipboardType(typeString); 166 if (type == ClipboardDataTypeURIList) { 167 if (!m_dataObject->hasURIList()) 168 return String(); 169 success = true; 170 return joinURIList(m_dataObject->uriList()); 171 } 172 173 if (type == ClipboardDataTypeURL) { 174 if (!m_dataObject->hasURL()) 175 return String(); 176 success = true; 156 if (type == ClipboardDataTypeURIList) 157 return m_dataObject->uriList(); 158 if (type == ClipboardDataTypeURL) 177 159 return m_dataObject->url(); 178 } 179 180 if (type == ClipboardDataTypeMarkup) { 181 if (!m_dataObject->hasMarkup()) 182 return String(); 183 success = true; 160 if (type == ClipboardDataTypeMarkup) 184 161 return m_dataObject->markup(); 185 } 186 187 if (type == ClipboardDataTypeText) { 188 if (!m_dataObject->hasText()) 189 return String(); 190 success = true; 162 if (type == ClipboardDataTypeText) 191 163 return m_dataObject->text(); 192 }193 164 194 165 return String(); … … 203 174 ClipboardDataType type = dataObjectTypeFromHTMLClipboardType(typeString); 204 175 if (type == ClipboardDataTypeURIList || type == ClipboardDataTypeURL) { 205 Vector<KURL> uriList; 206 gchar** uris = g_uri_list_extract_uris(data.utf8().data()); 207 if (uris) { 208 gchar** currentURI = uris; 209 while (*currentURI) { 210 uriList.append(KURL(KURL(), *currentURI)); 211 currentURI++; 212 } 213 g_strfreev(uris); 214 m_dataObject->setURIList(uriList); 215 success = true; 216 } 176 m_dataObject->setURIList(data); 177 success = true; 217 178 } else if (type == ClipboardDataTypeMarkup) { 218 179 m_dataObject->setMarkup(data); … … 249 210 types.add("text/uri-list"); 250 211 types.add("URL"); 212 } 213 214 if (m_dataObject->hasFilenames()) 251 215 types.add("Files"); 252 }253 216 254 217 return types; … … 264 227 265 228 RefPtr<FileList> fileList = FileList::create(); 266 Vector<String> fileVector(m_dataObject->files()); 267 268 for (size_t i = 0; i < fileVector.size(); i++) 269 fileList->append(File::create(fileVector[i])); 270 229 const Vector<String>& filenames = m_dataObject->filenames(); 230 for (size_t i = 0; i < filenames.size(); i++) 231 fileList->append(File::create(filenames[i])); 271 232 return fileList.release(); 272 233 } -
trunk/WebCore/platform/gtk/DataObjectGtk.cpp
r61281 r69530 60 60 } 61 61 62 void DataObjectGtk::setURIList(const String& uriListString) 63 { 64 m_uriList = uriListString; 65 66 // This code is originally from: platform/chromium/ChromiumDataObject.cpp. 67 // FIXME: We should make this code cross-platform eventually. 68 69 // Line separator is \r\n per RFC 2483 - however, for compatibility 70 // reasons we also allow just \n here. 71 Vector<String> uriList; 72 uriListString.split('\n', uriList); 73 74 // Process the input and copy the first valid URL into the url member. 75 // In case no URLs can be found, subsequent calls to getData("URL") 76 // will get an empty string. This is in line with the HTML5 spec (see 77 // "The DragEvent and DataTransfer interfaces"). Also extract all filenames 78 // from the URI list. 79 bool setURL = false; 80 for (size_t i = 0; i < uriList.size(); ++i) { 81 String& line = uriList[i]; 82 line = line.stripWhiteSpace(); 83 if (line.isEmpty()) 84 continue; 85 if (line[0] == '#') 86 continue; 87 88 KURL url = KURL(KURL(), line); 89 if (url.isValid()) { 90 if (!setURL) { 91 m_url = url; 92 setURL = true; 93 } 94 95 GOwnPtr<GError> error; 96 GOwnPtr<gchar> filename(g_filename_from_uri(line.utf8().data(), 0, &error.outPtr())); 97 if (!error && filename) 98 m_filenames.append(String::fromUTF8(filename.get())); 99 } 100 } 101 } 102 62 103 void DataObjectGtk::setURL(const KURL& url, const String& label) 63 104 { 105 m_url = url; 106 m_uriList = url; 64 107 setText(url.string()); 65 108 … … 76 119 append(markup, "</a>"); 77 120 setMarkup(String::adopt(markup)); 78 79 Vector<KURL> uriList;80 uriList.append(url);81 setURIList(uriList);82 121 } 83 122 … … 94 133 } 95 134 96 Vector<String> DataObjectGtk::files()97 {98 Vector<KURL> uris(uriList());99 Vector<String> files;100 101 for (size_t i = 0; i < uris.size(); i++) {102 KURL& uri = uris[0];103 if (!uri.isValid() || !uri.isLocalFile())104 continue;105 106 files.append(uri.string());107 }108 109 return files;110 }111 112 String DataObjectGtk::url()113 {114 Vector<KURL> uris(uriList());115 for (size_t i = 0; i < uris.size(); i++) {116 KURL& uri = uris[0];117 if (uri.isValid())118 return uri;119 }120 121 return String();122 }123 124 135 String DataObjectGtk::urlLabel() 125 136 { … … 133 144 } 134 145 135 bool DataObjectGtk::hasURL()136 {137 return !url().isEmpty();138 }139 140 146 void DataObjectGtk::clear() 141 147 { 142 148 m_text = ""; 143 149 m_markup = ""; 144 m_uriList.clear(); 150 m_uriList = ""; 151 m_url = KURL(); 145 152 m_image = 0; 146 153 m_range = 0; 154 155 // We do not clear filenames. According to the spec: "The clearData() method 156 // does not affect whether any files were included in the drag, so the types 157 // attribute's list might still not be empty after calling clearData() (it would 158 // still contain the "Files" string if any files were included in the drag)." 147 159 } 148 160 -
trunk/WebCore/platform/gtk/DataObjectGtk.h
r66531 r69530 37 37 } 38 38 39 Vector<KURL> uriList() { return m_uriList; } 39 const KURL& url() { return m_url; } 40 const String& uriList() { return m_uriList; } 41 const Vector<String>& filenames() { return m_filenames; } 40 42 GdkPixbuf* image() { return m_image.get(); } 41 43 void setRange(PassRefPtr<Range> newRange) { m_range = newRange; } 42 void setURIList(const Vector<KURL>& newURIList) { m_uriList = newURIList; }43 44 void setImage(GdkPixbuf* newImage) { m_image = newImage; } 44 45 void setDragContext(GdkDragContext* newDragContext) { m_dragContext = newDragContext; } … … 47 48 bool hasMarkup() { return m_range || !m_markup.isEmpty(); } 48 49 bool hasURIList() { return !m_uriList.isEmpty(); } 50 bool hasURL() { return !m_url.isEmpty() && m_url.isValid(); } 51 bool hasFilenames() { return !m_filenames.isEmpty(); } 49 52 bool hasImage() { return m_image; } 50 void clearURIList() { m_uriList.clear(); } 53 void clearURIList() { m_uriList = ""; } 54 void clearURL() { m_url = KURL(); } 51 55 void clearImage() { m_image = 0; } 52 56 GdkDragContext* dragContext() { return m_dragContext.get(); } … … 54 58 String text(); 55 59 String markup(); 56 Vector<String> files(); 57 void setText(const String& newText); 58 void setMarkup(const String& newMarkup); 59 bool hasURL(); 60 String url(); 60 void setText(const String&); 61 void setMarkup(const String&); 62 void setURIList(const String&); 61 63 String urlLabel(); 62 64 void clear(); … … 69 71 String m_text; 70 72 String m_markup; 71 Vector<KURL> m_uriList; 73 KURL m_url; 74 String m_uriList; 75 Vector<String> m_filenames; 72 76 PlatformRefPtr<GdkPixbuf> m_image; 73 77 PlatformRefPtr<GdkDragContext> m_dragContext; -
trunk/WebCore/platform/gtk/DragDataGtk.cpp
r64152 r69530 38 38 bool DragData::containsFiles() const 39 39 { 40 return !m_platformDragData->files().isEmpty();40 return m_platformDragData->hasFilenames(); 41 41 } 42 42 43 43 void DragData::asFilenames(Vector<String>& result) const 44 44 { 45 Vector<String> files(m_platformDragData->files()); 46 for (size_t i = 0; i < files.size(); i++) 47 result.append(files[i]); 45 result = m_platformDragData->filenames(); 48 46 } 49 47 -
trunk/WebCore/platform/gtk/PasteboardHelper.cpp
r66024 r69530 93 93 } 94 94 95 static Vector<KURL> urisToKURLVector(gchar** uris)96 {97 ASSERT(uris);98 99 Vector<KURL> uriList;100 for (int i = 0; *(uris + i); i++)101 uriList.append(KURL(KURL(), *(uris + i)));102 103 return uriList;104 }105 106 95 static String selectionDataToUTF8String(GtkSelectionData* data) 107 96 { … … 131 120 if (gtk_clipboard_wait_is_target_available(clipboard, uriListAtom)) { 132 121 if (GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard, uriListAtom)) { 133 gchar** uris = gtk_selection_data_get_uris(data); 134 if (uris) { 135 dataObject->setURIList(urisToKURLVector(uris)); 136 g_strfreev(uris); 137 } 122 dataObject->setURIList(selectionDataToUTF8String(data)); 138 123 gtk_selection_data_free(data); 139 124 } … … 152 137 153 138 } else if (info == getIdForTargetType(TargetTypeURIList)) { 154 Vector<KURL> uriList(dataObject->uriList()); 155 gchar** uris = g_new0(gchar*, uriList.size() + 1); 156 for (size_t i = 0; i < uriList.size(); i++) 157 uris[i] = g_strdup(uriList[i].string().utf8().data()); 158 159 gtk_selection_data_set_uris(selectionData, uris); 160 g_strfreev(uris); 139 CString uriList = dataObject->uriList().utf8(); 140 gtk_selection_data_set(selectionData, uriListAtom, 8, 141 reinterpret_cast<const guchar*>(uriList.data()), uriList.length() + 1); 161 142 162 143 } else if (info == getIdForTargetType(TargetTypeNetscapeURL) && dataObject->hasURL()) { … … 210 191 dataObject->setMarkup(selectionDataToUTF8String(data)); 211 192 else if (target == uriListAtom) { 212 gchar** uris = gtk_selection_data_get_uris(data); 213 if (!uris) 214 return; 215 216 Vector<KURL> uriList(urisToKURLVector(uris)); 217 dataObject->setURIList(uriList); 218 g_strfreev(uris); 193 dataObject->setURIList(selectionDataToUTF8String(data)); 219 194 } else if (target == netscapeURLAtom) { 220 195 String urlWithLabel(selectionDataToUTF8String(data)); 221 222 196 Vector<String> pieces; 223 197 urlWithLabel.split("\n", pieces); … … 225 199 // Give preference to text/uri-list here, as it can hold more 226 200 // than one URI but still take the label if there is one. 227 if (!dataObject->hasURL()) { 228 Vector<KURL> uriList; 229 uriList.append(KURL(KURL(), pieces[0])); 230 dataObject->setURIList(uriList); 231 } 232 201 if (!dataObject->hasURIList()) 202 dataObject->setURIList(pieces[0]); 233 203 if (pieces.size() > 1) 234 204 dataObject->setText(pieces[1]);
Note: See TracChangeset
for help on using the changeset viewer.