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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 | 69 |
70 size_t DataObject::length() const | 70 size_t DataObject::length() const |
71 { | 71 { |
72 return m_itemList.size(); | 72 return m_itemList.size(); |
73 } | 73 } |
74 | 74 |
75 PassRefPtr<DataObjectItem> DataObject::item(unsigned long index) | 75 PassRefPtr<DataObjectItem> DataObject::item(unsigned long index) |
76 { | 76 { |
77 if (index >= length()) | 77 if (index >= length()) |
78 return 0; | 78 return nullptr; |
79 return m_itemList[index]; | 79 return m_itemList[index]; |
80 } | 80 } |
81 | 81 |
82 void DataObject::deleteItem(unsigned long index) | 82 void DataObject::deleteItem(unsigned long index) |
83 { | 83 { |
84 if (index >= length()) | 84 if (index >= length()) |
85 return; | 85 return; |
86 m_itemList.remove(index); | 86 m_itemList.remove(index); |
87 } | 87 } |
88 | 88 |
89 void DataObject::clearAll() | 89 void DataObject::clearAll() |
90 { | 90 { |
91 m_itemList.clear(); | 91 m_itemList.clear(); |
92 } | 92 } |
93 | 93 |
94 PassRefPtr<DataObjectItem> DataObject::add(const String& data, const String& typ
e) | 94 PassRefPtr<DataObjectItem> DataObject::add(const String& data, const String& typ
e) |
95 { | 95 { |
96 RefPtr<DataObjectItem> item = DataObjectItem::createFromString(type, data); | 96 RefPtr<DataObjectItem> item = DataObjectItem::createFromString(type, data); |
97 if (!internalAddStringItem(item)) | 97 if (!internalAddStringItem(item)) |
98 return 0; | 98 return nullptr; |
99 return item; | 99 return item; |
100 } | 100 } |
101 | 101 |
102 PassRefPtr<DataObjectItem> DataObject::add(PassRefPtr<File> file) | 102 PassRefPtr<DataObjectItem> DataObject::add(PassRefPtr<File> file) |
103 { | 103 { |
104 if (!file) | 104 if (!file) |
105 return 0; | 105 return nullptr; |
106 | 106 |
107 RefPtr<DataObjectItem> item = DataObjectItem::createFromFile(file); | 107 RefPtr<DataObjectItem> item = DataObjectItem::createFromFile(file); |
108 m_itemList.append(item); | 108 m_itemList.append(item); |
109 return item; | 109 return item; |
110 } | 110 } |
111 | 111 |
112 void DataObject::clearData(const String& type) | 112 void DataObject::clearData(const String& type) |
113 { | 113 { |
114 for (size_t i = 0; i < m_itemList.size(); ++i) { | 114 for (size_t i = 0; i < m_itemList.size(); ++i) { |
115 if (m_itemList[i]->kind() == DataObjectItem::StringKind && m_itemList[i]
->type() == type) { | 115 if (m_itemList[i]->kind() == DataObjectItem::StringKind && m_itemList[i]
->type() == type) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 , m_modifierKeyState(0) | 238 , m_modifierKeyState(0) |
239 { | 239 { |
240 } | 240 } |
241 | 241 |
242 PassRefPtr<DataObjectItem> DataObject::findStringItem(const String& type) const | 242 PassRefPtr<DataObjectItem> DataObject::findStringItem(const String& type) const |
243 { | 243 { |
244 for (size_t i = 0; i < m_itemList.size(); ++i) { | 244 for (size_t i = 0; i < m_itemList.size(); ++i) { |
245 if (m_itemList[i]->kind() == DataObjectItem::StringKind && m_itemList[i]
->type() == type) | 245 if (m_itemList[i]->kind() == DataObjectItem::StringKind && m_itemList[i]
->type() == type) |
246 return m_itemList[i]; | 246 return m_itemList[i]; |
247 } | 247 } |
248 return 0; | 248 return nullptr; |
249 } | 249 } |
250 | 250 |
251 bool DataObject::internalAddStringItem(PassRefPtr<DataObjectItem> item) | 251 bool DataObject::internalAddStringItem(PassRefPtr<DataObjectItem> item) |
252 { | 252 { |
253 ASSERT(item->kind() == DataObjectItem::StringKind); | 253 ASSERT(item->kind() == DataObjectItem::StringKind); |
254 for (size_t i = 0; i < m_itemList.size(); ++i) { | 254 for (size_t i = 0; i < m_itemList.size(); ++i) { |
255 if (m_itemList[i]->kind() == DataObjectItem::StringKind && m_itemList[i]
->type() == item->type()) | 255 if (m_itemList[i]->kind() == DataObjectItem::StringKind && m_itemList[i]
->type() == item->type()) |
256 return false; | 256 return false; |
257 } | 257 } |
258 | 258 |
259 m_itemList.append(item); | 259 m_itemList.append(item); |
260 return true; | 260 return true; |
261 } | 261 } |
262 | 262 |
263 void DataObject::internalAddFileItem(PassRefPtr<DataObjectItem> item) | 263 void DataObject::internalAddFileItem(PassRefPtr<DataObjectItem> item) |
264 { | 264 { |
265 ASSERT(item->kind() == DataObjectItem::FileKind); | 265 ASSERT(item->kind() == DataObjectItem::FileKind); |
266 m_itemList.append(item); | 266 m_itemList.append(item); |
267 } | 267 } |
268 | 268 |
269 } // namespace WebCore | 269 } // namespace WebCore |
OLD | NEW |