1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:27:43 +00:00

LibWeb: Add range-checking to property_accepts_value()

For `number` and `integer` types, you can add a range afterwards to add
a range check, using similar syntax to that used in the CSS specs. For
example:

```json
"font-weight": {
  ...
  "valid-types": [
    "number [1,1000]"
  ],
  ...
}
```

This limits any numbers to the range `1 <= n <= 1000`.
This commit is contained in:
Sam Atkins 2021-09-23 12:45:08 +01:00 committed by Andreas Kling
parent e262596ee1
commit b927972da7
4 changed files with 31 additions and 3 deletions

View file

@ -98,6 +98,12 @@ bool StyleValue::is_color() const
return false;
}
float StyleValue::as_number() const
{
VERIFY(is_numeric());
return static_cast<NumericStyleValue const&>(*this).value();
}
String IdentifierStyleValue::to_string() const
{
return CSS::string_from_value_id(m_id);