Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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" | |
| 37 #include "core/inspector/InjectedScript.h" | 43 #include "core/inspector/InjectedScript.h" |
| 38 #include "core/inspector/InjectedScriptManager.h" | 44 #include "core/inspector/InjectedScriptManager.h" |
| 39 #include "core/inspector/InspectorState.h" | 45 #include "core/inspector/InspectorState.h" |
| 40 #include "platform/JSONValues.h" | 46 #include "platform/JSONValues.h" |
| 41 | 47 |
| 42 using blink::TypeBuilder::Runtime::ExecutionContextDescription; | 48 using blink::TypeBuilder::Runtime::ExecutionContextDescription; |
| 43 | 49 |
| 44 namespace blink { | 50 namespace blink { |
| 45 | 51 |
| 46 namespace InspectorRuntimeAgentState { | 52 namespace InspectorRuntimeAgentState { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 | 138 |
| 133 injectedScript.getProperties(errorString, objectId, asBool(ownProperties), a sBool(accessorPropertiesOnly), asBool(generatePreview), &result); | 139 injectedScript.getProperties(errorString, objectId, asBool(ownProperties), a sBool(accessorPropertiesOnly), asBool(generatePreview), &result); |
| 134 | 140 |
| 135 if (!asBool(accessorPropertiesOnly)) | 141 if (!asBool(accessorPropertiesOnly)) |
| 136 injectedScript.getInternalProperties(errorString, objectId, &internalPro perties); | 142 injectedScript.getInternalProperties(errorString, objectId, &internalPro perties); |
| 137 | 143 |
| 138 unmuteConsole(); | 144 unmuteConsole(); |
| 139 setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsStat e); | 145 setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsStat e); |
| 140 } | 146 } |
| 141 | 147 |
| 148 void InspectorRuntimeAgent::getEventListeners(ErrorString* errorString, const St ring& objectId, const String* objectGroup, RefPtr<TypeBuilder::Array<TypeBuilder ::Runtime::EventListener>>& listenersArray) | |
| 149 { | |
| 150 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb jectId(objectId); | |
| 151 if (injectedScript.isEmpty()) { | |
| 152 *errorString = "Inspected frame has gone"; | |
| 153 return; | |
| 154 } | |
| 155 listenersArray = TypeBuilder::Array<TypeBuilder::Runtime::EventListener>::cr eate(); | |
| 156 EventTarget* target = injectedScript.eventTargetForObjectId(objectId); | |
| 157 if (!target) | |
|
pfeldman
2015/04/10 08:45:11
Lets return error here.
kozy
2015/04/13 14:26:54
Done.
| |
| 158 return; | |
| 159 Vector<EventListenerInfo> eventInformation; | |
| 160 EventListenerInfo::getEventListeners(target, eventInformation, true); | |
| 161 if (!eventInformation.size()) | |
| 162 return; | |
| 163 RegisteredEventListenerIterator iterator(eventInformation); | |
| 164 while (const RegisteredEventListener* listener = iterator.nextRegisteredEven tListener()) { | |
| 165 const EventListenerInfo& info = iterator.currentEventListenerInfo(); | |
| 166 RefPtr<TypeBuilder::Runtime::EventListener> listenerObject = buildObject ForEventListener(*listener, info.eventType, info.eventTarget, objectGroup); | |
| 167 if (listenerObject) | |
| 168 listenersArray->addItem(listenerObject); | |
| 169 } | |
| 170 } | |
| 171 | |
| 172 PassRefPtr<TypeBuilder::Runtime::EventListener> InspectorRuntimeAgent::buildObje ctForEventListener(const RegisteredEventListener& registeredEventListener, const AtomicString& eventType, EventTarget* target, const String* objectGroupId) | |
| 173 { | |
| 174 RefPtr<EventListener> eventListener = registeredEventListener.listener; | |
| 175 String scriptId; | |
| 176 int lineNumber; | |
| 177 int columnNumber; | |
| 178 ExecutionContext* context = target->executionContext(); | |
| 179 if (!context) | |
| 180 return nullptr; | |
| 181 if (!eventListenerHandlerLocation(context, eventListener.get(), scriptId, li neNumber, columnNumber)) | |
| 182 return nullptr; | |
| 183 | |
| 184 RefPtr<TypeBuilder::Debugger::Location> location = TypeBuilder::Debugger::Lo cation::create() | |
| 185 .setScriptId(scriptId) | |
| 186 .setLineNumber(lineNumber); | |
| 187 location->setColumnNumber(columnNumber); | |
| 188 RefPtr<TypeBuilder::Runtime::EventListener> value = TypeBuilder::Runtime::Ev entListener::create() | |
| 189 .setType(eventType) | |
| 190 .setUseCapture(registeredEventListener.useCapture) | |
| 191 .setIsAttribute(eventListener->isAttribute()) | |
| 192 .setLocation(location); | |
| 193 if (objectGroupId) { | |
|
pfeldman
2015/04/10 08:45:11
This part can be reused w/ DOM.
kozy
2015/04/13 14:26:54
Done.
| |
| 194 ScriptValue functionValue = eventListenerHandler(context, eventListener. get()); | |
| 195 if (!functionValue.isEmpty() && context->isDocument()) { | |
| 196 LocalFrame* frame = toDocument(context)->frame(); | |
| 197 if (frame) { | |
| 198 ScriptState* scriptState = eventListenerHandlerScriptState(frame , eventListener.get()); | |
| 199 if (scriptState) { | |
| 200 InjectedScript injectedScript = m_injectedScriptManager->inj ectedScriptFor(scriptState); | |
| 201 if (!injectedScript.isEmpty()) { | |
| 202 RefPtr<TypeBuilder::Runtime::RemoteObject> valueJson = i njectedScript.wrapObject(functionValue, *objectGroupId); | |
| 203 value->setHandler(valueJson); | |
| 204 } | |
| 205 } | |
| 206 } | |
| 207 } | |
| 208 } | |
| 209 return value.release(); | |
| 210 } | |
| 211 | |
| 142 void InspectorRuntimeAgent::releaseObject(ErrorString*, const String& objectId) | 212 void InspectorRuntimeAgent::releaseObject(ErrorString*, const String& objectId) |
| 143 { | 213 { |
| 144 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb jectId(objectId); | 214 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForOb jectId(objectId); |
| 145 if (injectedScript.isEmpty()) | 215 if (injectedScript.isEmpty()) |
| 146 return; | 216 return; |
| 147 bool pausingOnNextStatement = m_scriptDebugServer->pausingOnNextStatement(); | 217 bool pausingOnNextStatement = m_scriptDebugServer->pausingOnNextStatement(); |
| 148 if (pausingOnNextStatement) | 218 if (pausingOnNextStatement) |
| 149 m_scriptDebugServer->setPauseOnNextStatement(false); | 219 m_scriptDebugServer->setPauseOnNextStatement(false); |
| 150 injectedScript.releaseObject(objectId); | 220 injectedScript.releaseObject(objectId); |
| 151 if (pausingOnNextStatement) | 221 if (pausingOnNextStatement) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 .setName(humanReadableName) | 287 .setName(humanReadableName) |
| 218 .setOrigin(origin) | 288 .setOrigin(origin) |
| 219 .setFrameId(frameId); | 289 .setFrameId(frameId); |
| 220 if (isPageContext) | 290 if (isPageContext) |
| 221 description->setIsPageContext(isPageContext); | 291 description->setIsPageContext(isPageContext); |
| 222 frontend()->executionContextCreated(description.release()); | 292 frontend()->executionContextCreated(description.release()); |
| 223 } | 293 } |
| 224 | 294 |
| 225 } // namespace blink | 295 } // namespace blink |
| 226 | 296 |
| OLD | NEW |