OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 { | 374 { |
375 String lowercaseMimeType = mimeType.lower(); | 375 String lowercaseMimeType = mimeType.lower(); |
376 | 376 |
377 // FIXME: Make isSupportedImageMIMETypeForEncoding threadsafe (to allow this method to be used on a worker thread). | 377 // FIXME: Make isSupportedImageMIMETypeForEncoding threadsafe (to allow this method to be used on a worker thread). |
378 if (mimeType.isNull() || !MIMETypeRegistry::isSupportedImageMIMETypeForEncod ing(lowercaseMimeType)) | 378 if (mimeType.isNull() || !MIMETypeRegistry::isSupportedImageMIMETypeForEncod ing(lowercaseMimeType)) |
379 lowercaseMimeType = "image/png"; | 379 lowercaseMimeType = "image/png"; |
380 | 380 |
381 return lowercaseMimeType; | 381 return lowercaseMimeType; |
382 } | 382 } |
383 | 383 |
384 String HTMLCanvasElement::toDataURL(const String& mimeType, const double* qualit y, ExceptionState& exceptionState) | 384 const AtomicString HTMLCanvasElement::imageSourceURL() const |
385 { | 385 { |
386 if (!m_originClean) { | 386 return AtomicString(toDataURLInternal("image/png", 0)); |
387 exceptionState.throwSecurityError("Tainted canvases may not be exported. "); | 387 } |
388 return String(); | |
389 } | |
390 | 388 |
389 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double * quality) const | |
390 { | |
391 if (m_size.isEmpty() || !buffer()) | 391 if (m_size.isEmpty() || !buffer()) |
392 return String("data:,"); | 392 return String("data:,"); |
393 | 393 |
394 String encodingMimeType = toEncodingMimeType(mimeType); | 394 String encodingMimeType = toEncodingMimeType(mimeType); |
395 | 395 |
396 // Try to get ImageData first, as that may avoid lossy conversions. | 396 // Try to get ImageData first, as that may avoid lossy conversions. |
397 RefPtrWillBeRawPtr<ImageData> imageData = getImageData(); | 397 RefPtrWillBeRawPtr<ImageData> imageData = getImageData(); |
398 | 398 |
399 if (imageData) | 399 if (imageData) |
400 return ImageDataToDataURL(ImageDataBuffer(imageData->size(), imageData-> data()), encodingMimeType, quality); | 400 return ImageDataToDataURL(ImageDataBuffer(imageData->size(), imageData-> data()), encodingMimeType, quality); |
401 | 401 |
402 if (m_context) | 402 if (m_context) |
403 m_context->paintRenderingResultsToCanvas(); | 403 m_context->paintRenderingResultsToCanvas(); |
404 | 404 |
405 return buffer()->toDataURL(encodingMimeType, quality); | 405 return buffer()->toDataURL(encodingMimeType, quality); |
406 } | 406 } |
407 | 407 |
408 PassRefPtrWillBeRawPtr<ImageData> HTMLCanvasElement::getImageData() | 408 String HTMLCanvasElement::toDataURL(const String& mimeType, const double* qualit y, ExceptionState& exceptionState) |
Justin Novosad
2014/04/24 14:19:39
I know it was like this before, but this method sh
| |
409 { | |
410 if (!m_originClean) { | |
411 exceptionState.throwSecurityError("Tainted canvases may not be exported. "); | |
412 return String(); | |
413 } | |
414 | |
415 return toDataURLInternal(mimeType, quality); | |
416 } | |
417 | |
418 PassRefPtrWillBeRawPtr<ImageData> HTMLCanvasElement::getImageData() const | |
409 { | 419 { |
410 if (!m_context || !m_context->is3d()) | 420 if (!m_context || !m_context->is3d()) |
411 return nullptr; | 421 return nullptr; |
412 return toWebGLRenderingContext(m_context.get())->paintRenderingResultsToImag eData(); | 422 return toWebGLRenderingContext(m_context.get())->paintRenderingResultsToImag eData(); |
413 } | 423 } |
414 | 424 |
415 SecurityOrigin* HTMLCanvasElement::securityOrigin() const | 425 SecurityOrigin* HTMLCanvasElement::securityOrigin() const |
416 { | 426 { |
417 return document().securityOrigin(); | 427 return document().securityOrigin(); |
418 } | 428 } |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
688 { | 698 { |
689 return !originClean(); | 699 return !originClean(); |
690 } | 700 } |
691 | 701 |
692 FloatSize HTMLCanvasElement::sourceSize() const | 702 FloatSize HTMLCanvasElement::sourceSize() const |
693 { | 703 { |
694 return FloatSize(width(), height()); | 704 return FloatSize(width(), height()); |
695 } | 705 } |
696 | 706 |
697 } | 707 } |
OLD | NEW |