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