| 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 } | 594 } |
| 595 | 595 |
| 596 void HTMLCanvasElement::didMoveToNewDocument(Document& oldDocument) | 596 void HTMLCanvasElement::didMoveToNewDocument(Document& oldDocument) |
| 597 { | 597 { |
| 598 setObservedDocument(document()); | 598 setObservedDocument(document()); |
| 599 HTMLElement::didMoveToNewDocument(oldDocument); | 599 HTMLElement::didMoveToNewDocument(oldDocument); |
| 600 } | 600 } |
| 601 | 601 |
| 602 PassRefPtr<Image> HTMLCanvasElement::getSourceImageForCanvas(ExceptionState& exc
eptionState, CanvasImageSourceUsage usage, bool* isVolatile) const |
| 603 { |
| 604 if (isVolatile) |
| 605 *isVolatile = false; |
| 606 if (!width() || !height()) { |
| 607 if (usage == PatternCanvasImageSourceUsage) |
| 608 exceptionState.throwDOMException(InvalidStateError, String::format("
The source %s is 0.", width() ? "height" : "width")); |
| 609 return nullptr; |
| 610 } |
| 611 |
| 612 if (usage == PatternCanvasImageSourceUsage || usage == DrawToSelfCanvasImage
SourceUsage) |
| 613 return copiedImage(); |
| 614 |
| 615 if (m_context && m_context->is3d()) { |
| 616 m_context->paintRenderingResultsToCanvas(); |
| 617 // We leave isVolatile to false when the source is a 2D canvas because |
| 618 // 2d canvas-to-canvas copies are not deferred and all 2D canvases live |
| 619 // in the same graphics context so we can avoid triggering an |
| 620 // unnecessary flush in CanvasRenderingContext2D::drawImage |
| 621 *isVolatile = true; |
| 622 } |
| 623 return buffer() ? m_imageBuffer->copyImage(DontCopyBackingStore, Unscaled) :
nullptr; |
| 602 } | 624 } |
| 625 |
| 626 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const |
| 627 { |
| 628 return !originClean(); |
| 629 } |
| 630 |
| 631 FloatSize HTMLCanvasElement::sourceSize() const |
| 632 { |
| 633 return FloatSize(width(), height()); |
| 634 } |
| 635 |
| 636 } |
| OLD | NEW |