| 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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 RefPtrWillBeRawPtr<ImageData> imageData = | 478 RefPtrWillBeRawPtr<ImageData> imageData = |
| 479 toWebGLRenderingContext(m_context.get())->paintRenderingResultsToIma
geData(sourceBuffer); | 479 toWebGLRenderingContext(m_context.get())->paintRenderingResultsToIma
geData(sourceBuffer); |
| 480 if (imageData) | 480 if (imageData) |
| 481 return ImageDataBuffer(imageData->size(), imageData->data()->data())
.toDataURL(encodingMimeType, quality); | 481 return ImageDataBuffer(imageData->size(), imageData->data()->data())
.toDataURL(encodingMimeType, quality); |
| 482 m_context->paintRenderingResultsToCanvas(sourceBuffer); | 482 m_context->paintRenderingResultsToCanvas(sourceBuffer); |
| 483 } | 483 } |
| 484 | 484 |
| 485 return buffer()->toDataURL(encodingMimeType, quality); | 485 return buffer()->toDataURL(encodingMimeType, quality); |
| 486 } | 486 } |
| 487 | 487 |
| 488 String HTMLCanvasElement::toDataURL(const String& mimeType, const double* qualit
y, ExceptionState& exceptionState) const | 488 String HTMLCanvasElement::toDataURL(const String& mimeType, const ScriptValue& q
ualityArgument, ExceptionState& exceptionState) const |
| 489 { | 489 { |
| 490 if (!originClean()) { | 490 if (!originClean()) { |
| 491 exceptionState.throwSecurityError("Tainted canvases may not be exported.
"); | 491 exceptionState.throwSecurityError("Tainted canvases may not be exported.
"); |
| 492 return String(); | 492 return String(); |
| 493 } | 493 } |
| 494 | 494 double quality; |
| 495 return toDataURLInternal(mimeType, quality, BackBuffer); | 495 double* qualityPtr = nullptr; |
| 496 if (!qualityArgument.isEmpty()) { |
| 497 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); |
| 498 if (v8Value->IsNumber()) { |
| 499 quality = v8Value->NumberValue(); |
| 500 qualityPtr = &quality; |
| 501 } |
| 502 } |
| 503 return toDataURLInternal(mimeType, qualityPtr, BackBuffer); |
| 496 } | 504 } |
| 497 | 505 |
| 498 SecurityOrigin* HTMLCanvasElement::securityOrigin() const | 506 SecurityOrigin* HTMLCanvasElement::securityOrigin() const |
| 499 { | 507 { |
| 500 return document().securityOrigin(); | 508 return document().securityOrigin(); |
| 501 } | 509 } |
| 502 | 510 |
| 503 bool HTMLCanvasElement::originClean() const | 511 bool HTMLCanvasElement::originClean() const |
| 504 { | 512 { |
| 505 if (document().settings() && document().settings()->disableReadingFromCanvas
()) | 513 if (document().settings() && document().settings()->disableReadingFromCanvas
()) |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 { | 893 { |
| 886 return FloatSize(width(), height()); | 894 return FloatSize(width(), height()); |
| 887 } | 895 } |
| 888 | 896 |
| 889 bool HTMLCanvasElement::isOpaque() const | 897 bool HTMLCanvasElement::isOpaque() const |
| 890 { | 898 { |
| 891 return m_context && !m_context->hasAlpha(); | 899 return m_context && !m_context->hasAlpha(); |
| 892 } | 900 } |
| 893 | 901 |
| 894 } // blink | 902 } // blink |
| OLD | NEW |