chrome-devtools-frontend 1.0.1624583 → 1.0.1625854
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/.agents/skills/foundation-test-migration/SKILL.md +2 -2
- package/front_end/core/common/VersionController.ts +9 -7
- package/front_end/core/common/common.ts +0 -4
- package/front_end/core/host/Platform.ts +0 -9
- package/front_end/core/host/UserMetrics.ts +0 -55
- package/front_end/core/root/ExperimentNames.ts +0 -1
- package/front_end/core/sdk/CPUThrottlingManager.ts +1 -1
- package/front_end/core/sdk/CSSMetadata.ts +0 -8
- package/front_end/core/sdk/CSSProperty.ts +1 -5
- package/front_end/core/sdk/CSSPropertyParserMatchers.ts +0 -30
- package/front_end/{panels/application → core/sdk}/DOMStorageModel.ts +12 -10
- package/front_end/core/sdk/sdk.ts +2 -0
- package/front_end/entrypoints/main/MainImpl.ts +12 -8
- package/front_end/entrypoints/main/SimpleApp.ts +3 -4
- package/front_end/entrypoints/main/main-meta.ts +1 -1
- package/front_end/generated/InspectorBackendCommands.ts +3 -3
- package/front_end/generated/SupportedCSSProperties.js +21 -21
- package/front_end/generated/protocol.ts +4 -1
- package/front_end/models/ai_assistance/data_formatters/NetworkRequestFormatter.ts +6 -2
- package/front_end/models/ai_code_completion/AiCodeCompletion.ts +10 -2
- package/front_end/models/ai_code_generation/AiCodeGeneration.ts +5 -1
- package/front_end/models/issues_manager/CookieIssue.ts +0 -4
- package/front_end/models/issues_manager/RelatedIssue.ts +0 -14
- package/front_end/models/javascript_metadata/NativeFunctions.js +4 -0
- package/front_end/models/trace/insights/DuplicatedJavaScript.ts +4 -0
- package/front_end/models/trace/insights/FontDisplay.ts +4 -0
- package/front_end/models/trace/insights/LegacyJavaScript.ts +4 -0
- package/front_end/models/workspace/IgnoreListManager.ts +1 -1
- package/front_end/models/workspace/UISourceCode.ts +10 -5
- package/front_end/panels/ai_assistance/components/ChatMessage.ts +26 -9
- package/front_end/panels/application/ApplicationPanelSidebar.ts +32 -42
- package/front_end/panels/application/BackForwardCacheTreeElement.ts +2 -2
- package/front_end/panels/application/BounceTrackingMitigationsTreeElement.ts +2 -2
- package/front_end/panels/application/DOMStorageItemsView.ts +18 -13
- package/front_end/panels/application/InterestGroupTreeElement.ts +2 -2
- package/front_end/panels/application/ReportingApiTreeElement.ts +3 -3
- package/front_end/panels/application/ResourcesPanel.ts +1 -2
- package/front_end/panels/application/ServiceWorkerCacheTreeElement.ts +1 -2
- package/front_end/panels/application/StorageView.ts +1 -2
- package/front_end/panels/application/TrustTokensTreeElement.ts +2 -2
- package/front_end/panels/application/WebMCPTreeElement.ts +2 -2
- package/front_end/panels/application/application.ts +0 -2
- package/front_end/panels/console/ConsolePrompt.ts +1 -1
- package/front_end/panels/console/ConsoleView.ts +3 -4
- package/front_end/panels/elements/ColorSwatchPopoverIcon.ts +0 -152
- package/front_end/panels/elements/ElementsTreeElement.ts +4 -9
- package/front_end/panels/elements/StylePropertiesSection.ts +0 -61
- package/front_end/panels/elements/StylePropertyTreeElement.ts +1 -21
- package/front_end/panels/elements/StylesAiCodeCompletionProvider.ts +6 -4
- package/front_end/panels/elements/StylesSidebarPane.ts +2 -3
- package/front_end/panels/elements/stylesSidebarPane.css +0 -8
- package/front_end/panels/emulation/AdvancedApp.ts +3 -3
- package/front_end/panels/emulation/DeviceModeToolbar.ts +275 -433
- package/front_end/panels/emulation/emulation-meta.ts +1 -1
- package/front_end/panels/network/NetworkPanel.ts +1 -1
- package/front_end/panels/profiler/HeapProfilerPanel.ts +1 -2
- package/front_end/panels/screencast/ScreencastApp.ts +3 -3
- package/front_end/panels/screencast/screencast-meta.ts +1 -2
- package/front_end/panels/settings/SettingsScreen.ts +2 -2
- package/front_end/panels/sources/AiCodeCompletionPlugin.ts +2 -4
- package/front_end/panels/sources/SourcesNavigator.ts +1 -1
- package/front_end/panels/sources/UISourceCodeFrame.ts +1 -3
- package/front_end/panels/timeline/TimelinePanel.ts +2 -2
- package/front_end/panels/timeline/components/SidebarSingleInsightSet.ts +12 -4
- package/front_end/panels/timeline/components/insights/DuplicatedJavaScript.ts +4 -0
- package/front_end/panels/timeline/components/insights/FontDisplay.ts +4 -0
- package/front_end/panels/timeline/components/insights/LegacyJavaScript.ts +4 -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/cjs/puppeteer/api/Page.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/locators/locators.d.ts +3 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/locators/locators.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/locators/locators.js +53 -23
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/locators/locators.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.d.ts +3 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.js +18 -8
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserConnector.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserConnector.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserConnector.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.js +4 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.js +54 -19
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/WebMCP.d.ts +5 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/WebMCP.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/WebMCP.js +2 -9
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/WebMCP.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/BrowserConnector.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/BrowserConnector.js +3 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/BrowserConnector.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/ConnectOptions.d.ts +37 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/ConnectOptions.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserLauncher.js +5 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserLauncher.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +3 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +3 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.d.ts +47 -65
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +143 -55
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/locators/locators.d.ts +3 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/locators/locators.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/locators/locators.js +53 -23
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/locators/locators.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.d.ts +3 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.js +18 -8
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserConnector.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserConnector.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserConnector.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.js +4 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.js +54 -19
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/WebMCP.d.ts +5 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/WebMCP.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/WebMCP.js +2 -9
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/WebMCP.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/BrowserConnector.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/BrowserConnector.js +3 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/BrowserConnector.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/ConnectOptions.d.ts +37 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/ConnectOptions.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserLauncher.js +5 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserLauncher.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +3 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +3 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/types.d.ts +47 -65
- package/front_end/third_party/puppeteer/package/package.json +6 -6
- package/front_end/third_party/puppeteer/package/src/api/Page.ts +2 -2
- package/front_end/third_party/puppeteer/package/src/api/locators/locators.ts +69 -27
- package/front_end/third_party/puppeteer/package/src/cdp/Browser.ts +27 -8
- package/front_end/third_party/puppeteer/package/src/cdp/BrowserConnector.ts +4 -2
- package/front_end/third_party/puppeteer/package/src/cdp/Page.ts +6 -0
- package/front_end/third_party/puppeteer/package/src/cdp/TargetManager.ts +60 -18
- package/front_end/third_party/puppeteer/package/src/cdp/WebMCP.ts +7 -9
- package/front_end/third_party/puppeteer/package/src/common/BrowserConnector.ts +3 -0
- package/front_end/third_party/puppeteer/package/src/common/ConnectOptions.ts +37 -1
- package/front_end/third_party/puppeteer/package/src/node/BrowserLauncher.ts +7 -2
- package/front_end/third_party/puppeteer/package/src/node/ChromeLauncher.ts +1 -0
- 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/ui/components/text_editor/AiCodeCompletionProvider.ts +19 -14
- package/front_end/ui/components/text_editor/AiCodeGenerationProvider.ts +8 -7
- package/front_end/{core/common → ui/legacy}/AppProvider.ts +1 -1
- package/front_end/ui/legacy/InspectorView.ts +4 -3
- package/front_end/ui/legacy/TabbedPane.ts +1 -1
- package/front_end/ui/legacy/UIUserMetrics.ts +70 -0
- package/front_end/ui/legacy/components/cookie_table/CookiesTable.ts +1 -8
- package/front_end/ui/legacy/components/inline_editor/inline_editor.ts +0 -6
- package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +328 -47
- package/front_end/ui/legacy/legacy.ts +6 -0
- package/front_end/ui/visual_logging/KnownContextValues.ts +1 -0
- package/package.json +1 -1
- package/front_end/Images/src/custom-typography.svg +0 -3
- package/front_end/ui/legacy/components/inline_editor/FontEditor.ts +0 -798
- package/front_end/ui/legacy/components/inline_editor/FontEditorUnitConverter.ts +0 -250
- package/front_end/ui/legacy/components/inline_editor/FontEditorUtils.ts +0 -204
- package/front_end/ui/legacy/components/inline_editor/fontEditor.css +0 -185
- /package/front_end/{core/common → ui/legacy}/App.ts +0 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Use of this source code is governed by a BSD-style license that can be
|
|
3
3
|
// found in the LICENSE file.
|
|
4
4
|
/* eslint-disable @devtools/no-imperative-dom-api */
|
|
5
|
+
/* eslint-disable @devtools/no-lit-render-outside-of-view */
|
|
5
6
|
|
|
6
7
|
import '../../ui/legacy/legacy.js';
|
|
7
8
|
|
|
@@ -11,8 +12,8 @@ import * as i18n from '../../core/i18n/i18n.js';
|
|
|
11
12
|
import * as Platform from '../../core/platform/platform.js';
|
|
12
13
|
import * as EmulationModel from '../../models/emulation/emulation.js';
|
|
13
14
|
import * as Buttons from '../../ui/components/buttons/buttons.js';
|
|
14
|
-
import * as uiI18n from '../../ui/i18n/i18n.js';
|
|
15
15
|
import * as UI from '../../ui/legacy/legacy.js';
|
|
16
|
+
import {Directives, html, i18nTemplate, type LitTemplate, render} from '../../ui/lit/lit.js';
|
|
16
17
|
import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
|
|
17
18
|
import * as MobileThrottling from '../mobile_throttling/mobile_throttling.js';
|
|
18
19
|
|
|
@@ -187,21 +188,9 @@ const UIStrings = {
|
|
|
187
188
|
} as const;
|
|
188
189
|
const str_ = i18n.i18n.registerUIStrings('panels/emulation/DeviceModeToolbar.ts', UIStrings);
|
|
189
190
|
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
* That's because the emulation elements are rendered around the page context, rather
|
|
194
|
-
* than in the DevTools panel itself. Therefore, we need to fall back to using the
|
|
195
|
-
* built-in tooltip by setting the title attribute on the button's element.
|
|
196
|
-
*/
|
|
197
|
-
function setTitleForButton(button: Buttons.Button.Button|UI.Toolbar.ToolbarMenuButton, title: string): void {
|
|
198
|
-
if (button instanceof UI.Toolbar.ToolbarMenuButton) {
|
|
199
|
-
button.setTitle(title);
|
|
200
|
-
button.element.title = title;
|
|
201
|
-
} else {
|
|
202
|
-
button.title = title;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
191
|
+
const {ifDefined, styleMap} = Directives;
|
|
192
|
+
const {widget} = UI.Widget;
|
|
193
|
+
const {bindToSetting} = UI.UIUtils;
|
|
205
194
|
|
|
206
195
|
export class DeviceModeToolbar {
|
|
207
196
|
private model: EmulationModel.DeviceModeModel.DeviceModeModel;
|
|
@@ -215,23 +204,10 @@ export class DeviceModeToolbar {
|
|
|
215
204
|
readonly #element: HTMLDivElement;
|
|
216
205
|
private readonly emulatedDevicesList: EmulationModel.EmulatedDevices.EmulatedDevicesList;
|
|
217
206
|
private readonly persistenceSetting: Common.Settings.Setting<{device: string, orientation: string, mode: string}>;
|
|
218
|
-
private
|
|
219
|
-
private
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
private heightInput: HTMLInputElement;
|
|
223
|
-
private deviceScaleItem!: HTMLSelectElement;
|
|
224
|
-
private deviceScaleItems: HTMLElement[] = [];
|
|
225
|
-
private deviceSelectItem!: HTMLSelectElement;
|
|
226
|
-
private scaleItem!: HTMLSelectElement;
|
|
227
|
-
private uaItem!: HTMLSelectElement;
|
|
228
|
-
private cachedDeviceScale!: number|null;
|
|
229
|
-
private cachedUaType!: string|null;
|
|
230
|
-
private xItem?: HTMLElement;
|
|
231
|
-
private cachedModelType?: EmulationModel.DeviceModeModel.Type;
|
|
232
|
-
private cachedScale?: number;
|
|
233
|
-
private cachedModelDevice?: EmulationModel.EmulatedDevices.EmulatedDevice|null;
|
|
234
|
-
private cachedModelMode?: EmulationModel.EmulatedDevices.Mode|null;
|
|
207
|
+
private mainToolbar: UI.Toolbar.Toolbar;
|
|
208
|
+
private optionsToolbar: UI.Toolbar.Toolbar;
|
|
209
|
+
readonly #itemWidthCache = new Map<string, string>();
|
|
210
|
+
#measuringElement: HTMLSelectElement|null = null;
|
|
235
211
|
|
|
236
212
|
constructor(
|
|
237
213
|
model: EmulationModel.DeviceModeModel.DeviceModeModel,
|
|
@@ -244,26 +220,23 @@ export class DeviceModeToolbar {
|
|
|
244
220
|
this.deviceOutlineSetting = this.model.deviceOutlineSetting();
|
|
245
221
|
this.showDeviceScaleFactorSetting =
|
|
246
222
|
Common.Settings.Settings.instance().createSetting('emulation.show-device-scale-factor', false);
|
|
247
|
-
this.showDeviceScaleFactorSetting.addChangeListener(this.
|
|
223
|
+
this.showDeviceScaleFactorSetting.addChangeListener(this.update, this);
|
|
248
224
|
|
|
249
225
|
this.showUserAgentTypeSetting =
|
|
250
226
|
Common.Settings.Settings.instance().createSetting('emulation.show-user-agent-type', false);
|
|
251
|
-
this.showUserAgentTypeSetting.addChangeListener(this.
|
|
227
|
+
this.showUserAgentTypeSetting.addChangeListener(this.update, this);
|
|
252
228
|
|
|
253
229
|
this.autoAdjustScaleSetting =
|
|
254
230
|
Common.Settings.Settings.instance().createSetting('emulation.auto-adjust-scale', true);
|
|
255
231
|
|
|
256
232
|
this.lastMode = new Map();
|
|
257
233
|
|
|
258
|
-
this.widthInput = this.createSizeInput(i18nString(UIStrings.width), 'width');
|
|
259
|
-
this.heightInput = this.createSizeInput(i18nString(UIStrings.heightLeaveEmptyForFull), 'height');
|
|
260
|
-
|
|
261
234
|
this.#element = document.createElement('div');
|
|
262
235
|
this.#element.classList.add('device-mode-toolbar');
|
|
263
236
|
this.#element.setAttribute('jslog', `${VisualLogging.toolbar('device-mode').track({resize: true})}`);
|
|
264
237
|
|
|
265
|
-
|
|
266
|
-
|
|
238
|
+
this.mainToolbar = this.createMainToolbar();
|
|
239
|
+
this.optionsToolbar = this.createOptionsToolbar();
|
|
267
240
|
|
|
268
241
|
this.emulatedDevicesList = EmulationModel.EmulatedDevices.EmulatedDevicesList.instance();
|
|
269
242
|
this.emulatedDevicesList.addEventListener(
|
|
@@ -274,28 +247,9 @@ export class DeviceModeToolbar {
|
|
|
274
247
|
this.persistenceSetting = Common.Settings.Settings.instance().createSetting(
|
|
275
248
|
'emulation.device-mode-value', {device: '', orientation: '', mode: ''});
|
|
276
249
|
|
|
277
|
-
this.model.toolbarControlsEnabledSetting().addChangeListener(
|
|
278
|
-
updateToolbarsEnabled();
|
|
250
|
+
this.model.toolbarControlsEnabledSetting().addChangeListener(this.update, this);
|
|
279
251
|
|
|
280
|
-
this.
|
|
281
|
-
this.updateScaleMenuItems();
|
|
282
|
-
this.updateDeviceScaleMenuItems();
|
|
283
|
-
this.updateUserAgentMenuItems();
|
|
284
|
-
this.updateDevicePostureItems();
|
|
285
|
-
|
|
286
|
-
function updateToolbarsEnabled(): void {
|
|
287
|
-
const enabled = model.toolbarControlsEnabledSetting().get();
|
|
288
|
-
mainToolbar.setEnabled(enabled);
|
|
289
|
-
optionsToolbar.setEnabled(enabled);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
private appendOption(parentElement: HTMLElement, title: string, value: string, jslogContext: string): void {
|
|
294
|
-
const option = document.createElement('option');
|
|
295
|
-
option.text = title;
|
|
296
|
-
option.value = value;
|
|
297
|
-
option.setAttribute('jslog', `${VisualLogging.item(jslogContext).track({click: true})}`);
|
|
298
|
-
parentElement.appendChild(option);
|
|
252
|
+
this.update();
|
|
299
253
|
}
|
|
300
254
|
|
|
301
255
|
private createEmptyToolbarElement(): HTMLDivElement {
|
|
@@ -304,16 +258,22 @@ export class DeviceModeToolbar {
|
|
|
304
258
|
return element;
|
|
305
259
|
}
|
|
306
260
|
|
|
307
|
-
private createSizeInput(
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
261
|
+
private createSizeInput(
|
|
262
|
+
title: string, jslogContext: string, value: string|undefined, disabled: boolean|undefined,
|
|
263
|
+
placeholder: string|undefined, onChange: (event: Event) => void): LitTemplate {
|
|
264
|
+
return html`
|
|
265
|
+
<input type="number"
|
|
266
|
+
max=${EmulationModel.DeviceModeModel.MaxDeviceSize}
|
|
267
|
+
min=${EmulationModel.DeviceModeModel.MinDeviceSize}
|
|
268
|
+
title=${title}
|
|
269
|
+
class="device-mode-size-input"
|
|
270
|
+
.disabled=${disabled ?? false}
|
|
271
|
+
jslog=${VisualLogging.textField().track({change: true}).context(jslogContext)}
|
|
272
|
+
.value=${value ?? ''}
|
|
273
|
+
placeholder=${ifDefined(placeholder)}
|
|
274
|
+
@change=${onChange}
|
|
275
|
+
@keydown=${(event: Event): void => {
|
|
276
|
+
const input = event.target as HTMLInputElement;
|
|
317
277
|
let modifiedValue = UI.UIUtils.modifiedFloatNumber(Number(input.value), event);
|
|
318
278
|
if (modifiedValue === null) {
|
|
319
279
|
return;
|
|
@@ -324,126 +284,200 @@ export class DeviceModeToolbar {
|
|
|
324
284
|
event.preventDefault();
|
|
325
285
|
input.value = String(modifiedValue);
|
|
326
286
|
input.dispatchEvent(new Event('change'));
|
|
327
|
-
}
|
|
328
|
-
return input;
|
|
287
|
+
}}>`;
|
|
329
288
|
}
|
|
330
289
|
|
|
331
290
|
private createMainToolbar(): UI.Toolbar.Toolbar {
|
|
332
291
|
const mainToolbar = this.#element.createChild('devtools-toolbar', 'main-toolbar');
|
|
292
|
+
return mainToolbar as UI.Toolbar.Toolbar;
|
|
293
|
+
}
|
|
333
294
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
this.
|
|
337
|
-
this.
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
this.
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
})
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
this.
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
295
|
+
private renderMainToolbar(): void {
|
|
296
|
+
const isResponsive = this.model.type() === EmulationModel.DeviceModeModel.Type.Responsive;
|
|
297
|
+
const isFullHeight = isResponsive && this.model.isFullHeight();
|
|
298
|
+
const size = this.model.appliedDeviceSize();
|
|
299
|
+
const widthValue = String(size.width);
|
|
300
|
+
const heightValue = isFullHeight ? '' : String(size.height);
|
|
301
|
+
const heightPlaceholder = String(size.height);
|
|
302
|
+
|
|
303
|
+
const device = this.model.device();
|
|
304
|
+
let modeButtonTitle = i18nString(UIStrings.rotate);
|
|
305
|
+
let modeButtonDisabled = false;
|
|
306
|
+
if (this.model.isScreenOrientationLocked()) {
|
|
307
|
+
modeButtonDisabled = true;
|
|
308
|
+
modeButtonTitle = i18nString(UIStrings.screenOrientationLocked);
|
|
309
|
+
} else if (device) {
|
|
310
|
+
const modeCount = device.modes.length;
|
|
311
|
+
modeButtonDisabled = modeCount < 2;
|
|
312
|
+
modeButtonTitle = modeCount === 2 ? i18nString(UIStrings.rotate) : i18nString(UIStrings.screenOrientationOptions);
|
|
313
|
+
} else if (isResponsive) {
|
|
314
|
+
modeButtonDisabled = false;
|
|
315
|
+
modeButtonTitle = i18nString(UIStrings.rotate);
|
|
316
|
+
} else {
|
|
317
|
+
modeButtonDisabled = true;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const showSpanButton = Boolean(device?.isDualScreen);
|
|
321
|
+
const showPostureItem = Boolean(!device?.isDualScreen && device?.isFoldableScreen);
|
|
322
|
+
|
|
323
|
+
const deviceModeOptions = this.getDeviceModeOptions();
|
|
324
|
+
const scaleOptions = this.getScaleOptions();
|
|
325
|
+
const dprOptions = this.getDeviceScaleFactorOptions();
|
|
326
|
+
const uaOptions = this.getUserAgentOptions();
|
|
327
|
+
const postureOptions = this.getDevicePostureOptions();
|
|
328
|
+
|
|
329
|
+
const selectedDeviceOption = [
|
|
330
|
+
deviceModeOptions.responsive,
|
|
331
|
+
...deviceModeOptions.standard,
|
|
332
|
+
...deviceModeOptions.custom,
|
|
333
|
+
].find(o => o.selected);
|
|
334
|
+
const deviceText = selectedDeviceOption ? selectedDeviceOption.title : deviceModeOptions.responsive.title;
|
|
335
|
+
|
|
336
|
+
let scaleText = scaleOptions.find(o => o.selected)?.title || '';
|
|
337
|
+
if (scaleText.includes(' (')) {
|
|
338
|
+
scaleText = scaleText.substring(0, scaleText.indexOf(' ('));
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
let dprText = dprOptions.find(o => o.selected)?.title || '';
|
|
342
|
+
if (dprText.includes(' (')) {
|
|
343
|
+
dprText = dprText.substring(0, dprText.indexOf(' ('));
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const uaText = uaOptions.find(o => o.selected)?.title || '';
|
|
347
|
+
const postureText = postureOptions.find(o => o.selected)?.title || '';
|
|
348
|
+
|
|
349
|
+
// clang-format off
|
|
350
|
+
render(html`
|
|
351
|
+
<div class="device-mode-empty-toolbar-element"></div>
|
|
352
|
+
${i18nTemplate(str_, UIStrings.dimensions, {PH1: html`
|
|
353
|
+
<select class="dark-text toolbar-has-dropdown-shrinkable"
|
|
354
|
+
style=${styleMap({width: this.calculateItemWidth(deviceText)})}
|
|
355
|
+
title=${i18nString(UIStrings.deviceType)}
|
|
356
|
+
aria-label=${i18nString(UIStrings.deviceType)}
|
|
357
|
+
@change=${this.onDeviceChange.bind(this)}
|
|
358
|
+
.value=${selectedDeviceOption === deviceModeOptions.responsive ? 'Responsive' : (selectedDeviceOption?.title || 'Responsive')}
|
|
359
|
+
jslog=${VisualLogging.dropDown().track({change: true}).context('device')}>
|
|
360
|
+
<option value="Responsive" ?selected=${deviceModeOptions.responsive.selected} jslog=${VisualLogging.item(deviceModeOptions.responsive.jslogContext).track({click: true})}>
|
|
361
|
+
${deviceModeOptions.responsive.title}
|
|
362
|
+
</option>
|
|
363
|
+
${deviceModeOptions.standard.length > 0 ? html`
|
|
364
|
+
<optgroup label="Standard">
|
|
365
|
+
${deviceModeOptions.standard.map(o => html`<option value=${o.title} ?selected=${o.selected} jslog=${VisualLogging.item(o.jslogContext).track({click: true})}>${o.title}</option>`)}
|
|
366
|
+
</optgroup>
|
|
367
|
+
` : ''}
|
|
368
|
+
${deviceModeOptions.custom.length > 0 ? html`
|
|
369
|
+
<optgroup label="Custom">
|
|
370
|
+
${deviceModeOptions.custom.map(o => html`<option value=${o.title} ?selected=${o.selected} jslog=${VisualLogging.item(o.jslogContext).track({click: true})}>${o.title}</option>`)}
|
|
371
|
+
</optgroup>
|
|
372
|
+
` : ''}
|
|
373
|
+
<option value="Edit" jslog=${VisualLogging.item(deviceModeOptions.edit.jslogContext).track({click: true})}>
|
|
374
|
+
${deviceModeOptions.edit.title}
|
|
375
|
+
</option>
|
|
376
|
+
</select>`})}
|
|
377
|
+
|
|
378
|
+
${this.createSizeInput(i18nString(UIStrings.width), 'width', widthValue, !isResponsive, '', (event: Event) => {
|
|
379
|
+
const width = Number((event.target as HTMLInputElement).value);
|
|
380
|
+
if (this.autoAdjustScaleSetting.get()) {
|
|
381
|
+
this.model.setWidthAndScaleToFit(width);
|
|
382
|
+
} else {
|
|
383
|
+
this.model.setWidth(width);
|
|
384
|
+
}
|
|
385
|
+
})}
|
|
386
|
+
|
|
387
|
+
<div class="device-mode-x">×</div>
|
|
388
|
+
${this.createSizeInput(i18nString(UIStrings.heightLeaveEmptyForFull), 'height', heightValue, !isResponsive, heightPlaceholder, (event: Event) => {
|
|
389
|
+
const height = Number((event.target as HTMLInputElement).value);
|
|
390
|
+
if (this.autoAdjustScaleSetting.get()) {
|
|
391
|
+
this.model.setHeightAndScaleToFit(height);
|
|
392
|
+
} else {
|
|
393
|
+
this.model.setHeight(height);
|
|
394
|
+
}
|
|
395
|
+
})}
|
|
396
|
+
|
|
397
|
+
<div class="device-mode-empty-toolbar-element"></div>
|
|
398
|
+
<select class="dark-text toolbar-has-dropdown-shrinkable"
|
|
399
|
+
style=${styleMap({width: this.calculateItemWidth(scaleText)})}
|
|
400
|
+
title=${i18nString(UIStrings.zoom)}
|
|
401
|
+
aria-label=${i18nString(UIStrings.zoom)}
|
|
402
|
+
@change=${this.onScaleChange.bind(this)}
|
|
403
|
+
.value=${String(scaleOptions.find(o => o.selected)?.value || '')}
|
|
404
|
+
jslog=${VisualLogging.dropDown().track({change: true}).context('scale')}>
|
|
405
|
+
${scaleOptions.map(o => html`<option value=${o.value} ?selected=${o.selected} jslog=${VisualLogging.item(o.jslogContext).track({click: true})}>${o.title}</option>`)}
|
|
406
|
+
</select>
|
|
407
|
+
|
|
408
|
+
<devtools-button .data=${{variant: Buttons.Button.Variant.TOOLBAR, iconName: 'center-focus-weak',
|
|
409
|
+
toggledIconName: 'center-focus-weak', toggleType: Buttons.Button.ToggleType.PRIMARY} as Buttons.Button.ButtonData}
|
|
410
|
+
class="toolbar-button" title=${i18nString(UIStrings.autoadjustZoom)}
|
|
411
|
+
${bindToSetting(this.autoAdjustScaleSetting)}>
|
|
412
|
+
</devtools-button>
|
|
413
|
+
|
|
414
|
+
<div class="device-mode-empty-toolbar-element"></div>
|
|
415
|
+
|
|
416
|
+
${this.showDeviceScaleFactorSetting.get() ? html`
|
|
417
|
+
${i18nTemplate(str_, UIStrings.dpr, {
|
|
418
|
+
PH1: html`
|
|
419
|
+
<select class="dark-text toolbar-has-dropdown-shrinkable"
|
|
420
|
+
style=${styleMap({width: this.calculateItemWidth(dprText)})}
|
|
421
|
+
title=${i18nString(UIStrings.devicePixelRatio)}
|
|
422
|
+
aria-label=${i18nString(UIStrings.devicePixelRatio)}
|
|
423
|
+
@change=${this.onDeviceScaleChange.bind(this)}
|
|
424
|
+
.value=${String(dprOptions.find(o => o.selected)?.value || '')}
|
|
425
|
+
jslog=${VisualLogging.dropDown().track({change: true}).context('device-pixel-ratio')}
|
|
426
|
+
?disabled=${!isResponsive}>
|
|
427
|
+
${dprOptions.map(o => html`<option value=${o.value} ?selected=${o.selected} jslog=${VisualLogging.item(o.jslogContext).track({click: true})}>${o.title}</option>`)}
|
|
428
|
+
</select>`
|
|
429
|
+
})}` : ''}
|
|
430
|
+
|
|
431
|
+
<div class="device-mode-empty-toolbar-element"></div>
|
|
432
|
+
${this.showUserAgentTypeSetting.get() ? html`
|
|
433
|
+
<select class="dark-text toolbar-has-dropdown-shrinkable"
|
|
434
|
+
style=${styleMap({width: this.calculateItemWidth(uaText)})}
|
|
435
|
+
title=${i18nString(UIStrings.deviceType)}
|
|
436
|
+
aria-label=${i18nString(UIStrings.deviceType)}
|
|
437
|
+
@change=${this.onUAChange.bind(this)}
|
|
438
|
+
.value=${uaOptions.find(o => o.selected)?.value || ''}
|
|
439
|
+
jslog=${VisualLogging.dropDown().track({change: true}).context('device-type')}
|
|
440
|
+
?disabled=${!isResponsive}>
|
|
441
|
+
${uaOptions.map(o => html`<option value=${o.value} ?selected=${o.selected} jslog=${VisualLogging.item(o.jslogContext).track({click: true})}>${o.title}</option>`)}
|
|
442
|
+
</select>` : ''}
|
|
443
|
+
<select class="dark-text" ${widget(MobileThrottling.NetworkThrottlingSelector.NetworkThrottlingSelect, {
|
|
444
|
+
title: i18nString(UIStrings.throttling),
|
|
445
|
+
bindToGlobalConditions: true,
|
|
446
|
+
})}></select>
|
|
447
|
+
<select class="dark-text toolbar-has-dropdown-shrinkable" ${widget(
|
|
448
|
+
MobileThrottling.ThrottlingManager.SaveDataOverrideSelect)}></select>
|
|
449
|
+
|
|
450
|
+
<div class="device-mode-empty-toolbar-element"></div>
|
|
451
|
+
<devtools-button class="toolbar-button"
|
|
452
|
+
.data=${{variant: Buttons.Button.Variant.TOOLBAR, iconName: 'screen-rotation'} as Buttons.Button.ButtonData}
|
|
453
|
+
jslog=${VisualLogging.action('screen-rotation').track({click: true})}
|
|
454
|
+
@click=${this.modeMenuClicked.bind(this)}
|
|
455
|
+
.title=${modeButtonTitle}
|
|
456
|
+
.disabled=${modeButtonDisabled}>
|
|
457
|
+
</devtools-button>
|
|
458
|
+
|
|
459
|
+
<!-- Show dual screen toolbar -->
|
|
460
|
+
${showSpanButton ? html`
|
|
461
|
+
<devtools-button class="toolbar-button"
|
|
462
|
+
.data=${{variant: Buttons.Button.Variant.TOOLBAR, iconName: 'device-fold'} as Buttons.Button.ButtonData}
|
|
463
|
+
jslog=${VisualLogging.action('device-fold').track({click: true})}
|
|
464
|
+
.title=${i18nString(UIStrings.toggleDualscreenMode)}
|
|
465
|
+
@click=${this.spanClicked.bind(this)}>
|
|
466
|
+
</devtools-button>` : ''}
|
|
467
|
+
|
|
468
|
+
<!-- Show posture toolbar menu for foldable devices. -->
|
|
469
|
+
<div class="device-mode-empty-toolbar-element"></div>
|
|
470
|
+
${showPostureItem ? html`
|
|
471
|
+
<select class="dark-text toolbar-has-dropdown-shrinkable"
|
|
472
|
+
style=${styleMap({width: this.calculateItemWidth(postureText)})}
|
|
473
|
+
title=${i18nString(UIStrings.devicePosture)}
|
|
474
|
+
aria-label=${i18nString(UIStrings.devicePosture)}
|
|
475
|
+
@change=${this.onPostureChange.bind(this)}
|
|
476
|
+
.value=${postureOptions.find(o => o.selected)?.value || ''}
|
|
477
|
+
jslog=${VisualLogging.dropDown().track({change: true}).context('device-posture')}>
|
|
478
|
+
${postureOptions.map(o => html`<option value=${o.value} ?selected=${o.selected} jslog=${VisualLogging.item(o.value.toLowerCase()).track({click: true})}>${o.title}</option>`)}
|
|
479
|
+
</select>` : ''}`, this.mainToolbar, {host: this});
|
|
480
|
+
// clang-format on
|
|
447
481
|
}
|
|
448
482
|
|
|
449
483
|
private createOptionsToolbar(): UI.Toolbar.Toolbar {
|
|
@@ -462,20 +496,8 @@ export class DeviceModeToolbar {
|
|
|
462
496
|
return ['Continuous', 'Folded'].map(title => ({title, value: title, selected: currentPosture === title}));
|
|
463
497
|
}
|
|
464
498
|
|
|
465
|
-
private
|
|
466
|
-
|
|
467
|
-
for (const option of this.getDevicePostureOptions()) {
|
|
468
|
-
this.appendOption(this.postureItem, option.title, option.value, option.title.toLowerCase());
|
|
469
|
-
}
|
|
470
|
-
const currentPosture = this.currentDevicePosture();
|
|
471
|
-
if (this.postureItem.value !== currentPosture) {
|
|
472
|
-
this.postureItem.value = currentPosture;
|
|
473
|
-
}
|
|
474
|
-
this.resizeItem(this.postureItem);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
private onPostureChange(): void {
|
|
478
|
-
const value = this.postureItem.value;
|
|
499
|
+
private onPostureChange(event: Event): void {
|
|
500
|
+
const value = (event.target as HTMLSelectElement).value;
|
|
479
501
|
if (value !== this.currentDevicePosture()) {
|
|
480
502
|
this.spanClicked();
|
|
481
503
|
}
|
|
@@ -523,21 +545,8 @@ export class DeviceModeToolbar {
|
|
|
523
545
|
});
|
|
524
546
|
}
|
|
525
547
|
|
|
526
|
-
private
|
|
527
|
-
|
|
528
|
-
const options = this.getScaleOptions();
|
|
529
|
-
for (const option of options) {
|
|
530
|
-
this.appendOption(this.scaleItem, option.title, String(option.value), option.jslogContext);
|
|
531
|
-
}
|
|
532
|
-
const selected = options.find(o => o.selected);
|
|
533
|
-
if (selected) {
|
|
534
|
-
this.scaleItem.value = String(selected.value);
|
|
535
|
-
}
|
|
536
|
-
this.resizeItem(this.scaleItem, true);
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
private onScaleChange(): void {
|
|
540
|
-
const value = Number(this.scaleItem.value);
|
|
548
|
+
private onScaleChange(event: Event): void {
|
|
549
|
+
const value = Number((event.target as HTMLSelectElement).value);
|
|
541
550
|
this.model.scaleSetting().set(value);
|
|
542
551
|
}
|
|
543
552
|
|
|
@@ -571,21 +580,8 @@ export class DeviceModeToolbar {
|
|
|
571
580
|
});
|
|
572
581
|
}
|
|
573
582
|
|
|
574
|
-
private
|
|
575
|
-
|
|
576
|
-
const options = this.getDeviceScaleFactorOptions();
|
|
577
|
-
for (const option of options) {
|
|
578
|
-
this.appendOption(this.deviceScaleItem, option.title, String(option.value), option.jslogContext);
|
|
579
|
-
}
|
|
580
|
-
const selected = options.find(o => o.selected);
|
|
581
|
-
if (selected) {
|
|
582
|
-
this.deviceScaleItem.value = String(selected.value);
|
|
583
|
-
}
|
|
584
|
-
this.resizeItem(this.deviceScaleItem, true);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
private onDeviceScaleChange(): void {
|
|
588
|
-
const value = Number(this.deviceScaleItem.value);
|
|
583
|
+
private onDeviceScaleChange(event: Event): void {
|
|
584
|
+
const value = Number((event.target as HTMLSelectElement).value);
|
|
589
585
|
this.model.deviceScaleFactorSetting().set(value);
|
|
590
586
|
}
|
|
591
587
|
|
|
@@ -606,23 +602,9 @@ export class DeviceModeToolbar {
|
|
|
606
602
|
}));
|
|
607
603
|
}
|
|
608
604
|
|
|
609
|
-
private
|
|
610
|
-
|
|
611
|
-
const options = this.getUserAgentOptions();
|
|
612
|
-
for (const option of options) {
|
|
613
|
-
this.appendOption(this.uaItem, option.title, option.value, option.jslogContext);
|
|
614
|
-
}
|
|
615
|
-
const selected = options.find(o => o.selected);
|
|
616
|
-
if (selected) {
|
|
617
|
-
this.uaItem.value = selected.value;
|
|
618
|
-
}
|
|
619
|
-
this.resizeItem(this.uaItem);
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
private onUAChange(): void {
|
|
623
|
-
const value = this.uaItem.value as EmulationModel.DeviceModeModel.UA;
|
|
605
|
+
private onUAChange(event: Event): void {
|
|
606
|
+
const value = (event.target as HTMLSelectElement).value as EmulationModel.DeviceModeModel.UA;
|
|
624
607
|
this.model.uaSetting().set(value);
|
|
625
|
-
this.resizeItem(this.uaItem);
|
|
626
608
|
}
|
|
627
609
|
|
|
628
610
|
private appendOptionsMenuItems(contextMenu: UI.ContextMenu.ContextMenu): void {
|
|
@@ -747,48 +729,11 @@ export class DeviceModeToolbar {
|
|
|
747
729
|
};
|
|
748
730
|
}
|
|
749
731
|
|
|
750
|
-
private
|
|
751
|
-
|
|
752
|
-
const options = this.getDeviceModeOptions();
|
|
753
|
-
|
|
754
|
-
this.appendOption(this.deviceSelectItem, options.responsive.title, 'Responsive', options.responsive.jslogContext);
|
|
755
|
-
|
|
756
|
-
appendGroup.call(this, options.standard, 'Standard');
|
|
757
|
-
appendGroup.call(this, options.custom, 'Custom');
|
|
758
|
-
|
|
759
|
-
this.appendOption(this.deviceSelectItem, options.edit.title, 'Edit', options.edit.jslogContext);
|
|
760
|
-
|
|
761
|
-
this.updateDeviceSelection();
|
|
762
|
-
|
|
763
|
-
function appendGroup(
|
|
764
|
-
this: DeviceModeToolbar, group: Array<{title: string, jslogContext: string}>, label: string): void {
|
|
765
|
-
if (!group.length) {
|
|
766
|
-
return;
|
|
767
|
-
}
|
|
768
|
-
const optGroup = document.createElement('optgroup');
|
|
769
|
-
optGroup.label = label;
|
|
770
|
-
for (const item of group) {
|
|
771
|
-
this.appendOption(optGroup, item.title, item.title, item.jslogContext);
|
|
772
|
-
}
|
|
773
|
-
this.deviceSelectItem.appendChild(optGroup);
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
private updateDeviceSelection(): void {
|
|
778
|
-
const device = this.model.device();
|
|
779
|
-
if (this.model.type() === EmulationModel.DeviceModeModel.Type.Responsive) {
|
|
780
|
-
this.deviceSelectItem.value = 'Responsive';
|
|
781
|
-
} else if (device) {
|
|
782
|
-
this.deviceSelectItem.value = device.title;
|
|
783
|
-
}
|
|
784
|
-
this.resizeItem(this.deviceSelectItem);
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
private onDeviceChange(): void {
|
|
788
|
-
const value = this.deviceSelectItem.value;
|
|
732
|
+
private onDeviceChange(event: Event): void {
|
|
733
|
+
const value = (event.target as HTMLSelectElement).value;
|
|
789
734
|
if (value === 'Edit') {
|
|
790
735
|
this.emulatedDevicesList.revealCustomSetting();
|
|
791
|
-
this.
|
|
736
|
+
this.renderMainToolbar();
|
|
792
737
|
} else if (value === 'Responsive') {
|
|
793
738
|
this.switchToResponsive();
|
|
794
739
|
} else {
|
|
@@ -802,7 +747,7 @@ export class DeviceModeToolbar {
|
|
|
802
747
|
}
|
|
803
748
|
|
|
804
749
|
private deviceListChanged(): void {
|
|
805
|
-
this.
|
|
750
|
+
this.renderMainToolbar();
|
|
806
751
|
const device = this.model.device();
|
|
807
752
|
if (!device) {
|
|
808
753
|
return;
|
|
@@ -820,26 +765,6 @@ export class DeviceModeToolbar {
|
|
|
820
765
|
}
|
|
821
766
|
}
|
|
822
767
|
|
|
823
|
-
private updateDeviceScaleFactorVisibility(): void {
|
|
824
|
-
if (this.deviceScaleItem) {
|
|
825
|
-
const visible = this.showDeviceScaleFactorSetting.get();
|
|
826
|
-
this.deviceScaleItem.classList.toggle('hidden', !visible);
|
|
827
|
-
for (const item of this.deviceScaleItems) {
|
|
828
|
-
item.classList.toggle('hidden', !visible);
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
private updateUserAgentTypeVisibility(): void {
|
|
834
|
-
if (this.uaItem) {
|
|
835
|
-
const visible = this.showUserAgentTypeSetting.get();
|
|
836
|
-
this.uaItem.classList.toggle('hidden', !visible);
|
|
837
|
-
if (visible) {
|
|
838
|
-
this.resizeItem(this.uaItem);
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
|
|
843
768
|
private spanClicked(): void {
|
|
844
769
|
const device = this.model.device();
|
|
845
770
|
|
|
@@ -900,13 +825,10 @@ export class DeviceModeToolbar {
|
|
|
900
825
|
return;
|
|
901
826
|
}
|
|
902
827
|
|
|
903
|
-
|
|
904
|
-
return;
|
|
905
|
-
}
|
|
906
|
-
|
|
828
|
+
const modeButton = event.target as HTMLElement;
|
|
907
829
|
const contextMenu = new UI.ContextMenu.ContextMenu(event, {
|
|
908
|
-
x:
|
|
909
|
-
y:
|
|
830
|
+
x: modeButton.getBoundingClientRect().left,
|
|
831
|
+
y: modeButton.getBoundingClientRect().top + modeButton.offsetHeight,
|
|
910
832
|
});
|
|
911
833
|
addOrientation(EmulationModel.EmulatedDevices.Vertical, i18nString(UIStrings.portrait));
|
|
912
834
|
addOrientation(EmulationModel.EmulatedDevices.Horizontal, i18nString(UIStrings.landscape));
|
|
@@ -954,77 +876,11 @@ export class DeviceModeToolbar {
|
|
|
954
876
|
}
|
|
955
877
|
|
|
956
878
|
update(): void {
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
this.heightInput.disabled = this.model.type() !== EmulationModel.DeviceModeModel.Type.Responsive;
|
|
962
|
-
this.deviceScaleItem.disabled = this.model.type() !== EmulationModel.DeviceModeModel.Type.Responsive;
|
|
963
|
-
this.uaItem.disabled = this.model.type() !== EmulationModel.DeviceModeModel.Type.Responsive;
|
|
964
|
-
|
|
965
|
-
if (this.model.type() === EmulationModel.DeviceModeModel.Type.Responsive) {
|
|
966
|
-
this.modeButton.disabled = false;
|
|
967
|
-
setTitleForButton(this.modeButton, i18nString(UIStrings.rotate));
|
|
968
|
-
} else {
|
|
969
|
-
this.modeButton.disabled = true;
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
const size = this.model.appliedDeviceSize();
|
|
974
|
-
this.widthInput.value = String(size.width);
|
|
975
|
-
this.heightInput.value =
|
|
976
|
-
this.model.type() === EmulationModel.DeviceModeModel.Type.Responsive && this.model.isFullHeight() ?
|
|
977
|
-
'' :
|
|
978
|
-
String(size.height);
|
|
979
|
-
this.heightInput.placeholder = String(size.height);
|
|
980
|
-
|
|
981
|
-
if (this.model.scale() !== this.cachedScale) {
|
|
982
|
-
this.updateScaleMenuItems();
|
|
983
|
-
this.cachedScale = this.model.scale();
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
const deviceScale = this.model.appliedDeviceScaleFactor();
|
|
987
|
-
if (deviceScale !== this.cachedDeviceScale) {
|
|
988
|
-
this.deviceScaleItem.value = String(deviceScale);
|
|
989
|
-
this.cachedDeviceScale = deviceScale;
|
|
990
|
-
this.resizeItem(this.deviceScaleItem, true);
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
const uaType = this.model.appliedUserAgentType();
|
|
994
|
-
if (uaType !== this.cachedUaType) {
|
|
995
|
-
this.uaItem.value = uaType;
|
|
996
|
-
this.cachedUaType = uaType;
|
|
997
|
-
this.updateDeviceScaleMenuItems();
|
|
998
|
-
this.resizeItem(this.uaItem);
|
|
999
|
-
}
|
|
879
|
+
const enabled = this.model.toolbarControlsEnabledSetting().get();
|
|
880
|
+
this.mainToolbar.setEnabled(enabled);
|
|
881
|
+
this.optionsToolbar.setEnabled(enabled);
|
|
1000
882
|
|
|
1001
883
|
const device = this.model.device();
|
|
1002
|
-
this.updateDeviceSelection();
|
|
1003
|
-
|
|
1004
|
-
if (this.model.device() !== this.cachedModelDevice) {
|
|
1005
|
-
const device = this.model.device();
|
|
1006
|
-
if (device) {
|
|
1007
|
-
const modeCount = device ? device.modes.length : 0;
|
|
1008
|
-
this.modeButton.disabled = modeCount < 2;
|
|
1009
|
-
setTitleForButton(
|
|
1010
|
-
this.modeButton,
|
|
1011
|
-
modeCount === 2 ? i18nString(UIStrings.rotate) : i18nString(UIStrings.screenOrientationOptions));
|
|
1012
|
-
}
|
|
1013
|
-
this.cachedModelDevice = device;
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
if (device?.isDualScreen) {
|
|
1017
|
-
this.spanButton.classList.toggle('hidden', false);
|
|
1018
|
-
this.postureItem.classList.toggle('hidden', true);
|
|
1019
|
-
} else if (device?.isFoldableScreen) {
|
|
1020
|
-
this.spanButton.classList.toggle('hidden', true);
|
|
1021
|
-
this.postureItem.classList.toggle('hidden', false);
|
|
1022
|
-
this.updateDevicePostureItems();
|
|
1023
|
-
} else {
|
|
1024
|
-
this.spanButton.classList.toggle('hidden', true);
|
|
1025
|
-
this.postureItem.classList.toggle('hidden', true);
|
|
1026
|
-
}
|
|
1027
|
-
setTitleForButton(this.spanButton, i18nString(UIStrings.toggleDualscreenMode));
|
|
1028
884
|
|
|
1029
885
|
if (this.model.type() === EmulationModel.DeviceModeModel.Type.Device) {
|
|
1030
886
|
this.lastMode.set(
|
|
@@ -1032,39 +888,20 @@ export class DeviceModeToolbar {
|
|
|
1032
888
|
(this.model.mode() as EmulationModel.EmulatedDevices.Mode));
|
|
1033
889
|
}
|
|
1034
890
|
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
value.device = '';
|
|
1046
|
-
value.orientation = '';
|
|
1047
|
-
value.mode = '';
|
|
1048
|
-
}
|
|
1049
|
-
this.persistenceSetting.set(value);
|
|
891
|
+
const value = this.persistenceSetting.get();
|
|
892
|
+
const currentMode = this.model.mode();
|
|
893
|
+
if (device) {
|
|
894
|
+
value.device = device.title;
|
|
895
|
+
value.orientation = currentMode ? currentMode.orientation : '';
|
|
896
|
+
value.mode = currentMode ? currentMode.title : '';
|
|
897
|
+
} else {
|
|
898
|
+
value.device = '';
|
|
899
|
+
value.orientation = '';
|
|
900
|
+
value.mode = '';
|
|
1050
901
|
}
|
|
902
|
+
this.persistenceSetting.set(value);
|
|
1051
903
|
|
|
1052
|
-
|
|
1053
|
-
// disable the rotate button to prevent user-initiated rotation.
|
|
1054
|
-
// When unlocked, restore the button to its normal state.
|
|
1055
|
-
if (this.model.isScreenOrientationLocked()) {
|
|
1056
|
-
this.modeButton.disabled = true;
|
|
1057
|
-
setTitleForButton(this.modeButton, i18nString(UIStrings.screenOrientationLocked));
|
|
1058
|
-
} else if (this.cachedModelDevice) {
|
|
1059
|
-
const modeCount = this.cachedModelDevice.modes.length;
|
|
1060
|
-
this.modeButton.disabled = modeCount < 2;
|
|
1061
|
-
setTitleForButton(
|
|
1062
|
-
this.modeButton,
|
|
1063
|
-
modeCount === 2 ? i18nString(UIStrings.rotate) : i18nString(UIStrings.screenOrientationOptions));
|
|
1064
|
-
} else if (this.model.type() === EmulationModel.DeviceModeModel.Type.Responsive) {
|
|
1065
|
-
this.modeButton.disabled = false;
|
|
1066
|
-
setTitleForButton(this.modeButton, i18nString(UIStrings.rotate));
|
|
1067
|
-
}
|
|
904
|
+
this.renderMainToolbar();
|
|
1068
905
|
}
|
|
1069
906
|
|
|
1070
907
|
restore(): void {
|
|
@@ -1084,30 +921,35 @@ export class DeviceModeToolbar {
|
|
|
1084
921
|
this.model.emulate(EmulationModel.DeviceModeModel.Type.Responsive, null, null);
|
|
1085
922
|
}
|
|
1086
923
|
|
|
1087
|
-
private
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
924
|
+
private calculateItemWidth(text: string): string {
|
|
925
|
+
if (!text) {
|
|
926
|
+
return '';
|
|
927
|
+
}
|
|
928
|
+
if (this.#itemWidthCache.has(text)) {
|
|
929
|
+
return this.#itemWidthCache.get(text) as string;
|
|
1091
930
|
}
|
|
1092
931
|
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
932
|
+
if (!this.#measuringElement) {
|
|
933
|
+
this.#measuringElement = document.createElement('select');
|
|
934
|
+
this.#measuringElement.className = 'dark-text toolbar-has-dropdown-shrinkable';
|
|
935
|
+
this.#measuringElement.style.width = 'fit-content';
|
|
936
|
+
this.#measuringElement.style.position = 'absolute';
|
|
937
|
+
this.#measuringElement.style.visibility = 'hidden';
|
|
938
|
+
this.#measuringElement.style.pointerEvents = 'none';
|
|
939
|
+
const dummyOption = document.createElement('option');
|
|
940
|
+
this.#measuringElement.appendChild(dummyOption);
|
|
941
|
+
this.#element.appendChild(this.#measuringElement);
|
|
1101
942
|
}
|
|
1102
943
|
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
dummySelect.style.pointerEvents = 'none';
|
|
944
|
+
const dummyOption = this.#measuringElement.options[0];
|
|
945
|
+
dummyOption.textContent = text;
|
|
946
|
+
|
|
947
|
+
const width = this.#measuringElement.offsetWidth;
|
|
1108
948
|
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
949
|
+
const widthPx = width ? `${width}px` : '';
|
|
950
|
+
if (width > 0) {
|
|
951
|
+
this.#itemWidthCache.set(text, widthPx);
|
|
952
|
+
}
|
|
953
|
+
return widthPx;
|
|
1112
954
|
}
|
|
1113
955
|
}
|