| 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/dom/ExecutionContext.h" | |
| 8 #include "core/html/canvas/CanvasContextCreationAttributes.h" | 7 #include "core/html/canvas/CanvasContextCreationAttributes.h" |
| 9 #include "core/offscreencanvas/OffscreenCanvas.h" | 8 #include "core/offscreencanvas/OffscreenCanvas.h" |
| 10 #include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h" | 9 #include "modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.h" |
| 11 | 10 |
| 12 namespace blink { | 11 namespace blink { |
| 13 | 12 |
| 14 void OffscreenCanvasModules::getContext( | 13 void OffscreenCanvasModules::getContext( |
| 15 ScriptState* script_state, | 14 ScriptState* script_state, |
| 16 OffscreenCanvas& offscreen_canvas, | 15 OffscreenCanvas& offscreen_canvas, |
| 17 const String& id, | 16 const String& id, |
| 18 const CanvasContextCreationAttributes& attributes, | 17 const CanvasContextCreationAttributes& attributes, |
| 19 ExceptionState& exception_state, | 18 ExceptionState& exception_state, |
| 20 OffscreenRenderingContext& result) { | 19 OffscreenRenderingContext& result) { |
| 21 if (offscreen_canvas.IsNeutered()) { | 20 if (offscreen_canvas.IsNeutered()) { |
| 22 exception_state.ThrowDOMException(kInvalidStateError, | 21 exception_state.ThrowDOMException(kInvalidStateError, |
| 23 "OffscreenCanvas object is detached"); | 22 "OffscreenCanvas object is detached"); |
| 24 return; | 23 return; |
| 25 } | 24 } |
| 26 | 25 |
| 27 // OffscreenCanvas cannot be transferred after getContext, so this execution | 26 // OffscreenCanvas cannot be transferred after getContext, so this execution |
| 28 // context will always be the right one from here on. | 27 // context will always be the right one from here on. |
| 29 offscreen_canvas.SetExecutionContext(ExecutionContext::From(script_state)); | 28 offscreen_canvas.SetExecutionContext(script_state->GetExecutionContext()); |
| 30 CanvasRenderingContext* context = | 29 CanvasRenderingContext* context = |
| 31 offscreen_canvas.GetCanvasRenderingContext(script_state, id, attributes); | 30 offscreen_canvas.GetCanvasRenderingContext(script_state, id, attributes); |
| 32 if (context) | 31 if (context) |
| 33 context->SetOffscreenCanvasGetContextResult(result); | 32 context->SetOffscreenCanvasGetContextResult(result); |
| 34 } | 33 } |
| 35 | 34 |
| 36 } // namespace blink | 35 } // namespace blink |
| OLD | NEW |