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

Side by Side Diff: third_party/WebKit/Source/core/clipboard/DataTransfer.cpp

Issue 2875013002: DataTransfer: Make |types| be a FrozenArray<DOMString>. (Closed)
Patch Set: Add new test, use CachedAttribute Created 3 years, 7 months 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 unified diff | Download patch
OLDNEW
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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 161 }
162 162
163 if (CanWriteData()) 163 if (CanWriteData())
164 effect_allowed_ = effect; 164 effect_allowed_ = effect;
165 } 165 }
166 166
167 void DataTransfer::clearData(const String& type) { 167 void DataTransfer::clearData(const String& type) {
168 if (!CanWriteData()) 168 if (!CanWriteData())
169 return; 169 return;
170 170
171 const size_t old_length = data_object_->length();
172
171 if (type.IsNull()) 173 if (type.IsNull())
172 data_object_->ClearAll(); 174 data_object_->ClearAll();
173 else 175 else
174 data_object_->ClearData(NormalizeType(type)); 176 data_object_->ClearData(NormalizeType(type));
177
178 if (old_length != data_object_->length())
179 data_store_item_list_changed_ = true;
175 } 180 }
176 181
177 String DataTransfer::getData(const String& type) const { 182 String DataTransfer::getData(const String& type) const {
178 if (!CanReadData()) 183 if (!CanReadData())
179 return String(); 184 return String();
180 185
181 bool convert_to_url = false; 186 bool convert_to_url = false;
182 String data = data_object_->GetData(NormalizeType(type, &convert_to_url)); 187 String data = data_object_->GetData(NormalizeType(type, &convert_to_url));
183 if (!convert_to_url) 188 if (!convert_to_url)
184 return data; 189 return data;
185 return ConvertURIListToURL(data); 190 return ConvertURIListToURL(data);
186 } 191 }
187 192
188 void DataTransfer::setData(const String& type, const String& data) { 193 void DataTransfer::setData(const String& type, const String& data) {
189 if (!CanWriteData()) 194 if (!CanWriteData())
190 return; 195 return;
191 196
192 data_object_->SetData(NormalizeType(type), data); 197 data_object_->SetData(NormalizeType(type), data);
198 data_store_item_list_changed_ = true;
193 } 199 }
194 200
195 // extensions beyond IE's API 201 bool DataTransfer::hasDataStoreItemListChanged() {
202 if (!data_store_item_list_changed_)
203 return false;
204 data_store_item_list_changed_ = false;
jsbell 2017/05/12 17:07:35 Hrm... most places where we use [CachedAttribute]
205 return true;
206 }
207
196 Vector<String> DataTransfer::types() const { 208 Vector<String> DataTransfer::types() const {
197 Vector<String> types; 209 Vector<String> types;
198 if (!CanReadTypes()) 210 if (!CanReadTypes())
199 return types; 211 return types;
200 212
201 return data_object_->Types(); 213 return data_object_->Types();
202 } 214 }
203 215
204 FileList* DataTransfer::files() const { 216 FileList* DataTransfer::files() const {
205 FileList* files = FileList::Create(); 217 FileList* files = FileList::Create();
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 return data_object_; 434 return data_object_;
423 } 435 }
424 436
425 DataTransfer::DataTransfer(DataTransferType type, 437 DataTransfer::DataTransfer(DataTransferType type,
426 DataTransferAccessPolicy policy, 438 DataTransferAccessPolicy policy,
427 DataObject* data_object) 439 DataObject* data_object)
428 : policy_(policy), 440 : policy_(policy),
429 drop_effect_("uninitialized"), 441 drop_effect_("uninitialized"),
430 effect_allowed_("uninitialized"), 442 effect_allowed_("uninitialized"),
431 transfer_type_(type), 443 transfer_type_(type),
432 data_object_(data_object) {} 444 data_object_(data_object),
445 data_store_item_list_changed_(true) {}
433 446
434 void DataTransfer::setDragImage(ImageResourceContent* image, 447 void DataTransfer::setDragImage(ImageResourceContent* image,
435 Node* node, 448 Node* node,
436 const IntPoint& loc) { 449 const IntPoint& loc) {
437 if (!CanSetDragImage()) 450 if (!CanSetDragImage())
438 return; 451 return;
439 452
440 drag_image_ = image; 453 drag_image_ = image;
441 drag_loc_ = loc; 454 drag_loc_ = loc;
442 drag_image_element_ = node; 455 drag_image_element_ = node;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 } 501 }
489 } 502 }
490 503
491 DEFINE_TRACE(DataTransfer) { 504 DEFINE_TRACE(DataTransfer) {
492 visitor->Trace(data_object_); 505 visitor->Trace(data_object_);
493 visitor->Trace(drag_image_); 506 visitor->Trace(drag_image_);
494 visitor->Trace(drag_image_element_); 507 visitor->Trace(drag_image_element_);
495 } 508 }
496 509
497 } // namespace blink 510 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698