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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "core/events/TextEvent.h" 49 #include "core/events/TextEvent.h"
50 #include "core/events/TouchEvent.h" 50 #include "core/events/TouchEvent.h"
51 #include "core/events/WheelEvent.h" 51 #include "core/events/WheelEvent.h"
52 #include "core/fetch/ImageResource.h" 52 #include "core/fetch/ImageResource.h"
53 #include "core/frame/EventHandlerRegistry.h" 53 #include "core/frame/EventHandlerRegistry.h"
54 #include "core/frame/FrameHost.h" 54 #include "core/frame/FrameHost.h"
55 #include "core/frame/FrameView.h" 55 #include "core/frame/FrameView.h"
56 #include "core/frame/LocalFrame.h" 56 #include "core/frame/LocalFrame.h"
57 #include "core/frame/Settings.h" 57 #include "core/frame/Settings.h"
58 #include "core/frame/VisualViewport.h" 58 #include "core/frame/VisualViewport.h"
59 #include "core/html/HTMLCanvasElement.h"
59 #include "core/html/HTMLDialogElement.h" 60 #include "core/html/HTMLDialogElement.h"
60 #include "core/html/HTMLFrameElementBase.h" 61 #include "core/html/HTMLFrameElementBase.h"
61 #include "core/html/HTMLFrameSetElement.h" 62 #include "core/html/HTMLFrameSetElement.h"
62 #include "core/html/HTMLInputElement.h" 63 #include "core/html/HTMLInputElement.h"
63 #include "core/input/InputDeviceCapabilities.h" 64 #include "core/input/InputDeviceCapabilities.h"
64 #include "core/input/TouchActionUtil.h" 65 #include "core/input/TouchActionUtil.h"
65 #include "core/layout/HitTestRequest.h" 66 #include "core/layout/HitTestRequest.h"
66 #include "core/layout/HitTestResult.h" 67 #include "core/layout/HitTestResult.h"
67 #include "core/layout/LayoutPart.h" 68 #include "core/layout/LayoutPart.h"
68 #include "core/layout/LayoutTextControlSingleLine.h" 69 #include "core/layout/LayoutTextControlSingleLine.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 visitor->trace(m_resizeScrollableArea); 282 visitor->trace(m_resizeScrollableArea);
282 visitor->trace(m_capturingMouseEventsNode); 283 visitor->trace(m_capturingMouseEventsNode);
283 visitor->trace(m_nodeUnderMouse); 284 visitor->trace(m_nodeUnderMouse);
284 visitor->trace(m_lastMouseMoveEventSubframe); 285 visitor->trace(m_lastMouseMoveEventSubframe);
285 visitor->trace(m_lastScrollbarUnderMouse); 286 visitor->trace(m_lastScrollbarUnderMouse);
286 visitor->trace(m_clickNode); 287 visitor->trace(m_clickNode);
287 visitor->trace(m_dragTarget); 288 visitor->trace(m_dragTarget);
288 visitor->trace(m_frameSetBeingResized); 289 visitor->trace(m_frameSetBeingResized);
289 visitor->trace(m_scrollbarHandlingScrollGesture); 290 visitor->trace(m_scrollbarHandlingScrollGesture);
290 visitor->trace(m_targetForTouchID); 291 visitor->trace(m_targetForTouchID);
292 visitor->trace(m_regionForTouchID);
291 visitor->trace(m_touchSequenceDocument); 293 visitor->trace(m_touchSequenceDocument);
292 visitor->trace(m_scrollGestureHandlingNode); 294 visitor->trace(m_scrollGestureHandlingNode);
293 visitor->trace(m_previousGestureScrolledNode); 295 visitor->trace(m_previousGestureScrolledNode);
294 visitor->trace(m_lastDeferredTapElement); 296 visitor->trace(m_lastDeferredTapElement);
295 visitor->trace(m_selectionController); 297 visitor->trace(m_selectionController);
296 visitor->trace(m_pointerEventManager); 298 visitor->trace(m_pointerEventManager);
297 #endif 299 #endif
298 } 300 }
299 301
300 DragState& EventHandler::dragState() 302 DragState& EventHandler::dragState()
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 invalidateClick(); 1052 invalidateClick();
1051 return WebInputEventResult::HandledSuppressed; 1053 return WebInputEventResult::HandledSuppressed;
1052 } 1054 }
1053 #endif 1055 #endif
1054 1056
1055 m_clickCount = mouseEvent.clickCount(); 1057 m_clickCount = mouseEvent.clickCount();
1056 m_clickNode = mev.innerNode()->isTextNode() ? FlatTreeTraversal::parent(*me v.innerNode()) : mev.innerNode(); 1058 m_clickNode = mev.innerNode()->isTextNode() ? FlatTreeTraversal::parent(*me v.innerNode()) : mev.innerNode();
1057 1059
1058 m_frame->selection().setCaretBlinkingSuspended(true); 1060 m_frame->selection().setCaretBlinkingSuspended(true);
1059 1061
1060 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event TypeNames::mousedown, mev.innerNode(), m_clickCount, mouseEvent); 1062 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event TypeNames::mousedown, mev.innerNode(), m_clickCount, mev.event());
zino 2016/03/12 05:59:08 Fix trybot error: The prepareMouseEvent() will ret
1061 1063
1062 if (eventResult == WebInputEventResult::NotHandled && m_frame->view()) { 1064 if (eventResult == WebInputEventResult::NotHandled && m_frame->view()) {
1063 FrameView* view = m_frame->view(); 1065 FrameView* view = m_frame->view();
1064 PaintLayer* layer = mev.innerNode()->layoutObject() ? mev.innerNode()->l ayoutObject()->enclosingLayer() : nullptr; 1066 PaintLayer* layer = mev.innerNode()->layoutObject() ? mev.innerNode()->l ayoutObject()->enclosingLayer() : nullptr;
1065 IntPoint p = view->rootFrameToContents(mouseEvent.position()); 1067 IntPoint p = view->rootFrameToContents(mouseEvent.position());
1066 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint InResizeControl(p, ResizerForPointer)) { 1068 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint InResizeControl(p, ResizerForPointer)) {
1067 m_resizeScrollableArea = layer->scrollableArea(); 1069 m_resizeScrollableArea = layer->scrollableArea();
1068 m_resizeScrollableArea->setInResizeMode(true); 1070 m_resizeScrollableArea->setInResizeMode(true);
1069 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p)); 1071 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p));
1070 return WebInputEventResult::HandledSystem; 1072 return WebInputEventResult::HandledSystem;
1071 } 1073 }
1072 } 1074 }
1073 1075
1074 // m_selectionInitiationState is initialized after dispatching mousedown 1076 // m_selectionInitiationState is initialized after dispatching mousedown
1075 // event in order not to keep the selection by DOM APIs Because we can't 1077 // event in order not to keep the selection by DOM APIs Because we can't
1076 // give the user the chance to handle the selection by user action like 1078 // give the user the chance to handle the selection by user action like
1077 // dragging if we keep the selection in case of mousedown. FireFox also has 1079 // dragging if we keep the selection in case of mousedown. FireFox also has
1078 // the same behavior and it's more compatible with other browsers. 1080 // the same behavior and it's more compatible with other browsers.
1079 selectionController().initializeSelectionState(); 1081 selectionController().initializeSelectionState();
1080 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H itTestRequest::ReadOnly); 1082 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H itTestRequest::ReadOnly);
1081 InputDeviceCapabilities* sourceCapabilities = mouseEvent.getSyntheticEventTy pe() == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEvent sSourceCapabilities() : 1083 InputDeviceCapabilities* sourceCapabilities = mouseEvent.getSyntheticEventTy pe() == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEvent sSourceCapabilities() :
1082 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities(); 1084 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities();
1083 if (eventResult == WebInputEventResult::NotHandled) 1085 if (eventResult == WebInputEventResult::NotHandled)
1084 eventResult = handleMouseFocus(MouseEventWithHitTestResults(mouseEvent, hitTestResult), sourceCapabilities); 1086 eventResult = handleMouseFocus(MouseEventWithHitTestResults(mev.event(), hitTestResult), sourceCapabilities);
1085 m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.s crollbar(); 1087 m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.s crollbar();
1086 1088
1087 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults 1089 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults
1088 // in case the scrollbar widget was destroyed when the mouse event was handl ed. 1090 // in case the scrollbar widget was destroyed when the mouse event was handl ed.
1089 if (mev.scrollbar()) { 1091 if (mev.scrollbar()) {
1090 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); 1092 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get();
1091 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active ); 1093 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active );
1092 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent); 1094 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent);
1093 if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get ()) 1095 if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get ())
1094 m_lastScrollbarUnderMouse = nullptr; 1096 m_lastScrollbarUnderMouse = nullptr;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 m_frame->document()->updateHoverActiveState(request, 0); 1242 m_frame->document()->updateHoverActiveState(request, 0);
1241 else 1243 else
1242 mev = prepareMouseEvent(request, mouseEvent); 1244 mev = prepareMouseEvent(request, mouseEvent);
1243 1245
1244 if (hoveredNode) 1246 if (hoveredNode)
1245 *hoveredNode = mev.hitTestResult(); 1247 *hoveredNode = mev.hitTestResult();
1246 1248
1247 Scrollbar* scrollbar = nullptr; 1249 Scrollbar* scrollbar = nullptr;
1248 1250
1249 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { 1251 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) {
1250 m_resizeScrollableArea->resize(mouseEvent, m_offsetFromResizeCorner); 1252 m_resizeScrollableArea->resize(mev.event(), m_offsetFromResizeCorner);
1251 } else { 1253 } else {
1252 if (!scrollbar) 1254 if (!scrollbar)
1253 scrollbar = mev.scrollbar(); 1255 scrollbar = mev.scrollbar();
1254 1256
1255 updateLastScrollbarUnderMouse(scrollbar, !m_mousePressed); 1257 updateLastScrollbarUnderMouse(scrollbar, !m_mousePressed);
1256 if (onlyUpdateScrollbars) 1258 if (onlyUpdateScrollbars)
1257 return WebInputEventResult::HandledSuppressed; 1259 return WebInputEventResult::HandledSuppressed;
1258 } 1260 }
1259 1261
1260 WebInputEventResult eventResult = WebInputEventResult::NotHandled; 1262 WebInputEventResult eventResult = WebInputEventResult::NotHandled;
1261 RefPtrWillBeRawPtr<LocalFrame> newSubframe = m_capturingMouseEventsNode.get( ) ? subframeForTargetNode(m_capturingMouseEventsNode.get()) : subframeForHitTest Result(mev); 1263 RefPtrWillBeRawPtr<LocalFrame> newSubframe = m_capturingMouseEventsNode.get( ) ? subframeForTargetNode(m_capturingMouseEventsNode.get()) : subframeForHitTest Result(mev);
1262 1264
1263 // We want mouseouts to happen first, from the inside out. First send a mov e event to the last subframe so that it will fire mouseouts. 1265 // We want mouseouts to happen first, from the inside out. First send a mov e event to the last subframe so that it will fire mouseouts.
1264 if (m_lastMouseMoveEventSubframe && m_lastMouseMoveEventSubframe->tree().isD escendantOf(m_frame) && m_lastMouseMoveEventSubframe != newSubframe) 1266 if (m_lastMouseMoveEventSubframe && m_lastMouseMoveEventSubframe->tree().isD escendantOf(m_frame) && m_lastMouseMoveEventSubframe != newSubframe)
1265 m_lastMouseMoveEventSubframe->eventHandler().handleMouseLeaveEvent(mouse Event); 1267 m_lastMouseMoveEventSubframe->eventHandler().handleMouseLeaveEvent(mev.e vent());
1266 1268
1267 if (newSubframe) { 1269 if (newSubframe) {
1268 // Update over/out state before passing the event to the subframe. 1270 // Update over/out state before passing the event to the subframe.
1269 updateMouseEventTargetNode(mev.innerNode(), mouseEvent); 1271 updateMouseEventTargetNode(mev.innerNode(), mev.event());
1270 1272
1271 // Event dispatch in updateMouseEventTargetNode may have caused the subf rame of the target 1273 // Event dispatch in updateMouseEventTargetNode may have caused the subf rame of the target
1272 // node to be detached from its FrameView, in which case the event shoul d not be passed. 1274 // node to be detached from its FrameView, in which case the event shoul d not be passed.
1273 if (newSubframe->view()) 1275 if (newSubframe->view())
1274 eventResult = passMouseMoveEventToSubframe(mev, newSubframe.get(), h overedNode); 1276 eventResult = passMouseMoveEventToSubframe(mev, newSubframe.get(), h overedNode);
1275 } else { 1277 } else {
1276 if (scrollbar && !m_mousePressed) 1278 if (scrollbar && !m_mousePressed)
1277 scrollbar->mouseMoved(mouseEvent); // Handle hover effects on platfo rms that support visual feedback on scrollbar hovering. 1279 scrollbar->mouseMoved(mev.event()); // Handle hover effects on platf orms that support visual feedback on scrollbar hovering.
1278 if (FrameView* view = m_frame->view()) { 1280 if (FrameView* view = m_frame->view()) {
1279 OptionalCursor optionalCursor = selectCursor(mev.hitTestResult()); 1281 OptionalCursor optionalCursor = selectCursor(mev.hitTestResult());
1280 if (optionalCursor.isCursorChange()) { 1282 if (optionalCursor.isCursorChange()) {
1281 view->setCursor(optionalCursor.cursor()); 1283 view->setCursor(optionalCursor.cursor());
1282 } 1284 }
1283 } 1285 }
1284 } 1286 }
1285 1287
1286 m_lastMouseMoveEventSubframe = newSubframe; 1288 m_lastMouseMoveEventSubframe = newSubframe;
1287 1289
1288 if (eventResult != WebInputEventResult::NotHandled) 1290 if (eventResult != WebInputEventResult::NotHandled)
1289 return eventResult; 1291 return eventResult;
1290 1292
1291 eventResult = updatePointerTargetAndDispatchEvents(EventTypeNames::mousemove , mev.innerNode(), 0, mouseEvent); 1293 eventResult = updatePointerTargetAndDispatchEvents(EventTypeNames::mousemove , mev.innerNode(), 0, mev.event());
1292 if (eventResult != WebInputEventResult::NotHandled) 1294 if (eventResult != WebInputEventResult::NotHandled)
1293 return eventResult; 1295 return eventResult;
1294 1296
1295 return handleMouseDraggedEvent(mev); 1297 return handleMouseDraggedEvent(mev);
1296 } 1298 }
1297 1299
1298 void EventHandler::invalidateClick() 1300 void EventHandler::invalidateClick()
1299 { 1301 {
1300 m_clickCount = 0; 1302 m_clickCount = 0;
1301 m_clickNode = nullptr; 1303 m_clickNode = nullptr;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 1356
1355 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Release; 1357 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Release;
1356 HitTestRequest request(hitType); 1358 HitTestRequest request(hitType);
1357 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); 1359 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent);
1358 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); 1360 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev);
1359 if (m_eventHandlerWillResetCapturingMouseEventsNode) 1361 if (m_eventHandlerWillResetCapturingMouseEventsNode)
1360 m_capturingMouseEventsNode = nullptr; 1362 m_capturingMouseEventsNode = nullptr;
1361 if (subframe) 1363 if (subframe)
1362 return passMouseReleaseEventToSubframe(mev, subframe); 1364 return passMouseReleaseEventToSubframe(mev, subframe);
1363 1365
1364 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event TypeNames::mouseup, mev.innerNode(), m_clickCount, mouseEvent); 1366 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event TypeNames::mouseup, mev.innerNode(), m_clickCount, mev.event());
1365 1367
1366 // TODO(crbug/545647): This state should reset with pointercancel too. 1368 // TODO(crbug/545647): This state should reset with pointercancel too.
1367 m_pointerEventManager.conditionallyEnableMouseEventForPointerTypeMouse( 1369 m_pointerEventManager.conditionallyEnableMouseEventForPointerTypeMouse(
1368 mouseEvent.getModifiers()); 1370 mouseEvent.getModifiers());
1369 1371
1370 bool contextMenuEvent = mouseEvent.button() == RightButton; 1372 bool contextMenuEvent = mouseEvent.button() == RightButton;
1371 #if OS(MACOSX) 1373 #if OS(MACOSX)
1372 // FIXME: The Mac port achieves the same behavior by checking whether the co ntext menu is currently open in WebPage::mouseEvent(). Consider merging the impl ementations. 1374 // FIXME: The Mac port achieves the same behavior by checking whether the co ntext menu is currently open in WebPage::mouseEvent(). Consider merging the impl ementations.
1373 if (mouseEvent.button() == LeftButton && mouseEvent.getModifiers() & Platfor mEvent::CtrlKey) 1375 if (mouseEvent.button() == LeftButton && mouseEvent.getModifiers() & Platfor mEvent::CtrlKey)
1374 contextMenuEvent = true; 1376 contextMenuEvent = true;
1375 #endif 1377 #endif
1376 1378
1377 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; 1379 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled;
1378 if (m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode && mev.innerNode()->canParticipateInFlatTree() && m_clickNode->canParticipateInF latTree()) { 1380 if (m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode && mev.innerNode()->canParticipateInFlatTree() && m_clickNode->canParticipateInF latTree()) {
1379 // Updates distribution because a 'mouseup' event listener can make the 1381 // Updates distribution because a 'mouseup' event listener can make the
1380 // tree dirty at dispatchMouseEvent() invocation above. 1382 // tree dirty at dispatchMouseEvent() invocation above.
1381 // Unless distribution is updated, commonAncestor would hit ASSERT. 1383 // Unless distribution is updated, commonAncestor would hit ASSERT.
1382 // Both m_clickNode and mev.innerNode() don't need to be updated 1384 // Both m_clickNode and mev.innerNode() don't need to be updated
1383 // because commonAncestor() will exit early if their documents are diffe rent. 1385 // because commonAncestor() will exit early if their documents are diffe rent.
1384 m_clickNode->updateDistribution(); 1386 m_clickNode->updateDistribution();
1385 if (Node* clickTargetNode = mev.innerNode()->commonAncestor( 1387 if (Node* clickTargetNode = mev.innerNode()->commonAncestor(
1386 *m_clickNode, parentForClickEvent)) { 1388 *m_clickNode, parentForClickEvent)) {
1387 1389
1388 // Dispatch mouseup directly w/o calling updateMouseEventTargetNode 1390 // Dispatch mouseup directly w/o calling updateMouseEventTargetNode
1389 // because the mouseup dispatch above has already updated it 1391 // because the mouseup dispatch above has already updated it
1390 // correctly. Moreover, clickTargetNode is different from 1392 // correctly. Moreover, clickTargetNode is different from
1391 // mev.innerNode at drag-release. 1393 // mev.innerNode at drag-release.
1392 clickEventResult = toWebInputEventResult(clickTargetNode->dispatchMo useEvent(mouseEvent, 1394 clickEventResult = toWebInputEventResult(clickTargetNode->dispatchMo useEvent(mev.event(),
1393 EventTypeNames::click, m_clickCount)); 1395 EventTypeNames::click, m_clickCount));
1394 } 1396 }
1395 } 1397 }
1396 1398
1397 if (m_resizeScrollableArea) { 1399 if (m_resizeScrollableArea) {
1398 m_resizeScrollableArea->setInResizeMode(false); 1400 m_resizeScrollableArea->setInResizeMode(false);
1399 m_resizeScrollableArea = nullptr; 1401 m_resizeScrollableArea = nullptr;
1400 } 1402 }
1401 1403
1402 if (eventResult == WebInputEventResult::NotHandled) 1404 if (eventResult == WebInputEventResult::NotHandled)
(...skipping 2297 matching lines...) Expand 10 before | Expand all | Expand 10 after
3700 continue; 3702 continue;
3701 3703
3702 RefPtrWillBeRawPtr<Touch> touch = Touch::create( 3704 RefPtrWillBeRawPtr<Touch> touch = Touch::create(
3703 touchInfo.targetFrame.get(), 3705 touchInfo.targetFrame.get(),
3704 touchInfo.touchTarget.get(), 3706 touchInfo.touchTarget.get(),
3705 point.id(), 3707 point.id(),
3706 point.screenPos(), 3708 point.screenPos(),
3707 touchInfo.adjustedPagePoint, 3709 touchInfo.adjustedPagePoint,
3708 touchInfo.adjustedRadius, 3710 touchInfo.adjustedRadius,
3709 point.rotationAngle(), 3711 point.rotationAngle(),
3710 point.force()); 3712 point.force(),
3713 touchInfo.region);
3711 3714
3712 // Ensure this target's touch list exists, even if it ends up empty, so 3715 // Ensure this target's touch list exists, even if it ends up empty, so
3713 // it can always be passed to TouchEvent::Create below. 3716 // it can always be passed to TouchEvent::Create below.
3714 TargetTouchesHeapMap::iterator targetTouchesIterator = touchesByTarget.f ind(touchInfo.touchTarget.get()); 3717 TargetTouchesHeapMap::iterator targetTouchesIterator = touchesByTarget.f ind(touchInfo.touchTarget.get());
3715 if (targetTouchesIterator == touchesByTarget.end()) { 3718 if (targetTouchesIterator == touchesByTarget.end()) {
3716 touchesByTarget.set(touchInfo.touchTarget.get(), TouchList::create() ); 3719 touchesByTarget.set(touchInfo.touchTarget.get(), TouchList::create() );
3717 targetTouchesIterator = touchesByTarget.find(touchInfo.touchTarget.g et()); 3720 targetTouchesIterator = touchesByTarget.find(touchInfo.touchTarget.g et());
3718 } 3721 }
3719 3722
3720 // touches and targetTouches should only contain information about 3723 // touches and targetTouches should only contain information about
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3826 LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceDocum ent->frame()->view()->rootFrameToContents(point.pos())); 3829 LayoutPoint framePoint = roundedLayoutPoint(m_touchSequenceDocum ent->frame()->view()->rootFrameToContents(point.pos()));
3827 result = hitTestResultInFrame(m_touchSequenceDocument->frame(), framePoint, hitType); 3830 result = hitTestResultInFrame(m_touchSequenceDocument->frame(), framePoint, hitType);
3828 } else { 3831 } else {
3829 continue; 3832 continue;
3830 } 3833 }
3831 3834
3832 Node* node = result.innerNode(); 3835 Node* node = result.innerNode();
3833 if (!node) 3836 if (!node)
3834 continue; 3837 continue;
3835 3838
3839 if (isHTMLCanvasElement(node)) {
3840 std::pair<Element*, String> regionInfo = toHTMLCanvasElement(nod e)->getControlAndIdIfHitRegionExists(result.pointInInnerNodeFrame());
3841 if (regionInfo.first)
3842 node = regionInfo.first;
3843 m_regionForTouchID.set(point.id(), regionInfo.second);
3844 }
3845
3836 // Touch events should not go to text nodes 3846 // Touch events should not go to text nodes
3837 if (node->isTextNode()) 3847 if (node->isTextNode())
3838 node = FlatTreeTraversal::parent(*node); 3848 node = FlatTreeTraversal::parent(*node);
3839 3849
3840 if (!m_touchSequenceDocument) { 3850 if (!m_touchSequenceDocument) {
3841 // Keep track of which document should receive all touch events 3851 // Keep track of which document should receive all touch events
3842 // in the active sequence. This must be a single document to 3852 // in the active sequence. This must be a single document to
3843 // ensure we don't leak Nodes between documents. 3853 // ensure we don't leak Nodes between documents.
3844 m_touchSequenceDocument = &(result.innerNode()->document()); 3854 m_touchSequenceDocument = &(result.innerNode()->document());
3845 ASSERT(m_touchSequenceDocument->frame()->view()); 3855 ASSERT(m_touchSequenceDocument->frame()->view());
(...skipping 26 matching lines...) Expand all
3872 return WebInputEventResult::NotHandled; 3882 return WebInputEventResult::NotHandled;
3873 } 3883 }
3874 3884
3875 // Compute and store the common info used by both PointerEvent and TouchEven t. 3885 // Compute and store the common info used by both PointerEvent and TouchEven t.
3876 WillBeHeapVector<TouchInfo> touchInfos(points.size()); 3886 WillBeHeapVector<TouchInfo> touchInfos(points.size());
3877 3887
3878 for (unsigned i = 0; i < points.size(); ++i) { 3888 for (unsigned i = 0; i < points.size(); ++i) {
3879 const PlatformTouchPoint& point = points[i]; 3889 const PlatformTouchPoint& point = points[i];
3880 PlatformTouchPoint::TouchState pointState = point.state(); 3890 PlatformTouchPoint::TouchState pointState = point.state();
3881 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr; 3891 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr;
3892 String regionID;
3882 3893
3883 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla tformTouchPoint::TouchCancelled) { 3894 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla tformTouchPoint::TouchCancelled) {
3884 // The target should be the original target for this touch, so get 3895 // The target should be the original target for this touch, so get
3885 // it from the hashmap. As it's a release or cancel we also remove 3896 // it from the hashmap. As it's a release or cancel we also remove
3886 // it from the map. 3897 // it from the map.
3887 touchTarget = m_targetForTouchID.take(point.id()); 3898 touchTarget = m_targetForTouchID.take(point.id());
3899 regionID = m_regionForTouchID.take(point.id());
3888 } else { 3900 } else {
3889 // No hittest is performed on move or stationary, since the target 3901 // No hittest is performed on move or stationary, since the target
3890 // is not allowed to change anyway. 3902 // is not allowed to change anyway.
3891 touchTarget = m_targetForTouchID.get(point.id()); 3903 touchTarget = m_targetForTouchID.get(point.id());
3904 regionID = m_regionForTouchID.get(point.id());
3892 } 3905 }
3893 3906
3894 LocalFrame* targetFrame = nullptr; 3907 LocalFrame* targetFrame = nullptr;
3895 bool knownTarget = false; 3908 bool knownTarget = false;
3896 if (touchTarget) { 3909 if (touchTarget) {
3897 Document& doc = touchTarget->toNode()->document(); 3910 Document& doc = touchTarget->toNode()->document();
3898 // If the target node has moved to a new document while it was being touched, 3911 // If the target node has moved to a new document while it was being touched,
3899 // we can't send events to the new document because that could leak nodes 3912 // we can't send events to the new document because that could leak nodes
3900 // from one document to another. See http://crbug.com/394339. 3913 // from one document to another. See http://crbug.com/394339.
3901 if (&doc == m_touchSequenceDocument.get()) { 3914 if (&doc == m_touchSequenceDocument.get()) {
(...skipping 25 matching lines...) Expand all
3927 float scaleFactor = 1.0f / targetFrame->pageZoomFactor(); 3940 float scaleFactor = 1.0f / targetFrame->pageZoomFactor();
3928 3941
3929 TouchInfo& touchInfo = touchInfos[i]; 3942 TouchInfo& touchInfo = touchInfos[i];
3930 touchInfo.point = point; 3943 touchInfo.point = point;
3931 touchInfo.touchTarget = touchTarget; 3944 touchInfo.touchTarget = touchTarget;
3932 touchInfo.targetFrame = targetFrame; 3945 touchInfo.targetFrame = targetFrame;
3933 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor); 3946 touchInfo.adjustedPagePoint = pagePoint.scaledBy(scaleFactor);
3934 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor); 3947 touchInfo.adjustedRadius = point.radius().scaledBy(scaleFactor);
3935 touchInfo.knownTarget = knownTarget; 3948 touchInfo.knownTarget = knownTarget;
3936 touchInfo.consumed = false; 3949 touchInfo.consumed = false;
3950 touchInfo.region = regionID;
3937 } 3951 }
3938 3952
3939 if (!m_inPointerCanceledState) { 3953 if (!m_inPointerCanceledState) {
3940 dispatchPointerEvents(event, touchInfos); 3954 dispatchPointerEvents(event, touchInfos);
3941 // Note that the disposition of any pointer events affects only the gene ration of touch 3955 // Note that the disposition of any pointer events affects only the gene ration of touch
3942 // events. If all pointer events were handled (and hence no touch events were fired), that 3956 // events. If all pointer events were handled (and hence no touch events were fired), that
3943 // is still equivalent to the touch events going unhandled because point er event handler 3957 // is still equivalent to the touch events going unhandled because point er event handler
3944 // don't block scroll gesture generation. 3958 // don't block scroll gesture generation.
3945 } 3959 }
3946 3960
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
4015 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 4029 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
4016 { 4030 {
4017 #if OS(MACOSX) 4031 #if OS(MACOSX)
4018 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 4032 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
4019 #else 4033 #else
4020 return PlatformEvent::AltKey; 4034 return PlatformEvent::AltKey;
4021 #endif 4035 #endif
4022 } 4036 }
4023 4037
4024 } // namespace blink 4038 } // namespace blink
OLDNEW
« 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