Chromium Code Reviews| 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) { |
| 271 | |
|
tkent
2016/06/02 04:38:00
nit: This blank line doesn't look helpful to me.
hayato
2016/06/02 04:47:44
Done
| |
| 268 EventTarget* adjustedRelatedTarget = findRelatedNode(treeScopeEventConte xt->treeScope(), relatedNodeMap); | 272 EventTarget* adjustedRelatedTarget = findRelatedNode(treeScopeEventConte xt->treeScope(), relatedNodeMap); |
| 269 ASSERT(adjustedRelatedTarget); | 273 ASSERT(adjustedRelatedTarget); |
| 270 treeScopeEventContext.get()->setRelatedTarget(adjustedRelatedTarget); | 274 treeScopeEventContext.get()->setRelatedTarget(adjustedRelatedTarget); |
| 271 } | 275 } |
| 272 | |
| 273 shrinkIfNeeded(target, *relatedTarget); | |
| 274 } | 276 } |
| 275 | 277 |
| 276 void EventPath::shrinkIfNeeded(const Node& target, const EventTarget& relatedTar get) | 278 void EventPath::shrinkForRelatedTarget(const Node& target, const Node& relatedTa rget) |
| 277 { | 279 { |
| 278 // Synthetic mouse events can have a relatedTarget which is identical to the target. | 280 if (!target.isInShadowTree() && !relatedTarget.isInShadowTree()) |
| 279 bool targetIsIdenticalToToRelatedTarget = (&target == &relatedTarget); | 281 return; |
| 280 | |
| 281 for (size_t i = 0; i < size(); ++i) { | 282 for (size_t i = 0; i < size(); ++i) { |
| 282 if (targetIsIdenticalToToRelatedTarget) { | 283 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. | 284 // Event dispatching should be stopped here. |
| 289 shrink(i); | 285 shrink(i); |
| 290 break; | 286 break; |
| 291 } | 287 } |
| 292 } | 288 } |
| 293 } | 289 } |
| 294 | 290 |
| 295 void EventPath::adjustForTouchEvent(TouchEvent& touchEvent) | 291 void EventPath::adjustForTouchEvent(TouchEvent& touchEvent) |
| 296 { | 292 { |
| 297 HeapVector<Member<TouchList>> adjustedTouches; | 293 HeapVector<Member<TouchList>> adjustedTouches; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 DEFINE_TRACE(EventPath) | 363 DEFINE_TRACE(EventPath) |
| 368 { | 364 { |
| 369 visitor->trace(m_nodeEventContexts); | 365 visitor->trace(m_nodeEventContexts); |
| 370 visitor->trace(m_node); | 366 visitor->trace(m_node); |
| 371 visitor->trace(m_event); | 367 visitor->trace(m_event); |
| 372 visitor->trace(m_treeScopeEventContexts); | 368 visitor->trace(m_treeScopeEventContexts); |
| 373 visitor->trace(m_windowEventContext); | 369 visitor->trace(m_windowEventContext); |
| 374 } | 370 } |
| 375 | 371 |
| 376 } // namespace blink | 372 } // namespace blink |
| OLD | NEW |