Exemplo n.º 1
0
 std::string operator()()
 {
   const std::string colorPath = props::polygon::color::relative();
   return 
     "gr.fillPolygon( " + js_so::jsColor( ptree_.template get<boost::uint32_t>(colorPath)) + ", " 
                                         + jsArray() + " );\n"
     + "gr.drawPolygon( " + js_so::jsPen() + ", " + jsArray() + " );\n";
 }
JSValue jsTestSerializedScriptValueInterfacePorts(ExecState* exec, JSValue slotBase, PropertyName)
{
    JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
    JSValue result = jsArray(exec, castedThis->globalObject(), *impl->ports());
    return result;
}
Exemplo n.º 3
0
JSC::JSValue JSMediaStreamTrack::getCapabilities(ExecState& state)
{
    JSValue thisValue = state.thisValue();
    JSMediaStreamTrack* castedThis = jsDynamicCast<JSMediaStreamTrack*>(thisValue);
    if (UNLIKELY(!castedThis))
        return JSValue::decode(throwThisTypeError(state, "MediaStreamTrack", "getSettings"));

    JSObject* object = constructEmptyObject(&state);
    auto& impl = castedThis->wrapped();
    RefPtr<RealtimeMediaSourceCapabilities> capabilities = WTF::getPtr(impl.getCapabilities());

    if (capabilities->supportsWidth())
        object->putDirect(state.vm(), Identifier::fromString(&state, "width"), capabilityValue(capabilities->width(), state), DontDelete | ReadOnly);
    if (capabilities->supportsHeight())
        object->putDirect(state.vm(), Identifier::fromString(&state, "height"), capabilityValue(capabilities->height(), state), DontDelete | ReadOnly);
    if (capabilities->supportsAspectRatio())
        object->putDirect(state.vm(), Identifier::fromString(&state, "aspectRatio"), capabilityValue(capabilities->aspectRatio(), state), DontDelete | ReadOnly);
    if (capabilities->supportsFrameRate())
        object->putDirect(state.vm(), Identifier::fromString(&state, "frameRate"), capabilityValue(capabilities->frameRate(), state), DontDelete | ReadOnly);
    if (capabilities->supportsFacingMode()) {
        const Vector<RealtimeMediaSourceSettings::VideoFacingMode>& modes = capabilities->facingMode();
        Vector<String> facingModes;
        if (modes.size()) {

            facingModes.reserveCapacity(modes.size());

            for (auto& mode : modes)
                facingModes.append(RealtimeMediaSourceSettings::facingMode(mode));
        }

        object->putDirect(state.vm(), Identifier::fromString(&state, "facingMode"), jsArray(&state, castedThis->globalObject(), facingModes), DontDelete | ReadOnly);
    }
    if (capabilities->supportsVolume())
        object->putDirect(state.vm(), Identifier::fromString(&state, "volume"), capabilityValue(capabilities->volume(), state), DontDelete | ReadOnly);
    if (capabilities->supportsSampleRate())
        object->putDirect(state.vm(), Identifier::fromString(&state, "sampleRate"), capabilityValue(capabilities->sampleRate(), state), DontDelete | ReadOnly);
    if (capabilities->supportsSampleSize())
        object->putDirect(state.vm(), Identifier::fromString(&state, "sampleSize"), capabilityValue(capabilities->sampleSize(), state), DontDelete | ReadOnly);
    if (capabilities->supportsEchoCancellation()) {
        Vector<String> cancellation;
        cancellation.reserveCapacity(2);

        cancellation.append("true");
        cancellation.append(capabilities->echoCancellation() == RealtimeMediaSourceCapabilities::EchoCancellation::ReadWrite ? "true" : "false");

        object->putDirect(state.vm(), Identifier::fromString(&state, "echoCancellation"), jsArray(&state, castedThis->globalObject(), cancellation), DontDelete | ReadOnly);
    }
    if (capabilities->supportsDeviceId())
        object->putDirect(state.vm(), Identifier::fromString(&state, "deviceId"), jsStringWithCache(&state, capabilities->deviceId()), DontDelete | ReadOnly);
    if (capabilities->supportsGroupId())
        object->putDirect(state.vm(), Identifier::fromString(&state, "groupId"), jsStringWithCache(&state, capabilities->groupId()), DontDelete | ReadOnly);
    

    return object;
}
Exemplo n.º 4
0
void JSMutationCallback::call(const Vector<RefPtr<MutationRecord> >& mutations, MutationObserver* observer)
{
    if (!canInvokeCallback())
        return;

    RefPtr<JSMutationCallback> protect(this);

    JSLockHolder lock(m_isolatedWorld->globalData());

    if (!m_callback)
        return;

    JSValue callback = m_callback.get();
    CallData callData;
    CallType callType = getCallData(callback, callData);
    if (callType == CallTypeNone) {
        ASSERT_NOT_REACHED();
        return;
    }

    ScriptExecutionContext* context = scriptExecutionContext();
    if (!context)
        return;
    ASSERT(context->isDocument());

    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get());
    ExecState* exec = globalObject->globalExec();

    JSValue jsObserver = toJS(exec, globalObject, observer);

    MarkedArgumentBuffer args;
    args.append(jsArray(exec, globalObject, mutations));
    args.append(jsObserver);

    globalObject->globalData().timeoutChecker.start();
    InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(context, callType, callData);

    JSMainThreadExecState::call(exec, callback, callType, callData, jsObserver, args);

    InspectorInstrumentation::didCallFunction(cookie);
    globalObject->globalData().timeoutChecker.stop();

    if (exec->hadException())
        reportCurrentException(exec);
}
void JSMutationCallback::call(const Vector<RefPtr<MutationRecord>>& mutations, MutationObserver* observer)
{
    if (!canInvokeCallback())
        return;

    Ref<JSMutationCallback> protect(*this);

    JSLockHolder lock(m_isolatedWorld->vm());

    if (!m_callback)
        return;

    JSValue callback = m_callback.get();
    CallData callData;
    CallType callType = getCallData(callback, callData);
    if (callType == CallType::None) {
        ASSERT_NOT_REACHED();
        return;
    }

    ScriptExecutionContext* context = scriptExecutionContext();
    if (!context)
        return;
    ASSERT(context->isDocument());

    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, *m_isolatedWorld);
    ExecState* exec = globalObject->globalExec();

    JSValue jsObserver = toJS(exec, globalObject, observer);

    MarkedArgumentBuffer args;
    args.append(jsArray(exec, globalObject, mutations));
    args.append(jsObserver);

    InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(context, callType, callData);

    NakedPtr<Exception> exception;
    JSMainThreadExecState::profiledCall(exec, JSC::ProfilingReason::Other, callback, callType, callData, jsObserver, args, exception);

    InspectorInstrumentation::didCallFunction(cookie, context);

    if (exception)
        reportException(exec, exception);
}
JSValue JSDataTransfer::types(ExecState* exec) const
{
    Vector<String> types = impl().types();
    return types.isEmpty() ? jsNull() : jsArray(exec, globalObject(), types);
}
Exemplo n.º 7
0
JSValue JSDataTransfer::types(ExecState& state) const
{
    Vector<String> types = wrapped().types();
    return types.isEmpty() ? jsNull() : jsArray(&state, globalObject(), types);
}