void V8DeviceMotionEvent::initDeviceMotionEventMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "initDeviceMotionEvent", "DeviceMotionEvent", info.Holder(), info.GetIsolate());
    DeviceMotionEvent* impl = V8DeviceMotionEvent::toImpl(info.Holder());
    v8::Isolate* isolate = info.GetIsolate();
    V8StringResource<> type(info[0]);
    if (!type.prepare())
        return;
    v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
    bool bubbles = false;
    V8_CALL(bubbles, info[1], BooleanValue(context), return);
    bool cancelable = false;
    V8_CALL(cancelable, info[2], BooleanValue(context), return);
    DeviceMotionData::Acceleration* acceleration = readAccelerationArgument(info[3], isolate);
    DeviceMotionData::Acceleration* accelerationIncludingGravity = readAccelerationArgument(info[4], isolate);
    DeviceMotionData::RotationRate* rotationRate = readRotationRateArgument(info[5], isolate);
    bool intervalProvided = !isUndefinedOrNull(info[6]);
    double interval = 0;
    if (intervalProvided) {
        interval = toRestrictedDouble(isolate, info[6], exceptionState);
        if (exceptionState.throwIfNeeded())
            return;
    }
    DeviceMotionData* deviceMotionData = DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, intervalProvided, interval);
    impl->initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData);
}
Ejemplo n.º 2
0
JSValue JSDeviceMotionEvent::initDeviceMotionEvent(ExecState& state)
{
    const String type = state.argument(0).toString(&state)->value(&state);
    bool bubbles = state.argument(1).toBoolean(&state);
    bool cancelable = state.argument(2).toBoolean(&state);

    // If any of the parameters are null or undefined, mark them as not provided.
    // Otherwise, use the standard JavaScript conversion.
    RefPtr<DeviceMotionData::Acceleration> acceleration = readAccelerationArgument(state.argument(3), state);
    if (state.hadException())
        return jsUndefined();

    RefPtr<DeviceMotionData::Acceleration> accelerationIncludingGravity = readAccelerationArgument(state.argument(4), state);
    if (state.hadException())
        return jsUndefined();

    RefPtr<DeviceMotionData::RotationRate> rotationRate = readRotationRateArgument(state.argument(5), state);
    if (state.hadException())
        return jsUndefined();

    bool intervalProvided = !state.argument(6).isUndefinedOrNull();
    double interval = state.argument(6).toNumber(&state);
    RefPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, intervalProvided, interval);
    wrapped().initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData.get());
    return jsUndefined();
}
JSValue JSDeviceMotionEvent::initDeviceMotionEvent(ExecState* exec)
{
    const UString& typeArg = exec->argument(0).toString(exec);
    bool bubbles = exec->argument(1).toBoolean(exec);
    bool cancelable = exec->argument(2).toBoolean(exec);

    // If any of the parameters are null or undefined, mark them as not provided.
    // Otherwise, use the standard JavaScript conversion.
    RefPtr<DeviceMotionData::Acceleration> acceleration = readAccelerationArgument(exec->argument(3), exec);
    if (exec->hadException())
        return jsUndefined();

    RefPtr<DeviceMotionData::Acceleration> accelerationIncludingGravity = readAccelerationArgument(exec->argument(4), exec);
    if (exec->hadException())
        return jsUndefined();

    RefPtr<DeviceMotionData::RotationRate> rotationRate = readRotationRateArgument(exec->argument(5), exec);
    if (exec->hadException())
        return jsUndefined();

    bool intervalProvided = !exec->argument(6).isUndefinedOrNull();
    double interval = exec->argument(6).toNumber(exec);
    RefPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, intervalProvided, interval);
    DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
    imp->initDeviceMotionEvent(ustringToAtomicString(typeArg), bubbles, cancelable, deviceMotionData.get());
    return jsUndefined();
}
Ejemplo n.º 4
0
v8::Handle<v8::Value> V8DeviceMotionEvent::initDeviceMotionEventCallback(const v8::Arguments& args)
{
    DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(args.Holder());
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, args[0]);
    bool bubbles = args[1]->BooleanValue();
    bool cancelable = args[2]->BooleanValue();
    RefPtr<DeviceMotionData::Acceleration> acceleration = readAccelerationArgument(args[3]);
    RefPtr<DeviceMotionData::Acceleration> accelerationIncludingGravity = readAccelerationArgument(args[4]);
    RefPtr<DeviceMotionData::RotationRate> rotationRate = readRotationRateArgument(args[5]);
    bool intervalProvided = !isUndefinedOrNull(args[6]);
    double interval = args[6]->NumberValue();
    RefPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, intervalProvided, interval);
    imp->initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData.get());
    return v8Undefined();
}