HTMLTableCaptionElement.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/Intrinsics.h>
  7. #include <LibWeb/CSS/StyleProperties.h>
  8. #include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
  9. #include <LibWeb/HTML/HTMLTableCaptionElement.h>
  10. namespace Web::HTML {
  11. JS_DEFINE_ALLOCATOR(HTMLTableCaptionElement);
  12. HTMLTableCaptionElement::HTMLTableCaptionElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  13. : HTMLElement(document, move(qualified_name))
  14. {
  15. }
  16. HTMLTableCaptionElement::~HTMLTableCaptionElement() = default;
  17. void HTMLTableCaptionElement::initialize(JS::Realm& realm)
  18. {
  19. Base::initialize(realm);
  20. WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLTableCaptionElement);
  21. }
  22. // https://html.spec.whatwg.org/multipage/rendering.html#tables-2
  23. void HTMLTableCaptionElement::apply_presentational_hints(CSS::StyleProperties& style) const
  24. {
  25. HTMLElement::apply_presentational_hints(style);
  26. for_each_attribute([&](auto& name, auto& value) {
  27. if (name.equals_ignoring_ascii_case("align"sv)) {
  28. if (value == "bottom"sv)
  29. style.set_property(CSS::PropertyID::CaptionSide, CSS::IdentifierStyleValue::create(CSS::ValueID::Bottom));
  30. }
  31. });
  32. }
  33. }