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


C++ DeviceMotionEvent类代码示例

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


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

示例1: readAccelerationArgument

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();
}
开发者ID:mulriple,项目名称:Webkit-Projects,代码行数:27,代码来源:JSDeviceMotionEventCustom.cpp

示例2: exceptionState

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);
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:26,代码来源:V8DeviceMotionEventCustom.cpp

示例3: interval

JSValue JSDeviceMotionEvent::interval(ExecState*) const
{
    DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
    if (!imp->deviceMotionData()->canProvideInterval())
        return jsNull();
    return jsNumber(imp->deviceMotionData()->interval());
}
开发者ID:mulriple,项目名称:Webkit-Projects,代码行数:7,代码来源:JSDeviceMotionEventCustom.cpp

示例4: rotationRate

JSValue JSDeviceMotionEvent::rotationRate(ExecState* exec) const
{
    DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
    if (!imp->deviceMotionData()->rotationRate())
        return jsNull();
    return createRotationRateObject(imp->deviceMotionData()->rotationRate(), exec);
}
开发者ID:mulriple,项目名称:Webkit-Projects,代码行数:7,代码来源:JSDeviceMotionEventCustom.cpp

示例5: accelerationIncludingGravity

JSValue JSDeviceMotionEvent::accelerationIncludingGravity(ExecState* exec) const
{
    DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
    if (!imp->deviceMotionData()->accelerationIncludingGravity())
        return jsNull();
    return createAccelerationObject(imp->deviceMotionData()->accelerationIncludingGravity(), exec);
}
开发者ID:mulriple,项目名称:Webkit-Projects,代码行数:7,代码来源:JSDeviceMotionEventCustom.cpp

示例6: INC_STATS

v8::Handle<v8::Value> V8DeviceMotionEvent::intervalAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.DeviceMotionEvent.interval._get");
    v8::Handle<v8::Object> holder = info.Holder();
    DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder);
    if (!imp->deviceMotionData()->canProvideInterval())
        return v8Null(info.GetIsolate());
    return v8::Number::New(imp->deviceMotionData()->interval());
}
开发者ID:jiezh,项目名称:h5vcc,代码行数:9,代码来源:V8DeviceMotionEventCustom.cpp

示例7: INC_STATS

v8::Handle<v8::Value> V8DeviceMotionEvent::accelerationIncludingGravityAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.DeviceMotionEvent.accelerationIncludingGravity._get");
    v8::Handle<v8::Object> holder = info.Holder();
    DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder);
    if (!imp->deviceMotionData()->accelerationIncludingGravity())
        return v8::Null();
    return createAccelerationObject(imp->deviceMotionData()->accelerationIncludingGravity());
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:9,代码来源:V8DeviceMotionEventCustom.cpp

示例8: V8TRYCATCH_FOR_V8STRINGRESOURCE

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();
}
开发者ID:jiezh,项目名称:h5vcc,代码行数:15,代码来源:V8DeviceMotionEventCustom.cpp

示例9: toDeviceMotionEvent

bool DeviceMotionController::isNullEvent(Event* event) const
{
    DeviceMotionEvent* motionEvent = toDeviceMotionEvent(event);
    return !motionEvent->deviceMotionData()->canProvideEventData();
}
开发者ID:alexanderbill,项目名称:blink-crosswalk,代码行数:5,代码来源:DeviceMotionController.cpp

示例10: switch

void
nsDeviceSensors::FireDOMMotionEvent(nsIDOMDocument *domdoc,
                                    EventTarget* target,
                                    uint32_t type,
                                    PRTime timestamp,
                                    double x,
                                    double y,
                                    double z)
{
  // Attempt to coalesce events
  TimeDuration sensorPollDuration =
    TimeDuration::FromMilliseconds(DEFAULT_SENSOR_POLL);
  bool fireEvent =
    (TimeStamp::Now() > mLastDOMMotionEventTime + sensorPollDuration) ||
    sTestSensorEvents;

  switch (type) {
  case nsIDeviceSensorData::TYPE_LINEAR_ACCELERATION:
    if (!mLastAcceleration) {
      mLastAcceleration.emplace();
    }
    mLastAcceleration->mX.SetValue(x);
    mLastAcceleration->mY.SetValue(y);
    mLastAcceleration->mZ.SetValue(z);
    break;
  case nsIDeviceSensorData::TYPE_ACCELERATION:
    if (!mLastAccelerationIncludingGravity) {
      mLastAccelerationIncludingGravity.emplace();
    }
    mLastAccelerationIncludingGravity->mX.SetValue(x);
    mLastAccelerationIncludingGravity->mY.SetValue(y);
    mLastAccelerationIncludingGravity->mZ.SetValue(z);
    break;
  case nsIDeviceSensorData::TYPE_GYROSCOPE:
    if (!mLastRotationRate) {
      mLastRotationRate.emplace();
    }
    mLastRotationRate->mAlpha.SetValue(x);
    mLastRotationRate->mBeta.SetValue(y);
    mLastRotationRate->mGamma.SetValue(z);
    break;
  }

  if (fireEvent) {
    if (!mLastAcceleration) {
      mLastAcceleration.emplace();
    }
    if (!mLastAccelerationIncludingGravity) {
      mLastAccelerationIncludingGravity.emplace();
    }
    if (!mLastRotationRate) {
      mLastRotationRate.emplace();
    }
  } else if (!mLastAcceleration ||
             !mLastAccelerationIncludingGravity ||
             !mLastRotationRate) {
    return;
  }

  nsCOMPtr<nsIDOMEvent> event;
  domdoc->CreateEvent(NS_LITERAL_STRING("DeviceMotionEvent"), getter_AddRefs(event));

  DeviceMotionEvent* me = static_cast<DeviceMotionEvent*>(event.get());

  me->InitDeviceMotionEvent(NS_LITERAL_STRING("devicemotion"),
                            true,
                            false,
                            *mLastAcceleration,
                            *mLastAccelerationIncludingGravity,
                            *mLastRotationRate,
                            Nullable<double>(DEFAULT_SENSOR_POLL),
                            Nullable<uint64_t>(timestamp));

  event->SetTrusted(true);

  bool defaultActionEnabled = true;
  target->DispatchEvent(event, &defaultActionEnabled);

  mLastRotationRate.reset();
  mLastAccelerationIncludingGravity.reset();
  mLastAcceleration.reset();
  mLastDOMMotionEventTime = TimeStamp::Now();
}
开发者ID:MekliCZ,项目名称:positron,代码行数:83,代码来源:nsDeviceSensors.cpp

示例11: ASSERT

bool DeviceMotionController::isNullEvent(Event* event)
{
    ASSERT(event->type() == eventNames().devicemotionEvent);
    DeviceMotionEvent* motionEvent = static_cast<DeviceMotionEvent*>(event);
    return !motionEvent->deviceMotionData()->canProvideEventData();
}
开发者ID:huningxin,项目名称:blink-crosswalk,代码行数:6,代码来源:DeviceMotionController.cpp


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