コード例 #1
0
JSValue JSHTMLCanvasElement::getContext(ExecState* exec)
{
    HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(impl());
    const String& contextId = exec->argument(0).toString(exec)->value(exec);
    
    RefPtr<CanvasContextAttributes> attrs;
#if ENABLE(WEBGL)
    if (HTMLCanvasElement::is3dType(contextId)) {
        get3DContextAttributes(exec, attrs);
        if (exec->hadException())
            return jsUndefined();
    }
#endif
    
    CanvasRenderingContext* context = canvas->getContext(contextId, attrs.get());
    if (!context)
        return jsNull();
    JSValue jsValue = toJS(exec, globalObject(), WTF::getPtr(context));
    if (InspectorInstrumentation::canvasAgentEnabled(canvas->document())) {
        ScriptObject contextObject(exec, jsValue.getObject());
        ScriptObject wrapped;
        if (context->is2d())
            wrapped = InspectorInstrumentation::wrapCanvas2DRenderingContextForInstrumentation(canvas->document(), contextObject);
#if ENABLE(WEBGL)
        else if (context->is3d())
            wrapped = InspectorInstrumentation::wrapWebGLRenderingContextForInstrumentation(canvas->document(), contextObject);
#endif
        if (!wrapped.hasNoValue())
            return wrapped.jsValue();
    }
    return jsValue;
}
コード例 #2
0
JSValue JSHTMLCanvasElement::getContext(ExecState* exec)
{
    HTMLCanvasElement& canvas = impl();
    const String& contextId = exec->argument(0).toString(exec)->value(exec);
    
    RefPtr<CanvasContextAttributes> attrs;
#if ENABLE(WEBGL)
    if (HTMLCanvasElement::is3dType(contextId)) {
        get3DContextAttributes(exec, attrs);
        if (exec->hadException())
            return jsUndefined();
    }
#endif
    
    CanvasRenderingContext* context = canvas.getContext(contextId, attrs.get());
    if (!context)
        return jsNull();
    return toJS(exec, globalObject(), WTF::getPtr(context));
}
コード例 #3
0
JSValue JSHTMLCanvasElement::probablySupportsContext(ExecState* exec)
{
    HTMLCanvasElement& canvas = impl();
    if (!exec->argumentCount())
        return jsBoolean(false);
    const String& contextId = exec->uncheckedArgument(0).toString(exec)->value(exec);
    if (exec->hadException())
        return jsUndefined();
    
    RefPtr<CanvasContextAttributes> attrs;
#if ENABLE(WEBGL)
    if (HTMLCanvasElement::is3dType(contextId)) {
        get3DContextAttributes(exec, attrs);
        if (exec->hadException())
            return jsUndefined();
    }
#endif
    
    return jsBoolean(canvas.probablySupportsContext(contextId, attrs.get()));
}
コード例 #4
0
JSValue JSHTMLCanvasElement::probablySupportsContext(ExecState& state)
{
    if (UNLIKELY(state.argumentCount() < 1))
        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));

    HTMLCanvasElement& canvas = wrapped();
    const String& contextId = state.uncheckedArgument(0).toWTFString(&state);
    if (state.hadException())
        return jsUndefined();
    
    RefPtr<CanvasContextAttributes> attrs;
#if ENABLE(WEBGL)
    if (HTMLCanvasElement::is3dType(contextId)) {
        get3DContextAttributes(state, attrs);
        if (state.hadException())
            return jsUndefined();
    }
#endif
    
    return jsBoolean(canvas.probablySupportsContext(contextId, attrs.get()));
}
コード例 #5
0
JSValue JSHTMLCanvasElement::getContext(ExecState& state)
{
    if (UNLIKELY(state.argumentCount() < 1))
        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));

    HTMLCanvasElement& canvas = wrapped();
    const String& contextId = state.uncheckedArgument(0).toWTFString(&state);
    
    RefPtr<CanvasContextAttributes> attrs;
#if ENABLE(WEBGL)
    if (HTMLCanvasElement::is3dType(contextId)) {
        get3DContextAttributes(state, attrs);
        if (state.hadException())
            return jsUndefined();
    }
#endif
    
    CanvasRenderingContext* context = canvas.getContext(contextId, attrs.get());
    if (!context)
        return jsNull();
    return toJS(&state, globalObject(), *context);
}