initial import
[vuplus_webkit] / Source / WebCore / dom / HashChangeEvent.h
1 /*
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 "Event.h"
25 #include "EventNames.h"
26
27 namespace WebCore {
28
29 struct HashChangeEventInit : public EventInit {
30     HashChangeEventInit()
31     {
32     };
33
34     String oldURL;
35     String newURL;
36 };
37
38 class HashChangeEvent : public Event {
39 public:
40     virtual bool isHashChangeEvent() const { return true; }
41
42     static PassRefPtr<HashChangeEvent> create()
43     {
44         return adoptRef(new HashChangeEvent);
45     }
46
47     static PassRefPtr<HashChangeEvent> create(const String& oldURL, const String& newURL)
48     {
49         return adoptRef(new HashChangeEvent(oldURL, newURL));
50     }
51
52     static PassRefPtr<HashChangeEvent> create(const AtomicString& type, const HashChangeEventInit& initializer)
53     {
54         return adoptRef(new HashChangeEvent(type, initializer));
55     }
56
57     void initHashChangeEvent(const AtomicString& eventType, bool canBubble, bool cancelable, const String& oldURL, const String& newURL)
58     {
59         if (dispatched())
60             return;
61
62         initEvent(eventType, canBubble, cancelable);
63
64         m_oldURL = oldURL;
65         m_newURL = newURL;
66     }
67
68     const String& oldURL() const { return m_oldURL; }
69     const String& newURL() const { return m_newURL; }
70
71 private:
72     HashChangeEvent()
73     {
74     }
75
76     HashChangeEvent(const String& oldURL, const String& newURL)
77         : Event(eventNames().hashchangeEvent, false, false)
78         , m_oldURL(oldURL)
79         , m_newURL(newURL)
80     {
81     }
82
83     HashChangeEvent(const AtomicString& type, const HashChangeEventInit& initializer)
84         : Event(type, initializer)
85         , m_oldURL(initializer.oldURL)
86         , m_newURL(initializer.newURL)
87     {
88     }
89
90     String m_oldURL;
91     String m_newURL;
92 };
93
94 } // namespace WebCore
95
96 #endif // HashChangeEvent_h