Update DeviceProximityEvent to stop using legacy [ConstructorTemplate=Event]
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Oct 2016 04:47:00 +0000 (04:47 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Oct 2016 04:47:00 +0000 (04:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163311

Reviewed by Ryosuke Niwa.

Update DeviceProximityEvent to stop using legacy [ConstructorTemplate=Event]
and use a regular constructor instead, as in the specification:
- https://www.w3.org/TR/2015/WD-proximity-20150903/#deviceproximityevent-interface

* Modules/proximity/DeviceProximityEvent.cpp:
(WebCore::DeviceProximityEvent::DeviceProximityEvent):
* Modules/proximity/DeviceProximityEvent.h:
(WebCore::DeviceProximityEvent::create):
(WebCore::DeviceProximityEventInit::DeviceProximityEventInit): Deleted.
* Modules/proximity/DeviceProximityEvent.idl:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207187 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/proximity/DeviceProximityEvent.cpp
Source/WebCore/Modules/proximity/DeviceProximityEvent.h
Source/WebCore/Modules/proximity/DeviceProximityEvent.idl

index 2ed94cd..630eb63 100644 (file)
@@ -1,3 +1,21 @@
+2016-10-11  Chris Dumez  <cdumez@apple.com>
+
+        Update DeviceProximityEvent to stop using legacy [ConstructorTemplate=Event]
+        https://bugs.webkit.org/show_bug.cgi?id=163311
+
+        Reviewed by Ryosuke Niwa.
+
+        Update DeviceProximityEvent to stop using legacy [ConstructorTemplate=Event]
+        and use a regular constructor instead, as in the specification:
+        - https://www.w3.org/TR/2015/WD-proximity-20150903/#deviceproximityevent-interface
+
+        * Modules/proximity/DeviceProximityEvent.cpp:
+        (WebCore::DeviceProximityEvent::DeviceProximityEvent):
+        * Modules/proximity/DeviceProximityEvent.h:
+        (WebCore::DeviceProximityEvent::create):
+        (WebCore::DeviceProximityEventInit::DeviceProximityEventInit): Deleted.
+        * Modules/proximity/DeviceProximityEvent.idl:
+
 2016-10-11  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
 
         Unreviewed, EFL build fix because of r207173.
index e32c0cb..06bf01e 100644 (file)
@@ -39,11 +39,11 @@ DeviceProximityEvent::DeviceProximityEvent(const AtomicString& eventType, const
 {
 }
 
-DeviceProximityEvent::DeviceProximityEvent(const AtomicString& eventType, const DeviceProximityEventInit& initializer)
-    : Event(eventType, initializer)
-    , m_value(initializer.value)
-    , m_min(initializer.min)
-    , m_max(initializer.max)
+DeviceProximityEvent::DeviceProximityEvent(const AtomicString& eventType, const Init& initializer, IsTrusted isTrusted)
+    : Event(eventType, initializer, isTrusted)
+    , m_value(initializer.value ? *initializer.value : std::numeric_limits<double>::infinity())
+    , m_min(initializer.min ? *initializer.min : -std::numeric_limits<double>::infinity())
+    , m_max(initializer.max ? *initializer.max : std::numeric_limits<double>::infinity())
 {
 }
 
index e297c6e..9592cbf 100644 (file)
 
 namespace WebCore {
 
-struct DeviceProximityEventInit : public EventInit {
-    DeviceProximityEventInit()
-        : value(std::numeric_limits<double>::infinity())
-        , min(-std::numeric_limits<double>::infinity())
-        , max(std::numeric_limits<double>::infinity())
-    {
-        // Default value of bubbles is true by the Proximity Events spec.
-        // http://www.w3.org/TR/proximity/#deviceproximityevent-interface
-        bubbles = true;
-    };
-
-    double value;
-    double min;
-    double max;
-};
-
 class DeviceProximityEvent : public Event {
 public:
     ~DeviceProximityEvent() { }
@@ -56,9 +40,15 @@ public:
         return adoptRef(*new DeviceProximityEvent(eventType, value, min, max));
     }
 
-    static Ref<DeviceProximityEvent> create(const AtomicString& type, const DeviceProximityEventInit& initializer)
+    struct Init : EventInit {
+        Optional<double> value;
+        Optional<double> min;
+        Optional<double> max;
+    };
+
+    static Ref<DeviceProximityEvent> create(const AtomicString& type, const Init& initializer, IsTrusted isTrusted = IsTrusted::No)
     {
-        return adoptRef(*new DeviceProximityEvent(type, initializer));
+        return adoptRef(*new DeviceProximityEvent(type, initializer, isTrusted));
     }
 
     double value() { return m_value; }
@@ -70,7 +60,7 @@ public:
 private:
     DeviceProximityEvent();
     DeviceProximityEvent(const AtomicString& eventType, const double value, const double min, const double max);
-    DeviceProximityEvent(const AtomicString& eventType, const DeviceProximityEventInit&);
+    DeviceProximityEvent(const AtomicString& eventType, const Init&, IsTrusted);
 
     double m_value;
     double m_min;
index 4354fc8..7ecbfe7 100644 (file)
 
 [
     Conditional=PROXIMITY_EVENTS,
-    ConstructorTemplate=Event,
+    Constructor(DOMString type, optional DeviceProximityEventInit eventInitDict),
 ] interface DeviceProximityEvent : Event {
-    [InitializedByEventConstructor] readonly attribute unrestricted double value;
-    [InitializedByEventConstructor] readonly attribute unrestricted double min;
-    [InitializedByEventConstructor] readonly attribute unrestricted double max;
+    readonly attribute unrestricted double value;
+    readonly attribute unrestricted double min;
+    readonly attribute unrestricted double max;
 };
 
+dictionary DeviceProximityEventInit : EventInit {
+    double value;
+    double min;
+    double max;
+};