HTMLTableSectionElement.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #include <LibWeb/DOM/HTMLCollection.h>
  8. #include <LibWeb/HTML/HTMLTableRowElement.h>
  9. #include <LibWeb/HTML/HTMLTableSectionElement.h>
  10. namespace Web::HTML {
  11. HTMLTableSectionElement::HTMLTableSectionElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  12. : HTMLElement(document, move(qualified_name))
  13. {
  14. }
  15. HTMLTableSectionElement::~HTMLTableSectionElement()
  16. {
  17. }
  18. // https://html.spec.whatwg.org/multipage/tables.html#dom-tbody-rows
  19. NonnullRefPtr<DOM::HTMLCollection> HTMLTableSectionElement::rows() const
  20. {
  21. // The rows attribute must return an HTMLCollection rooted at this element,
  22. // whose filter matches only tr elements that are children of this element.
  23. // FIXME: This should return the same HTMLCollection object every time,
  24. // but that would cause a reference cycle since HTMLCollection refs the root.
  25. return DOM::HTMLCollection::create(const_cast<HTMLTableSectionElement&>(*this), [this](Element const& element) {
  26. return element.parent() == this
  27. && is<HTMLTableRowElement>(element);
  28. });
  29. }
  30. }