Chromium Code Reviews| 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 RefPtrWillBeRawPtr<ImageData> imageData = | 462 RefPtrWillBeRawPtr<ImageData> imageData = |
| 463 toWebGLRenderingContext(m_context.get())->paintRenderingResultsToIma geData(sourceBuffer); | 463 toWebGLRenderingContext(m_context.get())->paintRenderingResultsToIma geData(sourceBuffer); |
| 464 if (imageData) | 464 if (imageData) |
| 465 return ImageDataBuffer(imageData->size(), imageData->data()->data()) .toDataURL(encodingMimeType, quality); | 465 return ImageDataBuffer(imageData->size(), imageData->data()->data()) .toDataURL(encodingMimeType, quality); |
| 466 m_context->paintRenderingResultsToCanvas(sourceBuffer); | 466 m_context->paintRenderingResultsToCanvas(sourceBuffer); |
| 467 } | 467 } |
| 468 | 468 |
| 469 return buffer()->toDataURL(encodingMimeType, quality); | 469 return buffer()->toDataURL(encodingMimeType, quality); |
| 470 } | 470 } |
| 471 | 471 |
| 472 String HTMLCanvasElement::toDataURL(const String& mimeType, const double* qualit y, ExceptionState& exceptionState) const | 472 String HTMLCanvasElement::toDataURL(const String& mimeType, const ScriptValue& q ualityArgument, ExceptionState& exceptionState) const |
| 473 { | 473 { |
| 474 if (!originClean()) { | 474 if (!originClean()) { |
| 475 exceptionState.throwSecurityError("Tainted canvases may not be exported. "); | 475 exceptionState.throwSecurityError("Tainted canvases may not be exported. "); |
| 476 return String(); | 476 return String(); |
| 477 } | 477 } |
| 478 | 478 double quality; |
| 479 return toDataURLInternal(mimeType, quality, BackBuffer); | 479 double* qualityPtr = nullptr; |
| 480 if (!qualityArgument.isEmpty()) { | |
| 481 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); | |
| 482 if (v8Value->IsNumber()) { | |
| 483 quality = v8Value.As<v8::Number>()->Value(); | |
|
Jens Widell
2015/02/11 15:13:08
quality = v8Value->NumberValue();
| |
| 484 qualityPtr = &quality; | |
| 485 } | |
| 486 } | |
| 487 return toDataURLInternal(mimeType, qualityPtr, BackBuffer); | |
| 480 } | 488 } |
| 481 | 489 |
| 482 SecurityOrigin* HTMLCanvasElement::securityOrigin() const | 490 SecurityOrigin* HTMLCanvasElement::securityOrigin() const |
| 483 { | 491 { |
| 484 return document().securityOrigin(); | 492 return document().securityOrigin(); |
| 485 } | 493 } |
| 486 | 494 |
| 487 bool HTMLCanvasElement::originClean() const | 495 bool HTMLCanvasElement::originClean() const |
| 488 { | 496 { |
| 489 if (document().settings() && document().settings()->disableReadingFromCanvas ()) | 497 if (document().settings() && document().settings()->disableReadingFromCanvas ()) |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 849 { | 857 { |
| 850 return !originClean(); | 858 return !originClean(); |
| 851 } | 859 } |
| 852 | 860 |
| 853 FloatSize HTMLCanvasElement::sourceSize() const | 861 FloatSize HTMLCanvasElement::sourceSize() const |
| 854 { | 862 { |
| 855 return FloatSize(width(), height()); | 863 return FloatSize(width(), height()); |
| 856 } | 864 } |
| 857 | 865 |
| 858 } | 866 } |
| OLD | NEW |