| Index: third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvas.cpp
|
| diff --git a/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvas.cpp b/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvas.cpp
|
| index 0aedca56e420feed6780983a749a355e6a8f3cd2..435ba369368b3d0818c20fdaa42659c5d45bef5d 100644
|
| --- a/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvas.cpp
|
| +++ b/third_party/WebKit/Source/modules/offscreencanvas/OffscreenCanvas.cpp
|
| @@ -35,8 +35,21 @@ void OffscreenCanvas::setHeight(unsigned height)
|
| m_size.setHeight(clampTo<int>(height));
|
| }
|
|
|
| -OffscreenCanvasRenderingContext2D* OffscreenCanvas::getContext(const String& id, const CanvasContextCreationAttributes& attributes)
|
| +void OffscreenCanvas::setNeutered()
|
| {
|
| + ASSERT(!m_context);
|
| + m_isNeutered = true;
|
| + m_size.setWidth(0);
|
| + m_size.setHeight(0);
|
| +}
|
| +
|
| +OffscreenCanvasRenderingContext2D* OffscreenCanvas::getContext(const String& id, const CanvasContextCreationAttributes& attributes, ExceptionState& exceptionState)
|
| +{
|
| + if (m_isNeutered) {
|
| + exceptionState.throwDOMException(InvalidStateError, "Cannot get context of a neutered OffscreenCanvas");
|
| + return nullptr;
|
| + }
|
| +
|
| OffscreenCanvasRenderingContext::ContextType contextType = OffscreenCanvasRenderingContext::contextTypeFromId(id);
|
|
|
| // Unknown type.
|
| @@ -64,6 +77,10 @@ OffscreenCanvasRenderingContext2D* OffscreenCanvas::getContext(const String& id,
|
|
|
| ImageBitmap* OffscreenCanvas::transferToImageBitmap(ExceptionState& exceptionState)
|
| {
|
| + if (m_isNeutered) {
|
| + exceptionState.throwDOMException(InvalidStateError, "Cannot transfer an ImageBitmap from a neutered OffscreenCanvas");
|
| + return nullptr;
|
| + }
|
| if (!m_context) {
|
| exceptionState.throwDOMException(InvalidStateError, "Cannot transfer an ImageBitmap from an OffscreenCanvas with no context");
|
| return nullptr;
|
| @@ -78,6 +95,7 @@ ImageBitmap* OffscreenCanvas::transferToImageBitmap(ExceptionState& exceptionSta
|
|
|
| OffscreenCanvasRenderingContext2D* OffscreenCanvas::renderingContext() const
|
| {
|
| + ASSERT(!m_isNeutered);
|
| // TODO: When there're more than one context type implemented in the future,
|
| // the return type here should be changed to base class of all Offscreen
|
| // context types.
|
| @@ -107,7 +125,6 @@ void OffscreenCanvas::registerRenderingContextFactory(PassOwnPtr<OffscreenCanvas
|
| DEFINE_TRACE(OffscreenCanvas)
|
| {
|
| visitor->trace(m_context);
|
| - visitor->trace(m_canvas);
|
| }
|
|
|
| } // namespace blink
|
|
|