Changeset 109540 in webkit
- Timestamp:
- Mar 2, 2012 2:39:04 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r109538 r109540 1 2012-03-02 Yury Semikhatsky <yurys@chromium.org> 2 3 Web Inspector: enable Timeline panel for workers 4 https://bugs.webkit.org/show_bug.cgi?id=80130 5 6 Enabled Timeline panel for worker inspector. Refactored 7 JS function calls instrumentation to work for both 8 worker contexts and documents. 9 10 Reviewed by Pavel Feldman. 11 12 * bindings/js/JSCallbackData.cpp: 13 (WebCore::JSCallbackData::invokeCallback): 14 * bindings/js/JSEventListener.cpp: 15 (WebCore::JSEventListener::handleEvent): 16 * bindings/js/JSMainThreadExecState.h: 17 (WebCore): 18 (WebCore::JSMainThreadExecState::instrumentedCall): 19 * bindings/js/ScriptState.cpp: 20 (WebCore::scriptExecutionContextFromScriptState): 21 (WebCore): 22 * bindings/js/ScriptState.h: 23 (WebCore): 24 * bindings/v8/ScriptState.cpp: 25 (WebCore::ScriptState::scriptExecutionContext): 26 (WebCore): 27 (WebCore::scriptExecutionContextFromScriptState): 28 * bindings/v8/ScriptState.h: 29 (WebCore): 30 (ScriptState): 31 * bindings/v8/V8Proxy.cpp: 32 (WebCore::V8Proxy::instrumentedCallFunction): 33 * bindings/v8/V8WorkerContextEventListener.cpp: 34 (WebCore::V8WorkerContextEventListener::callListenerFunction): 35 * inspector/InjectedScript.cpp: 36 (WebCore::InjectedScript::callFunctionWithEvalEnabled): 37 * inspector/InspectorInstrumentation.cpp: 38 (WebCore): 39 (WebCore::InspectorInstrumentation::instrumentingAgentsForNonDocumentContext): 40 * inspector/InspectorInstrumentation.h: 41 (InspectorInstrumentation): 42 (WebCore::InspectorInstrumentation::willCallFunction): 43 (WebCore): 44 (WebCore::InspectorInstrumentation::instrumentingAgentsForContext): 45 * inspector/WorkerInspectorController.cpp: 46 (WebCore::WorkerInspectorController::WorkerInspectorController): 47 (WebCore::WorkerInspectorController::connectFrontend): 48 (WebCore::WorkerInspectorController::disconnectFrontend): 49 (WebCore::WorkerInspectorController::restoreInspectorStateFromCookie): 50 * inspector/WorkerInspectorController.h: 51 (WebCore): 52 (WorkerInspectorController): 53 * inspector/front-end/inspector.js: 54 (WebInspector._createPanels): 55 1 56 2012-03-02 Kenichi Ishibashi <bashi@chromium.org> 2 57 -
trunk/Source/WebCore/bindings/js/JSCallbackData.cpp
r106030 r109540 67 67 globalObject()->globalData().timeoutChecker.start(); 68 68 69 bool contextIsDocument = context->isDocument(); 70 JSValue result; 71 if (contextIsDocument) { 72 Frame* frame = static_cast<JSDOMWindow*>(globalObject())->impl()->frame(); 73 Page* page = frame ? frame->page() : 0; 74 result = JSMainThreadExecState::instrumentedCall(page, exec, function, callType, callData, callback(), args); 75 } else 76 result = JSC::call(exec, function, callType, callData, callback(), args); 69 JSValue result = JSMainThreadExecState::instrumentedCall(context, exec, function, callType, callData, callback(), args); 77 70 78 71 globalObject()->globalData().timeoutChecker.stop(); 79 72 80 if (context IsDocument)73 if (context->isDocument()) 81 74 Document::updateStyleForAllDocuments(); 82 75 -
trunk/Source/WebCore/bindings/js/JSEventListener.cpp
r108047 r109540 123 123 globalData.timeoutChecker.start(); 124 124 JSValue thisValue = handleEventFunction == jsFunction ? toJS(exec, globalObject, event->currentTarget()) : jsFunction; 125 JSValue retval = scriptExecutionContext->isDocument() 126 ? JSMainThreadExecState::instrumentedCall(frame ? frame->page() : 0, exec, handleEventFunction, callType, callData, thisValue, args) 127 : JSC::call(exec, handleEventFunction, callType, callData, thisValue, args); 125 JSValue retval = JSMainThreadExecState::instrumentedCall(scriptExecutionContext, exec, handleEventFunction, callType, callData, thisValue, args); 128 126 globalData.timeoutChecker.stop(); 129 127 -
trunk/Source/WebCore/bindings/js/JSMainThreadExecState.h
r107149 r109540 37 37 namespace WebCore { 38 38 39 class Page;39 class ScriptExecutionContext; 40 40 41 41 class JSMainThreadExecState { … … 57 57 }; 58 58 59 static JSC::JSValue instrumentedCall( Page* page, JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args)59 static JSC::JSValue instrumentedCall(ScriptExecutionContext* context, JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args) 60 60 { 61 61 InspectorInstrumentationCookie cookie; … … 70 70 resourceName = "undefined"; 71 71 72 cookie = InspectorInstrumentation::willCallFunction( page, resourceName, lineNumber);72 cookie = InspectorInstrumentation::willCallFunction(context, resourceName, lineNumber); 73 73 } 74 74 -
trunk/Source/WebCore/bindings/js/ScriptState.cpp
r106657 r109540 72 72 } 73 73 74 ScriptExecutionContext* scriptExecutionContextFromScriptState(ScriptState* scriptState) 75 { 76 JSC::JSGlobalObject* globalObject = scriptState->lexicalGlobalObject(); 77 if (!globalObject->inherits(&JSDOMGlobalObject::s_info)) 78 return 0; 79 return static_cast<JSDOMGlobalObject*>(globalObject)->scriptExecutionContext(); 80 } 81 74 82 bool evalEnabled(ScriptState* scriptState) 75 83 { -
trunk/Source/WebCore/bindings/js/ScriptState.h
r106657 r109540 47 47 class Node; 48 48 class Page; 49 class ScriptExecutionContext; 49 50 class WorkerContext; 50 51 … … 66 67 67 68 DOMWindow* domWindowFromScriptState(ScriptState*); 69 ScriptExecutionContext* scriptExecutionContextFromScriptState(ScriptState*); 68 70 69 71 bool evalEnabled(ScriptState*); -
trunk/Source/WebCore/bindings/v8/ScriptState.cpp
r106657 r109540 38 38 #include "V8DOMWindow.h" 39 39 #include "V8HiddenPropertyName.h" 40 40 #include "V8WorkerContext.h" 41 41 #include "WorkerContext.h" 42 42 #include "WorkerContextExecutionProxy.h" … … 67 67 return 0; 68 68 return V8DOMWindow::toNative(v8RealGlobal); 69 } 70 71 ScriptExecutionContext* ScriptState::scriptExecutionContext() const 72 { 73 v8::HandleScope handleScope; 74 75 v8::Handle<v8::Object> global = m_context->Global(); 76 v8::Handle<v8::Object> v8RealGlobal = v8::Handle<v8::Object>::Cast(global->GetPrototype()); 77 if (V8DOMWrapper::isWrapperOfType(v8RealGlobal, &V8DOMWindow::info)) 78 return V8DOMWindow::toNative(v8RealGlobal)->scriptExecutionContext(); 79 #if ENABLE(WORKERS) 80 global = V8DOMWrapper::lookupDOMWrapper(V8WorkerContext::GetTemplate(), global); 81 if (!global.IsEmpty()) 82 return V8WorkerContext::toNative(global)->scriptExecutionContext(); 83 #endif 84 return 0; 69 85 } 70 86 … … 108 124 { 109 125 return scriptState->domWindow(); 126 } 127 128 ScriptExecutionContext* scriptExecutionContextFromScriptState(ScriptState* scriptState) 129 { 130 return scriptState->scriptExecutionContext(); 110 131 } 111 132 -
trunk/Source/WebCore/bindings/v8/ScriptState.h
r106657 r109540 43 43 class Node; 44 44 class Page; 45 class ScriptExecutionContext; 45 46 class WorkerContext; 46 47 … … 61 62 62 63 DOMWindow* domWindow() const; 64 ScriptExecutionContext* scriptExecutionContext() const; 63 65 64 66 static ScriptState* forContext(v8::Local<v8::Context>); … … 109 111 110 112 DOMWindow* domWindowFromScriptState(ScriptState*); 113 ScriptExecutionContext* scriptExecutionContextFromScriptState(ScriptState*); 111 114 112 115 bool evalEnabled(ScriptState*); -
trunk/Source/WebCore/bindings/v8/V8Proxy.cpp
r107685 r109540 415 415 return handleMaxRecursionDepthExceeded(); 416 416 417 ScriptExecutionContext* context = frame ? frame->document() : 0; 418 417 419 InspectorInstrumentationCookie cookie; 418 if (InspectorInstrumentation::hasFrontends() && frame) {420 if (InspectorInstrumentation::hasFrontends() && context) { 419 421 String resourceName("undefined"); 420 422 int lineNumber = 1; … … 424 426 lineNumber = function->GetScriptLineNumber() + 1; 425 427 } 426 cookie = InspectorInstrumentation::willCallFunction( frame->page(), resourceName, lineNumber);428 cookie = InspectorInstrumentation::willCallFunction(context, resourceName, lineNumber); 427 429 } 428 430 … … 432 434 TRACE_EVENT0("v8", "v8.callFunction"); 433 435 #endif 434 V8RecursionScope recursionScope( frame ? frame->document() : 0);436 V8RecursionScope recursionScope(context); 435 437 result = function->Call(receiver, argc, args); 436 438 } -
trunk/Source/WebCore/bindings/v8/V8WorkerContextEventListener.cpp
r108867 r109540 35 35 #include "V8WorkerContextEventListener.h" 36 36 37 #include "InspectorInstrumentation.h" 37 38 #include "V8Binding.h" 38 39 #include "V8DOMWrapper.h" … … 91 92 return v8::Local<v8::Value>(); 92 93 94 InspectorInstrumentationCookie cookie; 95 if (InspectorInstrumentation::hasFrontends()) { 96 String resourceName("undefined"); 97 int lineNumber = 1; 98 v8::ScriptOrigin origin = handlerFunction->GetScriptOrigin(); 99 if (!origin.ResourceName().IsEmpty()) { 100 resourceName = toWebCoreString(origin.ResourceName()); 101 lineNumber = handlerFunction->GetScriptLineNumber() + 1; 102 } 103 cookie = InspectorInstrumentation::willCallFunction(context, resourceName, lineNumber); 104 } 105 93 106 v8::Handle<v8::Value> parameters[1] = { jsEvent }; 94 107 V8RecursionScope recursionScope(context); … … 97 110 if (WorkerContextExecutionProxy* proxy = workerProxy(context)) 98 111 proxy->trackEvent(event); 112 113 InspectorInstrumentation::didCallFunction(cookie); 99 114 100 115 return result; -
trunk/Source/WebCore/inspector/InjectedScript.cpp
r108337 r109540 219 219 ScriptValue InjectedScript::callFunctionWithEvalEnabled(ScriptFunctionCall& function, bool& hadException) const 220 220 { 221 DOMWindow* domWindow = domWindowFromScriptState(m_injectedScriptObject.scriptState());222 InspectorInstrumentationCookie cookie = domWindow && domWindow->frame() ? InspectorInstrumentation::willCallFunction(domWindow->frame()->page(), "InjectedScript", 1) : InspectorInstrumentationCookie();221 ScriptExecutionContext* scriptExecutionContext = scriptExecutionContextFromScriptState(m_injectedScriptObject.scriptState()); 222 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willCallFunction(scriptExecutionContext, "InjectedScript", 1); 223 223 224 224 ScriptState* scriptState = m_injectedScriptObject.scriptState(); -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r109116 r109540 1062 1062 return instrumentationForWorkerContext(workerContext); 1063 1063 } 1064 1065 InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForNonDocumentContext(ScriptExecutionContext* context) 1066 { 1067 if (context->isWorkerContext()) 1068 return instrumentationForWorkerContext(static_cast<WorkerContext*>(context)); 1069 return 0; 1070 } 1064 1071 #endif 1065 1072 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r109091 r109540 107 107 static void didRemoveTimer(ScriptExecutionContext*, int timerId); 108 108 109 static InspectorInstrumentationCookie willCallFunction( Page*, const String& scriptName, int scriptLine);109 static InspectorInstrumentationCookie willCallFunction(ScriptExecutionContext*, const String& scriptName, int scriptLine); 110 110 static void didCallFunction(const InspectorInstrumentationCookie&); 111 111 static InspectorInstrumentationCookie willChangeXHRReadyState(ScriptExecutionContext*, XMLHttpRequest* request); … … 373 373 #if ENABLE(WORKERS) 374 374 static InstrumentingAgents* instrumentingAgentsForWorkerContext(WorkerContext*); 375 static InstrumentingAgents* instrumentingAgentsForNonDocumentContext(ScriptExecutionContext*); 375 376 #endif 376 377 … … 576 577 } 577 578 578 inline InspectorInstrumentationCookie InspectorInstrumentation::willCallFunction( Page* page, const String& scriptName, int scriptLine)579 { 580 #if ENABLE(INSPECTOR) 581 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie()); 582 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsFor Page(page))579 inline InspectorInstrumentationCookie InspectorInstrumentation::willCallFunction(ScriptExecutionContext* context, const String& scriptName, int scriptLine) 580 { 581 #if ENABLE(INSPECTOR) 582 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie()); 583 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context)) 583 584 return willCallFunctionImpl(instrumentingAgents, scriptName, scriptLine); 584 585 #endif 585 586 return InspectorInstrumentationCookie(); 586 587 } 588 587 589 588 590 inline void InspectorInstrumentation::didCallFunction(const InspectorInstrumentationCookie& cookie) … … 1242 1244 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForContext(ScriptExecutionContext* context) 1243 1245 { 1244 if (context && context->isDocument()) 1246 if (!context) 1247 return 0; 1248 if (context->isDocument()) 1245 1249 return instrumentingAgentsForPage(static_cast<Document*>(context)->page()); 1250 #if ENABLE(WORKERS) 1251 return instrumentingAgentsForNonDocumentContext(context); 1252 #else 1246 1253 return 0; 1254 #endif 1247 1255 } 1248 1256 -
trunk/Source/WebCore/inspector/WorkerInspectorController.cpp
r109214 r109540 45 45 #include "InspectorState.h" 46 46 #include "InspectorStateClient.h" 47 #include "InspectorTimelineAgent.h" 47 48 #include "InstrumentingAgents.h" 48 49 #include "WorkerConsoleAgent.h" … … 102 103 m_profilerAgent = InspectorProfilerAgent::create(m_instrumentingAgents.get(), m_consoleAgent.get(), workerContext, m_state.get(), m_injectedScriptManager.get()); 103 104 #endif 105 m_timelineAgent = InspectorTimelineAgent::create(m_instrumentingAgents.get(), m_state.get()); 104 106 105 107 m_injectedScriptManager->injectedScriptHost()->init(0 … … 129 131 m_backendDispatcher = InspectorBackendDispatcher::create(m_frontendChannel.get()); 130 132 m_consoleAgent->registerInDispatcher(m_backendDispatcher.get()); 133 m_timelineAgent->registerInDispatcher(m_backendDispatcher.get()); 131 134 #if ENABLE(JAVASCRIPT_DEBUGGER) 132 135 m_debuggerAgent->registerInDispatcher(m_backendDispatcher.get()); … … 140 143 #endif 141 144 m_consoleAgent->setFrontend(m_frontend.get()); 145 m_timelineAgent->setFrontend(m_frontend.get()); 142 146 } 143 147 … … 156 160 #endif 157 161 m_consoleAgent->clearFrontend(); 162 m_timelineAgent->clearFrontend(); 158 163 159 164 m_frontend.clear(); … … 172 177 #endif 173 178 m_consoleAgent->restore(); 179 m_timelineAgent->restore(); 174 180 } 175 181 -
trunk/Source/WebCore/inspector/WorkerInspectorController.h
r109214 r109540 56 56 class InspectorState; 57 57 class InspectorStateClient; 58 class InspectorTimelineAgent; 58 59 class InstrumentingAgents; 59 60 class WorkerContext; … … 89 90 OwnPtr<InspectorRuntimeAgent> m_runtimeAgent; 90 91 OwnPtr<InspectorConsoleAgent> m_consoleAgent; 92 OwnPtr<InspectorTimelineAgent> m_timelineAgent; 91 93 92 94 OwnPtr<InspectorFrontendChannel> m_frontendChannel; -
trunk/Source/WebCore/inspector/front-end/inspector.js
r109214 r109540 40 40 if (WebInspector.WorkerManager.isWorkerFrontend()) { 41 41 this.panels.scripts = new WebInspector.ScriptsPanel(this.debuggerPresentationModel); 42 this.panels.timeline = new WebInspector.TimelinePanel(); 42 43 this.panels.profiles = new WebInspector.ProfilesPanel(); 43 44 this.panels.console = new WebInspector.ConsolePanel();
Note: See TracChangeset
for help on using the changeset viewer.