当前位置: 首页>>代码示例>>C++>>正文


C++ jsc::ExecState类代码示例

本文整理汇总了C++中jsc::ExecState的典型用法代码示例。如果您正苦于以下问题:C++ ExecState类的具体用法?C++ ExecState怎么用?C++ ExecState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ExecState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getCSSCanvasContext

JSValue JSDocument::getCSSCanvasContext(JSC::ExecState& state)
{
    VM& vm = state.vm();
    auto scope = DECLARE_THROW_SCOPE(vm);

    if (UNLIKELY(state.argumentCount() < 4))
        return throwException(&state, scope, createNotEnoughArgumentsError(&state));
    auto contextId = state.uncheckedArgument(0).toWTFString(&state);
    if (UNLIKELY(state.hadException()))
        return jsUndefined();
    auto name = state.uncheckedArgument(1).toWTFString(&state);
    if (UNLIKELY(state.hadException()))
        return jsUndefined();
    auto width = convert<int32_t>(state, state.uncheckedArgument(2), NormalConversion);
    if (UNLIKELY(state.hadException()))
        return jsUndefined();
    auto height = convert<int32_t>(state, state.uncheckedArgument(3), NormalConversion);
    if (UNLIKELY(state.hadException()))
        return jsUndefined();

    auto* context = wrapped().getCSSCanvasContext(WTFMove(contextId), WTFMove(name), WTFMove(width), WTFMove(height));
    if (!context)
        return jsNull();

#if ENABLE(WEBGL)
    if (is<WebGLRenderingContextBase>(*context))
        return toJS(&state, globalObject(), downcast<WebGLRenderingContextBase>(*context));
#endif

    return toJS(&state, globalObject(), downcast<CanvasRenderingContext2D>(*context));
}
开发者ID:endlessm,项目名称:WebKit,代码行数:31,代码来源:JSDocumentCustom.cpp

示例2: willCreatePossiblyOrphanedTreeByRemovalSlowCase

void willCreatePossiblyOrphanedTreeByRemovalSlowCase(Node* root)
{
    JSC::ExecState* scriptState = mainWorldExecState(root->document().frame());
    if (!scriptState)
        return;

    JSLockHolder lock(scriptState);
    toJS(scriptState, static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()), root);
}
开发者ID:boska,项目名称:webkit,代码行数:9,代码来源:JSNodeCustom.cpp

示例3: dispatchDidPause

void ScriptDebugServer::dispatchDidPause(ScriptDebugListener* listener)
{
    ASSERT(isPaused());
    DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame();
    JSGlobalObject* globalObject = debuggerCallFrame->scope()->globalObject();
    JSC::ExecState* state = globalObject->globalExec();
    RefPtr<JavaScriptCallFrame> javaScriptCallFrame = JavaScriptCallFrame::create(debuggerCallFrame);
    JSValue jsCallFrame = toJS(state, globalObject, javaScriptCallFrame.get());
    listener->didPause(state, Deprecated::ScriptValue(state->vm(), jsCallFrame), Deprecated::ScriptValue());
}
开发者ID:JefferyJeffery,项目名称:webkit,代码行数:10,代码来源:ScriptDebugServer.cpp

示例4: didAddUserAgentShadowRoot

void HTMLPlugInImageElement::didAddUserAgentShadowRoot(ShadowRoot* root)
{
    HTMLPlugInElement::didAddUserAgentShadowRoot(root);
    if (displayState() >= PreparingPluginReplacement)
        return;

    Page* page = document().page();
    if (!page)
        return;

    // Reset any author styles that may apply as we only want explicit
    // styles defined in the injected user agents stylesheets to specify
    // the look-and-feel of the snapshotted plug-in overlay. 
    root->setResetStyleInheritance(true);
    
    String mimeType = loadedMimeType();

    DOMWrapperWorld& isolatedWorld = plugInImageElementIsolatedWorld();
    document().ensurePlugInsInjectedScript(isolatedWorld);

    ScriptController& scriptController = document().frame()->script();
    JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(isolatedWorld));
    JSC::ExecState* exec = globalObject->globalExec();

    JSC::JSLockHolder lock(exec);

    JSC::MarkedArgumentBuffer argList;
    argList.append(toJS(exec, globalObject, root));
    argList.append(jsString(exec, titleText(page, mimeType)));
    argList.append(jsString(exec, subtitleText(page, mimeType)));
    
    // This parameter determines whether or not the snapshot overlay should always be visible over the plugin snapshot.
    // If no snapshot was found then we want the overlay to be visible.
    argList.append(JSC::jsBoolean(!m_snapshotImage));

    // It is expected the JS file provides a createOverlay(shadowRoot, title, subtitle) function.
    JSC::JSObject* overlay = globalObject->get(exec, JSC::Identifier::fromString(exec, "createOverlay")).toObject(exec);
    if (!overlay) {
        ASSERT(exec->hadException());
        exec->clearException();
        return;
    }
    JSC::CallData callData;
    JSC::CallType callType = overlay->methodTable()->getCallData(overlay, callData);
    if (callType == JSC::CallType::None)
        return;

    JSC::call(exec, overlay, callType, callData, globalObject, argList);
    exec->clearException();
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:50,代码来源:HTMLPlugInImageElement.cpp

示例5: injectIDBKeyIntoScriptValue

bool injectIDBKeyIntoScriptValue(JSC::ExecState& exec, const IDBKeyData& keyData, JSC::JSValue value, const IDBKeyPath& keyPath)
{
    LOG(IndexedDB, "injectIDBKeyIntoScriptValue");

    ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);

    Vector<String> keyPathElements;
    IDBKeyPathParseError error;
    IDBParseKeyPath(keyPath.string(), keyPathElements, error);
    ASSERT(error == IDBKeyPathParseError::None);

    if (keyPathElements.isEmpty())
        return false;

    JSValue parent = ensureNthValueOnKeyPath(&exec, value, keyPathElements, keyPathElements.size() - 1);
    if (parent.isUndefined())
        return false;

    auto key = keyData.maybeCreateIDBKey();
    if (!key)
        return false;

    if (!set(&exec, parent, keyPathElements.last(), idbKeyToJSValue(&exec, exec.lexicalGlobalObject(), key.get())))
        return false;

    return true;
}
开发者ID:valbok,项目名称:WebKitForWayland,代码行数:27,代码来源:IDBBindingUtilities.cpp

示例6: payment

JSC::JSValue JSApplePayPaymentAuthorizedEvent::payment(JSC::ExecState& exec) const
{
    if (!m_payment)
        m_payment.set(exec.vm(), this, wrapped().payment().toJS(exec));

    return m_payment.get();
}
开发者ID:eocanha,项目名称:webkit,代码行数:7,代码来源:JSApplePayPaymentAuthorizedEventCustom.cpp

示例7: storeError

void ReadableJSStream::storeError(JSC::ExecState& exec, JSValue error)
{
    if (m_error)
        return;
    m_error.set(exec.vm(), error);

    changeStateToErrored();
}
开发者ID:GuoCheng111,项目名称:webkit,代码行数:8,代码来源:ReadableJSStream.cpp

示例8: idbValueDataToJSValue

static JSValue idbValueDataToJSValue(JSC::ExecState& exec, const Vector<uint8_t>& buffer)
{
    if (buffer.isEmpty())
        return jsNull();

    RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::createFromWireBytes(buffer);
    return serializedValue->deserialize(&exec, exec.lexicalGlobalObject(), 0, NonThrowing);
}
开发者ID:valbok,项目名称:WebKitForWayland,代码行数:8,代码来源:IDBBindingUtilities.cpp

示例9: error

void ReadableJSStream::error(JSC::ExecState& state, ExceptionCode& ec)
{
    if (!isReadable()) {
        ec = TypeError;
        return;
    }
    storeError(state, state.argument(0));
}
开发者ID:GuoCheng111,项目名称:webkit,代码行数:8,代码来源:ReadableJSStream.cpp

示例10: deserializeIDBValueDataToJSValue

JSC::JSValue deserializeIDBValueDataToJSValue(JSC::ExecState& exec, const ThreadSafeDataBuffer& valueData)
{
    if (!valueData.data())
        return jsUndefined();

    const Vector<uint8_t>& data = *valueData.data();
    JSValue result;
    if (data.size()) {
        RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::createFromWireBytes(data);

        exec.vm().apiLock().lock();
        result = serializedValue->deserialize(&exec, exec.lexicalGlobalObject(), 0, NonThrowing);
        exec.vm().apiLock().unlock();
    } else
        result = jsNull();

    return result;
}
开发者ID:valbok,项目名称:WebKitForWayland,代码行数:18,代码来源:IDBBindingUtilities.cpp

示例11: dispatchDidPause

void ScriptDebugServer::dispatchDidPause(ScriptDebugListener* listener)
{
    ASSERT(m_paused);
    DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame();
    JSGlobalObject* globalObject = debuggerCallFrame->scope()->globalObject();
    JSC::ExecState* state = globalObject->globalExec();
    RefPtr<JavaScriptCallFrame> javaScriptCallFrame = JavaScriptCallFrame::create(debuggerCallFrame);
    JSValue jsCallFrame;
    {
        if (globalObject->inherits(JSDOMGlobalObject::info())) {
            JSDOMGlobalObject* domGlobalObject = jsCast<JSDOMGlobalObject*>(globalObject);
            JSLockHolder lock(state);
            jsCallFrame = toJS(state, domGlobalObject, javaScriptCallFrame.get());
        } else
            jsCallFrame = jsUndefined();
    }
    listener->didPause(state, ScriptValue(state->vm(), jsCallFrame), ScriptValue());
}
开发者ID:jeremysjones,项目名称:webkit,代码行数:18,代码来源:ScriptDebugServer.cpp

示例12: fillMessagePortArray

void fillMessagePortArray(JSC::ExecState& state, JSC::JSValue value, MessagePortArray& portArray, ArrayBufferArray& arrayBuffers)
{
    // Convert from the passed-in JS array-like object to a MessagePortArray.
    // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 of the HTML5 spec.
    if (value.isUndefinedOrNull()) {
        portArray.resize(0);
        arrayBuffers.resize(0);
        return;
    }

    // Validation of sequence types, per WebIDL spec 4.1.13.
    unsigned length = 0;
    JSObject* object = toJSSequence(state, value, length);
    if (state.hadException())
        return;

    for (unsigned i = 0 ; i < length; ++i) {
        JSValue value = object->get(&state, i);
        if (state.hadException())
            return;
        // Validation of non-null objects, per HTML5 spec 10.3.3.
        if (value.isUndefinedOrNull()) {
            setDOMException(&state, INVALID_STATE_ERR);
            return;
        }

        // Validation of Objects implementing an interface, per WebIDL spec 4.1.15.
        if (RefPtr<MessagePort> port = JSMessagePort::toWrapped(value)) {
            // Check for duplicate ports.
            if (portArray.contains(port)) {
                setDOMException(&state, INVALID_STATE_ERR);
                return;
            }
            portArray.append(WTFMove(port));
        } else {
            if (RefPtr<ArrayBuffer> arrayBuffer = toArrayBuffer(value))
                arrayBuffers.append(WTFMove(arrayBuffer));
            else {
                throwTypeError(&state);
                return;
            }
        }
    }
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:44,代码来源:JSMessagePortCustom.cpp

示例13: throwTypeError

static JSC::JSValue dataFunctionMatrix(DataFunctionMatrixToCall f, JSC::ExecState& state, WebGLRenderingContextBase& context)
{
    if (state.argumentCount() != 3)
        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
    
    WebGLUniformLocation* location = JSWebGLUniformLocation::toWrapped(state.uncheckedArgument(0));
    if (!location && !state.uncheckedArgument(0).isUndefinedOrNull())
        return throwTypeError(&state);
    
    bool transpose = state.uncheckedArgument(1).toBoolean(&state);
    if (state.hadException())
        return jsUndefined();
    
    RefPtr<Float32Array> webGLArray = toFloat32Array(state.uncheckedArgument(2));
    
    ExceptionCode ec = 0;
    if (webGLArray) {
        switch (f) {
        case f_uniformMatrix2fv:
            context.uniformMatrix2fv(location, transpose, *webGLArray, ec);
            break;
        case f_uniformMatrix3fv:
            context.uniformMatrix3fv(location, transpose, *webGLArray, ec);
            break;
        case f_uniformMatrix4fv:
            context.uniformMatrix4fv(location, transpose, *webGLArray, ec);
            break;
        }
        
        setDOMException(&state, ec);
        return jsUndefined();
    }
    
    Vector<float, 64> array;
    if (!toVector(state, state.uncheckedArgument(2), array))
        return throwTypeError(&state);
    
    switch (f) {
    case f_uniformMatrix2fv:
        context.uniformMatrix2fv(location, transpose, array.data(), array.size(), ec);
        break;
    case f_uniformMatrix3fv:
        context.uniformMatrix3fv(location, transpose, array.data(), array.size(), ec);
        break;
    case f_uniformMatrix4fv:
        context.uniformMatrix4fv(location, transpose, array.data(), array.size(), ec);
        break;
    }
    
    setDOMException(&state, ec);
    return jsUndefined();
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:52,代码来源:JSWebGLRenderingContextBaseCustom.cpp

示例14: initCustomEvent

void CustomEvent::initCustomEvent(JSC::ExecState& state, const AtomicString& type, bool canBubble, bool cancelable, JSC::JSValue detail)
{
    if (dispatched())
        return;

    initEvent(type, canBubble, cancelable);

    m_detail = { state.vm(), detail };
    m_serializedDetail = nullptr;
    m_triedToSerialize = false;
}
开发者ID:caiolima,项目名称:webkit,代码行数:11,代码来源:CustomEvent.cpp

示例15: callFunction

static inline JSC::JSValue callFunction(JSC::ExecState& state, JSC::JSValue jsFunction, JSC::JSValue thisValue, const JSC::ArgList& arguments)
{
    VM& vm = state.vm();
    auto scope = DECLARE_CATCH_SCOPE(vm);
    JSC::CallData callData;
    auto callType = JSC::getCallData(vm, jsFunction, callData);
    ASSERT(callType != JSC::CallType::None);
    auto result = call(&state, jsFunction, callType, callData, thisValue, arguments);
    scope.assertNoException();
    return result;
}
开发者ID:wolfviking0,项目名称:webcl-webkit,代码行数:11,代码来源:ReadableStream.cpp


注:本文中的jsc::ExecState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。