HTMLTableElement.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/CSS/Parser/DeprecatedCSSParser.h>
  7. #include <LibWeb/HTML/HTMLTableElement.h>
  8. namespace Web::HTML {
  9. HTMLTableElement::HTMLTableElement(DOM::Document& document, QualifiedName qualified_name)
  10. : HTMLElement(document, move(qualified_name))
  11. {
  12. }
  13. HTMLTableElement::~HTMLTableElement()
  14. {
  15. }
  16. void HTMLTableElement::apply_presentational_hints(CSS::StyleProperties& style) const
  17. {
  18. for_each_attribute([&](auto& name, auto& value) {
  19. if (name == HTML::AttributeNames::width) {
  20. if (auto parsed_value = parse_html_length(document(), value))
  21. style.set_property(CSS::PropertyID::Width, parsed_value.release_nonnull());
  22. return;
  23. }
  24. if (name == HTML::AttributeNames::height) {
  25. if (auto parsed_value = parse_html_length(document(), value))
  26. style.set_property(CSS::PropertyID::Height, parsed_value.release_nonnull());
  27. return;
  28. }
  29. if (name == HTML::AttributeNames::bgcolor) {
  30. auto color = Color::from_string(value);
  31. if (color.has_value())
  32. style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()));
  33. return;
  34. }
  35. });
  36. }
  37. }