Skip to content

Commit 8c40968

Browse files
Alexander PavlovDevtools-frontend LUCI CQ
authored andcommitted
DevTools: Don't make ContrastInfo isNull() with missing backgroundColors
This is still a valid state where the background color picker may be displayed. Bug: https://g-issues.chromium.org/issues/40140133 Change-Id: Ib267bd03c1ea66057d88c50eb7e7520680b2551d Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6441185 Reviewed-by: Alex Rudenko <[email protected]> Reviewed-by: Simon Zünd <[email protected]> Commit-Queue: Alexander Pavlov <[email protected]>
1 parent b86a0ad commit 8c40968

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

front_end/ui/legacy/components/color_picker/ContrastInfo.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class ContrastInfo extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
1111
private contrastRatioThresholds: {
1212
[x: string]: number,
1313
}|null;
14-
private readonly contrastRationAPCAThreshold: number|null;
14+
private readonly contrastRatioAPCAThresholdInternal: number|null;
1515
private fgColor: Common.Color.Legacy|null;
1616
private bgColorInternal: Common.Color.Legacy|null;
1717
private colorFormatInternal: Common.Color.Format|undefined;
@@ -21,24 +21,27 @@ export class ContrastInfo extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
2121
this.contrastRatioInternal = null;
2222
this.contrastRatioAPCAInternal = null;
2323
this.contrastRatioThresholds = null;
24-
this.contrastRationAPCAThreshold = 0;
24+
this.contrastRatioAPCAThresholdInternal = 0;
2525
this.fgColor = null;
2626
this.bgColorInternal = null;
2727

2828
if (!contrastInfo) {
2929
return;
3030
}
3131

32-
if (!contrastInfo.computedFontSize || !contrastInfo.computedFontWeight || !contrastInfo.backgroundColors ||
33-
contrastInfo.backgroundColors.length !== 1) {
32+
if (!contrastInfo.computedFontSize || !contrastInfo.computedFontWeight) {
3433
return;
3534
}
3635

3736
this.isNullInternal = false;
3837
this.contrastRatioThresholds =
3938
Common.ColorUtils.getContrastThreshold(contrastInfo.computedFontSize, contrastInfo.computedFontWeight);
40-
this.contrastRationAPCAThreshold =
39+
this.contrastRatioAPCAThresholdInternal =
4140
Common.ColorUtils.getAPCAThreshold(contrastInfo.computedFontSize, contrastInfo.computedFontWeight);
41+
42+
if (!contrastInfo.backgroundColors || contrastInfo.backgroundColors.length !== 1) {
43+
return;
44+
}
4245
const bgColorText = contrastInfo.backgroundColors[0];
4346
const bgColor = Common.Color.parse(bgColorText)?.asLegacyColor();
4447
if (bgColor) {
@@ -74,7 +77,7 @@ export class ContrastInfo extends Common.ObjectWrapper.ObjectWrapper<EventTypes>
7477
}
7578

7679
contrastRatioAPCAThreshold(): number|null {
77-
return this.contrastRationAPCAThreshold;
80+
return this.contrastRatioAPCAThresholdInternal;
7881
}
7982

8083
setBgColor(bgColor: Common.Color.Legacy): void {

0 commit comments

Comments
 (0)