Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(622)

Side by Side Diff: Source/core/events/EventContext.cpp

Issue 26558004: Revert 158219 "Move dom/*Event* to events to match the DOM vs. E..." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/1651/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/events/EventContext.h ('k') | Source/core/events/EventDispatchMediator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2010 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 COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 */
26
27 #include "config.h"
28 #include "core/events/EventContext.h"
29
30 #include "core/events/Event.h"
31 #include "core/events/FocusEvent.h"
32 #include "core/events/MouseEvent.h"
33 #include "core/dom/Node.h"
34 #include "core/dom/StaticNodeList.h"
35 #include "core/events/TouchEvent.h"
36 #include "core/dom/TouchList.h"
37
38 namespace WebCore {
39
40 EventContext::EventContext(PassRefPtr<Node> node, PassRefPtr<EventTarget> curren tTarget, PassRefPtr<EventTarget> target)
41 : m_node(node)
42 , m_currentTarget(currentTarget)
43 , m_target(target)
44 {
45 ASSERT(m_node);
46 ASSERT(!isUnreachableNode(m_target.get()));
47 }
48
49 EventContext::~EventContext()
50 {
51 }
52
53 void EventContext::adoptEventPath(Vector<RefPtr<Node> >& nodes)
54 {
55 m_eventPath = StaticNodeList::adopt(nodes);
56 }
57
58 void EventContext::handleLocalEvents(Event* event) const
59 {
60 event->setTarget(m_target.get());
61 event->setCurrentTarget(m_currentTarget.get());
62 m_node->handleLocalEvents(event);
63 }
64
65 bool EventContext::isMouseOrFocusEventContext() const
66 {
67 return false;
68 }
69
70 bool EventContext::isTouchEventContext() const
71 {
72 return false;
73 }
74
75 MouseOrFocusEventContext::MouseOrFocusEventContext(PassRefPtr<Node> node, PassRe fPtr<EventTarget> currentTarget, PassRefPtr<EventTarget> target)
76 : EventContext(node, currentTarget, target)
77 , m_relatedTarget(0)
78 {
79 }
80
81 MouseOrFocusEventContext::~MouseOrFocusEventContext()
82 {
83 }
84
85 void MouseOrFocusEventContext::handleLocalEvents(Event* event) const
86 {
87 ASSERT(event->isMouseEvent() || event->isFocusEvent());
88 if (m_relatedTarget.get() && event->isMouseEvent())
89 toMouseEvent(event)->setRelatedTarget(m_relatedTarget.get());
90 else if (m_relatedTarget.get() && event->isFocusEvent())
91 toFocusEvent(event)->setRelatedTarget(m_relatedTarget.get());
92 EventContext::handleLocalEvents(event);
93 }
94
95 bool MouseOrFocusEventContext::isMouseOrFocusEventContext() const
96 {
97 return true;
98 }
99
100 TouchEventContext::TouchEventContext(PassRefPtr<Node> node, PassRefPtr<EventTarg et> currentTarget, PassRefPtr<EventTarget> target)
101 : EventContext(node, currentTarget, target)
102 , m_touches(TouchList::create())
103 , m_targetTouches(TouchList::create())
104 , m_changedTouches(TouchList::create())
105 {
106 }
107
108 TouchEventContext::~TouchEventContext()
109 {
110 }
111
112 void TouchEventContext::handleLocalEvents(Event* event) const
113 {
114 #ifndef NDEBUG
115 checkReachability(m_touches.get());
116 checkReachability(m_targetTouches.get());
117 checkReachability(m_changedTouches.get());
118 #endif
119 ASSERT(event->isTouchEvent());
120 TouchEvent* touchEvent = toTouchEvent(event);
121 touchEvent->setTouches(m_touches);
122 touchEvent->setTargetTouches(m_targetTouches);
123 touchEvent->setChangedTouches(m_changedTouches);
124 EventContext::handleLocalEvents(event);
125 }
126
127 bool TouchEventContext::isTouchEventContext() const
128 {
129 return true;
130 }
131
132 #ifndef NDEBUG
133 void TouchEventContext::checkReachability(TouchList* touchList) const
134 {
135 for (size_t i = 0; i < touchList->length(); ++i)
136 ASSERT(touchList->item(i)->target()->toNode()->treeScope().isInclusiveAn cestorOf(m_node->treeScope()));
137 }
138 #endif
139
140 }
OLDNEW
« no previous file with comments | « Source/core/events/EventContext.h ('k') | Source/core/events/EventDispatchMediator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698