Skip to content

Commit

Permalink
squash 'resources/unpacked/devtools' changes from 57772b8..2342364
Browse files Browse the repository at this point in the history
2342364 DevTools: render product badges behind the setting.
9bf40c1 DevTools: format keys in object previews using sans serif.
cbce35f DevTools: Colorize more types in JS syntax highlighting
1ea1319 DevTools/Coverage: keep old JS coverage after restart
919be47 DevTools: Fix flamechart jumping on mouseout
71e47f5 DevTools/Coverage: add filtering support
4ec103d DevTools: Show product name when available in group by [sub]domain mode.
a76e3d6 DevTools: do not dispose initiators individually in the network panel.
172466d [DevTools] Support async step in from arbitrary position
bc6aed6 [DevTools] Make async step in marker contiguous
570aae3 DevTools: removed unused SettingsUI fieldset builder

git-subtree-dir: resources/unpacked/devtools
git-subtree-split: 2342364
  • Loading branch information
darwin committed May 13, 2017
1 parent fdcd41d commit 5b401aa
Show file tree
Hide file tree
Showing 37 changed files with 604 additions and 260 deletions.
5 changes: 4 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,11 @@ all_devtools_files = [
"front_end/persistence/PersistenceUtils.js",
"front_end/platform/module.json",
"front_end/platform/utilities.js",
"front_end/product_registry/module.json",
"front_end/product_registry/BadgePool.js",
"front_end/product_registry/ProductRegistry.js",
"front_end/product_registry/badge.css",
"front_end/product_registry/module.json",
"front_end/product_registry/popup.css",
"front_end/product_registry_impl/module.json",
"front_end/product_registry_impl/ProductRegistryImpl.js",
"front_end/product_registry_impl/ProductRegistryData.js",
Expand Down
64 changes: 64 additions & 0 deletions front_end/common/Color.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,3 +817,67 @@ Common.Color.PageHighlight = {
Shape: Common.Color.fromRGBA([96, 82, 177, 0.8]),
ShapeMargin: Common.Color.fromRGBA([96, 82, 127, .6])
};

Common.Color.Generator = class {
/**
* @param {!{min: number, max: number}|number=} hueSpace
* @param {!{min: number, max: number, count: (number|undefined)}|number=} satSpace
* @param {!{min: number, max: number, count: (number|undefined)}|number=} lightnessSpace
* @param {!{min: number, max: number, count: (number|undefined)}|number=} alphaSpace
*/
constructor(hueSpace, satSpace, lightnessSpace, alphaSpace) {
this._hueSpace = hueSpace || {min: 0, max: 360};
this._satSpace = satSpace || 67;
this._lightnessSpace = lightnessSpace || 80;
this._alphaSpace = alphaSpace || 1;
/** @type {!Map<string, string>} */
this._colors = new Map();
}

/**
* @param {string} id
* @param {string} color
*/
setColorForID(id, color) {
this._colors.set(id, color);
}

/**
* @param {string} id
* @return {string}
*/
colorForID(id) {
var color = this._colors.get(id);
if (!color) {
color = this._generateColorForID(id);
this._colors.set(id, color);
}
return color;
}

/**
* @param {string} id
* @return {string}
*/
_generateColorForID(id) {
var hash = String.hashCode(id);
var h = this._indexToValueInSpace(hash, this._hueSpace);
var s = this._indexToValueInSpace(hash >> 8, this._satSpace);
var l = this._indexToValueInSpace(hash >> 16, this._lightnessSpace);
var a = this._indexToValueInSpace(hash >> 24, this._alphaSpace);
return `hsla(${h}, ${s}%, ${l}%, ${a})`;
}

/**
* @param {number} index
* @param {!{min: number, max: number, count: (number|undefined)}|number} space
* @return {number}
*/
_indexToValueInSpace(index, space) {
if (typeof space === 'number')
return space;
var count = space.count || space.max - space.min;
index %= count;
return space.min + Math.floor(index / (count - 1) * (space.max - space.min));
}
};
14 changes: 0 additions & 14 deletions front_end/components/Linkifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,20 +264,6 @@ Components.Linkifier = class {
return anchor;
}

/**
* @param {!SDK.Target} target
* @param {!Element} anchor
*/
disposeAnchor(target, anchor) {
Components.Linkifier._unbindUILocation(anchor);
var info = Components.Linkifier._linkInfo(anchor);
info.fallback = null;
if (info.liveLocation) {
info.liveLocation.dispose();
info.liveLocation = null;
}
}

reset() {
for (var target of this._anchorsByTarget.keysArray()) {
this.targetRemoved(target);
Expand Down
69 changes: 66 additions & 3 deletions front_end/coverage/CoverageListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Coverage.CoverageListView = class extends UI.VBox {
super(true);
/** @type {!Map<!Coverage.URLCoverageInfo, !Coverage.CoverageListView.GridNode>} */
this._nodeForCoverageInfo = new Map();
/** @type {?RegExp} */
this._filterRegExp = null;
this.registerRequiredCSS('coverage/coverageListView.css');
var columns = [
{id: 'url', title: Common.UIString('URL'), width: '300px', fixedWidth: false, sortable: true},
Expand Down Expand Up @@ -50,13 +52,16 @@ Coverage.CoverageListView = class extends UI.VBox {
for (var entry of coverageInfo) {
var node = this._nodeForCoverageInfo.get(entry);
if (node) {
hadUpdates = node._refreshIfNeeded(maxSize) || hadUpdates;
if (this._isVisible(node))
hadUpdates = node._refreshIfNeeded(maxSize) || hadUpdates;
continue;
}
hadUpdates = true;
node = new Coverage.CoverageListView.GridNode(entry, maxSize);
this._nodeForCoverageInfo.set(entry, node);
rootNode.appendChild(node);
if (this._isVisible(node)) {
rootNode.appendChild(node);
hadUpdates = true;
}
}
if (hadUpdates)
this._sortingChanged();
Expand All @@ -67,6 +72,29 @@ Coverage.CoverageListView = class extends UI.VBox {
this._dataGrid.rootNode().removeChildren();
}

/**
* @param {?RegExp} regExp
*/
setFilter(regExp) {
this._filterRegExp = regExp;
var hadTreeUpdates = false;
for (var node of this._nodeForCoverageInfo.values()) {
var shouldBeVisible = this._isVisible(node);
var isVisible = !!node.parent;
if (shouldBeVisible)
node._setHighlight(regExp);
if (shouldBeVisible === isVisible)
continue;
hadTreeUpdates = true;
if (!shouldBeVisible)
node.remove();
else
this._dataGrid.rootNode().appendChild(node);
}
if (hadTreeUpdates)
this._sortingChanged();
}

/**
* @param {!Common.Event} event
*/
Expand All @@ -75,6 +103,14 @@ Coverage.CoverageListView = class extends UI.VBox {
this._revealSourceForNode(node);
}

/**
* @param {!Coverage.CoverageListView.GridNode} node
* @return {boolean}
*/
_isVisible(node) {
return !this._filterRegExp || this._filterRegExp.test(node._url);
}

/**
* @param {!Event} event
*/
Expand Down Expand Up @@ -194,6 +230,19 @@ Coverage.CoverageListView.GridNode = class extends DataGrid.SortableDataGridNode
this._lastUsedSize;
this._url = coverageInfo.url();
this._maxSize = maxSize;
this._highlightDOMChanges = [];
/** @type {?RegExp} */
this._highlightRegExp = null;
}

/**
* @param {?RegExp} highlightRegExp
*/
_setHighlight(highlightRegExp) {
if (this._highlightRegExp === highlightRegExp)
return;
this._highlightRegExp = highlightRegExp;
this.refresh();
}

/**
Expand Down Expand Up @@ -225,6 +274,8 @@ Coverage.CoverageListView.GridNode = class extends DataGrid.SortableDataGridNode
var splitURL = /^(.*)(\/[^/]*)$/.exec(this._url);
prefix.textContent = splitURL ? splitURL[1] : this._url;
suffix.textContent = splitURL ? splitURL[2] : '';
if (this._highlightRegExp)
this._highlight(outer, this._url);
break;
case 'type':
cell.textContent = Coverage.CoverageListView._typeToString(this._coverageInfo.type());
Expand All @@ -248,4 +299,16 @@ Coverage.CoverageListView.GridNode = class extends DataGrid.SortableDataGridNode
}
return cell;
}

/**
* @param {!Element} element
* @param {string} textContent
*/
_highlight(element, textContent) {
var matches = this._highlightRegExp.exec(textContent);
if (!matches || !matches.length)
return;
var range = new TextUtils.SourceRange(matches.index, matches[0].length);
UI.highlightRangesWithStyleClass(element, [range], 'filter-highlight');
}
};
34 changes: 26 additions & 8 deletions front_end/coverage/CoverageModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ Coverage.CoverageModel = class extends SDK.SDKModel {
* @return {boolean}
*/
start() {
this._coverageByURL.clear();
if (this._cssModel)
if (this._cssModel) {
// Note there's no JS coverage since JS won't ever return
// coverage twice, even after it's restarted.
this._clearCSS();
this._cssModel.startCoverage();
}
if (this._cpuProfilerModel)
this._cpuProfilerModel.startPreciseCoverage();
return !!(this._cssModel || this._cpuProfilerModel);
Expand Down Expand Up @@ -82,6 +85,23 @@ Coverage.CoverageModel = class extends SDK.SDKModel {
return coverageInfo && coverageInfo.usageForRange(startOffset, endOffset);
}

_clearCSS() {
for (var entry of this._coverageByContentProvider.values()) {
if (entry.type() !== Coverage.CoverageType.CSS)
continue;
var contentProvider = /** @type {!SDK.CSSStyleSheetHeader} */ (entry.contentProvider());
this._coverageByContentProvider.delete(contentProvider);
var key = `${contentProvider.startLine}:${contentProvider.startColumn}`;
var urlEntry = this._coverageByURL.get(entry.url());
if (!urlEntry || !urlEntry._coverageInfoByLocation.delete(key))
continue;
urlEntry._size -= entry._size;
urlEntry._usedSize -= entry._usedSize;
if (!urlEntry._coverageInfoByLocation.size)
this._coverageByURL.delete(entry.url());
}
}

/**
* @return {!Promise<!Array<!Coverage.CoverageInfo>>}
*/
Expand Down Expand Up @@ -292,7 +312,7 @@ Coverage.URLCoverageInfo = class {
var entry = this._coverageInfoByLocation.get(key);

if (!entry) {
entry = new Coverage.CoverageInfo(contentProvider, lineOffset, columnOffset);
entry = new Coverage.CoverageInfo(contentProvider, contentLength);
this._coverageInfoByLocation.set(key, entry);
this._size += contentLength;
this._type |= entry.type();
Expand All @@ -304,13 +324,11 @@ Coverage.URLCoverageInfo = class {
Coverage.CoverageInfo = class {
/**
* @param {!Common.ContentProvider} contentProvider
* @param {number} lineOffset
* @param {number} columnOffset
* @param {number} size
*/
constructor(contentProvider, lineOffset, columnOffset) {
constructor(contentProvider, size) {
this._contentProvider = contentProvider;
this._lineOffset = lineOffset;
this._columnOffset = columnOffset;
this._size = size;
this._usedSize = 0;

if (contentProvider.contentType().isScript()) {
Expand Down
Loading

0 comments on commit 5b401aa

Please sign in to comment.