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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 // FIXME: Make isSupportedImageMIMETypeForEncoding threadsafe (to allow this method to be used on a worker thread). | 366 // FIXME: Make isSupportedImageMIMETypeForEncoding threadsafe (to allow this method to be used on a worker thread). |
367 if (mimeType.isNull() || !MIMETypeRegistry::isSupportedImageMIMETypeForEncod ing(lowercaseMimeType)) | 367 if (mimeType.isNull() || !MIMETypeRegistry::isSupportedImageMIMETypeForEncod ing(lowercaseMimeType)) |
368 lowercaseMimeType = "image/png"; | 368 lowercaseMimeType = "image/png"; |
369 | 369 |
370 return lowercaseMimeType; | 370 return lowercaseMimeType; |
371 } | 371 } |
372 | 372 |
373 String HTMLCanvasElement::toDataURL(const String& mimeType, const double* qualit y, ExceptionState& exceptionState) | 373 String HTMLCanvasElement::toDataURL(const String& mimeType, const double* qualit y, ExceptionState& exceptionState) |
374 { | 374 { |
375 if (!m_originClean) { | 375 if (!m_originClean) { |
376 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("to DataURL", "HTMLCanvasElement", "tainted canvases may not be exported.")); | 376 exceptionState.throwSecurityError("tainted canvases may not be exported. "); |
Mike West
2013/11/29 08:26:45
Nit: If you're changing this anyway, can you capit
sof
2013/11/29 08:58:03
Done, and same for the other taint-related error m
| |
377 return String(); | 377 return String(); |
378 } | 378 } |
379 | 379 |
380 if (m_size.isEmpty() || !buffer()) | 380 if (m_size.isEmpty() || !buffer()) |
381 return String("data:,"); | 381 return String("data:,"); |
382 | 382 |
383 String encodingMimeType = toEncodingMimeType(mimeType); | 383 String encodingMimeType = toEncodingMimeType(mimeType); |
384 | 384 |
385 // Try to get ImageData first, as that may avoid lossy conversions. | 385 // Try to get ImageData first, as that may avoid lossy conversions. |
386 RefPtr<ImageData> imageData = getImageData(); | 386 RefPtr<ImageData> imageData = getImageData(); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 ASSERT(hasImageBuffer() && !m_didFailToCreateImageBuffer); | 551 ASSERT(hasImageBuffer() && !m_didFailToCreateImageBuffer); |
552 IntSize unscaledSize = size(); | 552 IntSize unscaledSize = size(); |
553 IntSize size = convertLogicalToDevice(unscaledSize); | 553 IntSize size = convertLogicalToDevice(unscaledSize); |
554 AffineTransform transform; | 554 AffineTransform transform; |
555 if (size.width() && size.height()) | 555 if (size.width() && size.height()) |
556 transform.scaleNonUniform(size.width() / unscaledSize.width(), size.heig ht() / unscaledSize.height()); | 556 transform.scaleNonUniform(size.width() / unscaledSize.width(), size.heig ht() / unscaledSize.height()); |
557 return m_imageBuffer->baseTransform() * transform; | 557 return m_imageBuffer->baseTransform() * transform; |
558 } | 558 } |
559 | 559 |
560 } | 560 } |
OLD | NEW |