Skip to content

Commit

Permalink
squash 'resources/unpacked/devtools' changes from 7a4580b..8f5fe51
Browse files Browse the repository at this point in the history
8f5fe51 Exposes the resource type of an intercepted resource
aedf8f1 DevTools: Add keyboard focus highlight when focusing window
c3cf6b3 Revert "[DevTools] Display usage & quota information"
00fca8f DevTools: Promisify DOMDebugger protocol domain.
55bec15 DevTools: move styles sidebar toolbar into StylesSidebarPane
f437817 DevTools: allow setting individual console filter levels.
f0d250d [DevTools] Display usage & quota information
33413c0 DevTools: Promisify CSS protocol domain.
a073969 [DevTools] Make UI.ListModel more array-like and iterable
d498fe3 DevTools: update text inputs to new style
cdb324c DevTools: update buttons to new style
d03677a DevTools: jsdoc for showToolbarPane in Elements
1b3e4c2 Timeline: add shortcuts for showing prev/next recordings
f4e6cd3 DevTools: update dropdowns to new style
ff98574 DevTools: fix BUILD.gn for network_priorities_module

git-subtree-dir: resources/unpacked/devtools
git-subtree-split: 8f5fe51
  • Loading branch information
darwin committed Jun 7, 2017
1 parent 079e8ef commit faf51da
Show file tree
Hide file tree
Showing 55 changed files with 787 additions and 809 deletions.
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ generated_resources = [
"$resources_out_dir/layer_viewer/layer_viewer_module.js",
"$resources_out_dir/layers/layers_module.js",
"$resources_out_dir/network/network_module.js",
"$resources_out_dir/network_priorities/network_priorities_module.js",
"$resources_out_dir/object_ui/object_ui_module.js",
"$resources_out_dir/perf_ui/perf_ui_module.js",
"$resources_out_dir/profiler/profiler_module.js",
Expand Down
6 changes: 3 additions & 3 deletions front_end/Tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -847,10 +847,10 @@

function onExecutionContexts() {
var consoleView = Console.ConsoleView.instance();
var items = consoleView._consoleContextSelector._items;
var selector = consoleView._consoleContextSelector;
var values = [];
for (var i = 0; i < items.length(); ++i)
values.push(consoleView._consoleContextSelector._titleFor(items.itemAtIndex(i)));
for (var item of selector._items)
values.push(selector._titleFor(item));
test.assertEquals('top', values[0]);
test.assertEquals('Simple content script', values[1]);
test.releaseControl();
Expand Down
6 changes: 3 additions & 3 deletions front_end/audits2/Audits2Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Audits2.Audits2Panel = class extends UI.PanelWithSidebar {
'click', () => InspectorFrontendHost.openInNewTab('https://developers.google.com/web/tools/lighthouse/'));

var newButton = UI.createTextButton(
Common.UIString('Perform an audit\u2026'), this._showLauncherUI.bind(this), 'material-button default');
Common.UIString('Perform an audit\u2026'), this._showLauncherUI.bind(this), '', true /* primary */);
landingCenter.appendChild(newButton);
this.setDefaultFocusedElement(newButton);
}
Expand Down Expand Up @@ -190,10 +190,10 @@ Audits2.Audits2Panel = class extends UI.PanelWithSidebar {

var buttonsRow = uiElement.createChild('div', 'audits2-dialog-buttons hbox');
this._startButton =
UI.createTextButton(Common.UIString('Run audit'), this._start.bind(this), 'material-button default');
UI.createTextButton(Common.UIString('Run audit'), this._start.bind(this), '', true /* primary */);
this._updateStartButtonEnabled();
buttonsRow.appendChild(this._startButton);
this._cancelButton = UI.createTextButton(Common.UIString('Cancel'), this._cancel.bind(this), 'material-button');
this._cancelButton = UI.createTextButton(Common.UIString('Cancel'), this._cancel.bind(this));
buttonsRow.appendChild(this._cancelButton);

this._dialog.setSizeBehavior(UI.GlassPane.SizeBehavior.SetExactWidthMaxHeight);
Expand Down
23 changes: 6 additions & 17 deletions front_end/bindings/StylesSourceMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,28 +218,17 @@ Bindings.StylesSourceMapping = class {
* @param {boolean} majorChange
* @return {!Promise<?string>}
*/
_setStyleContent(uiSourceCode, content, majorChange) {
async _setStyleContent(uiSourceCode, content, majorChange) {
var styleSheetIds = this._cssModel.styleSheetIdsForURL(uiSourceCode.url());
if (!styleSheetIds.length)
return Promise.resolve(/** @type {?string} */ ('No stylesheet found: ' + uiSourceCode.url()));

return 'No stylesheet found: ' + uiSourceCode.url();
this._isSettingContent = true;
var promises = styleSheetIds.map(id => this._cssModel.setStyleSheetText(id, content, majorChange));

/**
* @param {?string} error
* @this {Bindings.StylesSourceMapping}
* @return {?string}
*/
function callback(error) {
delete this._isSettingContent;
return error || null;
}

var promises = [];
for (var i = 0; i < styleSheetIds.length; ++i)
promises.push(this._cssModel.setStyleSheetText(styleSheetIds[i], content, majorChange));
var results = await Promise.all(promises);

return Promise.all(promises).spread(callback.bind(this));
delete this._isSettingContent;
return results.find(error => !!error);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions front_end/color_picker/Spectrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ ColorPicker.Spectrum = class extends UI.VBox {
this._displayContainer = this.contentElement.createChild('div', 'spectrum-text source-code');
this._textValues = [];
for (var i = 0; i < 4; ++i) {
var inputValue = this._displayContainer.createChild('input', 'spectrum-text-value');
var inputValue = UI.createInput('spectrum-text-value');
this._displayContainer.appendChild(inputValue);
inputValue.maxLength = 4;
this._textValues.push(inputValue);
inputValue.addEventListener('keydown', this._inputChanged.bind(this), false);
Expand All @@ -97,7 +98,8 @@ ColorPicker.Spectrum = class extends UI.VBox {

// HEX display.
this._hexContainer = this.contentElement.createChild('div', 'spectrum-text spectrum-text-hex source-code');
this._hexValue = this._hexContainer.createChild('input', 'spectrum-text-value');
this._hexValue = UI.createInput('spectrum-text-value');
this._hexContainer.appendChild(this._hexValue);
this._hexValue.maxLength = 7;
this._hexValue.addEventListener('keydown', this._inputChanged.bind(this), false);
this._hexValue.addEventListener('input', this._inputChanged.bind(this), false);
Expand Down
53 changes: 24 additions & 29 deletions front_end/console/ConsoleContextSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Console.ConsoleContextSelector = class {
}

_updateGlasspaneSize() {
var maxHeight = this._rowHeight * (Math.min(this._items.length(), 9));
var maxHeight = this._rowHeight * (Math.min(this._items.length, 9));
this._glassPane.setMaxContentSize(new UI.Size(315, maxHeight));
this._list.viewportResized();
}
Expand Down Expand Up @@ -130,7 +130,7 @@ Console.ConsoleContextSelector = class {
var currentExecutionContext = this._list.selectedItem();
if (!currentExecutionContext)
break;
var nextExecutionContext = this._items.itemAtIndex(this._list.selectedIndex() + 1);
var nextExecutionContext = this._items.at(this._list.selectedIndex() + 1);
if (nextExecutionContext && this._depthFor(currentExecutionContext) < this._depthFor(nextExecutionContext))
handled = this._list.selectNextItem(false, false);
break;
Expand All @@ -140,9 +140,9 @@ Console.ConsoleContextSelector = class {
break;
var depth = this._depthFor(currentExecutionContext);
for (var i = this._list.selectedIndex() - 1; i >= 0; i--) {
if (this._depthFor(this._items.itemAtIndex(i)) < depth) {
if (this._depthFor(this._items.at(i)) < depth) {
handled = true;
this._list.selectItem(this._items.itemAtIndex(i), false);
this._list.selectItem(this._items.at(i), false);
break;
}
}
Expand All @@ -154,18 +154,18 @@ Console.ConsoleContextSelector = class {
handled = this._list.selectItemNextPage(false);
break;
case 'Home':
for (var i = 0; i < this._items.length(); i++) {
if (this.isItemSelectable(this._items.itemAtIndex(i))) {
this._list.selectItem(this._items.itemAtIndex(i));
for (var i = 0; i < this._items.length; i++) {
if (this.isItemSelectable(this._items.at(i))) {
this._list.selectItem(this._items.at(i));
handled = true;
break;
}
}
break;
case 'End':
for (var i = this._items.length() - 1; i >= 0; i--) {
if (this.isItemSelectable(this._items.itemAtIndex(i))) {
this._list.selectItem(this._items.itemAtIndex(i));
for (var i = this._items.length - 1; i >= 0; i--) {
if (this.isItemSelectable(this._items.at(i))) {
this._list.selectItem(this._items.at(i));
handled = true;
break;
}
Expand Down Expand Up @@ -195,8 +195,8 @@ Console.ConsoleContextSelector = class {
if (event.key.length === 1) {
var selectedIndex = this._list.selectedIndex();
var letter = event.key.toUpperCase();
for (var i = 0; i < this._items.length(); i++) {
var context = this._items.itemAtIndex((selectedIndex + i + 1) % this._items.length());
for (var i = 0; i < this._items.length; i++) {
var context = this._items.at((selectedIndex + i + 1) % this._items.length);
if (this._titleFor(context).toUpperCase().startsWith(letter)) {
this._list.selectItem(context);
break;
Expand Down Expand Up @@ -299,7 +299,7 @@ Console.ConsoleContextSelector = class {
if (!executionContext.target().hasJSCapability())
return;

this._items.insertItemWithComparator(executionContext, executionContext.runtimeModel.executionContextComparator());
this._items.insertWithComparator(executionContext, executionContext.runtimeModel.executionContextComparator());

if (executionContext === UI.context.flavor(SDK.ExecutionContext))
this._updateSelectionTitle();
Expand All @@ -320,7 +320,7 @@ Console.ConsoleContextSelector = class {
*/
_onExecutionContextChanged(event) {
var executionContext = /** @type {!SDK.ExecutionContext} */ (event.data);
if (this._items.indexOfItem(executionContext) === -1)
if (this._items.indexOf(executionContext) === -1)
return;
this._executionContextDestroyed(executionContext);
this._executionContextCreated(executionContext);
Expand All @@ -331,10 +331,11 @@ Console.ConsoleContextSelector = class {
* @param {!SDK.ExecutionContext} executionContext
*/
_executionContextDestroyed(executionContext) {
if (this._items.indexOfItem(executionContext) === -1)
var index = this._items.indexOf(executionContext);
if (index === -1)
return;
this._disposeExecutionContextBadge(executionContext);
this._items.removeItem(executionContext);
this._items.remove(index);
this._updateGlasspaneSize();
}

Expand All @@ -352,7 +353,7 @@ Console.ConsoleContextSelector = class {
*/
_executionContextChangedExternally(event) {
var executionContext = /** @type {?SDK.ExecutionContext} */ (event.data);
if (!executionContext || this._items.indexOfItem(executionContext) === -1)
if (!executionContext || this._items.indexOf(executionContext) === -1)
return;
this._list.selectItem(executionContext);
this._updateSelectedContext();
Expand Down Expand Up @@ -386,11 +387,7 @@ Console.ConsoleContextSelector = class {
* @return {boolean}
*/
_hasTopContext() {
for (var i = 0; i < this._items.length(); i++) {
if (this._isTopContext(this._items.itemAtIndex(i)))
return true;
}
return false;
return this._items.some(executionContext => this._isTopContext(executionContext));
}

/**
Expand All @@ -406,9 +403,9 @@ Console.ConsoleContextSelector = class {
* @param {!SDK.RuntimeModel} runtimeModel
*/
modelRemoved(runtimeModel) {
for (var i = 0; i < this._items.length(); i++) {
if (this._items.itemAtIndex(i).runtimeModel === runtimeModel)
this._executionContextDestroyed(this._items.itemAtIndex(i));
for (var i = 0; i < this._items.length; i++) {
if (this._items.at(i).runtimeModel === runtimeModel)
this._executionContextDestroyed(this._items.at(i));
}
}

Expand Down Expand Up @@ -523,8 +520,7 @@ Console.ConsoleContextSelector = class {
*/
_callFrameSelectedInModel(event) {
var debuggerModel = /** @type {!SDK.DebuggerModel} */ (event.data);
for (var i = 0; i < this._items.length(); i++) {
var executionContext = this._items.itemAtIndex(i);
for (var executionContext of this._items) {
if (executionContext.debuggerModel === debuggerModel) {
this._disposeExecutionContextBadge(executionContext);
this._list.refreshItem(executionContext);
Expand All @@ -537,8 +533,7 @@ Console.ConsoleContextSelector = class {
*/
_frameNavigated(event) {
var frameId = event.data.id;
for (var i = 0; i < this._items.length(); i++) {
var executionContext = this._items.itemAtIndex(i);
for (var executionContext of this._items) {
if (frameId === executionContext.frameId) {
this._disposeExecutionContextBadge(executionContext);
this._list.refreshItem(executionContext);
Expand Down
107 changes: 92 additions & 15 deletions front_end/console/ConsoleView.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ Console.ConsoleView = class extends UI.VBox {
toolbar.appendToolbarItem(this._consoleContextSelector.toolbarItem());
toolbar.appendSeparator();
toolbar.appendToolbarItem(this._filter._textFilterUI);
toolbar.appendToolbarItem(this._filter._levelComboBox);
toolbar.appendToolbarItem(this._filter._levelMenuButton);
toolbar.appendToolbarItem(this._filter._levelMenuButtonArrow);
toolbar.appendToolbarItem(this._progressToolbarItem);
toolbar.appendSpacer();
toolbar.appendToolbarItem(this._filterStatusText);
Expand Down Expand Up @@ -1007,8 +1008,8 @@ Console.ConsoleViewFilter = class {
this._filterChanged = filterChangedCallback;

this._messageURLFiltersSetting = Common.settings.createSetting('messageURLFilters', {});
this._messageLevelFiltersSetting =
Common.settings.createSetting('messageLevelFilters2', ConsoleModel.ConsoleMessage.MessageLevel.Info);
this._messageLevelFiltersSetting = Console.ConsoleViewFilter.levelFilterSetting();

this._hideNetworkMessagesSetting = Common.moduleSetting('hideNetworkMessages');
this._filterByExecutionContextSetting = Common.moduleSetting('selectedContextFilterEnabled');
this._filterByConsoleAPISetting = Common.moduleSetting('consoleAPIFilterEnabled');
Expand All @@ -1022,15 +1023,92 @@ Console.ConsoleViewFilter = class {
this._textFilterUI = new UI.ToolbarInput(Common.UIString('Filter'), 0.2, 1, true);
this._textFilterUI.addEventListener(UI.ToolbarInput.Event.TextChanged, this._textFilterChanged, this);

var levels = [
{value: ConsoleModel.ConsoleMessage.MessageLevel.Verbose, label: Common.UIString('Verbose')},
{value: ConsoleModel.ConsoleMessage.MessageLevel.Info, label: Common.UIString('Info'), default: true},
{value: ConsoleModel.ConsoleMessage.MessageLevel.Warning, label: Common.UIString('Warnings')},
{value: ConsoleModel.ConsoleMessage.MessageLevel.Error, label: Common.UIString('Errors')}
];
this._levelLabels = {};
this._levelLabels[ConsoleModel.ConsoleMessage.MessageLevel.Verbose] = Common.UIString('Verbose');
this._levelLabels[ConsoleModel.ConsoleMessage.MessageLevel.Info] = Common.UIString('Info');
this._levelLabels[ConsoleModel.ConsoleMessage.MessageLevel.Warning] = Common.UIString('Warnings');
this._levelLabels[ConsoleModel.ConsoleMessage.MessageLevel.Error] = Common.UIString('Errors');

this._levelMenuButton = new UI.ToolbarText('');
this._levelMenuButtonArrow = new UI.ToolbarItem(UI.Icon.create('smallicon-triangle-down'));
this._levelMenuButton.element.addEventListener('click', this._showLevelContextMenu.bind(this));
this._levelMenuButtonArrow.element.addEventListener('click', this._showLevelContextMenu.bind(this));

this._updateLevelMenuButtonText();
this._messageLevelFiltersSetting.addChangeListener(this._updateLevelMenuButtonText.bind(this));
}

/**
* @return {!Common.Setting}
*/
static levelFilterSetting() {
return Common.settings.createSetting('messageLevelFilters', Console.ConsoleViewFilter.defaultLevelsFilterValue());
}

/**
* @return {!Object<string, boolean>}
*/
static allLevelsFilterValue() {
var result = {};
for (var name of Object.values(ConsoleModel.ConsoleMessage.MessageLevel))
result[name] = true;
return result;
}

/**
* @return {!Object<string, boolean>}
*/
static defaultLevelsFilterValue() {
var result = Console.ConsoleViewFilter.allLevelsFilterValue();
result[ConsoleModel.ConsoleMessage.MessageLevel.Verbose] = false;
return result;
}

_updateLevelMenuButtonText() {
var isAll = true;
var isDefault = true;
var allValue = Console.ConsoleViewFilter.allLevelsFilterValue();
var defaultValue = Console.ConsoleViewFilter.defaultLevelsFilterValue();

var text = null;
var levels = this._messageLevelFiltersSetting.get();
for (var name of Object.values(ConsoleModel.ConsoleMessage.MessageLevel)) {
isAll = isAll && levels[name] === allValue[name];
isDefault = isDefault && levels[name] === defaultValue[name];
if (levels[name])
text = text ? Common.UIString('Custom levels') : Common.UIString('%s only', this._levelLabels[name]);
}
if (isAll)
text = Common.UIString('All levels');
else if (isDefault)
text = Common.UIString('Default levels');
else
text = text || Common.UIString('Hide all');
this._levelMenuButton.setText(text);
}

/**
* @param {!Event} event
*/
_showLevelContextMenu(event) {
var setting = this._messageLevelFiltersSetting;
var levels = setting.get();

var contextMenu = new UI.ContextMenu(event, true);
contextMenu.appendItem(
Common.UIString('Default'), () => setting.set(Console.ConsoleViewFilter.defaultLevelsFilterValue()));
contextMenu.appendSeparator();
for (var level in this._levelLabels)
contextMenu.appendCheckboxItem(this._levelLabels[level], toggleShowLevel.bind(null, level), levels[level]);
contextMenu.show();

this._levelComboBox =
new UI.ToolbarSettingComboBox(levels, this._messageLevelFiltersSetting, Common.UIString('Level'));
/**
* @param {string} level
*/
function toggleShowLevel(level) {
levels[level] = !levels[level];
setting.set(levels);
}
}

_textFilterChanged() {
Expand Down Expand Up @@ -1104,9 +1182,8 @@ Console.ConsoleViewFilter = class {
if (message.url && this._messageURLFiltersSetting.get()[message.url])
return false;

var filterOrdinal = ConsoleModel.ConsoleMessage.MessageLevel.ordinal(
/** @type {!ConsoleModel.ConsoleMessage.MessageLevel} */ (this._messageLevelFiltersSetting.get()));
if (message.level && ConsoleModel.ConsoleMessage.MessageLevel.ordinal(message.level) < filterOrdinal)
var levels = this._messageLevelFiltersSetting.get();
if (!levels[message.level])
return false;

if (this._filterRegex) {
Expand All @@ -1126,7 +1203,7 @@ Console.ConsoleViewFilter = class {

reset() {
this._messageURLFiltersSetting.set({});
this._messageLevelFiltersSetting.set(ConsoleModel.ConsoleMessage.MessageLevel.Info);
this._messageLevelFiltersSetting.set(Console.ConsoleViewFilter.defaultLevelsFilterValue());
this._filterByExecutionContextSetting.set(false);
this._filterByConsoleAPISetting.set(false);
this._hideNetworkMessagesSetting.set(false);
Expand Down
Loading

0 comments on commit faf51da

Please sign in to comment.