blob: 6d9569d4d9a085b796e3e37f5fd1a10eb8e47e36 [file] [log] [blame]
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +01001/*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "core/dom/FocusEvent.h"
28
29#include "core/dom/Event.h"
30#include "core/dom/EventDispatcher.h"
31#include "core/dom/EventNames.h"
32#include "core/dom/EventRetargeter.h"
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010033
34namespace WebCore {
35
36FocusEventInit::FocusEventInit()
37 : relatedTarget(0)
38{
39}
40
41const AtomicString& FocusEvent::interfaceName() const
42{
43 return eventNames().interfaceForFocusEvent;
44}
45
46bool FocusEvent::isFocusEvent() const
47{
48 return true;
49}
50
51FocusEvent::FocusEvent()
52{
53 ScriptWrappable::init(this);
54}
55
Ben Murdoch02772c62013-07-26 10:21:05 +010056FocusEvent::FocusEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView> view, int detail, EventTarget* relatedTarget)
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010057 : UIEvent(type, canBubble, cancelable, view, detail)
58 , m_relatedTarget(relatedTarget)
59{
60 ScriptWrappable::init(this);
61}
62
63FocusEvent::FocusEvent(const AtomicString& type, const FocusEventInit& initializer)
64 : UIEvent(type, initializer)
65 , m_relatedTarget(initializer.relatedTarget)
66{
67 ScriptWrappable::init(this);
68}
69
70PassRefPtr<FocusEventDispatchMediator> FocusEventDispatchMediator::create(PassRefPtr<FocusEvent> focusEvent)
71{
72 return adoptRef(new FocusEventDispatchMediator(focusEvent));
73}
74
75FocusEventDispatchMediator::FocusEventDispatchMediator(PassRefPtr<FocusEvent> focusEvent)
76 : EventDispatchMediator(focusEvent)
77{
78}
79
80bool FocusEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
81{
82 EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event());
83 return EventDispatchMediator::dispatchEvent(dispatcher);
84}
85
86PassRefPtr<BlurEventDispatchMediator> BlurEventDispatchMediator::create(PassRefPtr<FocusEvent> focusEvent)
87{
88 return adoptRef(new BlurEventDispatchMediator(focusEvent));
89}
90
91BlurEventDispatchMediator::BlurEventDispatchMediator(PassRefPtr<FocusEvent> focusEvent)
92 : EventDispatchMediator(focusEvent)
93{
94}
95
96bool BlurEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
97{
98 EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event());
99 return EventDispatchMediator::dispatchEvent(dispatcher);
100}
101
102PassRefPtr<FocusInEventDispatchMediator> FocusInEventDispatchMediator::create(PassRefPtr<FocusEvent> focusEvent)
103{
104 return adoptRef(new FocusInEventDispatchMediator(focusEvent));
105}
106
107FocusInEventDispatchMediator::FocusInEventDispatchMediator(PassRefPtr<FocusEvent> focusEvent)
108 : EventDispatchMediator(focusEvent)
109{
110}
111
112bool FocusInEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
113{
114 EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event());
115 return EventDispatchMediator::dispatchEvent(dispatcher);
116}
117
118PassRefPtr<FocusOutEventDispatchMediator> FocusOutEventDispatchMediator::create(PassRefPtr<FocusEvent> focusEvent)
119{
120 return adoptRef(new FocusOutEventDispatchMediator(focusEvent));
121}
122
123FocusOutEventDispatchMediator::FocusOutEventDispatchMediator(PassRefPtr<FocusEvent> focusEvent)
124 : EventDispatchMediator(focusEvent)
125{
126}
127
128bool FocusOutEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
129{
130 EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event());
131 return EventDispatchMediator::dispatchEvent(dispatcher);
132}
133
134} // namespace WebCore