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 f784bbcc17891a48cdfd2f466996e4e401ae6b86..0c551bfe59d93022a5bf08378155c0bfd53c89bb 100644 |
--- a/third_party/WebKit/Source/core/input/PointerEventManager.cpp |
+++ b/third_party/WebKit/Source/core/input/PointerEventManager.cpp |
@@ -4,8 +4,10 @@ |
#include "core/input/PointerEventManager.h" |
+#include "core/dom/ElementTraversal.h" |
#include "core/dom/shadow/FlatTreeTraversal.h" |
#include "core/events/MouseEvent.h" |
+#include "core/html/HTMLCanvasElement.h" |
#include "core/input/EventHandler.h" |
namespace blink { |
@@ -56,6 +58,25 @@ WebInputEventResult dispatchMouseEvent( |
return WebInputEventResult::NotHandled; |
} |
+PlatformMouseEvent mouseEventWithRegion(Node* node, const PlatformMouseEvent& mouseEvent) |
+{ |
+ if (!node->isElementNode()) |
+ return mouseEvent; |
+ |
+ Element* element = toElement(node); |
+ if (!element->isInCanvasSubtree()) |
+ return mouseEvent; |
+ |
+ HTMLCanvasElement* canvas = Traversal<HTMLCanvasElement>::firstAncestorOrSelf(*element); |
+ // In this case, the event target is canvas and mouse rerouting doesn't happen. |
+ if (canvas == element) |
+ return mouseEvent; |
+ String region = canvas->getIdFromControl(element); |
+ PlatformMouseEvent newMouseEvent = mouseEvent; |
+ newMouseEvent.setRegion(region); |
+ return newMouseEvent; |
+} |
+ |
} // namespace |
WebInputEventResult PointerEventManager::dispatchPointerEvent( |
@@ -148,7 +169,9 @@ void PointerEventManager::sendNodeTransitionEvents( |
pointerEvent, EventTypeNames::pointerout, enteredTarget)); |
} else { |
dispatchMouseEvent(exitedTarget, |
- EventTypeNames::mouseout, mouseEvent, enteredTarget); |
+ EventTypeNames::mouseout, |
+ mouseEventWithRegion(exitedTarget->toNode(), mouseEvent), |
+ enteredTarget); |
} |
} |
@@ -217,8 +240,9 @@ void PointerEventManager::sendNodeTransitionEvents( |
!exitedNodeHasCapturingAncestor); |
} else { |
dispatchMouseEvent(exitedAncestors[j].get(), |
- EventTypeNames::mouseleave, mouseEvent, enteredTarget, |
- 0, !exitedNodeHasCapturingAncestor); |
+ EventTypeNames::mouseleave, |
+ mouseEventWithRegion(exitedTarget->toNode(), mouseEvent), |
+ enteredTarget, 0, !exitedNodeHasCapturingAncestor); |
} |
} |