1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 04:34:59 +00:00

LibWeb: Add HTMLTableSectionElement.rows and HTMLTableRowElement.cells

1% progression on ACID3. :^)
This commit is contained in:
Andreas Kling 2022-02-26 11:43:52 +01:00
parent 647576ec13
commit 79ea30bc96
6 changed files with 43 additions and 1 deletions

View file

@ -1,9 +1,11 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/DOM/HTMLCollection.h>
#include <LibWeb/HTML/HTMLTableCellElement.h>
#include <LibWeb/HTML/HTMLTableRowElement.h>
namespace Web::HTML {
@ -17,4 +19,17 @@ HTMLTableRowElement::~HTMLTableRowElement()
{
}
// https://html.spec.whatwg.org/multipage/tables.html#dom-tr-cells
NonnullRefPtr<DOM::HTMLCollection> HTMLTableRowElement::cells() const
{
// The cells attribute must return an HTMLCollection rooted at this tr element,
// whose filter matches only td and th elements that are children of the tr element.
// FIXME: This should return the same HTMLCollection object every time,
// but that would cause a reference cycle since HTMLCollection refs the root.
return DOM::HTMLCollection::create(const_cast<HTMLTableRowElement&>(*this), [this](Element const& element) {
return element.parent() == this
&& is<HTMLTableCellElement>(element);
});
}
}