|
| 1 | +/* |
| 2 | + * Copyright (C) 2024-present The WebF authors. All rights reserved. |
| 3 | + */ |
| 4 | + |
| 5 | +#include "device_orientation_event.h" |
| 6 | +#include "qjs_device_orientation_event.h" |
| 7 | + |
| 8 | +namespace webf { |
| 9 | + |
| 10 | +DeviceOrientationEvent* DeviceOrientationEvent::Create(ExecutingContext* context, |
| 11 | + const AtomicString& type, |
| 12 | + ExceptionState& exception_state) { |
| 13 | + return MakeGarbageCollected<DeviceOrientationEvent>(context, type, exception_state); |
| 14 | +} |
| 15 | + |
| 16 | +DeviceOrientationEvent* DeviceOrientationEvent::Create(ExecutingContext* context, |
| 17 | + const AtomicString& type, |
| 18 | + const std::shared_ptr<DeviceOrientationEventInit>& initializer, |
| 19 | + ExceptionState& exception_state) { |
| 20 | + return MakeGarbageCollected<DeviceOrientationEvent>(context, type, initializer, exception_state); |
| 21 | +} |
| 22 | + |
| 23 | +DeviceOrientationEvent::DeviceOrientationEvent(ExecutingContext* context, const AtomicString& type, ExceptionState& exception_state) |
| 24 | + : Event(context, type) {} |
| 25 | + |
| 26 | +DeviceOrientationEvent::DeviceOrientationEvent(ExecutingContext* context, |
| 27 | + const AtomicString& type, |
| 28 | + const std::shared_ptr<DeviceOrientationEventInit>& initializer, |
| 29 | + ExceptionState& exception_state) |
| 30 | + : Event(context, type), |
| 31 | + absolute_(initializer->hasAbsolute ? initializer->absolute()), |
| 32 | + alpha_(initializer->hasAlpha() ? initializer->alpha() : 0.0), |
| 33 | + beta_(initializer->hasBeta() ? initializer->beta() : 0.0), |
| 34 | + gamma_(initializer->hasGamma() ? initializer->gamma() : 0.0) {} |
| 35 | + |
| 36 | +DeviceOrientationEvent::DeviceOrientationEvent(ExecutingContext* context, |
| 37 | + const AtomicString& type, |
| 38 | + NativeDeviceOrientationEvent* native_orientation_event) |
| 39 | + : Event(context, type, &native_orientation_event->native_event), |
| 40 | + absolute_(native_orientation_event->absolute), |
| 41 | + alpha_(native_orientation_event->alpha), |
| 42 | + beta_(native_orientation_event->beta), |
| 43 | + gamma_(native_orientation_event->gamma) { |
| 44 | +} |
| 45 | + |
| 46 | +bool DeviceOrientationEvent::IsDeviceOrientationEvent() const { |
| 47 | + return true; |
| 48 | +} |
| 49 | + |
| 50 | +bool DeviceOrientationEvent::absolute() const { |
| 51 | + return absolute_; |
| 52 | +} |
| 53 | + |
| 54 | +double DeviceOrientationEvent::alpha() const { |
| 55 | + return alpha_; |
| 56 | +} |
| 57 | + |
| 58 | +double DeviceOrientationEvent::beta() const { |
| 59 | + return beta_; |
| 60 | +} |
| 61 | + |
| 62 | +double DeviceOrientationEvent::gamma() const { |
| 63 | + return gamma_; |
| 64 | +} |
| 65 | + |
| 66 | +} // namespace webf |
0 commit comments