Index: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
index 2b554b54362aa1de55080ff79e61bf09aad4937e..286ab619aaa9a134ba1bee6d63f2b3843dbd07a4 100644 |
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
@@ -33,6 +33,9 @@ |
#include "core/HTMLNames.h" |
#include "core/dom/Document.h" |
#include "core/dom/ExceptionCode.h" |
+#include "core/events/Event.h" |
+#include "core/events/EventDispatcher.h" |
+#include "core/events/MouseEvent.h" |
#include "core/fileapi/File.h" |
#include "core/frame/ImageBitmap.h" |
#include "core/frame/LocalFrame.h" |
@@ -1022,4 +1025,23 @@ bool HTMLCanvasElement::isOpaque() const |
return m_context && !m_context->hasAlpha(); |
} |
+bool HTMLCanvasElement::dispatchEventInternal(PassRefPtrWillBeRawPtr<Event> event) |
+{ |
+ if (event->isMouseEvent() && event->isTrusted()) { |
+ MouseEvent* mouseEvent = toMouseEvent(event); |
+ std::pair<Element*, String> regionInfo = getControlAndIDIfHitRegionExists(mouseEvent->absoluteLocation()); |
+ mouseEvent->setRegion(regionInfo.second); |
+ if (regionInfo.first) |
+ return EventDispatcher::dispatchEvent(*regionInfo.first, event->createMediator()); |
+ } |
+ return HTMLElement::dispatchEventInternal(event); |
+} |
+ |
+std::pair<Element*, String> HTMLCanvasElement::getControlAndIDIfHitRegionExists(const LayoutPoint& location) |
philipj_slow
2016/02/05 07:30:06
Should probably be Id (not ID) for consistency. I
zino
2016/02/12 15:26:18
I think it's better to "Id" than "ID".
Done.
|
+{ |
+ if (m_context && m_context->is2d() && m_context->hitRegionsCount() > 0) |
philipj_slow
2016/02/05 07:30:06
It's a bit odd to both have an is2d() test and a v
|
+ return m_context->getControlAndIDIfHitRegionExists(location); |
+ return std::make_pair(nullptr, String()); |
+} |
+ |
} // namespace blink |