HTMLFontElement.cpp 858 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/CSS/StyleProperties.h>
  7. #include <LibWeb/CSS/StyleValue.h>
  8. #include <LibWeb/HTML/HTMLFontElement.h>
  9. namespace Web::HTML {
  10. HTMLFontElement::HTMLFontElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  11. : HTMLElement(document, move(qualified_name))
  12. {
  13. }
  14. HTMLFontElement::~HTMLFontElement() = default;
  15. void HTMLFontElement::apply_presentational_hints(CSS::StyleProperties& style) const
  16. {
  17. for_each_attribute([&](auto& name, auto& value) {
  18. if (name.equals_ignoring_case("color")) {
  19. auto color = Color::from_string(value);
  20. if (color.has_value())
  21. style.set_property(CSS::PropertyID::Color, CSS::ColorStyleValue::create(color.value()));
  22. }
  23. });
  24. }
  25. }