Changeset 60771 in webkit
- Timestamp:
- Jun 7, 2010 2:57:55 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r60768 r60771 1 2010-06-07 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: should be possible to distinguish extension scripts from main world scripts 6 https://bugs.webkit.org/show_bug.cgi?id=40220 7 8 * bindings/js/ScriptDebugServer.cpp: remove global listeners set which is not used anymore. 9 (WebCore::ScriptDebugServer::dispatchDidParseSource): pass script wrold type to the listeners. 10 (WebCore::currentWorldType): 11 (WebCore::ScriptDebugServer::sourceParsed): 12 * bindings/js/ScriptDebugServer.h: 13 * bindings/v8/ScriptDebugServer.cpp: 14 (WebCore::ScriptDebugServer::dispatchDidParseSource): 15 * inspector/InspectorController.cpp: 16 (WebCore::InspectorController::didParseSource): 17 * inspector/InspectorController.h: 18 * inspector/InspectorFrontend.cpp: 19 (WebCore::InspectorFrontend::parsedScriptSource): 20 * inspector/InspectorFrontend.h: 21 * inspector/ScriptDebugListener.h: pass type of the isolated world where the script was compiled to didParseSource. 22 (WebCore::): 23 * inspector/front-end/InjectedScript.js: 24 (injectedScriptConstructor): 25 * inspector/front-end/Script.js: 26 (WebInspector.Script): 27 * inspector/front-end/ScriptsPanel.js: 28 (WebInspector.ScriptsPanel.prototype.addScript): 29 (WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu): use different style to highlight content scripts. 30 * inspector/front-end/inspector.css: 31 (#scripts-files option.extension-script): 32 * inspector/front-end/inspector.js: 33 (WebInspector.parsedScriptSource): 34 1 35 2010-06-06 MORITA Hajime <morrita@google.com> 2 36 -
trunk/WebCore/bindings/js/ScriptDebugServer.cpp
r60154 r60771 131 131 ASSERT_ARG(page, page); 132 132 133 if (hasGlobalListeners())134 return true;135 136 133 return m_pageListenersMap.contains(page); 137 134 } … … 258 255 } 259 256 260 void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source )257 void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, ScriptWorldType worldType) 261 258 { 262 259 String sourceID = ustringToString(JSC::UString::from(source.provider()->asID())); … … 268 265 copyToVector(listeners, copy); 269 266 for (size_t i = 0; i < copy.size(); ++i) 270 copy[i]->didParseSource(sourceID, url, data, firstLine );267 copy[i]->didParseSource(sourceID, url, data, firstLine, worldType); 271 268 } 272 269 … … 290 287 Frame* frame = window->impl()->frame(); 291 288 return frame ? frame->page() : 0; 289 } 290 291 static ScriptWorldType currentWorldType(ExecState* exec) 292 { 293 if (currentWorld(exec) == mainThreadNormalWorld()) 294 return MAIN_WORLD; 295 return EXTENSIONS_WORLD; 292 296 } 293 297 … … 314 318 return; 315 319 320 ScriptWorldType worldType = currentWorldType(exec); 321 316 322 m_callingListeners = true; 317 323 318 324 bool isError = errorLine != -1; 319 320 if (hasGlobalListeners()) {321 if (isError)322 dispatchFailedToParseSource(m_listeners, source, errorLine, ustringToString(errorMessage));323 else324 dispatchDidParseSource(m_listeners, source);325 }326 325 327 326 if (ListenerSet* pageListeners = m_pageListenersMap.get(page)) { … … 330 329 dispatchFailedToParseSource(*pageListeners, source, errorLine, ustringToString(errorMessage)); 331 330 else 332 dispatchDidParseSource(*pageListeners, source );331 dispatchDidParseSource(*pageListeners, source, worldType); 333 332 } 334 333 … … 352 351 353 352 ASSERT(hasListeners()); 354 355 dispatchFunctionToListeners(m_listeners, callback);356 353 357 354 if (ListenerSet* pageListeners = m_pageListenersMap.get(page)) { … … 575 572 void ScriptDebugServer::didRemoveListener(Page* page) 576 573 { 577 if ( hasGlobalListeners() || (page && hasListenersInterestedInPage(page)))574 if (page && hasListenersInterestedInPage(page)) 578 575 return; 579 576 -
trunk/WebCore/bindings/js/ScriptDebugServer.h
r60154 r60771 33 33 #if ENABLE(JAVASCRIPT_DEBUGGER) 34 34 35 #include "ScriptDebugListener.h" 35 36 #include "PlatformString.h" 36 37 #include "ScriptBreakpoint.h" … … 97 98 98 99 bool hasBreakpoint(intptr_t sourceID, unsigned lineNumber) const; 99 bool hasListeners() const { return !m_listeners.isEmpty() || !m_pageListenersMap.isEmpty(); } 100 bool hasGlobalListeners() const { return !m_listeners.isEmpty(); } 100 bool hasListeners() const { return !m_pageListenersMap.isEmpty(); } 101 101 bool hasListenersInterestedInPage(Page*); 102 102 … … 110 110 void dispatchDidPause(ScriptDebugListener*); 111 111 void dispatchDidContinue(ScriptDebugListener*); 112 void dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source );112 void dispatchDidParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, enum ScriptWorldType); 113 113 void dispatchFailedToParseSource(const ListenerSet& listeners, const JSC::SourceCode& source, int errorLine, const String& errorMessage); 114 114 … … 134 134 135 135 PageListenersMap m_pageListenersMap; 136 ListenerSet m_listeners;137 136 bool m_callingListeners; 138 137 PauseOnExceptionsState m_pauseOnExceptionsState; -
trunk/WebCore/bindings/v8/ScriptDebugServer.cpp
r60309 r60771 321 321 toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("name"))), 322 322 toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("source"))), 323 object->Get(v8::String::New("lineOffset"))->ToInteger()->Value()); 323 object->Get(v8::String::New("lineOffset"))->ToInteger()->Value(), 324 static_cast<ScriptWorldType>(object->Get(v8::String::New("scriptWorldType"))->Int32Value())); 324 325 } 325 326 -
trunk/WebCore/inspector/InspectorController.cpp
r60618 r60771 1654 1654 // JavaScriptDebugListener functions 1655 1655 1656 void InspectorController::didParseSource(const String& sourceID, const String& url, const String& data, int firstLine )1657 { 1658 m_frontend->parsedScriptSource(sourceID, url, data, firstLine );1656 void InspectorController::didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType worldType) 1657 { 1658 m_frontend->parsedScriptSource(sourceID, url, data, firstLine, worldType); 1659 1659 1660 1660 if (url.isEmpty()) -
trunk/WebCore/inspector/InspectorController.h
r60414 r60771 244 244 void resumeDebugger(); 245 245 246 virtual void didParseSource(const String& sourceID, const String& url, const String& data, int firstLine );246 virtual void didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType); 247 247 virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage); 248 248 virtual void didPause(ScriptState*); -
trunk/WebCore/inspector/InspectorFrontend.cpp
r60443 r60771 306 306 } 307 307 308 void InspectorFrontend::parsedScriptSource(const String& sourceID, const String& url, const String& data, int firstLine )308 void InspectorFrontend::parsedScriptSource(const String& sourceID, const String& url, const String& data, int firstLine, int scriptWorldType) 309 309 { 310 310 ScriptFunctionCall function(m_webInspector, "dispatch"); … … 314 314 function.appendArgument(data); 315 315 function.appendArgument(firstLine); 316 function.appendArgument(scriptWorldType); 316 317 function.call(); 317 318 } -
trunk/WebCore/inspector/InspectorFrontend.h
r60443 r60771 93 93 void debuggerWasDisabled(); 94 94 95 void parsedScriptSource(const String& sourceID, const String& url, const String& data, int firstLine );95 void parsedScriptSource(const String& sourceID, const String& url, const String& data, int firstLine, int scriptWorldType); 96 96 void restoredBreakpoint(const String& sourceID, const String& url, int line, bool enabled, const String& condition); 97 97 void failedToParseScriptSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage); -
trunk/WebCore/inspector/ScriptDebugListener.h
r60154 r60771 39 39 class String; 40 40 41 enum ScriptWorldType { 42 MAIN_WORLD = 0, 43 EXTENSIONS_WORLD 44 }; 45 41 46 class ScriptDebugListener { 42 47 public: 43 48 virtual ~ScriptDebugListener() { } 44 49 45 virtual void didParseSource(const String& sourceID, const String& url, const String& data, int firstLine ) = 0;50 virtual void didParseSource(const String& sourceID, const String& url, const String& data, int firstLine, ScriptWorldType) = 0; 46 51 virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage) = 0; 47 52 virtual void didPause(ScriptState*) = 0; -
trunk/WebCore/inspector/front-end/InjectedScript.js
r60623 r60771 1018 1018 // I gave up and am using a check below to distinguish between the egine bingings. 1019 1019 1020 if (typeof Document === "object") { 1021 // JSC 1020 if (jsEngine == "JSC") { 1022 1021 var str = inspectedWindow.Object ? inspectedWindow.Object.prototype.toString.call(obj) : InjectedScript._toString(obj); 1023 1022 return str.replace(/^\[object (.*)\]$/i, "$1"); 1024 } 1025 // V8 1026 if (typeof obj !== "object") 1027 return "null"; 1028 return obj.constructor.name || "Object"; 1023 } else { 1024 // V8 1025 if (typeof obj !== "object") 1026 return "null"; 1027 return obj.constructor.name || "Object"; 1028 } 1029 1029 } 1030 1030 -
trunk/WebCore/inspector/front-end/Script.js
r55522 r60771 24 24 */ 25 25 26 WebInspector.Script = function(sourceID, sourceURL, source, startingLine, errorLine, errorMessage )26 WebInspector.Script = function(sourceID, sourceURL, source, startingLine, errorLine, errorMessage, worldType) 27 27 { 28 28 this.sourceID = sourceID; … … 32 32 this.errorLine = errorLine; 33 33 this.errorMessage = errorMessage; 34 this.worldType = worldType; 34 35 35 36 // if no URL, look for "//@ sourceURL=" decorator … … 47 48 } 48 49 50 WebInspector.Script.WorldType = { 51 MAIN_WORLD: 0, 52 EXTENSIONS_WORLD: 1 53 } 54 49 55 WebInspector.Script.prototype = { 50 56 get linesCount() -
trunk/WebCore/inspector/front-end/ScriptsPanel.js
r60567 r60771 242 242 }, 243 243 244 addScript: function(sourceID, sourceURL, source, startingLine, errorLine, errorMessage )245 { 246 var script = new WebInspector.Script(sourceID, sourceURL, source, startingLine, errorLine, errorMessage );244 addScript: function(sourceID, sourceURL, source, startingLine, errorLine, errorMessage, scriptWorldType) 245 { 246 var script = new WebInspector.Script(sourceID, sourceURL, source, startingLine, errorLine, errorMessage, scriptWorldType); 247 247 this._sourceIDMap[sourceID] = script; 248 248 … … 738 738 this._showScriptOrResource(option.representedObject, {initialLoad: true}); 739 739 } 740 741 if (script.worldType === WebInspector.Script.WorldType.EXTENSIONS_WORLD) 742 script.filesSelectOption.addStyleClass("extension-script"); 740 743 }, 741 744 -
trunk/WebCore/inspector/front-end/inspector.css
r60414 r60771 2352 2352 } 2353 2353 2354 #scripts-files option.extension-script { 2355 color: rgb(70, 134, 240); 2356 } 2357 2354 2358 #scripts-functions { 2355 2359 max-width: 150px; -
trunk/WebCore/inspector/front-end/inspector.js
r60680 r60771 1320 1320 } 1321 1321 1322 WebInspector.parsedScriptSource = function(sourceID, sourceURL, source, startingLine )1323 { 1324 this.panels.scripts.addScript(sourceID, sourceURL, source, startingLine );1322 WebInspector.parsedScriptSource = function(sourceID, sourceURL, source, startingLine, scriptWorldType) 1323 { 1324 this.panels.scripts.addScript(sourceID, sourceURL, source, startingLine, undefined, undefined, scriptWorldType); 1325 1325 } 1326 1326 -
trunk/WebKit/chromium/ChangeLog
r60695 r60771 1 2010-06-07 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: should be possible to distinguish extension scripts from main world scripts 6 https://bugs.webkit.org/show_bug.cgi?id=40220 7 8 * src/js/DebuggerAgent.js: 9 (devtools.DebuggerAgent.prototype.initUI): 10 (devtools.DebuggerAgent.prototype.addScriptInfo_): 11 (devtools.DebuggerAgent.prototype.formatCallFrame_): 12 (devtools.ScriptInfo.prototype.worldType): 13 * src/js/DebuggerScript.js: 14 (debuggerScriptConstructor.DebuggerScript.getScripts): use only context id without context type 15 when filtering scripts so that extension scripts are also included. 16 (debuggerScriptConstructor.DebuggerScript._formatScript): 17 * src/js/devTools.css: 18 1 19 2010-06-04 Jay Civelli <jcivelli@chromium.org> 2 20 -
trunk/WebKit/chromium/src/js/DebuggerAgent.js
r58477 r60771 182 182 for (var scriptId in this.parsedScripts_) { 183 183 var script = this.parsedScripts_[scriptId]; 184 WebInspector.parsedScriptSource(scriptId, script.getUrl(), undefined /* script source */, script.getLineOffset() + 1 );184 WebInspector.parsedScriptSource(scriptId, script.getUrl(), undefined /* script source */, script.getLineOffset() + 1, script.worldType()); 185 185 this.restoreBreakpoints_(scriptId, script.getUrl()); 186 186 } … … 949 949 { 950 950 var context = msg.lookup(script.context.ref); 951 var contextType;952 951 // Find the type from context data. The context data has the format 953 952 // "type,id". 954 953 var comma = context.data.indexOf(","); 955 954 if (comma < 0) 956 return 957 contextType = context.data.substring(0, comma); 958 this.parsedScripts_[script.id] = new devtools.ScriptInfo(script.id, script.name, script.lineOffset, contextType); 955 return; 956 var contextType = context.data.substring(0, comma); 957 var info = new devtools.ScriptInfo(script.id, script.name, script.lineOffset, contextType); 958 this.parsedScripts_[script.id] = info; 959 959 if (this.scriptsPanelInitialized_) { 960 960 // Only report script as parsed after scripts panel has been shown. 961 WebInspector.parsedScriptSource(script.id, script.name, script.source, script.lineOffset + 1 );961 WebInspector.parsedScriptSource(script.id, script.name, script.source, script.lineOffset + 1, info.worldType()); 962 962 this.restoreBreakpoints_(script.id, script.name); 963 963 } … … 1045 1045 if (!existingScript) { 1046 1046 this.parsedScripts_[sourceId] = new devtools.ScriptInfo(sourceId, null /* name */, 0 /* line */, "unknown" /* type */, true /* unresolved */); 1047 WebInspector.parsedScriptSource(sourceId, null, null, 0 );1047 WebInspector.parsedScriptSource(sourceId, null, null, 0, WebInspector.Script.WorldType.MAIN_WORLD); 1048 1048 } 1049 1049 … … 1258 1258 1259 1259 1260 devtools.ScriptInfo.prototype.worldType = function() 1261 { 1262 if (this.contextType_ === "injected") 1263 return WebInspector.Script.WorldType.EXTENSIONS_WORLD; 1264 return WebInspector.Script.WorldType.MAIN_WORLD; 1265 }; 1266 1267 1260 1268 /** 1261 1269 * @param {number} line 0-based line number in the script. -
trunk/WebKit/chromium/src/js/DebuggerScript.js
r60154 r60771 40 40 }; 41 41 42 DebuggerScript.ScriptWorldType = { 43 MainWorld : 0, 44 ExtensionsWorld : 1 45 }; 46 42 47 DebuggerScript._pauseOnExceptionsState = DebuggerScript.PauseOnExceptionsState.DontPauseOnExceptions; 43 48 Debug.clearBreakOnException(); … … 51 56 DebuggerScript.getScripts = function(contextData) 52 57 { 58 var result = []; 59 60 if (!contextData) 61 return result; 62 var comma = contextData.indexOf(","); 63 if (comma === -1) 64 return result; 65 // Context data is a string in the following format: 66 // ("page"|"injected")","<page id> 67 var idSuffix = contextData.substring(comma); // including the comma 68 53 69 var scripts = Debug.scripts(); 54 var result = [];55 70 for (var i = 0; i < scripts.length; ++i) { 56 71 var script = scripts[i]; 57 if ( contextData === script.context_data)72 if (script.context_data && script.context_data.lastIndexOf(idSuffix) != -1) 58 73 result.push(DebuggerScript._formatScript(script)); 59 74 } … … 63 78 DebuggerScript._formatScript = function(script) 64 79 { 80 var scriptWorldType = DebuggerScript.ScriptWorldType.MainWorld; 81 if (script.context_data && script.context_data.indexOf("injected") == 0) 82 scriptWorldType = DebuggerScript.ScriptWorldType.ExtensionsWorld; 65 83 return { 66 84 id: script.id, … … 69 87 lineOffset: script.line_offset, 70 88 lineCount: script.lineCount(), 71 contextData: script.context_data89 scriptWorldType: scriptWorldType 72 90 }; 73 91 } -
trunk/WebKit/chromium/src/js/devTools.css
r60141 r60771 1 #scripts-files option.injected {2 color: rgb(70, 134, 240);3 }4 5 1 .data-grid table { 6 2 line-height: 120%;
Note: See TracChangeset
for help on using the changeset viewer.