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

Side by Side Diff: Source/core/page/EventHandler.cpp

Issue 1071863002: Prefer ComposedTreeTraversal to NodeRenderingTraversal. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
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 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMo useEvent& mouseEvent, bool fireMouseEvents) 1870 void EventHandler::updateMouseEventTargetNode(Node* targetNode, const PlatformMo useEvent& mouseEvent, bool fireMouseEvents)
1871 { 1871 {
1872 Node* result = targetNode; 1872 Node* result = targetNode;
1873 1873
1874 // If we're capturing, we always go right to that node. 1874 // If we're capturing, we always go right to that node.
1875 if (m_capturingMouseEventsNode) { 1875 if (m_capturingMouseEventsNode) {
1876 result = m_capturingMouseEventsNode.get(); 1876 result = m_capturingMouseEventsNode.get();
1877 } else { 1877 } else {
1878 // If the target node is a text node, dispatch on the parent node - rdar ://4196646 1878 // If the target node is a text node, dispatch on the parent node - rdar ://4196646
1879 if (result && result->isTextNode()) 1879 if (result && result->isTextNode())
1880 result = NodeRenderingTraversal::parent(*result); 1880 result = ComposedTreeTraversal::parent(*result);
1881 } 1881 }
1882 m_nodeUnderMouse = result; 1882 m_nodeUnderMouse = result;
1883 1883
1884 if (fireMouseEvents) { 1884 if (fireMouseEvents) {
1885 DeprecatedPaintLayer* layerForLastNode = layerForNode(m_lastNodeUnderMou se.get()); 1885 DeprecatedPaintLayer* layerForLastNode = layerForNode(m_lastNodeUnderMou se.get());
1886 DeprecatedPaintLayer* layerForNodeUnderMouse = layerForNode(m_nodeUnderM ouse.get()); 1886 DeprecatedPaintLayer* layerForNodeUnderMouse = layerForNode(m_nodeUnderM ouse.get());
1887 Page* page = m_frame->page(); 1887 Page* page = m_frame->page();
1888 1888
1889 if (m_lastNodeUnderMouse && (!m_nodeUnderMouse || m_nodeUnderMouse->docu ment() != m_frame->document())) { 1889 if (m_lastNodeUnderMouse && (!m_nodeUnderMouse || m_nodeUnderMouse->docu ment() != m_frame->document())) {
1890 // The mouse has moved between frames. 1890 // The mouse has moved between frames.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 // - DOM mods in any mouseenter/mouseleave handler changes the common ancest or of exited & entered nodes, etc. 1942 // - DOM mods in any mouseenter/mouseleave handler changes the common ancest or of exited & entered nodes, etc.
1943 // We think the spec specifies a "frozen" state to avoid such corner cases ( check the discussion on "candidate event 1943 // We think the spec specifies a "frozen" state to avoid such corner cases ( check the discussion on "candidate event
1944 // listeners" at http://www.w3.org/TR/uievents), but our code below preserve s one such behavior from past only to 1944 // listeners" at http://www.w3.org/TR/uievents), but our code below preserve s one such behavior from past only to
1945 // match Firefox and IE behavior. 1945 // match Firefox and IE behavior.
1946 // 1946 //
1947 // TODO(mustaq): Confirm spec conformance, double-check with other browsers. 1947 // TODO(mustaq): Confirm spec conformance, double-check with other browsers.
1948 1948
1949 // Create lists of all exited/entered ancestors. 1949 // Create lists of all exited/entered ancestors.
1950 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> exitedAncestors; 1950 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> exitedAncestors;
1951 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> enteredAncestors; 1951 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> enteredAncestors;
1952 for (Node* node = exitedNode; node; node = NodeRenderingTraversal::parent(*n ode)) { 1952 for (Node* node = exitedNode; node; node = ComposedTreeTraversal::parent(*no de)) {
1953 exitedAncestors.append(node); 1953 exitedAncestors.append(node);
1954 } 1954 }
1955 for (Node* node = enteredNode; node; node = NodeRenderingTraversal::parent(* node)) { 1955 for (Node* node = enteredNode; node; node = ComposedTreeTraversal::parent(*n ode)) {
1956 enteredAncestors.append(node); 1956 enteredAncestors.append(node);
1957 } 1957 }
1958 1958
1959 size_t numExitedAncestors = exitedAncestors.size(); 1959 size_t numExitedAncestors = exitedAncestors.size();
1960 size_t numEnteredAncestors = enteredAncestors.size(); 1960 size_t numEnteredAncestors = enteredAncestors.size();
1961 1961
1962 // Locate the common ancestor in the two lists. Start with the assumption th at it's off both the lists. 1962 // Locate the common ancestor in the two lists. Start with the assumption th at it's off both the lists.
1963 size_t exitedAncestorIndex = numExitedAncestors; 1963 size_t exitedAncestorIndex = numExitedAncestors;
1964 size_t enteredAncestorIndex = numEnteredAncestors; 1964 size_t enteredAncestorIndex = numEnteredAncestors;
1965 for (size_t j = 0; j < numExitedAncestors; j++) { 1965 for (size_t j = 0; j < numExitedAncestors; j++) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 2119
2120 LayoutPoint vPoint = view->rootFrameToContents(event.position()); 2120 LayoutPoint vPoint = view->rootFrameToContents(event.position());
2121 2121
2122 HitTestRequest request(HitTestRequest::ReadOnly); 2122 HitTestRequest request(HitTestRequest::ReadOnly);
2123 HitTestResult result(request, vPoint); 2123 HitTestResult result(request, vPoint);
2124 doc->layoutView()->hitTest(result); 2124 doc->layoutView()->hitTest(result);
2125 2125
2126 Node* node = result.innerNode(); 2126 Node* node = result.innerNode();
2127 // Wheel events should not dispatch to text nodes. 2127 // Wheel events should not dispatch to text nodes.
2128 if (node && node->isTextNode()) 2128 if (node && node->isTextNode())
2129 node = NodeRenderingTraversal::parent(*node); 2129 node = ComposedTreeTraversal::parent(*node);
2130 2130
2131 bool isOverWidget; 2131 bool isOverWidget;
2132 if (event.useLatchedEventNode()) { 2132 if (event.useLatchedEventNode()) {
2133 if (!m_latchedWheelEventNode) { 2133 if (!m_latchedWheelEventNode) {
2134 m_latchedWheelEventNode = node; 2134 m_latchedWheelEventNode = node;
2135 m_widgetIsLatched = result.isOverWidget(); 2135 m_widgetIsLatched = result.isOverWidget();
2136 } else { 2136 } else {
2137 node = m_latchedWheelEventNode.get(); 2137 node = m_latchedWheelEventNode.get();
2138 } 2138 }
2139 2139
(...skipping 1936 matching lines...) Expand 10 before | Expand all | Expand 10 after
4076 unsigned EventHandler::accessKeyModifiers() 4076 unsigned EventHandler::accessKeyModifiers()
4077 { 4077 {
4078 #if OS(MACOSX) 4078 #if OS(MACOSX)
4079 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 4079 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
4080 #else 4080 #else
4081 return PlatformEvent::AltKey; 4081 return PlatformEvent::AltKey;
4082 #endif 4082 #endif
4083 } 4083 }
4084 4084
4085 } // namespace blink 4085 } // namespace blink
OLDNEW
« Source/core/dom/Node.cpp ('K') | « Source/core/layout/LayoutListItem.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698