chrome-devtools-frontend 1.0.1672388 → 1.0.1674545
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/eslint.config.mjs +3 -3
- package/front_end/core/common/SettingRegistration.ts +1 -26
- package/front_end/core/common/Settings.ts +4 -53
- package/front_end/core/host/UserMetrics.ts +127 -117
- package/front_end/core/protocol_client/PuppeteerDevToolsConnection.ts +42 -9
- package/front_end/core/root/Runtime.ts +7 -2
- package/front_end/core/sdk/NetworkManager.ts +0 -35
- package/front_end/core/sdk/SourceMap.ts +1 -19
- package/front_end/core/sdk/SourceMapManager.ts +75 -48
- package/front_end/core/sdk/SourceMapScopesInfo.ts +0 -62
- package/front_end/devtools_compatibility.js +1 -1
- package/front_end/generated/InspectorBackendCommands.ts +4 -3
- package/front_end/generated/{SupportedCSSProperties.js → SupportedCSSProperties.ts} +32 -1
- package/front_end/generated/protocol-mapping.d.ts +8 -0
- package/front_end/generated/protocol-proxy-api.d.ts +6 -0
- package/front_end/generated/protocol.ts +16 -2
- package/front_end/models/ai_assistance/AiSetting.ts +66 -3
- package/front_end/models/ai_assistance/agents/PerformanceAgent.snapshot.txt +1 -1
- package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.ts +4 -3
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +1 -1
- package/front_end/models/bindings/CompilerScriptMapping.ts +1 -1
- package/front_end/models/emulation/DeviceModeModel.ts +25 -34
- package/front_end/models/emulation/EmulatedDevices.ts +1 -1
- package/front_end/models/javascript_metadata/NativeFunctions.js +4 -4
- package/front_end/models/trace/ModelImpl.ts +5 -0
- package/front_end/models/trace/Processor.ts +47 -10
- package/front_end/models/trace/handlers/LayoutShiftsHandler.ts +18 -19
- package/front_end/models/trace/handlers/MetaHandler.ts +46 -9
- package/front_end/models/trace/handlers/PageLoadMetricsHandler.ts +11 -0
- package/front_end/models/trace/insights/CLSCulprits.ts +1 -2
- package/front_end/models/trace/insights/CharacterSet.ts +1 -1
- package/front_end/models/trace/insights/Common.ts +21 -2
- package/front_end/models/trace/insights/DocumentLatency.ts +1 -1
- package/front_end/models/trace/insights/LCPBreakdown.ts +7 -6
- package/front_end/models/trace/insights/LCPDiscovery.ts +1 -1
- package/front_end/models/trace/insights/ModernHTTP.ts +7 -3
- package/front_end/models/trace/insights/NetworkDependencyTree.ts +1 -1
- package/front_end/models/trace/insights/RenderBlocking.ts +1 -1
- package/front_end/models/trace/insights/ThirdParties.ts +5 -2
- package/front_end/models/trace/insights/types.ts +11 -6
- package/front_end/models/trace/types/Configuration.ts +5 -0
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +11 -10
- package/front_end/panels/ai_assistance/ai_assistance-meta.ts +3 -45
- package/front_end/panels/application/BackgroundServiceView.ts +42 -40
- package/front_end/panels/application/KeyValueStorageItemsView.ts +1 -0
- package/front_end/panels/common/ExtensionServer.ts +7 -1
- package/front_end/panels/common/common.ts +0 -1
- package/front_end/panels/console/ConsoleInsightTeaser.ts +7 -6
- package/front_end/panels/console/ConsoleViewMessage.ts +1 -1
- package/front_end/panels/elements/ClassesPaneWidget.ts +2 -2
- package/front_end/panels/elements/ElementsTreeElement.ts +56 -5
- package/front_end/panels/elements/StylesSidebarPane.ts +1 -1
- package/front_end/panels/elements/components/AdornerManager.ts +1 -0
- package/front_end/panels/emulation/AdvancedApp.ts +3 -3
- package/front_end/panels/emulation/DeviceModeToolbar.ts +2 -11
- package/front_end/panels/emulation/DeviceModeView.ts +234 -75
- package/front_end/panels/emulation/InspectedPagePlaceholder.ts +1 -1
- package/front_end/panels/emulation/deviceModeView.css +4 -21
- package/front_end/panels/emulation/emulation-meta.ts +4 -30
- package/front_end/panels/emulation/emulation.ts +0 -3
- package/front_end/panels/explain/components/ConsoleInsight.ts +11 -7
- package/front_end/panels/layers/LayersPanel.ts +2 -2
- package/front_end/panels/layers/layers-meta.ts +2 -2
- package/front_end/panels/lighthouse/LighthouseController.ts +3 -7
- package/front_end/panels/mobile_throttling/CPUThrottlingSelector.ts +313 -0
- package/front_end/panels/mobile_throttling/NetworkPanelIndicator.ts +0 -10
- package/front_end/panels/mobile_throttling/NetworkThrottlingSelector.ts +23 -10
- package/front_end/panels/mobile_throttling/mobile_throttling.ts +3 -0
- package/front_end/panels/network/NetworkConfigView.ts +1 -71
- package/front_end/panels/network/networkConfigView.css +1 -2
- package/front_end/panels/profiler/HeapDetachedElementsDataGrid.ts +3 -3
- package/front_end/panels/profiler/HeapDetachedElementsView.ts +5 -5
- package/front_end/panels/profiler/HeapProfileView.ts +32 -32
- package/front_end/panels/profiler/HeapProfilerPanel.ts +2 -2
- package/front_end/panels/profiler/HeapSnapshotDataGrids.ts +33 -37
- package/front_end/panels/profiler/HeapSnapshotGridNodes.ts +26 -27
- package/front_end/panels/profiler/HeapSnapshotView.ts +48 -48
- package/front_end/panels/profiler/IsolateSelector.ts +10 -10
- package/front_end/panels/profiler/ModuleUIStrings.ts +25 -25
- package/front_end/panels/profiler/ProfileLauncherView.ts +6 -6
- package/front_end/panels/profiler/ProfilesPanel.ts +6 -6
- package/front_end/panels/profiler/WritableProfileHeader.ts +6 -6
- package/front_end/panels/profiler/profiler-meta.ts +7 -7
- package/front_end/panels/recorder/RecorderPanel.ts +1 -1
- package/front_end/panels/settings/AISettingsTab.ts +27 -23
- package/front_end/panels/settings/emulation/DevicesSettingsTab.ts +463 -13
- package/front_end/panels/timeline/TimelineFlameChartNetworkDataProvider.ts +12 -17
- package/front_end/panels/timeline/TimelinePanel.ts +22 -35
- package/front_end/panels/timeline/components/CWVMetrics.ts +16 -3
- package/front_end/panels/timeline/components/LiveMetricsView.ts +27 -6
- package/front_end/panels/timeline/components/NetworkTrackWidget.ts +1 -1
- package/front_end/panels/timeline/components/components.ts +0 -4
- package/front_end/panels/timeline/components/cwvMetrics.css +4 -0
- package/front_end/panels/timeline/components/liveMetricsView.css +7 -17
- package/front_end/panels/timeline/components/metricValueStyles.css +17 -0
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/third_party/puppeteer/README.chromium +2 -2
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.d.ts +64 -15
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +65 -16
- package/front_end/third_party/puppeteer/package/lib/puppeteer/api/Page.d.ts +50 -7
- package/front_end/third_party/puppeteer/package/lib/puppeteer/api/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/api/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/BidiOverCdp.d.ts +2 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/BidiOverCdp.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/BidiOverCdp.js +5 -5
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/BidiOverCdp.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/Connection.d.ts +2 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/Connection.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/Connection.js +8 -6
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/Connection.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/Dialog.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/Dialog.js +3 -0
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/Dialog.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Browser.js +16 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Connection.d.ts +5 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Connection.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Connection.js +11 -6
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Connection.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Dialog.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Dialog.js +5 -0
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Dialog.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/NetworkManager.js +10 -0
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/NetworkManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/BrowserConnector.js +4 -3
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/BrowserConnector.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/Debug.d.ts +27 -2
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/Debug.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/Debug.js +12 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/Debug.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/util.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/util.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/util.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/util.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/node/ChromeLauncher.js +2 -0
- package/front_end/third_party/puppeteer/package/lib/puppeteer/node/ChromeLauncher.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/node/ScreenRecorder.d.ts +2 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/node/ScreenRecorder.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/node/ScreenRecorder.js +5 -4
- package/front_end/third_party/puppeteer/package/lib/puppeteer/node/ScreenRecorder.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/revisions.d.ts +3 -3
- package/front_end/third_party/puppeteer/package/lib/puppeteer/revisions.js +3 -3
- package/front_end/third_party/puppeteer/package/lib/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/types.d.ts +64 -15
- package/front_end/third_party/puppeteer/package/package.json +2 -2
- package/front_end/third_party/puppeteer/package/src/api/Page.ts +50 -7
- package/front_end/third_party/puppeteer/package/src/bidi/BidiOverCdp.ts +9 -7
- package/front_end/third_party/puppeteer/package/src/bidi/Connection.ts +9 -6
- package/front_end/third_party/puppeteer/package/src/bidi/Dialog.ts +4 -0
- package/front_end/third_party/puppeteer/package/src/cdp/Browser.ts +24 -1
- package/front_end/third_party/puppeteer/package/src/cdp/Connection.ts +11 -6
- package/front_end/third_party/puppeteer/package/src/cdp/Dialog.ts +7 -0
- package/front_end/third_party/puppeteer/package/src/cdp/NetworkManager.ts +11 -0
- package/front_end/third_party/puppeteer/package/src/common/BrowserConnector.ts +7 -3
- package/front_end/third_party/puppeteer/package/src/common/Debug.ts +30 -5
- package/front_end/third_party/puppeteer/package/src/common/util.ts +2 -2
- package/front_end/third_party/puppeteer/package/src/node/ChromeLauncher.ts +2 -0
- package/front_end/third_party/puppeteer/package/src/node/ScreenRecorder.ts +6 -4
- package/front_end/third_party/puppeteer/package/src/revisions.ts +3 -3
- package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
- package/front_end/third_party/source-map-scopes-codec/package/CONTRIBUTING.md +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/LICENSE +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/README.md +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts.map +1 -1
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/scopes.d.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/scopes.d.ts.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/deno.json +1 -1
- package/front_end/third_party/source-map-scopes-codec/package/package.json +1 -1
- package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js +2 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js.map +1 -1
- package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.ts +2 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/codec.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/codec.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/codec.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/mod.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/mod.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/mod.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/scopes.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/scopes.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/scopes.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/util.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/util.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/util.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/vlq.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/vlq.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/vlq.ts +0 -0
- package/front_end/ui/components/dialogs/ShortcutDialog.ts +2 -0
- package/front_end/ui/components/settings/SettingCheckbox.ts +4 -12
- package/front_end/ui/components/settings/settingCheckbox.css +0 -7
- package/front_end/ui/legacy/Treeoutline.ts +14 -14
- package/front_end/ui/legacy/UIUtils.ts +2 -47
- package/front_end/ui/legacy/Widget.ts +10 -2
- package/front_end/ui/legacy/components/settings_ui/SettingsUI.ts +1 -1
- package/front_end/ui/lit/Directives.ts +80 -0
- package/front_end/ui/lit/lit.ts +1 -0
- package/front_end/ui/lit/render.ts +8 -0
- package/front_end/ui/visual_logging/KnownContextValues.ts +18 -0
- package/mcp/mcp.ts +1 -0
- package/package.json +1 -1
- package/front_end/panels/common/ThrottlingUtils.ts +0 -51
- package/front_end/panels/emulation/DeviceModeWrapper.ts +0 -248
- package/front_end/panels/timeline/components/CPUThrottlingSelector.ts +0 -235
- package/front_end/panels/timeline/components/NetworkThrottlingSelector.ts +0 -245
- package/front_end/panels/timeline/components/cpuThrottlingSelector.css +0 -30
- package/front_end/panels/timeline/components/networkThrottlingSelector.css +0 -24
- /package/front_end/core/host/{UserMetricsEnums.d.ts → UserMetricsEnums.ts} +0 -0
- /package/front_end/generated/{ARIAProperties.js → ARIAProperties.ts} +0 -0
|
@@ -250,7 +250,8 @@ interface SettingItem {
|
|
|
250
250
|
|
|
251
251
|
interface AiSettingParams {
|
|
252
252
|
settingName: Platform.UIString.LocalizedString;
|
|
253
|
-
setting?: Common.Settings.Setting<boolean>;
|
|
253
|
+
setting?: Common.Settings.Setting<boolean>|AiAssistanceModel.AiSetting.AiSetting<boolean>;
|
|
254
|
+
disabledReasons?: Platform.UIString.LocalizedString[];
|
|
254
255
|
iconName: string;
|
|
255
256
|
settingDescription: Platform.UIString.LocalizedString;
|
|
256
257
|
enableSettingText: Common.UIString.LocalizedString;
|
|
@@ -320,6 +321,9 @@ export const AI_SETTINGS_TAB_DEFAULT_VIEW: View = (input, _output, target): void
|
|
|
320
321
|
open: settingData.settingExpandState.isSettingExpanded,
|
|
321
322
|
};
|
|
322
323
|
const tabindex = settingData.settingExpandState.isSettingExpanded ? '0' : '-1';
|
|
324
|
+
const isSettingDisabled = isDisabled ||
|
|
325
|
+
Boolean(settingData.disabledReasons?.length) ||
|
|
326
|
+
(settingData.setting instanceof AiAssistanceModel.AiSetting.AiSetting && settingData.setting.disabled);
|
|
323
327
|
return html`
|
|
324
328
|
<div class="accordion-header" @click=${input.expandSetting.bind(this, settingName)}>
|
|
325
329
|
<div class="icon-container centered">
|
|
@@ -350,9 +354,9 @@ export const AI_SETTINGS_TAB_DEFAULT_VIEW: View = (input, _output, target): void
|
|
|
350
354
|
@click=${settingData.setting ? input.toggleSetting.bind(this, settingName) : nothing}
|
|
351
355
|
>
|
|
352
356
|
<devtools-switch
|
|
353
|
-
.checked=${isChecked && !
|
|
357
|
+
.checked=${isChecked && !isSettingDisabled}
|
|
354
358
|
.jslogContext=${settingName}
|
|
355
|
-
.disabled=${
|
|
359
|
+
.disabled=${isSettingDisabled || !settingData.setting}
|
|
356
360
|
.label=${disabledReasonsJoined || settingData.enableSettingText}
|
|
357
361
|
data-testid=${settingData.enableSettingText}
|
|
358
362
|
@switchchange=${settingData.setting ? input.toggleSetting.bind(this, settingName) : nothing}
|
|
@@ -398,9 +402,9 @@ export const AI_SETTINGS_TAB_DEFAULT_VIEW: View = (input, _output, target): void
|
|
|
398
402
|
|
|
399
403
|
export class AISettingsTab extends UI.Widget.VBox {
|
|
400
404
|
#view: View;
|
|
401
|
-
#consoleInsightsSetting
|
|
405
|
+
#consoleInsightsSetting: AiAssistanceModel.AiSetting.AiSetting<boolean>;
|
|
402
406
|
#aiAnnotationsSetting?: Common.Settings.Setting<boolean>;
|
|
403
|
-
#aiAssistanceSetting
|
|
407
|
+
#aiAssistanceSetting: AiAssistanceModel.AiSetting.AiSetting<boolean>;
|
|
404
408
|
#aiCodeCompletionSetting?: Common.Settings.Setting<boolean>;
|
|
405
409
|
#aidaAvailability = Host.AidaClient.AidaAccessPreconditions.NO_ACCOUNT_EMAIL;
|
|
406
410
|
#boundOnAidaAvailabilityChange:
|
|
@@ -411,17 +415,16 @@ export class AISettingsTab extends UI.Widget.VBox {
|
|
|
411
415
|
|
|
412
416
|
constructor(view?: View) {
|
|
413
417
|
super();
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
}
|
|
418
|
+
this.#consoleInsightsSetting = new AiAssistanceModel.AiSetting.AiSetting(
|
|
419
|
+
AiAssistanceModel.AiUtils.consoleInsightsEnabledSettingDescriptor,
|
|
420
|
+
Host.AidaClient.HostConfigTracker.instance(),
|
|
421
|
+
Common.Settings.Settings.instance(),
|
|
422
|
+
);
|
|
423
|
+
this.#aiAssistanceSetting = new AiAssistanceModel.AiSetting.AiSetting(
|
|
424
|
+
AiAssistanceModel.AiUtils.aiAssistanceEnabledSettingDescriptor,
|
|
425
|
+
Host.AidaClient.HostConfigTracker.instance(),
|
|
426
|
+
Common.Settings.Settings.instance(),
|
|
427
|
+
);
|
|
425
428
|
|
|
426
429
|
if (Root.Runtime.hostConfig.devToolsAiGeneratedTimelineLabels?.enabled) {
|
|
427
430
|
// Get an existing setting or, if it does not exist, create a new one.
|
|
@@ -481,11 +484,10 @@ export class AISettingsTab extends UI.Widget.VBox {
|
|
|
481
484
|
Platform.assertNever(precondition, `Unknown precondition: ${precondition}`);
|
|
482
485
|
}
|
|
483
486
|
}
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
[];
|
|
487
|
+
const settingDisabledReasons = Array.from(new Set([
|
|
488
|
+
...this.#mapSettingDisabledReasons(this.#consoleInsightsSetting.disabledReasons),
|
|
489
|
+
...this.#mapSettingDisabledReasons(this.#aiAssistanceSetting.disabledReasons),
|
|
490
|
+
]));
|
|
489
491
|
return [...mappedReasons, ...settingDisabledReasons];
|
|
490
492
|
}
|
|
491
493
|
|
|
@@ -522,10 +524,11 @@ export class AISettingsTab extends UI.Widget.VBox {
|
|
|
522
524
|
const noLogging = Root.Runtime.hostConfig.aidaAvailability?.enterprisePolicyValue ===
|
|
523
525
|
Root.Runtime.GenAiEnterprisePolicyValue.ALLOW_WITHOUT_LOGGING;
|
|
524
526
|
|
|
525
|
-
if (this.#consoleInsightsSetting) {
|
|
527
|
+
if (!this.#consoleInsightsSetting.unavailable) {
|
|
526
528
|
const consoleInsightsData: AiSettingParams = {
|
|
527
529
|
settingName: i18n.i18n.lockedString('Console Insights'),
|
|
528
530
|
setting: this.#consoleInsightsSetting,
|
|
531
|
+
disabledReasons: this.#mapSettingDisabledReasons(this.#consoleInsightsSetting.disabledReasons),
|
|
529
532
|
iconName: 'lightbulb-spark',
|
|
530
533
|
settingDescription: i18nString(UIStrings.helpUnderstandConsole),
|
|
531
534
|
enableSettingText: i18nString(UIStrings.enableConsoleInsights),
|
|
@@ -551,11 +554,12 @@ export class AISettingsTab extends UI.Widget.VBox {
|
|
|
551
554
|
this.#settingToParams.set('console-insights-enabled', consoleInsightsData);
|
|
552
555
|
}
|
|
553
556
|
|
|
554
|
-
if (this.#aiAssistanceSetting) {
|
|
557
|
+
if (!this.#aiAssistanceSetting.unavailable) {
|
|
555
558
|
const aiAssistanceData: AiSettingParams = {
|
|
556
559
|
settingName: i18n.i18n.lockedString(AiAssistanceModel.AiUtils.isGeminiBranding() ? 'Gemini in Chrome DevTools' :
|
|
557
560
|
'AI assistance'),
|
|
558
561
|
setting: this.#aiAssistanceSetting,
|
|
562
|
+
disabledReasons: this.#mapSettingDisabledReasons(this.#aiAssistanceSetting.disabledReasons),
|
|
559
563
|
iconName: AiAssistanceModel.AiUtils.getIconName(),
|
|
560
564
|
settingDescription: this.#getAiAssistanceSettingDescription(),
|
|
561
565
|
enableSettingText: i18nString(UIStrings.enableAiAssistance),
|
|
@@ -105,6 +105,108 @@ const UIStrings = {
|
|
|
105
105
|
* @example {9999} PH3
|
|
106
106
|
*/
|
|
107
107
|
safeAreaValueMustBeInRange: '{PH1}: {PH2} must be an integer from 0 to {PH3}.',
|
|
108
|
+
/**
|
|
109
|
+
* @description Error message shown when custom device safe-area left and right insets are too large.
|
|
110
|
+
* @example {Portrait safe area} PH1
|
|
111
|
+
*/
|
|
112
|
+
safeAreaHorizontalInsetsExceedWidth: '{PH1}: Left and right insets must not exceed the device width.',
|
|
113
|
+
/**
|
|
114
|
+
* @description Error message shown when custom device safe-area top and bottom insets are too large.
|
|
115
|
+
* @example {Landscape safe area} PH1
|
|
116
|
+
*/
|
|
117
|
+
safeAreaVerticalInsetsExceedHeight: '{PH1}: Top and bottom insets must not exceed the device height.',
|
|
118
|
+
/**
|
|
119
|
+
* @description Label for display cutout values on a custom device.
|
|
120
|
+
*/
|
|
121
|
+
displayCutout: 'Display cutout',
|
|
122
|
+
/**
|
|
123
|
+
* @description Option shown when a custom device has no display cutout.
|
|
124
|
+
*/
|
|
125
|
+
noDisplayCutout: 'No cutout',
|
|
126
|
+
/**
|
|
127
|
+
* @description Option shown for pill-shaped display cutouts such as Dynamic Island.
|
|
128
|
+
*/
|
|
129
|
+
pillDisplayCutout: 'Pill',
|
|
130
|
+
/**
|
|
131
|
+
* @description Option shown for classic notch display cutouts.
|
|
132
|
+
*/
|
|
133
|
+
notchDisplayCutout: 'Notch',
|
|
134
|
+
/**
|
|
135
|
+
* @description Option shown for circular display cutouts such as hole-punch cameras.
|
|
136
|
+
*/
|
|
137
|
+
circleDisplayCutout: 'Circle',
|
|
138
|
+
/**
|
|
139
|
+
* @description Option shown for rectangular display cutouts.
|
|
140
|
+
*/
|
|
141
|
+
rectangleDisplayCutout: 'Rectangle',
|
|
142
|
+
/**
|
|
143
|
+
* @description Placeholder text for a custom device display cutout x coordinate field.
|
|
144
|
+
*/
|
|
145
|
+
cutoutX: 'Cutout x',
|
|
146
|
+
/**
|
|
147
|
+
* @description Placeholder text for a custom device display cutout y coordinate field.
|
|
148
|
+
*/
|
|
149
|
+
cutoutY: 'Cutout y',
|
|
150
|
+
/**
|
|
151
|
+
* @description Placeholder text for a custom device display cutout width field.
|
|
152
|
+
*/
|
|
153
|
+
cutoutWidth: 'Cutout width',
|
|
154
|
+
/**
|
|
155
|
+
* @description Placeholder text for a custom device display cutout height field.
|
|
156
|
+
*/
|
|
157
|
+
cutoutHeight: 'Cutout height',
|
|
158
|
+
/**
|
|
159
|
+
* @description Placeholder text for a custom device pill-shaped display cutout radius field.
|
|
160
|
+
*/
|
|
161
|
+
cutoutBorderRadius: 'Pill radius',
|
|
162
|
+
/**
|
|
163
|
+
* @description Placeholder text for a custom device notch upper radius field.
|
|
164
|
+
*/
|
|
165
|
+
cutoutUpperRadius: 'Upper radius',
|
|
166
|
+
/**
|
|
167
|
+
* @description Placeholder text for a custom device notch lower radius field.
|
|
168
|
+
*/
|
|
169
|
+
cutoutLowerRadius: 'Lower radius',
|
|
170
|
+
/**
|
|
171
|
+
* @description Placeholder text for a custom device circular display cutout center x coordinate field.
|
|
172
|
+
*/
|
|
173
|
+
cutoutCenterX: 'Center x',
|
|
174
|
+
/**
|
|
175
|
+
* @description Placeholder text for a custom device circular display cutout center y coordinate field.
|
|
176
|
+
*/
|
|
177
|
+
cutoutCenterY: 'Center y',
|
|
178
|
+
/**
|
|
179
|
+
* @description Placeholder text for a custom device circular display cutout radius field.
|
|
180
|
+
*/
|
|
181
|
+
cutoutRadius: 'Radius',
|
|
182
|
+
/**
|
|
183
|
+
* @description Error message shown when a custom display cutout field is required.
|
|
184
|
+
* @example {Cutout width} PH1
|
|
185
|
+
*/
|
|
186
|
+
cutoutFieldRequired: '{PH1} is required when display cutout is enabled.',
|
|
187
|
+
/**
|
|
188
|
+
* @description Error message shown when a custom display cutout field is outside its supported integer range.
|
|
189
|
+
* @example {Cutout x} PH1
|
|
190
|
+
* @example {9999} PH2
|
|
191
|
+
*/
|
|
192
|
+
cutoutValueMustBeInRange: '{PH1} must be an integer from 0 to {PH2}.',
|
|
193
|
+
/**
|
|
194
|
+
* @description Error message shown when a custom display cutout field must be positive.
|
|
195
|
+
* @example {Cutout width} PH1
|
|
196
|
+
*/
|
|
197
|
+
cutoutValueMustBePositiveInteger: '{PH1} must be a positive integer.',
|
|
198
|
+
/**
|
|
199
|
+
* @description Error message shown when a custom display cutout's x coordinate plus its width exceeds the device width.
|
|
200
|
+
*/
|
|
201
|
+
cutoutXAndWidthExceedDeviceWidth: 'Cutout x plus width must not exceed the device width.',
|
|
202
|
+
/**
|
|
203
|
+
* @description Error message shown when a custom display cutout's y coordinate plus its height exceeds the device height.
|
|
204
|
+
*/
|
|
205
|
+
cutoutYAndHeightExceedDeviceHeight: 'Cutout y plus height must not exceed the device height.',
|
|
206
|
+
/**
|
|
207
|
+
* @description Error message shown when a circular display cutout is outside its cutout bounds.
|
|
208
|
+
*/
|
|
209
|
+
circleMustFitCutoutBounds: 'Circle must fit within the cutout bounds.',
|
|
108
210
|
} as const;
|
|
109
211
|
const str_ = i18n.i18n.registerUIStrings('panels/settings/emulation/DevicesSettingsTab.ts', UIStrings);
|
|
110
212
|
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
@@ -125,6 +227,25 @@ function parseOptionalNonNegativeInteger(value: string): number|null {
|
|
|
125
227
|
return parsedValue;
|
|
126
228
|
}
|
|
127
229
|
|
|
230
|
+
const NO_CUSTOM_CUTOUT = 'none';
|
|
231
|
+
|
|
232
|
+
type DeviceEditorValidator = (item: EmulationModel.EmulatedDevices.EmulatedDevice, index: number,
|
|
233
|
+
input: UI.ListWidget.EditorControl) => UI.ListWidget.ValidatorResult;
|
|
234
|
+
|
|
235
|
+
interface CutoutFieldValidators {
|
|
236
|
+
shape: DeviceEditorValidator;
|
|
237
|
+
x: DeviceEditorValidator;
|
|
238
|
+
y: DeviceEditorValidator;
|
|
239
|
+
width: DeviceEditorValidator;
|
|
240
|
+
height: DeviceEditorValidator;
|
|
241
|
+
pillRadius: DeviceEditorValidator;
|
|
242
|
+
notchUpperRadius: DeviceEditorValidator;
|
|
243
|
+
notchLowerRadius: DeviceEditorValidator;
|
|
244
|
+
circleCenterX: DeviceEditorValidator;
|
|
245
|
+
circleCenterY: DeviceEditorValidator;
|
|
246
|
+
circleRadius: DeviceEditorValidator;
|
|
247
|
+
}
|
|
248
|
+
|
|
128
249
|
export class DevicesSettingsTab extends UI.Widget.VBox implements
|
|
129
250
|
UI.ListWidget.Delegate<EmulationModel.EmulatedDevices.EmulatedDevice> {
|
|
130
251
|
containerElement: HTMLElement;
|
|
@@ -323,6 +444,10 @@ export class DevicesSettingsTab extends UI.Widget.VBox implements
|
|
|
323
444
|
if (safeAreaInsets) {
|
|
324
445
|
verticalMode.safeAreaInsets = safeAreaInsets;
|
|
325
446
|
}
|
|
447
|
+
const cutout = this.cutoutFromEditor(editor);
|
|
448
|
+
if (cutout) {
|
|
449
|
+
verticalMode.cutout = cutout;
|
|
450
|
+
}
|
|
326
451
|
device.modes.push(verticalMode);
|
|
327
452
|
const horizontalMode: EmulationModel.EmulatedDevices.Mode = {
|
|
328
453
|
title: '',
|
|
@@ -379,6 +504,7 @@ export class DevicesSettingsTab extends UI.Widget.VBox implements
|
|
|
379
504
|
editor.control('scale').value = this.toNumericInputValue(device.deviceScaleFactor);
|
|
380
505
|
editor.control('user-agent').value = device.userAgent;
|
|
381
506
|
this.populateSafeAreaEditor(editor, device);
|
|
507
|
+
this.populateCutoutEditor(editor, device);
|
|
382
508
|
let uaType;
|
|
383
509
|
if (device.mobile()) {
|
|
384
510
|
uaType =
|
|
@@ -406,6 +532,44 @@ export class DevicesSettingsTab extends UI.Widget.VBox implements
|
|
|
406
532
|
return new EmulationModel.DeviceModeModel.Insets(left, top, right, bottom);
|
|
407
533
|
}
|
|
408
534
|
|
|
535
|
+
private cutoutFromEditor(editor: UI.ListWidget.Editor<EmulationModel.EmulatedDevices.EmulatedDevice>):
|
|
536
|
+
EmulationModel.EmulatedDevices.Cutout|null {
|
|
537
|
+
const shape = editor.control('cutout-shape').value;
|
|
538
|
+
const baseCutout = {
|
|
539
|
+
x: this.editorIntegerValue(editor, 'cutout-x'),
|
|
540
|
+
y: this.editorIntegerValue(editor, 'cutout-y'),
|
|
541
|
+
width: this.editorIntegerValue(editor, 'cutout-width'),
|
|
542
|
+
height: this.editorIntegerValue(editor, 'cutout-height'),
|
|
543
|
+
};
|
|
544
|
+
switch (shape) {
|
|
545
|
+
case EmulationModel.EmulatedDevices.CutoutShape.PILL:
|
|
546
|
+
return {
|
|
547
|
+
shape,
|
|
548
|
+
...baseCutout,
|
|
549
|
+
borderRadius: this.editorIntegerValue(editor, 'cutout-border-radius'),
|
|
550
|
+
};
|
|
551
|
+
case EmulationModel.EmulatedDevices.CutoutShape.NOTCH:
|
|
552
|
+
return {
|
|
553
|
+
shape,
|
|
554
|
+
...baseCutout,
|
|
555
|
+
upperRadius: this.editorIntegerValue(editor, 'cutout-upper-radius'),
|
|
556
|
+
lowerRadius: this.editorIntegerValue(editor, 'cutout-lower-radius'),
|
|
557
|
+
};
|
|
558
|
+
case EmulationModel.EmulatedDevices.CutoutShape.CIRCLE:
|
|
559
|
+
return {
|
|
560
|
+
shape,
|
|
561
|
+
...baseCutout,
|
|
562
|
+
cx: this.editorIntegerValue(editor, 'cutout-cx'),
|
|
563
|
+
cy: this.editorIntegerValue(editor, 'cutout-cy'),
|
|
564
|
+
radius: this.editorIntegerValue(editor, 'cutout-radius'),
|
|
565
|
+
};
|
|
566
|
+
case EmulationModel.EmulatedDevices.CutoutShape.RECTANGLE:
|
|
567
|
+
return {shape, ...baseCutout};
|
|
568
|
+
default:
|
|
569
|
+
return null;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
409
573
|
private populateSafeAreaEditor(editor: UI.ListWidget.Editor<EmulationModel.EmulatedDevices.EmulatedDevice>,
|
|
410
574
|
device: EmulationModel.EmulatedDevices.EmulatedDevice): void {
|
|
411
575
|
const safeAreaInsets = this.verticalMode(device)?.safeAreaInsets;
|
|
@@ -421,6 +585,53 @@ export class DevicesSettingsTab extends UI.Widget.VBox implements
|
|
|
421
585
|
editor.control('landscape-safe-area-bottom').value = this.toNumericInputValue(landscapeSafeAreaInsets?.bottom || 0);
|
|
422
586
|
}
|
|
423
587
|
|
|
588
|
+
private populateCutoutEditor(editor: UI.ListWidget.Editor<EmulationModel.EmulatedDevices.EmulatedDevice>,
|
|
589
|
+
device: EmulationModel.EmulatedDevices.EmulatedDevice): void {
|
|
590
|
+
const cutout = this.verticalMode(device)?.cutout;
|
|
591
|
+
editor.control('cutout-shape').value = cutout?.shape || NO_CUSTOM_CUTOUT;
|
|
592
|
+
editor.control('cutout-x').value = String(cutout?.x ?? '');
|
|
593
|
+
editor.control('cutout-y').value = String(cutout?.y ?? '');
|
|
594
|
+
editor.control('cutout-width').value = String(cutout?.width ?? '');
|
|
595
|
+
editor.control('cutout-height').value = String(cutout?.height ?? '');
|
|
596
|
+
editor.control('cutout-border-radius').value =
|
|
597
|
+
String(cutout?.shape === EmulationModel.EmulatedDevices.CutoutShape.PILL ? cutout.borderRadius : '');
|
|
598
|
+
editor.control('cutout-upper-radius').value =
|
|
599
|
+
String(cutout?.shape === EmulationModel.EmulatedDevices.CutoutShape.NOTCH ? cutout.upperRadius : '');
|
|
600
|
+
editor.control('cutout-lower-radius').value =
|
|
601
|
+
String(cutout?.shape === EmulationModel.EmulatedDevices.CutoutShape.NOTCH ? cutout.lowerRadius : '');
|
|
602
|
+
editor.control('cutout-cx').value =
|
|
603
|
+
String(cutout?.shape === EmulationModel.EmulatedDevices.CutoutShape.CIRCLE ? cutout.cx : '');
|
|
604
|
+
editor.control('cutout-cy').value =
|
|
605
|
+
String(cutout?.shape === EmulationModel.EmulatedDevices.CutoutShape.CIRCLE ? cutout.cy : '');
|
|
606
|
+
editor.control('cutout-radius').value =
|
|
607
|
+
String(cutout?.shape === EmulationModel.EmulatedDevices.CutoutShape.CIRCLE ? cutout.radius : '');
|
|
608
|
+
this.updateCutoutFieldsVisibility(editor);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
private updateCutoutFieldsVisibility(editor: UI.ListWidget.Editor<EmulationModel.EmulatedDevices.EmulatedDevice>):
|
|
612
|
+
void {
|
|
613
|
+
const shape = editor.control('cutout-shape').value;
|
|
614
|
+
const noCutout = shape === NO_CUSTOM_CUTOUT;
|
|
615
|
+
const isPill = shape === EmulationModel.EmulatedDevices.CutoutShape.PILL;
|
|
616
|
+
const isNotch = shape === EmulationModel.EmulatedDevices.CutoutShape.NOTCH;
|
|
617
|
+
const isCircle = shape === EmulationModel.EmulatedDevices.CutoutShape.CIRCLE;
|
|
618
|
+
const content = editor.contentElement();
|
|
619
|
+
const rectRow = content.querySelector<HTMLElement>('.devices-edit-cutout-rect-row');
|
|
620
|
+
const radiusRow = content.querySelector<HTMLElement>('.devices-edit-cutout-radius-row');
|
|
621
|
+
if (rectRow) {
|
|
622
|
+
rectRow.hidden = noCutout;
|
|
623
|
+
}
|
|
624
|
+
if (radiusRow) {
|
|
625
|
+
radiusRow.hidden = noCutout || !(isPill || isNotch || isCircle);
|
|
626
|
+
}
|
|
627
|
+
(editor.control('cutout-border-radius') as HTMLElement).hidden = !isPill;
|
|
628
|
+
(editor.control('cutout-upper-radius') as HTMLElement).hidden = !isNotch;
|
|
629
|
+
(editor.control('cutout-lower-radius') as HTMLElement).hidden = !isNotch;
|
|
630
|
+
(editor.control('cutout-cx') as HTMLElement).hidden = !isCircle;
|
|
631
|
+
(editor.control('cutout-cy') as HTMLElement).hidden = !isCircle;
|
|
632
|
+
(editor.control('cutout-radius') as HTMLElement).hidden = !isCircle;
|
|
633
|
+
}
|
|
634
|
+
|
|
424
635
|
private createEditor(): UI.ListWidget.Editor<EmulationModel.EmulatedDevices.EmulatedDevice> {
|
|
425
636
|
if (this.editor) {
|
|
426
637
|
return this.editor;
|
|
@@ -446,6 +657,19 @@ export class DevicesSettingsTab extends UI.Widget.VBox implements
|
|
|
446
657
|
portraitSafeAreaValidator);
|
|
447
658
|
this.appendSafeAreaFields(editor, deviceFields, i18nString(UIStrings.landscapeSafeArea), 'landscape-',
|
|
448
659
|
landscapeSafeAreaValidator);
|
|
660
|
+
this.appendCutoutFields(editor, content, {
|
|
661
|
+
shape: cutoutShapeValidator,
|
|
662
|
+
x: cutoutXValidator,
|
|
663
|
+
y: cutoutYValidator,
|
|
664
|
+
width: cutoutWidthValidator,
|
|
665
|
+
height: cutoutHeightValidator,
|
|
666
|
+
pillRadius: cutoutPillRadiusValidator,
|
|
667
|
+
notchUpperRadius: cutoutNotchUpperRadiusValidator,
|
|
668
|
+
notchLowerRadius: cutoutNotchLowerRadiusValidator,
|
|
669
|
+
circleCenterX: cutoutCircleCenterXValidator,
|
|
670
|
+
circleCenterY: cutoutCircleCenterYValidator,
|
|
671
|
+
circleRadius: cutoutCircleRadiusValidator,
|
|
672
|
+
});
|
|
449
673
|
|
|
450
674
|
const uaStringFields = content.createChild('div', 'devices-edit-fields');
|
|
451
675
|
UI.UIUtils.createTextChild(uaStringFields.createChild('b'), i18nString(UIStrings.userAgentString));
|
|
@@ -524,30 +748,206 @@ export class DevicesSettingsTab extends UI.Widget.VBox implements
|
|
|
524
748
|
return EmulationModel.DeviceModeModel.DeviceModeModel.scaleValidator(input.value);
|
|
525
749
|
}
|
|
526
750
|
|
|
527
|
-
function
|
|
751
|
+
function nonNegativeIntegerValue(controlName: string): number|null {
|
|
752
|
+
return parseOptionalNonNegativeInteger(editor.control(controlName).value);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
function positiveIntegerValue(controlName: string): number|null {
|
|
756
|
+
const value = nonNegativeIntegerValue(controlName);
|
|
757
|
+
return value && value > 0 ? value : null;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
function requiredIntegerValue(controlName: string): number|null {
|
|
761
|
+
const value = editor.control(controlName).value.trim();
|
|
762
|
+
return value ? parseOptionalNonNegativeInteger(value) : null;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
function controlLabel(input: UI.ListWidget.EditorControl): string {
|
|
766
|
+
return input.getAttribute('aria-label') || input.getAttribute('placeholder') || '';
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
function safeAreaValidator(controlPrefix: string, orientationLabel: string, widthControlName: string,
|
|
770
|
+
heightControlName: string,
|
|
528
771
|
input: UI.ListWidget.EditorControl): UI.ListWidget.ValidatorResult {
|
|
529
|
-
|
|
530
|
-
|
|
772
|
+
const ownValue = parseOptionalNonNegativeInteger(input.value);
|
|
773
|
+
if (ownValue === null) {
|
|
774
|
+
return {
|
|
775
|
+
valid: false,
|
|
776
|
+
errorMessage: i18nString(UIStrings.safeAreaValueMustBeInRange, {
|
|
777
|
+
PH1: orientationLabel,
|
|
778
|
+
PH2: input.getAttribute('aria-label') || input.getAttribute('placeholder') || '',
|
|
779
|
+
PH3: EmulationModel.DeviceModeModel.MaxDeviceSize,
|
|
780
|
+
}),
|
|
781
|
+
};
|
|
531
782
|
}
|
|
532
783
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
784
|
+
const left = nonNegativeIntegerValue(`${controlPrefix}safe-area-left`);
|
|
785
|
+
const top = nonNegativeIntegerValue(`${controlPrefix}safe-area-top`);
|
|
786
|
+
const right = nonNegativeIntegerValue(`${controlPrefix}safe-area-right`);
|
|
787
|
+
const bottom = nonNegativeIntegerValue(`${controlPrefix}safe-area-bottom`);
|
|
788
|
+
const width = positiveIntegerValue(widthControlName);
|
|
789
|
+
const height = positiveIntegerValue(heightControlName);
|
|
790
|
+
if (input === editor.control(`${controlPrefix}safe-area-right`) && left !== null && right !== null &&
|
|
791
|
+
width !== null && left + right > width) {
|
|
792
|
+
return {
|
|
793
|
+
valid: false,
|
|
794
|
+
errorMessage: i18nString(UIStrings.safeAreaHorizontalInsetsExceedWidth, {PH1: orientationLabel}),
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
if (input === editor.control(`${controlPrefix}safe-area-bottom`) && top !== null && bottom !== null &&
|
|
798
|
+
height !== null && top + bottom > height) {
|
|
799
|
+
return {
|
|
800
|
+
valid: false,
|
|
801
|
+
errorMessage: i18nString(UIStrings.safeAreaVerticalInsetsExceedHeight, {PH1: orientationLabel}),
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
return {valid: true};
|
|
541
805
|
}
|
|
542
806
|
|
|
543
807
|
function portraitSafeAreaValidator(_item: EmulationModel.EmulatedDevices.EmulatedDevice, _index: number,
|
|
544
808
|
input: UI.ListWidget.EditorControl): UI.ListWidget.ValidatorResult {
|
|
545
|
-
return safeAreaValidator(i18nString(UIStrings.portraitSafeArea), input);
|
|
809
|
+
return safeAreaValidator('', i18nString(UIStrings.portraitSafeArea), 'width', 'height', input);
|
|
546
810
|
}
|
|
547
811
|
|
|
548
812
|
function landscapeSafeAreaValidator(_item: EmulationModel.EmulatedDevices.EmulatedDevice, _index: number,
|
|
549
813
|
input: UI.ListWidget.EditorControl): UI.ListWidget.ValidatorResult {
|
|
550
|
-
return safeAreaValidator(i18nString(UIStrings.landscapeSafeArea), input);
|
|
814
|
+
return safeAreaValidator('landscape-', i18nString(UIStrings.landscapeSafeArea), 'height', 'width', input);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
function cutoutShapeValidator(): UI.ListWidget.ValidatorResult {
|
|
818
|
+
return {valid: true};
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
function cutoutValueValidator(input: UI.ListWidget.EditorControl,
|
|
822
|
+
mustBePositive = false): UI.ListWidget.ValidatorResult {
|
|
823
|
+
const label = controlLabel(input);
|
|
824
|
+
const value = input.value.trim();
|
|
825
|
+
if (!value) {
|
|
826
|
+
return {valid: false, errorMessage: i18nString(UIStrings.cutoutFieldRequired, {PH1: label})};
|
|
827
|
+
}
|
|
828
|
+
const numericValue = parseOptionalNonNegativeInteger(value);
|
|
829
|
+
if (numericValue === null) {
|
|
830
|
+
return {
|
|
831
|
+
valid: false,
|
|
832
|
+
errorMessage: i18nString(UIStrings.cutoutValueMustBeInRange, {
|
|
833
|
+
PH1: label,
|
|
834
|
+
PH2: EmulationModel.DeviceModeModel.MaxDeviceSize,
|
|
835
|
+
}),
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
if (mustBePositive && numericValue === 0) {
|
|
839
|
+
return {valid: false, errorMessage: i18nString(UIStrings.cutoutValueMustBePositiveInteger, {PH1: label})};
|
|
840
|
+
}
|
|
841
|
+
return {valid: true};
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
function isCutoutFieldActive(shape?: EmulationModel.EmulatedDevices.CutoutShape): boolean {
|
|
845
|
+
const selectedShape = editor.control('cutout-shape').value;
|
|
846
|
+
return selectedShape !== NO_CUSTOM_CUTOUT && (shape === undefined || selectedShape === shape);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
function cutoutXValidator(_item: EmulationModel.EmulatedDevices.EmulatedDevice, _index: number,
|
|
850
|
+
input: UI.ListWidget.EditorControl): UI.ListWidget.ValidatorResult {
|
|
851
|
+
return isCutoutFieldActive() ? cutoutValueValidator(input) : {valid: true};
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
function cutoutYValidator(_item: EmulationModel.EmulatedDevices.EmulatedDevice, _index: number,
|
|
855
|
+
input: UI.ListWidget.EditorControl): UI.ListWidget.ValidatorResult {
|
|
856
|
+
return isCutoutFieldActive() ? cutoutValueValidator(input) : {valid: true};
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
function cutoutWidthValidator(_item: EmulationModel.EmulatedDevices.EmulatedDevice, _index: number,
|
|
860
|
+
input: UI.ListWidget.EditorControl): UI.ListWidget.ValidatorResult {
|
|
861
|
+
if (!isCutoutFieldActive()) {
|
|
862
|
+
return {valid: true};
|
|
863
|
+
}
|
|
864
|
+
const validation = cutoutValueValidator(input, true);
|
|
865
|
+
if (!validation.valid) {
|
|
866
|
+
return validation;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
const cutoutX = requiredIntegerValue('cutout-x');
|
|
870
|
+
const cutoutWidth = positiveIntegerValue('cutout-width');
|
|
871
|
+
const width = positiveIntegerValue('width');
|
|
872
|
+
if (width !== null && cutoutX !== null && cutoutWidth !== null && cutoutX + cutoutWidth > width) {
|
|
873
|
+
return {valid: false, errorMessage: i18nString(UIStrings.cutoutXAndWidthExceedDeviceWidth)};
|
|
874
|
+
}
|
|
875
|
+
return {valid: true};
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
function cutoutHeightValidator(_item: EmulationModel.EmulatedDevices.EmulatedDevice, _index: number,
|
|
879
|
+
input: UI.ListWidget.EditorControl): UI.ListWidget.ValidatorResult {
|
|
880
|
+
if (!isCutoutFieldActive()) {
|
|
881
|
+
return {valid: true};
|
|
882
|
+
}
|
|
883
|
+
const validation = cutoutValueValidator(input, true);
|
|
884
|
+
if (!validation.valid) {
|
|
885
|
+
return validation;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
const cutoutY = requiredIntegerValue('cutout-y');
|
|
889
|
+
const cutoutHeight = positiveIntegerValue('cutout-height');
|
|
890
|
+
const height = positiveIntegerValue('height');
|
|
891
|
+
if (height !== null && cutoutY !== null && cutoutHeight !== null && cutoutY + cutoutHeight > height) {
|
|
892
|
+
return {valid: false, errorMessage: i18nString(UIStrings.cutoutYAndHeightExceedDeviceHeight)};
|
|
893
|
+
}
|
|
894
|
+
return {valid: true};
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
function cutoutPillRadiusValidator(_item: EmulationModel.EmulatedDevices.EmulatedDevice, _index: number,
|
|
898
|
+
input: UI.ListWidget.EditorControl): UI.ListWidget.ValidatorResult {
|
|
899
|
+
return isCutoutFieldActive(EmulationModel.EmulatedDevices.CutoutShape.PILL) ? cutoutValueValidator(input) :
|
|
900
|
+
{valid: true};
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
function cutoutNotchUpperRadiusValidator(_item: EmulationModel.EmulatedDevices.EmulatedDevice, _index: number,
|
|
904
|
+
input: UI.ListWidget.EditorControl): UI.ListWidget.ValidatorResult {
|
|
905
|
+
return isCutoutFieldActive(EmulationModel.EmulatedDevices.CutoutShape.NOTCH) ? cutoutValueValidator(input) :
|
|
906
|
+
{valid: true};
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
function cutoutNotchLowerRadiusValidator(_item: EmulationModel.EmulatedDevices.EmulatedDevice, _index: number,
|
|
910
|
+
input: UI.ListWidget.EditorControl): UI.ListWidget.ValidatorResult {
|
|
911
|
+
return isCutoutFieldActive(EmulationModel.EmulatedDevices.CutoutShape.NOTCH) ? cutoutValueValidator(input) :
|
|
912
|
+
{valid: true};
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
function cutoutCircleCenterXValidator(_item: EmulationModel.EmulatedDevices.EmulatedDevice, _index: number,
|
|
916
|
+
input: UI.ListWidget.EditorControl): UI.ListWidget.ValidatorResult {
|
|
917
|
+
return isCutoutFieldActive(EmulationModel.EmulatedDevices.CutoutShape.CIRCLE) ? cutoutValueValidator(input) :
|
|
918
|
+
{valid: true};
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
function cutoutCircleCenterYValidator(_item: EmulationModel.EmulatedDevices.EmulatedDevice, _index: number,
|
|
922
|
+
input: UI.ListWidget.EditorControl): UI.ListWidget.ValidatorResult {
|
|
923
|
+
return isCutoutFieldActive(EmulationModel.EmulatedDevices.CutoutShape.CIRCLE) ? cutoutValueValidator(input) :
|
|
924
|
+
{valid: true};
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
function cutoutCircleRadiusValidator(_item: EmulationModel.EmulatedDevices.EmulatedDevice, _index: number,
|
|
928
|
+
input: UI.ListWidget.EditorControl): UI.ListWidget.ValidatorResult {
|
|
929
|
+
if (!isCutoutFieldActive(EmulationModel.EmulatedDevices.CutoutShape.CIRCLE)) {
|
|
930
|
+
return {valid: true};
|
|
931
|
+
}
|
|
932
|
+
const validation = cutoutValueValidator(input, true);
|
|
933
|
+
if (!validation.valid) {
|
|
934
|
+
return validation;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
const cutoutX = requiredIntegerValue('cutout-x');
|
|
938
|
+
const cutoutY = requiredIntegerValue('cutout-y');
|
|
939
|
+
const cutoutWidth = positiveIntegerValue('cutout-width');
|
|
940
|
+
const cutoutHeight = positiveIntegerValue('cutout-height');
|
|
941
|
+
const centerX = requiredIntegerValue('cutout-cx');
|
|
942
|
+
const centerY = requiredIntegerValue('cutout-cy');
|
|
943
|
+
const radius = positiveIntegerValue('cutout-radius');
|
|
944
|
+
if (cutoutX !== null && cutoutY !== null && cutoutWidth !== null && cutoutHeight !== null && centerX !== null &&
|
|
945
|
+
centerY !== null && radius !== null &&
|
|
946
|
+
(centerX - radius < cutoutX || centerX + radius > cutoutX + cutoutWidth || centerY - radius < cutoutY ||
|
|
947
|
+
centerY + radius > cutoutY + cutoutHeight)) {
|
|
948
|
+
return {valid: false, errorMessage: i18nString(UIStrings.circleMustFitCutoutBounds)};
|
|
949
|
+
}
|
|
950
|
+
return {valid: true};
|
|
551
951
|
}
|
|
552
952
|
}
|
|
553
953
|
|
|
@@ -572,4 +972,54 @@ export class DevicesSettingsTab extends UI.Widget.VBox implements
|
|
|
572
972
|
safeAreaRow.appendChild(editor.createInput(`${controlPrefix}safe-area-bottom`, 'text',
|
|
573
973
|
i18nString(UIStrings.safeAreaBottom), safeAreaValidator));
|
|
574
974
|
}
|
|
975
|
+
|
|
976
|
+
private appendCutoutFields(editor: UI.ListWidget.Editor<EmulationModel.EmulatedDevices.EmulatedDevice>,
|
|
977
|
+
content: Element, validators: CutoutFieldValidators): void {
|
|
978
|
+
const cutoutFields = content.createChild('div', 'devices-edit-fields');
|
|
979
|
+
cutoutFields.classList.add('devices-edit-cutout-fields');
|
|
980
|
+
UI.ARIAUtils.markAsGroup(cutoutFields);
|
|
981
|
+
const heading = cutoutFields.createChild('b');
|
|
982
|
+
heading.id = UI.ARIAUtils.nextId('cutout-heading-');
|
|
983
|
+
UI.UIUtils.createTextChild(heading, i18nString(UIStrings.displayCutout));
|
|
984
|
+
cutoutFields.setAttribute('aria-labelledby', heading.id);
|
|
985
|
+
const shapeOptions = [
|
|
986
|
+
NO_CUSTOM_CUTOUT,
|
|
987
|
+
EmulationModel.EmulatedDevices.CutoutShape.PILL,
|
|
988
|
+
EmulationModel.EmulatedDevices.CutoutShape.NOTCH,
|
|
989
|
+
EmulationModel.EmulatedDevices.CutoutShape.CIRCLE,
|
|
990
|
+
EmulationModel.EmulatedDevices.CutoutShape.RECTANGLE,
|
|
991
|
+
];
|
|
992
|
+
const shapeControl =
|
|
993
|
+
editor.createSelect('cutout-shape', shapeOptions, validators.shape, i18nString(UIStrings.displayCutout));
|
|
994
|
+
shapeControl.options[0].textContent = i18nString(UIStrings.noDisplayCutout);
|
|
995
|
+
shapeControl.options[1].textContent = i18nString(UIStrings.pillDisplayCutout);
|
|
996
|
+
shapeControl.options[2].textContent = i18nString(UIStrings.notchDisplayCutout);
|
|
997
|
+
shapeControl.options[3].textContent = i18nString(UIStrings.circleDisplayCutout);
|
|
998
|
+
shapeControl.options[4].textContent = i18nString(UIStrings.rectangleDisplayCutout);
|
|
999
|
+
cutoutFields.createChild('div', 'hbox').appendChild(shapeControl);
|
|
1000
|
+
shapeControl.addEventListener('input', () => this.updateCutoutFieldsVisibility(editor), false);
|
|
1001
|
+
|
|
1002
|
+
const rectRow = cutoutFields.createChild('div', 'hbox devices-edit-cutout-rect-row');
|
|
1003
|
+
rectRow.appendChild(editor.createInput('cutout-x', 'text', i18nString(UIStrings.cutoutX), validators.x));
|
|
1004
|
+
rectRow.appendChild(editor.createInput('cutout-y', 'text', i18nString(UIStrings.cutoutY), validators.y));
|
|
1005
|
+
rectRow.appendChild(
|
|
1006
|
+
editor.createInput('cutout-width', 'text', i18nString(UIStrings.cutoutWidth), validators.width));
|
|
1007
|
+
rectRow.appendChild(
|
|
1008
|
+
editor.createInput('cutout-height', 'text', i18nString(UIStrings.cutoutHeight), validators.height));
|
|
1009
|
+
|
|
1010
|
+
const radiusRow = cutoutFields.createChild('div', 'hbox devices-edit-cutout-radius-row');
|
|
1011
|
+
radiusRow.appendChild(editor.createInput('cutout-border-radius', 'text', i18nString(UIStrings.cutoutBorderRadius),
|
|
1012
|
+
validators.pillRadius));
|
|
1013
|
+
radiusRow.appendChild(editor.createInput('cutout-upper-radius', 'text', i18nString(UIStrings.cutoutUpperRadius),
|
|
1014
|
+
validators.notchUpperRadius));
|
|
1015
|
+
radiusRow.appendChild(editor.createInput('cutout-lower-radius', 'text', i18nString(UIStrings.cutoutLowerRadius),
|
|
1016
|
+
validators.notchLowerRadius));
|
|
1017
|
+
radiusRow.appendChild(
|
|
1018
|
+
editor.createInput('cutout-cx', 'text', i18nString(UIStrings.cutoutCenterX), validators.circleCenterX));
|
|
1019
|
+
radiusRow.appendChild(
|
|
1020
|
+
editor.createInput('cutout-cy', 'text', i18nString(UIStrings.cutoutCenterY), validators.circleCenterY));
|
|
1021
|
+
radiusRow.appendChild(
|
|
1022
|
+
editor.createInput('cutout-radius', 'text', i18nString(UIStrings.cutoutRadius), validators.circleRadius));
|
|
1023
|
+
this.updateCutoutFieldsVisibility(editor);
|
|
1024
|
+
}
|
|
575
1025
|
}
|