Use "= default" to denote default constructor or destructor
[WebKit-https.git] / Source / WebCore / dom / DeviceOrientationEvent.cpp
index babc77e..add8ebc 100644 (file)
 #include "DeviceOrientationEvent.h"
 
 #include "DeviceOrientationData.h"
-#include "EventNames.h"
 
 namespace WebCore {
 
-DeviceOrientationEvent::~DeviceOrientationEvent()
-{
-}
+DeviceOrientationEvent::~DeviceOrientationEvent() = default;
 
 DeviceOrientationEvent::DeviceOrientationEvent()
     : m_orientation(DeviceOrientationData::create())
@@ -46,24 +43,69 @@ DeviceOrientationEvent::DeviceOrientationEvent(const AtomicString& eventType, De
 {
 }
 
-void DeviceOrientationEvent::initDeviceOrientationEvent(const AtomicString& type, bool bubbles, bool cancelable, DeviceOrientationData* orientation)
+std::optional<double> DeviceOrientationEvent::alpha() const
+{
+    return m_orientation->alpha();
+}
+
+std::optional<double> DeviceOrientationEvent::beta() const
+{
+    return m_orientation->beta();
+}
+
+std::optional<double> DeviceOrientationEvent::gamma() const
+{
+    return m_orientation->gamma();
+}
+
+#if PLATFORM(IOS)
+
+std::optional<double> DeviceOrientationEvent::compassHeading() const
+{
+    return m_orientation->compassHeading();
+}
+
+std::optional<double> DeviceOrientationEvent::compassAccuracy() const
+{
+    return m_orientation->compassAccuracy();
+}
+
+void DeviceOrientationEvent::initDeviceOrientationEvent(const AtomicString& type, bool bubbles, bool cancelable, std::optional<double> alpha, std::optional<double> beta, std::optional<double> gamma, std::optional<double> compassHeading, std::optional<double> compassAccuracy)
+{
+    if (dispatched())
+        return;
+
+    initEvent(type, bubbles, cancelable);
+    m_orientation = DeviceOrientationData::create(alpha, beta, gamma, compassHeading, compassAccuracy);
+}
+
+#else
+
+std::optional<bool> DeviceOrientationEvent::absolute() const
+{
+    return m_orientation->absolute();
+}
+
+void DeviceOrientationEvent::initDeviceOrientationEvent(const AtomicString& type, bool bubbles, bool cancelable, std::optional<double> alpha, std::optional<double> beta, std::optional<double> gamma, std::optional<bool> absolute)
 {
     if (dispatched())
         return;
 
     initEvent(type, bubbles, cancelable);
-    m_orientation = orientation;
+    m_orientation = DeviceOrientationData::create(alpha, beta, gamma, absolute);
 }
 
-const AtomicString& DeviceOrientationEvent::interfaceName() const
+#endif
+
+EventInterface DeviceOrientationEvent::eventInterface() const
 {
 #if ENABLE(DEVICE_ORIENTATION)
-    return eventNames().interfaceForDeviceOrientationEvent;
+    return DeviceOrientationEventInterfaceType;
 #else
     // FIXME: ENABLE(DEVICE_ORIENTATION) seems to be in a strange state where
     // it is half-guarded by #ifdefs. DeviceOrientationEvent.idl is guarded
     // but DeviceOrientationEvent.cpp itself is required by ungarded code.
-    return eventNames().interfaceForEvent;
+    return EventInterfaceType;
 #endif
 }