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

Side by Side Diff: Source/core/inspector/InspectorRuntimeAgent.cpp

Issue 1042853004: [DevTools] Event Listeners Sidebar shows window listeners (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Extracted eventListenersTreeOutline.css 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
« no previous file with comments | « Source/core/inspector/InspectorRuntimeAgent.h ('k') | Source/devtools/devtools.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/inspector/InspectorRuntimeAgent.h" 32 #include "core/inspector/InspectorRuntimeAgent.h"
33 33
34 #include "bindings/core/v8/DOMWrapperWorld.h" 34 #include "bindings/core/v8/DOMWrapperWorld.h"
35 #include "bindings/core/v8/ScriptDebugServer.h" 35 #include "bindings/core/v8/ScriptDebugServer.h"
36 #include "bindings/core/v8/ScriptEventListener.h"
36 #include "bindings/core/v8/ScriptState.h" 37 #include "bindings/core/v8/ScriptState.h"
38 #include "core/dom/Document.h"
39 #include "core/dom/Node.h"
40 #include "core/events/EventTarget.h"
41 #include "core/frame/DOMWindow.h"
42 #include "core/frame/LocalDOMWindow.h"
43 #include "core/inspector/EventListenerInfo.h"
37 #include "core/inspector/InjectedScript.h" 44 #include "core/inspector/InjectedScript.h"
38 #include "core/inspector/InjectedScriptManager.h" 45 #include "core/inspector/InjectedScriptManager.h"
39 #include "core/inspector/InspectorState.h" 46 #include "core/inspector/InspectorState.h"
40 #include "platform/JSONValues.h" 47 #include "platform/JSONValues.h"
41 48
42 using blink::TypeBuilder::Runtime::ExecutionContextDescription; 49 using blink::TypeBuilder::Runtime::ExecutionContextDescription;
43 50
44 namespace blink { 51 namespace blink {
45 52
46 namespace InspectorRuntimeAgentState { 53 namespace InspectorRuntimeAgentState {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 139
133 injectedScript.getProperties(errorString, objectId, asBool(ownProperties), a sBool(accessorPropertiesOnly), asBool(generatePreview), &result); 140 injectedScript.getProperties(errorString, objectId, asBool(ownProperties), a sBool(accessorPropertiesOnly), asBool(generatePreview), &result);
134 141
135 if (!asBool(accessorPropertiesOnly)) 142 if (!asBool(accessorPropertiesOnly))
136 injectedScript.getInternalProperties(errorString, objectId, &internalPro perties); 143 injectedScript.getInternalProperties(errorString, objectId, &internalPro perties);
137 144
138 unmuteConsole(); 145 unmuteConsole();
139 setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsStat e); 146 setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsStat e);
140 } 147 }
141 148
149 void InspectorRuntimeAgent::getEventListeners(ErrorString* errorString, const St ring& objectId, const String* objectGroup, RefPtr<TypeBuilder::Array<TypeBuilder ::Runtime::EventListener>>& listenersArray)
150 {
151 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb jectId(objectId);
152 if (injectedScript.isEmpty()) {
153 *errorString = "Inspected frame has gone";
154 return;
155 }
156 listenersArray = TypeBuilder::Array<TypeBuilder::Runtime::EventListener>::cr eate();
157 EventTarget* target = injectedScript.eventTargetForObjectId(objectId);
158 if (!target) {
159 *errorString = "No event target with passed objectId";
160 return;
161 }
162 Vector<EventListenerInfo> eventInformation;
163 EventListenerInfo::getEventListeners(target, eventInformation, true);
164 if (!eventInformation.size())
165 return;
166 RegisteredEventListenerIterator iterator(eventInformation);
167 while (const RegisteredEventListener* listener = iterator.nextRegisteredEven tListener()) {
168 const EventListenerInfo& info = iterator.currentEventListenerInfo();
169 RefPtr<TypeBuilder::Runtime::EventListener> listenerObject = buildObject ForEventListener(*listener, info.eventType, info.eventTarget, objectGroup);
170 if (listenerObject)
171 listenersArray->addItem(listenerObject);
172 }
173 }
174
175 PassRefPtr<TypeBuilder::Runtime::EventListener> InspectorRuntimeAgent::buildObje ctForEventListener(const RegisteredEventListener& registeredEventListener, const AtomicString& eventType, EventTarget* target, const String* objectGroupId)
176 {
177 RefPtr<EventListener> eventListener = registeredEventListener.listener;
178 String scriptId;
179 int lineNumber;
180 int columnNumber;
181 ExecutionContext* context = target->executionContext();
182 if (!context)
183 return nullptr;
184 if (!eventListenerHandlerLocation(context, eventListener.get(), scriptId, li neNumber, columnNumber))
185 return nullptr;
186
187 RefPtr<TypeBuilder::Debugger::Location> location = TypeBuilder::Debugger::Lo cation::create()
188 .setScriptId(scriptId)
189 .setLineNumber(lineNumber);
190 location->setColumnNumber(columnNumber);
191 RefPtr<TypeBuilder::Runtime::EventListener> value = TypeBuilder::Runtime::Ev entListener::create()
192 .setType(eventType)
193 .setUseCapture(registeredEventListener.useCapture)
194 .setLocation(location);
195 if (objectGroupId)
196 value->setHandler(getEventHandlerObject(context, eventListener.get(), m_ injectedScriptManager, objectGroupId));
197 return value.release();
198 }
199
142 void InspectorRuntimeAgent::releaseObject(ErrorString*, const String& objectId) 200 void InspectorRuntimeAgent::releaseObject(ErrorString*, const String& objectId)
143 { 201 {
144 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb jectId(objectId); 202 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb jectId(objectId);
145 if (injectedScript.isEmpty()) 203 if (injectedScript.isEmpty())
146 return; 204 return;
147 bool pausingOnNextStatement = m_scriptDebugServer->pausingOnNextStatement(); 205 bool pausingOnNextStatement = m_scriptDebugServer->pausingOnNextStatement();
148 if (pausingOnNextStatement) 206 if (pausingOnNextStatement)
149 m_scriptDebugServer->setPauseOnNextStatement(false); 207 m_scriptDebugServer->setPauseOnNextStatement(false);
150 injectedScript.releaseObject(objectId); 208 injectedScript.releaseObject(objectId);
151 if (pausingOnNextStatement) 209 if (pausingOnNextStatement)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 .setName(humanReadableName) 275 .setName(humanReadableName)
218 .setOrigin(origin) 276 .setOrigin(origin)
219 .setFrameId(frameId); 277 .setFrameId(frameId);
220 if (isPageContext) 278 if (isPageContext)
221 description->setIsPageContext(isPageContext); 279 description->setIsPageContext(isPageContext);
222 frontend()->executionContextCreated(description.release()); 280 frontend()->executionContextCreated(description.release());
223 } 281 }
224 282
225 } // namespace blink 283 } // namespace blink
226 284
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorRuntimeAgent.h ('k') | Source/devtools/devtools.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698