mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:38:11 +00:00
LibWeb: Implement [SameObject] behavior for HTMLTableRowElement.cells
This commit is contained in:
parent
d1bc89e30b
commit
7d8ff0c581
2 changed files with 17 additions and 6 deletions
|
@ -23,17 +23,24 @@ HTMLTableRowElement::HTMLTableRowElement(DOM::Document& document, DOM::Qualified
|
||||||
|
|
||||||
HTMLTableRowElement::~HTMLTableRowElement() = default;
|
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
|
// https://html.spec.whatwg.org/multipage/tables.html#dom-tr-cells
|
||||||
JS::NonnullGCPtr<DOM::HTMLCollection> HTMLTableRowElement::cells() const
|
JS::NonnullGCPtr<DOM::HTMLCollection> HTMLTableRowElement::cells() const
|
||||||
{
|
{
|
||||||
// The cells attribute must return an HTMLCollection rooted at this tr element,
|
// 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.
|
// 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,
|
if (!m_cells) {
|
||||||
// but that would cause a reference cycle since HTMLCollection refs the root.
|
m_cells = DOM::HTMLCollection::create(const_cast<HTMLTableRowElement&>(*this), [this](Element const& element) {
|
||||||
return DOM::HTMLCollection::create(const_cast<HTMLTableRowElement&>(*this), [this](Element const& element) {
|
return element.parent() == this
|
||||||
return element.parent() == this
|
&& is<HTMLTableCellElement>(element);
|
||||||
&& is<HTMLTableCellElement>(element);
|
});
|
||||||
});
|
}
|
||||||
|
return *m_cells;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/tables.html#dom-tr-rowindex
|
// https://html.spec.whatwg.org/multipage/tables.html#dom-tr-rowindex
|
||||||
|
|
|
@ -25,6 +25,10 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HTMLTableRowElement(DOM::Document&, DOM::QualifiedName);
|
HTMLTableRowElement(DOM::Document&, DOM::QualifiedName);
|
||||||
|
|
||||||
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
|
JS::GCPtr<DOM::HTMLCollection> mutable m_cells;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue