HTMLFontElement.cpp 1.0 KB

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