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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 #include "platform/heap/Handle.h" | 91 #include "platform/heap/Handle.h" |
92 #include "platform/scroll/ScrollAnimator.h" | 92 #include "platform/scroll/ScrollAnimator.h" |
93 #include "platform/scroll/Scrollbar.h" | 93 #include "platform/scroll/Scrollbar.h" |
94 #include "wtf/Assertions.h" | 94 #include "wtf/Assertions.h" |
95 #include "wtf/CurrentTime.h" | 95 #include "wtf/CurrentTime.h" |
96 #include "wtf/StdLibExtras.h" | 96 #include "wtf/StdLibExtras.h" |
97 #include "wtf/TemporaryChange.h" | 97 #include "wtf/TemporaryChange.h" |
98 | 98 |
99 namespace blink { | 99 namespace blink { |
100 | 100 |
| 101 namespace { |
| 102 |
| 103 bool isNodeInDocument(Node* n) |
| 104 { |
| 105 return n && n->inDocument(); |
| 106 } |
| 107 |
| 108 } |
| 109 |
101 using namespace HTMLNames; | 110 using namespace HTMLNames; |
102 | 111 |
103 // The link drag hysteresis is much larger than the others because there | 112 // The link drag hysteresis is much larger than the others because there |
104 // needs to be enough space to cancel the link press without starting a link dra
g, | 113 // needs to be enough space to cancel the link press without starting a link dra
g, |
105 // and because dragging links is rare. | 114 // and because dragging links is rare. |
106 static const int LinkDragHysteresis = 40; | 115 static const int LinkDragHysteresis = 40; |
107 static const int ImageDragHysteresis = 5; | 116 static const int ImageDragHysteresis = 5; |
108 static const int TextDragHysteresis = 3; | 117 static const int TextDragHysteresis = 3; |
109 static const int GeneralDragHysteresis = 3; | 118 static const int GeneralDragHysteresis = 3; |
110 | 119 |
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 | 1528 |
1520 m_lastNodeUnderMouse = m_nodeUnderMouse; | 1529 m_lastNodeUnderMouse = m_nodeUnderMouse; |
1521 } | 1530 } |
1522 } | 1531 } |
1523 | 1532 |
1524 void EventHandler::sendMouseEventsForNodeTransition(Node* exitedNode, Node* ente
redNode, const PlatformMouseEvent& mouseEvent) | 1533 void EventHandler::sendMouseEventsForNodeTransition(Node* exitedNode, Node* ente
redNode, const PlatformMouseEvent& mouseEvent) |
1525 { | 1534 { |
1526 ASSERT(exitedNode != enteredNode); | 1535 ASSERT(exitedNode != enteredNode); |
1527 | 1536 |
1528 // First, dispatch mouseout event (which bubbles to ancestors) | 1537 // First, dispatch mouseout event (which bubbles to ancestors) |
1529 if (exitedNode) | 1538 if (isNodeInDocument(exitedNode)) |
1530 exitedNode->dispatchMouseEvent(mouseEvent, EventTypeNames::mouseout, 0,
enteredNode); | 1539 exitedNode->dispatchMouseEvent(mouseEvent, EventTypeNames::mouseout, 0,
enteredNode); |
1531 | 1540 |
1532 // A note on mouseenter and mouseleave: These are non-bubbling events, and t
hey are dispatched if there | 1541 // 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 | 1542 // 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. | 1543 // handling is necessary to avoid O(n^2) capturing event handler checks. |
1535 // | 1544 // |
1536 // Note, however, that this optimization can possibly cause some unanswere
d/missing/redundant mouseenter or | 1545 // 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: | 1546 // 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 | 1547 // - 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. | 1548 // - 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 | 1549 // 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 | 1550 // 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. | 1551 // match Firefox and IE behavior. |
1543 // | 1552 // |
1544 // TODO(mustaq): Confirm spec conformance, double-check with other browsers. | 1553 // TODO(mustaq): Confirm spec conformance, double-check with other browsers. |
1545 | 1554 |
1546 // Create lists of all exited/entered ancestors. | 1555 // Create lists of all exited/entered ancestors. |
1547 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> exitedAncestors; | 1556 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> exitedAncestors; |
1548 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> enteredAncestors; | 1557 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> enteredAncestors; |
1549 if (exitedNode) { | 1558 if (isNodeInDocument(exitedNode)) { |
1550 exitedNode->updateDistribution(); | 1559 exitedNode->updateDistribution(); |
1551 for (Node* node = exitedNode; node; node = ComposedTreeTraversal::parent
(*node)) { | 1560 for (Node* node = exitedNode; node; node = ComposedTreeTraversal::parent
(*node)) { |
1552 exitedAncestors.append(node); | 1561 exitedAncestors.append(node); |
1553 } | 1562 } |
1554 } | 1563 } |
1555 if (enteredNode) { | 1564 if (isNodeInDocument(enteredNode)) { |
1556 enteredNode->updateDistribution(); | 1565 enteredNode->updateDistribution(); |
1557 for (Node* node = enteredNode; node; node = ComposedTreeTraversal::paren
t(*node)) { | 1566 for (Node* node = enteredNode; node; node = ComposedTreeTraversal::paren
t(*node)) { |
1558 enteredAncestors.append(node); | 1567 enteredAncestors.append(node); |
1559 } | 1568 } |
1560 } | 1569 } |
1561 | 1570 |
1562 size_t numExitedAncestors = exitedAncestors.size(); | 1571 size_t numExitedAncestors = exitedAncestors.size(); |
1563 size_t numEnteredAncestors = enteredAncestors.size(); | 1572 size_t numEnteredAncestors = enteredAncestors.size(); |
1564 | 1573 |
1565 // Locate the common ancestor in the two lists. Start with the assumption th
at it's off both the lists. | 1574 // 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; | 1593 exitedNodeHasCapturingAncestor = true; |
1585 } | 1594 } |
1586 | 1595 |
1587 // Send mouseleave events to appropriate exited ancestors, in child-to-paren
t order. | 1596 // Send mouseleave events to appropriate exited ancestors, in child-to-paren
t order. |
1588 for (size_t j = 0; j < exitedAncestorIndex; j++) { | 1597 for (size_t j = 0; j < exitedAncestorIndex; j++) { |
1589 if (exitedNodeHasCapturingAncestor || exitedAncestors[j]->hasEventListen
ers(EventTypeNames::mouseleave)) | 1598 if (exitedNodeHasCapturingAncestor || exitedAncestors[j]->hasEventListen
ers(EventTypeNames::mouseleave)) |
1590 exitedAncestors[j]->dispatchMouseEvent(mouseEvent, EventTypeNames::m
ouseleave, 0, enteredNode); | 1599 exitedAncestors[j]->dispatchMouseEvent(mouseEvent, EventTypeNames::m
ouseleave, 0, enteredNode); |
1591 } | 1600 } |
1592 | 1601 |
1593 // Dispatch mouseover event (which bubbles to ancestors) after the mouseleav
e events are sent. | 1602 // Dispatch mouseover event (which bubbles to ancestors) after the mouseleav
e events are sent. |
1594 if (enteredNode) | 1603 if (isNodeInDocument(enteredNode)) |
1595 enteredNode->dispatchMouseEvent(mouseEvent, EventTypeNames::mouseover, 0
, exitedNode); | 1604 enteredNode->dispatchMouseEvent(mouseEvent, EventTypeNames::mouseover, 0
, exitedNode); |
1596 | 1605 |
1597 // Determine if there is a capturing mouseenter listener in an ancestor. Thi
s must be done /after/ dispatching the | 1606 // 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. | 1607 // mouseleave events because the handler for mouseleave might set a capturin
g mouseenter handler. |
1599 bool enteredNodeHasCapturingAncestor = false; | 1608 bool enteredNodeHasCapturingAncestor = false; |
1600 for (size_t i = 0; i < numEnteredAncestors; i++) { | 1609 for (size_t i = 0; i < numEnteredAncestors; i++) { |
1601 if (enteredAncestors[i]->hasCapturingEventListeners(EventTypeNames::mous
eenter)) | 1610 if (enteredAncestors[i]->hasCapturingEventListeners(EventTypeNames::mous
eenter)) |
1602 enteredNodeHasCapturingAncestor = true; | 1611 enteredNodeHasCapturingAncestor = true; |
1603 } | 1612 } |
1604 | 1613 |
(...skipping 2394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3999 unsigned EventHandler::accessKeyModifiers() | 4008 unsigned EventHandler::accessKeyModifiers() |
4000 { | 4009 { |
4001 #if OS(MACOSX) | 4010 #if OS(MACOSX) |
4002 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4011 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
4003 #else | 4012 #else |
4004 return PlatformEvent::AltKey; | 4013 return PlatformEvent::AltKey; |
4005 #endif | 4014 #endif |
4006 } | 4015 } |
4007 | 4016 |
4008 } // namespace blink | 4017 } // namespace blink |
OLD | NEW |