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
|
@@ -13,46 +13,46 @@ import {CSSStyleDeclaration, Type} from './CSSStyleDeclaration.js';
|
|
|
13
13
|
import type {DOMNode} from './DOMModel.js';
|
|
14
14
|
|
|
15
15
|
export class CSSMatchedStyles {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
readonly #cssModelInternal: CSSModel;
|
|
17
|
+
readonly #nodeInternal: DOMNode;
|
|
18
|
+
readonly #addedStyles: Map<CSSStyleDeclaration, DOMNode>;
|
|
19
|
+
readonly #matchingSelectors: Map<number, Map<string, boolean>>;
|
|
20
|
+
readonly #keyframesInternal: CSSKeyframesRule[];
|
|
21
|
+
readonly #nodeForStyleInternal: Map<CSSStyleDeclaration, DOMNode|null>;
|
|
22
|
+
readonly #inheritedStyles: Set<CSSStyleDeclaration>;
|
|
23
|
+
readonly #mainDOMCascade: DOMInheritanceCascade;
|
|
24
|
+
readonly #pseudoDOMCascades: Map<Protocol.DOM.PseudoType, DOMInheritanceCascade>;
|
|
25
|
+
readonly #styleToDOMCascade: Map<CSSStyleDeclaration, DOMInheritanceCascade>;
|
|
26
26
|
|
|
27
27
|
constructor(
|
|
28
28
|
cssModel: CSSModel, node: DOMNode, inlinePayload: Protocol.CSS.CSSStyle|null,
|
|
29
29
|
attributesPayload: Protocol.CSS.CSSStyle|null, matchedPayload: Protocol.CSS.RuleMatch[],
|
|
30
30
|
pseudoPayload: Protocol.CSS.PseudoElementMatches[], inheritedPayload: Protocol.CSS.InheritedStyleEntry[],
|
|
31
31
|
animationsPayload: Protocol.CSS.CSSKeyframesRule[]) {
|
|
32
|
-
this
|
|
33
|
-
this
|
|
34
|
-
this
|
|
35
|
-
this
|
|
36
|
-
this
|
|
32
|
+
this.#cssModelInternal = cssModel;
|
|
33
|
+
this.#nodeInternal = node;
|
|
34
|
+
this.#addedStyles = new Map();
|
|
35
|
+
this.#matchingSelectors = new Map();
|
|
36
|
+
this.#keyframesInternal = [];
|
|
37
37
|
if (animationsPayload) {
|
|
38
|
-
this
|
|
38
|
+
this.#keyframesInternal = animationsPayload.map(rule => new CSSKeyframesRule(cssModel, rule));
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
this
|
|
42
|
-
this
|
|
41
|
+
this.#nodeForStyleInternal = new Map();
|
|
42
|
+
this.#inheritedStyles = new Set();
|
|
43
43
|
|
|
44
44
|
matchedPayload = cleanUserAgentPayload(matchedPayload);
|
|
45
45
|
for (const inheritedResult of inheritedPayload) {
|
|
46
46
|
inheritedResult.matchedCSSRules = cleanUserAgentPayload(inheritedResult.matchedCSSRules);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
this
|
|
50
|
-
this
|
|
49
|
+
this.#mainDOMCascade = this.buildMainCascade(inlinePayload, attributesPayload, matchedPayload, inheritedPayload);
|
|
50
|
+
this.#pseudoDOMCascades = this.buildPseudoCascades(pseudoPayload);
|
|
51
51
|
|
|
52
|
-
this
|
|
53
|
-
for (const domCascade of Array.from(this
|
|
52
|
+
this.#styleToDOMCascade = new Map();
|
|
53
|
+
for (const domCascade of Array.from(this.#pseudoDOMCascades.values()).concat(this.#mainDOMCascade)) {
|
|
54
54
|
for (const style of domCascade.styles()) {
|
|
55
|
-
this
|
|
55
|
+
this.#styleToDOMCascade.set(style, domCascade);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -125,68 +125,68 @@ export class CSSMatchedStyles {
|
|
|
125
125
|
if (!attributesPayload) {
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
|
-
const style = new CSSStyleDeclaration(this
|
|
129
|
-
this
|
|
128
|
+
const style = new CSSStyleDeclaration(this.#cssModelInternal, null, attributesPayload, Type.Attributes);
|
|
129
|
+
this.#nodeForStyleInternal.set(style, this.#nodeInternal);
|
|
130
130
|
nodeStyles.push(style);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// Inline style has the greatest specificity.
|
|
134
|
-
if (inlinePayload && this
|
|
135
|
-
const style = new CSSStyleDeclaration(this
|
|
136
|
-
this
|
|
134
|
+
if (inlinePayload && this.#nodeInternal.nodeType() === Node.ELEMENT_NODE) {
|
|
135
|
+
const style = new CSSStyleDeclaration(this.#cssModelInternal, null, inlinePayload, Type.Inline);
|
|
136
|
+
this.#nodeForStyleInternal.set(style, this.#nodeInternal);
|
|
137
137
|
nodeStyles.push(style);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
// Add rules in reverse order to match the cascade order.
|
|
141
141
|
let addedAttributesStyle;
|
|
142
142
|
for (let i = matchedPayload.length - 1; i >= 0; --i) {
|
|
143
|
-
const rule = new CSSStyleRule(this
|
|
143
|
+
const rule = new CSSStyleRule(this.#cssModelInternal, matchedPayload[i].rule);
|
|
144
144
|
if ((rule.isInjected() || rule.isUserAgent()) && !addedAttributesStyle) {
|
|
145
145
|
// Show element's Style Attributes after all author rules.
|
|
146
146
|
addedAttributesStyle = true;
|
|
147
147
|
addAttributesStyle.call(this);
|
|
148
148
|
}
|
|
149
|
-
this
|
|
149
|
+
this.#nodeForStyleInternal.set(rule.style, this.#nodeInternal);
|
|
150
150
|
nodeStyles.push(rule.style);
|
|
151
|
-
this.addMatchingSelectors(this
|
|
151
|
+
this.addMatchingSelectors(this.#nodeInternal, rule, matchedPayload[i].matchingSelectors);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
if (!addedAttributesStyle) {
|
|
155
155
|
addAttributesStyle.call(this);
|
|
156
156
|
}
|
|
157
|
-
nodeCascades.push(new NodeCascade(this, nodeStyles, false /* isInherited */));
|
|
157
|
+
nodeCascades.push(new NodeCascade(this, nodeStyles, false /* #isInherited */));
|
|
158
158
|
|
|
159
159
|
// Walk the node structure and identify styles with inherited properties.
|
|
160
|
-
let parentNode: (DOMNode|null) = this
|
|
160
|
+
let parentNode: (DOMNode|null) = this.#nodeInternal.parentNode;
|
|
161
161
|
for (let i = 0; parentNode && inheritedPayload && i < inheritedPayload.length; ++i) {
|
|
162
162
|
const inheritedStyles = [];
|
|
163
163
|
const entryPayload = inheritedPayload[i];
|
|
164
164
|
const inheritedInlineStyle = entryPayload.inlineStyle ?
|
|
165
|
-
new CSSStyleDeclaration(this
|
|
165
|
+
new CSSStyleDeclaration(this.#cssModelInternal, null, entryPayload.inlineStyle, Type.Inline) :
|
|
166
166
|
null;
|
|
167
167
|
if (inheritedInlineStyle && this.containsInherited(inheritedInlineStyle)) {
|
|
168
|
-
this
|
|
168
|
+
this.#nodeForStyleInternal.set(inheritedInlineStyle, parentNode);
|
|
169
169
|
inheritedStyles.push(inheritedInlineStyle);
|
|
170
|
-
this
|
|
170
|
+
this.#inheritedStyles.add(inheritedInlineStyle);
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
const inheritedMatchedCSSRules = entryPayload.matchedCSSRules || [];
|
|
174
174
|
for (let j = inheritedMatchedCSSRules.length - 1; j >= 0; --j) {
|
|
175
|
-
const inheritedRule = new CSSStyleRule(this
|
|
175
|
+
const inheritedRule = new CSSStyleRule(this.#cssModelInternal, inheritedMatchedCSSRules[j].rule);
|
|
176
176
|
this.addMatchingSelectors(parentNode, inheritedRule, inheritedMatchedCSSRules[j].matchingSelectors);
|
|
177
177
|
if (!this.containsInherited(inheritedRule.style)) {
|
|
178
178
|
continue;
|
|
179
179
|
}
|
|
180
180
|
if (containsStyle(nodeStyles, inheritedRule.style) ||
|
|
181
|
-
containsStyle(this
|
|
181
|
+
containsStyle(this.#inheritedStyles, inheritedRule.style)) {
|
|
182
182
|
continue;
|
|
183
183
|
}
|
|
184
|
-
this
|
|
184
|
+
this.#nodeForStyleInternal.set(inheritedRule.style, parentNode);
|
|
185
185
|
inheritedStyles.push(inheritedRule.style);
|
|
186
|
-
this
|
|
186
|
+
this.#inheritedStyles.add(inheritedRule.style);
|
|
187
187
|
}
|
|
188
188
|
parentNode = parentNode.parentNode;
|
|
189
|
-
nodeCascades.push(new NodeCascade(this, inheritedStyles, true /* isInherited */));
|
|
189
|
+
nodeCascades.push(new NodeCascade(this, inheritedStyles, true /* #isInherited */));
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
return new DOMInheritanceCascade(nodeCascades);
|
|
@@ -214,18 +214,18 @@ export class CSSMatchedStyles {
|
|
|
214
214
|
for (let i = 0; i < pseudoPayload.length; ++i) {
|
|
215
215
|
const entryPayload = pseudoPayload[i];
|
|
216
216
|
// PseudoElement nodes are not created unless "content" css property is set.
|
|
217
|
-
const pseudoElement = this
|
|
217
|
+
const pseudoElement = this.#nodeInternal.pseudoElements().get(entryPayload.pseudoType) || null;
|
|
218
218
|
const pseudoStyles = [];
|
|
219
219
|
const rules = entryPayload.matches || [];
|
|
220
220
|
for (let j = rules.length - 1; j >= 0; --j) {
|
|
221
|
-
const pseudoRule = new CSSStyleRule(this
|
|
221
|
+
const pseudoRule = new CSSStyleRule(this.#cssModelInternal, rules[j].rule);
|
|
222
222
|
pseudoStyles.push(pseudoRule.style);
|
|
223
|
-
this
|
|
223
|
+
this.#nodeForStyleInternal.set(pseudoRule.style, pseudoElement);
|
|
224
224
|
if (pseudoElement) {
|
|
225
225
|
this.addMatchingSelectors(pseudoElement, pseudoRule, rules[j].matchingSelectors);
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
const nodeCascade = new NodeCascade(this, pseudoStyles, false /* isInherited */);
|
|
228
|
+
const nodeCascade = new NodeCascade(this, pseudoStyles, false /* #isInherited */);
|
|
229
229
|
pseudoCascades.set(entryPayload.pseudoType, new DOMInheritanceCascade([nodeCascade]));
|
|
230
230
|
}
|
|
231
231
|
return pseudoCascades;
|
|
@@ -240,11 +240,11 @@ export class CSSMatchedStyles {
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
node(): DOMNode {
|
|
243
|
-
return this
|
|
243
|
+
return this.#nodeInternal;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
cssModel(): CSSModel {
|
|
247
|
-
return this
|
|
247
|
+
return this.#cssModelInternal;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
hasMatchingSelectors(rule: CSSStyleRule): boolean {
|
|
@@ -257,7 +257,7 @@ export class CSSMatchedStyles {
|
|
|
257
257
|
if (!node || typeof node.id !== 'number') {
|
|
258
258
|
return [];
|
|
259
259
|
}
|
|
260
|
-
const map = this
|
|
260
|
+
const map = this.#matchingSelectors.get(node.id);
|
|
261
261
|
if (!map) {
|
|
262
262
|
return [];
|
|
263
263
|
}
|
|
@@ -289,7 +289,7 @@ export class CSSMatchedStyles {
|
|
|
289
289
|
// We assume that "matching" property does not ever change during the
|
|
290
290
|
// MatchedStyleResult's lifetime.
|
|
291
291
|
if (typeof node.id === 'number') {
|
|
292
|
-
const map = this
|
|
292
|
+
const map = this.#matchingSelectors.get(node.id);
|
|
293
293
|
if (map && map.has(selectorText)) {
|
|
294
294
|
return;
|
|
295
295
|
}
|
|
@@ -298,7 +298,7 @@ export class CSSMatchedStyles {
|
|
|
298
298
|
if (typeof ownerDocument.id !== 'number') {
|
|
299
299
|
return;
|
|
300
300
|
}
|
|
301
|
-
const matchingNodeIds = await this
|
|
301
|
+
const matchingNodeIds = await this.#nodeInternal.domModel().querySelectorAll(ownerDocument.id, selectorText);
|
|
302
302
|
|
|
303
303
|
if (matchingNodeIds) {
|
|
304
304
|
if (typeof node.id === 'number') {
|
|
@@ -311,7 +311,7 @@ export class CSSMatchedStyles {
|
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
addNewRule(rule: CSSStyleRule, node: DOMNode): Promise<void> {
|
|
314
|
-
this
|
|
314
|
+
this.#addedStyles.set(rule.style, node);
|
|
315
315
|
return this.recomputeMatchingSelectors(rule);
|
|
316
316
|
}
|
|
317
317
|
|
|
@@ -319,10 +319,10 @@ export class CSSMatchedStyles {
|
|
|
319
319
|
if (typeof node.id !== 'number') {
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
|
-
let map = this
|
|
322
|
+
let map = this.#matchingSelectors.get(node.id);
|
|
323
323
|
if (!map) {
|
|
324
324
|
map = new Map();
|
|
325
|
-
this
|
|
325
|
+
this.#matchingSelectors.set(node.id, map);
|
|
326
326
|
}
|
|
327
327
|
map.set(selectorText, value);
|
|
328
328
|
}
|
|
@@ -341,20 +341,20 @@ export class CSSMatchedStyles {
|
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
nodeStyles(): CSSStyleDeclaration[] {
|
|
344
|
-
return this
|
|
344
|
+
return this.#mainDOMCascade.styles();
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
keyframes(): CSSKeyframesRule[] {
|
|
348
|
-
return this
|
|
348
|
+
return this.#keyframesInternal;
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
pseudoStyles(pseudoType: Protocol.DOM.PseudoType): CSSStyleDeclaration[] {
|
|
352
|
-
const domCascade = this
|
|
352
|
+
const domCascade = this.#pseudoDOMCascades.get(pseudoType);
|
|
353
353
|
return domCascade ? domCascade.styles() : [];
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
pseudoTypes(): Set<Protocol.DOM.PseudoType> {
|
|
357
|
-
return new Set(this
|
|
357
|
+
return new Set(this.#pseudoDOMCascades.keys());
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
private containsInherited(style: CSSStyleDeclaration): boolean {
|
|
@@ -370,63 +370,63 @@ export class CSSMatchedStyles {
|
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
nodeForStyle(style: CSSStyleDeclaration): DOMNode|null {
|
|
373
|
-
return this
|
|
373
|
+
return this.#addedStyles.get(style) || this.#nodeForStyleInternal.get(style) || null;
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
availableCSSVariables(style: CSSStyleDeclaration): string[] {
|
|
377
|
-
const domCascade = this
|
|
377
|
+
const domCascade = this.#styleToDOMCascade.get(style) || null;
|
|
378
378
|
return domCascade ? domCascade.findAvailableCSSVariables(style) : [];
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
computeCSSVariable(style: CSSStyleDeclaration, variableName: string): string|null {
|
|
382
|
-
const domCascade = this
|
|
382
|
+
const domCascade = this.#styleToDOMCascade.get(style) || null;
|
|
383
383
|
return domCascade ? domCascade.computeCSSVariable(style, variableName) : null;
|
|
384
384
|
}
|
|
385
385
|
|
|
386
386
|
computeValue(style: CSSStyleDeclaration, value: string): string|null {
|
|
387
|
-
const domCascade = this
|
|
387
|
+
const domCascade = this.#styleToDOMCascade.get(style) || null;
|
|
388
388
|
return domCascade ? domCascade.computeValue(style, value) : null;
|
|
389
389
|
}
|
|
390
390
|
|
|
391
391
|
/**
|
|
392
|
-
* Same as computeValue, but to be used for `var(
|
|
392
|
+
* Same as computeValue, but to be used for `var(--#name [,...])` values only
|
|
393
393
|
*/
|
|
394
394
|
computeSingleVariableValue(style: CSSStyleDeclaration, cssVariableValue: string): {
|
|
395
395
|
computedValue: string|null,
|
|
396
396
|
fromFallback: boolean,
|
|
397
397
|
}|null {
|
|
398
|
-
const domCascade = this
|
|
398
|
+
const domCascade = this.#styleToDOMCascade.get(style) || null;
|
|
399
399
|
const cssVariableValueNoSpaces = cssVariableValue.replace(/\s/g, '');
|
|
400
400
|
return domCascade ? domCascade.computeSingleVariableValue(style, cssVariableValueNoSpaces) : null;
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
isInherited(style: CSSStyleDeclaration): boolean {
|
|
404
|
-
return this
|
|
404
|
+
return this.#inheritedStyles.has(style);
|
|
405
405
|
}
|
|
406
406
|
|
|
407
407
|
propertyState(property: CSSProperty): PropertyState|null {
|
|
408
|
-
const domCascade = this
|
|
408
|
+
const domCascade = this.#styleToDOMCascade.get(property.ownerStyle);
|
|
409
409
|
return domCascade ? domCascade.propertyState(property) : null;
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
resetActiveProperties(): void {
|
|
413
|
-
this
|
|
414
|
-
for (const domCascade of this
|
|
413
|
+
this.#mainDOMCascade.reset();
|
|
414
|
+
for (const domCascade of this.#pseudoDOMCascades.values()) {
|
|
415
415
|
domCascade.reset();
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
|
|
420
420
|
class NodeCascade {
|
|
421
|
-
|
|
421
|
+
#matchedStyles: CSSMatchedStyles;
|
|
422
422
|
readonly styles: CSSStyleDeclaration[];
|
|
423
|
-
|
|
423
|
+
readonly #isInherited: boolean;
|
|
424
424
|
readonly propertiesState: Map<CSSProperty, PropertyState>;
|
|
425
425
|
readonly activeProperties: Map<string, CSSProperty>;
|
|
426
426
|
constructor(matchedStyles: CSSMatchedStyles, styles: CSSStyleDeclaration[], isInherited: boolean) {
|
|
427
|
-
this
|
|
427
|
+
this.#matchedStyles = matchedStyles;
|
|
428
428
|
this.styles = styles;
|
|
429
|
-
this
|
|
429
|
+
this.#isInherited = isInherited;
|
|
430
430
|
this.propertiesState = new Map();
|
|
431
431
|
this.activeProperties = new Map();
|
|
432
432
|
}
|
|
@@ -441,14 +441,14 @@ class NodeCascade {
|
|
|
441
441
|
if (rule && !(rule instanceof CSSStyleRule)) {
|
|
442
442
|
continue;
|
|
443
443
|
}
|
|
444
|
-
if (rule && !this
|
|
444
|
+
if (rule && !this.#matchedStyles.hasMatchingSelectors(rule)) {
|
|
445
445
|
continue;
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
for (const property of style.allProperties()) {
|
|
449
449
|
// Do not pick non-inherited properties from inherited styles.
|
|
450
450
|
const metadata = cssMetadata();
|
|
451
|
-
if (this
|
|
451
|
+
if (this.#isInherited && !metadata.isPropertyInherited(property.name)) {
|
|
452
452
|
continue;
|
|
453
453
|
}
|
|
454
454
|
|
|
@@ -493,34 +493,34 @@ class NodeCascade {
|
|
|
493
493
|
}
|
|
494
494
|
|
|
495
495
|
class DOMInheritanceCascade {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
496
|
+
readonly #nodeCascades: NodeCascade[];
|
|
497
|
+
readonly #propertiesState: Map<CSSProperty, PropertyState>;
|
|
498
|
+
readonly #availableCSSVariables: Map<NodeCascade, Map<string, string|null>>;
|
|
499
|
+
readonly #computedCSSVariables: Map<NodeCascade, Map<string, string|null>>;
|
|
500
|
+
#initialized: boolean;
|
|
501
|
+
readonly #styleToNodeCascade: Map<CSSStyleDeclaration, NodeCascade>;
|
|
502
502
|
constructor(nodeCascades: NodeCascade[]) {
|
|
503
|
-
this
|
|
504
|
-
this
|
|
505
|
-
this
|
|
506
|
-
this
|
|
507
|
-
this
|
|
503
|
+
this.#nodeCascades = nodeCascades;
|
|
504
|
+
this.#propertiesState = new Map();
|
|
505
|
+
this.#availableCSSVariables = new Map();
|
|
506
|
+
this.#computedCSSVariables = new Map();
|
|
507
|
+
this.#initialized = false;
|
|
508
508
|
|
|
509
|
-
this
|
|
509
|
+
this.#styleToNodeCascade = new Map();
|
|
510
510
|
for (const nodeCascade of nodeCascades) {
|
|
511
511
|
for (const style of nodeCascade.styles) {
|
|
512
|
-
this
|
|
512
|
+
this.#styleToNodeCascade.set(style, nodeCascade);
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
516
|
|
|
517
517
|
findAvailableCSSVariables(style: CSSStyleDeclaration): string[] {
|
|
518
|
-
const nodeCascade = this
|
|
518
|
+
const nodeCascade = this.#styleToNodeCascade.get(style);
|
|
519
519
|
if (!nodeCascade) {
|
|
520
520
|
return [];
|
|
521
521
|
}
|
|
522
522
|
this.ensureInitialized();
|
|
523
|
-
const availableCSSVariables = this
|
|
523
|
+
const availableCSSVariables = this.#availableCSSVariables.get(nodeCascade);
|
|
524
524
|
if (!availableCSSVariables) {
|
|
525
525
|
return [];
|
|
526
526
|
}
|
|
@@ -528,13 +528,13 @@ class DOMInheritanceCascade {
|
|
|
528
528
|
}
|
|
529
529
|
|
|
530
530
|
computeCSSVariable(style: CSSStyleDeclaration, variableName: string): string|null {
|
|
531
|
-
const nodeCascade = this
|
|
531
|
+
const nodeCascade = this.#styleToNodeCascade.get(style);
|
|
532
532
|
if (!nodeCascade) {
|
|
533
533
|
return null;
|
|
534
534
|
}
|
|
535
535
|
this.ensureInitialized();
|
|
536
|
-
const availableCSSVariables = this
|
|
537
|
-
const computedCSSVariables = this
|
|
536
|
+
const availableCSSVariables = this.#availableCSSVariables.get(nodeCascade);
|
|
537
|
+
const computedCSSVariables = this.#computedCSSVariables.get(nodeCascade);
|
|
538
538
|
if (!availableCSSVariables || !computedCSSVariables) {
|
|
539
539
|
return null;
|
|
540
540
|
}
|
|
@@ -542,13 +542,13 @@ class DOMInheritanceCascade {
|
|
|
542
542
|
}
|
|
543
543
|
|
|
544
544
|
computeValue(style: CSSStyleDeclaration, value: string): string|null {
|
|
545
|
-
const nodeCascade = this
|
|
545
|
+
const nodeCascade = this.#styleToNodeCascade.get(style);
|
|
546
546
|
if (!nodeCascade) {
|
|
547
547
|
return null;
|
|
548
548
|
}
|
|
549
549
|
this.ensureInitialized();
|
|
550
|
-
const availableCSSVariables = this
|
|
551
|
-
const computedCSSVariables = this
|
|
550
|
+
const availableCSSVariables = this.#availableCSSVariables.get(nodeCascade);
|
|
551
|
+
const computedCSSVariables = this.#computedCSSVariables.get(nodeCascade);
|
|
552
552
|
if (!availableCSSVariables || !computedCSSVariables) {
|
|
553
553
|
return null;
|
|
554
554
|
}
|
|
@@ -559,13 +559,13 @@ class DOMInheritanceCascade {
|
|
|
559
559
|
computedValue: string|null,
|
|
560
560
|
fromFallback: boolean,
|
|
561
561
|
}|null {
|
|
562
|
-
const nodeCascade = this
|
|
562
|
+
const nodeCascade = this.#styleToNodeCascade.get(style);
|
|
563
563
|
if (!nodeCascade) {
|
|
564
564
|
return null;
|
|
565
565
|
}
|
|
566
566
|
this.ensureInitialized();
|
|
567
|
-
const availableCSSVariables = this
|
|
568
|
-
const computedCSSVariables = this
|
|
567
|
+
const availableCSSVariables = this.#availableCSSVariables.get(nodeCascade);
|
|
568
|
+
const computedCSSVariables = this.#computedCSSVariables.get(nodeCascade);
|
|
569
569
|
if (!availableCSSVariables || !computedCSSVariables) {
|
|
570
570
|
return null;
|
|
571
571
|
}
|
|
@@ -632,44 +632,44 @@ class DOMInheritanceCascade {
|
|
|
632
632
|
}
|
|
633
633
|
|
|
634
634
|
styles(): CSSStyleDeclaration[] {
|
|
635
|
-
return Array.from(this
|
|
635
|
+
return Array.from(this.#styleToNodeCascade.keys());
|
|
636
636
|
}
|
|
637
637
|
|
|
638
638
|
propertyState(property: CSSProperty): PropertyState|null {
|
|
639
639
|
this.ensureInitialized();
|
|
640
|
-
return this
|
|
640
|
+
return this.#propertiesState.get(property) || null;
|
|
641
641
|
}
|
|
642
642
|
|
|
643
643
|
reset(): void {
|
|
644
|
-
this
|
|
645
|
-
this
|
|
646
|
-
this
|
|
647
|
-
this
|
|
644
|
+
this.#initialized = false;
|
|
645
|
+
this.#propertiesState.clear();
|
|
646
|
+
this.#availableCSSVariables.clear();
|
|
647
|
+
this.#computedCSSVariables.clear();
|
|
648
648
|
}
|
|
649
649
|
|
|
650
650
|
private ensureInitialized(): void {
|
|
651
|
-
if (this
|
|
651
|
+
if (this.#initialized) {
|
|
652
652
|
return;
|
|
653
653
|
}
|
|
654
|
-
this
|
|
654
|
+
this.#initialized = true;
|
|
655
655
|
|
|
656
656
|
const activeProperties = new Map<string, CSSProperty>();
|
|
657
|
-
for (const nodeCascade of this
|
|
657
|
+
for (const nodeCascade of this.#nodeCascades) {
|
|
658
658
|
nodeCascade.computeActiveProperties();
|
|
659
659
|
for (const entry of nodeCascade.propertiesState.entries()) {
|
|
660
660
|
const property = (entry[0] as CSSProperty);
|
|
661
661
|
const state = (entry[1] as PropertyState);
|
|
662
662
|
if (state === PropertyState.Overloaded) {
|
|
663
|
-
this
|
|
663
|
+
this.#propertiesState.set(property, PropertyState.Overloaded);
|
|
664
664
|
continue;
|
|
665
665
|
}
|
|
666
666
|
const canonicalName = cssMetadata().canonicalPropertyName(property.name);
|
|
667
667
|
if (activeProperties.has(canonicalName)) {
|
|
668
|
-
this
|
|
668
|
+
this.#propertiesState.set(property, PropertyState.Overloaded);
|
|
669
669
|
continue;
|
|
670
670
|
}
|
|
671
671
|
activeProperties.set(canonicalName, property);
|
|
672
|
-
this
|
|
672
|
+
this.#propertiesState.set(property, PropertyState.Active);
|
|
673
673
|
}
|
|
674
674
|
}
|
|
675
675
|
// If every longhand of the shorthand is not active, then the shorthand is not active too.
|
|
@@ -697,13 +697,13 @@ class DOMInheritanceCascade {
|
|
|
697
697
|
continue;
|
|
698
698
|
}
|
|
699
699
|
activeProperties.delete(canonicalName);
|
|
700
|
-
this
|
|
700
|
+
this.#propertiesState.set(shorthandProperty, PropertyState.Overloaded);
|
|
701
701
|
}
|
|
702
702
|
|
|
703
703
|
// Work inheritance chain backwards to compute visible CSS Variables.
|
|
704
704
|
const accumulatedCSSVariables = new Map<string, string|null>();
|
|
705
|
-
for (let i = this
|
|
706
|
-
const nodeCascade = this
|
|
705
|
+
for (let i = this.#nodeCascades.length - 1; i >= 0; --i) {
|
|
706
|
+
const nodeCascade = this.#nodeCascades[i];
|
|
707
707
|
const variableNames = [];
|
|
708
708
|
for (const entry of nodeCascade.activeProperties.entries()) {
|
|
709
709
|
const propertyName = (entry[0] as string);
|
|
@@ -715,8 +715,8 @@ class DOMInheritanceCascade {
|
|
|
715
715
|
}
|
|
716
716
|
const availableCSSVariablesMap = new Map(accumulatedCSSVariables);
|
|
717
717
|
const computedVariablesMap = new Map();
|
|
718
|
-
this
|
|
719
|
-
this
|
|
718
|
+
this.#availableCSSVariables.set(nodeCascade, availableCSSVariablesMap);
|
|
719
|
+
this.#computedCSSVariables.set(nodeCascade, computedVariablesMap);
|
|
720
720
|
for (const variableName of variableNames) {
|
|
721
721
|
accumulatedCSSVariables.delete(variableName);
|
|
722
722
|
accumulatedCSSVariables.set(
|
|
@@ -9,13 +9,13 @@ import type {CSSModel} from './CSSModel.js';
|
|
|
9
9
|
import {CSSQuery} from './CSSQuery.js';
|
|
10
10
|
|
|
11
11
|
export class CSSMediaQuery {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
readonly #activeInternal: boolean;
|
|
13
|
+
readonly #expressionsInternal: CSSMediaQueryExpression[]|null;
|
|
14
14
|
constructor(payload: Protocol.CSS.MediaQuery) {
|
|
15
|
-
this
|
|
16
|
-
this
|
|
15
|
+
this.#activeInternal = payload.active;
|
|
16
|
+
this.#expressionsInternal = [];
|
|
17
17
|
for (let j = 0; j < payload.expressions.length; ++j) {
|
|
18
|
-
this
|
|
18
|
+
this.#expressionsInternal.push(CSSMediaQueryExpression.parsePayload(payload.expressions[j]));
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -24,26 +24,26 @@ export class CSSMediaQuery {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
active(): boolean {
|
|
27
|
-
return this
|
|
27
|
+
return this.#activeInternal;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
expressions(): CSSMediaQueryExpression[]|null {
|
|
31
|
-
return this
|
|
31
|
+
return this.#expressionsInternal;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export class CSSMediaQueryExpression {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
readonly #valueInternal: number;
|
|
37
|
+
readonly #unitInternal: string;
|
|
38
|
+
readonly #featureInternal: string;
|
|
39
|
+
readonly #valueRangeInternal: TextUtils.TextRange.TextRange|null;
|
|
40
|
+
readonly #computedLengthInternal: number|null;
|
|
41
41
|
constructor(payload: Protocol.CSS.MediaQueryExpression) {
|
|
42
|
-
this
|
|
43
|
-
this
|
|
44
|
-
this
|
|
45
|
-
this
|
|
46
|
-
this
|
|
42
|
+
this.#valueInternal = payload.value;
|
|
43
|
+
this.#unitInternal = payload.unit;
|
|
44
|
+
this.#featureInternal = payload.feature;
|
|
45
|
+
this.#valueRangeInternal = payload.valueRange ? TextUtils.TextRange.TextRange.fromObject(payload.valueRange) : null;
|
|
46
|
+
this.#computedLengthInternal = payload.computedLength || null;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
static parsePayload(payload: Protocol.CSS.MediaQueryExpression): CSSMediaQueryExpression {
|
|
@@ -51,23 +51,23 @@ export class CSSMediaQueryExpression {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
value(): number {
|
|
54
|
-
return this
|
|
54
|
+
return this.#valueInternal;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
unit(): string {
|
|
58
|
-
return this
|
|
58
|
+
return this.#unitInternal;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
feature(): string {
|
|
62
|
-
return this
|
|
62
|
+
return this.#featureInternal;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
valueRange(): TextUtils.TextRange.TextRange|null {
|
|
66
|
-
return this
|
|
66
|
+
return this.#valueRangeInternal;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
computedLength(): number|null {
|
|
70
|
-
return this
|
|
70
|
+
return this.#computedLengthInternal;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|