JSValue JSDeviceOrientationEvent::absolute(ExecState*) const
{
    DeviceOrientationEvent* imp = static_cast<DeviceOrientationEvent*>(impl());
    if (!imp->orientation()->canProvideAbsolute())
        return jsNull();
    return jsBoolean(imp->orientation()->absolute());
}
JSValue JSDeviceOrientationEvent::gamma(ExecState*) const
{
    DeviceOrientationEvent* imp = static_cast<DeviceOrientationEvent*>(impl());
    if (!imp->orientation()->canProvideGamma())
        return jsNull();
    return jsNumber(imp->orientation()->gamma());
}
v8::Handle<v8::Value> V8DeviceOrientationEvent::gammaAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.DeviceOrientationEvent.gamma._get");
    v8::Handle<v8::Object> holder = info.Holder();
    DeviceOrientationEvent* imp = V8DeviceOrientationEvent::toNative(holder);
    if (!imp->orientation()->canProvideGamma())
        return v8::Null();
    return v8::Number::New(imp->orientation()->gamma());
}
Exemple #4
0
v8::Handle<v8::Value> V8DeviceOrientationEvent::absoluteAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.DeviceOrientationEvent.absolute._get");
    v8::Handle<v8::Object> holder = info.Holder();
    DeviceOrientationEvent* imp = V8DeviceOrientationEvent::toNative(holder);
    if (!imp->orientation()->canProvideAbsolute())
        return v8::Null(info.GetIsolate());
    return v8::Boolean::New(imp->orientation()->absolute());
}
v8::Handle<v8::Value> V8DeviceOrientationEvent::initDeviceOrientationEventCallback(const v8::Arguments& args)
{
    DeviceOrientationEvent* imp = V8DeviceOrientationEvent::toNative(args.Holder());
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, type, args[0]);
    bool bubbles = args[1]->BooleanValue();
    bool cancelable = args[2]->BooleanValue();
    // If alpha, beta or gamma are null or undefined, mark them as not provided.
    // Otherwise, use the standard JavaScript conversion.
    bool alphaProvided = !isUndefinedOrNull(args[3]);
    double alpha = args[3]->NumberValue();
    bool betaProvided = !isUndefinedOrNull(args[4]);
    double beta = args[4]->NumberValue();
    bool gammaProvided = !isUndefinedOrNull(args[5]);
    double gamma = args[5]->NumberValue();
    RefPtr<DeviceOrientation> orientation = DeviceOrientation::create(alphaProvided, alpha, betaProvided, beta, gammaProvided, gamma);
    imp->initDeviceOrientationEvent(type, bubbles, cancelable, orientation.get());
    return v8::Handle<v8::Value>();
}
void V8DeviceOrientationEvent::initDeviceOrientationEventMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    DeviceOrientationEvent* impl = V8DeviceOrientationEvent::toNative(info.Holder());
    TOSTRING_VOID(V8StringResource<>, type, info[0]);
    bool bubbles = info[1]->BooleanValue();
    bool cancelable = info[2]->BooleanValue();
    // If alpha, beta, gamma or absolute are null or undefined, mark them as not provided.
    // Otherwise, use the standard JavaScript conversion.
    bool alphaProvided = !isUndefinedOrNull(info[3]);
    double alpha = info[3]->NumberValue();
    bool betaProvided = !isUndefinedOrNull(info[4]);
    double beta = info[4]->NumberValue();
    bool gammaProvided = !isUndefinedOrNull(info[5]);
    double gamma = info[5]->NumberValue();
    bool absoluteProvided = !isUndefinedOrNull(info[6]);
    bool absolute = info[6]->BooleanValue();
    RefPtrWillBeRawPtr<DeviceOrientationData> orientation = DeviceOrientationData::create(alphaProvided, alpha, betaProvided, beta, gammaProvided, gamma, absoluteProvided, absolute);
    impl->initDeviceOrientationEvent(type, bubbles, cancelable, orientation.get());
}
v8::Handle<v8::Value> V8DeviceOrientationEvent::initDeviceOrientationEventCallback(const v8::Arguments& args)
{
    DeviceOrientationEvent* imp = V8DeviceOrientationEvent::toNative(args.Holder());
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, args[0]);
    bool bubbles = args[1]->BooleanValue();
    bool cancelable = args[2]->BooleanValue();
    // If alpha, beta, gamma or absolute are null or undefined, mark them as not provided.
    // Otherwise, use the standard JavaScript conversion.
    bool alphaProvided = !isUndefinedOrNull(args[3]);
    double alpha = args[3]->NumberValue();
    bool betaProvided = !isUndefinedOrNull(args[4]);
    double beta = args[4]->NumberValue();
    bool gammaProvided = !isUndefinedOrNull(args[5]);
    double gamma = args[5]->NumberValue();
    bool absoluteProvided = !isUndefinedOrNull(args[6]);
    bool absolute = args[6]->BooleanValue();
    RefPtr<DeviceOrientationData> orientation = DeviceOrientationData::create(alphaProvided, alpha, betaProvided, beta, gammaProvided, gamma, absoluteProvided, absolute);
    imp->initDeviceOrientationEvent(type, bubbles, cancelable, orientation.get());
    return v8Undefined();
}
JSValue JSDeviceOrientationEvent::initDeviceOrientationEvent(ExecState* exec)
{
    const String& type = ustringToString(exec->argument(0).toString(exec)->value(exec));
    bool bubbles = exec->argument(1).toBoolean(exec);
    bool cancelable = exec->argument(2).toBoolean(exec);
    // If alpha, beta or gamma are null or undefined, mark them as not provided.
    // Otherwise, use the standard JavaScript conversion.
    bool alphaProvided = !exec->argument(3).isUndefinedOrNull();
    double alpha = exec->argument(3).toNumber(exec);
    bool betaProvided = !exec->argument(4).isUndefinedOrNull();
    double beta = exec->argument(4).toNumber(exec);
    bool gammaProvided = !exec->argument(5).isUndefinedOrNull();
    double gamma = exec->argument(5).toNumber(exec);
    bool absoluteProvided = !exec->argument(5).isUndefinedOrNull();
    bool absolute = exec->argument(6).toBoolean(exec);
    RefPtr<DeviceOrientation> orientation = DeviceOrientation::create(alphaProvided, alpha, betaProvided, beta, gammaProvided, gamma, absoluteProvided, absolute);
    DeviceOrientationEvent* imp = static_cast<DeviceOrientationEvent*>(impl());
    imp->initDeviceOrientationEvent(type, bubbles, cancelable, orientation.get());
    return jsUndefined();
}
bool DeviceOrientationController::isNullEvent(Event* event)
{
    DeviceOrientationEvent* orientationEvent = toDeviceOrientationEvent(event);
    return !orientationEvent->orientation()->canProvideEventData();
}
bool NewDeviceOrientationController::isNullEvent(Event* event)
{
    ASSERT(event->type() == eventNames().deviceorientationEvent);
    DeviceOrientationEvent* orientationEvent = static_cast<DeviceOrientationEvent*>(event);
    return !orientationEvent->orientation()->canProvideEventData();
}