chrome-devtools-frontend 1.0.927127 → 1.0.928589
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/AUTHORS +1 -0
- package/config/gni/all_devtools_files.gni +0 -1
- package/config/gni/devtools_grd_files.gni +30 -4
- package/config/gni/devtools_image_files.gni +1 -0
- package/front_end/Images/src/ic_preview_feature.svg +3 -0
- package/front_end/Tests.js +2 -3
- package/front_end/core/common/Settings.ts +26 -45
- package/front_end/core/host/UserMetrics.ts +2 -2
- package/front_end/core/i18n/locales/en-US.json +60 -15
- package/front_end/core/i18n/locales/en-XL.json +60 -15
- package/front_end/core/platform/keyboard-utilities.ts +1 -0
- package/front_end/core/root/Runtime.ts +62 -61
- package/front_end/core/sdk/AccessibilityModel.ts +73 -73
- package/front_end/core/sdk/CPUProfileDataModel.ts +14 -14
- package/front_end/core/sdk/CPUProfilerModel.ts +33 -33
- package/front_end/core/sdk/CPUThrottlingManager.ts +8 -8
- package/front_end/core/sdk/CSSFontFace.ts +10 -10
- package/front_end/core/sdk/CSSMatchedStyles.ts +114 -114
- package/front_end/core/sdk/CSSMedia.ts +22 -22
- package/front_end/core/sdk/CSSMetadata.ts +53 -49
- package/front_end/core/sdk/CSSModel.ts +139 -135
- package/front_end/core/sdk/CSSProperty.ts +18 -18
- package/front_end/core/sdk/CSSRule.ts +15 -15
- package/front_end/core/sdk/CSSStyleDeclaration.ts +49 -47
- package/front_end/core/sdk/CSSStyleSheetHeader.ts +12 -12
- package/front_end/core/sdk/ChildTargetManager.ts +41 -40
- package/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +10 -10
- package/front_end/core/sdk/Connections.ts +81 -81
- package/front_end/core/sdk/ConsoleModel.ts +68 -68
- package/front_end/core/sdk/Cookie.ts +48 -48
- package/front_end/core/sdk/CookieModel.ts +13 -13
- package/front_end/core/sdk/CookieParser.ts +45 -45
- package/front_end/core/sdk/DOMDebuggerModel.ts +131 -131
- package/front_end/core/sdk/DOMModel.ts +264 -252
- package/front_end/core/sdk/DebuggerModel.ts +209 -205
- package/front_end/core/sdk/EmulationModel.ts +76 -76
- package/front_end/core/sdk/FilmStripModel.ts +29 -29
- package/front_end/core/sdk/FrameManager.ts +43 -42
- package/front_end/core/sdk/HeapProfilerModel.ts +36 -36
- package/front_end/core/sdk/IsolateManager.ts +82 -82
- package/front_end/core/sdk/IssuesModel.ts +6 -6
- package/front_end/core/sdk/LayerTreeBase.ts +37 -37
- package/front_end/core/sdk/LogModel.ts +5 -5
- package/front_end/core/sdk/NetworkManager.ts +229 -225
- package/front_end/core/sdk/NetworkRequest.ts +368 -360
- package/front_end/core/sdk/OverlayColorGenerator.ts +9 -9
- package/front_end/core/sdk/OverlayModel.ts +155 -153
- package/front_end/core/sdk/OverlayPersistentHighlighter.ts +100 -101
- package/front_end/core/sdk/PageResourceLoader.ts +30 -30
- package/front_end/core/sdk/PaintProfiler.ts +16 -16
- package/front_end/core/sdk/PerformanceMetricsModel.ts +12 -12
- package/front_end/core/sdk/ProfileTreeModel.ts +3 -3
- package/front_end/core/sdk/RemoteObject.ts +108 -104
- package/front_end/core/sdk/Resource.ts +85 -84
- package/front_end/core/sdk/ResourceTreeModel.ts +150 -145
- package/front_end/core/sdk/RuntimeModel.ts +38 -34
- package/front_end/core/sdk/SDKModel.ts +3 -3
- package/front_end/core/sdk/ScreenCaptureModel.ts +19 -19
- package/front_end/core/sdk/Script.ts +29 -29
- package/front_end/core/sdk/SecurityOriginManager.ts +19 -19
- package/front_end/core/sdk/ServerTiming.ts +2 -2
- package/front_end/core/sdk/ServiceWorkerCacheModel.ts +43 -43
- package/front_end/core/sdk/ServiceWorkerManager.ts +72 -68
- package/front_end/core/sdk/SourceMap.ts +40 -36
- package/front_end/core/sdk/SourceMapManager.ts +57 -57
- package/front_end/core/sdk/Target.ts +64 -63
- package/front_end/core/sdk/TargetManager.ts +60 -56
- package/front_end/core/sdk/TracingManager.ts +39 -39
- package/front_end/core/sdk/TracingModel.ts +125 -125
- package/front_end/core/sdk/WebAuthnModel.ts +9 -9
- package/front_end/entrypoints/lighthouse_worker/{LighthouseService.js → LighthouseService.ts} +20 -45
- package/front_end/entrypoints/lighthouse_worker/{lighthouse_worker.js → lighthouse_worker.ts} +0 -0
- package/front_end/entrypoints/main/MainImpl.ts +7 -2
- package/front_end/legacy_test_runner/elements_test_runner/ElementsTestRunner.js +4 -4
- package/front_end/legacy_test_runner/sdk_test_runner/sdk_test_runner.js +1 -1
- package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +0 -6
- package/front_end/models/issues_manager/GenericIssue.ts +86 -0
- package/front_end/models/issues_manager/Issue.ts +24 -0
- package/front_end/models/issues_manager/IssuesManager.ts +18 -6
- package/front_end/models/issues_manager/descriptions/genericCrossOriginPortalPostMessageError.md +3 -0
- package/front_end/models/issues_manager/issues_manager.ts +2 -0
- package/front_end/models/javascript_metadata/NativeFunctions.js +5422 -1
- package/front_end/panels/console/ConsoleSidebar.ts +0 -3
- package/front_end/panels/elements/ElementsTreeElement.ts +53 -61
- package/front_end/panels/elements/ElementsTreeOutline.ts +0 -1
- package/front_end/panels/elements/components/LayoutPane.ts +5 -1
- package/front_end/panels/issues/GenericIssueDetailsView.ts +68 -0
- package/front_end/panels/issues/IssueAggregator.ts +16 -0
- package/front_end/panels/issues/IssueKindView.ts +95 -0
- package/front_end/panels/issues/IssueView.ts +6 -0
- package/front_end/panels/issues/IssuesPane.ts +81 -18
- package/front_end/panels/issues/issuesTree.css +8 -3
- package/front_end/panels/lighthouse/LighthouseController.ts +3 -1
- package/front_end/panels/network/NetworkItemView.ts +1 -1
- package/front_end/panels/network/networkLogView.css +5 -0
- package/front_end/panels/sensors/LocationsSettingsTab.ts +1 -1
- package/front_end/panels/settings/SettingsScreen.ts +1 -0
- package/front_end/panels/settings/settingsScreen.css +24 -0
- package/front_end/panels/snippets/SnippetsQuickOpen.ts +8 -3
- package/front_end/panels/sources/TabbedEditorContainer.ts +1 -1
- package/front_end/panels/sources/sources-meta.ts +22 -7
- package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
- package/front_end/third_party/codemirror.next/package.json +4 -4
- package/front_end/ui/components/code_highlighter/CodeHighlighter.ts +137 -0
- package/front_end/ui/components/code_highlighter/codeHighlighter.css +51 -0
- package/front_end/ui/components/code_highlighter/code_highlighter.ts +11 -0
- package/front_end/ui/components/docs/text_editor/basic.html +28 -0
- package/front_end/ui/components/docs/text_editor/basic.ts +14 -0
- package/front_end/ui/components/docs/text_prompt/basic.html +35 -0
- package/front_end/ui/components/docs/text_prompt/basic.ts +19 -0
- package/front_end/ui/components/issue_counter/IssueLinkIcon.ts +1 -0
- package/front_end/ui/components/render_coordinator/RenderCoordinator.ts +17 -0
- package/front_end/ui/components/request_link_icon/RequestLinkIcon.ts +1 -0
- package/front_end/ui/components/text_editor/TextEditor.ts +161 -0
- package/front_end/ui/components/text_editor/config.ts +264 -0
- package/front_end/{panels/console/components/components.ts → ui/components/text_editor/text_editor.ts} +2 -5
- package/front_end/ui/components/text_editor/theme.ts +113 -0
- package/front_end/ui/components/text_prompt/TextPrompt.ts +144 -0
- package/front_end/ui/components/text_prompt/textPrompt.css +33 -0
- package/front_end/ui/components/text_prompt/text_prompt.ts +9 -0
- package/front_end/ui/legacy/ARIAUtils.ts +14 -11
- package/front_end/ui/legacy/TabbedPane.ts +32 -3
- package/front_end/ui/legacy/UIUtils.ts +3 -1
- package/front_end/ui/legacy/View.ts +6 -0
- package/front_end/ui/legacy/ViewManager.ts +5 -1
- package/front_end/ui/legacy/ViewRegistration.ts +5 -0
- package/front_end/ui/legacy/XLink.ts +1 -1
- package/front_end/ui/legacy/closeButton.css +6 -0
- package/front_end/ui/legacy/components/quick_open/CommandMenu.ts +8 -3
- package/front_end/ui/legacy/components/quick_open/FilteredListWidget.ts +38 -38
- package/front_end/ui/legacy/components/quick_open/HelpQuickOpen.ts +10 -4
- package/front_end/ui/legacy/components/quick_open/QuickOpen.ts +23 -6
- package/front_end/ui/legacy/components/quick_open/filteredListWidget.css +14 -16
- package/front_end/ui/legacy/filter.css +1 -0
- package/front_end/ui/legacy/tabbedPane.css +24 -0
- package/front_end/ui/legacy/toolbar.css +5 -0
- package/inspector_overlay/main.ts +2 -1
- package/inspector_overlay/tool_screenshot.ts +8 -1
- package/package.json +1 -1
- package/scripts/build/rollup.config.js +9 -0
- package/scripts/migration/class-fields/migrate.js +56 -0
- package/scripts/migration/class-fields/package.json +5 -0
- package/front_end/panels/console/components/SidebarDeprecation.ts +0 -58
- package/front_end/panels/console/components/sidebarDeprecation.css +0 -17
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// Copyright 2021 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
1
5
|
/*
|
|
2
6
|
* Copyright (C) 2010 Google Inc. All rights reserved.
|
|
3
7
|
*
|
|
@@ -11,7 +15,7 @@
|
|
|
11
15
|
* copyright notice, this list of conditions and the following disclaimer
|
|
12
16
|
* in the documentation and/or other materials provided with the
|
|
13
17
|
* distribution.
|
|
14
|
-
* * Neither the name of Google Inc. nor the names of its
|
|
18
|
+
* * Neither the #name of Google Inc. nor the names of its
|
|
15
19
|
* contributors may be used to endorse or promote products derived from
|
|
16
20
|
* this software without specific prior written permission.
|
|
17
21
|
*
|
|
@@ -50,62 +54,62 @@ import {SDKModel} from './SDKModel.js';
|
|
|
50
54
|
import {SourceMapManager} from './SourceMapManager.js';
|
|
51
55
|
|
|
52
56
|
export class CSSModel extends SDKModel<EventTypes> {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
#isEnabledInternal: boolean;
|
|
58
|
+
#cachedMatchedCascadeNode: DOMNode|null;
|
|
59
|
+
#cachedMatchedCascadePromise: Promise<CSSMatchedStyles|null>|null;
|
|
60
|
+
readonly #domModelInternal: DOMModel;
|
|
61
|
+
readonly #sourceMapManagerInternal: SourceMapManager<CSSStyleSheetHeader>;
|
|
58
62
|
agent: ProtocolProxyApi.CSSApi;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
readonly #styleLoader: ComputedStyleLoader;
|
|
64
|
+
readonly #resourceTreeModel: ResourceTreeModel|null;
|
|
65
|
+
#styleSheetIdToHeader: Map<Protocol.CSS.StyleSheetId, CSSStyleSheetHeader>;
|
|
66
|
+
readonly #styleSheetIdsForURL: Map<string, Map<string, Set<Protocol.CSS.StyleSheetId>>>;
|
|
67
|
+
readonly #originalStyleSheetTextInternal: Map<CSSStyleSheetHeader, Promise<string|null>>;
|
|
68
|
+
#isRuleUsageTrackingEnabled: boolean;
|
|
69
|
+
readonly #fontFacesInternal: Map<string, CSSFontFace>;
|
|
70
|
+
#cssPropertyTracker: CSSPropertyTracker|null;
|
|
71
|
+
#isCSSPropertyTrackingEnabled: boolean;
|
|
72
|
+
#isTrackingRequestPending: boolean;
|
|
73
|
+
readonly #trackedCSSProperties: Map<number, Protocol.CSS.CSSComputedStyleProperty[]>;
|
|
74
|
+
readonly #stylePollingThrottler: Common.Throttler.Throttler;
|
|
71
75
|
|
|
72
76
|
constructor(target: Target) {
|
|
73
77
|
super(target);
|
|
74
|
-
this
|
|
75
|
-
this
|
|
76
|
-
this
|
|
77
|
-
this
|
|
78
|
-
this
|
|
78
|
+
this.#isEnabledInternal = false;
|
|
79
|
+
this.#cachedMatchedCascadeNode = null;
|
|
80
|
+
this.#cachedMatchedCascadePromise = null;
|
|
81
|
+
this.#domModelInternal = (target.model(DOMModel) as DOMModel);
|
|
82
|
+
this.#sourceMapManagerInternal = new SourceMapManager(target);
|
|
79
83
|
this.agent = target.cssAgent();
|
|
80
|
-
this
|
|
81
|
-
this
|
|
82
|
-
if (this
|
|
83
|
-
this
|
|
84
|
+
this.#styleLoader = new ComputedStyleLoader(this);
|
|
85
|
+
this.#resourceTreeModel = target.model(ResourceTreeModel);
|
|
86
|
+
if (this.#resourceTreeModel) {
|
|
87
|
+
this.#resourceTreeModel.addEventListener(ResourceTreeModelEvents.MainFrameNavigated, this.resetStyleSheets, this);
|
|
84
88
|
}
|
|
85
89
|
target.registerCSSDispatcher(new CSSDispatcher(this));
|
|
86
90
|
if (!target.suspended()) {
|
|
87
91
|
this.enable();
|
|
88
92
|
}
|
|
89
|
-
this
|
|
90
|
-
this
|
|
93
|
+
this.#styleSheetIdToHeader = new Map();
|
|
94
|
+
this.#styleSheetIdsForURL = new Map();
|
|
91
95
|
|
|
92
|
-
this
|
|
96
|
+
this.#originalStyleSheetTextInternal = new Map();
|
|
93
97
|
|
|
94
|
-
this
|
|
98
|
+
this.#isRuleUsageTrackingEnabled = false;
|
|
95
99
|
|
|
96
|
-
this
|
|
100
|
+
this.#fontFacesInternal = new Map();
|
|
97
101
|
|
|
98
|
-
this
|
|
99
|
-
this
|
|
100
|
-
this
|
|
101
|
-
this
|
|
102
|
-
this
|
|
102
|
+
this.#cssPropertyTracker = null; // TODO: support multiple trackers when we refactor the backend
|
|
103
|
+
this.#isCSSPropertyTrackingEnabled = false;
|
|
104
|
+
this.#isTrackingRequestPending = false;
|
|
105
|
+
this.#trackedCSSProperties = new Map();
|
|
106
|
+
this.#stylePollingThrottler = new Common.Throttler.Throttler(StylePollingInterval);
|
|
103
107
|
|
|
104
|
-
this
|
|
108
|
+
this.#sourceMapManagerInternal.setEnabled(
|
|
105
109
|
Common.Settings.Settings.instance().moduleSetting('cssSourceMapsEnabled').get());
|
|
106
110
|
Common.Settings.Settings.instance()
|
|
107
111
|
.moduleSetting('cssSourceMapsEnabled')
|
|
108
|
-
.addChangeListener(event => this
|
|
112
|
+
.addChangeListener(event => this.#sourceMapManagerInternal.setEnabled((event.data as boolean)));
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
headersForSourceURL(sourceURL: string): CSSStyleSheetHeader[] {
|
|
@@ -144,7 +148,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
144
148
|
}
|
|
145
149
|
|
|
146
150
|
sourceMapManager(): SourceMapManager<CSSStyleSheetHeader> {
|
|
147
|
-
return this
|
|
151
|
+
return this.#sourceMapManagerInternal;
|
|
148
152
|
}
|
|
149
153
|
|
|
150
154
|
static trimSourceURL(text: string): string {
|
|
@@ -168,7 +172,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
168
172
|
}
|
|
169
173
|
|
|
170
174
|
domModel(): DOMModel {
|
|
171
|
-
return this
|
|
175
|
+
return this.#domModelInternal;
|
|
172
176
|
}
|
|
173
177
|
|
|
174
178
|
async setStyleText(
|
|
@@ -183,7 +187,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
183
187
|
return false;
|
|
184
188
|
}
|
|
185
189
|
|
|
186
|
-
this
|
|
190
|
+
this.#domModelInternal.markUndoableState(!majorChange);
|
|
187
191
|
const edit = new Edit(styleSheetId, range, text, styles[0]);
|
|
188
192
|
this.fireStyleSheetChanged(styleSheetId, edit);
|
|
189
193
|
return true;
|
|
@@ -203,7 +207,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
203
207
|
if (!selectorList) {
|
|
204
208
|
return false;
|
|
205
209
|
}
|
|
206
|
-
this
|
|
210
|
+
this.#domModelInternal.markUndoableState();
|
|
207
211
|
const edit = new Edit(styleSheetId, range, text, selectorList);
|
|
208
212
|
this.fireStyleSheetChanged(styleSheetId, edit);
|
|
209
213
|
return true;
|
|
@@ -223,7 +227,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
223
227
|
if (!keyText) {
|
|
224
228
|
return false;
|
|
225
229
|
}
|
|
226
|
-
this
|
|
230
|
+
this.#domModelInternal.markUndoableState();
|
|
227
231
|
const edit = new Edit(styleSheetId, range, text, keyText);
|
|
228
232
|
this.fireStyleSheetChanged(styleSheetId, edit);
|
|
229
233
|
return true;
|
|
@@ -233,7 +237,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
233
237
|
}
|
|
234
238
|
|
|
235
239
|
startCoverage(): Promise<Protocol.ProtocolResponseWithError> {
|
|
236
|
-
this
|
|
240
|
+
this.#isRuleUsageTrackingEnabled = true;
|
|
237
241
|
return this.agent.invoke_startRuleUsageTracking();
|
|
238
242
|
}
|
|
239
243
|
|
|
@@ -254,7 +258,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
254
258
|
}
|
|
255
259
|
|
|
256
260
|
async stopCoverage(): Promise<void> {
|
|
257
|
-
this
|
|
261
|
+
this.#isRuleUsageTrackingEnabled = false;
|
|
258
262
|
await this.agent.invoke_stopRuleUsageTracking();
|
|
259
263
|
}
|
|
260
264
|
|
|
@@ -264,13 +268,13 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
264
268
|
}
|
|
265
269
|
|
|
266
270
|
isEnabled(): boolean {
|
|
267
|
-
return this
|
|
271
|
+
return this.#isEnabledInternal;
|
|
268
272
|
}
|
|
269
273
|
|
|
270
274
|
private async enable(): Promise<void> {
|
|
271
275
|
await this.agent.invoke_enable();
|
|
272
|
-
this
|
|
273
|
-
if (this
|
|
276
|
+
this.#isEnabledInternal = true;
|
|
277
|
+
if (this.#isRuleUsageTrackingEnabled) {
|
|
274
278
|
await this.startCoverage();
|
|
275
279
|
}
|
|
276
280
|
this.dispatchEventToListeners(Events.ModelWasEnabled);
|
|
@@ -283,7 +287,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
283
287
|
return null;
|
|
284
288
|
}
|
|
285
289
|
|
|
286
|
-
const node = this
|
|
290
|
+
const node = this.#domModelInternal.nodeForId(nodeId);
|
|
287
291
|
if (!node) {
|
|
288
292
|
return null;
|
|
289
293
|
}
|
|
@@ -300,7 +304,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
300
304
|
}
|
|
301
305
|
|
|
302
306
|
computedStylePromise(nodeId: Protocol.DOM.NodeId): Promise<Map<string, string>|null> {
|
|
303
|
-
return this
|
|
307
|
+
return this.#styleLoader.computedStylePromise(nodeId);
|
|
304
308
|
}
|
|
305
309
|
|
|
306
310
|
async backgroundColorsPromise(nodeId: Protocol.DOM.NodeId): Promise<ContrastInfo|null> {
|
|
@@ -322,7 +326,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
322
326
|
}
|
|
323
327
|
|
|
324
328
|
allStyleSheets(): CSSStyleSheetHeader[] {
|
|
325
|
-
const values = [...this
|
|
329
|
+
const values = [...this.#styleSheetIdToHeader.values()];
|
|
326
330
|
function styleSheetComparator(a: CSSStyleSheetHeader, b: CSSStyleSheetHeader): number {
|
|
327
331
|
if (a.sourceURL < b.sourceURL) {
|
|
328
332
|
return -1;
|
|
@@ -395,7 +399,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
395
399
|
if (!media) {
|
|
396
400
|
return false;
|
|
397
401
|
}
|
|
398
|
-
this
|
|
402
|
+
this.#domModelInternal.markUndoableState();
|
|
399
403
|
const edit = new Edit(styleSheetId, range, newMediaText, media);
|
|
400
404
|
this.fireStyleSheetChanged(styleSheetId, edit);
|
|
401
405
|
return true;
|
|
@@ -417,7 +421,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
417
421
|
if (!containerQuery) {
|
|
418
422
|
return false;
|
|
419
423
|
}
|
|
420
|
-
this
|
|
424
|
+
this.#domModelInternal.markUndoableState();
|
|
421
425
|
const edit = new Edit(styleSheetId, range, newContainerQueryText, containerQuery);
|
|
422
426
|
this.fireStyleSheetChanged(styleSheetId, edit);
|
|
423
427
|
return true;
|
|
@@ -435,7 +439,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
435
439
|
if (!rule) {
|
|
436
440
|
return null;
|
|
437
441
|
}
|
|
438
|
-
this
|
|
442
|
+
this.#domModelInternal.markUndoableState();
|
|
439
443
|
const edit = new Edit(styleSheetId, ruleLocation, ruleText, rule);
|
|
440
444
|
this.fireStyleSheetChanged(styleSheetId, edit);
|
|
441
445
|
return new CSSStyleRule(this, rule);
|
|
@@ -446,8 +450,8 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
446
450
|
|
|
447
451
|
async requestViaInspectorStylesheet(node: DOMNode): Promise<CSSStyleSheetHeader|null> {
|
|
448
452
|
const frameId = node.frameId() ||
|
|
449
|
-
(this
|
|
450
|
-
const headers = [...this
|
|
453
|
+
(this.#resourceTreeModel && this.#resourceTreeModel.mainFrame ? this.#resourceTreeModel.mainFrame.id : null);
|
|
454
|
+
const headers = [...this.#styleSheetIdToHeader.values()];
|
|
451
455
|
const styleSheetHeader = headers.find(header => header.frameId === frameId && header.isViaInspector());
|
|
452
456
|
if (styleSheetHeader) {
|
|
453
457
|
return styleSheetHeader;
|
|
@@ -461,7 +465,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
461
465
|
if (!styleSheetId) {
|
|
462
466
|
return null;
|
|
463
467
|
}
|
|
464
|
-
return this
|
|
468
|
+
return this.#styleSheetIdToHeader.get(styleSheetId) || null;
|
|
465
469
|
} catch (e) {
|
|
466
470
|
return null;
|
|
467
471
|
}
|
|
@@ -473,21 +477,21 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
473
477
|
|
|
474
478
|
fontsUpdated(fontFace?: Protocol.CSS.FontFace|null): void {
|
|
475
479
|
if (fontFace) {
|
|
476
|
-
this
|
|
480
|
+
this.#fontFacesInternal.set(fontFace.src, new CSSFontFace(fontFace));
|
|
477
481
|
}
|
|
478
482
|
this.dispatchEventToListeners(Events.FontsUpdated);
|
|
479
483
|
}
|
|
480
484
|
|
|
481
485
|
fontFaces(): CSSFontFace[] {
|
|
482
|
-
return [...this
|
|
486
|
+
return [...this.#fontFacesInternal.values()];
|
|
483
487
|
}
|
|
484
488
|
|
|
485
489
|
styleSheetHeaderForId(id: Protocol.CSS.StyleSheetId): CSSStyleSheetHeader|null {
|
|
486
|
-
return this
|
|
490
|
+
return this.#styleSheetIdToHeader.get(id) || null;
|
|
487
491
|
}
|
|
488
492
|
|
|
489
493
|
styleSheetHeaders(): CSSStyleSheetHeader[] {
|
|
490
|
-
return [...this
|
|
494
|
+
return [...this.#styleSheetIdToHeader.values()];
|
|
491
495
|
}
|
|
492
496
|
|
|
493
497
|
fireStyleSheetChanged(styleSheetId: Protocol.CSS.StyleSheetId, edit?: Edit): void {
|
|
@@ -499,10 +503,10 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
499
503
|
if (!header) {
|
|
500
504
|
return Promise.resolve(null);
|
|
501
505
|
}
|
|
502
|
-
let promise = this
|
|
506
|
+
let promise = this.#originalStyleSheetTextInternal.get(header);
|
|
503
507
|
if (!promise) {
|
|
504
508
|
promise = this.getStyleSheetText(header.id);
|
|
505
|
-
this
|
|
509
|
+
this.#originalStyleSheetTextInternal.set(header, promise);
|
|
506
510
|
this.originalContentRequestedForTest(header);
|
|
507
511
|
}
|
|
508
512
|
return promise;
|
|
@@ -516,18 +520,18 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
516
520
|
}
|
|
517
521
|
|
|
518
522
|
getAllStyleSheetHeaders(): Iterable<CSSStyleSheetHeader> {
|
|
519
|
-
return this
|
|
523
|
+
return this.#styleSheetIdToHeader.values();
|
|
520
524
|
}
|
|
521
525
|
|
|
522
526
|
styleSheetAdded(header: Protocol.CSS.CSSStyleSheetHeader): void {
|
|
523
|
-
console.assert(!this
|
|
527
|
+
console.assert(!this.#styleSheetIdToHeader.get(header.styleSheetId));
|
|
524
528
|
const styleSheetHeader = new CSSStyleSheetHeader(this, header);
|
|
525
|
-
this
|
|
529
|
+
this.#styleSheetIdToHeader.set(header.styleSheetId, styleSheetHeader);
|
|
526
530
|
const url = styleSheetHeader.resourceURL();
|
|
527
|
-
let frameIdToStyleSheetIds = this
|
|
531
|
+
let frameIdToStyleSheetIds = this.#styleSheetIdsForURL.get(url);
|
|
528
532
|
if (!frameIdToStyleSheetIds) {
|
|
529
533
|
frameIdToStyleSheetIds = new Map();
|
|
530
|
-
this
|
|
534
|
+
this.#styleSheetIdsForURL.set(url, frameIdToStyleSheetIds);
|
|
531
535
|
}
|
|
532
536
|
if (frameIdToStyleSheetIds) {
|
|
533
537
|
let styleSheetIds = frameIdToStyleSheetIds.get(styleSheetHeader.frameId);
|
|
@@ -537,20 +541,20 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
537
541
|
}
|
|
538
542
|
styleSheetIds.add(styleSheetHeader.id);
|
|
539
543
|
}
|
|
540
|
-
this
|
|
544
|
+
this.#sourceMapManagerInternal.attachSourceMap(
|
|
541
545
|
styleSheetHeader, styleSheetHeader.sourceURL, styleSheetHeader.sourceMapURL);
|
|
542
546
|
this.dispatchEventToListeners(Events.StyleSheetAdded, styleSheetHeader);
|
|
543
547
|
}
|
|
544
548
|
|
|
545
549
|
styleSheetRemoved(id: Protocol.CSS.StyleSheetId): void {
|
|
546
|
-
const header = this
|
|
550
|
+
const header = this.#styleSheetIdToHeader.get(id);
|
|
547
551
|
console.assert(Boolean(header));
|
|
548
552
|
if (!header) {
|
|
549
553
|
return;
|
|
550
554
|
}
|
|
551
|
-
this
|
|
555
|
+
this.#styleSheetIdToHeader.delete(id);
|
|
552
556
|
const url = header.resourceURL();
|
|
553
|
-
const frameIdToStyleSheetIds = this
|
|
557
|
+
const frameIdToStyleSheetIds = this.#styleSheetIdsForURL.get(url);
|
|
554
558
|
console.assert(
|
|
555
559
|
Boolean(frameIdToStyleSheetIds), 'No frameId to styleSheetId map is available for given style sheet URL.');
|
|
556
560
|
if (frameIdToStyleSheetIds) {
|
|
@@ -560,18 +564,18 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
560
564
|
if (!stylesheetIds.size) {
|
|
561
565
|
frameIdToStyleSheetIds.delete(header.frameId);
|
|
562
566
|
if (!frameIdToStyleSheetIds.size) {
|
|
563
|
-
this
|
|
567
|
+
this.#styleSheetIdsForURL.delete(url);
|
|
564
568
|
}
|
|
565
569
|
}
|
|
566
570
|
}
|
|
567
571
|
}
|
|
568
|
-
this
|
|
569
|
-
this
|
|
572
|
+
this.#originalStyleSheetTextInternal.delete(header);
|
|
573
|
+
this.#sourceMapManagerInternal.detachSourceMap(header);
|
|
570
574
|
this.dispatchEventToListeners(Events.StyleSheetRemoved, header);
|
|
571
575
|
}
|
|
572
576
|
|
|
573
577
|
getStyleSheetIdsForURL(url: string): Protocol.CSS.StyleSheetId[] {
|
|
574
|
-
const frameIdToStyleSheetIds = this
|
|
578
|
+
const frameIdToStyleSheetIds = this.#styleSheetIdsForURL.get(url);
|
|
575
579
|
if (!frameIdToStyleSheetIds) {
|
|
576
580
|
return [];
|
|
577
581
|
}
|
|
@@ -585,7 +589,7 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
585
589
|
|
|
586
590
|
async setStyleSheetText(styleSheetId: Protocol.CSS.StyleSheetId, newText: string, majorChange: boolean):
|
|
587
591
|
Promise<string|null> {
|
|
588
|
-
const header = this
|
|
592
|
+
const header = this.#styleSheetIdToHeader.get(styleSheetId);
|
|
589
593
|
if (!header) {
|
|
590
594
|
return 'Unknown stylesheet in CSS.setStyleSheetText';
|
|
591
595
|
}
|
|
@@ -598,13 +602,13 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
598
602
|
const response = await this.agent.invoke_setStyleSheetText({styleSheetId: header.id, text: newText});
|
|
599
603
|
const sourceMapURL = response.sourceMapURL;
|
|
600
604
|
|
|
601
|
-
this
|
|
605
|
+
this.#sourceMapManagerInternal.detachSourceMap(header);
|
|
602
606
|
header.setSourceMapURL(sourceMapURL);
|
|
603
|
-
this
|
|
607
|
+
this.#sourceMapManagerInternal.attachSourceMap(header, header.sourceURL, header.sourceMapURL);
|
|
604
608
|
if (sourceMapURL === null) {
|
|
605
609
|
return 'Error in CSS.setStyleSheetText';
|
|
606
610
|
}
|
|
607
|
-
this
|
|
611
|
+
this.#domModelInternal.markUndoableState(!majorChange);
|
|
608
612
|
this.fireStyleSheetChanged(styleSheetId);
|
|
609
613
|
return null;
|
|
610
614
|
}
|
|
@@ -619,21 +623,21 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
619
623
|
}
|
|
620
624
|
|
|
621
625
|
private resetStyleSheets(): void {
|
|
622
|
-
const headers = [...this
|
|
623
|
-
this
|
|
624
|
-
this
|
|
626
|
+
const headers = [...this.#styleSheetIdToHeader.values()];
|
|
627
|
+
this.#styleSheetIdsForURL.clear();
|
|
628
|
+
this.#styleSheetIdToHeader.clear();
|
|
625
629
|
for (const header of headers) {
|
|
626
|
-
this
|
|
630
|
+
this.#sourceMapManagerInternal.detachSourceMap(header);
|
|
627
631
|
this.dispatchEventToListeners(Events.StyleSheetRemoved, header);
|
|
628
632
|
}
|
|
629
633
|
}
|
|
630
634
|
|
|
631
635
|
private resetFontFaces(): void {
|
|
632
|
-
this
|
|
636
|
+
this.#fontFacesInternal.clear();
|
|
633
637
|
}
|
|
634
638
|
|
|
635
639
|
async suspendModel(): Promise<void> {
|
|
636
|
-
this
|
|
640
|
+
this.#isEnabledInternal = false;
|
|
637
641
|
await this.agent.invoke_disable();
|
|
638
642
|
this.resetStyleSheets();
|
|
639
643
|
this.resetFontFaces();
|
|
@@ -648,23 +652,23 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
648
652
|
}
|
|
649
653
|
|
|
650
654
|
cachedMatchedCascadeForNode(node: DOMNode): Promise<CSSMatchedStyles|null> {
|
|
651
|
-
if (this
|
|
655
|
+
if (this.#cachedMatchedCascadeNode !== node) {
|
|
652
656
|
this.discardCachedMatchedCascade();
|
|
653
657
|
}
|
|
654
|
-
this
|
|
655
|
-
if (!this
|
|
658
|
+
this.#cachedMatchedCascadeNode = node;
|
|
659
|
+
if (!this.#cachedMatchedCascadePromise) {
|
|
656
660
|
if (node.id) {
|
|
657
|
-
this
|
|
661
|
+
this.#cachedMatchedCascadePromise = this.matchedStylesPromise(node.id);
|
|
658
662
|
} else {
|
|
659
663
|
return Promise.resolve(null);
|
|
660
664
|
}
|
|
661
665
|
}
|
|
662
|
-
return this
|
|
666
|
+
return this.#cachedMatchedCascadePromise;
|
|
663
667
|
}
|
|
664
668
|
|
|
665
669
|
discardCachedMatchedCascade(): void {
|
|
666
|
-
this
|
|
667
|
-
this
|
|
670
|
+
this.#cachedMatchedCascadeNode = null;
|
|
671
|
+
this.#cachedMatchedCascadePromise = null;
|
|
668
672
|
}
|
|
669
673
|
|
|
670
674
|
createCSSPropertyTracker(propertiesToTrack: Protocol.CSS.CSSComputedStyleProperty[]): CSSPropertyTracker {
|
|
@@ -678,50 +682,50 @@ export class CSSModel extends SDKModel<EventTypes> {
|
|
|
678
682
|
return;
|
|
679
683
|
}
|
|
680
684
|
this.agent.invoke_trackComputedStyleUpdates({propertiesToTrack});
|
|
681
|
-
this
|
|
682
|
-
this
|
|
685
|
+
this.#isCSSPropertyTrackingEnabled = true;
|
|
686
|
+
this.#cssPropertyTracker = cssPropertyTracker;
|
|
683
687
|
this.pollComputedStyleUpdates();
|
|
684
688
|
}
|
|
685
689
|
|
|
686
690
|
// Since we only support one tracker at a time, this call effectively disables
|
|
687
691
|
// style tracking.
|
|
688
692
|
disableCSSPropertyTracker(): void {
|
|
689
|
-
this
|
|
690
|
-
this
|
|
693
|
+
this.#isCSSPropertyTrackingEnabled = false;
|
|
694
|
+
this.#cssPropertyTracker = null;
|
|
691
695
|
// Sending an empty list to the backend signals the close of style tracking
|
|
692
696
|
this.agent.invoke_trackComputedStyleUpdates({propertiesToTrack: []});
|
|
693
697
|
}
|
|
694
698
|
|
|
695
699
|
private async pollComputedStyleUpdates(): Promise<void> {
|
|
696
|
-
if (this
|
|
700
|
+
if (this.#isTrackingRequestPending) {
|
|
697
701
|
return;
|
|
698
702
|
}
|
|
699
703
|
|
|
700
|
-
if (this
|
|
701
|
-
this
|
|
704
|
+
if (this.#isCSSPropertyTrackingEnabled) {
|
|
705
|
+
this.#isTrackingRequestPending = true;
|
|
702
706
|
const result = await this.agent.invoke_takeComputedStyleUpdates();
|
|
703
|
-
this
|
|
707
|
+
this.#isTrackingRequestPending = false;
|
|
704
708
|
|
|
705
|
-
if (result.getError() || !result.nodeIds || !this
|
|
709
|
+
if (result.getError() || !result.nodeIds || !this.#isCSSPropertyTrackingEnabled) {
|
|
706
710
|
return;
|
|
707
711
|
}
|
|
708
712
|
|
|
709
|
-
if (this
|
|
710
|
-
this
|
|
713
|
+
if (this.#cssPropertyTracker) {
|
|
714
|
+
this.#cssPropertyTracker.dispatchEventToListeners(
|
|
711
715
|
CSSPropertyTrackerEvents.TrackedCSSPropertiesUpdated,
|
|
712
|
-
result.nodeIds.map(nodeId => this
|
|
716
|
+
result.nodeIds.map(nodeId => this.#domModelInternal.nodeForId(nodeId)));
|
|
713
717
|
}
|
|
714
718
|
}
|
|
715
719
|
|
|
716
|
-
if (this
|
|
717
|
-
this
|
|
720
|
+
if (this.#isCSSPropertyTrackingEnabled) {
|
|
721
|
+
this.#stylePollingThrottler.schedule(this.pollComputedStyleUpdates.bind(this));
|
|
718
722
|
}
|
|
719
723
|
}
|
|
720
724
|
|
|
721
725
|
dispose(): void {
|
|
722
726
|
this.disableCSSPropertyTracker();
|
|
723
727
|
super.dispose();
|
|
724
|
-
this
|
|
728
|
+
this.#sourceMapManagerInternal.dispose();
|
|
725
729
|
}
|
|
726
730
|
|
|
727
731
|
getAgent(): ProtocolProxyApi.CSSApi {
|
|
@@ -780,13 +784,13 @@ export class Edit {
|
|
|
780
784
|
}
|
|
781
785
|
|
|
782
786
|
export class CSSLocation {
|
|
783
|
-
|
|
787
|
+
readonly #cssModelInternal: CSSModel;
|
|
784
788
|
styleSheetId: Protocol.CSS.StyleSheetId;
|
|
785
789
|
url: string;
|
|
786
790
|
lineNumber: number;
|
|
787
791
|
columnNumber: number;
|
|
788
792
|
constructor(header: CSSStyleSheetHeader, lineNumber: number, columnNumber?: number) {
|
|
789
|
-
this
|
|
793
|
+
this.#cssModelInternal = header.cssModel();
|
|
790
794
|
this.styleSheetId = header.id;
|
|
791
795
|
this.url = header.resourceURL();
|
|
792
796
|
this.lineNumber = lineNumber;
|
|
@@ -794,56 +798,56 @@ export class CSSLocation {
|
|
|
794
798
|
}
|
|
795
799
|
|
|
796
800
|
cssModel(): CSSModel {
|
|
797
|
-
return this
|
|
801
|
+
return this.#cssModelInternal;
|
|
798
802
|
}
|
|
799
803
|
|
|
800
804
|
header(): CSSStyleSheetHeader|null {
|
|
801
|
-
return this
|
|
805
|
+
return this.#cssModelInternal.styleSheetHeaderForId(this.styleSheetId);
|
|
802
806
|
}
|
|
803
807
|
}
|
|
804
808
|
|
|
805
809
|
class CSSDispatcher implements ProtocolProxyApi.CSSDispatcher {
|
|
806
|
-
|
|
810
|
+
readonly #cssModel: CSSModel;
|
|
807
811
|
constructor(cssModel: CSSModel) {
|
|
808
|
-
this
|
|
812
|
+
this.#cssModel = cssModel;
|
|
809
813
|
}
|
|
810
814
|
|
|
811
815
|
mediaQueryResultChanged(): void {
|
|
812
|
-
this
|
|
816
|
+
this.#cssModel.mediaQueryResultChanged();
|
|
813
817
|
}
|
|
814
818
|
|
|
815
819
|
fontsUpdated({font}: Protocol.CSS.FontsUpdatedEvent): void {
|
|
816
|
-
this
|
|
820
|
+
this.#cssModel.fontsUpdated(font);
|
|
817
821
|
}
|
|
818
822
|
|
|
819
823
|
styleSheetChanged({styleSheetId}: Protocol.CSS.StyleSheetChangedEvent): void {
|
|
820
|
-
this
|
|
824
|
+
this.#cssModel.fireStyleSheetChanged(styleSheetId);
|
|
821
825
|
}
|
|
822
826
|
|
|
823
827
|
styleSheetAdded({header}: Protocol.CSS.StyleSheetAddedEvent): void {
|
|
824
|
-
this
|
|
828
|
+
this.#cssModel.styleSheetAdded(header);
|
|
825
829
|
}
|
|
826
830
|
|
|
827
831
|
styleSheetRemoved({styleSheetId}: Protocol.CSS.StyleSheetRemovedEvent): void {
|
|
828
|
-
this
|
|
832
|
+
this.#cssModel.styleSheetRemoved(styleSheetId);
|
|
829
833
|
}
|
|
830
834
|
}
|
|
831
835
|
|
|
832
836
|
class ComputedStyleLoader {
|
|
833
|
-
|
|
834
|
-
|
|
837
|
+
#cssModel: CSSModel;
|
|
838
|
+
#nodeIdToPromise: Map<number, Promise<Map<string, string>|null>>;
|
|
835
839
|
constructor(cssModel: CSSModel) {
|
|
836
|
-
this
|
|
837
|
-
this
|
|
840
|
+
this.#cssModel = cssModel;
|
|
841
|
+
this.#nodeIdToPromise = new Map();
|
|
838
842
|
}
|
|
839
843
|
|
|
840
844
|
computedStylePromise(nodeId: Protocol.DOM.NodeId): Promise<Map<string, string>|null> {
|
|
841
|
-
let promise = this
|
|
845
|
+
let promise = this.#nodeIdToPromise.get(nodeId);
|
|
842
846
|
if (promise) {
|
|
843
847
|
return promise;
|
|
844
848
|
}
|
|
845
|
-
promise = this
|
|
846
|
-
this
|
|
849
|
+
promise = this.#cssModel.getAgent().invoke_getComputedStyleForNode({nodeId}).then(({computedStyle}) => {
|
|
850
|
+
this.#nodeIdToPromise.delete(nodeId);
|
|
847
851
|
if (!computedStyle || !computedStyle.length) {
|
|
848
852
|
return null;
|
|
849
853
|
}
|
|
@@ -853,7 +857,7 @@ class ComputedStyleLoader {
|
|
|
853
857
|
}
|
|
854
858
|
return result;
|
|
855
859
|
});
|
|
856
|
-
this
|
|
860
|
+
this.#nodeIdToPromise.set(nodeId, promise);
|
|
857
861
|
return promise;
|
|
858
862
|
}
|
|
859
863
|
}
|
|
@@ -868,24 +872,24 @@ export class InlineStyleResult {
|
|
|
868
872
|
}
|
|
869
873
|
|
|
870
874
|
export class CSSPropertyTracker extends Common.ObjectWrapper.ObjectWrapper<CSSPropertyTrackerEventTypes> {
|
|
871
|
-
|
|
872
|
-
|
|
875
|
+
readonly #cssModel: CSSModel;
|
|
876
|
+
readonly #properties: Protocol.CSS.CSSComputedStyleProperty[];
|
|
873
877
|
constructor(cssModel: CSSModel, propertiesToTrack: Protocol.CSS.CSSComputedStyleProperty[]) {
|
|
874
878
|
super();
|
|
875
|
-
this
|
|
876
|
-
this
|
|
879
|
+
this.#cssModel = cssModel;
|
|
880
|
+
this.#properties = propertiesToTrack;
|
|
877
881
|
}
|
|
878
882
|
|
|
879
883
|
start(): void {
|
|
880
|
-
this
|
|
884
|
+
this.#cssModel.enableCSSPropertyTracker(this);
|
|
881
885
|
}
|
|
882
886
|
|
|
883
887
|
stop(): void {
|
|
884
|
-
this
|
|
888
|
+
this.#cssModel.disableCSSPropertyTracker();
|
|
885
889
|
}
|
|
886
890
|
|
|
887
891
|
getTrackedProperties(): Protocol.CSS.CSSComputedStyleProperty[] {
|
|
888
|
-
return this
|
|
892
|
+
return this.#properties;
|
|
889
893
|
}
|
|
890
894
|
}
|
|
891
895
|
|