mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Implement [SameObject] behavior for HTMLTableRowElement.cells
This commit is contained in:
parent
d1bc89e30b
commit
7d8ff0c581
Notes:
sideshowbarker
2024-07-17 04:08:16 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7d8ff0c581 Pull-request: https://github.com/SerenityOS/serenity/pull/16175 Reviewed-by: https://github.com/ADKaster
2 changed files with 17 additions and 6 deletions
|
@ -23,17 +23,24 @@ HTMLTableRowElement::HTMLTableRowElement(DOM::Document& document, DOM::Qualified
|
|||
|
||||
HTMLTableRowElement::~HTMLTableRowElement() = default;
|
||||
|
||||
void HTMLTableRowElement::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_cells);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/tables.html#dom-tr-cells
|
||||
JS::NonnullGCPtr<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);
|
||||
});
|
||||
if (!m_cells) {
|
||||
m_cells = DOM::HTMLCollection::create(const_cast<HTMLTableRowElement&>(*this), [this](Element const& element) {
|
||||
return element.parent() == this
|
||||
&& is<HTMLTableCellElement>(element);
|
||||
});
|
||||
}
|
||||
return *m_cells;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/tables.html#dom-tr-rowindex
|
||||
|
|
|
@ -25,6 +25,10 @@ public:
|
|||
|
||||
private:
|
||||
HTMLTableRowElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::GCPtr<DOM::HTMLCollection> mutable m_cells;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue