Exemple #1
0
void HTMLCanvasElementModule::getContext(
    HTMLCanvasElement& canvas,
    const String& type,
    const CanvasContextCreationAttributes& attributes,
    ExceptionState& exceptionState,
    RenderingContext& result) {
  if (canvas.surfaceLayerBridge()) {
    // The existence of canvas surfaceLayerBridge indicates that
    // HTMLCanvasElement.transferControlToOffscreen() has been called.
    exceptionState.throwDOMException(InvalidStateError,
                                     "Cannot get context from a canvas that "
                                     "has transferred its control to "
                                     "offscreen.");
    return;
  }

  CanvasRenderingContext* context =
      canvas.getCanvasRenderingContext(type, attributes);
  if (context) {
    context->setCanvasGetContextResult(result);
  }
}