Use a 1-byte enum class for TextDirection
[WebKit-https.git] / Source / WebCore / dom / PopStateEvent.cpp
index 60e9ca7..82995f0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2009-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -13,7 +13,7 @@
  * 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
 #include "PopStateEvent.h"
 
 #include "EventNames.h"
+#include "History.h"
+#include <JavaScriptCore/JSCInlines.h>
 
 namespace WebCore {
 
-PopStateEventInit::PopStateEventInit()
-{
-}
-
-PopStateEvent::PopStateEvent()
-    : Event(eventNames().popstateEvent, false, true)
-    , m_serializedState(0)
-{
-}
-
-PopStateEvent::PopStateEvent(const AtomicString& type, const PopStateEventInit& initializer)
-    : Event(type, initializer)
+PopStateEvent::PopStateEvent(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
+    : Event(type, initializer, isTrusted)
     , m_state(initializer.state)
-    , m_serializedState(0)
 {
 }
 
-PopStateEvent::PopStateEvent(ScriptValue state)
-    : Event(eventNames().popstateEvent, false, true)
-    , m_state(state)
-    , m_serializedState(0)
+PopStateEvent::PopStateEvent(RefPtr<SerializedScriptValue>&& serializedState, History* history)
+    : Event(eventNames().popstateEvent, false, false)
+    , m_serializedState(WTFMove(serializedState))
+    , m_history(history)
 {
 }
 
-PopStateEvent::PopStateEvent(PassRefPtr<SerializedScriptValue> serializedState)
-    : Event(eventNames().popstateEvent, false, true)
-    , m_serializedState(serializedState)
-{
-}
-
-PopStateEvent::~PopStateEvent()
-{
-}
+PopStateEvent::~PopStateEvent() = default;
 
-PassRefPtr<PopStateEvent> PopStateEvent::create()
+Ref<PopStateEvent> PopStateEvent::create(RefPtr<SerializedScriptValue>&& serializedState, History* history)
 {
-    return adoptRef(new PopStateEvent);
+    return adoptRef(*new PopStateEvent(WTFMove(serializedState), history));
 }
 
-PassRefPtr<PopStateEvent> PopStateEvent::create(ScriptValue state)
+Ref<PopStateEvent> PopStateEvent::create(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
 {
-    return adoptRef(new PopStateEvent(state));
+    return adoptRef(*new PopStateEvent(type, initializer, isTrusted));
 }
 
-PassRefPtr<PopStateEvent> PopStateEvent::create(PassRefPtr<SerializedScriptValue> serializedState)
+Ref<PopStateEvent> PopStateEvent::createForBindings()
 {
-    return adoptRef(new PopStateEvent(serializedState));
+    return adoptRef(*new PopStateEvent);
 }
 
-PassRefPtr<PopStateEvent> PopStateEvent::create(const AtomicString& type, const PopStateEventInit& initializer)
+RefPtr<SerializedScriptValue> PopStateEvent::trySerializeState(JSC::ExecState& executionState)
 {
-    return adoptRef(new PopStateEvent(type, initializer));
+    ASSERT(m_state);
+    
+    if (!m_serializedState && !m_triedToSerialize) {
+        m_serializedState = SerializedScriptValue::create(executionState, m_state, SerializationErrorMode::NonThrowing);
+        m_triedToSerialize = true;
+    }
+    
+    return m_serializedState;
 }
 
-void PopStateEvent::initPopStateEvent(const AtomicString& type, bool canBubble, bool cancelable, ScriptValue state)
+EventInterface PopStateEvent::eventInterface() const
 {
-    if (dispatched())
-        return;
-
-    initEvent(type, canBubble, cancelable);
-
-    m_state = state;
+    return PopStateEventInterfaceType;
 }
 
 } // namespace WebCore