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

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

Issue 1815093002: Canvas2d: fix event.region being null on mouseleave/out events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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);
}
}

Powered by Google App Engine
This is Rietveld 408576698