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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 loc = m_dragLoc; | 257 loc = m_dragLoc; |
258 return DragImage::create(m_dragImage->image()); | 258 return DragImage::create(m_dragImage->image()); |
259 } | 259 } |
260 return nullptr; | 260 return nullptr; |
261 } | 261 } |
262 | 262 |
263 static ImageResource* getImageResource(Element* element) | 263 static ImageResource* getImageResource(Element* element) |
264 { | 264 { |
265 // Attempt to pull ImageResource from element | 265 // Attempt to pull ImageResource from element |
266 ASSERT(element); | 266 ASSERT(element); |
267 LayoutObject* renderer = element->renderer(); | 267 LayoutObject* renderer = element->layoutObject(); |
268 if (!renderer || !renderer->isImage()) | 268 if (!renderer || !renderer->isImage()) |
269 return 0; | 269 return 0; |
270 | 270 |
271 LayoutImage* image = toLayoutImage(renderer); | 271 LayoutImage* image = toLayoutImage(renderer); |
272 if (image->cachedImage() && !image->cachedImage()->errorOccurred()) | 272 if (image->cachedImage() && !image->cachedImage()->errorOccurred()) |
273 return image->cachedImage(); | 273 return image->cachedImage(); |
274 | 274 |
275 return 0; | 275 return 0; |
276 } | 276 } |
277 | 277 |
278 static void writeImageToDataObject(DataObject* dataObject, Element* element, con
st KURL& url) | 278 static void writeImageToDataObject(DataObject* dataObject, Element* element, con
st KURL& url) |
279 { | 279 { |
280 // Shove image data into a DataObject for use as a file | 280 // Shove image data into a DataObject for use as a file |
281 ImageResource* cachedImage = getImageResource(element); | 281 ImageResource* cachedImage = getImageResource(element); |
282 if (!cachedImage || !cachedImage->imageForRenderer(element->renderer()) || !
cachedImage->isLoaded()) | 282 if (!cachedImage || !cachedImage->imageForRenderer(element->layoutObject())
|| !cachedImage->isLoaded()) |
283 return; | 283 return; |
284 | 284 |
285 SharedBuffer* imageBuffer = cachedImage->imageForRenderer(element->renderer(
))->data(); | 285 SharedBuffer* imageBuffer = cachedImage->imageForRenderer(element->layoutObj
ect())->data(); |
286 if (!imageBuffer || !imageBuffer->size()) | 286 if (!imageBuffer || !imageBuffer->size()) |
287 return; | 287 return; |
288 | 288 |
289 String imageExtension = cachedImage->image()->filenameExtension(); | 289 String imageExtension = cachedImage->image()->filenameExtension(); |
290 ASSERT(!imageExtension.isEmpty()); | 290 ASSERT(!imageExtension.isEmpty()); |
291 | 291 |
292 // Determine the filename for the file contents of the image. | 292 // Determine the filename for the file contents of the image. |
293 String filename = cachedImage->response().suggestedFilename(); | 293 String filename = cachedImage->response().suggestedFilename(); |
294 if (filename.isEmpty()) | 294 if (filename.isEmpty()) |
295 filename = url.lastPathComponent(); | 295 filename = url.lastPathComponent(); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 } | 524 } |
525 } | 525 } |
526 | 526 |
527 DEFINE_TRACE(DataTransfer) | 527 DEFINE_TRACE(DataTransfer) |
528 { | 528 { |
529 visitor->trace(m_dataObject); | 529 visitor->trace(m_dataObject); |
530 visitor->trace(m_dragImageElement); | 530 visitor->trace(m_dragImageElement); |
531 } | 531 } |
532 | 532 |
533 } // namespace blink | 533 } // namespace blink |
OLD | NEW |