diff options
author | Tobias Christiansen <tobi@tobyase.de> | 2021-05-30 20:22:25 +0200 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-06-06 01:46:06 +0430 |
commit | ae61e9ded20638f3fadcdb25dc0210d1dba116dc (patch) | |
tree | 8596d3452dcb96fbc8e4a28d359d7fccbf9b4b55 /Userland/Libraries/LibWeb/CSS/StyleProperties.cpp | |
parent | af4d80af4d85dd469b852bad9b8b1daca2a0d9c5 (diff) | |
download | serenity-ae61e9ded20638f3fadcdb25dc0210d1dba116dc.zip |
LibWeb: Add flex-grow and flex-shrink
They get parsed and are available to the programmer of Layouts :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/StyleProperties.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleProperties.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index 6358e02613..0140059dcf 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <AK/TypeCasts.h> #include <LibCore/DirIterator.h> #include <LibGfx/FontDatabase.h> #include <LibWeb/CSS/StyleProperties.h> @@ -272,6 +273,32 @@ Optional<CSS::FlexBasisData> StyleProperties::flex_basis() const return {}; } +Optional<float> StyleProperties::flex_grow_factor() const +{ + auto value = property(CSS::PropertyID::FlexGrow); + if (!value.has_value()) + return {}; + if (value.value()->is_length() && downcast<CSS::LengthStyleValue>(value.value().ptr())->to_length().raw_value() == 0) + return { 0 }; + if (!value.value()->is_numeric()) + return {}; + auto numeric = downcast<CSS::NumericStyleValue>(value.value().ptr()); + return numeric->value(); +} + +Optional<float> StyleProperties::flex_shrink_factor() const +{ + auto value = property(CSS::PropertyID::FlexShrink); + if (!value.has_value()) + return {}; + if (value.value()->is_length() && downcast<CSS::LengthStyleValue>(value.value().ptr())->to_length().raw_value() == 0) + return { 0 }; + if (!value.value()->is_numeric()) + return {}; + auto numeric = downcast<CSS::NumericStyleValue>(value.value().ptr()); + return numeric->value(); +} + Optional<CSS::Position> StyleProperties::position() const { auto value = property(CSS::PropertyID::Position); @@ -694,5 +721,4 @@ Optional<CSS::Repeat> StyleProperties::background_repeat_y() const return {}; } } - } |