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

Side by Side Diff: third_party/WebKit/Source/core/events/EventPath.cpp

Issue 2384403002: Dispatch synthetic events even when target and relatedTarget are identical (Closed)
Patch Set: fix Created 4 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
« no previous file with comments | « third_party/WebKit/Source/core/events/EventPath.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 void EventPath::adjustForRelatedTarget(Node& target, 293 void EventPath::adjustForRelatedTarget(Node& target,
294 EventTarget* relatedTarget) { 294 EventTarget* relatedTarget) {
295 if (!relatedTarget) 295 if (!relatedTarget)
296 return; 296 return;
297 Node* relatedNode = relatedTarget->toNode(); 297 Node* relatedNode = relatedTarget->toNode();
298 if (!relatedNode) 298 if (!relatedNode)
299 return; 299 return;
300 if (target.document() != relatedNode->document()) 300 if (target.document() != relatedNode->document())
301 return; 301 return;
302 retargetRelatedTarget(*relatedNode); 302 retargetRelatedTarget(*relatedNode);
303 shrinkForRelatedTarget(target, *relatedNode); 303 shrinkForRelatedTarget(target);
304 } 304 }
305 305
306 void EventPath::retargetRelatedTarget(const Node& relatedTargetNode) { 306 void EventPath::retargetRelatedTarget(const Node& relatedTargetNode) {
307 RelatedTargetMap relatedNodeMap; 307 RelatedTargetMap relatedNodeMap;
308 buildRelatedNodeMap(relatedTargetNode, relatedNodeMap); 308 buildRelatedNodeMap(relatedTargetNode, relatedNodeMap);
309 309
310 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) { 310 for (const auto& treeScopeEventContext : m_treeScopeEventContexts) {
311 EventTarget* adjustedRelatedTarget = 311 EventTarget* adjustedRelatedTarget =
312 findRelatedNode(treeScopeEventContext->treeScope(), relatedNodeMap); 312 findRelatedNode(treeScopeEventContext->treeScope(), relatedNodeMap);
313 DCHECK(adjustedRelatedTarget); 313 DCHECK(adjustedRelatedTarget);
314 treeScopeEventContext.get()->setRelatedTarget(adjustedRelatedTarget); 314 treeScopeEventContext.get()->setRelatedTarget(adjustedRelatedTarget);
315 } 315 }
316 } 316 }
317 317
318 void EventPath::shrinkForRelatedTarget(const Node& target, 318 bool EventPath::shouldStopEventPath(EventTarget& currentTarget,
319 const Node& relatedTarget) { 319 EventTarget& currentRelatedTarget,
320 if (!target.isInShadowTree() && !relatedTarget.isInShadowTree()) 320 const Node& target) {
321 return; 321 if (&currentTarget != &currentRelatedTarget)
322 return false;
323 if (m_event->isTrusted())
324 return true;
325 Node* currentTargetNode = currentTarget.toNode();
326 if (!currentTargetNode)
327 return false;
328 return currentTargetNode->treeScope() != target.treeScope();
329 }
330
331 void EventPath::shrinkForRelatedTarget(const Node& target) {
322 for (size_t i = 0; i < size(); ++i) { 332 for (size_t i = 0; i < size(); ++i) {
323 if (at(i).target() == at(i).relatedTarget()) { 333 if (shouldStopEventPath(*at(i).target(), *at(i).relatedTarget(), target)) {
324 // Event dispatching should be stopped here.
325 shrink(i); 334 shrink(i);
326 break; 335 break;
327 } 336 }
328 } 337 }
329 } 338 }
330 339
331 void EventPath::adjustForTouchEvent(TouchEvent& touchEvent) { 340 void EventPath::adjustForTouchEvent(TouchEvent& touchEvent) {
332 HeapVector<Member<TouchList>> adjustedTouches; 341 HeapVector<Member<TouchList>> adjustedTouches;
333 HeapVector<Member<TouchList>> adjustedTargetTouches; 342 HeapVector<Member<TouchList>> adjustedTargetTouches;
334 HeapVector<Member<TouchList>> adjustedChangedTouches; 343 HeapVector<Member<TouchList>> adjustedChangedTouches;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 420
412 DEFINE_TRACE(EventPath) { 421 DEFINE_TRACE(EventPath) {
413 visitor->trace(m_nodeEventContexts); 422 visitor->trace(m_nodeEventContexts);
414 visitor->trace(m_node); 423 visitor->trace(m_node);
415 visitor->trace(m_event); 424 visitor->trace(m_event);
416 visitor->trace(m_treeScopeEventContexts); 425 visitor->trace(m_treeScopeEventContexts);
417 visitor->trace(m_windowEventContext); 426 visitor->trace(m_windowEventContext);
418 } 427 }
419 428
420 } // namespace blink 429 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/EventPath.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698