Browse Source

LibWeb: Add LengthPercentage::is_auto() convenience helper

This lets you ask if a LengthPercentage is `auto` with one call instead
of two, which will make some conditions nicer to express.
Andreas Kling 3 years ago
parent
commit
734ff422ad
1 changed files with 2 additions and 0 deletions
  1. 2 0
      Userland/Libraries/LibWeb/CSS/Percentage.h

+ 2 - 0
Userland/Libraries/LibWeb/CSS/Percentage.h

@@ -182,6 +182,8 @@ class LengthPercentage : public PercentageOr<Length> {
 public:
 public:
     using PercentageOr<Length>::PercentageOr;
     using PercentageOr<Length>::PercentageOr;
 
 
+    bool is_auto() const { return is_length() && length().is_auto(); }
+
     bool is_length() const { return is_t(); }
     bool is_length() const { return is_t(); }
     Length const& length() const { return get_t(); }
     Length const& length() const { return get_t(); }
     virtual Length resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&, Length const& reference_value) const override;
     virtual Length resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const&, Layout::Node const&, Length const& reference_value) const override;