| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 251 |
| 252 void EventPath::adjustForRelatedTarget(Node& target, EventTarget* relatedTarget) | 252 void EventPath::adjustForRelatedTarget(Node& target, EventTarget* relatedTarget) |
| 253 { | 253 { |
| 254 if (!relatedTarget) | 254 if (!relatedTarget) |
| 255 return; | 255 return; |
| 256 Node* relatedNode = relatedTarget->toNode(); | 256 Node* relatedNode = relatedTarget->toNode(); |
| 257 if (!relatedNode) | 257 if (!relatedNode) |
| 258 return; | 258 return; |
| 259 if (target.document() != relatedNode->document()) | 259 if (target.document() != relatedNode->document()) |
| 260 return; | 260 return; |
| 261 if (!target.inShadowIncludingDocument() || !relatedNode->inShadowIncludingDo
cument()) | 261 retargetRelatedTarget(*relatedNode); |
| 262 return; | 262 shrinkForRelatedTarget(target, *relatedNode); |
| 263 } |
| 263 | 264 |
| 265 void EventPath::retargetRelatedTarget(const Node& relatedTargetNode) |
| 266 { |
| 264 RelatedTargetMap relatedNodeMap; | 267 RelatedTargetMap relatedNodeMap; |
| 265 buildRelatedNodeMap(*relatedNode, relatedNodeMap); | 268 buildRelatedNodeMap(relatedTargetNode, relatedNodeMap); |
| 266 | 269 |
| 267 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) { | 270 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) { |
| 268 EventTarget* adjustedRelatedTarget = findRelatedNode(treeScopeEventConte
xt->treeScope(), relatedNodeMap); | 271 EventTarget* adjustedRelatedTarget = findRelatedNode(treeScopeEventConte
xt->treeScope(), relatedNodeMap); |
| 269 ASSERT(adjustedRelatedTarget); | 272 ASSERT(adjustedRelatedTarget); |
| 270 treeScopeEventContext.get()->setRelatedTarget(adjustedRelatedTarget); | 273 treeScopeEventContext.get()->setRelatedTarget(adjustedRelatedTarget); |
| 271 } | 274 } |
| 272 | |
| 273 shrinkIfNeeded(target, *relatedTarget); | |
| 274 } | 275 } |
| 275 | 276 |
| 276 void EventPath::shrinkIfNeeded(const Node& target, const EventTarget& relatedTar
get) | 277 void EventPath::shrinkForRelatedTarget(const Node& target, const Node& relatedTa
rget) |
| 277 { | 278 { |
| 278 // Synthetic mouse events can have a relatedTarget which is identical to the
target. | 279 if (!target.isInShadowTree() && !relatedTarget.isInShadowTree()) |
| 279 bool targetIsIdenticalToToRelatedTarget = (&target == &relatedTarget); | 280 return; |
| 280 | |
| 281 for (size_t i = 0; i < size(); ++i) { | 281 for (size_t i = 0; i < size(); ++i) { |
| 282 if (targetIsIdenticalToToRelatedTarget) { | 282 if (at(i).target() == at(i).relatedTarget()) { |
| 283 if (target.treeScope().rootNode() == at(i).node()) { | |
| 284 shrink(i + 1); | |
| 285 break; | |
| 286 } | |
| 287 } else if (at(i).target() == at(i).relatedTarget()) { | |
| 288 // Event dispatching should be stopped here. | 283 // Event dispatching should be stopped here. |
| 289 shrink(i); | 284 shrink(i); |
| 290 break; | 285 break; |
| 291 } | 286 } |
| 292 } | 287 } |
| 293 } | 288 } |
| 294 | 289 |
| 295 void EventPath::adjustForTouchEvent(TouchEvent& touchEvent) | 290 void EventPath::adjustForTouchEvent(TouchEvent& touchEvent) |
| 296 { | 291 { |
| 297 HeapVector<Member<TouchList>> adjustedTouches; | 292 HeapVector<Member<TouchList>> adjustedTouches; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 DEFINE_TRACE(EventPath) | 362 DEFINE_TRACE(EventPath) |
| 368 { | 363 { |
| 369 visitor->trace(m_nodeEventContexts); | 364 visitor->trace(m_nodeEventContexts); |
| 370 visitor->trace(m_node); | 365 visitor->trace(m_node); |
| 371 visitor->trace(m_event); | 366 visitor->trace(m_event); |
| 372 visitor->trace(m_treeScopeEventContexts); | 367 visitor->trace(m_treeScopeEventContexts); |
| 373 visitor->trace(m_windowEventContext); | 368 visitor->trace(m_windowEventContext); |
| 374 } | 369 } |
| 375 | 370 |
| 376 } // namespace blink | 371 } // namespace blink |
| OLD | NEW |