diff options
author | Ben Murdoch <benm@google.com> | 2011-05-13 16:23:25 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-16 11:35:02 +0100 |
commit | 65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch) | |
tree | f478babb801e720de7bfaee23443ffe029f58731 /Source/WebCore/inspector/front-end | |
parent | 47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff) | |
download | external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2 |
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/WebCore/inspector/front-end')
36 files changed, 879 insertions, 1434 deletions
diff --git a/Source/WebCore/inspector/front-end/ApplicationCacheItemsView.js b/Source/WebCore/inspector/front-end/ApplicationCacheItemsView.js index f5147e3..e7aa188 100644 --- a/Source/WebCore/inspector/front-end/ApplicationCacheItemsView.js +++ b/Source/WebCore/inspector/front-end/ApplicationCacheItemsView.js @@ -167,7 +167,7 @@ WebInspector.ApplicationCacheItemsView.prototype = { this._emptyMsgElement.addStyleClass("hidden"); this.deleteButton.visible = true; - var totalSizeString = Number.bytesToString(this._size, WebInspector.UIString); + var totalSizeString = Number.bytesToString(this._size); this._treeElement.subtitle = WebInspector.UIString("%s (%s)", lastPathComponent, totalSizeString); // FIXME: For Chrome, put creationTime and updateTime somewhere. @@ -223,7 +223,7 @@ WebInspector.ApplicationCacheItemsView.prototype = { var resource = this._resources[i]; data[0] = resource.name; data[1] = resource.type; - data[2] = Number.bytesToString(resource.size, WebInspector.UIString); + data[2] = Number.bytesToString(resource.size); var node = new WebInspector.DataGridNode(data); node.resource = resource; node.selectable = true; diff --git a/Source/WebCore/inspector/front-end/AuditLauncherView.js b/Source/WebCore/inspector/front-end/AuditLauncherView.js index d4bbf90..c140589 100644 --- a/Source/WebCore/inspector/front-end/AuditLauncherView.js +++ b/Source/WebCore/inspector/front-end/AuditLauncherView.js @@ -53,24 +53,6 @@ WebInspector.AuditLauncherView = function(runnerCallback) } WebInspector.AuditLauncherView.prototype = { - updateResourceTrackingState: function(isTracking) - { - if (!this._auditPresentStateLabelElement) - return; - - if (isTracking) { - this._auditPresentStateLabelElement.nodeValue = WebInspector.UIString("Audit Present State"); - this._auditPresentStateElement.disabled = false; - this._auditPresentStateElement.parentElement.removeStyleClass("disabled"); - } else { - this._resetResourceCount(); - this._auditPresentStateLabelElement.nodeValue = WebInspector.UIString("Audit Present State (Resource Tracking must be enabled)"); - this._auditPresentStateElement.disabled = true; - this._auditPresentStateElement.parentElement.addStyleClass("disabled"); - this.auditReloadedStateElement.checked = true; - } - }, - get totalResources() { return this._totalResources; @@ -100,20 +82,21 @@ WebInspector.AuditLauncherView.prototype = { _resetResourceCount: function() { this.loadedResources = 0; - - // We never receive a resourceStarted notification for the main resource - // (see InspectorController.willSendRequest()) - this.totalResources = 1; + this.totalResources = 0; }, resourceStarted: function(resource) { - ++this.totalResources; + // Ignore long-living WebSockets for the sake of progress indicator, as we won't be waiting them anyway. + if (resource.type !== WebInspector.Resource.Type.WebSocket) + ++this.totalResources; }, resourceFinished: function(resource) { - ++this.loadedResources; + // See resorceStarted for details. + if (resource.type !== WebInspector.Resource.Type.WebSocket) + ++this.loadedResources; }, reset: function() @@ -237,7 +220,7 @@ WebInspector.AuditLauncherView.prototype = { this._auditPresentStateElement.name = "audit-mode"; this._auditPresentStateElement.type = "radio"; this._auditPresentStateElement.checked = true; - this._auditPresentStateLabelElement = document.createTextNode(""); + this._auditPresentStateLabelElement = document.createTextNode(WebInspector.UIString("Audit Present State")); labelElement.appendChild(this._auditPresentStateElement); labelElement.appendChild(this._auditPresentStateLabelElement); this._buttonContainerElement.appendChild(labelElement); @@ -267,7 +250,6 @@ WebInspector.AuditLauncherView.prototype = { this._contentElement.appendChild(this._buttonContainerElement); this._selectAllClicked(this._selectAllCheckboxElement.checked); - this.updateResourceTrackingState(); this._updateButton(); this._updateResourceProgress(); }, diff --git a/Source/WebCore/inspector/front-end/AuditRules.js b/Source/WebCore/inspector/front-end/AuditRules.js index 3f79c25..7aa891f 100644 --- a/Source/WebCore/inspector/front-end/AuditRules.js +++ b/Source/WebCore/inspector/front-end/AuditRules.js @@ -92,13 +92,13 @@ WebInspector.AuditRules.GzipRule.prototype = { } var savings = 2 * size / 3; totalSavings += savings; - summary.addChild(String.sprintf("%s could save ~%s", WebInspector.AuditRuleResult.linkifyDisplayName(resource.url), Number.bytesToString(savings, WebInspector.UIString))); + summary.addChild(String.sprintf("%s could save ~%s", WebInspector.AuditRuleResult.linkifyDisplayName(resource.url), Number.bytesToString(savings))); result.violationCount++; } } if (!totalSavings) return callback(null); - summary.value = String.sprintf("Compressing the following resources with gzip could reduce their transfer size by about two thirds (~%s):", Number.bytesToString(totalSavings, WebInspector.UIString)); + summary.value = String.sprintf("Compressing the following resources with gzip could reduce their transfer size by about two thirds (~%s):", Number.bytesToString(totalSavings)); callback(result); }, @@ -966,7 +966,7 @@ WebInspector.AuditRules.CookieSizeRule.prototype = { for (var i = 0, len = sortedCookieSizes.length; i < len; ++i) { var maxCookieSize = sortedCookieSizes[i].maxCookieSize; if (maxCookieSize > this._maxBytesThreshold) - hugeCookieDomains.push(WebInspector.AuditRuleResult.resourceDomain(sortedCookieSizes[i].domain) + ": " + Number.bytesToString(maxCookieSize, WebInspector.UIString)); + hugeCookieDomains.push(WebInspector.AuditRuleResult.resourceDomain(sortedCookieSizes[i].domain) + ": " + Number.bytesToString(maxCookieSize)); } var bigAvgCookieDomains = []; @@ -975,9 +975,9 @@ WebInspector.AuditRules.CookieSizeRule.prototype = { var domain = sortedCookieSizes[i].domain; var avgCookieSize = sortedCookieSizes[i].avgCookieSize; if (avgCookieSize > this._avgBytesThreshold && avgCookieSize < this._maxBytesThreshold) - bigAvgCookieDomains.push(WebInspector.AuditRuleResult.resourceDomain(domain) + ": " + Number.bytesToString(avgCookieSize, WebInspector.UIString)); + bigAvgCookieDomains.push(WebInspector.AuditRuleResult.resourceDomain(domain) + ": " + Number.bytesToString(avgCookieSize)); } - result.addChild(String.sprintf("The average cookie size for all requests on this page is %s", Number.bytesToString(avgAllCookiesSize, WebInspector.UIString))); + result.addChild(String.sprintf("The average cookie size for all requests on this page is %s", Number.bytesToString(avgAllCookiesSize))); var message; if (hugeCookieDomains.length) { @@ -1027,7 +1027,7 @@ WebInspector.AuditRules.StaticCookielessRule.prototype = { if (badUrls.length < this._minResources) return; - var entry = result.addChild(String.sprintf("%s of cookies were sent with the following static resources. Serve these static resources from a domain that does not set cookies:", Number.bytesToString(cookieBytes, WebInspector.UIString)), true); + var entry = result.addChild(String.sprintf("%s of cookies were sent with the following static resources. Serve these static resources from a domain that does not set cookies:", Number.bytesToString(cookieBytes)), true); entry.addURLs(badUrls); result.violationCount = badUrls.length; }, diff --git a/Source/WebCore/inspector/front-end/AuditsPanel.js b/Source/WebCore/inspector/front-end/AuditsPanel.js index 096f8ce..c639f47 100644 --- a/Source/WebCore/inspector/front-end/AuditsPanel.js +++ b/Source/WebCore/inspector/front-end/AuditsPanel.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -129,9 +129,7 @@ WebInspector.AuditsPanel.prototype = { _executeAudit: function(categories, resultCallback) { - var resources = []; - for (var id in WebInspector.networkResources) - resources.push(WebInspector.networkResources[id]); + var resources = WebInspector.networkResources; var rulesRemaining = 0; for (var i = 0; i < categories.length; ++i) @@ -248,12 +246,6 @@ WebInspector.AuditsPanel.prototype = { x.show(this.viewsContainerElement); }, - show: function() - { - WebInspector.Panel.prototype.show.call(this); - this._updateLauncherViewControls(!WebInspector.panels.resources || WebInspector.panels.resources.resourceTrackingEnabled); - }, - reset: function() { this._launcherView.reset(); @@ -271,12 +263,6 @@ WebInspector.AuditsPanel.prototype = { this.viewsContainerElement.style.left = width + "px"; }, - _updateLauncherViewControls: function(isTracking) - { - if (this._launcherView) - this._launcherView.updateResourceTrackingState(isTracking); - }, - _clearButtonClicked: function() { this.auditsItemTreeElement.reveal(); diff --git a/Source/WebCore/inspector/front-end/Breakpoint.js b/Source/WebCore/inspector/front-end/Breakpoint.js index 0a888d2..e5e1768 100644 --- a/Source/WebCore/inspector/front-end/Breakpoint.js +++ b/Source/WebCore/inspector/front-end/Breakpoint.js @@ -37,7 +37,6 @@ WebInspector.Breakpoint = function(debuggerModel, breakpointId, sourceID, url, l this.sourceID = sourceID; this._enabled = enabled; this._condition = condition || ""; - this._sourceText = ""; this._hit = false; this._debuggerModel = debuggerModel; } @@ -56,17 +55,6 @@ WebInspector.Breakpoint.prototype = { WebInspector.debuggerModel.setBreakpoint(this.sourceID, this.line, enabled, this.condition); }, - get sourceText() - { - return this._sourceText; - }, - - set sourceText(text) - { - this._sourceText = text; - this.dispatchEventToListeners("label-changed"); - }, - get condition() { return this._condition; @@ -99,14 +87,19 @@ WebInspector.Breakpoint.prototype = { populateLabelElement: function(element) { - var displayName = this.url ? WebInspector.displayNameForURL(this.url) : WebInspector.UIString("(program)"); - var labelElement = document.createTextNode(displayName + ":" + this.line); - element.appendChild(labelElement); + function didGetSourceLine(text) + { + var displayName = this.url ? WebInspector.displayNameForURL(this.url) : WebInspector.UIString("(program)"); + var labelElement = document.createTextNode(displayName + ":" + this.line); + element.appendChild(labelElement); - var sourceTextElement = document.createElement("div"); - sourceTextElement.textContent = this.sourceText; - sourceTextElement.className = "source-text monospace"; - element.appendChild(sourceTextElement); + var sourceTextElement = document.createElement("div"); + sourceTextElement.textContent = text; + sourceTextElement.className = "source-text monospace"; + element.appendChild(sourceTextElement); + } + var script = this._debuggerModel.scriptForSourceID(this.sourceID); + script.sourceLine(this.line, didGetSourceLine.bind(this)); }, remove: function() diff --git a/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js b/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js index 619525c..408c5ba 100644 --- a/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js +++ b/Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js @@ -265,24 +265,24 @@ WebInspector.EventListenerBreakpointsSidebarPane = function() WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.EventListenerBreakpointAdded, this._breakpointAdded, this); this._breakpointItems = {}; - this._createCategory("Keyboard", "listener", ["keydown", "keyup", "keypress", "textInput"]); - this._createCategory("Mouse", "listener", ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove", "mouseout", "mousewheel"]); + this._createCategory(WebInspector.UIString("Keyboard"), "listener", ["keydown", "keyup", "keypress", "textInput"]); + this._createCategory(WebInspector.UIString("Mouse"), "listener", ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove", "mouseout", "mousewheel"]); // FIXME: uncomment following once inspector stops being drop targer in major ports. // Otherwise, inspector page reacts on drop event and tries to load the event data. - // this._createCategory("Drag", "listener", ["drag", "drop", "dragstart", "dragend", "dragenter", "dragleave", "dragover"]); - this._createCategory("Control", "listener", ["resize", "scroll", "zoom", "focus", "blur", "select", "change", "submit", "reset"]); - this._createCategory("Clipboard", "listener", ["copy", "cut", "paste", "beforecopy", "beforecut", "beforepaste"]); - this._createCategory("Load", "listener", ["load", "unload", "abort", "error"]); - this._createCategory("DOM Mutation", "listener", ["DOMActivate", "DOMFocusIn", "DOMFocusOut", "DOMAttrModified", "DOMCharacterDataModified", "DOMNodeInserted", "DOMNodeInsertedIntoDocument", "DOMNodeRemoved", "DOMNodeRemovedFromDocument", "DOMSubtreeModified", "DOMContentLoaded"]); - this._createCategory("Device", "listener", ["deviceorientation", "devicemotion"]); - this._createCategory("Timer", "instrumentation", ["setTimer", "clearTimer", "timerFired"]); + // this._createCategory(WebInspector.UIString("Drag"), "listener", ["drag", "drop", "dragstart", "dragend", "dragenter", "dragleave", "dragover"]); + this._createCategory(WebInspector.UIString("Control"), "listener", ["resize", "scroll", "zoom", "focus", "blur", "select", "change", "submit", "reset"]); + this._createCategory(WebInspector.UIString("Clipboard"), "listener", ["copy", "cut", "paste", "beforecopy", "beforecut", "beforepaste"]); + this._createCategory(WebInspector.UIString("Load"), "listener", ["load", "unload", "abort", "error"]); + this._createCategory(WebInspector.UIString("DOM Mutation"), "listener", ["DOMActivate", "DOMFocusIn", "DOMFocusOut", "DOMAttrModified", "DOMCharacterDataModified", "DOMNodeInserted", "DOMNodeInsertedIntoDocument", "DOMNodeRemoved", "DOMNodeRemovedFromDocument", "DOMSubtreeModified", "DOMContentLoaded"]); + this._createCategory(WebInspector.UIString("Device"), "listener", ["deviceorientation", "devicemotion"]); + this._createCategory(WebInspector.UIString("Timer"), "instrumentation", ["setTimer", "clearTimer", "timerFired"]); } WebInspector.EventListenerBreakpointsSidebarPane.prototype = { _createCategory: function(name, type, eventNames) { var categoryItem = {}; - categoryItem.element = new TreeElement(WebInspector.UIString(name)); + categoryItem.element = new TreeElement(name); this.categoriesTreeOutline.appendChild(categoryItem.element); categoryItem.element.listItemElement.addStyleClass("event-category"); categoryItem.element.selectable = true; diff --git a/Source/WebCore/inspector/front-end/ConsoleView.js b/Source/WebCore/inspector/front-end/ConsoleView.js index c98552d..a40030e 100644 --- a/Source/WebCore/inspector/front-end/ConsoleView.js +++ b/Source/WebCore/inspector/front-end/ConsoleView.js @@ -97,9 +97,63 @@ WebInspector.ConsoleView = function(drawer) "node": this._formatnode, "string": this._formatstring }; + + this._registerConsoleDomainDispatcher(); } WebInspector.ConsoleView.prototype = { + _registerConsoleDomainDispatcher: function() { + var console = this; + var dispatcher = { + addConsoleMessage: function(payload) + { + var consoleMessage = new WebInspector.ConsoleMessage( + payload.source, + payload.type, + payload.level, + payload.line, + payload.url, + payload.repeatCount, + payload.message, + payload.parameters, + payload.stackTrace, + payload.requestId); + console.addMessage(consoleMessage); + }, + + updateConsoleMessageExpiredCount: function(count) + { + var message = String.sprintf(WebInspector.UIString("%d console messages are not shown."), count); + console.addMessage(WebInspector.ConsoleMessage.createTextMessage(message, WebInspector.ConsoleMessage.MessageLevel.Warning)); + }, + + updateConsoleMessageRepeatCount: function(count) + { + var msg = console.previousMessage; + var prevRepeatCount = msg.totalRepeatCount; + + if (!console.commandSincePreviousMessage) { + msg.repeatDelta = count - prevRepeatCount; + msg.repeatCount = msg.repeatCount + msg.repeatDelta; + msg.totalRepeatCount = count; + msg._updateRepeatCount(); + console._incrementErrorWarningCount(msg); + } else { + var msgCopy = new WebInspector.ConsoleMessage(msg.source, msg.type, msg.level, msg.line, msg.url, count - prevRepeatCount, msg._messageText, msg._parameters, msg._stackTrace, msg._requestId); + msgCopy.totalRepeatCount = count; + msgCopy._formatMessage(); + console.addMessage(msgCopy); + } + }, + + consoleMessagesCleared: function() + { + console.clearMessages(); + } + } + InspectorBackend.registerDomainDispatcher("Console", dispatcher); + }, + _updateFilter: function(e) { var isMac = WebInspector.isMac(); @@ -247,25 +301,6 @@ WebInspector.ConsoleView.prototype = { this._scheduleScrollIntoView(); }, - updateMessageRepeatCount: function(count) - { - var msg = this.previousMessage; - var prevRepeatCount = msg.totalRepeatCount; - - if (!this.commandSincePreviousMessage) { - msg.repeatDelta = count - prevRepeatCount; - msg.repeatCount = msg.repeatCount + msg.repeatDelta; - msg.totalRepeatCount = count; - msg._updateRepeatCount(); - this._incrementErrorWarningCount(msg); - } else { - var msgCopy = new WebInspector.ConsoleMessage(msg.source, msg.type, msg.level, msg.line, msg.url, count - prevRepeatCount, msg._messageText, msg._parameters, msg._stackTrace, msg._requestId); - msgCopy.totalRepeatCount = count; - msgCopy._formatMessage(); - this.addMessage(msgCopy); - } - }, - _incrementErrorWarningCount: function(msg) { switch (msg.level) { @@ -668,7 +703,7 @@ WebInspector.ConsoleMessage.prototype = { messageText = document.createTextNode(this._messageText); break; case WebInspector.ConsoleMessage.MessageType.NetworkError: - var resource = this._requestId && WebInspector.panels.network.resources[this._requestId]; + var resource = this._requestId && WebInspector.networkResourceById(this._requestId); if (resource) { stackTrace = resource.stackTrace; diff --git a/Source/WebCore/inspector/front-end/CookieItemsView.js b/Source/WebCore/inspector/front-end/CookieItemsView.js index 75c7f84..dc76b39 100644 --- a/Source/WebCore/inspector/front-end/CookieItemsView.js +++ b/Source/WebCore/inspector/front-end/CookieItemsView.js @@ -101,9 +101,10 @@ WebInspector.CookieItemsView.prototype = { this._emptyMsgElement.addStyleClass("hidden"); if (isAdvanced) { this._treeElement.subtitle = String.sprintf(WebInspector.UIString("%d cookies (%s)"), this._cookies.length, - Number.bytesToString(this._totalSize, WebInspector.UIString)); + Number.bytesToString(this._totalSize)); this._deleteButton.visible = true; } + this._cookiesTable.updateWidths(); }, _filterCookiesForDomain: function(allCookies) diff --git a/Source/WebCore/inspector/front-end/DOMAgent.js b/Source/WebCore/inspector/front-end/DOMAgent.js index 89822a3..e4fc7ad 100644 --- a/Source/WebCore/inspector/front-end/DOMAgent.js +++ b/Source/WebCore/inspector/front-end/DOMAgent.js @@ -300,7 +300,7 @@ WebInspector.DOMAgent = function() { this._window = new WebInspector.DOMWindow(this); this._idToDOMNode = null; this.document = null; - InspectorBackend.registerDomainDispatcher("DOM", this); + InspectorBackend.registerDomainDispatcher("DOM", new WebInspector.DOMDispatcher(this)); } WebInspector.DOMAgent.prototype = { @@ -351,7 +351,7 @@ WebInspector.DOMAgent.prototype = { elem.updateTitle(); }, - attributesUpdated: function(nodeId, attrsArray) + _attributesUpdated: function(nodeId, attrsArray) { var node = this._idToDOMNode[nodeId]; node._setAttributesPayload(attrsArray); @@ -359,7 +359,7 @@ WebInspector.DOMAgent.prototype = { this.document._fireDomEvent("DOMAttrModified", event); }, - characterDataModified: function(nodeId, newValue) + _characterDataModified: function(nodeId, newValue) { var node = this._idToDOMNode[nodeId]; node._nodeValue = newValue; @@ -373,13 +373,7 @@ WebInspector.DOMAgent.prototype = { return this._idToDOMNode[nodeId]; }, - didCommitLoad: function() - { - // Cleanup elements panel early on inspected page refresh. - this.setDocument(null); - }, - - setDocument: function(payload) + _setDocument: function(payload) { this._idToDOMNode = {}; if (payload && "id" in payload) { @@ -392,13 +386,13 @@ WebInspector.DOMAgent.prototype = { WebInspector.panels.elements.setDocument(this.document); }, - setDetachedRoot: function(payload) + _setDetachedRoot: function(payload) { var root = new WebInspector.DOMNode(this.document, payload); this._idToDOMNode[payload.id] = root; }, - setChildNodes: function(parentId, payloads) + _setChildNodes: function(parentId, payloads) { var parent = this._idToDOMNode[parentId]; parent._setChildrenPayload(payloads); @@ -415,7 +409,7 @@ WebInspector.DOMAgent.prototype = { } }, - childNodeCountUpdated: function(nodeId, newValue) + _childNodeCountUpdated: function(nodeId, newValue) { var node = this._idToDOMNode[nodeId]; node._childNodeCount = newValue; @@ -425,7 +419,7 @@ WebInspector.DOMAgent.prototype = { treeElement.hasChildren = newValue; }, - childNodeInserted: function(parentId, prevId, payload) + _childNodeInserted: function(parentId, prevId, payload) { var parent = this._idToDOMNode[parentId]; var prev = this._idToDOMNode[prevId]; @@ -435,7 +429,7 @@ WebInspector.DOMAgent.prototype = { this.document._fireDomEvent("DOMNodeInserted", event); }, - childNodeRemoved: function(parentId, nodeId) + _childNodeRemoved: function(parentId, nodeId) { var parent = this._idToDOMNode[parentId]; var node = this._idToDOMNode[nodeId]; @@ -457,31 +451,82 @@ WebInspector.DOMAgent.prototype = { } } -WebInspector.ApplicationCache = {} - -WebInspector.ApplicationCache.getApplicationCachesAsync = function(callback) +WebInspector.DOMDispatcher = function(domAgent) { - function mycallback(applicationCaches) + this._domAgent = domAgent; +} + +WebInspector.DOMDispatcher.prototype = { + setDocument: function(payload) { - // FIXME: Currently, this list only returns a single application cache. - if (applicationCaches) - callback(applicationCaches); - } + this._domAgent._setDocument(payload); + }, + + attributesUpdated: function(nodeId, attrsArray) + { + this._domAgent._attributesUpdated(nodeId, attrsArray); + }, - InspectorBackend.getApplicationCaches(mycallback); + characterDataModified: function(nodeId, newValue) + { + this._domAgent._characterDataModified(nodeId, newValue); + }, + + setChildNodes: function(parentId, payloads) + { + this._domAgent._setChildNodes(parentId, payloads); + }, + + setDetachedRoot: function(payload) + { + this._domAgent._setDetachedRoot(payload); + }, + + childNodeCountUpdated: function(nodeId, newValue) + { + this._domAgent._childNodeCountUpdated(nodeId, newValue); + }, + + childNodeInserted: function(parentId, prevId, payload) + { + this._domAgent._childNodeInserted(parentId, prevId, payload); + }, + + childNodeRemoved: function(parentId, nodeId) + { + this._domAgent._childNodeRemoved(parentId, nodeId); + } } -WebInspector.ApplicationCache.updateApplicationCacheStatus = function(status) +WebInspector.ApplicationCacheDispatcher = function() { - WebInspector.panels.resources.updateApplicationCacheStatus(status); } -WebInspector.ApplicationCache.updateNetworkState = function(isNowOnline) -{ - WebInspector.panels.resources.updateNetworkState(isNowOnline); +WebInspector.ApplicationCacheDispatcher.prototype = { + getApplicationCachesAsync: function(callback) + { + function mycallback(applicationCaches) + { + // FIXME: Currently, this list only returns a single application cache. + if (applicationCaches) + callback(applicationCaches); + } + + InspectorBackend.getApplicationCaches(mycallback); + }, + + updateApplicationCacheStatus: function(status) + { + WebInspector.panels.resources.updateApplicationCacheStatus(status); + }, + + updateNetworkState: function(isNowOnline) + { + WebInspector.panels.resources.updateNetworkState(isNowOnline); + } } -InspectorBackend.registerDomainDispatcher("ApplicationCache", WebInspector.ApplicationCache); +InspectorBackend.registerDomainDispatcher("ApplicationCache", new WebInspector.ApplicationCacheDispatcher()); WebInspector.Cookies = {} diff --git a/Source/WebCore/inspector/front-end/DOMStorage.js b/Source/WebCore/inspector/front-end/DOMStorage.js index aa14a9c..d3d2226 100644 --- a/Source/WebCore/inspector/front-end/DOMStorage.js +++ b/Source/WebCore/inspector/front-end/DOMStorage.js @@ -70,26 +70,33 @@ WebInspector.DOMStorage.prototype = { } } -WebInspector.DOMStorage.addDOMStorage = function(payload) -{ - if (!WebInspector.panels.resources) - return; - var domStorage = new WebInspector.DOMStorage( - payload.id, - payload.host, - payload.isLocalStorage); - WebInspector.panels.resources.addDOMStorage(domStorage); -} -WebInspector.DOMStorage.selectDOMStorage = function(o) +WebInspector.DOMStorageDispatcher = function() { - WebInspector.showPanel("resources"); - WebInspector.panels.resources.selectDOMStorage(o); } -WebInspector.DOMStorage.updateDOMStorage = function(storageId) -{ - WebInspector.panels.resources.updateDOMStorage(storageId); +WebInspector.DOMStorageDispatcher.prototype = { + addDOMStorage: function(payload) + { + if (!WebInspector.panels.resources) + return; + var domStorage = new WebInspector.DOMStorage( + payload.id, + payload.host, + payload.isLocalStorage); + WebInspector.panels.resources.addDOMStorage(domStorage); + }, + + selectDOMStorage: function(o) + { + WebInspector.showPanel("resources"); + WebInspector.panels.resources.selectDOMStorage(o); + }, + + updateDOMStorage: function(storageId) + { + WebInspector.panels.resources.updateDOMStorage(storageId); + } } -InspectorBackend.registerDomainDispatcher("DOMStorage", WebInspector.DOMStorage); +InspectorBackend.registerDomainDispatcher("DOMStorage", new WebInspector.DOMStorageDispatcher()); diff --git a/Source/WebCore/inspector/front-end/Database.js b/Source/WebCore/inspector/front-end/Database.js index 0b00330..faa17fa 100644 --- a/Source/WebCore/inspector/front-end/Database.js +++ b/Source/WebCore/inspector/front-end/Database.js @@ -34,8 +34,6 @@ WebInspector.Database = function(id, domain, name, version) this._version = version; } -WebInspector.Database._callbacks = {}; - WebInspector.Database.prototype = { get id() { @@ -94,50 +92,58 @@ WebInspector.Database.prototype = { onError(WebInspector.UIString("Database not found.")); return; } - WebInspector.Database._callbacks[transactionId] = {"onSuccess": onSuccess, "onError": onError}; + WebInspector.DatabaseDispatcher._callbacks[transactionId] = {"onSuccess": onSuccess, "onError": onError}; } InspectorBackend.executeSQL(this._id, query, callback); } } -WebInspector.Database.addDatabase = function(payload) +WebInspector.DatabaseDispatcher = function() { - if (!WebInspector.panels.resources) - return; - var database = new WebInspector.Database( - payload.id, - payload.domain, - payload.name, - payload.version); - WebInspector.panels.resources.addDatabase(database); } -WebInspector.Database.selectDatabase = function(o) -{ - WebInspector.showPanel("resources"); - WebInspector.panels.resources.selectDatabase(o); -} +WebInspector.DatabaseDispatcher._callbacks = {}; -WebInspector.Database.sqlTransactionSucceeded = function(transactionId, columnNames, values) -{ - if (!WebInspector.Database._callbacks[transactionId]) - return; +WebInspector.DatabaseDispatcher.prototype = { + addDatabase: function(payload) + { + if (!WebInspector.panels.resources) + return; + var database = new WebInspector.Database( + payload.id, + payload.domain, + payload.name, + payload.version); + WebInspector.panels.resources.addDatabase(database); + }, - var callback = WebInspector.Database._callbacks[transactionId].onSuccess; - delete WebInspector.Database._callbacks[transactionId]; - if (callback) - callback(columnNames, values); -} + selectDatabase: function(o) + { + WebInspector.showPanel("resources"); + WebInspector.panels.resources.selectDatabase(o); + }, -WebInspector.Database.sqlTransactionFailed = function(transactionId, errorObj) -{ - if (!WebInspector.Database._callbacks[transactionId]) - return; + sqlTransactionSucceeded: function(transactionId, columnNames, values) + { + if (!WebInspector.DatabaseDispatcher._callbacks[transactionId]) + return; + + var callback = WebInspector.DatabaseDispatcher._callbacks[transactionId].onSuccess; + delete WebInspector.DatabaseDispatcher._callbacks[transactionId]; + if (callback) + callback(columnNames, values); + }, + + sqlTransactionFailed: function(transactionId, errorObj) + { + if (!WebInspector.DatabaseDispatcher._callbacks[transactionId]) + return; - var callback = WebInspector.Database._callbacks[transactionId].onError; - delete WebInspector.Database._callbacks[transactionId]; - if (callback) - callback(errorObj); + var callback = WebInspector.DatabaseDispatcher._callbacks[transactionId].onError; + delete WebInspector.DatabaseDispatcher._callbacks[transactionId]; + if (callback) + callback(errorObj); + } } -InspectorBackend.registerDomainDispatcher("Database", WebInspector.Database); +InspectorBackend.registerDomainDispatcher("Database", new WebInspector.DatabaseDispatcher()); diff --git a/Source/WebCore/inspector/front-end/DebuggerModel.js b/Source/WebCore/inspector/front-end/DebuggerModel.js index 5ab0e2d..8f5bcf7 100644 --- a/Source/WebCore/inspector/front-end/DebuggerModel.js +++ b/Source/WebCore/inspector/front-end/DebuggerModel.js @@ -30,12 +30,12 @@ WebInspector.DebuggerModel = function() { - InspectorBackend.registerDomainDispatcher("Debugger", this); - this._paused = false; this._breakpoints = {}; this._sourceIDAndLineToBreakpointId = {}; this._scripts = {}; + + InspectorBackend.registerDomainDispatcher("Debugger", new WebInspector.DebuggerDispatcher(this)); } WebInspector.DebuggerModel.Events = { @@ -86,11 +86,6 @@ WebInspector.DebuggerModel.prototype = { this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointRemoved, breakpointId); }, - breakpointResolved: function(breakpointId, sourceID, lineNumber, condition, enabled, originalLineNumber) - { - this._breakpointSetOnBackend(breakpointId, sourceID, lineNumber, condition, enabled, originalLineNumber, true); - }, - _breakpointSetOnBackend: function(breakpointId, sourceID, lineNumber, condition, enabled, originalLineNumber, restored) { var sourceIDAndLine = this._encodeSourceIDAndLine(sourceID, lineNumber); @@ -161,9 +156,7 @@ WebInspector.DebuggerModel.prototype = { return scripts; }, - // All the methods below are InspectorBackend notification handlers. - - pausedScript: function(details) + _pausedScript: function(details) { this._paused = true; if ("_continueToLineBreakpointId" in this) { @@ -182,7 +175,7 @@ WebInspector.DebuggerModel.prototype = { this._lastHitBreakpoint = breakpoint; }, - resumedScript: function() + _resumedScript: function() { this._paused = false; this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerResumed); @@ -193,9 +186,42 @@ WebInspector.DebuggerModel.prototype = { delete this._lastHitBreakpoint; }, - attachDebuggerWhenShown: function() + _parsedScriptSource: function(sourceID, sourceURL, lineOffset, columnOffset, scriptWorldType) + { + var script = new WebInspector.Script(sourceID, sourceURL, "", lineOffset, columnOffset, undefined, undefined, scriptWorldType); + this._scripts[sourceID] = script; + this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, sourceID); + }, + + _failedToParseScriptSource: function(sourceURL, source, startingLine, errorLine, errorMessage) + { + var script = new WebInspector.Script(null, sourceURL, source, startingLine, errorLine, errorMessage, undefined); + this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, script); + } +} + +WebInspector.DebuggerModel.prototype.__proto__ = WebInspector.Object.prototype; + +WebInspector.DebuggerEventTypes = { + JavaScriptPause: 0, + JavaScriptBreakpoint: 1, + NativeBreakpoint: 2 +}; + +WebInspector.DebuggerDispatcher = function(debuggerModel) +{ + this._debuggerModel = debuggerModel; +} + +WebInspector.DebuggerDispatcher.prototype = { + pausedScript: function(details) + { + this._debuggerModel._pausedScript(details); + }, + + resumedScript: function() { - WebInspector.panels.scripts.attachDebuggerWhenShown(); + this._debuggerModel._resumedScript(); }, debuggerWasEnabled: function() @@ -208,17 +234,19 @@ WebInspector.DebuggerModel.prototype = { WebInspector.panels.scripts.debuggerWasDisabled(); }, - parsedScriptSource: function(sourceID, sourceURL, source, startingLine, scriptWorldType) + parsedScriptSource: function(sourceID, sourceURL, lineOffset, columnOffset, scriptWorldType) { - var script = new WebInspector.Script(sourceID, sourceURL, source, startingLine, undefined, undefined, scriptWorldType); - this._scripts[sourceID] = script; - this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, sourceID); + this._debuggerModel._parsedScriptSource(sourceID, sourceURL, lineOffset, columnOffset, scriptWorldType); }, failedToParseScriptSource: function(sourceURL, source, startingLine, errorLine, errorMessage) { - var script = new WebInspector.Script(null, sourceURL, source, startingLine, errorLine, errorMessage, undefined); - this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, script); + this._debuggerModel._failedToParseScriptSource(sourceURL, source, startingLine, errorLine, errorMessage); + }, + + breakpointResolved: function(breakpointId, sourceID, lineNumber, condition, enabled, originalLineNumber) + { + this._debuggerModel._breakpointSetOnBackend(breakpointId, sourceID, lineNumber, condition, enabled, originalLineNumber, true); }, didCreateWorker: function() @@ -233,11 +261,3 @@ WebInspector.DebuggerModel.prototype = { workersPane.removeWorker.apply(workersPane, arguments); } } - -WebInspector.DebuggerModel.prototype.__proto__ = WebInspector.Object.prototype; - -WebInspector.DebuggerEventTypes = { - JavaScriptPause: 0, - JavaScriptBreakpoint: 1, - NativeBreakpoint: 2 -}; diff --git a/Source/WebCore/inspector/front-end/ExtensionServer.js b/Source/WebCore/inspector/front-end/ExtensionServer.js index 373c855..1320efb 100644 --- a/Source/WebCore/inspector/front-end/ExtensionServer.js +++ b/Source/WebCore/inspector/front-end/ExtensionServer.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -288,7 +288,7 @@ WebInspector.ExtensionServer.prototype = { var id = message.id; var resource = null; - resource = WebInspector.networkResources[id] || WebInspector.resourceForURL(id); + resource = WebInspector.networkResourceById(id) || WebInspector.resourceForURL(id); if (!resource) return this._status.E_NOTFOUND(typeof id + ": " + id); @@ -318,7 +318,7 @@ WebInspector.ExtensionServer.prototype = { }; this._dispatchCallback(message.requestId, port, response); } - var resource = WebInspector.networkResources[message.id]; + var resource = WebInspector.networkResourceById(message.id); if (!resource) return this._status.E_NOTFOUND(message.id); resource.requestContent(onContentAvailable.bind(this)); diff --git a/Source/WebCore/inspector/front-end/FileSystemView.js b/Source/WebCore/inspector/front-end/FileSystemView.js index 14ecf46..56f21a4 100644 --- a/Source/WebCore/inspector/front-end/FileSystemView.js +++ b/Source/WebCore/inspector/front-end/FileSystemView.js @@ -28,34 +28,38 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -WebInspector.FileSystem = {} +WebInspector.FileSystemDispatcher = function() +{ +} // Keep in sync with Type in AsyncFileSystem.h -WebInspector.FileSystem.TEMPORARY = 0; -WebInspector.FileSystem.PERSISTENT = 1; +WebInspector.FileSystemDispatcher.TEMPORARY = 0; +WebInspector.FileSystemDispatcher.PERSISTENT = 1; -WebInspector.FileSystem.getFileSystemPathsAsync = function(origin) -{ - InspectorBackend.getFileSystemPathAsync(WebInspector.FileSystem.PERSISTENT, origin); - InspectorBackend.getFileSystemPathAsync(WebInspector.FileSystem.TEMPORARY, origin); -} +WebInspector.FileSystemDispatcher.prototype = { + getFileSystemPathsAsync: function(origin) + { + InspectorBackend.getFileSystemPathAsync(WebInspector.FileSystemDispatcher.PERSISTENT, origin); + InspectorBackend.getFileSystemPathAsync(WebInspector.FileSystemDispatcher.TEMPORARY, origin); + }, -WebInspector.FileSystem.didGetFileSystemPath = function(root, type, origin) -{ - WebInspector.panels.resources.updateFileSystemPath(root, type, origin); -} + didGetFileSystemPath: function(root, type, origin) + { + WebInspector.panels.resources.updateFileSystemPath(root, type, origin); + }, -WebInspector.FileSystem.didGetFileSystemError = function(type, origin) -{ - WebInspector.panels.resources.updateFileSystemError(type, origin); -} + didGetFileSystemError: function(type, origin) + { + WebInspector.panels.resources.updateFileSystemError(type, origin); + }, -WebInspector.FileSystem.didGetFileSystemDisabled = function() -{ - WebInspector.panels.resources.setFileSystemDisabled(); + didGetFileSystemDisabled: function() + { + WebInspector.panels.resources.setFileSystemDisabled(); + } } -InspectorBackend.registerDomainDispatcher("FileSystem", WebInspector.FileSystem); +InspectorBackend.registerDomainDispatcher("FileSystem", new WebInspector.FileSystemDispatcher()); WebInspector.FileSystemView = function(treeElement, fileSystemOrigin) { diff --git a/Source/WebCore/inspector/front-end/HAREntry.js b/Source/WebCore/inspector/front-end/HAREntry.js index 6dfbd1b..4d690b3 100644 --- a/Source/WebCore/inspector/front-end/HAREntry.js +++ b/Source/WebCore/inspector/front-end/HAREntry.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -204,7 +204,7 @@ WebInspector.HARLog.prototype = { version: webKitVersion ? webKitVersion[1] : "n/a" }, pages: this._buildPages(), - entries: Object.keys(WebInspector.networkResources).map(this._convertResource.bind(this)) + entries: WebInspector.networkResources.map(this._convertResource.bind(this)) } }, @@ -228,11 +228,11 @@ WebInspector.HARLog.prototype = { } }, - _convertResource: function(id) + _convertResource: function(resource) { - var entry = (new WebInspector.HAREntry(WebInspector.networkResources[id])).build(); + var entry = (new WebInspector.HAREntry(resource)).build(); if (this.includeResourceIds) - entry._resourceId = id; + entry._resourceId = resource.identifier; return entry; }, diff --git a/Source/WebCore/inspector/front-end/ImageView.js b/Source/WebCore/inspector/front-end/ImageView.js index 54a16bb..917a9da 100644 --- a/Source/WebCore/inspector/front-end/ImageView.js +++ b/Source/WebCore/inspector/front-end/ImageView.js @@ -70,12 +70,7 @@ WebInspector.ImageView.prototype = { var infoListElement = document.createElement("dl"); infoListElement.className = "infoList"; - function onResourceContent(element, content) - { - imagePreviewElement.setAttribute("src", this.resource.contentURL); - } - this.resource.requestContent(onResourceContent.bind(this)); - + this.resource.populateImageSource(imagePreviewElement); function onImageLoad() { @@ -87,7 +82,7 @@ WebInspector.ImageView.prototype = { var imageProperties = [ { name: WebInspector.UIString("Dimensions"), value: WebInspector.UIString("%d × %d", imagePreviewElement.naturalWidth, imagePreviewElement.naturalHeight) }, - { name: WebInspector.UIString("File size"), value: Number.bytesToString(resourceSize, WebInspector.UIString) }, + { name: WebInspector.UIString("File size"), value: Number.bytesToString(resourceSize) }, { name: WebInspector.UIString("MIME type"), value: this.resource.mimeType } ]; @@ -100,6 +95,13 @@ WebInspector.ImageView.prototype = { dd.textContent = imageProperties[i].value; infoListElement.appendChild(dd); } + var dt = document.createElement("dt"); + dt.textContent = WebInspector.UIString("URL"); + infoListElement.appendChild(dt); + var dd = document.createElement("dd"); + dd.appendChild(WebInspector.linkifyURLAsNode(this.resource.url)); + infoListElement.appendChild(dd); + this._container.appendChild(infoListElement); } imagePreviewElement.addEventListener("load", onImageLoad.bind(this), false); diff --git a/Source/WebCore/inspector/front-end/InjectedScript.js b/Source/WebCore/inspector/front-end/InjectedScript.js deleted file mode 100644 index fb6b796..0000000 --- a/Source/WebCore/inspector/front-end/InjectedScript.js +++ /dev/null @@ -1,716 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -var injectedScriptConstructor = (function (InjectedScriptHost, inspectedWindow, injectedScriptId) { - -var InjectedScript = function() -{ - this._lastBoundObjectId = 1; - this._idToWrappedObject = {}; - this._objectGroups = {}; -} - -InjectedScript.prototype = { - wrapObjectForConsole: function(object, canAccessInspectedWindow) - { - if (canAccessInspectedWindow) - return this._wrapObject(object, "console"); - var result = {}; - result.type = typeof object; - result.description = this._toString(object); - return result; - }, - - _wrapObject: function(object, objectGroupName, abbreviate) - { - try { - var objectId; - if (typeof object === "object" || typeof object === "function" || this._isHTMLAllCollection(object)) { - var id = this._lastBoundObjectId++; - this._idToWrappedObject[id] = object; - - var group = this._objectGroups[objectGroupName]; - if (!group) { - group = []; - this._objectGroups[objectGroupName] = group; - } - group.push(id); - objectId = this._serializeObjectId(id, objectGroupName); - } - return InjectedScript.RemoteObject.fromObject(object, objectId, abbreviate); - } catch (e) { - return InjectedScript.RemoteObject.fromObject("[ Exception: " + e.toString() + " ]"); - } - }, - - _serializeObjectId: function(id, groupName) - { - return injectedScriptId + ":" + id + ":" + groupName; - }, - - _parseObjectId: function(objectId) - { - var tokens = objectId.split(":"); - var parsedObjectId = {}; - parsedObjectId.id = parseInt(tokens[1]); - parsedObjectId.groupName = tokens[2]; - return parsedObjectId; - }, - - releaseWrapperObjectGroup: function(objectGroupName) - { - var group = this._objectGroups[objectGroupName]; - if (!group) - return; - for (var i = 0; i < group.length; i++) - delete this._idToWrappedObject[group[i]]; - delete this._objectGroups[objectGroupName]; - }, - - dispatch: function(methodName, args) - { - var argsArray = eval("(" + args + ")"); - var result = this[methodName].apply(this, argsArray); - if (typeof result === "undefined") { - inspectedWindow.console.error("Web Inspector error: InjectedScript.%s returns undefined", methodName); - result = null; - } - return result; - }, - - getPrototypes: function(nodeId) - { - this.releaseWrapperObjectGroup("prototypes"); - var node = this._nodeForId(nodeId); - if (!node) - return false; - - var result = []; - var prototype = node; - do { - result.push(this._wrapObject(prototype, "prototypes")); - prototype = prototype.__proto__; - } while (prototype) - return result; - }, - - getProperties: function(objectId, ignoreHasOwnProperty, abbreviate) - { - var parsedObjectId = this._parseObjectId(objectId); - var object = this._objectForId(parsedObjectId); - if (!this._isDefined(object)) - return false; - var properties = []; - - var propertyNames = ignoreHasOwnProperty ? this._getPropertyNames(object) : Object.getOwnPropertyNames(object); - if (!ignoreHasOwnProperty && object.__proto__) - propertyNames.push("__proto__"); - - // Go over properties, prepare results. - for (var i = 0; i < propertyNames.length; ++i) { - var propertyName = propertyNames[i]; - - var property = {}; - property.name = propertyName + ""; - var isGetter = object["__lookupGetter__"] && object.__lookupGetter__(propertyName); - if (!isGetter) { - try { - property.value = this._wrapObject(object[propertyName], parsedObjectId.groupName, abbreviate); - } catch(e) { - property.value = new InjectedScript.RemoteObject.fromException(e); - } - } else { - // FIXME: this should show something like "getter" (bug 16734). - property.value = new InjectedScript.RemoteObject.fromObject("\u2014"); // em dash - property.isGetter = true; - } - properties.push(property); - } - return properties; - }, - - setPropertyValue: function(objectId, propertyName, expression) - { - var parsedObjectId = this._parseObjectId(objectId); - var object = this._objectForId(parsedObjectId); - if (!this._isDefined(object)) - return false; - - var expressionLength = expression.length; - if (!expressionLength) { - delete object[propertyName]; - return !(propertyName in object); - } - - try { - // Surround the expression in parenthesis so the result of the eval is the result - // of the whole expression not the last potential sub-expression. - - // There is a regression introduced here: eval is now happening against global object, - // not call frame while on a breakpoint. - // TODO: bring evaluation against call frame back. - var result = inspectedWindow.eval("(" + expression + ")"); - // Store the result in the property. - object[propertyName] = result; - return true; - } catch(e) { - try { - var result = inspectedWindow.eval("\"" + expression.replace(/"/g, "\\\"") + "\""); - object[propertyName] = result; - return true; - } catch(e) { - return false; - } - } - }, - - _populatePropertyNames: function(object, resultSet) - { - for (var o = object; o; o = o.__proto__) { - try { - var names = Object.getOwnPropertyNames(o); - for (var i = 0; i < names.length; ++i) - resultSet[names[i]] = true; - } catch (e) { - } - } - }, - - _getPropertyNames: function(object, resultSet) - { - var propertyNameSet = {}; - this._populatePropertyNames(object, propertyNameSet); - return Object.keys(propertyNameSet); - }, - - getCompletions: function(expression, includeInspectorCommandLineAPI, callFrameId) - { - var props = {}; - try { - var expressionResult; - // Evaluate on call frame if call frame id is available. - if (typeof callFrameId === "number") { - var callFrame = this._callFrameForId(callFrameId); - if (!callFrame) - return props; - if (expression) - expressionResult = this._evaluateOn(callFrame.evaluate, callFrame, expression, true); - else { - // Evaluate into properties in scope of the selected call frame. - var scopeChain = callFrame.scopeChain; - for (var i = 0; i < scopeChain.length; ++i) - this._populatePropertyNames(scopeChain[i], props); - } - } else { - if (!expression) - expression = "this"; - expressionResult = this._evaluateOn(inspectedWindow.eval, inspectedWindow, expression, false); - } - if (typeof expressionResult === "object") - this._populatePropertyNames(expressionResult, props); - - if (includeInspectorCommandLineAPI) { - for (var prop in this._commandLineAPI) - props[prop] = true; - } - } catch(e) { - } - return props; - }, - - evaluate: function(expression, objectGroup) - { - return this._evaluateAndWrap(inspectedWindow.eval, inspectedWindow, expression, objectGroup, false); - }, - - _evaluateAndWrap: function(evalFunction, object, expression, objectGroup, isEvalOnCallFrame) - { - try { - return this._wrapObject(this._evaluateOn(evalFunction, object, expression, isEvalOnCallFrame), objectGroup); - } catch (e) { - return InjectedScript.RemoteObject.fromException(e); - } - }, - - _evaluateOn: function(evalFunction, object, expression, isEvalOnCallFrame) - { - // Only install command line api object for the time of evaluation. - // Surround the expression in with statements to inject our command line API so that - // the window object properties still take more precedent than our API functions. - inspectedWindow.console._commandLineAPI = this._commandLineAPI; - - // We don't want local variables to be shadowed by global ones when evaluating on CallFrame. - if (!isEvalOnCallFrame) - expression = "with (window) {\n" + expression + "\n} "; - expression = "with (window ? window.console._commandLineAPI : {}) {\n" + expression + "\n}"; - var value = evalFunction.call(object, expression); - - delete inspectedWindow.console._commandLineAPI; - - // When evaluating on call frame error is not thrown, but returned as a value. - if (this._type(value) === "error") - throw value.toString(); - - return value; - }, - - getNodeId: function(node) - { - return InjectedScriptHost.pushNodePathToFrontend(node, false, false); - }, - - callFrames: function() - { - var callFrame = InjectedScriptHost.currentCallFrame(); - if (!callFrame) - return false; - - injectedScript.releaseWrapperObjectGroup("backtrace"); - var result = []; - var depth = 0; - do { - result.push(new InjectedScript.CallFrameProxy(depth++, callFrame)); - callFrame = callFrame.caller; - } while (callFrame); - return result; - }, - - evaluateInCallFrame: function(callFrameId, code, objectGroup) - { - var callFrame = this._callFrameForId(callFrameId); - if (!callFrame) - return false; - return this._evaluateAndWrap(callFrame.evaluate, callFrame, code, objectGroup, true); - }, - - _callFrameForId: function(id) - { - var callFrame = InjectedScriptHost.currentCallFrame(); - while (--id >= 0 && callFrame) - callFrame = callFrame.caller; - return callFrame; - }, - - _nodeForId: function(nodeId) - { - if (!nodeId) - return null; - return InjectedScriptHost.nodeForId(nodeId); - }, - - _objectForId: function(parsedObjectId) - { - return this._idToWrappedObject[parsedObjectId.id]; - }, - - resolveNode: function(nodeId) - { - var node = this._nodeForId(nodeId); - if (!node) - return false; - // FIXME: receive the object group from client. - return this._wrapObject(node, "prototype"); - }, - - getNodeProperties: function(nodeId, properties) - { - var node = this._nodeForId(nodeId); - if (!node) - return false; - var result = {}; - for (var i = 0; i < properties.length; ++i) - result[properties[i]] = node[properties[i]]; - return result; - }, - - pushNodeToFrontend: function(objectId) - { - var parsedObjectId = this._parseObjectId(objectId); - var object = this._objectForId(parsedObjectId); - if (!object || this._type(object) !== "node") - return false; - return InjectedScriptHost.pushNodePathToFrontend(object, false, false); - }, - - evaluateOnSelf: function(funcBody, args) - { - var func = window.eval("(" + funcBody + ")"); - return func.apply(this, args || []); - }, - - _isDefined: function(object) - { - return object || this._isHTMLAllCollection(object); - }, - - _isHTMLAllCollection: function(object) - { - // document.all is reported as undefined, but we still want to process it. - return (typeof object === "undefined") && inspectedWindow.HTMLAllCollection && object instanceof inspectedWindow.HTMLAllCollection; - }, - - _type: function(obj) - { - if (obj === null) - return "null"; - - var type = typeof obj; - if (type !== "object" && type !== "function") { - // FIXME(33716): typeof document.all is always 'undefined'. - if (this._isHTMLAllCollection(obj)) - return "array"; - return type; - } - - // If owning frame has navigated to somewhere else window properties will be undefined. - // In this case just return result of the typeof. - if (!inspectedWindow.document) - return type; - - if (obj instanceof inspectedWindow.Node) - return (obj.nodeType === undefined ? type : "node"); - if (obj instanceof inspectedWindow.String) - return "string"; - if (obj instanceof inspectedWindow.Array) - return "array"; - if (obj instanceof inspectedWindow.Boolean) - return "boolean"; - if (obj instanceof inspectedWindow.Number) - return "number"; - if (obj instanceof inspectedWindow.Date) - return "date"; - if (obj instanceof inspectedWindow.RegExp) - return "regexp"; - // FireBug's array detection. - if (isFinite(obj.length) && typeof obj.splice === "function") - return "array"; - if (isFinite(obj.length) && typeof obj.callee === "function") // arguments. - return "array"; - if (obj instanceof inspectedWindow.NodeList) - return "array"; - if (obj instanceof inspectedWindow.HTMLCollection) - return "array"; - if (obj instanceof inspectedWindow.Error) - return "error"; - return type; - }, - - _describe: function(obj, abbreviated) - { - var type = this._type(obj); - - switch (type) { - case "object": - case "node": - var result = InjectedScriptHost.internalConstructorName(obj); - if (result === "Object") { - // In Chromium DOM wrapper prototypes will have Object as their constructor name, - // get the real DOM wrapper name from the constructor property. - var constructorName = obj.constructor && obj.constructor.name; - if (constructorName) - return constructorName; - } - return result; - case "array": - var className = InjectedScriptHost.internalConstructorName(obj); - if (typeof obj.length === "number") - className += "[" + obj.length + "]"; - return className; - case "string": - if (!abbreviated) - return obj; - if (obj.length > 100) - return "\"" + obj.substring(0, 100) + "\u2026\""; - return "\"" + obj + "\""; - case "function": - var objectText = this._toString(obj); - if (abbreviated) - objectText = /.*/.exec(objectText)[0].replace(/ +$/g, ""); - return objectText; - default: - return this._toString(obj); - } - }, - - _toString: function(obj) - { - // We don't use String(obj) because inspectedWindow.String is undefined if owning frame navigated to another page. - return "" + obj; - }, - - _logEvent: function(event) - { - console.log(event.type, event); - }, - - _normalizeEventTypes: function(types) - { - if (typeof types === "undefined") - types = [ "mouse", "key", "load", "unload", "abort", "error", "select", "change", "submit", "reset", "focus", "blur", "resize", "scroll" ]; - else if (typeof types === "string") - types = [ types ]; - - var result = []; - for (var i = 0; i < types.length; i++) { - if (types[i] === "mouse") - result.splice(0, 0, "mousedown", "mouseup", "click", "dblclick", "mousemove", "mouseover", "mouseout"); - else if (types[i] === "key") - result.splice(0, 0, "keydown", "keyup", "keypress"); - else - result.push(types[i]); - } - return result; - }, - - _inspectedNode: function(num) - { - var nodeId = InjectedScriptHost.inspectedNode(num); - return this._nodeForId(nodeId); - }, - - _bindToScript: function(func) - { - var args = Array.prototype.slice.call(arguments, 1); - function bound() - { - return func.apply(injectedScript, args.concat(Array.prototype.slice.call(arguments))); - } - bound.toString = function() { - return "bound: " + func; - }; - return bound; - } -} - -var injectedScript = new InjectedScript(); - -InjectedScript.RemoteObject = function(objectId, type, description, hasChildren) -{ - this.objectId = objectId; - this.type = type; - this.description = description; - this.hasChildren = hasChildren; -} - -InjectedScript.RemoteObject.fromException = function(e) -{ - return new InjectedScript.RemoteObject(null, "error", e.toString()); -} - -InjectedScript.RemoteObject.fromObject = function(object, objectId, abbreviate) -{ - var type = injectedScript._type(object); - var rawType = typeof object; - var hasChildren = (rawType === "object" && object !== null && (Object.getOwnPropertyNames(object).length || !!object.__proto__)) || rawType === "function"; - var description = ""; - try { - var description = injectedScript._describe(object, abbreviate); - return new InjectedScript.RemoteObject(objectId, type, description, hasChildren); - } catch (e) { - return InjectedScript.RemoteObject.fromException(e); - } -} - -InjectedScript.CallFrameProxy = function(id, callFrame) -{ - this.id = id; - this.type = callFrame.type; - this.functionName = (this.type === "function" ? callFrame.functionName : ""); - this.sourceID = callFrame.sourceID; - this.line = callFrame.line; - this.scopeChain = this._wrapScopeChain(callFrame); - this.worldId = injectedScriptId; -} - -InjectedScript.CallFrameProxy.prototype = { - _wrapScopeChain: function(callFrame) - { - const GLOBAL_SCOPE = 0; - const LOCAL_SCOPE = 1; - const WITH_SCOPE = 2; - const CLOSURE_SCOPE = 3; - const CATCH_SCOPE = 4; - - var scopeChain = callFrame.scopeChain; - var scopeChainProxy = []; - var foundLocalScope = false; - for (var i = 0; i < scopeChain.length; i++) { - var scopeType = callFrame.scopeType(i); - var scopeObject = scopeChain[i]; - var scopeObjectProxy = injectedScript._wrapObject(scopeObject, "backtrace", true); - - switch(scopeType) { - case LOCAL_SCOPE: { - foundLocalScope = true; - scopeObjectProxy.isLocal = true; - scopeObjectProxy.thisObject = injectedScript._wrapObject(callFrame.thisObject, "backtrace", true); - break; - } - case CLOSURE_SCOPE: { - scopeObjectProxy.isClosure = true; - break; - } - case WITH_SCOPE: - case CATCH_SCOPE: { - if (foundLocalScope && scopeObject instanceof inspectedWindow.Element) - scopeObjectProxy.isElement = true; - else if (foundLocalScope && scopeObject instanceof inspectedWindow.Document) - scopeObjectProxy.isDocument = true; - else - scopeObjectProxy.isWithBlock = true; - break; - } - } - scopeChainProxy.push(scopeObjectProxy); - } - return scopeChainProxy; - } -} - -function CommandLineAPI() -{ - for (var i = 0; i < 5; ++i) - this.__defineGetter__("$" + i, injectedScript._bindToScript(injectedScript._inspectedNode, i)); -} - -CommandLineAPI.prototype = { - // Only add API functions here, private stuff should go to - // InjectedScript so that it is not suggested by the completion. - $: function() - { - return document.getElementById.apply(document, arguments) - }, - - $$: function() - { - return document.querySelectorAll.apply(document, arguments) - }, - - $x: function(xpath, context) - { - var nodes = []; - try { - var doc = context || document; - var results = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var node; - while (node = results.iterateNext()) - nodes.push(node); - } catch (e) { - } - return nodes; - }, - - dir: function() - { - return console.dir.apply(console, arguments) - }, - - dirxml: function() - { - return console.dirxml.apply(console, arguments) - }, - - keys: function(object) - { - return Object.keys(object); - }, - - values: function(object) - { - var result = []; - for (var key in object) - result.push(object[key]); - return result; - }, - - profile: function() - { - return console.profile.apply(console, arguments) - }, - - profileEnd: function() - { - return console.profileEnd.apply(console, arguments) - }, - - monitorEvents: function(object, types) - { - if (!object || !object.addEventListener || !object.removeEventListener) - return; - types = injectedScript._normalizeEventTypes(types); - for (var i = 0; i < types.length; ++i) { - object.removeEventListener(types[i], injectedScript._logEvent, false); - object.addEventListener(types[i], injectedScript._logEvent, false); - } - }, - - unmonitorEvents: function(object, types) - { - if (!object || !object.addEventListener || !object.removeEventListener) - return; - types = injectedScript._normalizeEventTypes(types); - for (var i = 0; i < types.length; ++i) - object.removeEventListener(types[i], injectedScript._logEvent, false); - }, - - inspect: function(object) - { - if (arguments.length === 0) - return; - - inspectedWindow.console.log(object); - if (injectedScript._type(object) === "node") - InjectedScriptHost.pushNodePathToFrontend(object, false, true); - else { - switch (injectedScript._describe(object)) { - case "Database": - InjectedScriptHost.selectDatabase(object); - break; - case "Storage": - InjectedScriptHost.selectDOMStorage(object); - break; - } - } - }, - - copy: function(object) - { - if (injectedScript._type(object) === "node") - object = object.outerHTML; - InjectedScriptHost.copyText(object); - }, - - clear: function() - { - InjectedScriptHost.clearConsoleMessages(); - } -} - -injectedScript._commandLineAPI = new CommandLineAPI(); -return injectedScript; -}); diff --git a/Source/WebCore/inspector/front-end/NetworkManager.js b/Source/WebCore/inspector/front-end/NetworkManager.js index b1ec97c..a657377 100644 --- a/Source/WebCore/inspector/front-end/NetworkManager.js +++ b/Source/WebCore/inspector/front-end/NetworkManager.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009, 2010 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -30,8 +30,9 @@ WebInspector.NetworkManager = function(resourceTreeModel) { - this._resourcesById = {}; + this._inflightResources = {}; this._resourceTreeModel = resourceTreeModel; + this._lastIdentifierForCachedResource = 0; InspectorBackend.registerDomainDispatcher("Network", this); } @@ -86,20 +87,21 @@ WebInspector.NetworkManager.updateResourceWithCachedResource = function(resource } WebInspector.NetworkManager.prototype = { - identifierForInitialRequest: function(identifier, url, loader, callStack) + reset: function() { - var resource = this._createResource(identifier, url, loader, callStack); - - // It is important to bind resource url early (before scripts compile). - this._resourceTreeModel.bindResourceURL(resource); + WebInspector.panels.network.clear(); + WebInspector.panels.resources.clear(); + this._resourceTreeModel.reloadCachedResources(); + }, - WebInspector.panels.network.refreshResource(resource); - WebInspector.panels.audits.resourceStarted(resource); + identifierForInitialRequest: function(identifier, url, loader, callStack) + { + this._startResource(this._resourceTreeModel.createResource(identifier, url, loader, callStack)); }, willSendRequest: function(identifier, time, request, redirectResponse) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; @@ -107,24 +109,22 @@ WebInspector.NetworkManager.prototype = { // See http/tests/misc/will-send-request-returns-null-on-redirect.html var isRedirect = !redirectResponse.isNull && request.url.length; if (isRedirect) { - resource.endTime = time; this.didReceiveResponse(identifier, time, "Other", redirectResponse); - resource = this._appendRedirect(resource.identifier, request.url); + resource = this._appendRedirect(resource.identifier, time, request.url); } WebInspector.NetworkManager.updateResourceWithRequest(resource, request); resource.startTime = time; - if (isRedirect) { - WebInspector.panels.network.refreshResource(resource); - WebInspector.panels.audits.resourceStarted(resource); - } else + if (isRedirect) + this._startResource(resource); + else WebInspector.panels.network.refreshResource(resource); }, markResourceAsCached: function(identifier) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; @@ -134,7 +134,7 @@ WebInspector.NetworkManager.prototype = { didReceiveResponse: function(identifier, time, resourceType, response) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; @@ -149,7 +149,7 @@ WebInspector.NetworkManager.prototype = { didReceiveContentLength: function(identifier, time, lengthReceived) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; @@ -161,54 +161,44 @@ WebInspector.NetworkManager.prototype = { didFinishLoading: function(identifier, finishTime) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; - resource.endTime = finishTime; - resource.finished = true; - - WebInspector.panels.network.refreshResource(resource); - WebInspector.panels.audits.resourceFinished(resource); - WebInspector.extensionServer.notifyResourceFinished(resource); - delete this._resourcesById[identifier]; + this._finishResource(resource, finishTime); }, didFailLoading: function(identifier, time, localizedDescription) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; resource.failed = true; resource.localizedFailDescription = localizedDescription; - resource.finished = true; - resource.endTime = time; - - WebInspector.panels.network.refreshResource(resource); - WebInspector.panels.audits.resourceFinished(resource); - WebInspector.extensionServer.notifyResourceFinished(resource); - delete this._resourcesById[identifier]; + this._finishResource(resource, time); }, didLoadResourceFromMemoryCache: function(time, cachedResource) { - var resource = this._createResource(null, cachedResource.url, cachedResource.loader); + var resource = this._resourceTreeModel.createResource("cached:" + ++this._lastIdentifierForCachedResource, cachedResource.url, cachedResource.loader); WebInspector.NetworkManager.updateResourceWithCachedResource(resource, cachedResource); resource.cached = true; resource.requestMethod = "GET"; - resource.startTime = resource.responseReceivedTime = resource.endTime = time; - resource.finished = true; - - WebInspector.panels.network.refreshResource(resource); - WebInspector.panels.audits.resourceStarted(resource); - WebInspector.panels.audits.resourceFinished(resource); + this._startResource(resource); + resource.startTime = resource.responseReceivedTime = time; + this._finishResource(resource, time); this._resourceTreeModel.addResourceToFrame(resource.loader.frameId, resource); }, + frameDetachedFromParent: function(frameId) + { + this._resourceTreeModel.frameDetachedFromParent(frameId); + }, + setInitialContent: function(identifier, sourceString, type) { - var resource = WebInspector.panels.network.resources[identifier]; + var resource = WebInspector.networkResourceById(identifier); if (!resource) return; @@ -226,20 +216,21 @@ WebInspector.NetworkManager.prototype = { if (mainResource) { WebInspector.mainResource = mainResource; mainResource.isMainResource = true; + WebInspector.panels.network.mainResourceChanged(); } } }, didCreateWebSocket: function(identifier, requestURL) { - var resource = this._createResource(identifier, requestURL); + var resource = this._resourceTreeModel.createResource(identifier, requestURL); resource.type = WebInspector.Resource.Type.WebSocket; - WebInspector.panels.network.refreshResource(resource); + this._startResource(resource); }, willSendWebSocketHandshakeRequest: function(identifier, time, request) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; @@ -253,7 +244,7 @@ WebInspector.NetworkManager.prototype = { didReceiveWebSocketHandshakeResponse: function(identifier, time, response) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; @@ -268,31 +259,44 @@ WebInspector.NetworkManager.prototype = { didCloseWebSocket: function(identifier, time) { - var resource = this._resourcesById[identifier]; + var resource = this._inflightResources[identifier]; if (!resource) return; - resource.endTime = time; - - WebInspector.panels.network.refreshResource(resource); + this._finishResource(resource, time); }, - _createResource: function(identifier, url, loader, callStack) + _appendRedirect: function(identifier, time, redirectURL) { - var resource = WebInspector.ResourceTreeModel.createResource(identifier, url, loader, callStack); - this._resourcesById[identifier] = resource; - return resource; + var originalResource = this._inflightResources[identifier]; + var previousRedirects = originalResource.redirects || []; + originalResource.identifier = "redirected:" + identifier + "." + previousRedirects.length; + delete originalResource.redirects; + this._finishResource(originalResource, time); + // We bound resource early, but it happened to be a redirect and won't make it through to + // the resource tree -- so unbind it. + // FIXME: we should bind upon adding to the tree only (encapsulated into ResourceTreeModel), + // Script debugger should do explicit late binding on its own. + this._resourceTreeModel.unbindResourceURL(originalResource); + + var newResource = this._resourceTreeModel.createResource(identifier, redirectURL, originalResource.loader, originalResource.stackTrace); + newResource.redirects = previousRedirects.concat(originalResource); + return newResource; }, - _appendRedirect: function(identifier, redirectURL) + _startResource: function(resource, skipRefresh) { - var originalResource = this._resourcesById[identifier]; - originalResource.finished = true; - originalResource.identifier = null; + this._inflightResources[resource.identifier] = resource; + WebInspector.panels.network.appendResource(resource, skipRefresh); + WebInspector.panels.audits.resourceStarted(resource); + }, - var newResource = this._createResource(identifier, redirectURL, originalResource.loader, originalResource.stackTrace); - newResource.redirects = originalResource.redirects || []; - delete originalResource.redirects; - newResource.redirects.push(originalResource); - return newResource; + _finishResource: function(resource, finishTime) + { + resource.endTime = finishTime; + resource.finished = true; + WebInspector.panels.network.refreshResource(resource); + WebInspector.panels.audits.resourceFinished(resource); + WebInspector.extensionServer.notifyResourceFinished(resource); + delete this._inflightResources[resource.identifier]; } } diff --git a/Source/WebCore/inspector/front-end/NetworkPanel.js b/Source/WebCore/inspector/front-end/NetworkPanel.js index 7b6df8b..28cbd36 100644 --- a/Source/WebCore/inspector/front-end/NetworkPanel.js +++ b/Source/WebCore/inspector/front-end/NetworkPanel.js @@ -1,7 +1,7 @@ /* * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> - * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -38,7 +38,6 @@ WebInspector.NetworkPanel = function() this._resources = []; this._resourcesById = {}; this._resourcesByURL = {}; - this._lastIdentifier = 0; this._staleResources = []; this._resourceGridNodes = {}; this._mainResourceLoadTime = -1; @@ -733,12 +732,6 @@ WebInspector.NetworkPanel.prototype = { this._preserveLogToggle.toggled = !this._preserveLogToggle.toggled; }, - reset: function() - { - if (!this._preserveLogToggle.toggled) - this._reset(); - }, - _reset: function() { this._popoverHelper.hidePopup(); @@ -771,32 +764,34 @@ WebInspector.NetworkPanel.prototype = { get resources() { - return this._resourcesById; + return this._resources; }, - refreshResource: function(resource) + resourceById: function(id) { - if (!resource.identifier) - resource.identifier = "network:" + this._lastIdentifier++; + return this._resourcesById[id]; + }, - if (!this._resourcesById[resource.identifier]) { - this._resources.push(resource); - this._resourcesById[resource.identifier] = resource; - this._resourcesByURL[resource.url] = resource; + appendResource: function(resource) + { + this._resources.push(resource); + this._resourcesById[resource.identifier] = resource; + this._resourcesByURL[resource.url] = resource; - // Pull all the redirects of the main resource upon commit load. - if (resource.redirects) { - for (var i = 0; i < resource.redirects.length; ++i) - this.refreshResource(resource.redirects[i]); - } + // Pull all the redirects of the main resource upon commit load. + if (resource.redirects) { + for (var i = 0; i < resource.redirects.length; ++i) + this.refreshResource(resource.redirects[i]); } + this.refreshResource(resource); + }, + + refreshResource: function(resource) + { this._staleResources.push(resource); this._scheduleRefresh(); - if (!resource) - return; - var oldView = WebInspector.ResourceView.existingResourceViewForResource(resource); if (!oldView) return; @@ -809,6 +804,24 @@ WebInspector.NetworkPanel.prototype = { this.visibleView = newView; }, + clear: function() + { + if (this._preserveLogToggle.toggled) + return; + this._reset(); + }, + + mainResourceChanged: function() + { + if (this._preserveLogToggle.toggled) + return; + + this._reset(); + // Now resurrect the main resource along with all redirects that lead to it. + var resourcesToAppend = (WebInspector.mainResource.redirects || []).concat(WebInspector.mainResource); + resourcesToAppend.forEach(this.appendResource, this); + }, + canShowSourceLine: function(url, line) { return !!this._resourcesByURL[url]; @@ -978,7 +991,7 @@ WebInspector.NetworkPanel.prototype = { _contextMenu: function(event) { // createBlobURL is enabled conditionally, do not expose resource export if it's not available. - if (typeof window.createObjectURL !== "function" || !Preferences.resourceExportEnabled) + if (typeof window.webkitURL.createObjectURL !== "function" || !Preferences.resourceExportEnabled) return; var contextMenu = new WebInspector.ContextMenu(); @@ -1230,7 +1243,7 @@ WebInspector.NetworkTimeCalculator.prototype = { formatValue: function(value) { - return Number.secondsToString(value, WebInspector.UIString); + return Number.secondsToString(value); }, _lowerBound: function(resource) @@ -1254,7 +1267,7 @@ WebInspector.NetworkTransferTimeCalculator = function() WebInspector.NetworkTransferTimeCalculator.prototype = { formatValue: function(value) { - return Number.secondsToString(value, WebInspector.UIString); + return Number.secondsToString(value); }, _lowerBound: function(resource) @@ -1278,7 +1291,7 @@ WebInspector.NetworkTransferDurationCalculator = function() WebInspector.NetworkTransferDurationCalculator.prototype = { formatValue: function(value) { - return Number.secondsToString(value, WebInspector.UIString); + return Number.secondsToString(value); }, _upperBound: function(resource) @@ -1408,15 +1421,7 @@ WebInspector.NetworkDataGridNode.prototype = { if (this._resource.category === WebInspector.resourceCategories.images) { var previewImage = document.createElement("img"); previewImage.className = "image-network-icon-preview"; - - function onResourceContent() - { - previewImage.src = this._resource.contentURL; - } - if (Preferences.useDataURLForResourceImageIcons) - this._resource.requestContent(onResourceContent.bind(this)); - else - previewImage.src = this._resource.url; + this._resource.populateImageSource(previewImage); var iconElement = document.createElement("div"); iconElement.className = "icon"; diff --git a/Source/WebCore/inspector/front-end/ProfileDataGridTree.js b/Source/WebCore/inspector/front-end/ProfileDataGridTree.js index adf34f1..7988674 100644 --- a/Source/WebCore/inspector/front-end/ProfileDataGridTree.js +++ b/Source/WebCore/inspector/front-end/ProfileDataGridTree.js @@ -50,7 +50,7 @@ WebInspector.ProfileDataGridNode.prototype = { { function formatMilliseconds(time) { - return Number.secondsToString(time / 1000, WebInspector.UIString, !Preferences.samplingCPUProfiler); + return Number.secondsToString(time / 1000, !Preferences.samplingCPUProfiler); } var data = {}; diff --git a/Source/WebCore/inspector/front-end/ProfilesPanel.js b/Source/WebCore/inspector/front-end/ProfilesPanel.js index bff5be7..2e0ab28 100644 --- a/Source/WebCore/inspector/front-end/ProfilesPanel.js +++ b/Source/WebCore/inspector/front-end/ProfilesPanel.js @@ -124,7 +124,7 @@ WebInspector.ProfilesPanel = function() this._profiles = []; this._profilerEnabled = Preferences.profilerAlwaysEnabled; this._reset(); - InspectorBackend.registerDomainDispatcher("Profiler", this); + InspectorBackend.registerDomainDispatcher("Profiler", new WebInspector.ProfilerDispatcher(this)); } WebInspector.ProfilesPanel.prototype = { @@ -162,7 +162,7 @@ WebInspector.ProfilesPanel.prototype = { this._populateProfiles(); }, - profilerWasEnabled: function() + _profilerWasEnabled: function() { if (this._profilerEnabled) return; @@ -174,7 +174,7 @@ WebInspector.ProfilesPanel.prototype = { this._populateProfiles(); }, - profilerWasDisabled: function() + _profilerWasDisabled: function() { if (!this._profilerEnabled) return; @@ -183,11 +183,6 @@ WebInspector.ProfilesPanel.prototype = { this._reset(); }, - resetProfiles: function() - { - this._reset(); - }, - _reset: function() { for (var i = 0; i < this._profiles.length; ++i) @@ -262,7 +257,7 @@ WebInspector.ProfilesPanel.prototype = { return escape(text) + '/' + escape(profileTypeId); }, - addProfileHeader: function(profile) + _addProfileHeader: function(profile) { var typeId = profile.typeId; var profileType = this.getProfileType(typeId); @@ -327,7 +322,7 @@ WebInspector.ProfilesPanel.prototype = { } }, - removeProfileHeader: function(profile) + _removeProfileHeader: function(profile) { var typeId = profile.typeId; var profileType = this.getProfileType(typeId); @@ -432,7 +427,7 @@ WebInspector.ProfilesPanel.prototype = { } }, - addHeapSnapshotChunk: function(uid, chunk) + _addHeapSnapshotChunk: function(uid, chunk) { var profile = this._profilesIdMap[this._makeKey(uid, WebInspector.HeapSnapshotProfileType.TypeId)]; if (!profile || profile._loaded || !profile._is_loading) @@ -441,7 +436,7 @@ WebInspector.ProfilesPanel.prototype = { profile._json += chunk; }, - finishHeapSnapshot: function(uid) + _finishHeapSnapshot: function(uid) { var profile = this._profilesIdMap[this._makeKey(uid, WebInspector.HeapSnapshotProfileType.TypeId)]; if (!profile || profile._loaded || !profile._is_loading) @@ -600,7 +595,7 @@ WebInspector.ProfilesPanel.prototype = { var profileHeadersLength = profileHeaders.length; for (var i = 0; i < profileHeadersLength; ++i) if (!this.hasProfile(profileHeaders[i])) - WebInspector.panels.profiles.addProfileHeader(profileHeaders[i]); + this._addProfileHeader(profileHeaders[i]); } InspectorBackend.getProfileHeaders(populateCallback.bind(this)); @@ -616,22 +611,22 @@ WebInspector.ProfilesPanel.prototype = { this.resize(); }, - setRecordingProfile: function(isProfiling) + _setRecordingProfile: function(isProfiling) { this.getProfileType(WebInspector.CPUProfileType.TypeId).setRecordingProfile(isProfiling); if (this.hasTemporaryProfile(WebInspector.CPUProfileType.TypeId) !== isProfiling) { if (!this._temporaryRecordingProfile) { this._temporaryRecordingProfile = { typeId: WebInspector.CPUProfileType.TypeId, - title: WebInspector.UIString("Recording"), + title: WebInspector.UIString("Recording…"), uid: -1, isTemporary: true }; } if (isProfiling) - this.addProfileHeader(this._temporaryRecordingProfile); + this._addProfileHeader(this._temporaryRecordingProfile); else - this.removeProfileHeader(this._temporaryRecordingProfile); + this._removeProfileHeader(this._temporaryRecordingProfile); } this.updateProfileTypeButtons(); } @@ -639,6 +634,49 @@ WebInspector.ProfilesPanel.prototype = { WebInspector.ProfilesPanel.prototype.__proto__ = WebInspector.Panel.prototype; + +WebInspector.ProfilerDispatcher = function(profiler) +{ + this._profiler = profiler; +} + +WebInspector.ProfilerDispatcher.prototype = { + profilerWasEnabled: function() + { + this._profiler._profilerWasEnabled(); + }, + + profilerWasDisabled: function() + { + this._profiler._profilerWasDisabled(); + }, + + resetProfiles: function() + { + this._profiler._reset(); + }, + + addProfileHeader: function(profile) + { + this._profiler._addProfileHeader(profile); + }, + + addHeapSnapshotChunk: function(uid, chunk) + { + this._profiler._addHeapSnapshotChunk(uid, chunk); + }, + + finishHeapSnapshot: function(uid) + { + this._profiler._finishHeapSnapshot(uid); + }, + + setRecordingProfile: function(isProfiling) + { + this._profiler._setRecordingProfile(isProfiling); + } +} + WebInspector.ProfileSidebarTreeElement = function(profile, titleFormat, className) { this.profile = profile; @@ -660,7 +698,7 @@ WebInspector.ProfileSidebarTreeElement.prototype = { ondelete: function() { - this.treeOutline.panel.removeProfileHeader(this.profile); + this.treeOutline.panel._removeProfileHeader(this.profile); return true; }, @@ -720,4 +758,3 @@ WebInspector.ProfileGroupSidebarTreeElement.prototype = { } WebInspector.ProfileGroupSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; - diff --git a/Source/WebCore/inspector/front-end/Resource.js b/Source/WebCore/inspector/front-end/Resource.js index 063ca43..7340645 100644 --- a/Source/WebCore/inspector/front-end/Resource.js +++ b/Source/WebCore/inspector/front-end/Resource.js @@ -55,7 +55,27 @@ WebInspector.Resource.Type = { toUIString: function(type) { - return WebInspector.UIString(WebInspector.Resource.Type.toString(type)); + switch (type) { + case this.Document: + return WebInspector.UIString("Document"); + case this.Stylesheet: + return WebInspector.UIString("Stylesheet"); + case this.Image: + return WebInspector.UIString("Image"); + case this.Font: + return WebInspector.UIString("Font"); + case this.Script: + return WebInspector.UIString("Script"); + case this.XHR: + return WebInspector.UIString("XHR"); + case this.Media: + return WebInspector.UIString("Media"); + case this.WebSocket: + return WebInspector.UIString("WebSocket"); + case this.Other: + default: + return WebInspector.UIString("Other"); + } }, // Returns locale-independent string identifier of resource type (primarily for use in extension API). @@ -658,7 +678,20 @@ WebInspector.Resource.prototype = { this._innerRequestContent(); }, - get contentURL() + populateImageSource: function(image) + { + function onResourceContent() + { + image.src = this._contentURL(); + } + + if (Preferences.useDataURLForResourceImageIcons) + this.requestContent(onResourceContent.bind(this)); + else + image.src = this.url; + }, + + _contentURL: function() { const maxDataUrlSize = 1024 * 1024; // If resource content is not available or won't fit a data URL, fall back to using original URL. diff --git a/Source/WebCore/inspector/front-end/ResourceCookiesView.js b/Source/WebCore/inspector/front-end/ResourceCookiesView.js index e419070..b60b1b6 100644 --- a/Source/WebCore/inspector/front-end/ResourceCookiesView.js +++ b/Source/WebCore/inspector/front-end/ResourceCookiesView.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009, 2010 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -56,10 +56,12 @@ WebInspector.ResourceCookiesView.prototype = { if (this._emptyMsgElement) this._emptyMsgElement.parentElement.removeChild(this._emptyMsgElement); - this._cookiesTable = new WebInspector.CookiesTable(null, true, true); - this._cookiesTable.addCookiesFolder(WebInspector.UIString("Request Cookies"), this._resource.requestCookies); - this._cookiesTable.addCookiesFolder(WebInspector.UIString("Response Cookies"), this._resource.responseCookies); - this.element.appendChild(this._cookiesTable.element); + if (!this._cookiesTable) { + this._cookiesTable = new WebInspector.CookiesTable(null, true, true); + this._cookiesTable.addCookiesFolder(WebInspector.UIString("Request Cookies"), this._resource.requestCookies); + this._cookiesTable.addCookiesFolder(WebInspector.UIString("Response Cookies"), this._resource.responseCookies); + this.element.appendChild(this._cookiesTable.element); + } WebInspector.View.prototype.show.call(this, parentElement); this._cookiesTable.updateWidths(); diff --git a/Source/WebCore/inspector/front-end/ResourceTreeModel.js b/Source/WebCore/inspector/front-end/ResourceTreeModel.js index 7c7b86d..b114b94 100644 --- a/Source/WebCore/inspector/front-end/ResourceTreeModel.js +++ b/Source/WebCore/inspector/front-end/ResourceTreeModel.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -31,25 +31,18 @@ WebInspector.ResourceTreeModel = function() { - this._resourcesByURL = {}; - this._resourcesByFrameId = {}; - this._subframes = {}; - InspectorBackend.registerDomainDispatcher("Resources", this); - InspectorBackend.cachedResources(this._processCachedResources.bind(this)); -} - -WebInspector.ResourceTreeModel.createResource = function(identifier, url, loader, stackTrace) -{ - var resource = new WebInspector.Resource(identifier, url); - resource.loader = loader; - if (loader) - resource.documentURL = loader.url; - resource.stackTrace = stackTrace; - - return resource; + this.reloadCachedResources(); } WebInspector.ResourceTreeModel.prototype = { + reloadCachedResources: function() + { + this._resourcesByURL = {}; + this._resourcesByFrameId = {}; + this._subframes = {}; + InspectorBackend.cachedResources(this._processCachedResources.bind(this)); + }, + addOrUpdateFrame: function(frame) { var tmpResource = new WebInspector.Resource(null, frame.url); @@ -175,7 +168,7 @@ WebInspector.ResourceTreeModel.prototype = { preservedResourcesForFrame.push(resource); continue; } - this._unbindResourceURL(resource); + this.unbindResourceURL(resource); } delete this._resourcesByFrameId[frameId]; @@ -201,7 +194,7 @@ WebInspector.ResourceTreeModel.prototype = { return false; }, - _unbindResourceURL: function(resource) + unbindResourceURL: function(resource) { var resourceForURL = this._resourcesByURL[resource.url]; if (!resourceForURL) @@ -226,13 +219,12 @@ WebInspector.ResourceTreeModel.prototype = { _addFramesRecursively: function(framePayload) { - var frameResource = WebInspector.ResourceTreeModel.createResource(null, framePayload.resource.url, framePayload.resource.loader); + var frameResource = this.createResource(null, framePayload.resource.url, framePayload.resource.loader); WebInspector.NetworkManager.updateResourceWithRequest(frameResource, framePayload.resource.request); WebInspector.NetworkManager.updateResourceWithResponse(frameResource, framePayload.resource.response); frameResource.type = WebInspector.Resource.Type["Document"]; frameResource.finished = true; - this.bindResourceURL(frameResource); this.addOrUpdateFrame(framePayload); this.addResourceToFrame(framePayload.id, frameResource); @@ -244,12 +236,24 @@ WebInspector.ResourceTreeModel.prototype = { for (var i = 0; i < framePayload.subresources.length; ++i) { var cachedResource = framePayload.subresources[i]; - var resource = WebInspector.ResourceTreeModel.createResource(null, cachedResource.url, cachedResource.loader); + var resource = this.createResource(null, cachedResource.url, cachedResource.loader); WebInspector.NetworkManager.updateResourceWithCachedResource(resource, cachedResource); resource.finished = true; - this.bindResourceURL(resource); this.addResourceToFrame(framePayload.id, resource); } return frameResource; + }, + + createResource: function(identifier, url, loader, stackTrace) + { + var resource = new WebInspector.Resource(identifier, url); + resource.loader = loader; + if (loader) { + resource.documentURL = loader.url; + this.bindResourceURL(resource); + } + resource.stackTrace = stackTrace; + + return resource; } } diff --git a/Source/WebCore/inspector/front-end/ResourcesPanel.js b/Source/WebCore/inspector/front-end/ResourcesPanel.js index ecb826f..d96989b 100644 --- a/Source/WebCore/inspector/front-end/ResourcesPanel.js +++ b/Source/WebCore/inspector/front-end/ResourcesPanel.js @@ -165,6 +165,12 @@ WebInspector.ResourcesPanel.prototype = { this.sidebarTree.selectedTreeElement.deselect(); }, + clear: function() + { + this.resourcesListTreeElement.removeChildren(); + this.reset(); + }, + addOrUpdateFrame: function(parentFrameId, frameId, title, subtitle) { var frameTreeElement = this._treeElementForFrameId[frameId]; @@ -1005,7 +1011,7 @@ WebInspector.FrameResourceTreeElement.prototype = { if (this._resource.category === WebInspector.resourceCategories.images) { var previewImage = document.createElement("img"); previewImage.className = "image-resource-icon-preview"; - previewImage.src = this._resource.url; + this._resource.populateImageSource(previewImage); var iconElement = document.createElement("div"); iconElement.className = "icon"; @@ -1227,7 +1233,7 @@ WebInspector.ApplicationCacheTreeElement.prototype.__proto__ = WebInspector.Base WebInspector.ResourceRevisionTreeElement = function(storagePanel, revision) { - var title = revision.timestamp ? revision.timestamp.toLocaleTimeString() : "(original)"; + var title = revision.timestamp ? revision.timestamp.toLocaleTimeString() : WebInspector.UIString("(original)"); WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, title, "resource-sidebar-tree-item resources-category-" + revision.category.name); if (revision.timestamp) this.tooltip = revision.timestamp.toLocaleString(); diff --git a/Source/WebCore/inspector/front-end/Script.js b/Source/WebCore/inspector/front-end/Script.js index 184fe97..89b2121 100644 --- a/Source/WebCore/inspector/front-end/Script.js +++ b/Source/WebCore/inspector/front-end/Script.js @@ -23,12 +23,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -WebInspector.Script = function(sourceID, sourceURL, source, startingLine, errorLine, errorMessage, worldType) +WebInspector.Script = function(sourceID, sourceURL, source, lineOffset, columnOffset, errorLine, errorMessage, worldType) { this.sourceID = sourceID; this.sourceURL = sourceURL; this._source = source; - this.startingLine = startingLine; + this.lineOffset = lineOffset; + this.columnOffset = columnOffset; this.errorLine = errorLine; this.errorMessage = errorMessage; this.worldType = worldType; @@ -57,24 +58,40 @@ WebInspector.Script.WorldType = { EXTENSIONS_WORLD: 1 } -WebInspector.Script.Events = { - SourceChanged: "source-changed" -} - WebInspector.Script.prototype = { + get startingLine() + { + return this.lineOffset + 1; + }, + get linesCount() { if (!this.source) return 0; - if (this._linesCount) - return this._linesCount; - this._linesCount = 0; - var lastIndex = this.source.indexOf("\n"); - while (lastIndex !== -1) { - lastIndex = this.source.indexOf("\n", lastIndex + 1) - this._linesCount++; + if (!this._lineEndings) + this._lineEndings = this._source.findAll("\n"); + return this._lineEndings.length + 1; + }, + + sourceLine: function(lineNumber, callback) + { + function extractSourceLine() + { + lineNumber -= this.startingLine; + callback(this._source.substring(this._lineEndings[lineNumber - 1], this._lineEndings[lineNumber])); + } + + if (this._lineEndings) { + extractSourceLine.call(this); + return; } - return this._linesCount; + + function didRequestSource() + { + this._lineEndings = this._source.findAll("\n"); + extractSourceLine.call(this); + } + this.requestSource(didRequestSource.bind(this)); }, get source() @@ -85,8 +102,20 @@ WebInspector.Script.prototype = { set source(source) { this._source = source; - this.dispatchEventToListeners(WebInspector.Script.Events.SourceChanged); + }, + + requestSource: function(callback) + { + if (this._source) { + callback(this._source); + return; + } + + function didGetScriptSource(source) + { + this._source = source; + callback(this._source); + } + InspectorBackend.getScriptSource(this.sourceID, didGetScriptSource.bind(this)); } } - -WebInspector.Script.prototype.__proto__ = WebInspector.Object.prototype; diff --git a/Source/WebCore/inspector/front-end/ScriptView.js b/Source/WebCore/inspector/front-end/ScriptView.js index 39dae55..d6c1c59 100644 --- a/Source/WebCore/inspector/front-end/ScriptView.js +++ b/Source/WebCore/inspector/front-end/ScriptView.js @@ -29,70 +29,15 @@ WebInspector.ScriptView = function(script) this.element.addStyleClass("script-view"); - this.script = script; - this.script.addEventListener(WebInspector.Script.Events.SourceChanged, this._scriptSourceChanged, this); - - this._frameNeedsSetup = true; - this._sourceFrameSetup = false; - this.sourceFrame = new WebInspector.SourceFrame(this.element, [script], WebInspector.panels.scripts.canEditScripts()); + var contentProvider = new WebInspector.SourceFrameContentProviderForScript(script); + this.sourceFrame = new WebInspector.SourceFrame(this.element, contentProvider, "", WebInspector.panels.scripts.canEditScripts()); } WebInspector.ScriptView.prototype = { - show: function(parentElement) - { - WebInspector.View.prototype.show.call(this, parentElement); - this.setupSourceFrameIfNeeded(); - this.sourceFrame.visible = true; - this.resize(); - }, - - setupSourceFrameIfNeeded: function() - { - if (!this._frameNeedsSetup) - return; - delete this._frameNeedsSetup; - - this.attach(); - - if (this.script.source) - this._sourceFrameSetupFinished(); - else - InspectorBackend.getScriptSource(this.script.sourceID, this._didGetScriptSource.bind(this)); - }, - - _didGetScriptSource: function(source) - { - this.script.source = source || WebInspector.UIString("<source is not available>"); - this._sourceFrameSetupFinished(); - }, - - _sourceFrameSetupFinished: function() - { - this.sourceFrame.setContent("text/javascript", this._prependWhitespace(this.script.source)); - this._sourceFrameSetup = true; - }, - - _prependWhitespace: function(content) { - var prefix = ""; - for (var i = 0; i < this.script.startingLine - 1; ++i) - prefix += "\n"; - return prefix + content; - }, - - attach: function() - { - if (!this.element.parentNode) - document.getElementById("script-resource-views").appendChild(this.element); - }, - - _scriptSourceChanged: function(event) - { - this.sourceFrame.updateContent(this._prependWhitespace(this.script.source)); - }, - // The following methods are pulled from SourceView, since they are // generic and work with ScriptView just fine. + show: WebInspector.SourceView.prototype.show, hide: WebInspector.SourceView.prototype.hide, revealLine: WebInspector.SourceView.prototype.revealLine, highlightLine: WebInspector.SourceView.prototype.highlightLine, @@ -111,3 +56,41 @@ WebInspector.ScriptView.prototype = { } WebInspector.ScriptView.prototype.__proto__ = WebInspector.View.prototype; + + +WebInspector.SourceFrameContentProviderForScript = function(script) +{ + WebInspector.SourceFrameContentProvider.call(this); + this._script = script; +} + +WebInspector.SourceFrameContentProviderForScript.prototype = { + requestContent: function(callback) + { + if (this._script.source) { + callback("text/javascript", this._script.source); + return; + } + + function didRequestSource(content) + { + var source; + if (content) { + var prefix = ""; + for (var i = 0; i < this._script.startingLine - 1; ++i) + prefix += "\n"; + source = prefix + content; + } else + source = WebInspector.UIString("<source is not available>"); + callback("text/javascript", source); + } + this._script.requestSource(didRequestSource.bind(this)); + }, + + scripts: function() + { + return [this._script]; + } +} + +WebInspector.SourceFrameContentProviderForScript.prototype.__proto__ = WebInspector.SourceFrameContentProvider.prototype; diff --git a/Source/WebCore/inspector/front-end/ScriptsPanel.js b/Source/WebCore/inspector/front-end/ScriptsPanel.js index 138bbda..32212d4 100644 --- a/Source/WebCore/inspector/front-end/ScriptsPanel.js +++ b/Source/WebCore/inspector/front-end/ScriptsPanel.js @@ -218,11 +218,6 @@ WebInspector.ScriptsPanel.prototype = { if (this.visibleView) this.visibleView.show(this.viewsContainerElement); - - if (this._attachDebuggerWhenShown) { - InspectorBackend.enableDebuggerFromFrontend(false); - delete this._attachDebuggerWhenShown; - } }, hide: function() @@ -256,9 +251,6 @@ WebInspector.ScriptsPanel.prototype = { if (resource.finished) { // Resource is finished, bind the script right away. script.resource = resource; - var view = WebInspector.ResourceView.existingResourceViewForResource(resource); - if (view && view.sourceFrame) - view.sourceFrame.addScript(script); } else { // Resource is not finished, bind the script later. if (!resource._scriptsPendingResourceLoad) { @@ -292,7 +284,7 @@ WebInspector.ScriptsPanel.prototype = { return Preferences.canEditScriptSource; }, - editScriptSource: function(editData, commitEditingCallback, cancelEditingCallback) + editScriptSource: function(editData, revertEditingCallback, cancelEditingCallback) { if (!this.canEditScripts()) return; @@ -305,7 +297,16 @@ WebInspector.ScriptsPanel.prototype = { function mycallback(success, newBodyOrErrorMessage, callFrames) { if (success) { - commitEditingCallback(newBodyOrErrorMessage); + var script = WebInspector.debuggerModel.scriptForSourceID(editData.sourceID); + script.source = newBodyOrErrorMessage; + var oldView = script._scriptView + if (oldView) { + script._scriptView = new WebInspector.ScriptView(script); + this.viewRecreated(oldView, script._scriptView); + } + if (script.resource) + script.resource.setContent(newBodyOrErrorMessage, revertEditingCallback); + if (callFrames && callFrames.length) this._debuggerPaused({ data: { callFrames: callFrames } }); } else { @@ -389,15 +390,6 @@ WebInspector.ScriptsPanel.prototype = { this._clearInterface(); }, - attachDebuggerWhenShown: function() - { - if (this.element.parentElement) { - InspectorBackend.enableDebuggerFromFrontend(false); - } else { - this._attachDebuggerWhenShown = true; - } - }, - debuggerWasEnabled: function() { if (this._debuggerEnabled) @@ -460,8 +452,8 @@ WebInspector.ScriptsPanel.prototype = { viewRecreated: function(oldView, newView) { - if (this._visibleView === oldView) - this._visibleView = newView; + if (this.visibleView === oldView) + this.visibleView = newView; }, canShowSourceLine: function(url, line) @@ -527,7 +519,6 @@ WebInspector.ScriptsPanel.prototype = { if (!this.element.parentNode) this.attach(); - view.setupSourceFrameIfNeeded(); return view.sourceFrame; }, @@ -545,10 +536,6 @@ WebInspector.ScriptsPanel.prototype = { if (!view) return null; - if (!view.setupSourceFrameIfNeeded) - return null; - - view.setupSourceFrameIfNeeded(); return view.sourceFrame; }, @@ -862,7 +849,7 @@ WebInspector.ScriptsPanel.prototype = { if (this._debuggerEnabled) InspectorBackend.disableDebugger(true); else - InspectorBackend.enableDebuggerFromFrontend(!!optionalAlways); + InspectorBackend.enableDebugger(!!optionalAlways); }, _togglePauseOnExceptions: function() @@ -892,7 +879,7 @@ WebInspector.ScriptsPanel.prototype = { this._clearInterface(); - InspectorBackend.stepOverStatement(); + InspectorBackend.stepOver(); }, _stepIntoClicked: function() @@ -902,7 +889,7 @@ WebInspector.ScriptsPanel.prototype = { this._clearInterface(); - InspectorBackend.stepIntoStatement(); + InspectorBackend.stepInto(); }, _stepOutClicked: function() @@ -912,7 +899,7 @@ WebInspector.ScriptsPanel.prototype = { this._clearInterface(); - InspectorBackend.stepOutOfFunction(); + InspectorBackend.stepOut(); }, toggleBreakpointsClicked: function() diff --git a/Source/WebCore/inspector/front-end/SourceFrame.js b/Source/WebCore/inspector/front-end/SourceFrame.js index fa8441d..af10f1e 100644 --- a/Source/WebCore/inspector/front-end/SourceFrame.js +++ b/Source/WebCore/inspector/front-end/SourceFrame.js @@ -28,12 +28,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -WebInspector.SourceFrame = function(parentElement, scripts, canEditScripts) +WebInspector.SourceFrame = function(parentElement, contentProvider, url, canEditScripts) { this._parentElement = parentElement; - this._scripts = {}; - for (var i = 0; i < scripts.length; ++i) - this._scripts[scripts[i].sourceID] = scripts[i]; + this._contentProvider = contentProvider; + this._url = url; this._canEditScripts = canEditScripts; this._textModel = new WebInspector.TextEditorModel(); @@ -43,7 +42,6 @@ WebInspector.SourceFrame = function(parentElement, scripts, canEditScripts) this._rowMessages = {}; this._messageBubbles = {}; - this._loaded = false; this._popoverObjectGroup = "popover"; } @@ -51,14 +49,18 @@ WebInspector.SourceFrame.prototype = { set visible(visible) { - this._visible = visible; - this._createViewerIfNeeded(); + if (!this._contentRequested) { + this._contentRequested = true; + this._contentProvider.requestContent(this._createTextViewer.bind(this)); + } if (visible) { if (this._textViewer && this._scrollTop) this._textViewer.element.scrollTop = this._scrollTop; if (this._textViewer && this._scrollLeft) this._textViewer.element.scrollLeft = this._scrollLeft; + if (this._textViewer) + this._textViewer.resize(); } else { this._hidePopup(); if (this._textViewer) { @@ -114,11 +116,6 @@ WebInspector.SourceFrame.prototype = { this._addMessageToSource(msg); }, - addScript: function(script) - { - this._scripts[script.sourceID] = script; - }, - clearMessages: function() { for (var line in this._messageBubbles) { @@ -139,20 +136,6 @@ WebInspector.SourceFrame.prototype = { this._textViewer.revalidateDecorationsAndPaint(); }, - setContent: function(mimeType, content, url) - { - this._loaded = true; - this._textModel.setText(null, content); - this._mimeType = mimeType; - this._url = url; - this._createViewerIfNeeded(); - }, - - updateContent: function(content) - { - this._textModel.setText(null, content); - }, - get textModel() { return this._textModel; @@ -185,10 +168,10 @@ WebInspector.SourceFrame.prototype = { delete this._lineToHighlight; }, - _createViewerIfNeeded: function() + _createTextViewer: function(mimeType, content) { - if (!this._visible || !this._loaded || this._textViewer) - return; + this._content = content; + this._textModel.setText(null, content); this._textViewer = new WebInspector.TextViewer(this._textModel, WebInspector.platform, this._url); var element = this._textViewer.element; @@ -200,7 +183,7 @@ WebInspector.SourceFrame.prototype = { this._textViewer.beginUpdates(); - this._textViewer.mimeType = this._mimeType; + this._textViewer.mimeType = mimeType; this._addExistingMessagesToSource(); this._updateExecutionLine(); this._updateDiffDecorations(); @@ -222,6 +205,11 @@ WebInspector.SourceFrame.prototype = { delete this._lineToHighlight; } + if (this._delayedFindSearchMatches) { + this._delayedFindSearchMatches(); + delete this._delayedFindSearchMatches; + } + var breakpoints = this._breakpoints(); for (var i = 0; i < breakpoints.length; ++i) this._addBreakpoint(breakpoints[i]); @@ -233,22 +221,35 @@ WebInspector.SourceFrame.prototype = { this._textViewer.editCallback = this._editLine.bind(this); }, - findSearchMatches: function(query) + findSearchMatches: function(query, finishedCallback) { - var ranges = []; + function doFindSearchMatches() + { + var ranges = []; + + // First do case-insensitive search. + var regexObject = createSearchRegex(query); + this._collectRegexMatches(regexObject, ranges); + + // Then try regex search if user knows the / / hint. + try { + if (/^\/.*\/$/.test(query)) + this._collectRegexMatches(new RegExp(query.substring(1, query.length - 1)), ranges); + } catch (e) { + // Silent catch. + } + finishedCallback(ranges); + } - // First do case-insensitive search. - var regexObject = createSearchRegex(query); - this._collectRegexMatches(regexObject, ranges); + if (this._textViewer) + doFindSearchMatches.call(this); + else + this._delayedFindSearchMatches = doFindSearchMatches.bind(this); + }, - // Then try regex search if user knows the / / hint. - try { - if (/^\/.*\/$/.test(query)) - this._collectRegexMatches(new RegExp(query.substring(1, query.length - 1)), ranges); - } catch (e) { - // Silent catch. - } - return ranges; + cancelFindSearchMatches: function() + { + delete this._delayedFindSearchMatches; }, _collectRegexMatches: function(regexObject, ranges) @@ -405,7 +406,7 @@ WebInspector.SourceFrame.prototype = { { var breakpoint = event.data; - if (breakpoint.sourceID in this._scripts) + if (breakpoint.sourceID in this._sourceIDSet()) this._addBreakpoint(breakpoint); }, @@ -418,7 +419,6 @@ WebInspector.SourceFrame.prototype = { breakpoint.addEventListener("condition-changed", this._breakpointChanged, this); breakpoint.addEventListener("removed", this._breakpointRemoved, this); - breakpoint.sourceText = this._textModel.line(breakpoint.line - 1); this._setBreakpointDecoration(breakpoint.line, breakpoint.enabled, !!breakpoint.condition); }, @@ -789,11 +789,12 @@ WebInspector.SourceFrame.prototype = { lineNumber += 1; var lines = []; - for (var i = 0; i < this._textModel.linesCount; ++i) { + var oldLines = this._content.split('\n'); + for (var i = 0; i < oldLines.length; ++i) { if (i === lineNumber - 1) lines.push(newContent); else - lines.push(this._textModel.line(i)); + lines.push(oldLines[i]); } var editData = {}; @@ -817,16 +818,7 @@ WebInspector.SourceFrame.prototype = { _doEditLine: function(editData, cancelEditingCallback) { var revertEditingCallback = this._revertEditLine.bind(this, editData); - var commitEditingCallback = this._commitEditLine.bind(this, editData, revertEditingCallback); - WebInspector.panels.scripts.editScriptSource(editData, commitEditingCallback, cancelEditingCallback); - }, - - _commitEditLine: function(editData, revertEditLineCallback, newContent) - { - var script = this._scripts[editData.sourceID]; - script.source = newContent; - if (script.resource) - script.resource.setContent(newContent, revertEditLineCallback); + WebInspector.panels.scripts.editScriptSource(editData, revertEditingCallback, cancelEditingCallback); }, _setBreakpoint: function(lineNumber, enabled, condition) @@ -841,8 +833,8 @@ WebInspector.SourceFrame.prototype = { _breakpoints: function() { - var scripts = this._scripts; - return WebInspector.debuggerModel.queryBreakpoints(function(b) { return b.sourceID in scripts; }); + var sourceIDSet = this._sourceIDSet(); + return WebInspector.debuggerModel.queryBreakpoints(function(b) { return b.sourceID in sourceIDSet; }); }, _findBreakpoint: function(lineNumber) @@ -855,15 +847,42 @@ WebInspector.SourceFrame.prototype = { { var sourceIDForLine = null; var closestStartingLine = 0; - for (var sourceID in this._scripts) { - var script = this._scripts[sourceID]; - if (script.startingLine <= lineNumber && script.startingLine >= closestStartingLine) { - closestStartingLine = script.startingLine; - sourceIDForLine = sourceID; + var scripts = this._contentProvider.scripts(); + for (var i = 0; i < scripts.length; ++i) { + var startingLine = scripts[i].startingLine; + if (startingLine <= lineNumber && startingLine >= closestStartingLine) { + closestStartingLine = startingLine; + sourceIDForLine = scripts[i].sourceID; } } return sourceIDForLine; + }, + + _sourceIDSet: function() + { + var scripts = this._contentProvider.scripts(); + var sourceIDSet = {}; + for (var i = 0; i < scripts.length; ++i) + sourceIDSet[scripts[i].sourceID] = true; + return sourceIDSet; } } WebInspector.SourceFrame.prototype.__proto__ = WebInspector.Object.prototype; + + +WebInspector.SourceFrameContentProvider = function() +{ +} + +WebInspector.SourceFrameContentProvider.prototype = { + requestContent: function(callback) + { + // Should be implemented by subclasses. + }, + + scripts: function() + { + // Should be implemented by subclasses. + } +} diff --git a/Source/WebCore/inspector/front-end/SourceView.js b/Source/WebCore/inspector/front-end/SourceView.js index 7a97db2..e78ff94 100644 --- a/Source/WebCore/inspector/front-end/SourceView.js +++ b/Source/WebCore/inspector/front-end/SourceView.js @@ -32,43 +32,29 @@ WebInspector.SourceView = function(resource) this.element.addStyleClass("source"); - var scripts = WebInspector.debuggerModel.scriptsForURL(resource.url); + var contentProvider = new WebInspector.SourceFrameContentProviderForResource(resource); var canEditScripts = WebInspector.panels.scripts.canEditScripts() && resource.type === WebInspector.Resource.Type.Script; - this.sourceFrame = new WebInspector.SourceFrame(this.element, scripts, canEditScripts); - resource.addEventListener("finished", this._resourceLoadingFinished, this); - this._frameNeedsSetup = true; -} - -// This is a map from resource.type to mime types -// found in WebInspector.SourceTokenizer.Registry. -WebInspector.SourceView.DefaultMIMETypeForResourceType = { - 0: "text/html", - 1: "text/css", - 4: "text/javascript" + this.sourceFrame = new WebInspector.SourceFrame(this.element, contentProvider, resource.url, canEditScripts); } WebInspector.SourceView.prototype = { show: function(parentElement) { - WebInspector.ResourceView.prototype.show.call(this, parentElement); - this.setupSourceFrameIfNeeded(); + WebInspector.View.prototype.show.call(this, parentElement); this.sourceFrame.visible = true; - this.resize(); }, hide: function() { this.sourceFrame.visible = false; - if (!this._frameNeedsSetup) - this.sourceFrame.clearLineHighlight(); + this.sourceFrame.clearLineHighlight(); WebInspector.View.prototype.hide.call(this); this._currentSearchResultIndex = -1; }, resize: function() { - if (this.sourceFrame) - this.sourceFrame.resize(); + this.sourceFrame.resize(); }, get scrollTop() @@ -81,42 +67,11 @@ WebInspector.SourceView.prototype = { this.sourceFrame.scrollTop = scrollTop; }, - - setupSourceFrameIfNeeded: function() - { - if (!this._frameNeedsSetup) - return; - - delete this._frameNeedsSetup; - this.resource.requestContent(this._contentLoaded.bind(this)); - }, - hasContent: function() { return true; }, - _contentLoaded: function(content) - { - var mimeType = this._canonicalMimeType(this.resource); - this.sourceFrame.setContent(mimeType, content, this.resource.url); - this._sourceFrameSetupFinished(); - }, - - _canonicalMimeType: function(resource) - { - return WebInspector.SourceView.DefaultMIMETypeForResourceType[resource.type] || resource.mimeType; - }, - - _resourceLoadingFinished: function(event) - { - this._frameNeedsSetup = true; - this._sourceFrameSetup = false; - if (this.visible) - this.setupSourceFrameIfNeeded(); - this.resource.removeEventListener("finished", this._resourceLoadingFinished, this); - }, - // The rest of the methods in this prototype need to be generic enough to work with a ScriptView. // The ScriptView prototype pulls these methods into it's prototype to avoid duplicate code. @@ -125,7 +80,7 @@ WebInspector.SourceView.prototype = { this._currentSearchResultIndex = -1; this._searchResults = []; this.sourceFrame.clearMarkedRange(); - delete this._delayedFindSearchMatches; + this.sourceFrame.cancelFindSearchMatches(); }, performSearch: function(query, finishedCallback) @@ -133,23 +88,13 @@ WebInspector.SourceView.prototype = { // Call searchCanceled since it will reset everything we need before doing a new search. this.searchCanceled(); - this._searchFinishedCallback = finishedCallback; - - function findSearchMatches(query, finishedCallback) + function didFindSearchMatches(searchResults) { - this._searchResults = this.sourceFrame.findSearchMatches(query); + this._searchResults = searchResults; if (this._searchResults) finishedCallback(this, this._searchResults.length); } - - if (!this._sourceFrameSetup) { - // The search is performed in _sourceFrameSetupFinished by calling _delayedFindSearchMatches. - this._delayedFindSearchMatches = findSearchMatches.bind(this, query, finishedCallback); - this.setupSourceFrameIfNeeded(); - return; - } - - findSearchMatches.call(this, query, finishedCallback); + this.sourceFrame.findSearchMatches(query, didFindSearchMatches.bind(this)); }, jumpToFirstSearchResult: function() @@ -198,13 +143,11 @@ WebInspector.SourceView.prototype = { revealLine: function(lineNumber) { - this.setupSourceFrameIfNeeded(); this.sourceFrame.revealLine(lineNumber); }, highlightLine: function(lineNumber) { - this.setupSourceFrameIfNeeded(); this.sourceFrame.highlightLine(lineNumber); }, @@ -225,17 +168,41 @@ WebInspector.SourceView.prototype = { return; this.sourceFrame.markAndRevealRange(foundRange); - }, + } +} + +WebInspector.SourceView.prototype.__proto__ = WebInspector.ResourceView.prototype; - _sourceFrameSetupFinished: function() + +WebInspector.SourceFrameContentProviderForResource = function(resource) +{ + WebInspector.SourceFrameContentProvider.call(this); + this._resource = resource; +} + +//This is a map from resource.type to mime types +//found in WebInspector.SourceTokenizer.Registry. +WebInspector.SourceFrameContentProviderForResource.DefaultMIMETypeForResourceType = { + 0: "text/html", + 1: "text/css", + 4: "text/javascript" +} + +WebInspector.SourceFrameContentProviderForResource.prototype = { + requestContent: function(callback) { - this._sourceFrameSetup = true; - this.resize(); - if (this._delayedFindSearchMatches) { - this._delayedFindSearchMatches(); - delete this._delayedFindSearchMatches; + function contentLoaded(content) + { + var mimeType = WebInspector.SourceFrameContentProviderForResource.DefaultMIMETypeForResourceType[this._resource.type] || this._resource.mimeType; + callback(mimeType, content); } + this._resource.requestContent(contentLoaded.bind(this)); + }, + + scripts: function() + { + return WebInspector.debuggerModel.scriptsForURL(this._resource.url); } } -WebInspector.SourceView.prototype.__proto__ = WebInspector.ResourceView.prototype; +WebInspector.SourceFrameContentProviderForResource.prototype.__proto__ = WebInspector.SourceFrameContentProvider.prototype; diff --git a/Source/WebCore/inspector/front-end/TimelineOverviewPane.js b/Source/WebCore/inspector/front-end/TimelineOverviewPane.js index 55e24c5..0dac916 100644 --- a/Source/WebCore/inspector/front-end/TimelineOverviewPane.js +++ b/Source/WebCore/inspector/front-end/TimelineOverviewPane.js @@ -398,7 +398,7 @@ WebInspector.TimelineOverviewCalculator.prototype = { formatValue: function(value) { - return Number.secondsToString(value, WebInspector.UIString); + return Number.secondsToString(value); } } diff --git a/Source/WebCore/inspector/front-end/TimelinePanel.js b/Source/WebCore/inspector/front-end/TimelinePanel.js index a661b75..1d8b9c9 100644 --- a/Source/WebCore/inspector/front-end/TimelinePanel.js +++ b/Source/WebCore/inspector/front-end/TimelinePanel.js @@ -83,7 +83,7 @@ WebInspector.TimelinePanel = function() this._calculator = new WebInspector.TimelineCalculator(); this._calculator._showShortEvents = false; - var shortRecordThresholdTitle = Number.secondsToString(WebInspector.TimelinePanel.shortRecordThreshold, WebInspector.UIString); + var shortRecordThresholdTitle = Number.secondsToString(WebInspector.TimelinePanel.shortRecordThreshold); this._showShortRecordsTitleText = WebInspector.UIString("Show the records that are shorter than %s", shortRecordThresholdTitle); this._hideShortRecordsTitleText = WebInspector.UIString("Hide the records that are shorter than %s", shortRecordThresholdTitle); this._createStatusbarButtons(); @@ -99,7 +99,7 @@ WebInspector.TimelinePanel = function() this._markTimelineRecords = []; this._expandOffset = 15; - InspectorBackend.registerDomainDispatcher("Timeline", this); + InspectorBackend.registerDomainDispatcher("Timeline", new WebInspector.TimelineDispatcher(this)); } // Define row height, should be in sync with styles for timeline graphs. @@ -285,20 +285,21 @@ WebInspector.TimelinePanel.prototype = { this._scheduleRefresh(true); }, - timelineProfilerWasStarted: function() + _timelineProfilerWasStarted: function() { this.toggleTimelineButton.toggled = true; }, - timelineProfilerWasStopped: function() + _timelineProfilerWasStopped: function() { this.toggleTimelineButton.toggled = false; }, - addRecordToTimeline: function(record) + _addRecordToTimeline: function(record) { - if (record.type == WebInspector.TimelineAgent.RecordType.ResourceSendRequest && record.data.isMainResource) { - if (this._mainResourceIdentifier != record.data.identifier) { + if (record.type == WebInspector.TimelineAgent.RecordType.ResourceSendRequest) { + var isMainResource = (record.data.identifier === WebInspector.mainResource.identifier); + if (isMainResource && this._mainResourceIdentifier !== record.data.identifier) { // We are loading new main resource -> clear the panel. Check above is necessary since // there may be several resource loads with main resource marker upon redirects, redirects are reported with // the original identifier. @@ -642,6 +643,28 @@ WebInspector.TimelinePanel.prototype = { WebInspector.TimelinePanel.prototype.__proto__ = WebInspector.Panel.prototype; +WebInspector.TimelineDispatcher = function(timelinePanel) +{ + this._timelinePanel = timelinePanel; +} + +WebInspector.TimelineDispatcher.prototype = { + timelineProfilerWasStarted: function() + { + this._timelinePanel._timelineProfilerWasStarted(); + }, + + timelineProfilerWasStopped: function() + { + this._timelinePanel._timelineProfilerWasStopped(); + }, + + addRecordToTimeline: function(record) + { + this._timelinePanel._addRecordToTimeline(record); + } +} + WebInspector.TimelineCategory = function(name, title, color) { this.name = name; @@ -709,7 +732,7 @@ WebInspector.TimelineCalculator.prototype = { formatValue: function(value) { - return Number.secondsToString(value + this.minimumBoundary - this._absoluteMinimumBoundary, WebInspector.UIString); + return Number.secondsToString(value + this.minimumBoundary - this._absoluteMinimumBoundary); } } @@ -907,7 +930,7 @@ WebInspector.TimelinePanel.FormattedRecord.prototype = { label.className = "timeline-aggregated-category timeline-" + index; cell.appendChild(label); var text = document.createElement("span"); - text.textContent = Number.secondsToString(this._aggregatedStats[index] + 0.0001, WebInspector.UIString); + text.textContent = Number.secondsToString(this._aggregatedStats[index] + 0.0001); cell.appendChild(text); } return cell; @@ -918,10 +941,10 @@ WebInspector.TimelinePanel.FormattedRecord.prototype = { var contentHelper = new WebInspector.TimelinePanel.PopupContentHelper(this.title); if (this._children && this._children.length) { - contentHelper._appendTextRow(WebInspector.UIString("Self Time"), Number.secondsToString(this._selfTime + 0.0001, WebInspector.UIString)); + contentHelper._appendTextRow(WebInspector.UIString("Self Time"), Number.secondsToString(this._selfTime + 0.0001)); contentHelper._appendElementRow(WebInspector.UIString("Aggregated Time"), this._generateAggregatedInfo()); } - var text = WebInspector.UIString("%s (at %s)", Number.secondsToString(this._lastChildEndTime - this.startTime, WebInspector.UIString), + var text = WebInspector.UIString("%s (at %s)", Number.secondsToString(this._lastChildEndTime - this.startTime), calculator.formatValue(this.startTime - calculator.minimumBoundary)); contentHelper._appendTextRow(WebInspector.UIString("Duration"), text); @@ -929,14 +952,14 @@ WebInspector.TimelinePanel.FormattedRecord.prototype = { switch (this.type) { case recordTypes.GCEvent: - contentHelper._appendTextRow(WebInspector.UIString("Collected"), Number.bytesToString(this.data.usedHeapSizeDelta, WebInspector.UIString)); + contentHelper._appendTextRow(WebInspector.UIString("Collected"), Number.bytesToString(this.data.usedHeapSizeDelta)); break; case recordTypes.TimerInstall: case recordTypes.TimerFire: case recordTypes.TimerRemove: contentHelper._appendTextRow(WebInspector.UIString("Timer ID"), this.data.timerId); if (typeof this.timeout === "number") { - contentHelper._appendTextRow(WebInspector.UIString("Timeout"), Number.secondsToString(this.timeout / 1000, WebInspector.UIString)); + contentHelper._appendTextRow(WebInspector.UIString("Timeout"), Number.secondsToString(this.timeout / 1000)); contentHelper._appendTextRow(WebInspector.UIString("Repeats"), !this.singleShot); } break; @@ -977,7 +1000,7 @@ WebInspector.TimelinePanel.FormattedRecord.prototype = { contentHelper._appendLinkRow(WebInspector.UIString("Function Call"), this.data.scriptName, this.data.scriptLine); if (this.usedHeapSize) - contentHelper._appendTextRow(WebInspector.UIString("Used Heap Size"), WebInspector.UIString("%s of %s", Number.bytesToString(this.usedHeapSize, WebInspector.UIString), Number.bytesToString(this.totalHeapSize, WebInspector.UIString))); + contentHelper._appendTextRow(WebInspector.UIString("Used Heap Size"), WebInspector.UIString("%s of %s", Number.bytesToString(this.usedHeapSize), Number.bytesToString(this.totalHeapSize))); if (this.callSiteStackTrace && this.callSiteStackTrace.length) contentHelper._appendStackTrace(WebInspector.UIString("Call Site stack"), this.callSiteStackTrace); @@ -992,7 +1015,7 @@ WebInspector.TimelinePanel.FormattedRecord.prototype = { { switch (record.type) { case WebInspector.TimelineAgent.RecordType.GCEvent: - return WebInspector.UIString("%s collected", Number.bytesToString(record.data.usedHeapSizeDelta, WebInspector.UIString)); + return WebInspector.UIString("%s collected", Number.bytesToString(record.data.usedHeapSizeDelta)); case WebInspector.TimelineAgent.RecordType.TimerFire: return record.data.scriptName ? WebInspector.linkifyResourceAsNode(record.data.scriptName, "scripts", record.data.scriptLine, "", "") : record.data.timerId; case WebInspector.TimelineAgent.RecordType.FunctionCall: diff --git a/Source/WebCore/inspector/front-end/WebKit.qrc b/Source/WebCore/inspector/front-end/WebKit.qrc index c1008ad..80a6533 100644 --- a/Source/WebCore/inspector/front-end/WebKit.qrc +++ b/Source/WebCore/inspector/front-end/WebKit.qrc @@ -51,7 +51,6 @@ <file>HelpScreen.js</file> <file>ImageView.js</file> <file>InjectedFakeWorker.js</file> - <file>InjectedScript.js</file> <file>InjectedScriptAccess.js</file> <file>inspector.js</file> <file>InspectorFrontendHostStub.js</file> diff --git a/Source/WebCore/inspector/front-end/inspector.html b/Source/WebCore/inspector/front-end/inspector.html index e1590f2..44f096f 100644 --- a/Source/WebCore/inspector/front-end/inspector.html +++ b/Source/WebCore/inspector/front-end/inspector.html @@ -142,7 +142,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <script type="text/javascript" src="HeapSnapshotView.js"></script> <script type="text/javascript" src="DebuggerModel.js"></script> <script type="text/javascript" src="DOMAgent.js"></script> - <script type="text/javascript" src="InjectedScript.js"></script> <script type="text/javascript" src="InjectedScriptAccess.js"></script> <script type="text/javascript" src="TimelineAgent.js"></script> <script type="text/javascript" src="TimelinePanel.js"></script> diff --git a/Source/WebCore/inspector/front-end/inspector.js b/Source/WebCore/inspector/front-end/inspector.js index 33a75d7..d8a93b1 100644 --- a/Source/WebCore/inspector/front-end/inspector.js +++ b/Source/WebCore/inspector/front-end/inspector.js @@ -443,6 +443,11 @@ var WebInspector = { return this.panels.network.resources; }, + networkResourceById: function(id) + { + return this.panels.network.resourceById(id); + }, + forAllResources: function(callback) { WebInspector.resourceTreeModel.forAllResources(callback); @@ -492,7 +497,7 @@ WebInspector.loaded = function() WebInspector.doLoadedDone = function() { - InspectorBackend.setInjectedScriptSource("(" + injectedScriptConstructor + ");"); + InspectorFrontendHost.loaded(); var platform = WebInspector.platform; document.body.addStyleClass("platform-" + platform); @@ -502,7 +507,6 @@ WebInspector.doLoadedDone = function() var port = WebInspector.port; document.body.addStyleClass("port-" + port); - InspectorFrontendHost.loaded(); WebInspector.settings = new WebInspector.Settings(); this._registerShortcuts(); @@ -618,7 +622,6 @@ WebInspector.doLoadedDone = function() { WebInspector.cssNameCompletions = new WebInspector.CSSCompletions(names); } - // As a DOMAgent method, this needs to happen after the frontend has loaded and the agent is available. InspectorBackend.getSupportedCSSProperties(propertyNamesCallback); } @@ -1175,11 +1178,6 @@ WebInspector.showPanel = function(panel) this.currentPanel = this.panels[panel]; } -WebInspector.consoleMessagesCleared = function() -{ - WebInspector.console.clearMessages(); -} - WebInspector.domContentEventFired = function(time) { this.panels.audits.mainResourceDOMContentTime = time; @@ -1237,33 +1235,6 @@ WebInspector.inspectedURLChanged = function(url) this.extensionServer.notifyInspectedURLChanged(); } -WebInspector.updateConsoleMessageExpiredCount = function(count) -{ - var message = String.sprintf(WebInspector.UIString("%d console messages are not shown."), count); - WebInspector.console.addMessage(WebInspector.ConsoleMessage.createTextMessage(message, WebInspector.ConsoleMessage.MessageLevel.Warning)); -} - -WebInspector.addConsoleMessage = function(payload) -{ - var consoleMessage = new WebInspector.ConsoleMessage( - payload.source, - payload.type, - payload.level, - payload.line, - payload.url, - payload.repeatCount, - payload.message, - payload.parameters, - payload.stackTrace, - payload.requestId); - this.console.addMessage(consoleMessage); -} - -WebInspector.updateConsoleMessageRepeatCount = function(count) -{ - this.console.updateMessageRepeatCount(count); -} - WebInspector.log = function(message, messageLevel) { // remember 'this' for setInterval() callback @@ -1681,6 +1652,12 @@ WebInspector.doPerformSearch = function(query, forceSearch, isBackwardSearch, re this.currentPanel.performSearch(query); } +WebInspector.frontendReused = function() +{ + this.networkManager.reset(); + this.reset(); +} + WebInspector.addNodesToSearchResult = function(nodeIds) { WebInspector.panels.elements.addNodesToSearchResult(nodeIds); diff --git a/Source/WebCore/inspector/front-end/utilities.js b/Source/WebCore/inspector/front-end/utilities.js index 688e080..4320ba8 100644 --- a/Source/WebCore/inspector/front-end/utilities.js +++ b/Source/WebCore/inspector/front-end/utilities.js @@ -388,6 +388,17 @@ String.prototype.hasSubstring = function(string, caseInsensitive) return this.match(new RegExp(string.escapeForRegExp(), "i")); } +String.prototype.findAll = function(string) +{ + var matches = []; + var i = this.indexOf(string); + while (i !== -1) { + matches.push(i); + i = this.indexOf(string, i + string.length); + } + return matches; +} + String.prototype.asParsedURL = function() { // RegExp groups: @@ -643,61 +654,56 @@ function parentNode(node) return node.parentNode; } -Number.millisToString = function(ms, formatterFunction, higherResolution) +Number.millisToString = function(ms, higherResolution) { - return Number.secondsToString(ms / 1000, formatterFunction, higherResolution); + return Number.secondsToString(ms / 1000, higherResolution); } -Number.secondsToString = function(seconds, formatterFunction, higherResolution) +Number.secondsToString = function(seconds, higherResolution) { - if (!formatterFunction) - formatterFunction = String.sprintf; - if (seconds === 0) return "0"; var ms = seconds * 1000; if (higherResolution && ms < 1000) - return formatterFunction("%.3fms", ms); + return WebInspector.UIString("%.3fms", ms); else if (ms < 1000) - return formatterFunction("%.0fms", ms); + return WebInspector.UIString("%.0fms", ms); if (seconds < 60) - return formatterFunction("%.2fs", seconds); + return WebInspector.UIString("%.2fs", seconds); var minutes = seconds / 60; if (minutes < 60) - return formatterFunction("%.1fmin", minutes); + return WebInspector.UIString("%.1fmin", minutes); var hours = minutes / 60; if (hours < 24) - return formatterFunction("%.1fhrs", hours); + return WebInspector.UIString("%.1fhrs", hours); var days = hours / 24; - return formatterFunction("%.1f days", days); + return WebInspector.UIString("%.1f days", days); } -Number.bytesToString = function(bytes, formatterFunction, higherResolution) +Number.bytesToString = function(bytes, higherResolution) { - if (!formatterFunction) - formatterFunction = String.sprintf; if (typeof higherResolution === "undefined") higherResolution = true; if (bytes < 1024) - return formatterFunction("%.0fB", bytes); + return WebInspector.UIString("%.0fB", bytes); var kilobytes = bytes / 1024; if (higherResolution && kilobytes < 1024) - return formatterFunction("%.2fKB", kilobytes); + return WebInspector.UIString("%.2fKB", kilobytes); else if (kilobytes < 1024) - return formatterFunction("%.0fKB", kilobytes); + return WebInspector.UIString("%.0fKB", kilobytes); var megabytes = kilobytes / 1024; if (higherResolution) - return formatterFunction("%.2fMB", megabytes); + return WebInspector.UIString("%.2fMB", megabytes); else - return formatterFunction("%.0fMB", megabytes); + return WebInspector.UIString("%.0fMB", megabytes); } Number.constrain = function(num, min, max) @@ -715,7 +721,7 @@ HTMLTextAreaElement.prototype.moveCursorToEnd = function() this.setSelectionRange(length, length); } -Array.prototype.remove = function(value, onlyFirst) +Object.defineProperty(Array.prototype, "remove", { value: function(value, onlyFirst) { if (onlyFirst) { var index = this.indexOf(value); @@ -729,15 +735,15 @@ Array.prototype.remove = function(value, onlyFirst) if (this[i] === value) this.splice(i, 1); } -} +}}); -Array.prototype.keySet = function() +Object.defineProperty(Array.prototype, "keySet", { value: function() { var keys = {}; for (var i = 0; i < this.length; ++i) keys[this[i]] = true; return keys; -} +}}); Array.diff = function(left, right) { @@ -1050,6 +1056,6 @@ function offerFileForDownload(contents) var builder = new BlobBuilder(); builder.append(contents); var blob = builder.getBlob("application/octet-stream"); - var url = window.createObjectURL(blob); + var url = window.webkitURL.createObjectURL(blob); window.open(url); } |