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

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

Issue 1654653002: Canvas2d: Implement rerouting event by hit region's control. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix bot errors Created 4 years, 9 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/EventHandler.cpp
diff --git a/third_party/WebKit/Source/core/input/EventHandler.cpp b/third_party/WebKit/Source/core/input/EventHandler.cpp
index 6dd54001587b8793c2427a3817dc2ad4c4f751d5..b152fd45c8813bf11411103b3872476a03a4709c 100644
--- a/third_party/WebKit/Source/core/input/EventHandler.cpp
+++ b/third_party/WebKit/Source/core/input/EventHandler.cpp
@@ -56,6 +56,7 @@
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
#include "core/frame/VisualViewport.h"
+#include "core/html/HTMLCanvasElement.h"
#include "core/html/HTMLDialogElement.h"
#include "core/html/HTMLFrameElementBase.h"
#include "core/html/HTMLFrameSetElement.h"
@@ -288,6 +289,7 @@ DEFINE_TRACE(EventHandler)
visitor->trace(m_frameSetBeingResized);
visitor->trace(m_scrollbarHandlingScrollGesture);
visitor->trace(m_targetForTouchID);
+ visitor->trace(m_regionForTouchID);
visitor->trace(m_touchSequenceDocument);
visitor->trace(m_scrollGestureHandlingNode);
visitor->trace(m_previousGestureScrolledNode);
@@ -1057,7 +1059,7 @@ WebInputEventResult EventHandler::handleMousePressEvent(const PlatformMouseEvent
m_frame->selection().setCaretBlinkingSuspended(true);
- WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(EventTypeNames::mousedown, mev.innerNode(), m_clickCount, mouseEvent);
+ WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(EventTypeNames::mousedown, mev.innerNode(), m_clickCount, mev.event());
zino 2016/03/12 05:59:08 Fix trybot error: The prepareMouseEvent() will ret
if (eventResult == WebInputEventResult::NotHandled && m_frame->view()) {
FrameView* view = m_frame->view();
@@ -1081,7 +1083,7 @@ WebInputEventResult EventHandler::handleMousePressEvent(const PlatformMouseEvent
InputDeviceCapabilities* sourceCapabilities = mouseEvent.getSyntheticEventType() == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEventsSourceCapabilities() :
InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities();
if (eventResult == WebInputEventResult::NotHandled)
- eventResult = handleMouseFocus(MouseEventWithHitTestResults(mouseEvent, hitTestResult), sourceCapabilities);
+ eventResult = handleMouseFocus(MouseEventWithHitTestResults(mev.event(), hitTestResult), sourceCapabilities);
m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.scrollbar();
// If the hit testing originally determined the event was in a scrollbar, refetch the MouseEventWithHitTestResults
@@ -1247,7 +1249,7 @@ WebInputEventResult EventHandler::handleMouseMoveOrLeaveEvent(const PlatformMous
Scrollbar* scrollbar = nullptr;
if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) {
- m_resizeScrollableArea->resize(mouseEvent, m_offsetFromResizeCorner);
+ m_resizeScrollableArea->resize(mev.event(), m_offsetFromResizeCorner);
} else {
if (!scrollbar)
scrollbar = mev.scrollbar();
@@ -1262,11 +1264,11 @@ WebInputEventResult EventHandler::handleMouseMoveOrLeaveEvent(const PlatformMous
// We want mouseouts to happen first, from the inside out. First send a move event to the last subframe so that it will fire mouseouts.
if (m_lastMouseMoveEventSubframe && m_lastMouseMoveEventSubframe->tree().isDescendantOf(m_frame) && m_lastMouseMoveEventSubframe != newSubframe)
- m_lastMouseMoveEventSubframe->eventHandler().handleMouseLeaveEvent(mouseEvent);
+ m_lastMouseMoveEventSubframe->eventHandler().handleMouseLeaveEvent(mev.event());
if (newSubframe) {
// Update over/out state before passing the event to the subframe.
- updateMouseEventTargetNode(mev.innerNode(), mouseEvent);
+ updateMouseEventTargetNode(mev.innerNode(), mev.event());
// Event dispatch in updateMouseEventTargetNode may have caused the subframe of the target
// node to be detached from its FrameView, in which case the event should not be passed.
@@ -1274,7 +1276,7 @@ WebInputEventResult EventHandler::handleMouseMoveOrLeaveEvent(const PlatformMous
eventResult = passMouseMoveEventToSubframe(mev, newSubframe.get(), hoveredNode);
} else {
if (scrollbar && !m_mousePressed)
- scrollbar->mouseMoved(mouseEvent); // Handle hover effects on platforms that support visual feedback on scrollbar hovering.
+ scrollbar->mouseMoved(mev.event()); // Handle hover effects on platforms that support visual feedback on scrollbar hovering.
if (FrameView* view = m_frame->view()) {
OptionalCursor optionalCursor = selectCursor(mev.hitTestResult());
if (optionalCursor.isCursorChange()) {
@@ -1288,7 +1290,7 @@ WebInputEventResult EventHandler::handleMouseMoveOrLeaveEvent(const PlatformMous
if (eventResult != WebInputEventResult::NotHandled)
return eventResult;
- eventResult = updatePointerTargetAndDispatchEvents(EventTypeNames::mousemove, mev.innerNode(), 0, mouseEvent);
+ eventResult = updatePointerTargetAndDispatchEvents(EventTypeNames::mousemove, mev.innerNode(), 0, mev.event());
if (eventResult != WebInputEventResult::NotHandled)
return eventResult;
@@ -1361,7 +1363,7 @@ WebInputEventResult EventHandler::handleMouseReleaseEvent(const PlatformMouseEve
if (subframe)
return passMouseReleaseEventToSubframe(mev, subframe);
- WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(EventTypeNames::mouseup, mev.innerNode(), m_clickCount, mouseEvent);
+ WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(EventTypeNames::mouseup, mev.innerNode(), m_clickCount, mev.event());
// TODO(crbug/545647): This state should reset with pointercancel too.
m_pointerEventManager.conditionallyEnableMouseEventForPointerTypeMouse(
@@ -1389,7 +1391,7 @@ WebInputEventResult EventHandler::handleMouseReleaseEvent(const PlatformMouseEve
// because the mouseup dispatch above has already updated it
// correctly. Moreover, clickTargetNode is different from
// mev.innerNode at drag-release.
- clickEventResult = toWebInputEventResult(clickTargetNode->dispatchMouseEvent(mouseEvent,
+ clickEventResult = toWebInputEventResult(clickTargetNode->dispatchMouseEvent(mev.event(),
EventTypeNames::click, m_clickCount));
}
}
@@ -3707,7 +3709,8 @@ WebInputEventResult EventHandler::dispatchTouchEvents(const PlatformTouchEvent&
touchInfo.adjustedPagePoint,
touchInfo.adjustedRadius,
point.rotationAngle(),
- point.force());
+ point.force(),
+ touchInfo.region);
// Ensure this target's touch list exists, even if it ends up empty, so
// it can always be passed to TouchEvent::Create below.
@@ -3833,6 +3836,13 @@ WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
if (!node)
continue;
+ if (isHTMLCanvasElement(node)) {
+ std::pair<Element*, String> regionInfo = toHTMLCanvasElement(node)->getControlAndIdIfHitRegionExists(result.pointInInnerNodeFrame());
+ if (regionInfo.first)
+ node = regionInfo.first;
+ m_regionForTouchID.set(point.id(), regionInfo.second);
+ }
+
// Touch events should not go to text nodes
if (node->isTextNode())
node = FlatTreeTraversal::parent(*node);
@@ -3879,16 +3889,19 @@ WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
const PlatformTouchPoint& point = points[i];
PlatformTouchPoint::TouchState pointState = point.state();
RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr;
+ String regionID;
if (pointState == PlatformTouchPoint::TouchReleased || pointState == PlatformTouchPoint::TouchCancelled) {
// The target should be the original target for this touch, so get
// it from the hashmap. As it's a release or cancel we also remove
// it from the map.
touchTarget = m_targetForTouchID.take(point.id());
+ regionID = m_regionForTouchID.take(point.id());
} else {
// No hittest is performed on move or stationary, since the target
// is not allowed to change anyway.
touchTarget = m_targetForTouchID.get(point.id());
+ regionID = m_regionForTouchID.get(point.id());
}
LocalFrame* targetFrame = nullptr;
@@ -3934,6 +3947,7 @@ WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve
touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor);
touchInfo.knownTarget = knownTarget;
touchInfo.consumed = false;
+ touchInfo.region = regionID;
}
if (!m_inPointerCanceledState) {
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandler.h ('k') | third_party/WebKit/Source/core/page/ContextMenuControllerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698