mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +00:00
LibWeb: Clarify StyleValue API with new naming scheme
This does a few things, that are hard to separate. For a while now, it's been confuzing what `StyleValue::is_foo()` actually means. It sometimes was used to check the type, and sometimes to see if it could return a certain value type. The new naming scheme is: - `is_length()` - is it a LengthStyleValue? - `as_length()` - casts it to LengthStyleValue - `has_length()` - can it return a Length? - `to_length()` - gets the internal value out (eg, Length) This also means, no more `static_cast<LengthStyleValue const&>(*this)` stuff when dealing with StyleValues. :^) Hopefully this will be a bit clearer going forward. There are lots of places using the original methods, so I'll be going through them to hopefully catch any issues.
This commit is contained in:
parent
1ae0781ce1
commit
4b554ba92a
6 changed files with 263 additions and 60 deletions
|
@ -268,7 +268,7 @@ Optional<int> StyleProperties::z_index() const
|
|||
return {};
|
||||
auto& value = maybe_value.value();
|
||||
|
||||
if (value->is_auto())
|
||||
if (value->has_auto())
|
||||
return 0;
|
||||
if (value->is_numeric())
|
||||
return static_cast<int>(static_cast<NumericStyleValue&>(*value).value());
|
||||
|
@ -339,7 +339,7 @@ Optional<CSS::FlexBasisData> StyleProperties::flex_basis() const
|
|||
if (value.value()->is_identifier() && value.value()->to_identifier() == CSS::ValueID::Content)
|
||||
return { { CSS::FlexBasis::Content, {} } };
|
||||
|
||||
if (value.value()->is_auto())
|
||||
if (value.value()->has_auto())
|
||||
return { { CSS::FlexBasis::Auto, {} } };
|
||||
|
||||
if (value.value()->is_length())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue