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

Side by Side Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 2174863002: Change mouse pointer event targets to the capturing node (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix redundant compat mouse boundary events Created 4 years, 5 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 { 302 {
303 if (nodeToBeRemoved.isShadowIncludingInclusiveAncestorOf(m_clickNode.get())) { 303 if (nodeToBeRemoved.isShadowIncludingInclusiveAncestorOf(m_clickNode.get())) {
304 // We don't dispatch click events if the mousedown node is removed 304 // We don't dispatch click events if the mousedown node is removed
305 // before a mouseup event. It is compatible with IE and Firefox. 305 // before a mouseup event. It is compatible with IE and Firefox.
306 m_clickNode = nullptr; 306 m_clickNode = nullptr;
307 } 307 }
308 } 308 }
309 309
310 void EventHandler::immediatelyProcessPendingPointerCapture(int pointerId) 310 void EventHandler::immediatelyProcessPendingPointerCapture(int pointerId)
311 { 311 {
312 m_pointerEventManager.immediatelyProcessPendingPointerCapture(pointerId); 312 m_pointerEventManager.processPendingPointerCapture(pointerId);
313 } 313 }
314 314
315 WebInputEventResult EventHandler::handleMousePressEvent(const MouseEventWithHitT estResults& event) 315 WebInputEventResult EventHandler::handleMousePressEvent(const MouseEventWithHitT estResults& event)
316 { 316 {
317 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); 317 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent");
318 318
319 // Reset drag state. 319 // Reset drag state.
320 dragState().m_dragSrc = nullptr; 320 dragState().m_dragSrc = nullptr;
321 321
322 cancelFakeMouseMoveEvent(); 322 cancelFakeMouseMoveEvent();
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 { 1401 {
1402 ASSERT(m_frame); 1402 ASSERT(m_frame);
1403 ASSERT(m_frame->document()); 1403 ASSERT(m_frame->document());
1404 1404
1405 return m_frame->document()->prepareMouseEvent(request, contentPointFromRootF rame(m_frame, mev.position()), mev); 1405 return m_frame->document()->prepareMouseEvent(request, contentPointFromRootF rame(m_frame, mev.position()), mev);
1406 } 1406 }
1407 1407
1408 Node* EventHandler::updateMouseEventTargetNode(Node* targetNode, 1408 Node* EventHandler::updateMouseEventTargetNode(Node* targetNode,
1409 const PlatformMouseEvent& mouseEvent) 1409 const PlatformMouseEvent& mouseEvent)
1410 { 1410 {
1411 Node* result = targetNode; 1411 Node* newNodeUnderMouse = targetNode;
1412 1412
1413 // If we're capturing, we always go right to that node. 1413 // If we're capturing, we always go right to that node.
1414 if (m_capturingMouseEventsNode) { 1414 if (EventTarget* mousePointerCapturingNode = m_pointerEventManager.getMouseC apturingNode()) {
1415 result = m_capturingMouseEventsNode.get(); 1415 newNodeUnderMouse = mousePointerCapturingNode->toNode();
1416 DCHECK(newNodeUnderMouse);
1417 } else if (m_capturingMouseEventsNode) {
1418 newNodeUnderMouse = m_capturingMouseEventsNode.get();
1416 } else { 1419 } else {
1417 // If the target node is a text node, dispatch on the parent node - rdar ://4196646 1420 // If the target node is a text node, dispatch on the parent node - rdar ://4196646
1418 if (result && result->isTextNode()) 1421 if (newNodeUnderMouse && newNodeUnderMouse->isTextNode())
1419 result = FlatTreeTraversal::parent(*result); 1422 newNodeUnderMouse = FlatTreeTraversal::parent(*newNodeUnderMouse);
1420 } 1423 }
1421 Node* lastNodeUnderMouse = m_nodeUnderMouse; 1424 Node* lastNodeUnderMouse = m_nodeUnderMouse;
1422 m_nodeUnderMouse = result; 1425 m_nodeUnderMouse = newNodeUnderMouse;
1423 1426
1424 PaintLayer* layerForLastNode = layerForNode(lastNodeUnderMouse); 1427 PaintLayer* layerForLastNode = layerForNode(lastNodeUnderMouse);
1425 PaintLayer* layerForNodeUnderMouse = layerForNode(m_nodeUnderMouse.get()); 1428 PaintLayer* layerForNodeUnderMouse = layerForNode(m_nodeUnderMouse.get());
1426 Page* page = m_frame->page(); 1429 Page* page = m_frame->page();
1427 1430
1428 if (lastNodeUnderMouse && (!m_nodeUnderMouse || m_nodeUnderMouse->document() != m_frame->document())) { 1431 if (lastNodeUnderMouse && (!m_nodeUnderMouse || m_nodeUnderMouse->document() != m_frame->document())) {
1429 // The mouse has moved between frames. 1432 // The mouse has moved between frames.
1430 if (LocalFrame* frame = lastNodeUnderMouse->document().frame()) { 1433 if (LocalFrame* frame = lastNodeUnderMouse->document().frame()) {
1431 if (FrameView* frameView = frame->view()) 1434 if (FrameView* frameView = frame->view())
1432 frameView->mouseExitedContentArea(); 1435 frameView->mouseExitedContentArea();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 { 1505 {
1503 ASSERT(mouseEventType == EventTypeNames::mousedown 1506 ASSERT(mouseEventType == EventTypeNames::mousedown
1504 || mouseEventType == EventTypeNames::mousemove 1507 || mouseEventType == EventTypeNames::mousemove
1505 || mouseEventType == EventTypeNames::mouseup); 1508 || mouseEventType == EventTypeNames::mouseup);
1506 1509
1507 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent ); 1510 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent );
1508 1511
1509 if (mouseEvent.getSyntheticEventType() == PlatformMouseEvent::FromTouch) 1512 if (mouseEvent.getSyntheticEventType() == PlatformMouseEvent::FromTouch)
1510 return dispatchMouseEvent(mouseEventType, m_nodeUnderMouse, clickCount, mouseEvent); 1513 return dispatchMouseEvent(mouseEventType, m_nodeUnderMouse, clickCount, mouseEvent);
1511 1514
1512 return m_pointerEventManager.sendMousePointerEvent( 1515 Node* newNodeUnderMouse = nullptr;
1516 const auto& retVal = m_pointerEventManager.sendMousePointerEvent(
1513 m_nodeUnderMouse, mouseEventType, clickCount, mouseEvent, nullptr, 1517 m_nodeUnderMouse, mouseEventType, clickCount, mouseEvent, nullptr,
1514 lastNodeUnderMouse); 1518 lastNodeUnderMouse, &newNodeUnderMouse);
1519 m_nodeUnderMouse = newNodeUnderMouse;
1520 return retVal;
1515 } 1521 }
1516 1522
1517 void EventHandler::setClickNode(Node* node) 1523 void EventHandler::setClickNode(Node* node)
1518 { 1524 {
1519 m_clickNode = node; 1525 m_clickNode = node;
1520 } 1526 }
1521 1527
1522 WebInputEventResult EventHandler::handleMouseFocus(const MouseEventWithHitTestRe sults& targetedEvent, InputDeviceCapabilities* sourceCapabilities) 1528 WebInputEventResult EventHandler::handleMouseFocus(const MouseEventWithHitTestRe sults& targetedEvent, InputDeviceCapabilities* sourceCapabilities)
1523 { 1529 {
1524 // If clicking on a frame scrollbar, do not mess up with content focus. 1530 // If clicking on a frame scrollbar, do not mess up with content focus.
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
2585 2591
2586 FrameHost* EventHandler::frameHost() const 2592 FrameHost* EventHandler::frameHost() const
2587 { 2593 {
2588 if (!m_frame->page()) 2594 if (!m_frame->page())
2589 return nullptr; 2595 return nullptr;
2590 2596
2591 return &m_frame->page()->frameHost(); 2597 return &m_frame->page()->frameHost();
2592 } 2598 }
2593 2599
2594 } // namespace blink 2600 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698