HTMLBodyElement.cpp 860 B

123456789101112131415161718192021222324252627
  1. #include <LibHTML/CSS/StyleProperties.h>
  2. #include <LibHTML/CSS/StyleValue.h>
  3. #include <LibHTML/DOM/HTMLBodyElement.h>
  4. HTMLBodyElement::HTMLBodyElement(Document& document, const String& tag_name)
  5. : HTMLElement(document, tag_name)
  6. {
  7. }
  8. HTMLBodyElement::~HTMLBodyElement()
  9. {
  10. }
  11. void HTMLBodyElement::apply_presentational_hints(StyleProperties& style) const
  12. {
  13. for_each_attribute([&](auto& name, auto& value) {
  14. if (name == "bgcolor") {
  15. auto color = Color::from_string(value);
  16. if (color.has_value())
  17. style.set_property("background-color", ColorStyleValue::create(color.value()));
  18. } else if (name == "text") {
  19. auto color = Color::from_string(value);
  20. if (color.has_value())
  21. style.set_property("color", ColorStyleValue::create(color.value()));
  22. }
  23. });
  24. }