#pragma once
#include "Event.h"
#include "EventNames.h"
namespace WebCore {
class HashChangeEvent final : public Event {
public:
static Ref<HashChangeEvent> create(const String& oldURL, const String& newURL)
{
return adoptRef(*new HashChangeEvent(oldURL, newURL));
}
static Ref<HashChangeEvent> createForBindings()
{
return adoptRef(*new HashChangeEvent);
}
struct Init : EventInit {
String oldURL;
String newURL;
};
static Ref<HashChangeEvent> create(const AtomicString& type, const Init& initializer, IsTrusted isTrusted = IsTrusted::No)
{
return adoptRef(*new HashChangeEvent(type, initializer, isTrusted));
}
void initHashChangeEvent(const AtomicString& eventType, bool canBubble, bool cancelable, const String& oldURL, const String& newURL)
{
if (dispatched())
return;
initEvent(eventType, canBubble, cancelable);
m_oldURL = oldURL;
m_newURL = newURL;
}
const String& oldURL() const { return m_oldURL; }
const String& newURL() const { return m_newURL; }
EventInterface eventInterface() const override { return HashChangeEventInterfaceType; }
private:
HashChangeEvent()
{
}
HashChangeEvent(const String& oldURL, const String& newURL)
: Event(eventNames().hashchangeEvent, false, false)
, m_oldURL(oldURL)
, m_newURL(newURL)
{
}
HashChangeEvent(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
: Event(type, initializer, isTrusted)
, m_oldURL(initializer.oldURL)
, m_newURL(initializer.newURL)
{
}
String m_oldURL;
String m_newURL;
};
}