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

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

Issue 2858963002: Replace ASSERT with DCHECK in core/ (Closed)
Patch Set: WorkerBackingThread 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 Blob* blob = data_object_->Item(i)->GetAsFile(); 211 Blob* blob = data_object_->Item(i)->GetAsFile();
212 if (blob && blob->IsFile()) 212 if (blob && blob->IsFile())
213 files->Append(ToFile(blob)); 213 files->Append(ToFile(blob));
214 } 214 }
215 } 215 }
216 216
217 return files; 217 return files;
218 } 218 }
219 219
220 void DataTransfer::setDragImage(Element* image, int x, int y) { 220 void DataTransfer::setDragImage(Element* image, int x, int y) {
221 ASSERT(image); 221 DCHECK(image);
222 222
223 if (!IsForDragAndDrop()) 223 if (!IsForDragAndDrop())
224 return; 224 return;
225 225
226 IntPoint location(x, y); 226 IntPoint location(x, y);
227 if (isHTMLImageElement(*image) && !image->isConnected()) 227 if (isHTMLImageElement(*image) && !image->isConnected())
228 SetDragImageResource(toHTMLImageElement(*image).CachedImage(), location); 228 SetDragImageResource(toHTMLImageElement(*image).CachedImage(), location);
229 else 229 else
230 SetDragImageElement(image, location); 230 SetDragImageElement(image, location);
231 } 231 }
(...skipping 26 matching lines...) Expand all
258 } 258 }
259 if (drag_image_) { 259 if (drag_image_) {
260 loc = drag_loc_; 260 loc = drag_loc_;
261 return DragImage::Create(drag_image_->GetImage()); 261 return DragImage::Create(drag_image_->GetImage());
262 } 262 }
263 return nullptr; 263 return nullptr;
264 } 264 }
265 265
266 static ImageResourceContent* GetImageResourceContent(Element* element) { 266 static ImageResourceContent* GetImageResourceContent(Element* element) {
267 // Attempt to pull ImageResourceContent from element 267 // Attempt to pull ImageResourceContent from element
268 ASSERT(element); 268 DCHECK(element);
269 LayoutObject* layout_object = element->GetLayoutObject(); 269 LayoutObject* layout_object = element->GetLayoutObject();
270 if (!layout_object || !layout_object->IsImage()) 270 if (!layout_object || !layout_object->IsImage())
271 return 0; 271 return 0;
272 272
273 LayoutImage* image = ToLayoutImage(layout_object); 273 LayoutImage* image = ToLayoutImage(layout_object);
274 if (image->CachedImage() && !image->CachedImage()->ErrorOccurred()) 274 if (image->CachedImage() && !image->CachedImage()->ErrorOccurred())
275 return image->CachedImage(); 275 return image->CachedImage();
276 276
277 return 0; 277 return 0;
278 } 278 }
(...skipping 30 matching lines...) Expand all
309 WriteImageToDataObject(data_object_.Get(), element, image_url); 309 WriteImageToDataObject(data_object_.Get(), element, image_url);
310 310
311 // Put img tag on the clipboard referencing the image 311 // Put img tag on the clipboard referencing the image
312 data_object_->SetData(kMimeTypeTextHTML, 312 data_object_->SetData(kMimeTypeTextHTML,
313 CreateMarkup(element, kIncludeNode, kResolveAllURLs)); 313 CreateMarkup(element, kIncludeNode, kResolveAllURLs));
314 } 314 }
315 315
316 void DataTransfer::WriteURL(Node* node, const KURL& url, const String& title) { 316 void DataTransfer::WriteURL(Node* node, const KURL& url, const String& title) {
317 if (!data_object_) 317 if (!data_object_)
318 return; 318 return;
319 ASSERT(!url.IsEmpty()); 319 DCHECK(!url.IsEmpty());
320 320
321 data_object_->SetURLAndTitle(url, title); 321 data_object_->SetURLAndTitle(url, title);
322 322
323 // The URL can also be used as plain text. 323 // The URL can also be used as plain text.
324 data_object_->SetData(kMimeTypeTextPlain, url.GetString()); 324 data_object_->SetData(kMimeTypeTextPlain, url.GetString());
325 325
326 // The URL can also be used as an HTML fragment. 326 // The URL can also be used as an HTML fragment.
327 data_object_->SetHTMLAndBaseURL( 327 data_object_->SetHTMLAndBaseURL(
328 CreateMarkup(node, kIncludeNode, kResolveAllURLs), url); 328 CreateMarkup(node, kIncludeNode, kResolveAllURLs), url);
329 } 329 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 } 488 }
489 } 489 }
490 490
491 DEFINE_TRACE(DataTransfer) { 491 DEFINE_TRACE(DataTransfer) {
492 visitor->Trace(data_object_); 492 visitor->Trace(data_object_);
493 visitor->Trace(drag_image_); 493 visitor->Trace(drag_image_);
494 visitor->Trace(drag_image_element_); 494 visitor->Trace(drag_image_element_);
495 } 495 }
496 496
497 } // namespace blink 497 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698