Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated webkit front-end

- strip function wrapper from node sources
  • Loading branch information...
commit 23812b3855cc31061bd26549fd0aa5a960647cfa 1 parent 635ff93
Danny Coates dannycoates authored
Showing with 5,825 additions and 4,959 deletions.
  1. +1 −1  front-end/ApplicationCacheItemsView.js
  2. +1 −0  front-end/AuditLauncherView.js
  3. +2 −1  front-end/AuditResultView.js
  4. +46 −36 front-end/AuditRules.js
  5. +8 −13 front-end/AuditsPanel.js
  6. +131 −61 front-end/BreakpointManager.js
  7. +183 −135 front-end/BreakpointsSidebarPane.js
  8. +470 −31 front-end/CSSStyleModel.js
  9. +6 −5 front-end/CallStackSidebarPane.js
  10. +7 −20 front-end/ConsoleView.js
  11. +65 −168 front-end/CookieItemsView.js
  12. +210 −0 front-end/CookieParser.js
  13. +205 −0 front-end/CookiesTable.js
  14. +5 −151 front-end/DOMAgent.js
  15. +32 −9 front-end/DataGrid.js
  16. +2 −2 front-end/DatabaseQueryView.js
  17. +2 −2 front-end/DatabaseTableView.js
  18. +1 −111 front-end/ElementsPanel.js
  19. +56 −44 front-end/ElementsTreeOutline.js
  20. +8 −18 front-end/EventListenersSidebarPane.js
  21. +149 −104 front-end/ExtensionAPI.js
  22. +4 −4 front-end/ExtensionCommon.js
  23. +36 −0 front-end/ExtensionPanel.js
  24. +72 −89 front-end/ExtensionServer.js
  25. +190 −0 front-end/FileSystemView.js
  26. +6 −4 front-end/FontView.js
  27. +35 −11 front-end/HAREntry.js
  28. +58 −20 front-end/ImageView.js
  29. BIN  front-end/Images/auditsIcon.png
  30. BIN  front-end/Images/frame.png
  31. BIN  front-end/Images/grayConnectorPoint.png
  32. BIN  front-end/Images/networkIcon.png
  33. BIN  front-end/Images/resourcesSilhouette.png
  34. BIN  front-end/Images/storageIcon.png
  35. BIN  front-end/Images/whiteConnectorPoint.png
  36. +1 −2  front-end/InjectedScript.js
  37. +39 −17 front-end/MetricsSidebarPane.js
  38. +90 −0 front-end/NetworkItemView.js
  39. +162 −265 front-end/NetworkPanel.js
  40. +22 −1 front-end/ObjectPropertiesSection.js
  41. +3 −3 front-end/Panel.js
  42. +9 −3 front-end/Popover.js
  43. +19 −4 front-end/ProfilesPanel.js
  44. +2 −1  front-end/PropertiesSection.js
  45. +1 −1  front-end/PropertiesSidebarPane.js
  46. +64 −0 front-end/RemoteObject.js
  47. +153 −142 front-end/Resource.js
  48. +0 −29 front-end/ResourceCategory.js
  49. +69 −0 front-end/ResourceCookiesView.js
  50. +276 −0 front-end/ResourceHeadersView.js
  51. +621 −0 front-end/ResourceManager.js
  52. +157 −0 front-end/ResourceTimingView.js
  53. +4 −314 front-end/ResourceView.js
  54. +891 −1,553 front-end/ResourcesPanel.js
  55. +44 −35 front-end/ScriptsPanel.js
  56. +54 −66 front-end/Settings.js
  57. +49 −0 front-end/SourceFrame.js
  58. +19 −38 front-end/SourceView.js
  59. +0 −618 front-end/StoragePanel.js
  60. +279 −224 front-end/StylesSidebarPane.js
  61. +37 −32 front-end/TabbedPane.js
  62. +0 −28 front-end/TextPrompt.js
  63. +5 −5 front-end/WatchExpressionsSidebarPane.js
  64. +10 −6 front-end/WebKit.qrc
  65. +2 −2 front-end/WorkersSidebarPane.js
  66. +10 −3 front-end/index.html
  67. +217 −212 front-end/inspector.css
  68. +9 −2 front-end/inspector.html
  69. +115 −217 front-end/inspector.js
  70. +295 −73 front-end/networkPanel.css
  71. +2 −0  front-end/node/InspectorBackendStub.js
  72. +1 −1  front-end/node/InspectorFrontendHostStub.js
  73. +15 −4 front-end/textViewer.css
  74. +16 −2 front-end/treeoutline.js
  75. +69 −14 front-end/utilities.js
  76. +3 −2 lib/session.js
2  front-end/ApplicationCacheItemsView.js
View
@@ -64,7 +64,7 @@ WebInspector.ApplicationCacheItemsView = function(treeElement, appcacheDomain)
this._appcacheDomain = appcacheDomain;
this._emptyMsgElement = document.createElement("div");
- this._emptyMsgElement.className = "storage-table-empty";
+ this._emptyMsgElement.className = "storage-empty-view";
this._emptyMsgElement.textContent = WebInspector.UIString("No Application Cache information available.");
this.element.appendChild(this._emptyMsgElement);
1  front-end/AuditLauncherView.js
View
@@ -269,6 +269,7 @@ WebInspector.AuditLauncherView.prototype = {
this._selectAllClicked(this._selectAllCheckboxElement.checked);
this.updateResourceTrackingState();
this._updateButton();
+ this._updateResourceProgress();
},
_updateResourceProgress: function()
3  front-end/AuditResultView.js
View
@@ -89,7 +89,8 @@ WebInspector.AuditCategoryResultPane.prototype = {
title = String.sprintf("%s (%d)", title, result.violationCount);
}
- var treeElement = new TreeElement(title, null, !!result.children);
+ var treeElement = new TreeElement(null, null, !!result.children);
+ treeElement.titleHTML = title;
parentTreeElement.appendChild(treeElement);
if (result.className)
82 front-end/AuditRules.js
View
@@ -42,17 +42,17 @@ WebInspector.AuditRules.CacheableResponseCodes =
304: true // Underlying resource is cacheable
}
-WebInspector.AuditRules.getDomainToResourcesMap = function(resources, types, regexp, needFullResources)
+WebInspector.AuditRules.getDomainToResourcesMap = function(resources, types, needFullResources)
{
var domainToResourcesMap = {};
for (var i = 0, size = resources.length; i < size; ++i) {
var resource = resources[i];
if (types && types.indexOf(resource.type) === -1)
continue;
- var match = resource.url.match(regexp);
- if (!match)
+ var parsedURL = resource.url.asParsedURL();
+ if (!parsedURL)
continue;
- var domain = match[2];
+ var domain = parsedURL.host;
var domainResources = domainToResourcesMap[domain];
if (domainResources === undefined) {
domainResources = [];
@@ -128,7 +128,7 @@ WebInspector.AuditRules.CombineExternalResourcesRule = function(id, name, type,
WebInspector.AuditRules.CombineExternalResourcesRule.prototype = {
doRun: function(resources, result, callback)
{
- var domainToResourcesMap = WebInspector.AuditRules.getDomainToResourcesMap(resources, [this._type], WebInspector.URLRegExp);
+ var domainToResourcesMap = WebInspector.AuditRules.getDomainToResourcesMap(resources, [this._type]);
var penalizedResourceCount = 0;
// TODO: refactor according to the chosen i18n approach
var summary = result.addChild("", true);
@@ -175,14 +175,14 @@ WebInspector.AuditRules.MinimizeDnsLookupsRule.prototype = {
doRun: function(resources, result, callback)
{
var summary = result.addChild("");
- var domainToResourcesMap = WebInspector.AuditRules.getDomainToResourcesMap(resources, undefined, WebInspector.URLRegExp);
+ var domainToResourcesMap = WebInspector.AuditRules.getDomainToResourcesMap(resources, undefined);
for (var domain in domainToResourcesMap) {
if (domainToResourcesMap[domain].length > 1)
continue;
- var match = domain.match(WebInspector.URLRegExp);
- if (!match)
+ var parsedURL = domain.asParsedURL();
+ if (!parsedURL)
continue;
- if (!match[2].search(WebInspector.AuditRules.IPAddressRegexp))
+ if (!parsedURL.host.search(WebInspector.AuditRules.IPAddressRegexp))
continue; // an IP address
summary.addSnippet(match[2]);
result.violationCount++;
@@ -220,7 +220,6 @@ WebInspector.AuditRules.ParallelizeDownloadRule.prototype = {
var domainToResourcesMap = WebInspector.AuditRules.getDomainToResourcesMap(
resources,
[WebInspector.Resource.Type.Stylesheet, WebInspector.Resource.Type.Image],
- WebInspector.URLRegExp,
true);
var hosts = [];
@@ -278,6 +277,7 @@ WebInspector.AuditRules.UnusedCssRule.prototype = {
doRun: function(resources, result, callback)
{
var self = this;
+
function evalCallback(styleSheets) {
if (!styleSheets.length)
return callback(null);
@@ -287,12 +287,12 @@ WebInspector.AuditRules.UnusedCssRule.prototype = {
var testedSelectors = {};
for (var i = 0; i < styleSheets.length; ++i) {
var styleSheet = styleSheets[i];
- for (var curRule = 0; curRule < styleSheet.cssRules.length; ++curRule) {
- var rule = styleSheet.cssRules[curRule];
- if (rule.selectorText.match(pseudoSelectorRegexp))
+ for (var curRule = 0; curRule < styleSheet.rules.length; ++curRule) {
+ var selectorText = styleSheet.rules[curRule].selectorText;
+ if (selectorText.match(pseudoSelectorRegexp) || testedSelectors[selectorText])
continue;
- selectors.push(rule.selectorText);
- testedSelectors[rule.selectorText] = 1;
+ selectors.push(selectorText);
+ testedSelectors[selectorText] = 1;
}
}
@@ -308,9 +308,12 @@ WebInspector.AuditRules.UnusedCssRule.prototype = {
var stylesheetSize = 0;
var unusedStylesheetSize = 0;
var unusedRules = [];
- for (var curRule = 0; curRule < styleSheet.cssRules.length; ++curRule) {
- var rule = styleSheet.cssRules[curRule];
- var textLength = rule.cssText ? rule.cssText.length : 0;
+ for (var curRule = 0; curRule < styleSheet.rules.length; ++curRule) {
+ var rule = styleSheet.rules[curRule];
+ // Exact computation whenever source ranges are available.
+ var textLength = (rule.selectorRange && rule.style.properties.endOffset) ? rule.style.properties.endOffset - rule.selectorRange.start + 1 : 0;
+ if (!textLength && rule.style.cssText)
+ textLength = rule.style.cssText.length + rule.selectorText.length;
stylesheetSize += textLength;
if (!testedSelectors[rule.selectorText] || foundSelectors[rule.selectorText])
continue;
@@ -323,11 +326,13 @@ WebInspector.AuditRules.UnusedCssRule.prototype = {
if (!unusedRules.length)
continue;
- var url = styleSheet.href ? WebInspector.AuditRuleResult.linkifyDisplayName(styleSheet.href) : String.sprintf("Inline block #%d", ++inlineBlockOrdinal);
+ var resource = WebInspector.resourceManager.resourceForURL(styleSheet.sourceURL);
+ var isInlineBlock = resource && resource.type == WebInspector.Resource.Type.Document;
+ var url = !isInlineBlock ? WebInspector.AuditRuleResult.linkifyDisplayName(styleSheet.sourceURL) : String.sprintf("Inline block #%d", ++inlineBlockOrdinal);
var pctUnused = Math.round(100 * unusedStylesheetSize / stylesheetSize);
if (!summary)
summary = result.addChild("", true);
- var entry = summary.addChild(String.sprintf("%s: %d%% (estimated) is not used by the current page.", url, pctUnused));
+ var entry = summary.addChild(String.sprintf("%s: %s (%d%%) is not used by the current page.", url, Number.bytesToString(unusedStylesheetSize), pctUnused));
for (var j = 0; j < unusedRules.length; ++j)
entry.addSnippet(unusedRules[j]);
@@ -339,7 +344,7 @@ WebInspector.AuditRules.UnusedCssRule.prototype = {
return callback(null);
var totalUnusedPercent = Math.round(100 * totalUnusedStylesheetSize / totalStylesheetSize);
- summary.value = String.sprintf("%d%% of CSS (estimated) is not used by the current page.", totalUnusedPercent);
+ summary.value = String.sprintf("%s (%d%%) of CSS is not used by the current page.", Number.bytesToString(totalUnusedStylesheetSize), totalUnusedPercent);
callback(result);
}
@@ -349,11 +354,10 @@ WebInspector.AuditRules.UnusedCssRule.prototype = {
var result = {};
for (var i = 0; i < selectorArray.length; ++i) {
try {
- var nodes = document.querySelectorAll(selectorArray[i]);
- if (nodes && nodes.length)
+ if (document.querySelector(selectorArray[i]))
result[selectorArray[i]] = true;
} catch(e) {
- // ignore and mark as unused
+ // Ignore and mark as unused.
}
}
return result;
@@ -362,16 +366,24 @@ WebInspector.AuditRules.UnusedCssRule.prototype = {
WebInspector.AuditRules.evaluateInTargetWindow(routine, [selectors], selectorsCallback.bind(null, callback, styleSheets, testedSelectors));
}
- function routine()
+ function styleSheetCallback(styleSheets, continuation, styleSheet)
{
- var styleSheets = document.styleSheets;
- if (!styleSheets)
- return false;
+ if (styleSheet)
+ styleSheets.push(styleSheet);
+ if (continuation)
+ continuation(styleSheets);
+ }
- return routineResult;
+ function allStylesCallback(styleSheetIds)
+ {
+ if (!styleSheetIds || !styleSheetIds.length)
+ return evalCallback([]);
+ var styleSheets = [];
+ for (var i = 0; i < styleSheetIds.length; ++i)
+ WebInspector.CSSStyleSheet.createForId(styleSheetIds[i], styleSheetCallback.bind(null, styleSheets, i == styleSheetIds.length - 1 ? evalCallback : null));
}
- InspectorBackend.getAllStyles(evalCallback);
+ InspectorBackend.getAllStyles2(allStylesCallback);
}
}
@@ -647,7 +659,7 @@ WebInspector.AuditRules.ImageDimensionsRule.prototype = {
const node = WebInspector.domAgent.nodeForId(imageId);
var src = node.getAttribute("src");
- if (!WebInspector.URLRegExp.test(src)) {
+ if (!src.asParsedURL()) {
for (var frameOwnerCandidate = node; frameOwnerCandidate; frameOwnerCandidate = frameOwnerCandidate.parentNode) {
if (frameOwnerCandidate.documentURL) {
var completeSrc = WebInspector.completeURL(frameOwnerCandidate.documentURL, src);
@@ -658,7 +670,7 @@ WebInspector.AuditRules.ImageDimensionsRule.prototype = {
if (completeSrc)
src = completeSrc;
- const computedStyle = new WebInspector.CSSStyleDeclaration(styles.computedStyle);
+ const computedStyle = styles.computedStyle;
if (computedStyle.getPropertyValue("position") === "absolute") {
if (!context.imagesLeft)
doneCallback(context);
@@ -669,7 +681,7 @@ WebInspector.AuditRules.ImageDimensionsRule.prototype = {
var heightFound = "height" in styles.styleAttributes;
for (var i = styles.matchedCSSRules.length - 1; i >= 0 && !(widthFound && heightFound); --i) {
- var style = WebInspector.CSSStyleDeclaration.parseRule(styles.matchedCSSRules[i]).style;
+ var style = styles.matchedCSSRules[i].style;
if (style.getPropertyValue("width") !== "")
widthFound = true;
if (style.getPropertyValue("height") !== "")
@@ -693,7 +705,7 @@ WebInspector.AuditRules.ImageDimensionsRule.prototype = {
return callback(null);
var context = {imagesLeft: imageIds.length, urlToNoDimensionCount: {}};
for (var i = imageIds.length - 1; i >= 0; --i)
- InspectorBackend.getStyles(imageIds[i], true, imageStylesReady.bind(this, imageIds[i], context));
+ WebInspector.cssModel.getStylesAsync(imageIds[i], imageStylesReady.bind(this, imageIds[i], context));
}
function pushImageNodes()
@@ -934,7 +946,6 @@ WebInspector.AuditRules.CookieSizeRule.prototype = {
var domainToResourcesMap = WebInspector.AuditRules.getDomainToResourcesMap(resources,
null,
- WebInspector.URLRegExp,
true);
var matchingResourceData = {};
this.mapResourceCookies(domainToResourcesMap, allCookies, collectorCallback.bind(this));
@@ -998,7 +1009,6 @@ WebInspector.AuditRules.StaticCookielessRule.prototype = {
var domainToResourcesMap = WebInspector.AuditRules.getDomainToResourcesMap(resources,
[WebInspector.Resource.Type.Stylesheet,
WebInspector.Resource.Type.Image],
- WebInspector.URLRegExp,
true);
var totalStaticResources = 0;
for (var domain in domainToResourcesMap)
21 front-end/AuditsPanel.js
View
@@ -130,8 +130,8 @@ WebInspector.AuditsPanel.prototype = {
_executeAudit: function(categories, resultCallback)
{
var resources = [];
- for (var id in WebInspector.resources)
- resources.push(WebInspector.resources[id]);
+ for (var id in WebInspector.networkResources)
+ resources.push(WebInspector.networkResources[id]);
var rulesRemaining = 0;
for (var i = 0; i < categories.length; ++i)
@@ -203,20 +203,15 @@ WebInspector.AuditsPanel.prototype = {
_reloadResources: function(callback)
{
- this._resourceTrackingCallback = callback;
-
- if (!WebInspector.panels.resources.resourceTrackingEnabled) {
- InspectorBackend.enableResourceTracking(false);
- this._updateLauncherViewControls(true);
- } else
- InspectorBackend.reloadPage();
+ this._pageReloadCallback = callback;
+ InspectorBackend.reloadPage();
},
_didMainResourceLoad: function()
{
- if (this._resourceTrackingCallback) {
- var callback = this._resourceTrackingCallback;
- delete this._resourceTrackingCallback;
+ if (this._pageReloadCallback) {
+ var callback = this._pageReloadCallback;
+ delete this._pageReloadCallback;
callback();
}
},
@@ -256,7 +251,7 @@ WebInspector.AuditsPanel.prototype = {
show: function()
{
WebInspector.Panel.prototype.show.call(this);
- this._updateLauncherViewControls(WebInspector.panels.resources.resourceTrackingEnabled);
+ this._updateLauncherViewControls(!WebInspector.panels.resources || WebInspector.panels.resources.resourceTrackingEnabled);
},
reset: function()
192 front-end/BreakpointManager.js
View
@@ -28,7 +28,6 @@ WebInspector.BreakpointManager = function()
{
this._breakpoints = {};
this._nativeBreakpoints = {};
- this._domBreakpoints = {};
}
WebInspector.BreakpointManager.prototype = {
@@ -137,13 +136,12 @@ WebInspector.BreakpointManager.prototype = {
var breakpoint = new WebInspector.DOMBreakpoint(this, frontendId, nodeId, domEventType);
this._nativeBreakpoints[frontendId] = breakpoint;
- this._domBreakpoints[frontendId] = breakpoint;
this.dispatchEventToListeners("dom-breakpoint-added", breakpoint);
breakpoint.enabled = !disabled;
return breakpoint;
},
- createEventListenerBreakpoint: function(eventName, disabled)
+ createEventListenerBreakpoint: function(eventName)
{
var frontendId = eventName;
if (frontendId in this._nativeBreakpoints)
@@ -151,7 +149,8 @@ WebInspector.BreakpointManager.prototype = {
var breakpoint = new WebInspector.EventListenerBreakpoint(this, frontendId, eventName);
this._nativeBreakpoints[frontendId] = breakpoint;
- breakpoint.enabled = !disabled;
+ this.dispatchEventToListeners("event-listener-breakpoint-added", { breakpoint: breakpoint, eventName: eventName });
+ breakpoint.enabled = true;
return breakpoint;
},
@@ -175,8 +174,7 @@ WebInspector.BreakpointManager.prototype = {
if (breakpoint.enabled)
this._removeNativeBreakpointFromBackend(breakpoint);
delete this._nativeBreakpoints[breakpoint._frontendId];
- if (breakpoint._type === "DOM")
- delete this._domBreakpoints[breakpoint._frontendId];
+ this._updateNativeBreakpointsInSettings();
breakpoint.dispatchEventToListeners("removed");
},
@@ -195,7 +193,7 @@ WebInspector.BreakpointManager.prototype = {
_setNativeBreakpointOnBackend: function(breakpoint)
{
breakpoint._beingSetOnBackend = true;
- var data = { type: breakpoint._type, condition: breakpoint._condition() };
+ var data = { type: breakpoint._type, condition: breakpoint._condition };
InspectorBackend.setNativeBreakpoint(data, didSetNativeBreakpoint.bind(this));
function didSetNativeBreakpoint(backendBreakpointId)
@@ -206,6 +204,7 @@ WebInspector.BreakpointManager.prototype = {
this._breakpoints[backendBreakpointId] = breakpoint;
}
breakpoint.dispatchEventToListeners("enable-changed");
+ this._updateNativeBreakpointsInSettings();
}
},
@@ -215,14 +214,33 @@ WebInspector.BreakpointManager.prototype = {
delete this._breakpoints[breakpoint._backendId]
delete breakpoint._backendId;
breakpoint.dispatchEventToListeners("enable-changed");
+ this._updateNativeBreakpointsInSettings();
+ },
+
+ _updateNativeBreakpointsInSettings: function()
+ {
+ var persistentBreakpoints = [];
+ for (var id in this._nativeBreakpoints) {
+ var breakpoint = this._nativeBreakpoints[id];
+ if (breakpoint._persistentCondition)
+ persistentBreakpoints.push({ type: breakpoint._type, enabled: breakpoint.enabled, condition: breakpoint._persistentCondition });
+ }
+ WebInspector.settings.nativeBreakpoints = persistentBreakpoints;
},
debuggerPaused: function(details)
{
- if (details.eventType !== WebInspector.DebuggerEventTypes.NativeBreakpoint)
+ if (details.eventType === WebInspector.DebuggerEventTypes.JavaScriptPause)
+ return;
+
+ if (details.eventData && details.eventData.breakpointId)
+ var breakpointId = details.eventData.breakpointId;
+ else if (details.callFrames && details.callFrames.length)
+ var breakpointId = WebInspector.Breakpoint.jsBreakpointId(details.callFrames[0].sourceID, details.callFrames[0].line);
+ else
return;
- var breakpoint = this._breakpoints[details.eventData.breakpointId];
+ var breakpoint = this._breakpoints[breakpointId];
if (!breakpoint)
return;
@@ -242,31 +260,60 @@ WebInspector.BreakpointManager.prototype = {
delete this._lastHitBreakpoint;
},
+ restoreBreakpoints: function()
+ {
+ var breakpoints = this._persistentBreakpoints();
+ for (var i = 0; i < breakpoints.length; ++i) {
+ if (breakpoints[i].type === "EventListener")
+ this.createEventListenerBreakpoint(breakpoints[i].condition.eventName);
+ else if (breakpoints[i].type === "XHR")
+ this.createXHRBreakpoint(breakpoints[i].condition.url, !breakpoints[i].enabled);
+ }
+ },
+
restoreDOMBreakpoints: function()
{
- var domBreakpoints = this._domBreakpoints;
- this._domBreakpoints = {};
+ function didPushNodeByPathToFrontend(path, nodeId)
+ {
+ pathToNodeId[path] = nodeId;
+ pendingCalls -= 1;
+ if (pendingCalls)
+ return;
+ for (var i = 0; i < breakpoints.length; ++i) {
+ var breakpoint = breakpoints[i];
+ var nodeId = pathToNodeId[breakpoint.condition.path];
+ if (nodeId)
+ this.createDOMBreakpoint(nodeId, breakpoint.condition.type, !breakpoint.enabled);
+ }
+ }
- var breakpointsToRestore = {};
- for (var frontendId in domBreakpoints) {
- var breakpoint = domBreakpoints[frontendId];
- var path = breakpoint._path;
- if (!path)
+ var breakpoints = this._persistentBreakpoints();
+ var pathToNodeId = {};
+ var pendingCalls = 0;
+ for (var i = 0; i < breakpoints.length; ++i) {
+ if (breakpoints[i].type !== "DOM")
continue;
- if (!breakpointsToRestore[path]) {
- breakpointsToRestore[path] = [];
- InspectorBackend.pushNodeByPathToFrontend(path, restoreBreakpointsForNode.bind(this, breakpointsToRestore[path]));
- }
- breakpointsToRestore[path].push(breakpoint);
+ var path = breakpoints[i].condition.path;
+ if (path in pathToNodeId)
+ continue;
+ pathToNodeId[path] = 0;
+ pendingCalls += 1;
+ InspectorBackend.pushNodeByPathToFrontend(path, didPushNodeByPathToFrontend.bind(this, path));
}
+ },
- function restoreBreakpointsForNode(breakpoints, nodeId)
- {
- if (!nodeId)
- return;
- for (var i = 0; i < breakpoints.length; ++i)
- this.createDOMBreakpoint(nodeId, breakpoints[i]._domEventType, !breakpoints[i].enabled);
+ _persistentBreakpoints: function()
+ {
+ var result = [];
+ var breakpoints = WebInspector.settings.nativeBreakpoints;
+ if (breakpoints instanceof Array) {
+ for (var i = 0; i < breakpoints.length; ++i) {
+ var breakpoint = breakpoints[i];
+ if ("type" in breakpoint && "condition" in breakpoint)
+ result.push(breakpoint)
+ }
}
+ return result;
}
}
@@ -283,6 +330,11 @@ WebInspector.Breakpoint = function(breakpointManager, sourceID, url, line, enabl
this._breakpointManager = breakpointManager;
}
+WebInspector.Breakpoint.jsBreakpointId = function(sourceID, line)
+{
+ return sourceID + ":" + line;
+}
+
WebInspector.Breakpoint.prototype = {
get enabled()
{
@@ -307,12 +359,12 @@ WebInspector.Breakpoint.prototype = {
set sourceText(text)
{
this._sourceText = text;
- this.dispatchEventToListeners("text-changed");
+ this.dispatchEventToListeners("label-changed");
},
get id()
{
- return this.sourceID + ":" + this.line;
+ return WebInspector.Breakpoint.jsBreakpointId(this.sourceID, this.line);
},
get condition()
@@ -332,6 +384,11 @@ WebInspector.Breakpoint.prototype = {
this.dispatchEventToListeners("condition-changed");
},
+ click: function(event)
+ {
+ WebInspector.panels.scripts.showSourceLine(this.url, this.line);
+ },
+
compareTo: function(other)
{
if (this.url != other.url)
@@ -341,6 +398,18 @@ WebInspector.Breakpoint.prototype = {
return 0;
},
+ populateLabelElement: function(element)
+ {
+ 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);
+ },
+
remove: function()
{
InspectorBackend.removeBreakpoint(this.sourceID, this.line);
@@ -405,20 +474,16 @@ WebInspector.DOMBreakpoint = function(manager, frontendId, nodeId, domEventType)
WebInspector.NativeBreakpoint.call(this, manager, frontendId, "DOM");
this._nodeId = nodeId;
this._domEventType = domEventType;
+ this._condition = { nodeId: this._nodeId, type: this._domEventType };
var node = WebInspector.domAgent.nodeForId(this._nodeId);
if (node) {
node.breakpoints[this._domEventType] = this;
- this._path = node.path();
+ this._persistentCondition = { path: node.path(), type: this._domEventType };
}
}
WebInspector.DOMBreakpoint.prototype = {
- click: function()
- {
- WebInspector.updateFocusedNode(this._nodeId);
- },
-
compareTo: function(other)
{
return this._compare(this._domEventType, other._domEventType);
@@ -426,9 +491,14 @@ WebInspector.DOMBreakpoint.prototype = {
populateLabelElement: function(element)
{
- element.appendChild(WebInspector.panels.elements.linkifyNodeById(this._nodeId));
- element.appendChild(document.createTextNode(" - "));
- element.appendChild(document.createTextNode(WebInspector.domBreakpointTypeLabel(this._domEventType)));
+ // FIXME: this should belong to the view, not the manager.
+ var linkifiedNode = WebInspector.panels.elements.linkifyNodeById(this._nodeId);
+ linkifiedNode.addStyleClass("monospace");
+ element.appendChild(linkifiedNode);
+ var description = document.createElement("div");
+ description.className = "source-text";
+ description.textContent = WebInspector.domBreakpointTypeLabel(this._domEventType);
+ element.appendChild(description);
},
populateStatusMessageElement: function(element, eventData)
@@ -459,11 +529,6 @@ WebInspector.DOMBreakpoint.prototype = {
WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s.", substitutions, formatters, "", append);
},
- _condition: function()
- {
- return { nodeId: this._nodeId, type: this._domEventType };
- },
-
_onRemove: function()
{
var node = WebInspector.domAgent.nodeForId(this._nodeId);
@@ -478,6 +543,20 @@ WebInspector.EventListenerBreakpoint = function(manager, frontendId, eventName)
{
WebInspector.NativeBreakpoint.call(this, manager, frontendId, "EventListener");
this._eventName = eventName;
+ this._condition = { eventName: this._eventName };
+ this._persistentCondition = this._condition;
+}
+
+WebInspector.EventListenerBreakpoint.eventNameForUI = function(eventName)
+{
+ if (!WebInspector.EventListenerBreakpoint._eventNamesForUI) {
+ WebInspector.EventListenerBreakpoint._eventNamesForUI = {
+ "instrumentation:setTimer": WebInspector.UIString("Set Timer"),
+ "instrumentation:clearTimer": WebInspector.UIString("Clear Timer"),
+ "instrumentation:timerFired": WebInspector.UIString("Timer Fired")
+ };
+ }
+ return WebInspector.EventListenerBreakpoint._eventNamesForUI[eventName] || eventName.substring(eventName.indexOf(":") + 1);
}
WebInspector.EventListenerBreakpoint.prototype = {
@@ -497,21 +576,9 @@ WebInspector.EventListenerBreakpoint.prototype = {
element.appendChild(document.createTextNode(status));
},
- _condition: function()
- {
- return { eventName: this._eventName };
- },
-
_uiEventName: function()
{
- if (!WebInspector.EventListenerBreakpoint._uiEventNames) {
- WebInspector.EventListenerBreakpoint._uiEventNames = {
- "instrumentation:setTimer": WebInspector.UIString("Set Timer"),
- "instrumentation:clearTimer": WebInspector.UIString("Clear Timer"),
- "instrumentation:timerFired": WebInspector.UIString("Timer Fired")
- };
- }
- return WebInspector.EventListenerBreakpoint._uiEventNames[this._eventName] || this._eventName.substring(this._eventName.indexOf(":") + 1);
+ return WebInspector.EventListenerBreakpoint.eventNameForUI(this._eventName);
}
}
@@ -521,6 +588,8 @@ WebInspector.XHRBreakpoint = function(manager, frontendId, url)
{
WebInspector.NativeBreakpoint.call(this, manager, frontendId, "XHR");
this._url = url;
+ this._condition = { url: this._url };
+ this._persistentCondition = this._condition;
}
WebInspector.XHRBreakpoint.prototype = {
@@ -529,6 +598,11 @@ WebInspector.XHRBreakpoint.prototype = {
return this._compare(this._url, other._url);
},
+ populateEditElement: function(element)
+ {
+ element.textContent = this._url;
+ },
+
populateLabelElement: function(element)
{
var label;
@@ -537,17 +611,13 @@ WebInspector.XHRBreakpoint.prototype = {
else
label = WebInspector.UIString("URL contains \"%s\"", this._url);
element.appendChild(document.createTextNode(label));
+ element.addStyleClass("cursor-auto");
},
populateStatusMessageElement: function(element)
{
var status = WebInspector.UIString("Paused on a XMLHttpRequest.");
element.appendChild(document.createTextNode(status));
- },
-
- _condition: function()
- {
- return { url: this._url };
}
}
318 front-end/BreakpointsSidebarPane.js
View
@@ -47,46 +47,56 @@ WebInspector.BreakpointsSidebarPane.prototype = {
}
},
- addBreakpoint: function(breakpointItem)
+ addBreakpointItem: function(breakpointItem)
{
- breakpointItem.addEventListener("removed", this._breakpointRemoved, this);
-
- var element = breakpointItem.element();
+ var element = breakpointItem.element;
element._breakpointItem = breakpointItem;
+ breakpointItem.addEventListener("breakpoint-hit", this.expand, this);
+ breakpointItem.addEventListener("removed", this._removeListElement.bind(this, element), this);
+
var currentElement = this.listElement.firstChild;
while (currentElement) {
- if (currentElement._breakpointItem.compareTo(element._breakpointItem) > 0) {
- this.listElement.insertBefore(element, currentElement);
+ if (currentElement._breakpointItem && currentElement._breakpointItem.compareTo(element._breakpointItem) > 0)
break;
- }
currentElement = currentElement.nextSibling;
}
- if (!currentElement)
- this.listElement.appendChild(element);
+ this._addListElement(element, currentElement);
+ if (breakpointItem.click) {
+ element.addStyleClass("cursor-pointer");
+ element.addEventListener("click", breakpointItem.click.bind(breakpointItem), false);
+ }
element.addEventListener("contextmenu", this._contextMenuEventFired.bind(this, breakpointItem), true);
+ },
- if (this.emptyElement.parentElement) {
- this.bodyElement.removeChild(this.emptyElement);
- this.bodyElement.appendChild(this.listElement);
+ _contextMenuEventFired: function(breakpointItem, event)
+ {
+ var contextMenu = new WebInspector.ContextMenu();
+ contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), breakpointItem.remove.bind(breakpointItem));
+ contextMenu.show(event);
+ },
+
+ _addListElement: function(element, beforeElement)
+ {
+ if (beforeElement)
+ this.listElement.insertBefore(element, beforeElement);
+ else {
+ if (!this.listElement.firstChild) {
+ this.bodyElement.removeChild(this.emptyElement);
+ this.bodyElement.appendChild(this.listElement);
+ }
+ this.listElement.appendChild(element);
}
},
- _breakpointRemoved: function(event)
+ _removeListElement: function(element)
{
- this.listElement.removeChild(event.target.element());
+ this.listElement.removeChild(element);
if (!this.listElement.firstChild) {
this.bodyElement.removeChild(this.listElement);
this.bodyElement.appendChild(this.emptyElement);
}
- },
-
- _contextMenuEventFired: function(breakpointItem, event)
- {
- var contextMenu = new WebInspector.ContextMenu();
- contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), breakpointItem.remove.bind(breakpointItem));
- contextMenu.show(event);
}
}
@@ -96,36 +106,58 @@ WebInspector.XHRBreakpointsSidebarPane = function()
{
WebInspector.BreakpointsSidebarPane.call(this, WebInspector.UIString("XHR Breakpoints"));
+ function addButtonClicked(event)
+ {
+ event.stopPropagation();
+ this._startEditingBreakpoint(null);
+ }
+
var addButton = document.createElement("button");
addButton.className = "add";
- addButton.addEventListener("click", this._showEditBreakpointDialog.bind(this), false);
+ addButton.addEventListener("click", addButtonClicked.bind(this), false);
this.titleElement.appendChild(addButton);
-
- this.urlInputElement = document.createElement("span");
- this.urlInputElement.className = "breakpoint-condition editing";
}
WebInspector.XHRBreakpointsSidebarPane.prototype = {
- _showEditBreakpointDialog: function(event)
+ addBreakpointItem: function(breakpointItem)
{
- event.stopPropagation();
+ WebInspector.BreakpointsSidebarPane.prototype.addBreakpointItem.call(this, breakpointItem);
+ breakpointItem._labelElement.addEventListener("dblclick", this._startEditingBreakpoint.bind(this, breakpointItem), false);
+ },
- if (this.urlInputElement.parentElement)
+ _startEditingBreakpoint: function(breakpointItem)
+ {
+ if (this._editingBreakpoint)
return;
+ this._editingBreakpoint = true;
if (!this.expanded)
this.expanded = true;
- this.urlInputElement.textContent = "";
- this.bodyElement.insertBefore(this.urlInputElement, this.bodyElement.firstChild);
- WebInspector.startEditing(this.urlInputElement, this._hideEditBreakpointDialog.bind(this, false), this._hideEditBreakpointDialog.bind(this, true));
+ var inputElement = document.createElement("span");
+ inputElement.className = "breakpoint-condition editing";
+ if (breakpointItem) {
+ breakpointItem.populateEditElement(inputElement);
+ this.listElement.insertBefore(inputElement, breakpointItem.element);
+ breakpointItem.element.addStyleClass("hidden");
+ } else
+ this._addListElement(inputElement, this.listElement.firstChild);
+
+ var commitHandler = this._hideEditBreakpointDialog.bind(this, inputElement, true, breakpointItem);
+ var cancelHandler = this._hideEditBreakpointDialog.bind(this, inputElement, false, breakpointItem);
+ WebInspector.startEditing(inputElement, commitHandler, cancelHandler);
},
- _hideEditBreakpointDialog: function(discard)
+ _hideEditBreakpointDialog: function(inputElement, accept, breakpointItem)
{
- if (!discard)
- WebInspector.breakpointManager.createXHRBreakpoint(this.urlInputElement.textContent.toLowerCase());
- this.bodyElement.removeChild(this.urlInputElement);
+ this._removeListElement(inputElement);
+ this._editingBreakpoint = false;
+ if (accept) {
+ if (breakpointItem)
+ breakpointItem.remove();
+ WebInspector.breakpointManager.createXHRBreakpoint(inputElement.textContent.toLowerCase());
+ } else if (breakpointItem)
+ breakpointItem.element.removeStyleClass("hidden");
}
}
@@ -136,7 +168,6 @@ WebInspector.BreakpointItem = function(breakpoint)
this._breakpoint = breakpoint;
this._element = document.createElement("li");
- this._element.addEventListener("click", this._breakpointClicked.bind(this), false);
var checkboxElement = document.createElement("input");
checkboxElement.className = "checkbox-elem";
@@ -145,16 +176,18 @@ WebInspector.BreakpointItem = function(breakpoint)
checkboxElement.addEventListener("click", this._checkboxClicked.bind(this), false);
this._element.appendChild(checkboxElement);
- if ("populateLabelElement" in this._breakpoint)
- this._breakpoint.populateLabelElement(this._element);
+ this._createLabelElement();
this._breakpoint.addEventListener("enable-changed", this._enableChanged, this);
this._breakpoint.addEventListener("hit-state-changed", this._hitStateChanged, this);
+ this._breakpoint.addEventListener("label-changed", this._labelChanged, this);
this._breakpoint.addEventListener("removed", this.dispatchEventToListeners.bind(this, "removed"));
+ if (breakpoint.click)
+ this.click = breakpoint.click.bind(breakpoint);
}
WebInspector.BreakpointItem.prototype = {
- element: function()
+ get element()
{
return this._element;
},
@@ -164,15 +197,14 @@ WebInspector.BreakpointItem.prototype = {
return this._breakpoint.compareTo(other._breakpoint);
},
- remove: function()
+ populateEditElement: function(element)
{
- this._breakpoint.remove();
+ this._breakpoint.populateEditElement(element);
},
- _breakpointClicked: function(event)
+ remove: function()
{
- if ("click" in this._breakpoint)
- this._breakpoint.click();
+ this._breakpoint.remove();
},
_checkboxClicked: function(event)
@@ -191,45 +223,28 @@ WebInspector.BreakpointItem.prototype = {
_hitStateChanged: function(event)
{
- if (event.target.hit)
+ if (event.target.hit) {
this._element.addStyleClass("breakpoint-hit");
- else
+ this.dispatchEventToListeners("breakpoint-hit");
+ } else
this._element.removeStyleClass("breakpoint-hit");
- }
-}
-
-WebInspector.BreakpointItem.prototype.__proto__ = WebInspector.Object.prototype;
-
-WebInspector.JSBreakpointItem = function(breakpoint)
-{
- WebInspector.BreakpointItem.call(this, breakpoint);
-
- var displayName = this._breakpoint.url ? WebInspector.displayNameForURL(this._breakpoint.url) : WebInspector.UIString("(program)");
- var labelElement = document.createTextNode(displayName + ":" + this._breakpoint.line);
- this._element.appendChild(labelElement);
-
- var sourceTextElement = document.createElement("div");
- sourceTextElement.textContent = this._breakpoint.sourceText;
- sourceTextElement.className = "source-text monospace";
- this._element.appendChild(sourceTextElement);
-
- this._breakpoint.addEventListener("text-changed", this._textChanged, this);
-}
+ },
-WebInspector.JSBreakpointItem.prototype = {
- _breakpointClicked: function()
+ _labelChanged: function(event)
{
- WebInspector.panels.scripts.showSourceLine(this._breakpoint.url, this._breakpoint.line);
+ this._element.removeChild(this._labelElement);
+ this._createLabelElement();
},
- _textChanged: function()
+ _createLabelElement: function()
{
- var sourceTextElement = this._element.firstChild.nextSibling.nextSibling;
- sourceTextElement.textContent = this._breakpoint.sourceText;
+ this._labelElement = document.createElement("span");
+ this._breakpoint.populateLabelElement(this._labelElement);
+ this._element.appendChild(this._labelElement);
}
}
-WebInspector.JSBreakpointItem.prototype.__proto__ = WebInspector.BreakpointItem.prototype;
+WebInspector.BreakpointItem.prototype.__proto__ = WebInspector.Object.prototype;
WebInspector.EventListenerBreakpointsSidebarPane = function()
{
@@ -240,97 +255,126 @@ WebInspector.EventListenerBreakpointsSidebarPane = function()
this.categoriesElement.addStyleClass("properties-tree event-listener-breakpoints");
this.categoriesTreeOutline = new TreeOutline(this.categoriesElement);
this.bodyElement.appendChild(this.categoriesElement);
+
+ WebInspector.breakpointManager.addEventListener("event-listener-breakpoint-added", 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"]);
+ // 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"]);
}
WebInspector.EventListenerBreakpointsSidebarPane.prototype = {
- _populate: function()
+ _createCategory: function(name, type, eventNames)
{
- var categories = {
- "Mouse": { type: "listener", eventNames: ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove", "mouseout", "mousewheel"] },
- "Keyboard": { type: "listener", eventNames: ["keydown", "keypress", "keyup"] },
- "HTML frame/object": { type: "listener", eventNames: ["load", "error", "resize", "scroll"] },
- "Timer": { type: "instrumentation", eventNames: ["setTimer", "clearTimer", "timerFired"] }
- };
-
- for (var category in categories) {
- var categoryTreeElement = new TreeElement(WebInspector.UIString(category));
- this.categoriesTreeOutline.appendChild(categoryTreeElement);
- categoryTreeElement.listItemElement.addStyleClass("event-category");
- categoryTreeElement.selectable = true;
-
- var categoryItem = {};
- categoryItem.checkbox = this._createCheckbox(categoryTreeElement, this._categoryCheckboxClicked.bind(this, categoryItem));
- categoryItem.children = {};
-
- var categoryType = categories[category].type;
- var eventNames = categories[category].eventNames;
- for (var i = 0; i < eventNames.length; ++i) {
- var eventName = categoryType + ":" + eventNames[i];
-
- var breakpoint = WebInspector.breakpointManager.createEventListenerBreakpoint(eventName, true);
- if (!breakpoint)
- continue;
-
- var labelElement = document.createElement("div");
- breakpoint.populateLabelElement(labelElement);
- var eventNameTreeElement = new TreeElement(labelElement);
- categoryTreeElement.appendChild(eventNameTreeElement);
- eventNameTreeElement.listItemElement.addStyleClass("source-code");
- eventNameTreeElement.selectable = true;
-
- var eventNameItem = {};
- eventNameItem.checkbox = this._createCheckbox(eventNameTreeElement, this._eventNameCheckboxClicked.bind(this, categoryItem, eventNameItem));
- eventNameItem.breakpoint = breakpoint;
-
- breakpoint.addEventListener("enable-changed", this._breakpointEnableChanged.bind(this, categoryItem, eventNameItem), true);
-
- categoryItem.children[eventName] = eventNameItem;
- }
+ var categoryItem = {};
+ categoryItem.element = new TreeElement(WebInspector.UIString(name));
+ this.categoriesTreeOutline.appendChild(categoryItem.element);
+ categoryItem.element.listItemElement.addStyleClass("event-category");
+ categoryItem.element.selectable = true;
+
+ categoryItem.checkbox = this._createCheckbox(categoryItem.element);
+ categoryItem.checkbox.addEventListener("click", this._categoryCheckboxClicked.bind(this, categoryItem), true);
+
+ categoryItem.children = {};
+ for (var i = 0; i < eventNames.length; ++i) {
+ var eventName = type + ":" + eventNames[i];
+
+ var breakpointItem = {};
+ var title = WebInspector.EventListenerBreakpoint.eventNameForUI(eventName);
+ breakpointItem.element = new TreeElement(title);
+ categoryItem.element.appendChild(breakpointItem.element);
+ var hitMarker = document.createElement("div");
+ hitMarker.className = "breakpoint-hit-marker";
+ breakpointItem.element.listItemElement.appendChild(hitMarker);
+ breakpointItem.element.listItemElement.addStyleClass("source-code");
+ breakpointItem.element.selectable = true;
+
+ breakpointItem.checkbox = this._createCheckbox(breakpointItem.element);
+ breakpointItem.checkbox.addEventListener("click", this._breakpointCheckboxClicked.bind(this, breakpointItem), true);
+ breakpointItem.parent = categoryItem;
+ breakpointItem.eventName = eventName;
+
+ this._breakpointItems[eventName] = breakpointItem;
+ categoryItem.children[eventName] = breakpointItem;
}
},
- _createCheckbox: function(treeElement, checkboxClickedDelegate)
+ _createCheckbox: function(treeElement)
{
var checkbox = document.createElement("input");
checkbox.className = "checkbox-elem";
checkbox.type = "checkbox";
- checkbox.addEventListener("click", checkboxClickedDelegate, true);
treeElement.listItemElement.insertBefore(checkbox, treeElement.listItemElement.firstChild);
return checkbox;
},
_categoryCheckboxClicked: function(categoryItem)
{
- var checkbox = categoryItem.checkbox;
- checkbox.indeterminate = false;
+ var checked = categoryItem.checkbox.checked;
for (var eventName in categoryItem.children) {
- var eventNameItem = categoryItem.children[eventName];
- eventNameItem.checkbox.checked = checkbox.checked;
- eventNameItem.breakpoint.enabled = checkbox.checked;
+ var breakpointItem = categoryItem.children[eventName];
+ if (breakpointItem.checkbox.checked !== checked) {
+ breakpointItem.checkbox.checked = checked;
+ this._breakpointCheckboxClicked(breakpointItem);
+ }
}
},
- _eventNameCheckboxClicked: function(categoryItem, eventNameItem)
+ _breakpointCheckboxClicked: function(breakpointItem)
{
- this._updateCategoryCheckbox(categoryItem);
- eventNameItem.breakpoint.enabled = eventNameItem.checkbox.checked;
+ if (breakpointItem.checkbox.checked)
+ WebInspector.breakpointManager.createEventListenerBreakpoint(breakpointItem.eventName);
+ else
+ breakpointItem.breakpoint.remove();
},
- _breakpointEnableChanged: function(categoryItem, eventNameItem)
+ _breakpointAdded: function(event)
{
- if (eventNameItem.checkbox.checked === eventNameItem.breakpoint.enabled)
- return;
+ var breakpoint = event.data.breakpoint;
+ var eventName = event.data.eventName;
+
+ var breakpointItem = this._breakpointItems[eventName];
+ breakpointItem.breakpoint = breakpoint;
+ breakpoint.addEventListener("hit-state-changed", this._breakpointHitStateChanged.bind(this, breakpointItem));
+ breakpoint.addEventListener("removed", this._breakpointRemoved.bind(this, breakpointItem));
+ breakpointItem.checkbox.checked = true;
+ this._updateCategoryCheckbox(breakpointItem);
+ },
- eventNameItem.checkbox.checked = eventNameItem.breakpoint.enabled;
- this._updateCategoryCheckbox(categoryItem);
+ _breakpointHitStateChanged: function(breakpointItem, event)
+ {
+ if (event.target.hit) {
+ this.expanded = true;
+ var categoryItem = breakpointItem.parent;
+ categoryItem.element.expand();
+ breakpointItem.element.listItemElement.addStyleClass("breakpoint-hit");
+ } else
+ breakpointItem.element.listItemElement.removeStyleClass("breakpoint-hit");
},
- _updateCategoryCheckbox: function(categoryItem)
+ _breakpointRemoved: function(breakpointItem)
{
+ breakpointItem.breakpoint = null;
+ breakpointItem.checkbox.checked = false;
+ this._updateCategoryCheckbox(breakpointItem);
+ },
+
+ _updateCategoryCheckbox: function(breakpointItem)
+ {
+ var categoryItem = breakpointItem.parent;
var hasEnabled = false, hasDisabled = false;
for (var eventName in categoryItem.children) {
- var eventNameItem = categoryItem.children[eventName];
- if (eventNameItem.checkbox.checked)
+ var breakpointItem = categoryItem.children[eventName];
+ if (breakpointItem.checkbox.checked)
hasEnabled = true;
else
hasDisabled = true;
@@ -341,8 +385,12 @@ WebInspector.EventListenerBreakpointsSidebarPane.prototype = {
reset: function()
{
- this.categoriesTreeOutline.removeChildren();
- this._populate();
+ for (var eventName in this._breakpointItems) {
+ var breakpointItem = this._breakpointItems[eventName];
+ breakpointItem.breakpoint = null;
+ breakpointItem.checkbox.checked = false;
+ this._updateCategoryCheckbox(breakpointItem);
+ }
}
}
501 front-end/CSSStyleModel.js
View
@@ -32,80 +32,519 @@ WebInspector.CSSStyleModel = function()
{
}
+WebInspector.CSSStyleModel.parseRuleArrayPayload = function(ruleArray)
+{
+ var result = [];
+ for (var i = 0; i < ruleArray.length; ++i)
+ result.push(WebInspector.CSSRule.parsePayload(ruleArray[i]));
+ return result;
+}
+
WebInspector.CSSStyleModel.prototype = {
- getStylesAsync: function(nodeId, authOnly, userCallback)
+ getStylesAsync: function(nodeId, userCallback)
{
- InspectorBackend.getStyles(nodeId, authOnly, userCallback);
+ function callback(userCallback, payload)
+ {
+ if (!payload) {
+ if (userCallback)
+ userCallback(null);
+ return;
+ }
+
+ var result = {};
+ if ("inlineStyle" in payload)
+ result.inlineStyle = WebInspector.CSSStyleDeclaration.parsePayload(payload.inlineStyle);
+
+ result.computedStyle = WebInspector.CSSStyleDeclaration.parsePayload(payload.computedStyle);
+ result.matchedCSSRules = WebInspector.CSSStyleModel.parseRuleArrayPayload(payload.matchedCSSRules);
+
+ result.styleAttributes = {};
+ for (var name in payload.styleAttributes)
+ result.styleAttributes[name] = WebInspector.CSSStyleDeclaration.parsePayload(payload.styleAttributes[name]);
+
+ result.pseudoElements = [];
+ for (var i = 0; i < payload.pseudoElements.length; ++i) {
+ var entryPayload = payload.pseudoElements[i];
+ result.pseudoElements.push({ pseudoId: entryPayload.pseudoId, rules: WebInspector.CSSStyleModel.parseRuleArrayPayload(entryPayload.rules) });
+ }
+
+ result.inherited = [];
+ for (var i = 0; i < payload.inherited.length; ++i) {
+ var entryPayload = payload.inherited[i];
+ var entry = {};
+ if ("inlineStyle" in entryPayload)
+ entry.inlineStyle = WebInspector.CSSStyleDeclaration.parsePayload(entryPayload.inlineStyle);
+ if ("matchedCSSRules" in entryPayload)
+ entry.matchedCSSRules = WebInspector.CSSStyleModel.parseRuleArrayPayload(entryPayload.matchedCSSRules);
+ result.inherited.push(entry);
+ }
+
+ if (userCallback)
+ userCallback(result);
+ }
+
+ InspectorBackend.getStylesForNode2(nodeId, callback.bind(null, userCallback));
},
getComputedStyleAsync: function(nodeId, userCallback)
{
- InspectorBackend.getComputedStyle(nodeId, userCallback);
+ function callback(userCallback, stylePayload)
+ {
+ if (!stylePayload)
+ userCallback(null);
+ else
+ userCallback(WebInspector.CSSStyleDeclaration.parsePayload(stylePayload));
+ }
+
+ InspectorBackend.getComputedStyleForNode2(nodeId, callback.bind(null, userCallback));
+ },
+
+ getInlineStyleAsync: function(nodeId, userCallback)
+ {
+ function callback(userCallback, stylePayload)
+ {
+ if (!stylePayload)
+ userCallback(null);
+ else
+ userCallback(WebInspector.CSSStyleDeclaration.parsePayload(stylePayload));
+ }
+
+ InspectorBackend.getInlineStyleForNode2(nodeId, callback.bind(null, userCallback));
},
- setRuleSelector: function(ruleId, newContent, nodeId, successCallback, failureCallback)
+ setRuleSelector: function(ruleId, nodeId, newSelector, successCallback, failureCallback)
{
- function callback(newRulePayload, doesAffectSelectedNode)
+ function checkAffectsCallback(nodeId, successCallback, rulePayload, selectedNodeIds)
+ {
+ var doesAffectSelectedNode = (selectedNodeIds.indexOf(nodeId) >= 0);
+ var rule = WebInspector.CSSRule.parsePayload(rulePayload);
+ successCallback(rule, doesAffectSelectedNode);
+ this._styleSheetChanged(rule.id.styleSheetId, true);
+ }
+
+ function callback(nodeId, successCallback, failureCallback, newSelector, rulePayload)
{
- if (!newRulePayload)
+ if (!rulePayload)
failureCallback();
else
- successCallback(WebInspector.CSSStyleDeclaration.parseRule(newRulePayload), doesAffectSelectedNode);
+ InspectorBackend.querySelectorAll(nodeId, newSelector, checkAffectsCallback.bind(this, nodeId, successCallback, rulePayload));
}
- InspectorBackend.setRuleSelector(ruleId, newContent, nodeId, callback);
+ InspectorBackend.setRuleSelector2(ruleId, newSelector, callback.bind(this, nodeId, successCallback, failureCallback));
},
- addRule: function(nodeId, newContent, successCallback, failureCallback)
+ addRule: function(nodeId, selector, successCallback, failureCallback)
{
- function callback(rule, doesAffectSelectedNode)
+ function checkAffectsCallback(nodeId, successCallback, rulePayload, selectedNodeIds)
+ {
+ var doesAffectSelectedNode = (selectedNodeIds.indexOf(nodeId) >= 0);
+ var rule = WebInspector.CSSRule.parsePayload(rulePayload);
+ successCallback(rule, doesAffectSelectedNode);
+ this._styleSheetChanged(rule.id.styleSheetId, true);
+ }
+
+ function callback(successCallback, failureCallback, selector, rulePayload)
{
- if (!rule) {
+ if (!rulePayload) {
// Invalid syntax for a selector
failureCallback();
+ } else
+ InspectorBackend.querySelectorAll(nodeId, selector, checkAffectsCallback.bind(this, nodeId, successCallback, rulePayload));
+ }
+
+ InspectorBackend.addRule2(nodeId, selector, callback.bind(this, successCallback, failureCallback, selector));
+ },
+
+ _styleSheetChanged: function(styleSheetId, majorChange)
+ {
+ if (!majorChange || !styleSheetId)
+ return;
+
+ function callback(href, content)
+ {
+ var resource = WebInspector.resourceManager.resourceForURL(href);
+ if (resource && resource.type === WebInspector.Resource.Type.Stylesheet)
+ resource.content = content;
+ }
+ InspectorBackend.getStyleSheetText2(styleSheetId, callback);
+ }
+}
+
+WebInspector.CSSStyleDeclaration = function(payload)
+{
+ this.id = payload.styleId;
+ this.properties = payload.properties;
+ this._shorthandValues = payload.shorthandValues;
+ this._livePropertyMap = {}; // LIVE properties (source-based or style-based) : { name -> CSSProperty }
+ this._allProperties = []; // ALL properties: [ CSSProperty ]
+ this._longhandProperties = {}; // shorthandName -> [ CSSProperty ]
+ this.__disabledProperties = {}; // DISABLED properties: { index -> CSSProperty }
+ var payloadPropertyCount = payload.cssProperties.length;
+
+ var propertyIndex = 0;
+ for (var i = 0; i < payloadPropertyCount; ++i) {
+ var property = new WebInspector.CSSProperty.parsePayload(this, i, payload.cssProperties[i]);
+ this._allProperties.push(property);
+ if (property.disabled)
+ this.__disabledProperties[i] = property;
+ if (!property.active && !property.styleBased)
+ continue;
+ var name = property.name;
+ this[propertyIndex] = name;
+ this._livePropertyMap[name] = property;
+
+ // Index longhand properties.
+ if (property.shorthand) { // only for parsed
+ var longhands = this._longhandProperties[property.shorthand];
+ if (!longhands) {
+ longhands = [];
+ this._longhandProperties[property.shorthand] = longhands;
+ }
+ longhands.push(property);
+ }
+ ++propertyIndex;
+ }
+ this.length = propertyIndex;
+ if ("cssText" in payload)
+ this.cssText = payload.cssText;
+}
+
+WebInspector.CSSStyleDeclaration.parsePayload = function(payload)
+{
+ return new WebInspector.CSSStyleDeclaration(payload);
+}
+
+WebInspector.CSSStyleDeclaration.prototype = {
+ get allProperties()
+ {
+ return this._allProperties;
+ },
+
+ getLiveProperty: function(name)
+ {
+ return this._livePropertyMap[name];
+ },
+
+ getPropertyValue: function(name)
+ {
+ var property = this._livePropertyMap[name];
+ return property ? property.value : "";
+ },
+
+ getPropertyPriority: function(name)
+ {
+ var property = this._livePropertyMap[name];
+ return property ? property.priority : "";
+ },
+
+ getPropertyShorthand: function(name)
+ {
+ var property = this._livePropertyMap[name];
+ return property ? property.shorthand : "";
+ },
+
+ isPropertyImplicit: function(name)
+ {
+ var property = this._livePropertyMap[name];
+ return property ? property.implicit : "";
+ },
+
+ styleTextWithShorthands: function()
+ {
+ var cssText = "";
+ var foundProperties = {};
+ for (var i = 0; i < this.length; ++i) {
+ var individualProperty = this[i];
+ var shorthandProperty = this.getPropertyShorthand(individualProperty);
+ var propertyName = (shorthandProperty || individualProperty);
+
+ if (propertyName in foundProperties)
+ continue;
+
+ if (shorthandProperty) {
+ var value = this.getShorthandValue(shorthandProperty);
+ var priority = this.getShorthandPriority(shorthandProperty);
} else {
- var styleRule = WebInspector.CSSStyleDeclaration.parseRule(rule);
- styleRule.rule = rule;
- successCallback(styleRule, doesAffectSelectedNode);
+ var value = this.getPropertyValue(individualProperty);
+ var priority = this.getPropertyPriority(individualProperty);
}
+
+ foundProperties[propertyName] = true;
+
+ cssText += propertyName + ": " + value;
+ if (priority)
+ cssText += " !" + priority;
+ cssText += "; ";
}
- InspectorBackend.addRule(newContent, nodeId, callback);
+ return cssText;
+ },
+
+ getLonghandProperties: function(name)
+ {
+ return this._longhandProperties[name] || [];
},
- toggleStyleEnabled: function(styleId, propertyName, disabled, userCallback)
+ getShorthandValue: function(shorthandProperty)
{
- function callback(newPayload)
+ var property = this.getLiveProperty(shorthandProperty);
+ return property ? property.value : this._shorthandValues[shorthandProperty];
+ },
+
+ getShorthandPriority: function(shorthandProperty)
+ {
+ var priority = this.getPropertyPriority(shorthandProperty);
+ if (priority)
+ return priority;
+
+ var longhands = this._longhandProperties[shorthandProperty];
+ return longhands ? this.getPropertyPriority(longhands[0]) : null;
+ },
+
+ propertyAt: function(index)
+ {
+ return (index < this.allProperties.length) ? this.allProperties[index] : null;
+ },
+
+ pastLastSourcePropertyIndex: function()
+ {
+ for (var i = this.allProperties.length - 1; i >= 0; --i) {
+ var property = this.allProperties[i];
+ if (property.active || property.disabled)
+ return i + 1;
+ }
+ return 0;
+ },
+
+ newBlankProperty: function()
+ {
+ return new WebInspector.CSSProperty(this, this.pastLastSourcePropertyIndex(), "", "", "", "active", true, false, false, "");
+ },
+
+ insertPropertyAt: function(index, name, value, userCallback)
+ {
+ function callback(userCallback, payload)
{
- if (!newPayload) {
- userCallback(null);
+ if (!userCallback)
return;
+
+ if (!payload)
+ userCallback(null);
+ else {
+ userCallback(WebInspector.CSSStyleDeclaration.parsePayload(payload));
+ WebInspector.cssModel._styleSheetChanged(this.id.styleSheetId, true);
}
+ }
+
+ InspectorBackend.setPropertyText2(this.id, index, name + ": " + value + ";", false, callback.bind(null, userCallback));
+ },
+
+ appendProperty: function(name, value, userCallback)
+ {
+ this.insertPropertyAt(this.allProperties.length, name, value, userCallback);
+ }
+}
+
+WebInspector.CSSRule = function(payload)
+{
+ this.id = payload.ruleId;
+ this.selectorText = payload.selectorText;
+ this.sourceLine = payload.sourceLine;
+ this.sourceURL = payload.sourceURL;
+ this.origin = payload.origin;
+ this.style = WebInspector.CSSStyleDeclaration.parsePayload(payload.style);
+ this.style.parentRule = this;
+ this.selectorRange = payload.selectorRange;
+}
+
+WebInspector.CSSRule.parsePayload = function(payload)
+{
+ return new WebInspector.CSSRule(payload);
+}
+
+WebInspector.CSSRule.prototype = {
+ get isUserAgent()
+ {
+ return this.origin === "user-agent";
+ },
+
+ get isUser()
+ {
+ return this.origin === "user";
+ },
+
+ get isViaInspector()
+ {
+ return this.origin === "inspector";
+ },
+
+ get isRegular()
+ {
+ return this.origin === "";
+ }
+}
+
+WebInspector.CSSProperty = function(ownerStyle, index, name, value, priority, status, parsedOk, implicit, shorthand, text)
+{
+ this.ownerStyle = ownerStyle;
+ this.index = index;
+ this.name = name;
+ this.value = value;
+ this.priority = priority;
+ this.status = status;
+ this.parsedOk = parsedOk;
+ this.implicit = implicit;
+ this.shorthand = shorthand;
+ this.text = text;
+}
+
+WebInspector.CSSProperty.parsePayload = function(ownerStyle, index, payload)
+{
+ var result = new WebInspector.CSSProperty(
+ ownerStyle, index, payload.name, payload.value, payload.priority, payload.status, payload.parsedOk, payload.implicit, payload.shorthandName, payload.text);
+ return result;
+}
+
+WebInspector.CSSProperty.prototype = {
+ get propertyText()
+ {
+ if (this.text !== undefined)
+ return this.text;
+
+ if (this.name === "")
+ return "";
+ return this.name + ": " + this.value + (this.priority ? " !" + this.priority : "") + ";";
+ },
+
+ get isLive()
+ {
+ return this.active || this.styleBased;
+ },
+
+ get active()
+ {
+ return this.status === "active";
+ },
+
+ get styleBased()
+ {
+ return this.status === "style";
+ },
+
+ get inactive()
+ {
+ return this.status === "inactive";
+ },
+
+ get disabled()
+ {
+ return this.status === "disabled";
+ },
+
+ // Replaces "propertyName: propertyValue [!important];" in the stylesheet by an arbitrary propertyText.
+ setText: function(propertyText, majorChange, userCallback)
+ {
+ function callback(stylePayload)
+ {
+ if (stylePayload)
+ this.text = propertyText;
- var newStyle = WebInspector.CSSStyleDeclaration.parseStyle(newPayload);
- userCallback(newStyle);
+ if (!userCallback)
+ return;
+ if (!stylePayload)
+ userCallback(null);
+ else {
+ var style = WebInspector.CSSStyleDeclaration.parsePayload(stylePayload);
+ userCallback(style);
+ WebInspector.cssModel._styleSheetChanged(style.id.styleSheetId, majorChange);
+ }
}
- InspectorBackend.toggleStyleEnabled(styleId, propertyName, disabled, callback);
+ if (!this.ownerStyle)
+ throw "No ownerStyle for property";
+
+ // An index past all the properties adds a new property to the style.
+ InspectorBackend.setPropertyText2(this.ownerStyle.id, this.index, propertyText, this.index < this.ownerStyle.pastLastSourcePropertyIndex(), callback.bind(this));
},
- setCSSText: function(styleId, cssText)
+ setValue: function(newValue, userCallback)
{
- InspectorBackend.setStyleText(styleId, cssText);
+ var text = this.name + ": " + newValue + (this.priority ? " !" + this.priority : "") + ";"
+ this.setText(text, userCallback);
},
- applyStyleText: function(styleId, styleText, propertyName, successCallback, failureCallback)
+ setDisabled: function(disabled, userCallback)
{
- function callback(success, newPayload, changedProperties)
+ if (!this.ownerStyle && userCallback)
+ userCallback(null);
+ if (disabled === this.disabled && userCallback)
+ userCallback(this.ownerStyle);
+
+ function callback(stylePayload)
{
- if (!success)
- failureCallback();
+ if (!userCallback)
+ return;
+ if (!stylePayload)
+ userCallback(null);
+ else {
+ var style = WebInspector.CSSStyleDeclaration.parsePayload(stylePayload);
+ userCallback(style);
+ WebInspector.cssModel._styleSheetChanged(this.ownerStyle.id.styleSheetId, false);
+ }
+ }
+
+ InspectorBackend.toggleProperty2(this.ownerStyle.id, this.index, disabled, callback.bind(this));
+ }
+}
+
+WebInspector.CSSStyleSheet = function(payload)
+{
+ this.id = payload.styleSheetId;
+ this.sourceURL = payload.sourceURL;
+ this.title = payload.title;
+ this.disabled = payload.disabled;
+ this.rules = [];
+ this.styles = {};
+ for (var i = 0; i < payload.rules.length; ++i) {
+ var rule = WebInspector.CSSRule.parsePayload(payload.rules[i]);
+ this.rules.push(rule);
+ if (rule.style)
+ this.styles[rule.style.id] = rule.style;
+ }
+ if ("text" in payload)
+ this._text = payload.text;
+}
+
+WebInspector.CSSStyleSheet.createForId = function(styleSheetId, userCallback)
+{
+ function callback(styleSheetPayload)
+ {
+ if (!styleSheetPayload)
+ userCallback(null);
+ else
+ userCallback(new WebInspector.CSSStyleSheet(styleSheetPayload));
+ }
+ InspectorBackend.getStyleSheet2(styleSheetId, callback.bind(this));
+}
+
+WebInspector.CSSStyleSheet.prototype = {
+ getText: function()
+ {
+ return this._text;
+ },
+
+ setText: function(newText, userCallback)
+ {
+ function callback(styleSheetPayload)
+ {
+ if (!styleSheetPayload)
+ userCallback(null);
else {
- var newStyle = newPayload ? WebInspector.CSSStyleDeclaration.parseStyle(newPayload) : null;
- successCallback(newStyle, changedProperties);
+ userCallback(new WebInspector.CSSStyleSheet(styleSheetPayload));
+ WebInspector.cssModel._styleSheetChanged(this.id, true);
}
}
- InspectorBackend.applyStyleText(styleId, styleText, propertyName, callback);
+ InspectorBackend.setStyleSheetText2(this.id, newText, callback.bind(this));
}
}
11 front-end/CallStackSidebarPane.js
View
@@ -173,11 +173,12 @@ WebInspector.CallStackSidebarPane.prototype = {
_breakpointHit: function(event)
{
var breakpoint = event.data.breakpoint;
-
- var statusMessageElement = document.createElement("div");
- statusMessageElement.className = "info";
- breakpoint.populateStatusMessageElement(statusMessageElement, event.data.eventData);
- this.bodyElement.appendChild(statusMessageElement);
+ if (breakpoint.populateStatusMessageElement) {
+ var statusMessageElement = document.createElement("div");
+ statusMessageElement.className = "info";
+ breakpoint.populateStatusMessageElement(statusMessageElement, event.data.eventData);
+ this.bodyElement.appendChild(statusMessageElement);
+ }
}
}
27 front-end/ConsoleView.js
View
@@ -48,7 +48,7 @@ WebInspector.ConsoleView = function(drawer)
this.promptElement.className = "source-code";
this.promptElement.addEventListener("keydown", this._promptKeyDown.bind(this), true);
this.prompt = new WebInspector.TextPrompt(this.promptElement, this.completions.bind(this), ExpressionStopCharacters + ".");
- WebInspector.applicationSettings.addEventListener("loaded", this._settingsLoaded, this);
+ this.prompt.history = WebInspector.settings.consoleHistory;
this.topGroup = new WebInspector.ConsoleGroup(null, 0);
this.messagesElement.insertBefore(this.topGroup.element, this.promptElement);
@@ -102,11 +102,6 @@ WebInspector.ConsoleView = function(drawer)
}
WebInspector.ConsoleView.prototype = {
- _settingsLoaded: function()
- {
- this.prompt.history = WebInspector.applicationSettings.consoleHistory;
- },
-
_updateFilter: function(e)
{
var isMac = WebInspector.isMac();
@@ -223,14 +218,7 @@ WebInspector.ConsoleView.prototype = {
{
if (msg instanceof WebInspector.ConsoleMessage && !(msg instanceof WebInspector.ConsoleCommandResult)) {
this._incrementErrorWarningCount(msg);
-
- // Add message to the resource panel
- if (msg.url in WebInspector.resourceURLMap) {
- msg.resource = WebInspector.resourceURLMap[msg.url];
- if (WebInspector.panels.resources)
- WebInspector.panels.resources.addMessageToResource(msg.resource, msg);
- }
-
+ WebInspector.resourceManager.addConsoleMessage(msg);
this.commandSincePreviousMessage = false;
this.previousMessage = msg;
} else if (msg instanceof WebInspector.ConsoleCommand) {
@@ -301,8 +289,7 @@ WebInspector.ConsoleView.prototype = {
clearMessages: function()
{
- if (WebInspector.panels.resources)
- WebInspector.panels.resources.clearMessages();
+ WebInspector.resourceManager.clearConsoleMessages();
this.messages = [];
@@ -360,7 +347,7 @@ WebInspector.ConsoleView.prototype = {
}
var results = [];
- var properties = Object.sortedProperties(result);
+ var properties = Object.keys(result).sort();
for (var i = 0; i < properties.length; ++i) {
var property = properties[i];
@@ -521,7 +508,7 @@ WebInspector.ConsoleView.prototype = {
_enterKeyPressed: function(event)
{
- if (event.altKey || event.ctrlKey)
+ if (event.altKey || event.ctrlKey || event.shiftKey)
return;
event.preventDefault();
@@ -543,7 +530,7 @@ WebInspector.ConsoleView.prototype = {
self.prompt.historyOffset = 0;
self.prompt.text = "";
- WebInspector.applicationSettings.consoleHistory = self.prompt.history.slice(-30);
+ WebInspector.settings.consoleHistory = self.prompt.history.slice(-30);
self.addMessage(new WebInspector.ConsoleCommandResult(result, commandMessage));
}
@@ -678,7 +665,7 @@ WebInspector.ConsoleMessage.prototype = {
case WebInspector.ConsoleMessage.MessageType.Trace:
case WebInspector.ConsoleMessage.MessageType.UncaughtException:
var ol = document.createElement("ol");
- ol.addStyleClass("stack-trace");
+ ol.className = "outline-disclosure";
var treeOutline = new TreeOutline(ol);
var messageText;
if (this.type === WebInspector.ConsoleMessage.MessageType.Assert)
233 front-end/CookieItemsView.js
View
@@ -32,20 +32,19 @@ WebInspector.CookieItemsView = function(treeElement, cookieDomain)
WebInspector.View.call(this);
this.element.addStyleClass("storage-view");
- this.element.addStyleClass("table");
- this.deleteButton = new WebInspector.StatusBarButton(WebInspector.UIString("Delete"), "delete-storage-status-bar-item");
- this.deleteButton.visible = false;
- this.deleteButton.addEventListener("click", this._deleteButtonClicked.bind(this), false);
+ this._deleteButton = new WebInspector.StatusBarButton(WebInspector.UIString("Delete"), "delete-storage-status-bar-item");
+ this._deleteButton.visible = false;
+ this._deleteButton.addEventListener("click", this._deleteButtonClicked.bind(this), false);
+
+ this._refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"), "refresh-storage-status-bar-item");
+ this._refreshButton.addEventListener("click", this._refreshButtonClicked.bind(this), false);
- this.refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"), "refresh-storage-status-bar-item");
- this.refreshButton.addEventListener("click", this._refreshButtonClicked.bind(this), false);
-
this._treeElement = treeElement;
this._cookieDomain = cookieDomain;
this._emptyMsgElement = document.createElement("div");
- this._emptyMsgElement.className = "storage-table-empty";
+ this._emptyMsgElement.className = "storage-empty-view";
this._emptyMsgElement.textContent = WebInspector.UIString("This site has no cookies.");
this.element.appendChild(this._emptyMsgElement);
}
@@ -53,7 +52,7 @@ WebInspector.CookieItemsView = function(treeElement, cookieDomain)
WebInspector.CookieItemsView.prototype = {
get statusBarItems()
{
- return [this.refreshButton.element, this.deleteButton.element];
+ return [this._refreshButton.element, this._deleteButton.element];
},
show: function(parentElement)
@@ -65,7 +64,13 @@ WebInspector.CookieItemsView.prototype = {
hide: function()
{
WebInspector.View.prototype.hide.call(this);
- this.deleteButton.visible = false;
+ this._deleteButton.visible = false;
+ },
+
+ resize: function()
+ {
+ if (this._cookiesTable)
+ this._cookiesTable.updateWidths();
},
_update: function()
@@ -75,57 +80,45 @@ WebInspector.CookieItemsView.prototype = {
_updateWithCookies: function(allCookies, isAdvanced)
{
- if (isAdvanced)
- this._filterCookiesForDomain(allCookies);
- else
- this._cookies = allCookies;
+ this._cookies = isAdvanced ? this._filterCookiesForDomain(allCookies) : allCookies;
if (!this._cookies.length) {
// Nothing to show.
this._emptyMsgElement.removeStyleClass("hidden");
- this.deleteButton.visible = false;
- if (this._dataGrid)
- this._dataGrid.element.addStyleClass("hidden");
+ this._deleteButton.visible = false;
+ if (this._cookiesTable)
+ this._cookiesTable.element.addStyleClass("hidden");
return;
}
- if (!this._dataGrid) {
- if (isAdvanced) {
- this._createDataGrid();
- this._populateDataGrid();
- this._dataGrid.autoSizeColumns(6, 33);
- this._treeElement.subtitle = String.sprintf(WebInspector.UIString("%d cookies (%s)"), this._cookies.length,
- Number.bytesToString(this._totalSize, WebInspector.UIString));
- } else {
- this._createSimpleDataGrid();
- this._populateSimpleDataGrid();
- this._dataGrid.autoSizeColumns(20, 80);
- }
- } else {
- if (isAdvanced)
- this._populateDataGrid();
- else
- this._populateSimpleDataGrid();
+ if (!this._cookiesTable) {
+ this._cookiesTable = isAdvanced ? new WebInspector.CookiesTable(this._cookieDomain, false, this._deleteCookie.bind(this)) : new WebInspector.SimpleCookiesTable();
+ this.element.appendChild(this._cookiesTable.element);
}
- this._dataGrid.element.removeStyleClass("hidden");
+ this._cookiesTable.setCookies(this._cookies);
+ this._cookiesTable.element.removeStyleClass("hidden");
this._emptyMsgElement.addStyleClass("hidden");
- if (isAdvanced)
- this.deleteButton.visible = true;
+ if (isAdvanced) {
+ this._treeElement.subtitle = String.sprintf(WebInspector.UIString("%d cookies (%s)"), this._cookies.length,
+ Number.bytesToString(this._totalSize, WebInspector.UIString));
+ this._deleteButton.visible = true;
+ }
},
_filterCookiesForDomain: function(allCookies)
{
- this._cookies = [];
+ var cookies = [];
var resourceURLsForDocumentURL = [];
this._totalSize = 0;
- for (var id in WebInspector.resources) {
- var resource = WebInspector.resources[id];
- var match = resource.documentURL.match(WebInspector.GenericURLRegExp);
- if (match && match[2] === this._cookieDomain)
+ function populateResourcesForDocuments(resource)
+ {
+ var url = resource.documentURL.asParsedURL();
+ if (url && url.host == this._cookieDomain)
resourceURLsForDocumentURL.push(resource.url);
}
+ WebInspector.forAllResources(populateResourcesForDocuments.bind(this));
for (var i = 0; i < allCookies.length; ++i) {
var pushed = false;
@@ -136,126 +129,52 @@ WebInspector.CookieItemsView.prototype = {
this._totalSize += size;
if (!pushed) {
pushed = true;
- this._cookies.push(allCookies[i]);
+ cookies.push(allCookies[i]);
}
}
}
}
+ return cookies;
},
- _createDataGrid: function()
+ _deleteCookie: function(cookie)
{
- var columns = { 0: {}, 1: {}, 2: {}, 3: {}, 4: {}, 5: {}, 6: {}, 7: {} };
- columns[0].title = WebInspector.UIString("Name");
- columns[0].sortable = true;
- columns[1].title = WebInspector.UIString("Value");
- columns[1].sortable = true;
- columns[2].title = WebInspector.UIString("Domain");
- columns[2].sortable = true;
- columns[3].title = WebInspector.UIString("Path");
- columns[3].sortable = true;
- columns[4].title = WebInspector.UIString("Expires");
- columns[4].sortable = true;
- columns[5].title = WebInspector.UIString("Size");
- columns[5].aligned = "right";
- columns[5].sortable = true;
- columns[6].title = WebInspector.UIString("HTTP");
- columns[6].aligned = "centered";
- columns[6].sortable = true;
- columns[7].title = WebInspector.UIString("Secure");
- columns[7].aligned = "centered";
- columns[7].sortable = true;
-
- this._dataGrid = new WebInspector.DataGrid(columns, null, this._deleteCookieCallback.bind(this));
- this._dataGrid.addEventListener("sorting changed", this._populateDataGrid, this);
- this.element.appendChild(this._dataGrid.element);
- this._dataGrid.updateWidths();
+ InspectorBackend.deleteCookie(cookie.name, this._cookieDomain);
+ this._update();
},
- _populateDataGrid: function()
+ _deleteButtonClicked: function()
{
- var selectedCookie = this._dataGrid.selectedNode ? this._dataGrid.selectedNode.cookie : null;
- var sortDirection = this._dataGrid.sortOrder === "ascending" ? 1 : -1;
-
- function localeCompare(field, cookie1, cookie2)
- {
- return sortDirection * (cookie1[field] + "").localeCompare(cookie2[field] + "")
- }
-
- function numberCompare(field, cookie1, cookie2)
- {
- return sortDirection * (cookie1[field] - cookie2[field]);
- }
-
- function expiresCompare(cookie1, cookie2)
- {
- if (cookie1.session !== cookie2.session)
- return sortDirection * (cookie1.session ? 1 : -1);
-
- if (cookie1.session)
- return 0;
-
- return sortDirection * (cookie1.expires - cookie2.expires);
- }
-
- var comparator;
- switch (parseInt(this._dataGrid.sortColumnIdentifier)) {
- case 0: comparator = localeCompare.bind(this, "name"); break;
- case 1: comparator = localeCompare.bind(this, "value"); break;
- case 2: comparator = localeCompare.bind(this, "domain"); break;
- case 3: comparator = localeCompare.bind(this, "path"); break;
- case 4: comparator = expiresCompare; break;
- case 5: comparator = numberCompare.bind(this, "size"); break;
- case 6: comparator = localeCompare.bind(this, "httpOnly"); break;
- case 7: comparator = localeCompare.bind(this, "secure"); break;
- default: localeCompare.bind(this, "name");
- }
-
- this._cookies.sort(comparator);
-
- this._dataGrid.removeChildren();
- var nodeToSelect;
- for (var i = 0; i < this._cookies.length; ++i) {
- var data = {};
- var cookie = this._cookies[i];
- data[0] = cookie.name;
- data[1] = cookie.value;
- data[2] = cookie.domain;
- data[3] = cookie.path;
- data[4] = (cookie.session ? WebInspector.UIString("Session") : new Date(cookie.expires).toGMTString());
- data[5] = Number.bytesToString(cookie.size, WebInspector.UIString);
- data[6] = (cookie.httpOnly ? "\u2713" : ""); // Checkmark
- data[7] = (cookie.secure ? "\u2713" : ""); // Checkmark
-
- var node = new WebInspector.DataGridNode(data);
- node.cookie = cookie;
- node.selectable = true;
- this._dataGrid.appendChild(node);
- if (cookie === selectedCookie)
- nodeToSelect = node;
- }
- if (nodeToSelect)
- nodeToSelect.selected = true;
- else
- this._dataGrid.children[0].selected = true;
+ if (this._cookiesTable.selectedCookie)
+ this._deleteCookie(this._cookiesTable.selectedCookie);
},
- _createSimpleDataGrid: function()
+ _refreshButtonClicked: function(event)
{
- var columns = {};
- columns[0] = {};
- columns[1] = {};
- columns[0].title = WebInspector.UIString("Name");
- columns[1].title = WebInspector.UIString("Value");
+ this._update();
+ }
+}
- this._dataGrid = new WebInspector.DataGrid(columns);
- this.element.appendChild(this._dataGrid.element);
- this._dataGrid.updateWidths();
- },
+WebInspector.CookieItemsView.prototype.__proto__ = WebInspector.View.prototype;
+
+WebInspector.SimpleCookiesTable = function()
+{
+ this.element = document.createElement("div");
+ var columns = {};
+ columns[0] = {};
+ columns[1] = {};
+ columns[0].title = WebInspector.UIString("Name");
+ columns[1].title = WebInspector.UIString("Value");
+
+ this._dataGrid = new WebInspector.DataGrid(columns);
+ this._dataGrid.autoSizeColumns(20, 80);
+ this.element.appendChild(this._dataGrid.element);
+ this._dataGrid.updateWidths();
+}
- _populateSimpleDataGrid: function()
+WebInspector.SimpleCookiesTable.prototype = {
+ setCookies: function(cookies)
{
- var cookies = this._cookies;
this._dataGrid.removeChildren();
var addedCookies = {};
for (var i = 0; i < cookies.length; ++i) {
@@ -277,27 +196,5 @@ WebInspector.CookieItemsView.prototype = {
{
if (this._dataGrid)
this._dataGrid.updateWidths();
- },
-
- _deleteButtonClicked: function(event)
- {
- if (!this._dataGrid || !this._dataGrid.selectedNode)
- return;
-
- this._deleteCookieCallback(this._dataGrid.selectedNode);
- },
-
- _deleteCookieCallback: function(node)
- {
- var cookie = node.cookie;
- InspectorBackend.deleteCookie(cookie.name, this._cookieDomain);
- this._update();
- },
-
- _refreshButtonClicked: function(event)
- {
- this._update();
}
}
-
-WebInspector.CookieItemsView.prototype.__proto__ = WebInspector.View.prototype;
210 front-end/CookieParser.js
View
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2010 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
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+// Ideally, we would rely on platform support for parsing a cookie, since