Skip to content

Editor GPU: Consolidate CSS rule support and logic #285603

@Tyriar

Description

@Tyriar

These should be co-located

/**
* A list of supported decoration CSS rules that can be used in the GPU renderer.
*/
const gpuSupportedDecorationCssRules = [
'color',
'font-weight',
'opacity',
];
function supportsCssRule(rule: string, style: CSSStyleDeclaration) {
if (!gpuSupportedDecorationCssRules.includes(rule)) {
return false;
}
// Check for values that aren't supported
switch (rule) {
default: return true;
}
}

switch (r) {
case 'color': {
// TODO: This parsing and error handling should move into canRender so fallback
// to DOM works
const parsedColor = Color.Format.CSS.parse(value);
if (!parsedColor) {
throw new BugIndicatingError('Invalid color format ' + value);
}
decorationStyleSetColor = parsedColor.toNumber32Bit();
break;
}
case 'font-weight': {
const parsedValue = parseCssFontWeight(value);
if (parsedValue >= 400) {
decorationStyleSetBold = true;

Metadata

Metadata

Assignees

Labels

debtCode quality issueseditor-gpuEditor GPU rendering related issues

Type

No type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions