summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/CustomEvent.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/dom/CustomEvent.h')
-rw-r--r--Source/WebCore/dom/CustomEvent.h47
1 files changed, 22 insertions, 25 deletions
diff --git a/Source/WebCore/dom/CustomEvent.h b/Source/WebCore/dom/CustomEvent.h
index 7f4c1cf04..483495f1e 100644
--- a/Source/WebCore/dom/CustomEvent.h
+++ b/Source/WebCore/dom/CustomEvent.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 CustomEvent_h
-#define CustomEvent_h
+#pragma once
#include "Event.h"
#include "SerializedScriptValue.h"
@@ -32,41 +31,39 @@
namespace WebCore {
-struct CustomEventInit : public EventInit {
- CustomEventInit();
-
- Deprecated::ScriptValue detail;
-};
-
-class CustomEvent : public Event {
+class CustomEvent final : public Event {
public:
virtual ~CustomEvent();
- static PassRefPtr<CustomEvent> create()
+ static Ref<CustomEvent> create(IsTrusted isTrusted = IsTrusted::No)
{
- return adoptRef(new CustomEvent);
+ return adoptRef(*new CustomEvent(isTrusted));
}
- static PassRefPtr<CustomEvent> create(const AtomicString& type, const CustomEventInit& initializer)
+ struct Init : EventInit {
+ JSC::JSValue detail;
+ };
+
+ static Ref<CustomEvent> create(JSC::ExecState& state, const AtomicString& type, const Init& initializer, IsTrusted isTrusted = IsTrusted::No)
{
- return adoptRef(new CustomEvent(type, initializer));
+ return adoptRef(*new CustomEvent(state, type, initializer, isTrusted));
}
- void initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, const Deprecated::ScriptValue& detail);
+ void initCustomEvent(JSC::ExecState&, const AtomicString& type, bool canBubble, bool cancelable, JSC::JSValue detail = JSC::JSValue::JSUndefined);
- virtual EventInterface eventInterface() const;
+ EventInterface eventInterface() const override;
- const Deprecated::ScriptValue& detail() const { return m_detail; }
- PassRefPtr<SerializedScriptValue> serializedScriptValue() { return m_serializedScriptValue; }
+ JSC::JSValue detail() const { return m_detail.jsValue(); }
+
+ RefPtr<SerializedScriptValue> trySerializeDetail(JSC::ExecState&);
private:
- CustomEvent();
- CustomEvent(const AtomicString& type, const CustomEventInit& initializer);
+ CustomEvent(IsTrusted);
+ CustomEvent(JSC::ExecState&, const AtomicString& type, const Init& initializer, IsTrusted);
- Deprecated::ScriptValue m_detail;
- RefPtr<SerializedScriptValue> m_serializedScriptValue;
+ Deprecated::ScriptValue m_detail; // FIXME: Why is it OK to use a strong reference here? What prevents a reference cycle?
+ RefPtr<SerializedScriptValue> m_serializedDetail;
+ bool m_triedToSerialize { false };
};
} // namespace WebCore
-
-#endif // CustomEvent_h