Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1519 | 1519 |
| 1520 m_lastNodeUnderMouse = m_nodeUnderMouse; | 1520 m_lastNodeUnderMouse = m_nodeUnderMouse; |
| 1521 } | 1521 } |
| 1522 } | 1522 } |
| 1523 | 1523 |
| 1524 void EventHandler::sendMouseEventsForNodeTransition(Node* exitedNode, Node* ente redNode, const PlatformMouseEvent& mouseEvent) | 1524 void EventHandler::sendMouseEventsForNodeTransition(Node* exitedNode, Node* ente redNode, const PlatformMouseEvent& mouseEvent) |
| 1525 { | 1525 { |
| 1526 ASSERT(exitedNode != enteredNode); | 1526 ASSERT(exitedNode != enteredNode); |
| 1527 | 1527 |
| 1528 // First, dispatch mouseout event (which bubbles to ancestors) | 1528 // First, dispatch mouseout event (which bubbles to ancestors) |
| 1529 if (exitedNode) | 1529 if (exitedNode && exitedNode->inDocument()) |
|
dtapuska
2015/08/14 17:20:09
Can we just make an anonymous scope function to ch
mustaq
2015/08/14 21:00:15
Done.
| |
| 1530 exitedNode->dispatchMouseEvent(mouseEvent, EventTypeNames::mouseout, 0, enteredNode); | 1530 exitedNode->dispatchMouseEvent(mouseEvent, EventTypeNames::mouseout, 0, enteredNode); |
| 1531 | 1531 |
| 1532 // A note on mouseenter and mouseleave: These are non-bubbling events, and t hey are dispatched if there | 1532 // A note on mouseenter and mouseleave: These are non-bubbling events, and t hey are dispatched if there |
| 1533 // is a capturing event handler on an ancestor or a normal event handler on the element itself. This special | 1533 // is a capturing event handler on an ancestor or a normal event handler on the element itself. This special |
| 1534 // handling is necessary to avoid O(n^2) capturing event handler checks. | 1534 // handling is necessary to avoid O(n^2) capturing event handler checks. |
| 1535 // | 1535 // |
| 1536 // Note, however, that this optimization can possibly cause some unanswere d/missing/redundant mouseenter or | 1536 // Note, however, that this optimization can possibly cause some unanswere d/missing/redundant mouseenter or |
| 1537 // mouseleave events in certain contrived eventhandling scenarios, e.g., whe n: | 1537 // mouseleave events in certain contrived eventhandling scenarios, e.g., whe n: |
| 1538 // - the mouseleave handler for a node sets the only capturing-mouseleave-li stener in its ancestor, or | 1538 // - the mouseleave handler for a node sets the only capturing-mouseleave-li stener in its ancestor, or |
| 1539 // - DOM mods in any mouseenter/mouseleave handler changes the common ancest or of exited & entered nodes, etc. | 1539 // - DOM mods in any mouseenter/mouseleave handler changes the common ancest or of exited & entered nodes, etc. |
| 1540 // We think the spec specifies a "frozen" state to avoid such corner cases ( check the discussion on "candidate event | 1540 // We think the spec specifies a "frozen" state to avoid such corner cases ( check the discussion on "candidate event |
| 1541 // listeners" at http://www.w3.org/TR/uievents), but our code below preserve s one such behavior from past only to | 1541 // listeners" at http://www.w3.org/TR/uievents), but our code below preserve s one such behavior from past only to |
| 1542 // match Firefox and IE behavior. | 1542 // match Firefox and IE behavior. |
| 1543 // | 1543 // |
| 1544 // TODO(mustaq): Confirm spec conformance, double-check with other browsers. | 1544 // TODO(mustaq): Confirm spec conformance, double-check with other browsers. |
| 1545 | 1545 |
| 1546 // Create lists of all exited/entered ancestors. | 1546 // Create lists of all exited/entered ancestors. |
| 1547 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> exitedAncestors; | 1547 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> exitedAncestors; |
| 1548 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> enteredAncestors; | 1548 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> enteredAncestors; |
| 1549 if (exitedNode) { | 1549 if (exitedNode && exitedNode->inDocument()) { |
| 1550 exitedNode->updateDistribution(); | 1550 exitedNode->updateDistribution(); |
| 1551 for (Node* node = exitedNode; node; node = ComposedTreeTraversal::parent (*node)) { | 1551 for (Node* node = exitedNode; node; node = ComposedTreeTraversal::parent (*node)) { |
| 1552 exitedAncestors.append(node); | 1552 exitedAncestors.append(node); |
| 1553 } | 1553 } |
| 1554 } | 1554 } |
| 1555 if (enteredNode) { | 1555 if (enteredNode && enteredNode->inDocument()) { |
| 1556 enteredNode->updateDistribution(); | 1556 enteredNode->updateDistribution(); |
| 1557 for (Node* node = enteredNode; node; node = ComposedTreeTraversal::paren t(*node)) { | 1557 for (Node* node = enteredNode; node; node = ComposedTreeTraversal::paren t(*node)) { |
| 1558 enteredAncestors.append(node); | 1558 enteredAncestors.append(node); |
| 1559 } | 1559 } |
| 1560 } | 1560 } |
| 1561 | 1561 |
| 1562 size_t numExitedAncestors = exitedAncestors.size(); | 1562 size_t numExitedAncestors = exitedAncestors.size(); |
| 1563 size_t numEnteredAncestors = enteredAncestors.size(); | 1563 size_t numEnteredAncestors = enteredAncestors.size(); |
| 1564 | 1564 |
| 1565 // Locate the common ancestor in the two lists. Start with the assumption th at it's off both the lists. | 1565 // Locate the common ancestor in the two lists. Start with the assumption th at it's off both the lists. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1584 exitedNodeHasCapturingAncestor = true; | 1584 exitedNodeHasCapturingAncestor = true; |
| 1585 } | 1585 } |
| 1586 | 1586 |
| 1587 // Send mouseleave events to appropriate exited ancestors, in child-to-paren t order. | 1587 // Send mouseleave events to appropriate exited ancestors, in child-to-paren t order. |
| 1588 for (size_t j = 0; j < exitedAncestorIndex; j++) { | 1588 for (size_t j = 0; j < exitedAncestorIndex; j++) { |
| 1589 if (exitedNodeHasCapturingAncestor || exitedAncestors[j]->hasEventListen ers(EventTypeNames::mouseleave)) | 1589 if (exitedNodeHasCapturingAncestor || exitedAncestors[j]->hasEventListen ers(EventTypeNames::mouseleave)) |
| 1590 exitedAncestors[j]->dispatchMouseEvent(mouseEvent, EventTypeNames::m ouseleave, 0, enteredNode); | 1590 exitedAncestors[j]->dispatchMouseEvent(mouseEvent, EventTypeNames::m ouseleave, 0, enteredNode); |
| 1591 } | 1591 } |
| 1592 | 1592 |
| 1593 // Dispatch mouseover event (which bubbles to ancestors) after the mouseleav e events are sent. | 1593 // Dispatch mouseover event (which bubbles to ancestors) after the mouseleav e events are sent. |
| 1594 if (enteredNode) | 1594 if (enteredNode && enteredNode->inDocument()) |
| 1595 enteredNode->dispatchMouseEvent(mouseEvent, EventTypeNames::mouseover, 0 , exitedNode); | 1595 enteredNode->dispatchMouseEvent(mouseEvent, EventTypeNames::mouseover, 0 , exitedNode); |
| 1596 | 1596 |
| 1597 // Determine if there is a capturing mouseenter listener in an ancestor. Thi s must be done /after/ dispatching the | 1597 // Determine if there is a capturing mouseenter listener in an ancestor. Thi s must be done /after/ dispatching the |
| 1598 // mouseleave events because the handler for mouseleave might set a capturin g mouseenter handler. | 1598 // mouseleave events because the handler for mouseleave might set a capturin g mouseenter handler. |
| 1599 bool enteredNodeHasCapturingAncestor = false; | 1599 bool enteredNodeHasCapturingAncestor = false; |
| 1600 for (size_t i = 0; i < numEnteredAncestors; i++) { | 1600 for (size_t i = 0; i < numEnteredAncestors; i++) { |
| 1601 if (enteredAncestors[i]->hasCapturingEventListeners(EventTypeNames::mous eenter)) | 1601 if (enteredAncestors[i]->hasCapturingEventListeners(EventTypeNames::mous eenter)) |
| 1602 enteredNodeHasCapturingAncestor = true; | 1602 enteredNodeHasCapturingAncestor = true; |
| 1603 } | 1603 } |
| 1604 | 1604 |
| (...skipping 2394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3999 unsigned EventHandler::accessKeyModifiers() | 3999 unsigned EventHandler::accessKeyModifiers() |
| 4000 { | 4000 { |
| 4001 #if OS(MACOSX) | 4001 #if OS(MACOSX) |
| 4002 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4002 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 4003 #else | 4003 #else |
| 4004 return PlatformEvent::AltKey; | 4004 return PlatformEvent::AltKey; |
| 4005 #endif | 4005 #endif |
| 4006 } | 4006 } |
| 4007 | 4007 |
| 4008 } // namespace blink | 4008 } // namespace blink |
| OLD | NEW |