HTMLFontElement.cpp 962 B

123456789101112131415161718192021222324252627282930313233
  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. #include <LibWeb/HTML/Window.h>
  10. namespace Web::HTML {
  11. HTMLFontElement::HTMLFontElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  12. : HTMLElement(document, move(qualified_name))
  13. {
  14. set_prototype(&window().cached_web_prototype("HTMLFontElement"));
  15. }
  16. HTMLFontElement::~HTMLFontElement() = default;
  17. void HTMLFontElement::apply_presentational_hints(CSS::StyleProperties& style) const
  18. {
  19. for_each_attribute([&](auto& name, auto& value) {
  20. if (name.equals_ignoring_case("color"sv)) {
  21. auto color = Color::from_string(value);
  22. if (color.has_value())
  23. style.set_property(CSS::PropertyID::Color, CSS::ColorStyleValue::create(color.value()));
  24. }
  25. });
  26. }
  27. }