Changeset 109176 in webkit
- Timestamp:
- Feb 28, 2012 5:31:55 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r109170 r109176 1 2012-02-28 Daniel Cheng <dcheng@chromium.org> 2 3 Clipboard::getData should return an empty string instead of undefined 4 https://bugs.webkit.org/show_bug.cgi?id=79712 5 6 Reviewed by Tony Chang. 7 8 * fast/events/dataTransfer-getData-returns-empty-string-expected.txt: Added. 9 * fast/events/dataTransfer-getData-returns-empty-string.html: Added. 10 * http/tests/local/drag-over-remote-content-expected.txt: 11 * http/tests/security/drag-over-remote-content-iframe-expected.txt: 12 * http/tests/security/drag-over-remote-content-iframe.html: 13 1 14 2012-02-28 Adam Klein <adamk@chromium.org> 2 15 -
trunk/LayoutTests/http/tests/local/drag-over-remote-content-expected.txt
r44027 r109176 8 8 To test, drag Abe's image into this light blue div. 9 9 10 PASS: ondragover saw a URL of ' undefined'10 PASS: ondragover saw a URL of '' 11 11 -
trunk/LayoutTests/http/tests/security/drag-over-remote-content-iframe-expected.txt
r44027 r109176 5 5 To test, drag Abe's image into this light blue div. 6 6 7 PASS: ondragover saw a URL of ' undefined'7 PASS: ondragover saw a URL of '' 8 8 -
trunk/LayoutTests/http/tests/security/drag-over-remote-content-iframe.html
r44027 r109176 18 18 dragTarget.ondragover = function() { 19 19 var url = event.dataTransfer.getData('URL'); 20 var result = url === undefined21 ? "PASS: ondragover saw a URL of ' undefined'"20 var result = url === '' 21 ? "PASS: ondragover saw a URL of ''" 22 22 : "FAIL: ondragover saw a URL of '" + url + "'"; 23 23 log(result); -
trunk/Source/WebCore/ChangeLog
r109175 r109176 1 2012-02-28 Daniel Cheng <dcheng@chromium.org> 2 3 Clipboard::getData should return an empty string instead of undefined 4 https://bugs.webkit.org/show_bug.cgi?id=79712 5 6 Reviewed by Tony Chang. 7 8 Per the spec, an empty string should be returned when there is no data for the given typestring. 9 10 Test: fast/events/dataTransfer-getData-returns-empty-string.html 11 12 * bindings/js/JSClipboardCustom.cpp: 13 * bindings/v8/custom/V8ClipboardCustom.cpp: 14 * dom/Clipboard.h: 15 (Clipboard): 16 * dom/Clipboard.idl: 17 * platform/blackberry/ClipboardBlackBerry.cpp: 18 (WebCore::ClipboardBlackBerry::getData): 19 * platform/blackberry/ClipboardBlackBerry.h: 20 (ClipboardBlackBerry): 21 * platform/chromium/ClipboardChromium.cpp: 22 (WebCore::ClipboardChromium::getData): 23 * platform/chromium/ClipboardChromium.h: 24 (ClipboardChromium): 25 * platform/efl/ClipboardEfl.cpp: 26 (WebCore::ClipboardEfl::getData): 27 * platform/efl/ClipboardEfl.h: 28 (ClipboardEfl): 29 * platform/gtk/ClipboardGtk.cpp: 30 (WebCore::ClipboardGtk::getData): 31 * platform/gtk/ClipboardGtk.h: 32 (ClipboardGtk): 33 * platform/mac/ClipboardMac.h: 34 (ClipboardMac): 35 * platform/mac/ClipboardMac.mm: 36 (WebCore::ClipboardMac::getData): 37 * platform/qt/ClipboardQt.cpp: 38 (WebCore::ClipboardQt::getData): 39 * platform/qt/ClipboardQt.h: 40 (ClipboardQt): 41 * platform/win/ClipboardUtilitiesWin.cpp: 42 (WebCore::getFullCFHTML): 43 (WebCore::getURL): 44 (WebCore::getPlainText): 45 (WebCore::getTextHTML): 46 (WebCore::getCFHTML): 47 (WebCore::fragmentFromHTML): 48 * platform/win/ClipboardUtilitiesWin.h: 49 (WebCore): 50 * platform/win/ClipboardWin.cpp: 51 (WebCore::ClipboardWin::getData): 52 * platform/win/ClipboardWin.h: 53 (ClipboardWin): 54 * platform/wx/ClipboardWx.cpp: 55 (WebCore::ClipboardWx::getData): 56 * platform/wx/ClipboardWx.h: 57 (ClipboardWx): 58 1 59 2012-02-28 Kenichi Ishibashi <bashi@chromium.org> 2 60 -
trunk/Source/WebCore/bindings/js/JSClipboardCustom.cpp
r107894 r109176 67 67 } 68 68 69 JSValue JSClipboard::getData(ExecState* exec)70 {71 // FIXME: It does not match the rest of the JS bindings to throw on invalid number of arguments.72 if (exec->argumentCount() != 1)73 return throwError(exec, createSyntaxError(exec, "getData: Invalid number of arguments"));74 75 Clipboard* clipboard = impl();76 77 bool success;78 String result = clipboard->getData(ustringToString(exec->argument(0).toString(exec)->value(exec)), success);79 if (!success)80 return jsUndefined();81 82 return jsString(exec, result);83 }84 85 69 JSValue JSClipboard::setDragImage(ExecState* exec) 86 70 { -
trunk/Source/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp
r107894 r109176 63 63 } 64 64 65 v8::Handle<v8::Value> V8Clipboard::getDataCallback(const v8::Arguments& args)66 {67 INC_STATS("DOM.Clipboard.getData()");68 Clipboard* clipboard = V8Clipboard::toNative(args.Holder());69 70 if (args.Length() != 1)71 return throwError("getData: Invalid number of arguments", V8Proxy::SyntaxError);72 73 bool success;74 String result = clipboard->getData(toWebCoreString(args[0]), success);75 if (success)76 return v8String(result);77 78 return v8::Undefined();79 }80 81 65 v8::Handle<v8::Value> V8Clipboard::setDragImageCallback(const v8::Arguments& args) 82 66 { -
trunk/Source/WebCore/dom/Clipboard.h
r107894 r109176 64 64 virtual void clearData(const String& type) = 0; 65 65 virtual void clearAllData() = 0; 66 virtual String getData(const String& type , bool& success) const = 0;66 virtual String getData(const String& type) const = 0; 67 67 virtual bool setData(const String& type, const String& data) = 0; 68 68 -
trunk/Source/WebCore/dom/Clipboard.idl
r107894 r109176 37 37 [Custom] void clearData(in [Optional] DOMString type) 38 38 raises(DOMException); 39 [Custom] void getData(in DOMString type) 40 raises(DOMException); 39 DOMString getData(in DOMString type); 41 40 boolean setData(in DOMString type, in DOMString data); 42 41 [Custom] void setDragImage(in HTMLImageElement image, in long x, in long y) -
trunk/Source/WebCore/platform/blackberry/ClipboardBlackBerry.cpp
r107894 r109176 57 57 } 58 58 59 String ClipboardBlackBerry::getData(const String& type , bool& success) const59 String ClipboardBlackBerry::getData(const String& type) const 60 60 { 61 success = true;62 61 return String::fromUTF8(BlackBerry::Platform::Clipboard::readClipboardByType(type.utf8().data()).c_str()); 63 62 } -
trunk/Source/WebCore/platform/blackberry/ClipboardBlackBerry.h
r107894 r109176 33 33 void clearData(const String& type); 34 34 void clearAllData(); 35 String getData(const String& type , bool& success) const;35 String getData(const String& type) const; 36 36 bool setData(const String& type, const String& data); 37 37 -
trunk/Source/WebCore/platform/chromium/ClipboardChromium.cpp
r107894 r109176 264 264 } 265 265 266 String ClipboardChromium::getData(const String& type , bool& success) const267 { 268 success = false;266 String ClipboardChromium::getData(const String& type) const 267 { 268 bool ignoredSuccess = false; 269 269 if (policy() != ClipboardReadable || !m_dataObject) 270 270 return String(); … … 273 273 return String(); 274 274 275 return m_dataObject->getData(normalizeType(type), success);275 return m_dataObject->getData(normalizeType(type), ignoredSuccess); 276 276 } 277 277 -
trunk/Source/WebCore/platform/chromium/ClipboardChromium.h
r107894 r109176 59 59 virtual void clearData(const String& type); 60 60 void clearAllData(); 61 String getData(const String& type , bool& success) const;61 String getData(const String& type) const; 62 62 bool setData(const String& type, const String& data); 63 63 bool platformClipboardChanged() const; -
trunk/Source/WebCore/platform/efl/ClipboardEfl.cpp
r107894 r109176 66 66 } 67 67 68 String ClipboardEfl::getData(const String& , bool &success) const68 String ClipboardEfl::getData(const String&) const 69 69 { 70 70 notImplemented(); 71 success = false;72 71 return String(); 73 72 } -
trunk/Source/WebCore/platform/efl/ClipboardEfl.h
r107894 r109176 37 37 void clearData(const String&); 38 38 void clearAllData(); 39 String getData(const String& , bool&) const;39 String getData(const String&) const; 40 40 bool setData(const String&, const String&); 41 41 -
trunk/Source/WebCore/platform/gtk/ClipboardGtk.cpp
r107894 r109176 144 144 } 145 145 146 String ClipboardGtk::getData(const String& typeString, bool& success) const 147 { 148 success = true; // According to http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html 149 // "The getData(format) method must return the data that is associated with the type format converted 150 // to ASCII lowercase, if any, and must return the empty string otherwise." Since success == false 151 // results in an 'undefined' return value, we always want to return success == true. This parameter 152 // should eventually be removed. 146 String ClipboardGtk::getData(const String& typeString) const 147 { 153 148 if (policy() != ClipboardReadable || !m_dataObject) 154 149 return String(); -
trunk/Source/WebCore/platform/gtk/ClipboardGtk.h
r107894 r109176 55 55 void clearData(const String&); 56 56 void clearAllData(); 57 String getData(const String& , bool&) const;57 String getData(const String&) const; 58 58 bool setData(const String&, const String&); 59 59 -
trunk/Source/WebCore/platform/mac/ClipboardMac.h
r109147 r109176 50 50 void clearData(const String& type); 51 51 void clearAllData(); 52 String getData(const String& type , bool& success) const;52 String getData(const String& type) const; 53 53 bool setData(const String& type, const String& data); 54 54 -
trunk/Source/WebCore/platform/mac/ClipboardMac.mm
r108101 r109176 213 213 } 214 214 215 String ClipboardMac::getData(const String& type, bool& success) const 216 { 217 success = false; 215 String ClipboardMac::getData(const String& type) const 216 { 218 217 if (policy() != ClipboardReadable) 219 218 return String(); … … 237 236 // sure it doesn't change between our testing the change count and accessing the data. 238 237 if (!cocoaValue.isEmpty() && m_changeCount == platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName)) { 239 success = true;240 238 return cocoaValue; 241 239 } -
trunk/Source/WebCore/platform/qt/ClipboardQt.cpp
r107894 r109176 145 145 } 146 146 147 String ClipboardQt::getData(const String& type, bool& success) const 148 { 149 150 if (policy() != ClipboardReadable) { 151 success = false; 147 String ClipboardQt::getData(const String& type) const 148 { 149 150 if (policy() != ClipboardReadable) 152 151 return String(); 153 } 154 155 if (isHtmlMimeType(type) && m_readableData->hasHtml()) { 156 success = true; 152 153 if (isHtmlMimeType(type) && m_readableData->hasHtml()) 157 154 return m_readableData->html(); 158 } 159 160 if (isTextMimeType(type) && m_readableData->hasText()) { 161 success = true; 155 156 if (isTextMimeType(type) && m_readableData->hasText()) 162 157 return m_readableData->text(); 163 }164 158 165 159 ASSERT(m_readableData); 166 160 QByteArray rawData = m_readableData->data(type); 167 161 QString data = QTextCodec::codecForName("UTF-16")->toUnicode(rawData); 168 success = !data.isEmpty();169 162 return data; 170 163 } -
trunk/Source/WebCore/platform/qt/ClipboardQt.h
r107894 r109176 54 54 void clearData(const String& type); 55 55 void clearAllData(); 56 String getData(const String& type , bool& success) const;56 String getData(const String& type) const; 57 57 bool setData(const String& type, const String& data); 58 58 -
trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp
r89717 r109176 209 209 } 210 210 211 static String getFullCFHTML(IDataObject* data , bool& success)211 static String getFullCFHTML(IDataObject* data) 212 212 { 213 213 STGMEDIUM store; … … 219 219 GlobalUnlock(store.hGlobal); 220 220 ReleaseStgMedium(&store); 221 success = true;222 221 return cfhtml; 223 222 } 224 success = false;225 223 return String(); 226 224 } … … 448 446 } 449 447 450 String getURL(IDataObject* dataObject, DragData::FilenameConversionPolicy filenamePolicy, bool& success,String* title)448 String getURL(IDataObject* dataObject, DragData::FilenameConversionPolicy filenamePolicy, String* title) 451 449 { 452 450 STGMEDIUM store; 453 451 String url; 454 success = false;455 452 if (getWebLocData(dataObject, url, title)) 456 success = true; 457 else if (SUCCEEDED(dataObject->GetData(urlWFormat(), &store))) { 453 return url; 454 455 if (SUCCEEDED(dataObject->GetData(urlWFormat(), &store))) { 458 456 // URL using Unicode 459 457 UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal)); … … 461 459 GlobalUnlock(store.hGlobal); 462 460 ReleaseStgMedium(&store); 463 success = true;464 461 } else if (SUCCEEDED(dataObject->GetData(urlFormat(), &store))) { 465 462 // URL using ASCII … … 468 465 GlobalUnlock(store.hGlobal); 469 466 ReleaseStgMedium(&store); 470 success = true;471 467 } 472 468 #if USE(CF) … … 477 473 if (data && data[0] && (PathFileExists(data) || PathIsUNC(data))) { 478 474 RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)data, wcslen(data))); 479 if (urlFromPath(pathAsCFString.get(), url)) { 480 if (title) 481 *title = url; 482 success = true; 483 } 475 if (urlFromPath(pathAsCFString.get(), url) && title) 476 *title = url; 484 477 } 485 478 GlobalUnlock(store.hGlobal); … … 490 483 if (data && data[0] && (PathFileExistsA(data) || PathIsUNCA(data))) { 491 484 RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCString(kCFAllocatorDefault, data, kCFStringEncodingASCII)); 492 if (urlFromPath(pathAsCFString.get(), url)) { 493 if (title) 494 *title = url; 495 success = true; 496 } 485 if (urlFromPath(pathAsCFString.get(), url) && title) 486 *title = url; 497 487 } 498 488 GlobalUnlock(store.hGlobal); … … 531 521 } 532 522 533 String getPlainText(IDataObject* dataObject , bool& success)523 String getPlainText(IDataObject* dataObject) 534 524 { 535 525 STGMEDIUM store; 536 526 String text; 537 success = false;538 527 if (SUCCEEDED(dataObject->GetData(plainTextWFormat(), &store))) { 539 528 // Unicode text … … 542 531 GlobalUnlock(store.hGlobal); 543 532 ReleaseStgMedium(&store); 544 success = true;545 533 } else if (SUCCEEDED(dataObject->GetData(plainTextFormat(), &store))) { 546 534 // ASCII text … … 549 537 GlobalUnlock(store.hGlobal); 550 538 ReleaseStgMedium(&store); 551 success = true;552 539 } else { 553 540 // FIXME: Originally, we called getURL() here because dragging and dropping files doesn't 554 541 // populate the drag with text data. Per https://bugs.webkit.org/show_bug.cgi?id=38826, this 555 542 // is undesirable, so maybe this line can be removed. 556 text = getURL(dataObject, DragData::DoNotConvertFilenames, success); 557 success = true; 543 text = getURL(dataObject, DragData::DoNotConvertFilenames); 558 544 } 559 545 return text; … … 571 557 } 572 558 573 String getTextHTML(IDataObject* data , bool& success)559 String getTextHTML(IDataObject* data) 574 560 { 575 561 STGMEDIUM store; 576 562 String html; 577 success = false;578 563 if (SUCCEEDED(data->GetData(texthtmlFormat(), &store))) { 579 564 UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal)); … … 581 566 GlobalUnlock(store.hGlobal); 582 567 ReleaseStgMedium(&store); 583 success = true;584 568 } 585 569 return html; … … 593 577 } 594 578 595 String getCFHTML(IDataObject* data , bool& success)596 { 597 String cfhtml = getFullCFHTML(data , success);598 if ( success)579 String getCFHTML(IDataObject* data) 580 { 581 String cfhtml = getFullCFHTML(data); 582 if (!cfhtml.isEmpty()) 599 583 return extractMarkupFromCFHTML(cfhtml); 600 584 return String(); … … 656 640 return 0; 657 641 658 bool success = false; 659 String cfhtml = getFullCFHTML(data, success); 660 if (success) { 642 String cfhtml = getFullCFHTML(data); 643 if (!cfhtml.isEmpty()) { 661 644 if (RefPtr<DocumentFragment> fragment = fragmentFromCFHTML(doc, cfhtml)) 662 645 return fragment.release(); 663 646 } 664 647 665 String html = getTextHTML(data , success);648 String html = getTextHTML(data); 666 649 String srcURL; 667 if ( success)650 if (!html.isEmpty()) 668 651 return createFragmentFromMarkup(doc, html, srcURL, FragmentScriptingNotAllowed); 669 652 -
trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.h
r89707 r109176 68 68 PassRefPtr<DocumentFragment> fragmentFromCFHTML(Document*, const String& cfhtml); 69 69 70 String getURL(IDataObject*, DragData::FilenameConversionPolicy, bool& success,String* title = 0);70 String getURL(IDataObject*, DragData::FilenameConversionPolicy, String* title = 0); 71 71 String getURL(const DragDataMap*, DragData::FilenameConversionPolicy, String* title = 0); 72 String getPlainText(IDataObject* , bool& success);72 String getPlainText(IDataObject*); 73 73 String getPlainText(const DragDataMap*); 74 String getTextHTML(IDataObject* , bool& success);74 String getTextHTML(IDataObject*); 75 75 String getTextHTML(const DragDataMap*); 76 String getCFHTML(IDataObject* , bool& success);76 String getCFHTML(IDataObject*); 77 77 String getCFHTML(const DragDataMap*); 78 78 -
trunk/Source/WebCore/platform/win/ClipboardWin.cpp
r107894 r109176 437 437 } 438 438 439 String ClipboardWin::getData(const String& type , bool& success) const439 String ClipboardWin::getData(const String& type) const 440 440 { 441 success = false;442 441 if (policy() != ClipboardReadable || (!m_dataObject && m_dragDataMap.isEmpty())) 443 442 return ""; … … 445 444 ClipboardDataType dataType = clipboardTypeFromMIMEType(type); 446 445 if (dataType == ClipboardDataTypeText) 447 return m_dataObject ? getPlainText(m_dataObject.get() , success) : getPlainText(&m_dragDataMap);446 return m_dataObject ? getPlainText(m_dataObject.get()) : getPlainText(&m_dragDataMap); 448 447 if (dataType == ClipboardDataTypeURL) 449 return m_dataObject ? getURL(m_dataObject.get(), DragData::DoNotConvertFilenames , success) : getURL(&m_dragDataMap, DragData::DoNotConvertFilenames);448 return m_dataObject ? getURL(m_dataObject.get(), DragData::DoNotConvertFilenames) : getURL(&m_dragDataMap, DragData::DoNotConvertFilenames); 450 449 else if (dataType == ClipboardDataTypeTextHTML) { 451 String data = m_dataObject ? getTextHTML(m_dataObject.get() , success) : getTextHTML(&m_dragDataMap);452 if ( success)450 String data = m_dataObject ? getTextHTML(m_dataObject.get()) : getTextHTML(&m_dragDataMap); 451 if (!data.isEmpty()) 453 452 return data; 454 return m_dataObject ? getCFHTML(m_dataObject.get() , success) : getCFHTML(&m_dragDataMap);453 return m_dataObject ? getCFHTML(m_dataObject.get()) : getCFHTML(&m_dragDataMap); 455 454 } 456 455 -
trunk/Source/WebCore/platform/win/ClipboardWin.h
r107894 r109176 61 61 void clearData(const String& type); 62 62 void clearAllData(); 63 String getData(const String& type , bool& success) const;63 String getData(const String& type) const; 64 64 bool setData(const String& type, const String& data); 65 65 -
trunk/Source/WebCore/platform/win/DragDataWin.cpp
r99108 r109176 102 102 String DragData::asURL(Frame*, FilenameConversionPolicy filenamePolicy, String* title) const 103 103 { 104 bool success; 105 return (m_platformDragData) ? getURL(m_platformDragData, filenamePolicy, success, title) : getURL(&m_dragDataMap, filenamePolicy, title); 104 return (m_platformDragData) ? getURL(m_platformDragData, filenamePolicy, title) : getURL(&m_dragDataMap, filenamePolicy, title); 106 105 } 107 106 … … 156 155 String DragData::asPlainText(Frame*) const 157 156 { 158 bool success; 159 return (m_platformDragData) ? getPlainText(m_platformDragData, success) : getPlainText(&m_dragDataMap); 157 return (m_platformDragData) ? getPlainText(m_platformDragData) : getPlainText(&m_dragDataMap); 160 158 } 161 159 -
trunk/Source/WebCore/platform/wx/ClipboardWx.cpp
r107894 r109176 59 59 } 60 60 61 String ClipboardWx::getData(const String& type , bool& success) const61 String ClipboardWx::getData(const String& type) const 62 62 { 63 63 notImplemented(); -
trunk/Source/WebCore/platform/wx/ClipboardWx.h
r107894 r109176 43 43 void clearData(const String& type); 44 44 void clearAllData(); 45 String getData(const String& type , bool& success) const;45 String getData(const String& type) const; 46 46 bool setData(const String& type, const String& data); 47 47
Note: See TracChangeset
for help on using the changeset viewer.