HTMLTableRowElement.cpp 1.1 KB

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