• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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/events/FocusEvent.h"
28 
29 #include "core/events/Event.h"
30 #include "core/events/EventDispatcher.h"
31 #include "core/events/EventRetargeter.h"
32 #include "core/events/ThreadLocalEventNames.h"
33 
34 namespace WebCore {
35 
FocusEventInit()36 FocusEventInit::FocusEventInit()
37     : relatedTarget(0)
38 {
39 }
40 
interfaceName() const41 const AtomicString& FocusEvent::interfaceName() const
42 {
43     return EventNames::FocusEvent;
44 }
45 
isFocusEvent() const46 bool FocusEvent::isFocusEvent() const
47 {
48     return true;
49 }
50 
FocusEvent()51 FocusEvent::FocusEvent()
52 {
53     ScriptWrappable::init(this);
54 }
55 
FocusEvent(const AtomicString & type,bool canBubble,bool cancelable,PassRefPtr<AbstractView> view,int detail,EventTarget * relatedTarget)56 FocusEvent::FocusEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView> view, int detail, EventTarget* relatedTarget)
57     : UIEvent(type, canBubble, cancelable, view, detail)
58     , m_relatedTarget(relatedTarget)
59 {
60     ScriptWrappable::init(this);
61 }
62 
FocusEvent(const AtomicString & type,const FocusEventInit & initializer)63 FocusEvent::FocusEvent(const AtomicString& type, const FocusEventInit& initializer)
64     : UIEvent(type, initializer)
65     , m_relatedTarget(initializer.relatedTarget)
66 {
67     ScriptWrappable::init(this);
68 }
69 
create(PassRefPtr<FocusEvent> focusEvent)70 PassRefPtr<FocusEventDispatchMediator> FocusEventDispatchMediator::create(PassRefPtr<FocusEvent> focusEvent)
71 {
72     return adoptRef(new FocusEventDispatchMediator(focusEvent));
73 }
74 
FocusEventDispatchMediator(PassRefPtr<FocusEvent> focusEvent)75 FocusEventDispatchMediator::FocusEventDispatchMediator(PassRefPtr<FocusEvent> focusEvent)
76     : EventDispatchMediator(focusEvent)
77 {
78 }
79 
dispatchEvent(EventDispatcher * dispatcher) const80 bool FocusEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
81 {
82     EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event());
83     return EventDispatchMediator::dispatchEvent(dispatcher);
84 }
85 
create(PassRefPtr<FocusEvent> focusEvent)86 PassRefPtr<BlurEventDispatchMediator> BlurEventDispatchMediator::create(PassRefPtr<FocusEvent> focusEvent)
87 {
88     return adoptRef(new BlurEventDispatchMediator(focusEvent));
89 }
90 
BlurEventDispatchMediator(PassRefPtr<FocusEvent> focusEvent)91 BlurEventDispatchMediator::BlurEventDispatchMediator(PassRefPtr<FocusEvent> focusEvent)
92     : EventDispatchMediator(focusEvent)
93 {
94 }
95 
dispatchEvent(EventDispatcher * dispatcher) const96 bool BlurEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
97 {
98     EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event());
99     return EventDispatchMediator::dispatchEvent(dispatcher);
100 }
101 
create(PassRefPtr<FocusEvent> focusEvent)102 PassRefPtr<FocusInEventDispatchMediator> FocusInEventDispatchMediator::create(PassRefPtr<FocusEvent> focusEvent)
103 {
104     return adoptRef(new FocusInEventDispatchMediator(focusEvent));
105 }
106 
FocusInEventDispatchMediator(PassRefPtr<FocusEvent> focusEvent)107 FocusInEventDispatchMediator::FocusInEventDispatchMediator(PassRefPtr<FocusEvent> focusEvent)
108     : EventDispatchMediator(focusEvent)
109 {
110 }
111 
dispatchEvent(EventDispatcher * dispatcher) const112 bool FocusInEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
113 {
114     EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event());
115     return EventDispatchMediator::dispatchEvent(dispatcher);
116 }
117 
create(PassRefPtr<FocusEvent> focusEvent)118 PassRefPtr<FocusOutEventDispatchMediator> FocusOutEventDispatchMediator::create(PassRefPtr<FocusEvent> focusEvent)
119 {
120     return adoptRef(new FocusOutEventDispatchMediator(focusEvent));
121 }
122 
FocusOutEventDispatchMediator(PassRefPtr<FocusEvent> focusEvent)123 FocusOutEventDispatchMediator::FocusOutEventDispatchMediator(PassRefPtr<FocusEvent> focusEvent)
124     : EventDispatchMediator(focusEvent)
125 {
126 }
127 
dispatchEvent(EventDispatcher * dispatcher) const128 bool FocusOutEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
129 {
130     EventRetargeter::adjustForFocusEvent(dispatcher->node(), *event());
131     return EventDispatchMediator::dispatchEvent(dispatcher);
132 }
133 
134 } // namespace WebCore
135