Open Bug 1857518 Opened 2 years ago Updated 2 months ago

Add a way to check that property name and values are valid for CSSPropertyRule

Categories

(DevTools :: Inspector, task, P3)

task

Tracking

(Not tracked)

People

(Reporter: nchevobbe, Unassigned)

References

Details

At the moment, we're using InspectorUtils.supports (based on CSS.supports), to check if a declaration is valid, and also to check if the property name is valid https://searchfox.org/mozilla-central/rev/6602bdf9fff5020fbc8e248c963ddddf09a77b1b/devtools/server/actors/style-rule.js#440-443,447-450

decl.isValid = InspectorUtils.supports(
  `${decl.name}:${decl.value}`,
  supportsOptions
);
...
decl.isNameValid = InspectorUtils.supports(
  `${decl.name}:initial`,
  supportsOptions
);

This doesn't work for @property declarations (e.g. CSS.supports('syntax: "<color>"'))
This mean we should either:

  • add support for such thing in InspectorUtils.supports (maybe with a specific option, but not sure how hard this would be/if we want this)
  • add another method for which would give us information about the validity of the declarations of the CSSPropertyRule telling us:
    • if a given property name is valid (this one should be easy)
    • if the given value is valid for the property
    • but also extra info like is the initial-value valid based on the rule syntax value, …

Zach, do you know how complex it would be to implement ?

Flags: needinfo?(zach)

It sounds like the fact that an invalid @property rule will still result in a CSSPropertyRule (but not a property registration) might be complicating things a bit. That behavior does not match the spec, and it needs to be fixed (see bug 1857724).

  • if the given value is valid for the property

Probably the Servo_GetRegisteredCustomProperties binding from bug 1841265 can be used, but validating would also need another binding to expose properties_and_values::ComputedValue::parse ?

https://searchfox.org/mozilla-central/rev/17a7c14d6e36ae370c78e63104b82d296ecd0761/servo/components/style/properties_and_values/value.rs#94

  • but also extra info like is the initial-value valid based on the rule syntax value, …

Validating the initial value should be pretty straightforward, we already do essentially that before registering custom properties from JavaScript:

https://searchfox.org/mozilla-central/rev/17a7c14d6e36ae370c78e63104b82d296ecd0761/servo/ports/geckolib/glue.rs#8577-8590

Flags: needinfo?(zach)
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.