| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
| 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 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 | 930 |
| 931 m_domEditor->replaceWholeText(toText(node), value, errorString); | 931 m_domEditor->replaceWholeText(toText(node), value, errorString); |
| 932 } | 932 } |
| 933 | 933 |
| 934 void InspectorDOMAgent::getEventListenersForNode(ErrorString* errorString, int n
odeId, const String* objectGroup, RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Ev
entListener> >& listenersArray) | 934 void InspectorDOMAgent::getEventListenersForNode(ErrorString* errorString, int n
odeId, const String* objectGroup, RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Ev
entListener> >& listenersArray) |
| 935 { | 935 { |
| 936 listenersArray = TypeBuilder::Array<TypeBuilder::DOM::EventListener>::create
(); | 936 listenersArray = TypeBuilder::Array<TypeBuilder::DOM::EventListener>::create
(); |
| 937 Node* node = assertNode(errorString, nodeId); | 937 Node* node = assertNode(errorString, nodeId); |
| 938 if (!node) | 938 if (!node) |
| 939 return; | 939 return; |
| 940 |
| 940 Vector<EventListenerInfo> eventInformation; | 941 Vector<EventListenerInfo> eventInformation; |
| 941 getEventListeners(node, eventInformation, true); | 942 EventListenerInfo::getEventListeners(node, eventInformation, true); |
| 942 | 943 if (!eventInformation.size()) |
| 943 // Get Capturing Listeners (in this order) | 944 return; |
| 944 size_t eventInformationLength = eventInformation.size(); | 945 RegisteredEventListenerIterator iterator(eventInformation); |
| 945 for (size_t i = 0; i < eventInformationLength; ++i) { | 946 while (const RegisteredEventListener* listener = iterator.nextRegisteredEven
tListener()) { |
| 946 const EventListenerInfo& info = eventInformation[i]; | 947 const EventListenerInfo& info = iterator.currentEventListenerInfo(); |
| 947 const EventListenerVector& vector = info.eventListenerVector; | 948 RefPtr<TypeBuilder::DOM::EventListener> listenerObject = buildObjectForE
ventListener(*listener, info.eventType, info.eventTarget->toNode(), objectGroup)
; |
| 948 for (size_t j = 0; j < vector.size(); ++j) { | 949 if (listenerObject) |
| 949 const RegisteredEventListener& listener = vector[j]; | 950 listenersArray->addItem(listenerObject); |
| 950 if (listener.useCapture) { | |
| 951 RefPtr<TypeBuilder::DOM::EventListener> listenerObject = buildOb
jectForEventListener(listener, info.eventType, info.eventTarget->toNode(), objec
tGroup); | |
| 952 if (listenerObject) | |
| 953 listenersArray->addItem(listenerObject); | |
| 954 } | |
| 955 } | |
| 956 } | |
| 957 | |
| 958 // Get Bubbling Listeners (reverse order) | |
| 959 for (size_t i = eventInformationLength; i; --i) { | |
| 960 const EventListenerInfo& info = eventInformation[i - 1]; | |
| 961 const EventListenerVector& vector = info.eventListenerVector; | |
| 962 for (size_t j = 0; j < vector.size(); ++j) { | |
| 963 const RegisteredEventListener& listener = vector[j]; | |
| 964 if (!listener.useCapture) { | |
| 965 RefPtr<TypeBuilder::DOM::EventListener> listenerObject = buildOb
jectForEventListener(listener, info.eventType, info.eventTarget->toNode(), objec
tGroup); | |
| 966 if (listenerObject) | |
| 967 listenersArray->addItem(listenerObject); | |
| 968 } | |
| 969 } | |
| 970 } | 951 } |
| 971 } | 952 } |
| 972 | 953 |
| 973 void InspectorDOMAgent::getEventListeners(EventTarget* target, Vector<EventListe
nerInfo>& eventInformation, bool includeAncestors) | |
| 974 { | |
| 975 // The Node's Ancestors including self. | |
| 976 Vector<EventTarget*> ancestors; | |
| 977 ancestors.append(target); | |
| 978 if (includeAncestors) { | |
| 979 Node* node = target->toNode(); | |
| 980 for (ContainerNode* ancestor = node ? node->parentOrShadowHostNode() : n
ullptr; ancestor; ancestor = ancestor->parentOrShadowHostNode()) | |
| 981 ancestors.append(ancestor); | |
| 982 } | |
| 983 | |
| 984 // Nodes and their Listeners for the concerned event types (order is top to
bottom) | |
| 985 for (size_t i = ancestors.size(); i; --i) { | |
| 986 EventTarget* ancestor = ancestors[i - 1]; | |
| 987 Vector<AtomicString> eventTypes = ancestor->eventTypes(); | |
| 988 for (size_t j = 0; j < eventTypes.size(); ++j) { | |
| 989 AtomicString& type = eventTypes[j]; | |
| 990 const EventListenerVector& listeners = ancestor->getEventListeners(t
ype); | |
| 991 EventListenerVector filteredListeners; | |
| 992 filteredListeners.reserveCapacity(listeners.size()); | |
| 993 for (size_t k = 0; k < listeners.size(); ++k) { | |
| 994 if (listeners[k].listener->type() == EventListener::JSEventListe
nerType) | |
| 995 filteredListeners.append(listeners[k]); | |
| 996 } | |
| 997 if (!filteredListeners.isEmpty()) | |
| 998 eventInformation.append(EventListenerInfo(ancestor, type, filter
edListeners)); | |
| 999 } | |
| 1000 } | |
| 1001 } | |
| 1002 | |
| 1003 static Node* nextNodeWithShadowDOMInMind(const Node& current, const Node* stayWi
thin, bool includeUserAgentShadowDOM) | 954 static Node* nextNodeWithShadowDOMInMind(const Node& current, const Node* stayWi
thin, bool includeUserAgentShadowDOM) |
| 1004 { | 955 { |
| 1005 // At first traverse the subtree. | 956 // At first traverse the subtree. |
| 1006 if (current.isElementNode()) { | 957 if (current.isElementNode()) { |
| 1007 const Element& element = toElement(current); | 958 const Element& element = toElement(current); |
| 1008 ElementShadow* elementShadow = element.shadow(); | 959 ElementShadow* elementShadow = element.shadow(); |
| 1009 if (elementShadow) { | 960 if (elementShadow) { |
| 1010 ShadowRoot* shadowRoot = elementShadow->youngestShadowRoot(); | 961 ShadowRoot* shadowRoot = elementShadow->youngestShadowRoot(); |
| 1011 if (shadowRoot) { | 962 if (shadowRoot) { |
| 1012 if (shadowRoot->type() == ShadowRoot::OpenShadowRoot || includeU
serAgentShadowDOM) | 963 if (shadowRoot->type() == ShadowRoot::OpenShadowRoot || includeU
serAgentShadowDOM) |
| (...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2299 visitor->trace(m_searchResults); | 2250 visitor->trace(m_searchResults); |
| 2300 #endif | 2251 #endif |
| 2301 visitor->trace(m_hoveredNodeForInspectMode); | 2252 visitor->trace(m_hoveredNodeForInspectMode); |
| 2302 visitor->trace(m_history); | 2253 visitor->trace(m_history); |
| 2303 visitor->trace(m_domEditor); | 2254 visitor->trace(m_domEditor); |
| 2304 visitor->trace(m_listener); | 2255 visitor->trace(m_listener); |
| 2305 InspectorBaseAgent::trace(visitor); | 2256 InspectorBaseAgent::trace(visitor); |
| 2306 } | 2257 } |
| 2307 | 2258 |
| 2308 } // namespace blink | 2259 } // namespace blink |
| OLD | NEW |