| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/offscreencanvas/OffscreenCanvasModules.h" | 5 #include "modules/offscreencanvas/OffscreenCanvasModules.h" |
| 6 | 6 |
| 7 #include "core/html/canvas/CanvasContextCreationAttributes.h" | 7 #include "core/html/canvas/CanvasContextCreationAttributes.h" |
| 8 #include "core/offscreencanvas/OffscreenCanvas.h" | 8 #include "core/offscreencanvas/OffscreenCanvas.h" |
| 9 #include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h" | 9 #include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 void OffscreenCanvasModules::getContext( | 13 void OffscreenCanvasModules::getContext( |
| 14 ScriptState* scriptState, | 14 ScriptState* scriptState, |
| 15 OffscreenCanvas& offscreenCanvas, | 15 OffscreenCanvas& offscreenCanvas, |
| 16 const String& id, | 16 const String& id, |
| 17 const CanvasContextCreationAttributes& attributes, | 17 const CanvasContextCreationAttributes& attributes, |
| 18 ExceptionState& exceptionState, | 18 ExceptionState& exceptionState, |
| 19 OffscreenRenderingContext& result) { | 19 OffscreenRenderingContext& result) { |
| 20 if (offscreenCanvas.isNeutered()) { | 20 if (offscreenCanvas.isNeutered()) { |
| 21 exceptionState.throwDOMException(InvalidStateError, | 21 exceptionState.throwDOMException(InvalidStateError, |
| 22 "OffscreenCanvas object is detached"); | 22 "OffscreenCanvas object is detached"); |
| 23 return; | 23 return; |
| 24 } | 24 } |
| 25 | 25 |
| 26 // OffscreenCanvas cannot be transferred after getContext, so this execution |
| 27 // context will always be the right one from here on. |
| 28 offscreenCanvas.setExecutionContext(scriptState->getExecutionContext()); |
| 26 CanvasRenderingContext* context = | 29 CanvasRenderingContext* context = |
| 27 offscreenCanvas.getCanvasRenderingContext(scriptState, id, attributes); | 30 offscreenCanvas.getCanvasRenderingContext(scriptState, id, attributes); |
| 28 if (context) | 31 if (context) |
| 29 context->setOffscreenCanvasGetContextResult(result); | 32 context->setOffscreenCanvasGetContextResult(result); |
| 30 } | 33 } |
| 31 | 34 |
| 32 } // namespace blink | 35 } // namespace blink |
| OLD | NEW |