| 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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 | 605 |
| 606 return ImageDataBuffer(imageData->size(), imageData->data()->data()).toDataU
RL(encodingMimeType, quality); | 606 return ImageDataBuffer(imageData->size(), imageData->data()->data()).toDataU
RL(encodingMimeType, quality); |
| 607 } | 607 } |
| 608 | 608 |
| 609 String HTMLCanvasElement::toDataURL(const String& mimeType, const ScriptValue& q
ualityArgument, ExceptionState& exceptionState) const | 609 String HTMLCanvasElement::toDataURL(const String& mimeType, const ScriptValue& q
ualityArgument, ExceptionState& exceptionState) const |
| 610 { | 610 { |
| 611 if (!originClean()) { | 611 if (!originClean()) { |
| 612 exceptionState.throwSecurityError("Tainted canvases may not be exported.
"); | 612 exceptionState.throwSecurityError("Tainted canvases may not be exported.
"); |
| 613 return String(); | 613 return String(); |
| 614 } | 614 } |
| 615 Optional<ScopedUsHistogramTimer> timer; |
| 616 String lowercaseMimeType = mimeType.lower(); |
| 617 if (mimeType.isNull()) |
| 618 lowercaseMimeType = DefaultMimeType; |
| 619 if (lowercaseMimeType == "image/png") { |
| 620 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterPNG
, new CustomCountHistogram("Blink.Canvas.ToDataURL.PNG", 0, 10000000, 50)); |
| 621 timer.emplace(scopedUsCounterPNG); |
| 622 } else if (lowercaseMimeType == "image/jpeg") { |
| 623 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterJPE
G, new CustomCountHistogram("Blink.Canvas.ToDataURL.JPEG", 0, 10000000, 50)); |
| 624 timer.emplace(scopedUsCounterJPEG); |
| 625 } else if (lowercaseMimeType == "image/webp") { |
| 626 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterWEB
P, new CustomCountHistogram("Blink.Canvas.ToDataURL.WEBP", 0, 10000000, 50)); |
| 627 timer.emplace(scopedUsCounterWEBP); |
| 628 } else if (lowercaseMimeType == "image/gif") { |
| 629 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterGIF
, new CustomCountHistogram("Blink.Canvas.ToDataURL.GIF", 0, 10000000, 50)); |
| 630 timer.emplace(scopedUsCounterGIF); |
| 631 } else if (lowercaseMimeType == "image/bmp" || lowercaseMimeType == "image/x
-windows-bmp") { |
| 632 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterBMP
, new CustomCountHistogram("Blink.Canvas.ToDataURL.BMP", 0, 10000000, 50)); |
| 633 timer.emplace(scopedUsCounterBMP); |
| 634 } else if (lowercaseMimeType == "image/x-icon") { |
| 635 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterICO
N, new CustomCountHistogram("Blink.Canvas.ToDataURL.ICON", 0, 10000000, 50)); |
| 636 timer.emplace(scopedUsCounterICON); |
| 637 } else if (lowercaseMimeType == "image/tiff" || lowercaseMimeType == "image/
x-tiff") { |
| 638 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterTIF
F, new CustomCountHistogram("Blink.Canvas.ToDataURL.TIFF", 0, 10000000, 50)); |
| 639 timer.emplace(scopedUsCounterTIFF); |
| 640 } else { |
| 641 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounterUnk
nown, new CustomCountHistogram("Blink.Canvas.ToDataURL.Unknown", 0, 10000000, 50
)); |
| 642 timer.emplace(scopedUsCounterUnknown); |
| 643 } |
| 644 |
| 615 double quality = UndefinedQualityValue; | 645 double quality = UndefinedQualityValue; |
| 616 if (!qualityArgument.isEmpty()) { | 646 if (!qualityArgument.isEmpty()) { |
| 617 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); | 647 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); |
| 618 if (v8Value->IsNumber()) { | 648 if (v8Value->IsNumber()) { |
| 619 quality = v8Value.As<v8::Number>()->Value(); | 649 quality = v8Value.As<v8::Number>()->Value(); |
| 620 } | 650 } |
| 621 } | 651 } |
| 622 return toDataURLInternal(mimeType, quality, BackBuffer); | 652 return toDataURLInternal(mimeType, quality, BackBuffer); |
| 623 } | 653 } |
| 624 | 654 |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 return m_context->getIdFromControl(element); | 1165 return m_context->getIdFromControl(element); |
| 1136 return String(); | 1166 return String(); |
| 1137 } | 1167 } |
| 1138 | 1168 |
| 1139 void HTMLCanvasElement::createSurfaceLayerBridge() | 1169 void HTMLCanvasElement::createSurfaceLayerBridge() |
| 1140 { | 1170 { |
| 1141 m_surfaceLayerBridge = adoptPtr(new CanvasSurfaceLayerBridge()); | 1171 m_surfaceLayerBridge = adoptPtr(new CanvasSurfaceLayerBridge()); |
| 1142 } | 1172 } |
| 1143 | 1173 |
| 1144 } // namespace blink | 1174 } // namespace blink |
| OLD | NEW |