Use "= default" to denote default constructor or destructor
[WebKit-https.git] / Source / WebCore / dom / DeviceOrientationEvent.cpp
index 97b919e..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,15 +43,60 @@ 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);
 }
 
+#endif
+
 EventInterface DeviceOrientationEvent::eventInterface() const
 {
 #if ENABLE(DEVICE_ORIENTATION)