diff options
Diffstat (limited to 'Source/WebCore/dom/DeviceMotionEvent.h')
-rw-r--r-- | Source/WebCore/dom/DeviceMotionEvent.h | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/Source/WebCore/dom/DeviceMotionEvent.h b/Source/WebCore/dom/DeviceMotionEvent.h index 2f06d86b8..7a8e9a5a1 100644 --- a/Source/WebCore/dom/DeviceMotionEvent.h +++ b/Source/WebCore/dom/DeviceMotionEvent.h @@ -10,10 +10,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -23,8 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef DeviceMotionEvent_h -#define DeviceMotionEvent_h +#pragma once #include "Event.h" @@ -32,31 +31,48 @@ namespace WebCore { class DeviceMotionData; -class DeviceMotionEvent : public Event { +class DeviceMotionEvent final : public Event { public: - ~DeviceMotionEvent(); - static PassRefPtr<DeviceMotionEvent> create() + virtual ~DeviceMotionEvent(); + + // FIXME: Merge this with DeviceMotionData::Acceleration + struct Acceleration { + std::optional<double> x; + std::optional<double> y; + std::optional<double> z; + }; + + // FIXME: Merge this with DeviceMotionData::RotationRate + struct RotationRate { + std::optional<double> alpha; + std::optional<double> beta; + std::optional<double> gamma; + }; + + static Ref<DeviceMotionEvent> create(const AtomicString& eventType, DeviceMotionData* deviceMotionData) { - return adoptRef(new DeviceMotionEvent); + return adoptRef(*new DeviceMotionEvent(eventType, deviceMotionData)); } - static PassRefPtr<DeviceMotionEvent> create(const AtomicString& eventType, DeviceMotionData* deviceMotionData) + + static Ref<DeviceMotionEvent> createForBindings() { - return adoptRef(new DeviceMotionEvent(eventType, deviceMotionData)); + return adoptRef(*new DeviceMotionEvent); } - void initDeviceMotionEvent(const AtomicString& type, bool bubbles, bool cancelable, DeviceMotionData*); + std::optional<Acceleration> acceleration() const; + std::optional<Acceleration> accelerationIncludingGravity() const; + std::optional<RotationRate> rotationRate() const; + std::optional<double> interval() const; - DeviceMotionData* deviceMotionData() const { return m_deviceMotionData.get(); } - - virtual EventInterface eventInterface() const override; + void initDeviceMotionEvent(const AtomicString& type, bool bubbles, bool cancelable, std::optional<Acceleration>&&, std::optional<Acceleration>&&, std::optional<RotationRate>&&, std::optional<double>); private: DeviceMotionEvent(); DeviceMotionEvent(const AtomicString& eventType, DeviceMotionData*); + EventInterface eventInterface() const override; + RefPtr<DeviceMotionData> m_deviceMotionData; }; } // namespace WebCore - -#endif // DeviceMotionEvent_h |