summaryrefslogtreecommitdiffstats
path: root/WebCore/inspector/front-end/inspector.js
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/inspector/front-end/inspector.js')
-rw-r--r--WebCore/inspector/front-end/inspector.js141
1 files changed, 85 insertions, 56 deletions
diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js
index f090d3a..c24d589 100644
--- a/WebCore/inspector/front-end/inspector.js
+++ b/WebCore/inspector/front-end/inspector.js
@@ -139,10 +139,15 @@ var WebInspector = {
this.panels.resources = new WebInspector.ResourcesPanel();
if (hiddenPanels.indexOf("scripts") === -1)
this.panels.scripts = new WebInspector.ScriptsPanel();
- if (hiddenPanels.indexOf("profiles") === -1)
+ if (hiddenPanels.indexOf("profiles") === -1) {
this.panels.profiles = new WebInspector.ProfilesPanel();
+ this.panels.profiles.registerProfileType(new WebInspector.CPUProfileType());
+ }
+ if (hiddenPanels.indexOf("timeline") === -1 && hiddenPanels.indexOf("timeline") === -1)
+ this.panels.timeline = new WebInspector.TimelinePanel();
+
if (hiddenPanels.indexOf("storage") === -1 && hiddenPanels.indexOf("databases") === -1)
- this.panels.storage = new WebInspector.StoragePanel();
+ this.panels.storage = new WebInspector.StoragePanel();
},
_loadPreferences: function()
@@ -367,6 +372,7 @@ WebInspector.loaded = function()
document.body.addStyleClass("platform-" + platform);
this._loadPreferences();
+ this.pendingDispatches = 0;
this.drawer = new WebInspector.Drawer();
this.console = new WebInspector.ConsoleView(this.drawer);
@@ -377,13 +383,13 @@ WebInspector.loaded = function()
this.domAgent = new WebInspector.DOMAgent();
this.resourceCategories = {
- documents: new WebInspector.ResourceCategory(WebInspector.UIString("Documents"), "documents"),
- stylesheets: new WebInspector.ResourceCategory(WebInspector.UIString("Stylesheets"), "stylesheets"),
- images: new WebInspector.ResourceCategory(WebInspector.UIString("Images"), "images"),
- scripts: new WebInspector.ResourceCategory(WebInspector.UIString("Scripts"), "scripts"),
- xhr: new WebInspector.ResourceCategory(WebInspector.UIString("XHR"), "xhr"),
- fonts: new WebInspector.ResourceCategory(WebInspector.UIString("Fonts"), "fonts"),
- other: new WebInspector.ResourceCategory(WebInspector.UIString("Other"), "other")
+ documents: new WebInspector.ResourceCategory("documents", WebInspector.UIString("Documents"), "rgb(47,102,236)"),
+ stylesheets: new WebInspector.ResourceCategory("stylesheets", WebInspector.UIString("Stylesheets"), "rgb(157,231,119)"),
+ images: new WebInspector.ResourceCategory("images", WebInspector.UIString("Images"), "rgb(164,60,255)"),
+ scripts: new WebInspector.ResourceCategory("scripts", WebInspector.UIString("Scripts"), "rgb(255,121,0)"),
+ xhr: new WebInspector.ResourceCategory("xhr", WebInspector.UIString("XHR"), "rgb(231,231,10)"),
+ fonts: new WebInspector.ResourceCategory("fonts", WebInspector.UIString("Fonts"), "rgb(255,82,62)"),
+ other: new WebInspector.ResourceCategory("other", WebInspector.UIString("Other"), "rgb(186,186,186)")
};
this.panels = {};
@@ -454,8 +460,6 @@ WebInspector.loaded = function()
// this._updateErrorAndWarningCounts();
var searchField = document.getElementById("search");
- searchField.addEventListener("keydown", this.searchKeyDown.bind(this), false);
- searchField.addEventListener("keyup", this.searchKeyUp.bind(this), false);
searchField.addEventListener("search", this.performSearch.bind(this), false); // when the search is emptied
toolbarElement.addEventListener("mousedown", this.toolbarDragStart, true);
@@ -486,7 +490,16 @@ window.addEventListener("load", windowLoaded, false);
WebInspector.dispatch = function() {
var methodName = arguments[0];
var parameters = Array.prototype.slice.call(arguments, 1);
- WebInspector[methodName].apply(this, parameters);
+
+ // We'd like to enforce asynchronous interaction between the inspector controller and the frontend.
+ // This is important to LayoutTests.
+ function delayDispatch()
+ {
+ WebInspector[methodName].apply(WebInspector, parameters);
+ WebInspector.pendingDispatches--;
+ }
+ WebInspector.pendingDispatches++;
+ setTimeout(delayDispatch, 0);
}
WebInspector.windowUnload = function(event)
@@ -502,13 +515,19 @@ WebInspector.windowResize = function(event)
WebInspector.windowFocused = function(event)
{
- if (event.target.nodeType === Node.DOCUMENT_NODE)
+ // Fires after blur, so when focusing on either the main inspector
+ // or an <iframe> within the inspector we should always remove the
+ // "inactive" class.
+ if (event.target.document.nodeType === Node.DOCUMENT_NODE)
document.body.removeStyleClass("inactive");
}
-WebInspector.windowBlured = function(event)
+WebInspector.windowBlurred = function(event)
{
- if (event.target.nodeType === Node.DOCUMENT_NODE)
+ // Leaving the main inspector or an <iframe> within the inspector.
+ // We can add "inactive" now, and if we are moving the focus to another
+ // part of the inspector then windowFocused will correct this.
+ if (event.target.document.nodeType === Node.DOCUMENT_NODE)
document.body.addStyleClass("inactive");
}
@@ -547,10 +566,9 @@ WebInspector.documentClick = function(event)
WebInspector.showResourceForURL(anchor.href, anchor.lineNumber, anchor.preferredPanel);
} else {
- var profileStringRegEx = new RegExp("webkit-profile://.+/([0-9]+)");
- var profileString = profileStringRegEx.exec(anchor.href);
+ var profileString = WebInspector.ProfileType.URLRegExp.exec(anchor.href);
if (profileString)
- WebInspector.showProfileById(profileString[1])
+ WebInspector.showProfileForURL(anchor.href);
}
}
@@ -618,7 +636,9 @@ WebInspector.documentKeyDown = function(event)
break;
- case "U+005B": // [ key
+ // Windows and Mac have two different definitions of [, so accept both.
+ case "U+005B":
+ case "U+00DB": // [ key
if (isMac)
var isRotateLeft = event.metaKey && !event.shiftKey && !event.ctrlKey && !event.altKey;
else
@@ -633,7 +653,9 @@ WebInspector.documentKeyDown = function(event)
break;
- case "U+005D": // ] key
+ // Windows and Mac have two different definitions of ], so accept both.
+ case "U+005D":
+ case "U+00DD": // ] key
if (isMac)
var isRotateRight = event.metaKey && !event.shiftKey && !event.ctrlKey && !event.altKey;
else
@@ -1043,7 +1065,8 @@ WebInspector.addDatabase = function(payload)
WebInspector.addCookieDomain = function(domain)
{
- this.panels.storage.addCookieDomain(domain);
+ if (this.panels.storage)
+ this.panels.storage.addCookieDomain(domain);
}
WebInspector.addDOMStorage = function(payload)
@@ -1156,7 +1179,7 @@ WebInspector.didCommitLoad = function()
WebInspector.setDocument(null);
}
-WebInspector.addMessageToConsole = function(payload)
+WebInspector.addConsoleMessage = function(payload)
{
var consoleMessage = new WebInspector.ConsoleMessage(
payload.source,
@@ -1170,6 +1193,11 @@ WebInspector.addMessageToConsole = function(payload)
this.console.addMessage(consoleMessage);
}
+WebInspector.updateConsoleMessageRepeatCount = function(count)
+{
+ this.console.updateMessageRepeatCount(count);
+}
+
WebInspector.log = function(message)
{
// remember 'this' for setInterval() callback
@@ -1254,14 +1282,15 @@ WebInspector.log = function(message)
logMessage(message);
}
-WebInspector.addProfile = function(profile)
+WebInspector.addProfileHeader = function(profile)
{
- this.panels.profiles.addProfile(profile);
+ this.panels.profiles.addProfileHeader(WebInspector.CPUProfileType.TypeId, new WebInspector.CPUProfile(profile));
}
WebInspector.setRecordingProfile = function(isProfiling)
{
- this.panels.profiles.setRecordingProfile(isProfiling);
+ this.panels.profiles.getProfileType(WebInspector.CPUProfileType.TypeId).setRecordingProfile(isProfiling);
+ this.panels.profiles.updateProfileTypeButtons();
}
WebInspector.drawLoadingPieChart = function(canvas, percent) {
@@ -1367,13 +1396,9 @@ WebInspector.linkifyStringAsFragment = function(string)
var nonLink = string.substring(0, linkIndex);
container.appendChild(document.createTextNode(nonLink));
- var profileStringRegEx = new RegExp("webkit-profile://(.+)/[0-9]+");
- var profileStringMatches = profileStringRegEx.exec(title);
- var profileTitle;
+ var profileStringMatches = WebInspector.ProfileType.URLRegExp.exec(title);
if (profileStringMatches)
- profileTitle = profileStringMatches[1];
- if (profileTitle)
- title = WebInspector.panels.profiles.displayTitleForProfileLink(profileTitle);
+ title = WebInspector.panels.profiles.displayTitleForProfileLink(profileStringMatches[2], profileStringMatches[1]);
var realURL = (linkString.indexOf("www.") === 0 ? "http://" + linkString : linkString);
container.appendChild(WebInspector.linkifyURLAsNode(realURL, title, null, (realURL in WebInspector.resourceURLMap)));
@@ -1386,9 +1411,9 @@ WebInspector.linkifyStringAsFragment = function(string)
return container;
}
-WebInspector.showProfileById = function(uid) {
+WebInspector.showProfileForURL = function(url) {
WebInspector.showProfilesPanel();
- WebInspector.panels.profiles.showProfileById(uid);
+ WebInspector.panels.profiles.showProfileForURL(url);
}
WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal)
@@ -1417,26 +1442,15 @@ WebInspector.linkifyURL = function(url, linkText, classes, isExternal)
WebInspector.addMainEventListeners = function(doc)
{
- doc.defaultView.addEventListener("focus", this.windowFocused.bind(this), true);
- doc.defaultView.addEventListener("blur", this.windowBlured.bind(this), true);
+ doc.defaultView.addEventListener("focus", this.windowFocused.bind(this), false);
+ doc.defaultView.addEventListener("blur", this.windowBlurred.bind(this), false);
doc.addEventListener("click", this.documentClick.bind(this), true);
}
WebInspector.searchKeyDown = function(event)
{
- if (event.keyIdentifier !== "Enter")
- return;
-
- // Call preventDefault since this was the Enter key. This prevents a "search" event
- // from firing for key down. We handle the Enter key on key up in searchKeyUp. This
- // stops performSearch from being called twice in a row.
- event.preventDefault();
-}
-
-WebInspector.searchKeyUp = function(event)
-{
- if (event.keyIdentifier !== "Enter")
- return;
+ if (!isEnterKey(event))
+ return false;
// Select all of the text so the user can easily type an entirely new query.
event.target.select();
@@ -1445,14 +1459,33 @@ WebInspector.searchKeyUp = function(event)
// performance is poor because of searching on every key. The search field has
// the incremental attribute set, so we still get incremental searches.
this.performSearch(event);
+
+ // Call preventDefault since this was the Enter key. This prevents a "search" event
+ // from firing for key down. This stops performSearch from being called twice in a row.
+ event.preventDefault();
}
WebInspector.performSearch = function(event)
{
var query = event.target.value;
var forceSearch = event.keyIdentifier === "Enter";
+ var isShortSearch = (query.length < 3);
+
+ // Clear a leftover short search flag due to a non-conflicting forced search.
+ if (isShortSearch && this.shortSearchWasForcedByKeyEvent && this.currentQuery !== query)
+ delete this.shortSearchWasForcedByKeyEvent;
+
+ // Indicate this was a forced search on a short query.
+ if (isShortSearch && forceSearch)
+ this.shortSearchWasForcedByKeyEvent = true;
+
+ if (!query || !query.length || (!forceSearch && isShortSearch)) {
+ // Prevent clobbering a short search forced by the user.
+ if (this.shortSearchWasForcedByKeyEvent) {
+ delete this.shortSearchWasForcedByKeyEvent;
+ return;
+ }
- if (!query || !query.length || (!forceSearch && query.length < 3)) {
delete this.currentQuery;
for (var panelName in this.panels) {
@@ -1525,7 +1558,8 @@ WebInspector.UIString = function(string)
string = window.localizedStrings[string];
else {
if (!(string in this.missingLocalizedStrings)) {
- console.error("Localized string \"" + string + "\" not found.");
+ if (!WebInspector.InspectorControllerStub)
+ console.error("Localized string \"" + string + "\" not found.");
this.missingLocalizedStrings[string] = true;
}
@@ -1608,7 +1642,7 @@ WebInspector.startEditing = function(element, committedCallback, cancelledCallba
if (event.handled)
return;
- if (event.keyIdentifier === "Enter") {
+ if (isEnterKey(event)) {
editingCommitted.call(element);
event.preventDefault();
} else if (event.keyCode === 27) { // Escape key
@@ -1630,11 +1664,6 @@ WebInspector._toolbarItemClicked = function(event)
this.currentPanel = toolbarItem.panel;
}
-WebInspector.evaluateForTestInFrontend = function(callId, script)
-{
- InspectorController.didEvaluateForTestInFrontend(callId, JSON.stringify(window.eval(script)));
-}
-
// This table maps MIME types to the Resource.Types which are valid for them.
// The following line:
// "text/html": {0: 1},