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 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 double quality = UndefinedQualityValue; | 573 double quality = UndefinedQualityValue; |
574 if (!qualityArgument.isEmpty()) { | 574 if (!qualityArgument.isEmpty()) { |
575 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); | 575 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); |
576 if (v8Value->IsNumber()) { | 576 if (v8Value->IsNumber()) { |
577 quality = v8Value.As<v8::Number>()->Value(); | 577 quality = v8Value.As<v8::Number>()->Value(); |
578 } | 578 } |
579 } | 579 } |
580 return toDataURLInternal(mimeType, quality, BackBuffer); | 580 return toDataURLInternal(mimeType, quality, BackBuffer); |
581 } | 581 } |
582 | 582 |
583 void HTMLCanvasElement::toBlob(ScriptState* scriptState, FileCallback* callback,
const String& mimeType, const ScriptValue& qualityArgument, ExceptionState& exc
eptionState) | 583 void HTMLCanvasElement::toBlob(ScriptState* scriptState, BlobCallback* callback,
const String& mimeType, const ScriptValue& qualityArgument, ExceptionState& exc
eptionState) |
584 { | 584 { |
585 if (!originClean()) { | 585 if (!originClean()) { |
586 exceptionState.throwSecurityError("Tainted canvases may not be exported.
"); | 586 exceptionState.throwSecurityError("Tainted canvases may not be exported.
"); |
587 return; | 587 return; |
588 } | 588 } |
589 | 589 |
590 if (!isPaintable()) { | 590 if (!isPaintable()) { |
591 // If the canvas element's bitmap has no pixels | 591 // If the canvas element's bitmap has no pixels |
592 Platform::current()->mainThread()->taskRunner()->postTask(BLINK_FROM_HER
E, bind(&FileCallback::handleEvent, callback, nullptr)); | 592 Platform::current()->mainThread()->taskRunner()->postTask(BLINK_FROM_HER
E, bind(&BlobCallback::handleEvent, callback, nullptr)); |
593 return; | 593 return; |
594 } | 594 } |
595 | 595 |
596 double quality = UndefinedQualityValue; | 596 double quality = UndefinedQualityValue; |
597 if (!qualityArgument.isEmpty()) { | 597 if (!qualityArgument.isEmpty()) { |
598 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); | 598 v8::Local<v8::Value> v8Value = qualityArgument.v8Value(); |
599 if (v8Value->IsNumber()) { | 599 if (v8Value->IsNumber()) { |
600 quality = v8Value.As<v8::Number>()->Value(); | 600 quality = v8Value.As<v8::Number>()->Value(); |
601 } | 601 } |
602 } | 602 } |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 } | 1013 } |
1014 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im
ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr); | 1014 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im
ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr); |
1015 } | 1015 } |
1016 | 1016 |
1017 bool HTMLCanvasElement::isOpaque() const | 1017 bool HTMLCanvasElement::isOpaque() const |
1018 { | 1018 { |
1019 return m_context && !m_context->hasAlpha(); | 1019 return m_context && !m_context->hasAlpha(); |
1020 } | 1020 } |
1021 | 1021 |
1022 } // blink | 1022 } // blink |
OLD | NEW |