| 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 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 getEventListeners(node, eventInformation, true); | 856 getEventListeners(node, eventInformation, true); |
| 857 | 857 |
| 858 // Get Capturing Listeners (in this order) | 858 // Get Capturing Listeners (in this order) |
| 859 size_t eventInformationLength = eventInformation.size(); | 859 size_t eventInformationLength = eventInformation.size(); |
| 860 for (size_t i = 0; i < eventInformationLength; ++i) { | 860 for (size_t i = 0; i < eventInformationLength; ++i) { |
| 861 const EventListenerInfo& info = eventInformation[i]; | 861 const EventListenerInfo& info = eventInformation[i]; |
| 862 const EventListenerVector& vector = info.eventListenerVector; | 862 const EventListenerVector& vector = info.eventListenerVector; |
| 863 for (size_t j = 0; j < vector.size(); ++j) { | 863 for (size_t j = 0; j < vector.size(); ++j) { |
| 864 const RegisteredEventListener& listener = vector[j]; | 864 const RegisteredEventListener& listener = vector[j]; |
| 865 if (listener.useCapture) | 865 if (listener.useCapture) |
| 866 listenersArray->addItem(buildObjectForEventListener(listener, in
fo.eventType, info.node, objectGroup)); | 866 listenersArray->addItem(buildObjectForEventListener(listener, in
fo.eventType, info.eventTarget->toNode(), objectGroup)); |
| 867 } | 867 } |
| 868 } | 868 } |
| 869 | 869 |
| 870 // Get Bubbling Listeners (reverse order) | 870 // Get Bubbling Listeners (reverse order) |
| 871 for (size_t i = eventInformationLength; i; --i) { | 871 for (size_t i = eventInformationLength; i; --i) { |
| 872 const EventListenerInfo& info = eventInformation[i - 1]; | 872 const EventListenerInfo& info = eventInformation[i - 1]; |
| 873 const EventListenerVector& vector = info.eventListenerVector; | 873 const EventListenerVector& vector = info.eventListenerVector; |
| 874 for (size_t j = 0; j < vector.size(); ++j) { | 874 for (size_t j = 0; j < vector.size(); ++j) { |
| 875 const RegisteredEventListener& listener = vector[j]; | 875 const RegisteredEventListener& listener = vector[j]; |
| 876 if (!listener.useCapture) | 876 if (!listener.useCapture) |
| 877 listenersArray->addItem(buildObjectForEventListener(listener, in
fo.eventType, info.node, objectGroup)); | 877 listenersArray->addItem(buildObjectForEventListener(listener, in
fo.eventType, info.eventTarget->toNode(), objectGroup)); |
| 878 } | 878 } |
| 879 } | 879 } |
| 880 } | 880 } |
| 881 | 881 |
| 882 void InspectorDOMAgent::getEventListeners(Node* node, Vector<EventListenerInfo>&
eventInformation, bool includeAncestors) | 882 void InspectorDOMAgent::getEventListeners(EventTarget* target, Vector<EventListe
nerInfo>& eventInformation, bool includeAncestors) |
| 883 { | 883 { |
| 884 // The Node's Ancestors including self. | 884 // The Node's Ancestors including self. |
| 885 Vector<Node*> ancestors; | 885 Vector<EventTarget*> ancestors; |
| 886 // Push this node as the firs element. | 886 ancestors.append(target); |
| 887 ancestors.append(node); | |
| 888 if (includeAncestors) { | 887 if (includeAncestors) { |
| 889 for (ContainerNode* ancestor = node->parentOrShadowHostNode(); ancestor;
ancestor = ancestor->parentOrShadowHostNode()) | 888 Node* node = target->toNode(); |
| 889 for (ContainerNode* ancestor = node ? node->parentOrShadowHostNode() : 0
; ancestor; ancestor = ancestor->parentOrShadowHostNode()) |
| 890 ancestors.append(ancestor); | 890 ancestors.append(ancestor); |
| 891 } | 891 } |
| 892 | 892 |
| 893 // Nodes and their Listeners for the concerned event types (order is top to
bottom) | 893 // Nodes and their Listeners for the concerned event types (order is top to
bottom) |
| 894 for (size_t i = ancestors.size(); i; --i) { | 894 for (size_t i = ancestors.size(); i; --i) { |
| 895 Node* ancestor = ancestors[i - 1]; | 895 EventTarget* ancestor = ancestors[i - 1]; |
| 896 EventTargetData* d = ancestor->eventTargetData(); | 896 Vector<AtomicString> eventTypes = ancestor->eventTypes(); |
| 897 if (!d) | |
| 898 continue; | |
| 899 // Get the list of event types this Node is concerned with | |
| 900 Vector<AtomicString> eventTypes = d->eventListenerMap.eventTypes(); | |
| 901 for (size_t j = 0; j < eventTypes.size(); ++j) { | 897 for (size_t j = 0; j < eventTypes.size(); ++j) { |
| 902 AtomicString& type = eventTypes[j]; | 898 AtomicString& type = eventTypes[j]; |
| 903 const EventListenerVector& listeners = ancestor->getEventListeners(t
ype); | 899 const EventListenerVector& listeners = ancestor->getEventListeners(t
ype); |
| 904 EventListenerVector filteredListeners; | 900 EventListenerVector filteredListeners; |
| 905 filteredListeners.reserveCapacity(listeners.size()); | 901 filteredListeners.reserveCapacity(listeners.size()); |
| 906 for (size_t k = 0; k < listeners.size(); ++k) { | 902 for (size_t k = 0; k < listeners.size(); ++k) { |
| 907 if (listeners[k].listener->type() == EventListener::JSEventListe
nerType) | 903 if (listeners[k].listener->type() == EventListener::JSEventListe
nerType) |
| 908 filteredListeners.append(listeners[k]); | 904 filteredListeners.append(listeners[k]); |
| 909 } | 905 } |
| 910 if (!filteredListeners.isEmpty()) | 906 if (!filteredListeners.isEmpty()) |
| (...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 if (!m_documentNodeToIdMap.contains(m_document)) { | 2024 if (!m_documentNodeToIdMap.contains(m_document)) { |
| 2029 RefPtr<TypeBuilder::DOM::Node> root; | 2025 RefPtr<TypeBuilder::DOM::Node> root; |
| 2030 getDocument(errorString, root); | 2026 getDocument(errorString, root); |
| 2031 return errorString->isEmpty(); | 2027 return errorString->isEmpty(); |
| 2032 } | 2028 } |
| 2033 return true; | 2029 return true; |
| 2034 } | 2030 } |
| 2035 | 2031 |
| 2036 } // namespace WebCore | 2032 } // namespace WebCore |
| 2037 | 2033 |
| OLD | NEW |