Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1228)

Unified Diff: third_party/WebKit/Source/core/clipboard/DataTransfer.cpp

Issue 2575303002: Fix webkitdropzone to accept file drops on non-file: page. (Closed)
Patch Set: jsbell feedback Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/dnd/resources/dragged-file.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/clipboard/DataTransfer.cpp
diff --git a/third_party/WebKit/Source/core/clipboard/DataTransfer.cpp b/third_party/WebKit/Source/core/clipboard/DataTransfer.cpp
index 4a4f2ff9422e0e064feada3c0874822f6cdf28a4..a4305db054aef75522ab92ba24195094d6241825 100644
--- a/third_party/WebKit/Source/core/clipboard/DataTransfer.cpp
+++ b/third_party/WebKit/Source/core/clipboard/DataTransfer.cpp
@@ -127,11 +127,13 @@ void DataTransfer::setDropEffect(const String& effect) {
effect != "move")
return;
- // FIXME: The spec actually allows this in all circumstances, even though
- // there's no point in setting the drop effect when this condition is not
- // true.
- if (canReadTypes())
- m_dropEffect = effect;
+ // The specification states that dropEffect can be changed at all times, even
+ // if the DataTransfer instance is protected or neutered.
+ //
+ // Allowing these changes seems inconsequential, but findDropZone() in
+ // EventHandler.cpp relies on being able to call setDropEffect during
+ // dragenter, when the DataTransfer policy is DataTransferTypesReadable.
+ m_dropEffect = effect;
}
void DataTransfer::setEffectAllowed(const String& effect) {
@@ -464,13 +466,12 @@ bool DataTransfer::hasFileOfType(const String& type) const {
if (!canReadTypes())
return false;
- FileList* fileList = files();
- if (fileList->isEmpty())
- return false;
-
- for (unsigned f = 0; f < fileList->length(); f++) {
- if (equalIgnoringCase(fileList->item(f)->type(), type))
- return true;
+ for (size_t i = 0; i < m_dataObject->length(); ++i) {
+ if (m_dataObject->item(i)->kind() == DataObjectItem::FileKind) {
+ Blob* blob = m_dataObject->item(i)->getAsFile();
+ if (blob && blob->isFile() && equalIgnoringCase(blob->type(), type))
+ return true;
+ }
}
return false;
}
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/dnd/resources/dragged-file.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698