tizen beta release
[profile/ivi/webkit-efl.git] / Source / WebCore / dom / UIEvent.cpp
1 /*
2  * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3  * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4  * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5  * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 #include "config.h"
24 #include "UIEvent.h"
25
26 #include "Console.h"
27 #include "DOMWindow.h"
28 #include "EventDispatcher.h"
29
30 namespace WebCore {
31
32 UIEvent::UIEvent()
33     : m_detail(0)
34 {
35 }
36
37 UIEvent::UIEvent(const AtomicString& eventType, bool canBubbleArg, bool cancelableArg, PassRefPtr<AbstractView> viewArg, int detailArg)
38     : Event(eventType, canBubbleArg, cancelableArg)
39     , m_view(viewArg)
40     , m_detail(detailArg)
41 {
42 }
43
44 UIEvent::~UIEvent()
45 {
46 }
47
48 void UIEvent::initUIEvent(const AtomicString& typeArg, bool canBubbleArg, bool cancelableArg, PassRefPtr<AbstractView> viewArg, int detailArg)
49 {
50     if (dispatched())
51         return;
52
53     initEvent(typeArg, canBubbleArg, cancelableArg);
54
55     m_view = viewArg;
56     m_detail = detailArg;
57 }
58
59 bool UIEvent::isUIEvent() const
60 {
61     return true;
62 }
63
64 const AtomicString& UIEvent::interfaceName() const
65 {
66     return eventNames().interfaceForUIEvent;
67 }
68
69 int UIEvent::keyCode() const
70 {
71     return 0;
72 }
73
74 int UIEvent::charCode() const
75 {
76     return 0;
77 }
78
79 int UIEvent::layerX()
80 {
81     warnDeprecatedLayerXYUsage();
82     return 0;
83 }
84
85 int UIEvent::layerY()
86 {
87     warnDeprecatedLayerXYUsage();
88     return 0;
89 }
90
91 int UIEvent::pageX() const
92 {
93     return 0;
94 }
95
96 int UIEvent::pageY() const
97 {
98     return 0;
99 }
100
101 int UIEvent::which() const
102 {
103     return 0;
104 }
105
106 void UIEvent::warnDeprecatedLayerXYUsage()
107 {
108     DEFINE_STATIC_LOCAL(String, consoleMessage , ("event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future."));
109     if (m_view)
110         m_view->console()->addMessage(JSMessageSource, LogMessageType, WarningMessageLevel, consoleMessage, 1, String());
111 }
112
113 PassRefPtr<FocusInEventDispatchMediator> FocusInEventDispatchMediator::create(PassRefPtr<Event> event, PassRefPtr<Node> oldFocusedNode)
114 {
115     return adoptRef(new FocusInEventDispatchMediator(event, oldFocusedNode));
116 }
117
118 FocusInEventDispatchMediator::FocusInEventDispatchMediator(PassRefPtr<Event> event, PassRefPtr<Node> oldFocusedNode)
119     : EventDispatchMediator(event)
120     , m_oldFocusedNode(oldFocusedNode)
121 {
122 }
123
124 bool FocusInEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
125 {
126     dispatcher->adjustRelatedTarget(event(), m_oldFocusedNode);
127     return EventDispatchMediator::dispatchEvent(dispatcher);
128 }
129
130 PassRefPtr<FocusOutEventDispatchMediator> FocusOutEventDispatchMediator::create(PassRefPtr<Event> event, PassRefPtr<Node> newFocusedNode)
131 {
132     return adoptRef(new FocusOutEventDispatchMediator(event, newFocusedNode));
133 }
134
135 FocusOutEventDispatchMediator::FocusOutEventDispatchMediator(PassRefPtr<Event> event, PassRefPtr<Node> newFocusedNode)
136     : EventDispatchMediator(event)
137     , m_newFocusedNode(newFocusedNode)
138 {
139 }
140
141 bool FocusOutEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
142 {
143     dispatcher->adjustRelatedTarget(event(), m_newFocusedNode);
144     return EventDispatchMediator::dispatchEvent(dispatcher);
145 }
146
147 } // namespace WebCore