| 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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 } | 592 } |
| 593 | 593 |
| 594 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double
& quality, SourceDrawingBuffer sourceBuffer) const | 594 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double
& quality, SourceDrawingBuffer sourceBuffer) const |
| 595 { | 595 { |
| 596 if (!isPaintable()) | 596 if (!isPaintable()) |
| 597 return String("data:,"); | 597 return String("data:,"); |
| 598 | 598 |
| 599 String encodingMimeType = toEncodingMimeType(mimeType, EncodeReasonToDataURL
); | 599 String encodingMimeType = toEncodingMimeType(mimeType, EncodeReasonToDataURL
); |
| 600 | 600 |
| 601 ImageData* imageData = toImageData(sourceBuffer, SnapshotReasonToDataURL); | 601 ImageData* imageData = toImageData(sourceBuffer, SnapshotReasonToDataURL); |
| 602 ScopedDisposal<ImageData> disposer(imageData); | |
| 603 | 602 |
| 604 return ImageDataBuffer(imageData->size(), imageData->data()->data()).toDataU
RL(encodingMimeType, quality); | 603 return ImageDataBuffer(imageData->size(), imageData->data()->data()).toDataU
RL(encodingMimeType, quality); |
| 605 } | 604 } |
| 606 | 605 |
| 607 String HTMLCanvasElement::toDataURL(const String& mimeType, const ScriptValue& q
ualityArgument, ExceptionState& exceptionState) const | 606 String HTMLCanvasElement::toDataURL(const String& mimeType, const ScriptValue& q
ualityArgument, ExceptionState& exceptionState) const |
| 608 { | 607 { |
| 609 if (!originClean()) { | 608 if (!originClean()) { |
| 610 exceptionState.throwSecurityError("Tainted canvases may not be exported.
"); | 609 exceptionState.throwSecurityError("Tainted canvases may not be exported.
"); |
| 611 return String(); | 610 return String(); |
| 612 } | 611 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 637 if (!qualityArgument.isEmpty()) { | 636 if (!qualityArgument.isEmpty()) { |
| 638 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); | 637 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); |
| 639 if (v8Value->IsNumber()) { | 638 if (v8Value->IsNumber()) { |
| 640 quality = v8Value.As<v8::Number>()->Value(); | 639 quality = v8Value.As<v8::Number>()->Value(); |
| 641 } | 640 } |
| 642 } | 641 } |
| 643 | 642 |
| 644 String encodingMimeType = toEncodingMimeType(mimeType, EncodeReasonToBlobCal
lback); | 643 String encodingMimeType = toEncodingMimeType(mimeType, EncodeReasonToBlobCal
lback); |
| 645 | 644 |
| 646 ImageData* imageData = toImageData(BackBuffer, SnapshotReasonToBlob); | 645 ImageData* imageData = toImageData(BackBuffer, SnapshotReasonToBlob); |
| 647 // imageData unref its data, which we still keep alive for the async toBlob
thread | 646 |
| 648 ScopedDisposal<ImageData> disposer(imageData); | |
| 649 CanvasAsyncBlobCreator* asyncCreator = CanvasAsyncBlobCreator::create(imageD
ata->data(), encodingMimeType, imageData->size(), callback); | 647 CanvasAsyncBlobCreator* asyncCreator = CanvasAsyncBlobCreator::create(imageD
ata->data(), encodingMimeType, imageData->size(), callback); |
| 650 | 648 |
| 651 if (encodingMimeType == DefaultMimeType) | 649 if (encodingMimeType == DefaultMimeType) |
| 652 asyncCreator->scheduleAsyncBlobCreation(true); | 650 asyncCreator->scheduleAsyncBlobCreation(true); |
| 653 else | 651 else |
| 654 asyncCreator->scheduleAsyncBlobCreation(false, quality); | 652 asyncCreator->scheduleAsyncBlobCreation(false, quality); |
| 655 } | 653 } |
| 656 | 654 |
| 657 void HTMLCanvasElement::addListener(CanvasDrawListener* listener) | 655 void HTMLCanvasElement::addListener(CanvasDrawListener* listener) |
| 658 { | 656 { |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 } | 1114 } |
| 1117 | 1115 |
| 1118 std::pair<Element*, String> HTMLCanvasElement::getControlAndIdIfHitRegionExists(
const LayoutPoint& location) | 1116 std::pair<Element*, String> HTMLCanvasElement::getControlAndIdIfHitRegionExists(
const LayoutPoint& location) |
| 1119 { | 1117 { |
| 1120 if (m_context && m_context->is2d()) | 1118 if (m_context && m_context->is2d()) |
| 1121 return m_context->getControlAndIdIfHitRegionExists(location); | 1119 return m_context->getControlAndIdIfHitRegionExists(location); |
| 1122 return std::make_pair(nullptr, String()); | 1120 return std::make_pair(nullptr, String()); |
| 1123 } | 1121 } |
| 1124 | 1122 |
| 1125 } // namespace blink | 1123 } // namespace blink |
| OLD | NEW |