| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008, 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2008, 2009, 2012 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 if (index >= length()) | 83 if (index >= length()) |
| 84 return; | 84 return; |
| 85 m_itemList.remove(index); | 85 m_itemList.remove(index); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void ChromiumDataObject::clearAll() | 88 void ChromiumDataObject::clearAll() |
| 89 { | 89 { |
| 90 m_itemList.clear(); | 90 m_itemList.clear(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void ChromiumDataObject::add(const String& data, const String& type, ExceptionSt
ate& es) | 93 PassRefPtr<ChromiumDataObjectItem> ChromiumDataObject::add(const String& data, c
onst String& type, ExceptionState& es) |
| 94 { | 94 { |
| 95 if (!internalAddStringItem(ChromiumDataObjectItem::createFromString(type, da
ta))) | 95 RefPtr<ChromiumDataObjectItem> item = ChromiumDataObjectItem::createFromStri
ng(type, data); |
| 96 if (!internalAddStringItem(item)) { |
| 96 es.throwDOMException(NotSupportedError); | 97 es.throwDOMException(NotSupportedError); |
| 98 return 0; |
| 99 } |
| 100 return item; |
| 97 } | 101 } |
| 98 | 102 |
| 99 void ChromiumDataObject::add(PassRefPtr<File> file, ScriptExecutionContext* cont
ext) | 103 PassRefPtr<ChromiumDataObjectItem> ChromiumDataObject::add(PassRefPtr<File> file
, ScriptExecutionContext* context) |
| 100 { | 104 { |
| 101 if (!file) | 105 if (!file) |
| 102 return; | 106 return 0; |
| 103 | 107 |
| 104 m_itemList.append(ChromiumDataObjectItem::createFromFile(file)); | 108 RefPtr<ChromiumDataObjectItem> item = ChromiumDataObjectItem::createFromFile
(file); |
| 109 m_itemList.append(item); |
| 110 return item; |
| 105 } | 111 } |
| 106 | 112 |
| 107 void ChromiumDataObject::clearData(const String& type) | 113 void ChromiumDataObject::clearData(const String& type) |
| 108 { | 114 { |
| 109 for (size_t i = 0; i < m_itemList.size(); ++i) { | 115 for (size_t i = 0; i < m_itemList.size(); ++i) { |
| 110 if (m_itemList[i]->kind() == DataTransferItem::kindString && m_itemList[
i]->type() == type) { | 116 if (m_itemList[i]->kind() == DataTransferItem::kindString && m_itemList[
i]->type() == type) { |
| 111 // Per the spec, type must be unique among all items of kind 'string
'. | 117 // Per the spec, type must be unique among all items of kind 'string
'. |
| 112 m_itemList.remove(i); | 118 m_itemList.remove(i); |
| 113 return; | 119 return; |
| 114 } | 120 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 return true; | 255 return true; |
| 250 } | 256 } |
| 251 | 257 |
| 252 void ChromiumDataObject::internalAddFileItem(PassRefPtr<ChromiumDataObjectItem>
item) | 258 void ChromiumDataObject::internalAddFileItem(PassRefPtr<ChromiumDataObjectItem>
item) |
| 253 { | 259 { |
| 254 ASSERT(item->kind() == DataTransferItem::kindFile); | 260 ASSERT(item->kind() == DataTransferItem::kindFile); |
| 255 m_itemList.append(item); | 261 m_itemList.append(item); |
| 256 } | 262 } |
| 257 | 263 |
| 258 } // namespace WebCore | 264 } // namespace WebCore |
| OLD | NEW |