summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-02-26 11:43:52 +0100
committerAndreas Kling <kling@serenityos.org>2022-02-26 12:18:39 +0100
commit79ea30bc967f0ed1b28cb4aed4d6fdabb3f62408 (patch)
treed8600b815771fa8d9a3193493111c86d81ee1000 /Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp
parent647576ec13f6be9f2b7f7c9ef4fef8aaf083f5f2 (diff)
downloadserenity-79ea30bc967f0ed1b28cb4aed4d6fdabb3f62408.zip
LibWeb: Add HTMLTableSectionElement.rows and HTMLTableRowElement.cells
1% progression on ACID3. :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp')
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp
index 22698165c8..0e08d6f8f6 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLTableSectionElement.cpp
@@ -1,9 +1,12 @@
/*
* Copyright (c) 2020, the SerenityOS developers.
+ * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <LibWeb/DOM/HTMLCollection.h>
+#include <LibWeb/HTML/HTMLTableRowElement.h>
#include <LibWeb/HTML/HTMLTableSectionElement.h>
namespace Web::HTML {
@@ -17,4 +20,17 @@ HTMLTableSectionElement::~HTMLTableSectionElement()
{
}
+// https://html.spec.whatwg.org/multipage/tables.html#dom-tbody-rows
+NonnullRefPtr<DOM::HTMLCollection> HTMLTableSectionElement::rows() const
+{
+ // The rows attribute must return an HTMLCollection rooted at this element,
+ // whose filter matches only tr elements that are children of this 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<HTMLTableSectionElement&>(*this), [this](Element const& element) {
+ return element.parent() == this
+ && is<HTMLTableRowElement>(element);
+ });
+}
+
}