StyleProperties.cpp 642 B

12345678910111213141516171819202122
  1. #include <LibHTML/CSS/StyleProperties.h>
  2. void StyleProperties::set_property(const String& name, NonnullRefPtr<StyleValue> value)
  3. {
  4. m_property_values.set(name, move(value));
  5. }
  6. Optional<NonnullRefPtr<StyleValue>> StyleProperties::property(const String& name) const
  7. {
  8. auto it = m_property_values.find(name);
  9. if (it == m_property_values.end())
  10. return {};
  11. return it->value;
  12. }
  13. Length StyleProperties::length_or_fallback(const StringView& property_name, const Length& fallback) const
  14. {
  15. auto value = property(property_name);
  16. if (!value.has_value())
  17. return fallback;
  18. return value.value()->to_length();
  19. }