Use an options object in the appendCheckboxItem
Bug: chromium:1467464
Change-Id: I1f01aeca4b98a90de75f87f85b481d15f1dd5479
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5314346
Auto-Submit: Danil Somsikov <[email protected]>
Reviewed-by: Ergün Erdoğmuş <[email protected]>
Commit-Queue: Ergün Erdoğmuş <[email protected]>
Commit-Queue: Danil Somsikov <[email protected]>
diff --git a/front_end/panels/browser_debugger/DOMBreakpointsSidebarPane.ts b/front_end/panels/browser_debugger/DOMBreakpointsSidebarPane.ts
index ce1196d..29151e8 100644
--- a/front_end/panels/browser_debugger/DOMBreakpointsSidebarPane.ts
+++ b/front_end/panels/browser_debugger/DOMBreakpointsSidebarPane.ts
@@ -425,7 +425,7 @@
const label = Sources.DebuggerPausedMessage.BreakpointTypeNouns.get(type);
if (label) {
breakpointsMenu.defaultSection().appendCheckboxItem(
- label(), toggleBreakpoint.bind(null, type), domDebuggerModel.hasDOMBreakpoint(node, type));
+ label(), toggleBreakpoint.bind(null, type), {checked: domDebuggerModel.hasDOMBreakpoint(node, type)});
}
}
}
diff --git a/front_end/panels/console/ConsoleView.ts b/front_end/panels/console/ConsoleView.ts
index 9417566..ffb8dd4 100644
--- a/front_end/panels/console/ConsoleView.ts
+++ b/front_end/panels/console/ConsoleView.ts
@@ -1759,7 +1759,8 @@
contextMenu.headerSection().appendItem(
i18nString(UIStrings.default), () => setting.set(ConsoleFilter.defaultLevelsFilterValue()));
for (const [level, levelText] of this.levelLabels.entries()) {
- contextMenu.defaultSection().appendCheckboxItem(levelText, toggleShowLevel.bind(null, level), levels[level]);
+ contextMenu.defaultSection().appendCheckboxItem(
+ levelText, toggleShowLevel.bind(null, level), {checked: levels[level]});
}
void contextMenu.show();
diff --git a/front_end/panels/elements/ElementsTreeElement.ts b/front_end/panels/elements/ElementsTreeElement.ts
index a318107..f4047df 100644
--- a/front_end/panels/elements/ElementsTreeElement.ts
+++ b/front_end/panels/elements/ElementsTreeElement.ts
@@ -347,8 +347,8 @@
for (const pseudoClass of pseudoClasses) {
const pseudoClassForced = forcedPseudoState ? forcedPseudoState.indexOf(pseudoClass) >= 0 : false;
stateMenu.defaultSection().appendCheckboxItem(
- ':' + pseudoClass, setPseudoStateCallback.bind(null, pseudoClass, !pseudoClassForced), pseudoClassForced,
- false);
+ ':' + pseudoClass, setPseudoStateCallback.bind(null, pseudoClass, !pseudoClassForced),
+ {checked: pseudoClassForced});
}
function setPseudoStateCallback(pseudoState: string, enabled: boolean): void {
@@ -802,7 +802,7 @@
menuItem = contextMenu.debugSection().appendCheckboxItem(
i18nString(UIStrings.hideElement), treeOutline.toggleHideElement.bind(treeOutline, this.nodeInternal),
- treeOutline.isToggledToHidden(this.nodeInternal));
+ {checked: treeOutline.isToggledToHidden(this.nodeInternal)});
menuItem.setShortcut(
UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutTitleForAction('elements.hide-element') || '');
diff --git a/front_end/panels/elements/StylePropertyTreeElement.ts b/front_end/panels/elements/StylePropertyTreeElement.ts
index 26cb243..8b93b98 100644
--- a/front_end/panels/elements/StylePropertyTreeElement.ts
+++ b/front_end/panels/elements/StylePropertyTreeElement.ts
@@ -1419,7 +1419,7 @@
event.consume();
this.parentPaneInternal.continueEditingElement(sectionIndex, propertyIndex);
}
- }, !this.property.disabled);
+ }, {checked: !this.property.disabled});
}
const revealCallback = this.navigateToSource.bind(this) as () => void;
contextMenu.defaultSection().appendItem(i18nString(UIStrings.revealInSourcesPanel), revealCallback);
diff --git a/front_end/panels/emulation/DeviceModeToolbar.ts b/front_end/panels/emulation/DeviceModeToolbar.ts
index a1c6d9b..5604b42 100644
--- a/front_end/panels/emulation/DeviceModeToolbar.ts
+++ b/front_end/panels/emulation/DeviceModeToolbar.ts
@@ -419,8 +419,8 @@
private appendDevicePostureItems(contextMenu: UI.ContextMenu.ContextMenu): void {
for (const title of ['Continuous', 'Folded']) {
contextMenu.defaultSection().appendCheckboxItem(
- title, this.spanClicked.bind(this), title === this.currentDevicePosture(), false, undefined, undefined,
- title.toLowerCase());
+ title, this.spanClicked.bind(this),
+ {checked: title === this.currentDevicePosture(), jslogContext: title.toLowerCase()});
}
}
@@ -442,7 +442,7 @@
}
contextMenu.footerSection().appendCheckboxItem(
i18nString(UIStrings.autoadjustZoom), this.onAutoAdjustScaleChanged.bind(this),
- this.autoAdjustScaleSetting.get(), undefined, undefined, undefined, 'auto-adjust-zoom');
+ {checked: this.autoAdjustScaleSetting.get(), jslogContext: 'auto-adjust-zoom'});
const boundAppendScaleItem = appendScaleItem.bind(this);
boundAppendScaleItem('50%', 0.5);
boundAppendScaleItem('75%', 0.75);
@@ -453,8 +453,8 @@
function appendScaleItem(this: DeviceModeToolbar, title: string, value: number): void {
contextMenu.defaultSection().appendCheckboxItem(
- title, this.onScaleMenuChanged.bind(this, value), this.model.scaleSetting().get() === value, false, undefined,
- undefined, title);
+ title, this.onScaleMenuChanged.bind(this, value),
+ {checked: this.model.scaleSetting().get() === value, jslogContext: title});
}
}
@@ -482,7 +482,7 @@
section: UI.ContextMenu.Section, title: string, value: number, jslogContext: string): void {
section.appendCheckboxItem(
title, deviceScaleFactorSetting.set.bind(deviceScaleFactorSetting, value),
- deviceScaleFactorSetting.get() === value, undefined, undefined, undefined, jslogContext);
+ {checked: deviceScaleFactorSetting.get() === value, jslogContext});
}
}
@@ -495,8 +495,7 @@
function appendUAItem(title: string, value: EmulationModel.DeviceModeModel.UA): void {
contextMenu.defaultSection().appendCheckboxItem(
- title, uaSetting.set.bind(uaSetting, value), uaSetting.get() === value, undefined, undefined, undefined,
- value);
+ title, uaSetting.set.bind(uaSetting, value), {checked: uaSetting.get() === value, jslogContext: value});
}
}
@@ -592,8 +591,7 @@
private appendDeviceMenuItems(contextMenu: UI.ContextMenu.ContextMenu): void {
contextMenu.headerSection().appendCheckboxItem(
i18nString(UIStrings.responsive), this.switchToResponsive.bind(this),
- this.model.type() === EmulationModel.DeviceModeModel.Type.Responsive, false, undefined, undefined,
- 'responsive');
+ {checked: this.model.type() === EmulationModel.DeviceModeModel.Type.Responsive, jslogContext: 'responsive'});
appendGroup.call(this, this.standardDevices());
appendGroup.call(this, this.customDevices());
contextMenu.footerSection().appendItem(
@@ -606,9 +604,10 @@
}
const section = contextMenu.section();
for (const device of devices) {
- section.appendCheckboxItem(
- device.title, this.emulateDevice.bind(this, device), this.model.device() === device, false, undefined,
- undefined, Platform.StringUtilities.toKebabCase(device.title));
+ section.appendCheckboxItem(device.title, this.emulateDevice.bind(this, device), {
+ checked: this.model.device() === device,
+ jslogContext: Platform.StringUtilities.toKebabCase(device.title),
+ });
}
}
}
@@ -734,7 +733,8 @@
}
function addMode(mode: EmulationModel.EmulatedDevices.Mode, title: string): void {
- contextMenu.defaultSection().appendCheckboxItem(title, applyMode.bind(null, mode), model.mode() === mode, false);
+ contextMenu.defaultSection().appendCheckboxItem(
+ title, applyMode.bind(null, mode), {checked: model.mode() === mode});
}
function applyMode(mode: EmulationModel.EmulatedDevices.Mode): void {
diff --git a/front_end/panels/event_listeners/EventListenersView.ts b/front_end/panels/event_listeners/EventListenersView.ts
index 6df4abe..db5e441 100644
--- a/front_end/panels/event_listeners/EventListenersView.ts
+++ b/front_end/panels/event_listeners/EventListenersView.ts
@@ -344,8 +344,8 @@
i18nString(UIStrings.deleteEventListener), this.removeListener.bind(this),
{disabled: !this.eventListenerInternal.canRemove()});
menu.defaultSection().appendCheckboxItem(
- i18nString(UIStrings.passive), this.togglePassiveListener.bind(this), this.eventListenerInternal.passive(),
- !this.eventListenerInternal.canTogglePassive());
+ i18nString(UIStrings.passive), this.togglePassiveListener.bind(this),
+ {checked: this.eventListenerInternal.passive(), disabled: !this.eventListenerInternal.canTogglePassive()});
void menu.show();
});
}
diff --git a/front_end/panels/layer_viewer/LayerViewHost.ts b/front_end/panels/layer_viewer/LayerViewHost.ts
index 6f6c5dd..b113e8a 100644
--- a/front_end/panels/layer_viewer/LayerViewHost.ts
+++ b/front_end/panels/layer_viewer/LayerViewHost.ts
@@ -170,9 +170,10 @@
showContextMenu(contextMenu: UI.ContextMenu.ContextMenu, selection: Selection|null): void {
contextMenu.defaultSection().appendCheckboxItem(
- i18nString(UIStrings.showInternalLayers), this.toggleShowInternalLayers.bind(this),
- this.showInternalLayersSettingInternal.get(), undefined, undefined, undefined,
- this.showInternalLayersSettingInternal.name);
+ i18nString(UIStrings.showInternalLayers), this.toggleShowInternalLayers.bind(this), {
+ checked: this.showInternalLayersSettingInternal.get(),
+ jslogContext: this.showInternalLayersSettingInternal.name,
+ });
const node = selection && selection.layer() && selection.layer().nodeForSelfOrAncestor();
if (node) {
contextMenu.appendApplicableItems(node);
diff --git a/front_end/panels/mobile_throttling/ThrottlingManager.ts b/front_end/panels/mobile_throttling/ThrottlingManager.ts
index 40a7f66..aeed355 100644
--- a/front_end/panels/mobile_throttling/ThrottlingManager.ts
+++ b/front_end/panels/mobile_throttling/ThrottlingManager.ts
@@ -242,8 +242,8 @@
continue;
}
contextMenu.defaultSection().appendCheckboxItem(
- conditions.title, selector.optionSelected.bind(selector, conditions as Conditions), selectedIndex === index,
- undefined, undefined, undefined, conditions.jslogContext);
+ conditions.title, selector.optionSelected.bind(selector, conditions as Conditions),
+ {checked: selectedIndex === index, jslogContext: conditions.jslogContext});
}
}
diff --git a/front_end/panels/network/NetworkLogView.ts b/front_end/panels/network/NetworkLogView.ts
index 99501f5..39a3c83 100644
--- a/front_end/panels/network/NetworkLogView.ts
+++ b/front_end/panels/network/NetworkLogView.ts
@@ -2641,7 +2641,7 @@
contextMenu.defaultSection().appendCheckboxItem(label, () => {
this.setting.get()[name] = !this.setting.get()[name];
this.toggleTypeFilter(name);
- }, this.setting.get()[name], undefined, undefined, undefined, jslogContext);
+ }, {checked: this.setting.get()[name], jslogContext});
}
private toggleTypeFilter(typeName: string): void {
@@ -2853,31 +2853,41 @@
this.contextMenu.defaultSection().appendCheckboxItem(
i18nString(UIStrings.hideDataUrls),
- () => this.networkHideDataURLSetting.set(!this.networkHideDataURLSetting.get()),
- this.networkHideDataURLSetting.get(), undefined, undefined, i18nString(UIStrings.hidesDataAndBlobUrls),
- 'hide-data-urls');
+ () => this.networkHideDataURLSetting.set(!this.networkHideDataURLSetting.get()), {
+ checked: this.networkHideDataURLSetting.get(),
+ tooltip: i18nString(UIStrings.hidesDataAndBlobUrls),
+ jslogContext: 'hide-data-urls',
+ });
this.contextMenu.defaultSection().appendCheckboxItem(
i18nString(UIStrings.chromeExtensions),
- () => this.networkHideChromeExtensionsSetting.set(!this.networkHideChromeExtensionsSetting.get()),
- this.networkHideChromeExtensionsSetting.get(), undefined, undefined, i18nString(UIStrings.hideChromeExtension),
- 'hide-extension-urls');
+ () => this.networkHideChromeExtensionsSetting.set(!this.networkHideChromeExtensionsSetting.get()), {
+ checked: this.networkHideChromeExtensionsSetting.get(),
+ tooltip: i18nString(UIStrings.hideChromeExtension),
+ jslogContext: 'hide-extension-urls',
+ });
this.contextMenu.defaultSection().appendSeparator();
this.contextMenu.defaultSection().appendCheckboxItem(
i18nString(UIStrings.hasBlockedCookies),
- () => this.networkShowBlockedCookiesOnlySetting.set(!this.networkShowBlockedCookiesOnlySetting.get()),
- this.networkShowBlockedCookiesOnlySetting.get(), undefined, undefined,
- i18nString(UIStrings.onlyShowRequestsWithBlockedCookies), 'only-blocked-response-cookies');
+ () => this.networkShowBlockedCookiesOnlySetting.set(!this.networkShowBlockedCookiesOnlySetting.get()), {
+ checked: this.networkShowBlockedCookiesOnlySetting.get(),
+ tooltip: i18nString(UIStrings.onlyShowRequestsWithBlockedCookies),
+ jslogContext: 'only-blocked-response-cookies',
+ });
this.contextMenu.defaultSection().appendCheckboxItem(
i18nString(UIStrings.blockedRequests),
- () => this.networkOnlyBlockedRequestsSetting.set(!this.networkOnlyBlockedRequestsSetting.get()),
- this.networkOnlyBlockedRequestsSetting.get(), undefined, undefined,
- i18nString(UIStrings.onlyShowBlockedRequests), 'only-blocked-requests');
+ () => this.networkOnlyBlockedRequestsSetting.set(!this.networkOnlyBlockedRequestsSetting.get()), {
+ checked: this.networkOnlyBlockedRequestsSetting.get(),
+ tooltip: i18nString(UIStrings.onlyShowBlockedRequests),
+ jslogContext: 'only-blocked-requests',
+ });
this.contextMenu.defaultSection().appendCheckboxItem(
i18nString(UIStrings.thirdParty),
- () => this.networkOnlyThirdPartySetting.set(!this.networkOnlyThirdPartySetting.get()),
- this.networkOnlyThirdPartySetting.get(), undefined, undefined, i18nString(UIStrings.onlyShowThirdPartyRequests),
- 'only-3rd-party-requests');
+ () => this.networkOnlyThirdPartySetting.set(!this.networkOnlyThirdPartySetting.get()), {
+ checked: this.networkOnlyThirdPartySetting.get(),
+ tooltip: i18nString(UIStrings.onlyShowThirdPartyRequests),
+ jslogContext: 'only-3rd-party-requests',
+ });
void this.contextMenu.show();
}
diff --git a/front_end/panels/network/NetworkLogViewColumns.ts b/front_end/panels/network/NetworkLogViewColumns.ts
index 131f219..56f98e6 100644
--- a/front_end/panels/network/NetworkLogViewColumns.ts
+++ b/front_end/panels/network/NetworkLogViewColumns.ts
@@ -648,11 +648,11 @@
for (const columnConfig of group) {
// Make sure that at least one item in every group is enabled
- const isDisabled = visibleColumns.length === 1 && visibleColumns[0] === columnConfig;
+ const disabled = visibleColumns.length === 1 && visibleColumns[0] === columnConfig;
const title = columnConfig.title instanceof Function ? columnConfig.title() : columnConfig.title;
contextMenu.headerSection().appendCheckboxItem(
- title, this.toggleColumnVisibility.bind(this, columnConfig), columnConfig.visible, isDisabled);
+ title, this.toggleColumnVisibility.bind(this, columnConfig), {checked: columnConfig.visible, disabled});
}
contextMenu.headerSection().appendSeparator();
@@ -662,7 +662,7 @@
for (const columnConfig of nonResponseHeadersWithoutGroup) {
const title = columnConfig.title instanceof Function ? columnConfig.title() : columnConfig.title;
contextMenu.headerSection().appendCheckboxItem(
- title, this.toggleColumnVisibility.bind(this, columnConfig), columnConfig.visible);
+ title, this.toggleColumnVisibility.bind(this, columnConfig), {checked: columnConfig.visible});
}
const responseSubMenu = contextMenu.footerSection().appendSubMenuItem(i18nString(UIStrings.responseHeaders));
@@ -670,7 +670,7 @@
for (const columnConfig of responseHeaders) {
const title = columnConfig.title instanceof Function ? columnConfig.title() : columnConfig.title;
responseSubMenu.defaultSection().appendCheckboxItem(
- title, this.toggleColumnVisibility.bind(this, columnConfig), columnConfig.visible);
+ title, this.toggleColumnVisibility.bind(this, columnConfig), {checked: columnConfig.visible});
}
responseSubMenu.footerSection().appendItem(
@@ -680,19 +680,19 @@
const waterfallSubMenu = contextMenu.footerSection().appendSubMenuItem(i18nString(UIStrings.waterfall));
waterfallSubMenu.defaultSection().appendCheckboxItem(
i18nString(UIStrings.startTime), setWaterfallMode.bind(this, waterfallSortIds.StartTime),
- this.activeWaterfallSortId === waterfallSortIds.StartTime);
+ {checked: this.activeWaterfallSortId === waterfallSortIds.StartTime});
waterfallSubMenu.defaultSection().appendCheckboxItem(
i18nString(UIStrings.responseTime), setWaterfallMode.bind(this, waterfallSortIds.ResponseTime),
- this.activeWaterfallSortId === waterfallSortIds.ResponseTime);
+ {checked: this.activeWaterfallSortId === waterfallSortIds.ResponseTime});
waterfallSubMenu.defaultSection().appendCheckboxItem(
i18nString(UIStrings.endTime), setWaterfallMode.bind(this, waterfallSortIds.EndTime),
- this.activeWaterfallSortId === waterfallSortIds.EndTime);
+ {checked: this.activeWaterfallSortId === waterfallSortIds.EndTime});
waterfallSubMenu.defaultSection().appendCheckboxItem(
i18nString(UIStrings.totalDuration), setWaterfallMode.bind(this, waterfallSortIds.Duration),
- this.activeWaterfallSortId === waterfallSortIds.Duration);
+ {checked: this.activeWaterfallSortId === waterfallSortIds.Duration});
waterfallSubMenu.defaultSection().appendCheckboxItem(
i18nString(UIStrings.latency), setWaterfallMode.bind(this, waterfallSortIds.Latency),
- this.activeWaterfallSortId === waterfallSortIds.Latency);
+ {checked: this.activeWaterfallSortId === waterfallSortIds.Latency});
function setWaterfallMode(this: NetworkLogViewColumns, sortId: WaterfallSortIds): void {
let calculator = this.calculatorsMap.get(CalculatorTypes.Time);
diff --git a/front_end/panels/sources/SourcesPanel.ts b/front_end/panels/sources/SourcesPanel.ts
index 51363ff..91cf67c 100644
--- a/front_end/panels/sources/SourcesPanel.ts
+++ b/front_end/panels/sources/SourcesPanel.ts
@@ -567,9 +567,11 @@
groupByFolderSetting.set(groupByFolderSetting.get());
}
- menuSection.appendCheckboxItem(
- menuItem, toggleExperiment, Root.Runtime.experiments.isEnabled(experiment), false,
- IconButton.Icon.create('experiment'), undefined, Platform.StringUtilities.toKebabCase(experiment));
+ menuSection.appendCheckboxItem(menuItem, toggleExperiment, {
+ checked: Root.Runtime.experiments.isEnabled(experiment),
+ additionalElement: IconButton.Icon.create('experiment'),
+ jslogContext: Platform.StringUtilities.toKebabCase(experiment),
+ });
}
private populateNavigatorMenu(contextMenu: UI.ContextMenu.ContextMenu): void {
@@ -577,7 +579,7 @@
contextMenu.appendItemsAtLocation('navigatorMenu');
contextMenu.viewSection().appendCheckboxItem(
i18nString(UIStrings.groupByFolder), () => groupByFolderSetting.set(!groupByFolderSetting.get()),
- groupByFolderSetting.get(), undefined, undefined, undefined, groupByFolderSetting.name);
+ {checked: groupByFolderSetting.get(), jslogContext: groupByFolderSetting.name});
this.addExperimentMenuItem(
contextMenu.viewSection(), Root.Runtime.ExperimentName.AUTHORED_DEPLOYED_GROUPING,