OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) | 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) |
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) | 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) |
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 if (e == this) | 229 if (e == this) |
230 return; | 230 return; |
231 m_underlyingEvent = ue; | 231 m_underlyingEvent = ue; |
232 } | 232 } |
233 | 233 |
234 void Event::initEventPath(Node& node) | 234 void Event::initEventPath(Node& node) |
235 { | 235 { |
236 m_eventPath = adoptPtrWillBeNoop(new EventPath(node, this)); | 236 m_eventPath = adoptPtrWillBeNoop(new EventPath(node, this)); |
237 } | 237 } |
238 | 238 |
239 PassRefPtrWillBeRawPtr<StaticNodeList> Event::path() const | 239 WillBeHeapVector<RefPtrWillBeRawPtr<EventTarget>> Event::path() const |
240 { | 240 { |
241 if (!m_currentTarget) { | 241 if (!m_currentTarget) { |
242 ASSERT(m_eventPhase == Event::NONE); | 242 ASSERT(m_eventPhase == Event::NONE); |
243 if (!m_eventPath) { | 243 if (!m_eventPath) { |
244 // Before dispatching the event | 244 // Before dispatching the event |
245 return StaticNodeList::createEmpty(); | 245 return WillBeHeapVector<RefPtrWillBeRawPtr<EventTarget>>(); |
246 } | 246 } |
247 ASSERT(!m_eventPath->isEmpty()); | 247 ASSERT(!m_eventPath->isEmpty()); |
248 // After dispatching the event | 248 // After dispatching the event |
249 return m_eventPath->last().treeScopeEventContext().ensureEventPath(*m_ev
entPath); | 249 return m_eventPath->last().treeScopeEventContext().ensureEventPath(*m_ev
entPath); |
250 } | 250 } |
251 if (!m_currentTarget->toNode()) | 251 |
252 return StaticNodeList::createEmpty(); | 252 if (Node* node = m_currentTarget->toNode()) { |
253 Node* node = m_currentTarget->toNode(); | 253 ASSERT(m_eventPath); |
254 size_t eventPathSize = m_eventPath->size(); | 254 size_t eventPathSize = m_eventPath->size(); |
255 for (size_t i = 0; i < eventPathSize; ++i) { | 255 for (size_t i = 0; i < eventPathSize; ++i) { |
256 if (node == (*m_eventPath)[i].node()) { | 256 if (node == (*m_eventPath)[i].node()) { |
257 return (*m_eventPath)[i].treeScopeEventContext().ensureEventPath(*m_
eventPath); | 257 return (*m_eventPath)[i].treeScopeEventContext().ensureEventPath
(*m_eventPath); |
| 258 } |
258 } | 259 } |
| 260 ASSERT_NOT_REACHED(); |
259 } | 261 } |
260 return StaticNodeList::createEmpty(); | 262 |
| 263 // Returns [window] for events that are directly dispatched to the window ob
ject; |
| 264 // e.g., window.load, pageshow, etc. |
| 265 if (LocalDOMWindow* window = m_currentTarget->toDOMWindow()) |
| 266 return WillBeHeapVector<RefPtrWillBeRawPtr<EventTarget>>(1, window); |
| 267 |
| 268 return WillBeHeapVector<RefPtrWillBeRawPtr<EventTarget>>(); |
261 } | 269 } |
262 | 270 |
263 EventTarget* Event::currentTarget() const | 271 EventTarget* Event::currentTarget() const |
264 { | 272 { |
265 if (!m_currentTarget) | 273 if (!m_currentTarget) |
266 return 0; | 274 return 0; |
267 Node* node = m_currentTarget->toNode(); | 275 Node* node = m_currentTarget->toNode(); |
268 if (node && node->isSVGElement()) { | 276 if (node && node->isSVGElement()) { |
269 if (SVGElement* svgElement = toSVGElement(node)->correspondingElement()) | 277 if (SVGElement* svgElement = toSVGElement(node)->correspondingElement()) |
270 return svgElement; | 278 return svgElement; |
271 } | 279 } |
272 return m_currentTarget.get(); | 280 return m_currentTarget.get(); |
273 } | 281 } |
274 | 282 |
275 void Event::trace(Visitor* visitor) | 283 void Event::trace(Visitor* visitor) |
276 { | 284 { |
277 visitor->trace(m_currentTarget); | 285 visitor->trace(m_currentTarget); |
278 visitor->trace(m_target); | 286 visitor->trace(m_target); |
279 visitor->trace(m_underlyingEvent); | 287 visitor->trace(m_underlyingEvent); |
280 visitor->trace(m_eventPath); | 288 visitor->trace(m_eventPath); |
281 } | 289 } |
282 | 290 |
283 } // namespace blink | 291 } // namespace blink |
OLD | NEW |