mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
LibWeb: Implement basic support for Document.all
The finer details are missing here, but the basic API is up.
This commit is contained in:
parent
3df9861814
commit
e6ef366859
Notes:
sideshowbarker
2024-07-17 06:53:00 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e6ef366859
3 changed files with 17 additions and 0 deletions
|
@ -323,6 +323,7 @@ void Document::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(m_links);
|
||||
visitor.visit(m_forms);
|
||||
visitor.visit(m_scripts);
|
||||
visitor.visit(m_all);
|
||||
|
||||
for (auto& script : m_scripts_to_execute_when_parsing_has_finished)
|
||||
visitor.visit(script.ptr());
|
||||
|
@ -1041,6 +1042,17 @@ JS::NonnullGCPtr<HTMLCollection> Document::scripts()
|
|||
return *m_scripts;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dom.html#dom-document-all
|
||||
JS::NonnullGCPtr<HTMLCollection> Document::all()
|
||||
{
|
||||
if (!m_all) {
|
||||
m_all = HTMLCollection::create(*this, [](Element const&) {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
return *m_all;
|
||||
}
|
||||
|
||||
Color Document::link_color() const
|
||||
{
|
||||
if (m_link_color.has_value())
|
||||
|
|
|
@ -183,6 +183,7 @@ public:
|
|||
JS::NonnullGCPtr<HTMLCollection> links();
|
||||
JS::NonnullGCPtr<HTMLCollection> forms();
|
||||
JS::NonnullGCPtr<HTMLCollection> scripts();
|
||||
JS::NonnullGCPtr<HTMLCollection> all();
|
||||
|
||||
String const& source() const { return m_source; }
|
||||
void set_source(String const& source) { m_source = source; }
|
||||
|
@ -494,6 +495,7 @@ private:
|
|||
JS::GCPtr<HTMLCollection> m_links;
|
||||
JS::GCPtr<HTMLCollection> m_forms;
|
||||
JS::GCPtr<HTMLCollection> m_scripts;
|
||||
JS::GCPtr<HTMLCollection> m_all;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -69,6 +69,9 @@ interface Document : Node {
|
|||
readonly attribute HTMLCollection forms;
|
||||
readonly attribute HTMLCollection scripts;
|
||||
|
||||
// FIXME: Should return an HTMLAllCollection
|
||||
readonly attribute HTMLCollection all;
|
||||
|
||||
Element createElement(DOMString tagName);
|
||||
Element createElementNS(DOMString? namespace, DOMString qualifiedName);
|
||||
DocumentFragment createDocumentFragment();
|
||||
|
|
Loading…
Reference in a new issue