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

Unified Diff: third_party/WebKit/Source/core/input/PointerEventManager.cpp

Issue 1949563002: Retarget mouse event if the target is removed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Applying comments Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/events/Event.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/input/PointerEventManager.cpp
diff --git a/third_party/WebKit/Source/core/input/PointerEventManager.cpp b/third_party/WebKit/Source/core/input/PointerEventManager.cpp
index 1528d20163ce97e7746e7dda79ead3d038609fce..e199b2a2a363bf0019d3e1f42f05fbf883bb4a6f 100644
--- a/third_party/WebKit/Source/core/input/PointerEventManager.cpp
+++ b/third_party/WebKit/Source/core/input/PointerEventManager.cpp
@@ -81,6 +81,21 @@ PlatformMouseEvent mouseEventWithRegion(Node* node, const PlatformMouseEvent& mo
return newMouseEvent;
}
+void buildAncestorChain(
+ EventTarget* target,
+ HeapVector<Member<Node>, 20>* ancestors)
+{
+ if (!isInDocument(target))
+ return;
+ Node* targetNode = target->toNode();
+ DCHECK(targetNode);
+ targetNode->updateDistribution();
+ // Index 0 element in the ancestors arrays will be the corresponding
+ // target. So the root of their document will be their last element.
+ for (Node* node = targetNode; node; node = FlatTreeTraversal::parent(*node))
+ ancestors->append(node);
+}
+
void buildAncestorChainsAndFindCommonAncestors(
EventTarget* exitedTarget, EventTarget* enteredTarget,
HeapVector<Member<Node>, 20>* exitedAncestorsOut,
@@ -93,24 +108,8 @@ void buildAncestorChainsAndFindCommonAncestors(
DCHECK(exitedAncestorsCommonParentIndexOut);
DCHECK(enteredAncestorsCommonParentIndexOut);
- // Index 0 element in the ancestors arrays will be the corresponding
- // target. So the root of their document will be their last element.
-
- if (isInDocument(exitedTarget)) {
- Node* exitedNode = exitedTarget->toNode();
- DCHECK(exitedNode);
- exitedNode->updateDistribution();
- for (Node* node = exitedNode; node; node = FlatTreeTraversal::parent(*node))
- exitedAncestorsOut->append(node);
- }
-
- if (isInDocument(enteredTarget)) {
- Node* enteredNode = enteredTarget->toNode();
- DCHECK(enteredNode);
- enteredNode->updateDistribution();
- for (Node* node = enteredNode; node; node = FlatTreeTraversal::parent(*node))
- enteredAncestorsOut->append(node);
- }
+ buildAncestorChain(exitedTarget, exitedAncestorsOut);
+ buildAncestorChain(enteredTarget, enteredAncestorsOut);
*exitedAncestorsCommonParentIndexOut = exitedAncestorsOut->size();
*enteredAncestorsCommonParentIndexOut = enteredAncestorsOut->size();
@@ -508,8 +507,19 @@ WebInputEventResult PointerEventManager::sendMousePointerEvent(
if (pointerEvent->isPrimary() && !m_preventMouseEventForPointerType[toPointerTypeIndex(
mouseEvent.pointerProperties().pointerType)]) {
+ EventTarget* mouseTarget = effectiveTarget;
+ // Event path could be null if pointer event is not dispatched and
+ // that happens for example when pointer event feature is not enabled.
+ if (!isInDocument(mouseTarget) && pointerEvent->hasEventPath()) {
+ for (size_t i = 0; i < pointerEvent->eventPath().size(); i++) {
+ if (isInDocument(pointerEvent->eventPath()[i].node())) {
+ mouseTarget = pointerEvent->eventPath()[i].node();
+ break;
+ }
+ }
+ }
result = EventHandler::mergeEventResult(result,
- dispatchMouseEvent(effectiveTarget, mouseEventType, mouseEvent,
+ dispatchMouseEvent(mouseTarget, mouseEventType, mouseEvent,
nullptr, clickCount));
}
« no previous file with comments | « third_party/WebKit/Source/core/events/Event.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698