OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 void DataTransfer::setDropEffect(const String& effect) { | 120 void DataTransfer::setDropEffect(const String& effect) { |
121 if (!isForDragAndDrop()) | 121 if (!isForDragAndDrop()) |
122 return; | 122 return; |
123 | 123 |
124 // The attribute must ignore any attempts to set it to a value other than | 124 // The attribute must ignore any attempts to set it to a value other than |
125 // none, copy, link, and move. | 125 // none, copy, link, and move. |
126 if (effect != "none" && effect != "copy" && effect != "link" && | 126 if (effect != "none" && effect != "copy" && effect != "link" && |
127 effect != "move") | 127 effect != "move") |
128 return; | 128 return; |
129 | 129 |
130 // FIXME: The spec actually allows this in all circumstances, even though | 130 // The specification states that dropEffect can be changed at all times, even |
131 // there's no point in setting the drop effect when this condition is not | 131 // if the DataTransfer instance is protected or neutered. |
132 // true. | 132 // |
133 if (canReadTypes()) | 133 // Allowing these changes seems inconsequential, but findDropZone() in |
134 m_dropEffect = effect; | 134 // EventHandler.cpp relies on being able to call setDropEffect during |
| 135 // dragenter, when the DataTransfer policy is DataTransferTypesReadable. |
| 136 m_dropEffect = effect; |
135 } | 137 } |
136 | 138 |
137 void DataTransfer::setEffectAllowed(const String& effect) { | 139 void DataTransfer::setEffectAllowed(const String& effect) { |
138 if (!isForDragAndDrop()) | 140 if (!isForDragAndDrop()) |
139 return; | 141 return; |
140 | 142 |
141 if (convertEffectAllowedToDragOperation(effect) == DragOperationPrivate) { | 143 if (convertEffectAllowedToDragOperation(effect) == DragOperationPrivate) { |
142 // This means that there was no conversion, and the effectAllowed that | 144 // This means that there was no conversion, and the effectAllowed that |
143 // we are passed isn't a valid effectAllowed, so we should ignore it, | 145 // we are passed isn't a valid effectAllowed, so we should ignore it, |
144 // and not set m_effectAllowed. | 146 // and not set m_effectAllowed. |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 | 459 |
458 m_dragImage = image; | 460 m_dragImage = image; |
459 m_dragLoc = loc; | 461 m_dragLoc = loc; |
460 m_dragImageElement = node; | 462 m_dragImageElement = node; |
461 } | 463 } |
462 | 464 |
463 bool DataTransfer::hasFileOfType(const String& type) const { | 465 bool DataTransfer::hasFileOfType(const String& type) const { |
464 if (!canReadTypes()) | 466 if (!canReadTypes()) |
465 return false; | 467 return false; |
466 | 468 |
467 FileList* fileList = files(); | 469 for (size_t i = 0; i < m_dataObject->length(); ++i) { |
468 if (fileList->isEmpty()) | 470 if (m_dataObject->item(i)->kind() == DataObjectItem::FileKind) { |
469 return false; | 471 Blob* blob = m_dataObject->item(i)->getAsFile(); |
470 | 472 if (blob && blob->isFile() && equalIgnoringCase(blob->type(), type)) |
471 for (unsigned f = 0; f < fileList->length(); f++) { | 473 return true; |
472 if (equalIgnoringCase(fileList->item(f)->type(), type)) | 474 } |
473 return true; | |
474 } | 475 } |
475 return false; | 476 return false; |
476 } | 477 } |
477 | 478 |
478 bool DataTransfer::hasStringOfType(const String& type) const { | 479 bool DataTransfer::hasStringOfType(const String& type) const { |
479 if (!canReadTypes()) | 480 if (!canReadTypes()) |
480 return false; | 481 return false; |
481 | 482 |
482 return types().contains(type); | 483 return types().contains(type); |
483 } | 484 } |
(...skipping 22 matching lines...) Expand all Loading... |
506 } | 507 } |
507 } | 508 } |
508 | 509 |
509 DEFINE_TRACE(DataTransfer) { | 510 DEFINE_TRACE(DataTransfer) { |
510 visitor->trace(m_dataObject); | 511 visitor->trace(m_dataObject); |
511 visitor->trace(m_dragImage); | 512 visitor->trace(m_dragImage); |
512 visitor->trace(m_dragImageElement); | 513 visitor->trace(m_dragImageElement); |
513 } | 514 } |
514 | 515 |
515 } // namespace blink | 516 } // namespace blink |
OLD | NEW |