Skip to content

Commit 7e925b3

Browse files
pfaffeDevtools-frontend LUCI CQ
authored andcommitted
[css] show crossed-out values on hover
In the styles pane we cross out values that are unused, e.g., fallbacks in a var(), colors in light-dark(), values in min(), and so forth. Crossed out values are hard to read, so we remove the line-through when hovering the values. Bug: None Change-Id: I7843a88ec72ed890f27c863b1387e2651c310132 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6243916 Auto-Submit: Philip Pfaffe <[email protected]> Reviewed-by: Ergün Erdoğmuş <[email protected]> Commit-Queue: Ergün Erdoğmuş <[email protected]>
1 parent b8dd208 commit 7e925b3

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

front_end/panels/elements/StylePropertyTreeElement.test.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,8 +1392,8 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
13921392
assert.exists(dark);
13931393
const active = colorScheme === SDK.CSSModel.ColorScheme.LIGHT ? light : dark;
13941394
const inactive = colorScheme === SDK.CSSModel.ColorScheme.LIGHT ? dark : light;
1395-
assert.strictEqual(inactive.parentElement?.style.textDecoration, 'line-through');
1396-
assert.strictEqual(active.parentElement?.style.textDecoration, '');
1395+
assert.isTrue(inactive.parentElement?.classList.contains('inactive-value'));
1396+
assert.isFalse(active.parentElement?.classList.contains('inactive-value'));
13971397
}
13981398

13991399
await check(SDK.CSSModel.ColorScheme.LIGHT, 'red', 'blue');
@@ -1566,9 +1566,9 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
15661566
undefined;
15671567
assert.exists(values);
15681568
assert.strictEqual(values?.length, 3);
1569-
assert.strictEqual(values[0].style.textDecoration, 'line-through');
1570-
assert.strictEqual(values[1].style.textDecoration, '');
1571-
assert.strictEqual(values[2].style.textDecoration, 'line-through');
1569+
assert.isTrue(values[0].classList.contains('inactive-value'));
1570+
assert.isFalse(values[1].classList.contains('inactive-value'));
1571+
assert.isTrue(values[2].classList.contains('inactive-value'));
15721572
});
15731573

15741574
it('renders the position-try correctly with keyword', () => {
@@ -1582,9 +1582,9 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
15821582
undefined;
15831583
assert.exists(values);
15841584
assert.strictEqual(values?.length, 3);
1585-
assert.strictEqual(values[0].style.textDecoration, 'line-through');
1586-
assert.strictEqual(values[1].style.textDecoration, '');
1587-
assert.strictEqual(values[2].style.textDecoration, 'line-through');
1585+
assert.isTrue(values[0].classList.contains('inactive-value'));
1586+
assert.isFalse(values[1].classList.contains('inactive-value'));
1587+
assert.isTrue(values[2].classList.contains('inactive-value'));
15881588
});
15891589
});
15901590

@@ -1633,7 +1633,7 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
16331633
stylePropertyTreeElement.valueElement?.querySelectorAll(':scope > span') as NodeListOf<HTMLSpanElement>;
16341634
assert.lengthOf(args, 3);
16351635
assert.deepEqual(
1636-
Array.from(args.values()).map(arg => arg.style.textDecoration), ['line-through', '', 'line-through']);
1636+
Array.from(args.values()).map(arg => arg.classList.contains('inactive-value')), [true, false, true]);
16371637
});
16381638
});
16391639

@@ -1647,14 +1647,16 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
16471647

16481648
let args = stylePropertyTreeElement.valueElement?.querySelectorAll('span') as NodeListOf<HTMLSpanElement>;
16491649
assert.lengthOf(args, 3);
1650-
assert.deepEqual(Array.from(args.values()).map(arg => arg.style.textDecoration), ['', '', 'line-through']);
1650+
assert.deepEqual(
1651+
Array.from(args.values()).map(arg => arg.classList.contains('inactive-value')), [false, false, true]);
16511652

16521653
stylePropertyTreeElement.setComputedStyles(new Map([['appearance', 'base-select']]));
16531654
stylePropertyTreeElement.updateTitle();
16541655

16551656
args = stylePropertyTreeElement.valueElement?.querySelectorAll('span') as NodeListOf<HTMLSpanElement>;
16561657
assert.lengthOf(args, 3);
1657-
assert.deepEqual(Array.from(args.values()).map(arg => arg.style.textDecoration), ['', 'line-through', '']);
1658+
assert.deepEqual(
1659+
Array.from(args.values()).map(arg => arg.classList.contains('inactive-value')), [false, true, false]);
16581660
});
16591661
});
16601662

front_end/panels/elements/StylePropertyTreeElement.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ export class LightDarkColorRenderer extends rendererBase(SDK.CSSPropertyParserMa
521521
const inactiveColor = (activeColor === match.light) ? dark : light;
522522
const colorText = context.matchedResult.getComputedTextRange(activeColor[0], activeColor[activeColor.length - 1]);
523523
const color = colorText && Common.Color.parse(colorText);
524-
inactiveColor.style.textDecoration = 'line-through';
524+
inactiveColor.classList.add('inactive-value');
525525
if (color) {
526526
colorSwatch.renderColor(color);
527527
}
@@ -851,9 +851,9 @@ export class AutoBaseRenderer extends rendererBase(SDK.CSSPropertyParserMatchers
851851

852852
const activeAppearance = this.#treeElement.getComputedStyle('appearance');
853853
if (activeAppearance?.startsWith('base')) {
854-
auto.style.textDecoration = 'line-through';
854+
auto.classList.add('inactive-value');
855855
} else {
856-
base.style.textDecoration = 'line-through';
856+
base.classList.add('inactive-value');
857857
}
858858

859859
return [content];
@@ -1314,7 +1314,7 @@ export class SelectFunctionRenderer extends rendererBase(SDK.CSSPropertyParserMa
13141314
}
13151315
for (let i = 0; i < renderedArgs.length; ++i) {
13161316
if (evaledArgs.results[i] !== functionResult) {
1317-
renderedArgs[i].style.textDecoration = 'line-through';
1317+
renderedArgs[i].classList.add('inactive-value');
13181318
}
13191319
}
13201320
}
@@ -1443,7 +1443,7 @@ export class PositionTryRenderer extends rendererBase(SDK.CSSPropertyParserMatch
14431443
fallbackContent.appendChild(document.createTextNode(', '));
14441444
}
14451445
if (i !== this.#treeElement.matchedStyles().activePositionFallbackIndex()) {
1446-
fallbackContent.style.textDecoration = 'line-through';
1446+
fallbackContent.classList.add('inactive-value');
14471447
}
14481448
Renderer.renderInto(fallback, context, fallbackContent);
14491449

front_end/panels/elements/stylePropertiesTreeOutline.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
color: inherit;
99
}
1010

11+
.inactive-value:not(:hover) {
12+
text-decoration: line-through;
13+
}
14+
1115
.tree-outline {
1216
padding: 0;
1317
}

0 commit comments

Comments
 (0)