blob: dee8c10fcceff0a5098d7d6857f22b9a28e3d97c [file] [log] [blame]
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +01001/*
2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21#ifndef HashChangeEvent_h
22#define HashChangeEvent_h
23
24#include "core/dom/Event.h"
25#include "core/dom/EventNames.h"
26
27namespace WebCore {
28
29struct HashChangeEventInit : public EventInit {
30 HashChangeEventInit()
31 {
32 };
33
34 String oldURL;
35 String newURL;
36};
37
38class HashChangeEvent : public Event {
39public:
40 static PassRefPtr<HashChangeEvent> create()
41 {
42 return adoptRef(new HashChangeEvent);
43 }
44
45 static PassRefPtr<HashChangeEvent> create(const String& oldURL, const String& newURL)
46 {
47 return adoptRef(new HashChangeEvent(oldURL, newURL));
48 }
49
50 static PassRefPtr<HashChangeEvent> create(const AtomicString& type, const HashChangeEventInit& initializer)
51 {
52 return adoptRef(new HashChangeEvent(type, initializer));
53 }
54
55 void initHashChangeEvent(const AtomicString& eventType, bool canBubble, bool cancelable, const String& oldURL, const String& newURL)
56 {
57 if (dispatched())
58 return;
59
60 initEvent(eventType, canBubble, cancelable);
61
62 m_oldURL = oldURL;
63 m_newURL = newURL;
64 }
65
66 const String& oldURL() const { return m_oldURL; }
67 const String& newURL() const { return m_newURL; }
68
69 virtual const AtomicString& interfaceName() const { return eventNames().interfaceForHashChangeEvent; }
70
71private:
72 HashChangeEvent()
73 {
74 ScriptWrappable::init(this);
75 }
76
77 HashChangeEvent(const String& oldURL, const String& newURL)
78 : Event(eventNames().hashchangeEvent, false, false)
79 , m_oldURL(oldURL)
80 , m_newURL(newURL)
81 {
82 ScriptWrappable::init(this);
83 }
84
85 HashChangeEvent(const AtomicString& type, const HashChangeEventInit& initializer)
86 : Event(type, initializer)
87 , m_oldURL(initializer.oldURL)
88 , m_newURL(initializer.newURL)
89 {
90 ScriptWrappable::init(this);
91 }
92
93 String m_oldURL;
94 String m_newURL;
95};
96
97} // namespace WebCore
98
99#endif // HashChangeEvent_h