cssHelpers.ts ×8

Frontier kind: Code frontier

unlabeled · c_3ae6721f8257

29 tests · 3688 LOC · 19 files · introduces 0 tests · 308 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges308 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
489 ranges3688 lines · 19 files · Browse complete extent
All tests (intent)
29 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Introduced files, introduced tests, and structurally relevant concept specializationcssHelpers.test|title=collapseToShorthands realistic element with multiple shorthand groups|occurrence=1 · 0 introduced LOCcssHelpers.test|title=co…cssHelpers.ts ×5 · 22 introduced LOCcssHelpers.ts ×5cssHelpers.test|title=collapseToShorthands transition: single property with cubic-bezier|occurrence=1 · 0 introduced LOCcssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands transition: multi-property comma-separated|occurrence=1 · 0 introduced LOCcssHelpers.test|title=co…cssHelpers.ts ×1 · 7 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×2 · 2 introduced LOCcssHelpers.ts ×2cssHelpers.test|title=collapseToShorthands animation: name and duration only|occurrence=1, cssHelpers.test|title=collapseToShorthands animation: with fill-mode and custom easing|occurrence=1 · 0 introduced LOCcssHelpers.test|title=co…cssHelpers.ts ×1 · 3 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×1 · 3 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×2 · 10 introduced LOCcssHelpers.ts ×2cssHelpers.ts ×6 · 36 introduced LOCcssHelpers.ts ×6cssHelpers.test|title=collapseToShorthands border: uniform sides → single shorthand|occurrence=1 · 0 introduced LOCcssHelpers.test|title=co…cssHelpers.ts ×1 · 2 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×1 · 2 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×1 · 3 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×5 · 8 introduced LOCcssHelpers.ts ×5cssHelpers.test|title=collapseToShorthands border-radius: uniform|occurrence=1, cssHelpers.test|title=collapseToShorthands margin: all sides equal → 1-value|occurrence=1 · 0 introduced LOCcssHelpers.test|title=co…cssHelpers.ts ×1 · 6 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×1 · 1 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×4 · 9 introduced LOCcssHelpers.ts ×4horizontal → 2-value|occurrence=1 · 0 introduced LOChorizontal → 2-value|occ…cssHelpers.test|title=collapseToShorthands animation-range at defaults → dropped|occurrence=1, cssHelpers.test|title=collapseToShorthands border-image at defaults → dropped entirely|occurrence=1 · 0 introduced LOCcssHelpers.test|title=co…cssHelpers.ts ×1 · 2 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×3 · 4 introduced LOCcssHelpers.ts ×3cssHelpers.test|title=collapseToShorthands background: color-only when others at default|occurrence=1 · 0 introduced LOCcssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands unknown properties pass through alphabetically|occurrence=1 · 0 introduced LOCcssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands white-space: nowrap|occurrence=1, cssHelpers.test|title=collapseToShorthands white-space: pre-wrap|occurrence=1 · 0 introduced LOCcssHelpers.test|title=co…cssHelpers.ts ×1 · 2 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×1 · 2 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×1 · 4 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×1 · 2 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×2 · 11 introduced LOCcssHelpers.ts ×2cssHelpers.ts ×1 · 3 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×1 · 5 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×1 · 2 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×1 · 6 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×1 · 6 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×1 · 2 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×1 · 2 introduced LOCcssHelpers.ts ×1cssHelpers.ts ×12 · 75 introduced LOCcssHelpers.ts ×12cssHelpers.ts ×12 · 47 introduced LOCcssHelpers.ts ×12uri.test|title=URI URI#file, win-speciale|occurrence=1, charCode.test|title=CharCode has good values|occurrence=1, +2 · 0 introduced LOCuri.test|title=URI URI#f…utils.ts ×3 · 9 introduced LOCutils.ts ×3lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×4 · 8 introduced LOClifecycle.ts ×4lifecycle.ts ×6 · 16 introduced LOClifecycle.ts ×6lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1map.ts ×97 · 3334 introduced LOCmap.ts ×97src/vs/base/common/arrays.ts · 949 LOCcommon/arrays.tssrc/vs/base/common/arraysFind.ts · 226 LOCcommon/arraysFind.tssrc/vs/base/common/assert.ts · 91 LOCcommon/assert.tssrc/vs/base/common/charCode.ts · 450 LOCcommon/charCode.tssrc/vs/base/common/collections.ts · 176 LOCcommon/collections.tssrc/vs/base/common/errors.ts · 357 LOCcommon/errors.tssrc/vs/base/common/functional.ts · 32 LOCcommon/functional.tssrc/vs/base/common/iterator.ts · 194 LOCcommon/iterator.tssrc/vs/base/common/lifecycle.ts · 974 LOCcommon/lifecycle.tssrc/vs/base/common/map.ts · 1016 LOCcommon/map.tssrc/vs/base/common/marshallingIds.ts · 33 LOCcommon/marshallingIds.tssrc/vs/base/common/path.ts · 1589 LOCcommon/path.tssrc/vs/base/common/platform.ts · 281 LOCcommon/platform.tssrc/vs/base/common/process.ts · 76 LOCcommon/process.tssrc/vs/base/common/types.ts · 410 LOCcommon/types.tssrc/vs/base/common/uri.ts · 754 LOCcommon/uri.tssrc/vs/base/test/common/utils.ts · 107 LOCcommon/utils.tssrc/vs/nls.ts · 244 LOCvs/nls.tssrc/vs/platform/browserView/common/cssHelpers.ts · 616 LOCcommon/cssHelpers.tscharCode.test|title=CharCode has good values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1charCode.test|title=Char…path.test|title=Paths (Node Implementation) path|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1path.test|title=Paths (N…uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1uri.test|title=URI File …uri.test|title=URI URI#file, win-speciale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1uri.test|title=URI URI#f…cssHelpers.test|title=collapseToShorthands animation-range at defaults → dropped|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands animation-range at defaults → dropped|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands animation: name and duration only|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands animation: name and duration only|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands animation: with fill-mode and custom easing|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands animation: with fill-mode and custom easing|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands background: color-only when others at default|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands background: color-only when others at default|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands border-image at defaults → dropped entirely|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands border-image at defaults → dropped entirely|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands border-radius: uniform|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands border-radius: uniform|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands border: non-uniform → per-group shorthands|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands border: non-uniform → per-group shorthands|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands border: uniform sides → single shorthand|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands border: uniform sides → single shorthand|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands margin: 3-value when left === right|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands margin: 3-value when left === right|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands margin: 4-value when all differ|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands margin: 4-value when all differ|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands margin: all sides equal → 1-value|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands margin: all sides equal → 1-value|occurrence=1cssHelpers.test|title=co…horizontal → 2-value|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands padding: vertical/horizontal → 2-value|occurrence=1horizontal → 2-value|occ…cssHelpers.test|title=collapseToShorthands realistic element with multiple shorthand groups|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands realistic element with multiple shorthand groups|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands text-decoration: none|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands text-decoration: none|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands text-decoration: underline with non-default style|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands text-decoration: underline with non-default style|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands transition: multi-property comma-separated|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands transition: multi-property comma-separated|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands transition: single property with cubic-bezier|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands transition: single property with cubic-bezier|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands unknown properties pass through alphabetically|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands unknown properties pass through alphabetically|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands white-space: nowrap|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands white-space: nowrap|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=collapseToShorthands white-space: pre-wrap|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=collapseToShorthands white-space: pre-wrap|occurrence=1cssHelpers.test|title=co…cssHelpers.test|title=formatAuthorStyles collects var references from rules|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=formatAuthorStyles collects var references from rules|occurrence=1cssHelpers.test|title=fo…cssHelpers.test|title=formatAuthorStyles filters inherited rules to inheritable properties only|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=formatAuthorStyles filters inherited rules to inheritable properties only|occurrence=1cssHelpers.test|title=fo…cssHelpers.test|title=formatAuthorStyles includes direct author rules and skips user-agent|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=formatAuthorStyles includes direct author rules and skips user-agent|occurrence=1cssHelpers.test|title=fo…cssHelpers.test|title=formatAuthorStyles includes pseudo-element styles|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=formatAuthorStyles includes pseudo-element styles|occurrence=1cssHelpers.test|title=fo…cssHelpers.test|title=formatAuthorStyles skips user-agent pseudo-element rules|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=formatAuthorStyles skips user-agent pseudo-element rules|occurrence=1cssHelpers.test|title=fo…cssHelpers.test|title=formatAuthorStyles tracks author property names from cssProperties longhands|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=formatAuthorStyles tracks author property names from cssProperties longhands|occurrence=1cssHelpers.test|title=fo…cssHelpers.test|title=formatAuthorStyles tracks user-agent property names from direct rules|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=formatAuthorStyles tracks user-agent property names from direct rules|occurrence=1cssHelpers.test|title=fo…cssHelpers.test|title=formatAuthorStyles tracks user-agent property names from inherited rules (inheritable only)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=formatAuthorStyles tracks user-agent property names from inherited rules (inheritable only)|occurrence=1cssHelpers.test|title=fo…cssHelpers.test|title=formatAuthorStyles tracks user-agent property names from pseudo-element rules|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/browserView/test/common/cssHelpers.test|title=formatAuthorStyles tracks user-agent property names from pseudo-element rules|occurrence=1cssHelpers.test|title=fo…Focused concept · cssHelpers.ts ×8 · 308 introduced LOCcssHelpers.ts ×8

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 308 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/browserView/common/cssHelpers.ts 308 introduced LOC · 8 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- cssHelpers.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > // -- CDP matched-styles types (subset used by formatAuthorStyles) --
7 >
8 > export interface ICSSStyle {
9 > cssText?: string;
10 > cssProperties: Array<{ name: string; value: string; disabled?: boolean }>;
11 > }
12 >
13 > interface ISelectorList {
14 > selectors: Array<{ text: string }>;
15 > }
16 >
17 > interface ICSSRule {
18 > selectorList: ISelectorList;
19 > origin: string;
20 > style: ICSSStyle;
21 > }
22 >
23 > interface IRuleMatch {
24 > rule: ICSSRule;
25 > }
26 >
27 > interface IInheritedStyleEntry {
28 > inlineStyle?: ICSSStyle;
29 > matchedCSSRules: IRuleMatch[];
30 > }
31 >
32 > interface IPseudoElementMatches {
33 > pseudoType: string;
34 > matches: IRuleMatch[];
35 > }
36 >
37 > export interface IMatchedStyles {
38 > inlineStyle?: ICSSStyle;
39 > matchedCSSRules?: IRuleMatch[];
40 > inherited?: IInheritedStyleEntry[];
41 > pseudoElements?: IPseudoElementMatches[];
42 > }
43 >
44 > export interface IFormattedStyles {
45 > /** Compact CSS text for the agent prompt (rules only, without resolved values). */
46 > rulesText: string;
47 > /** Set of CSS variable names referenced by the element's rules. */
48 > referencedVars: Set<string>;
49 > /** Set of CSS property names that were explicitly set by author rules. */
50 > authorPropertyNames: Set<string>;
51 > /** Set of CSS property names that were set by user-agent rules. */
52 > userAgentPropertyNames: Set<string>;
53 > }
54 >
55 > // -- Constants --
56 >
57 > /**
58 > * CSS properties that are inherited by child elements.
59 > */
60 > const inheritableCSSProperties = new Set([
61 > 'color', 'cursor', 'direction', 'font', 'font-family', 'font-feature-settings',
62 > 'font-kerning', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style',
63 > 'font-variant', 'font-weight', 'letter-spacing', 'line-height', 'list-style',
64 > 'list-style-image', 'list-style-position', 'list-style-type', 'orphans',
65 > 'overflow-wrap', 'quotes', 'tab-size', 'text-align', 'text-align-last',
66 > 'text-indent', 'text-transform', 'visibility', 'white-space', 'widows',
67 > 'word-break', 'word-spacing', 'writing-mode',
68 > ]);
69 >
70 > const varReferenceRegex = /var\(\s*(--[a-zA-Z0-9_-]+)/g;
71 >
72 > /**
73 > * Key computed properties included for hover display in the UI.
74 > */
75 > export const keyComputedProperties = new Set([
76 > 'display', 'position', 'margin', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left',
77 > 'padding', 'padding-top', 'padding-right', 'padding-bottom', 'padding-left',
78 > 'font-size', 'font-family', 'color', 'background-color',
79 > ]);
80 >
81 > /**
82 > * Properties always included in resolved values even if only set by user-agent rules,
83 > * matching Chrome DevTools' `alwaysShownComputedProperties`.
84 > */
85 > const alwaysResolvedProperties = new Set(['display', 'height', 'width']);
86 >
87 > // -- Helper functions --
88 >
89 > /**
90 > * Collects var(--name) references from a CSS value string.
91 > */
92 function collectVarReferences(value: string, into: Set<string>): void {
93 for (const m of value.matchAll(varReferenceRegex)) {
95 }
96 }
98 > /**
99 > * Collects longhand property names from the `cssProperties` array of a matched rule.
100 > * Skips variable definitions and disabled properties.
101 > */
102 function collectPropertyNames(cssProperties: Array<{ name: string; value: string; disabled?: boolean }>, into: Set<string>, inheritableOnly?: boolean): void {
103 for (const prop of cssProperties) {
111 }
112 }
114 > /**
115 > * Filters CSS declarations to only inheritable properties (not variable definitions).
116 > */
117 > export function filterInheritableDeclarations(cssText: string): string | undefined {
118 const declarations = cssText.split(';').map(d => d.trim()).filter(Boolean);
119 const filtered = declarations.filter(decl => {
127 return filtered.length > 0 ? filtered.join('; ') : undefined;
128 }
130 > /**
131 > * Formats matched styles into a compact representation for agent prompts.
132 > *
133 > * Only includes author-origin rules (not browser defaults), uses the raw
134 > * `cssText` instead of expanded longhand properties, and for inherited
135 > * rules only keeps inheritable CSS properties.
136 > *
137 > * Also includes pseudo-element styles (::before, ::after, etc.) when present.
138 > *
139 > * Uses `cssProperties` (the longhand array) from matched rules to determine
140 > * which computed properties are author-affected, matching Chrome DevTools'
141 > * `computePropertyTraces` approach.
142 > */
143 > export function formatMatchedStyles(matched: IMatchedStyles): IFormattedStyles {
144 const referencedVars = new Set<string>();
145 const authorPropertyNames = new Set<string>();
239 return { rulesText: lines.join('\n'), referencedVars, authorPropertyNames, userAgentPropertyNames };
240 }
242 > /**
243 > * -- Shorthand collapsing configuration ----------------------------------
244 > *
245 > * Each constant below describes one kind of CSS shorthand that can be
246 > * reconstituted from computed longhand values. The `collapseToShorthands`
247 > * function walks these lists in declaration order and produces compact
248 > * output for the agent prompt.
249 > *
250 > * Sources:
251 > * • MDN "Formal definition → Initial value" tables
252 > * • CSS Backgrounds & Borders 3, CSS Transitions 1, CSS Animations 1,
253 > * CSS Text Decoration 4, CSS Text 4
254 > */
255 >
256 > // -- Box model (T R B L) shorthands --
257 > // Collapsed with 1-4-value syntax per CSS spec section 8.3.
258 >
259 > interface IBoxShorthand {
260 > shorthand: string;
261 > sides: [string, string, string, string]; // top/TL, right/TR, bottom/BR, left/BL
262 > }
263 >
264 > const boxShorthands: IBoxShorthand[] = [
265 > // margin: <margin-top> <margin-right> <margin-bottom> <margin-left>
266 > { shorthand: 'margin', sides: ['margin-top', 'margin-right', 'margin-bottom', 'margin-left'] },
267 > // padding: <padding-top> <padding-right> <padding-bottom> <padding-left>
268 > { shorthand: 'padding', sides: ['padding-top', 'padding-right', 'padding-bottom', 'padding-left'] },
269 > // border-radius: <TL> <TR> <BR> <BL> (clockwise from top-left)
270 > { shorthand: 'border-radius', sides: ['border-top-left-radius', 'border-top-right-radius', 'border-bottom-right-radius', 'border-bottom-left-radius'] },
271 > ];
272 >
273 > // -- Border per-side groups (collapse to border: W S C when uniform) --
274 >
275 > const borderSideGroups: IBoxShorthand[] = [
276 > // border-width: initial medium per MDN (but computed is always an absolute length)
277 > { shorthand: 'border-width', sides: ['border-top-width', 'border-right-width', 'border-bottom-width', 'border-left-width'] },
278 > // border-style: initial none per MDN
279 > { shorthand: 'border-style', sides: ['border-top-style', 'border-right-style', 'border-bottom-style', 'border-left-style'] },
280 > // border-color: initial currentcolor per MDN
281 > { shorthand: 'border-color', sides: ['border-top-color', 'border-right-color', 'border-bottom-color', 'border-left-color'] },
282 > ];
283 >
284 > // -- Longhands that are dropped entirely when all at their initial values --
285 >
286 > interface IDefaultsGroup {
287 > /** Longhands to check and remove. */
288 > longhands: Record<string, string>;
289 > }
290 >
291 > const dropWhenAllDefault: IDefaultsGroup[] = [
292 > // border-image (CSS Backgrounds & Borders 3 section 6.8)
293 > {
294 > longhands: {
295 > 'border-image-source': 'none',
296 > 'border-image-slice': '100%',
297 > 'border-image-width': '1',
298 > 'border-image-outset': '0',
299 > 'border-image-repeat': 'stretch',
300 > },
301 > },
302 > // animation-range (CSS Scroll-driven Animations section 5.2) initial: normal
303 > {
304 > longhands: {
305 > 'animation-range-start': 'normal',
306 > 'animation-range-end': 'normal',
307 > },
308 > },
309 > ];
310 >
311 > // -- Background collapse (color-only shorthand when images/position/etc. default) --
312 >
313 > interface IBackgroundCollapseGroup {
314 > /** background-color longhand */
315 > colorLonghand: string;
316 > /** Other background longhands that must all be at their initial value. */
317 > otherLonghands: Record<string, string>;
318 > }
319 >
320 > const backgroundCollapse: IBackgroundCollapseGroup = {
321 > colorLonghand: 'background-color',
322 > otherLonghands: {
323 > // MDN background formal definition initial values:
324 > 'background-image': 'none', // initial: none
325 > 'background-position-x': '0px', // initial: 0% (computed as 0px)
326 > 'background-position-y': '0px', // initial: 0%
327 > 'background-size': 'auto', // initial: auto auto
328 > 'background-repeat': 'repeat', // initial: repeat
329 > 'background-attachment': 'scroll', // initial: scroll
330 > 'background-origin': 'padding-box', // initial: padding-box
331 > 'background-clip': 'border-box', // initial: border-box
332 > },
333 > };
334 >
335 > // -- Simple shorthand collapse (longhands → single shorthand, omit defaults) --
336 >
337 > interface ISimpleShorthand {
338 > shorthand: string;
339 > longhands: Array<{ name: string; initial: string }>;
340 > }
341 >
342 > const simpleShorthands: ISimpleShorthand[] = [
343 > // text-decoration (CSS Text Decoration 4 section 3)
344 > // Constituents: text-decoration-line || text-decoration-style || text-decoration-color || text-decoration-thickness
345 > {
346 > shorthand: 'text-decoration',
347 > longhands: [
348 > { name: 'text-decoration-line', initial: 'none' },
349 > { name: 'text-decoration-style', initial: 'solid' },
350 > { name: 'text-decoration-color', initial: 'currentcolor' },
351 > { name: 'text-decoration-thickness', initial: 'auto' },
352 > ],
353 > },
354 > ];
355 >
356 > // -- white-space (CSS Text 4 section 3) --
357 > // Shorthand for white-space-collapse || text-wrap-mode.
358 > // Named keyword mappings for the well-known combinations:
359 >
360 > const whiteSpaceKeywords: Array<{ collapse: string; wrap: string; keyword: string }> = [
361 > { collapse: 'collapse', wrap: 'wrap', keyword: 'normal' },
362 > { collapse: 'collapse', wrap: 'nowrap', keyword: 'nowrap' },
363 > { collapse: 'preserve', wrap: 'nowrap', keyword: 'pre' },
364 > { collapse: 'preserve', wrap: 'wrap', keyword: 'pre-wrap' },
365 > { collapse: 'preserve-breaks', wrap: 'wrap', keyword: 'pre-line' },
366 > { collapse: 'break-spaces', wrap: 'wrap', keyword: 'break-spaces' },
367 > ];
368 >
369 > // -- Comma-separated list shorthands (transition, animation) --
370 >
371 > interface IListShorthand {
372 > shorthand: string;
373 > longhands: Array<{ name: string; initial: string }>;
374 > }
375 >
376 > const listShorthands: IListShorthand[] = [
377 > // transition (CSS Transitions 1 section 2.1)
378 > // Constituents: transition-property || transition-duration || transition-timing-function || transition-delay || transition-behavior
379 > {
380 > shorthand: 'transition',
381 > longhands: [
382 > { name: 'transition-property', initial: 'all' },
383 > { name: 'transition-duration', initial: '0s' },
384 > { name: 'transition-timing-function', initial: 'ease' },
385 > { name: 'transition-delay', initial: '0s' },
386 > { name: 'transition-behavior', initial: 'normal' },
387 > ],
388 > },
389 > // animation (CSS Animations 1 section 3 + Scroll-driven Animations section 5)
390 > // Constituents: animation-name || animation-duration || animation-timing-function || animation-delay
391 > // || animation-iteration-count || animation-direction || animation-fill-mode
392 > // || animation-play-state || animation-timeline
393 > {
394 > shorthand: 'animation',
395 > longhands: [
396 > { name: 'animation-name', initial: 'none' },
397 > { name: 'animation-duration', initial: '0s' },
398 > { name: 'animation-timing-function', initial: 'ease' },
399 > { name: 'animation-delay', initial: '0s' },
400 > { name: 'animation-iteration-count', initial: '1' },
401 > { name: 'animation-direction', initial: 'normal' },
402 > { name: 'animation-fill-mode', initial: 'none' },
403 > { name: 'animation-play-state', initial: 'running' },
404 > { name: 'animation-timeline', initial: 'auto' },
405 > ],
406 > },
407 > ];
408 >
409 > // -- Helper functions --
410 >
411 > /**
412 > * Tries to collapse a box shorthand (4 sides → 1-4 value shorthand).
413 > * Returns the collapsed value or undefined if not all sides are present.
414 > */
415 function collapseBoxValues(entries: Map<string, string>, sides: [string, string, string, string]): string | undefined {
416 const [topKey, rightKey, bottomKey, leftKey] = sides;
440 return `${top} ${right} ${bottom} ${left}`;
441 }
443 > /**
444 > * Splits a CSS value by top-level commas, respecting parenthesized groups
445 > * like `cubic-bezier(0.16, 1, 0.3, 1)`.
446 > */
447 function splitCSSList(value: string): string[] {
448 const items: string[] = [];
463 return items;
464 }
466 > /**
467 > * Collapses comma-separated list longhands into a single shorthand declaration.
468 > */
469 function collapseListShorthand(
470 entries: Map<string, string>,
502 output.push(`${shorthand}: ${items.join(', ')};`);
503 }
505 > // -- Main entry point --
506 >
507 > /**
508 > * Collapses resolved computed properties into shorthands where possible,
509 > * then returns sorted CSS declaration lines. Driven entirely by the
510 > * constant shorthand configuration tables above.
511 > */
512 > export function collapseToShorthands(entries: Map<string, string>): string[] {
513 const shorthandLines: string[] = [];
514