mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 09:09:43 +00:00
LibWeb: Add more fast_is<T> helpers for DOM::Node subclasses
This commit is contained in:
parent
0e490e3352
commit
aecb144df0
Notes:
github-actions[bot]
2025-04-18 12:47:31 +00:00
Author: https://github.com/awesomekling
Commit: aecb144df0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4395
10 changed files with 68 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2024, Andreas Kling <andreas@ladybird.org>
|
* Copyright (c) 2018-2025, Andreas Kling <andreas@ladybird.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -144,6 +144,8 @@ public:
|
||||||
virtual bool is_svg_style_element() const { return false; }
|
virtual bool is_svg_style_element() const { return false; }
|
||||||
virtual bool is_svg_svg_element() const { return false; }
|
virtual bool is_svg_svg_element() const { return false; }
|
||||||
virtual bool is_svg_use_element() const { return false; }
|
virtual bool is_svg_use_element() const { return false; }
|
||||||
|
virtual bool is_svg_a_element() const { return false; }
|
||||||
|
virtual bool is_svg_foreign_object_element() const { return false; }
|
||||||
|
|
||||||
bool in_a_document_tree() const;
|
bool in_a_document_tree() const;
|
||||||
|
|
||||||
|
@ -158,10 +160,13 @@ public:
|
||||||
virtual bool is_html_element() const { return false; }
|
virtual bool is_html_element() const { return false; }
|
||||||
virtual bool is_html_html_element() const { return false; }
|
virtual bool is_html_html_element() const { return false; }
|
||||||
virtual bool is_html_anchor_element() const { return false; }
|
virtual bool is_html_anchor_element() const { return false; }
|
||||||
|
virtual bool is_html_area_element() const { return false; }
|
||||||
virtual bool is_html_base_element() const { return false; }
|
virtual bool is_html_base_element() const { return false; }
|
||||||
virtual bool is_html_body_element() const { return false; }
|
virtual bool is_html_body_element() const { return false; }
|
||||||
|
virtual bool is_html_head_element() const { return false; }
|
||||||
virtual bool is_html_input_element() const { return false; }
|
virtual bool is_html_input_element() const { return false; }
|
||||||
virtual bool is_html_link_element() const { return false; }
|
virtual bool is_html_link_element() const { return false; }
|
||||||
|
virtual bool is_html_media_element() const { return false; }
|
||||||
virtual bool is_html_progress_element() const { return false; }
|
virtual bool is_html_progress_element() const { return false; }
|
||||||
virtual bool is_html_script_element() const { return false; }
|
virtual bool is_html_script_element() const { return false; }
|
||||||
virtual bool is_html_style_element() const { return false; }
|
virtual bool is_html_style_element() const { return false; }
|
||||||
|
@ -170,6 +175,7 @@ public:
|
||||||
virtual bool is_html_table_section_element() const { return false; }
|
virtual bool is_html_table_section_element() const { return false; }
|
||||||
virtual bool is_html_table_row_element() const { return false; }
|
virtual bool is_html_table_row_element() const { return false; }
|
||||||
virtual bool is_html_table_cell_element() const { return false; }
|
virtual bool is_html_table_cell_element() const { return false; }
|
||||||
|
virtual bool is_html_title_element() const { return false; }
|
||||||
virtual bool is_html_br_element() const { return false; }
|
virtual bool is_html_br_element() const { return false; }
|
||||||
virtual bool is_html_button_element() const { return false; }
|
virtual bool is_html_button_element() const { return false; }
|
||||||
virtual bool is_html_slot_element() const { return false; }
|
virtual bool is_html_slot_element() const { return false; }
|
||||||
|
@ -178,6 +184,8 @@ public:
|
||||||
virtual bool is_html_form_element() const { return false; }
|
virtual bool is_html_form_element() const { return false; }
|
||||||
virtual bool is_html_image_element() const { return false; }
|
virtual bool is_html_image_element() const { return false; }
|
||||||
virtual bool is_html_iframe_element() const { return false; }
|
virtual bool is_html_iframe_element() const { return false; }
|
||||||
|
virtual bool is_html_frameset_element() const { return false; }
|
||||||
|
virtual bool is_html_fieldset_element() const { return false; }
|
||||||
virtual bool is_navigable_container() const { return false; }
|
virtual bool is_navigable_container() const { return false; }
|
||||||
virtual bool is_lazy_loading() const { return false; }
|
virtual bool is_lazy_loading() const { return false; }
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ public:
|
||||||
private:
|
private:
|
||||||
HTMLAreaElement(DOM::Document&, DOM::QualifiedName);
|
HTMLAreaElement(DOM::Document&, DOM::QualifiedName);
|
||||||
|
|
||||||
|
virtual bool is_html_area_element() const override { return true; }
|
||||||
|
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
|
@ -59,3 +61,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Web::DOM {
|
||||||
|
template<>
|
||||||
|
inline bool Node::fast_is<HTML::HTMLAreaElement>() const { return is_html_area_element(); }
|
||||||
|
}
|
||||||
|
|
|
@ -54,7 +54,14 @@ private:
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
|
virtual bool is_html_fieldset_element() const override { return true; }
|
||||||
|
|
||||||
GC::Ptr<DOM::HTMLCollection> m_elements;
|
GC::Ptr<DOM::HTMLCollection> m_elements;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Web::DOM {
|
||||||
|
template<>
|
||||||
|
inline bool Node::fast_is<HTML::HTMLFieldSetElement>() const { return is_html_fieldset_element(); }
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ public:
|
||||||
private:
|
private:
|
||||||
HTMLFrameSetElement(DOM::Document&, DOM::QualifiedName);
|
HTMLFrameSetElement(DOM::Document&, DOM::QualifiedName);
|
||||||
|
|
||||||
|
virtual bool is_html_frameset_element() const override { return true; }
|
||||||
|
|
||||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||||
|
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
|
@ -37,3 +39,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Web::DOM {
|
||||||
|
template<>
|
||||||
|
inline bool Node::fast_is<HTML::HTMLFrameSetElement>() const { return is_html_frameset_element(); }
|
||||||
|
}
|
||||||
|
|
|
@ -20,7 +20,13 @@ public:
|
||||||
private:
|
private:
|
||||||
HTMLHeadElement(DOM::Document&, DOM::QualifiedName);
|
HTMLHeadElement(DOM::Document&, DOM::QualifiedName);
|
||||||
|
|
||||||
|
virtual bool is_html_head_element() const final { return true; }
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Web::DOM {
|
||||||
|
template<>
|
||||||
|
inline bool Node::fast_is<HTML::HTMLHeadElement>() const { return is_html_head_element(); }
|
||||||
|
}
|
||||||
|
|
|
@ -69,3 +69,8 @@ private:
|
||||||
void run_iframe_load_event_steps(HTML::HTMLIFrameElement&);
|
void run_iframe_load_event_steps(HTML::HTMLIFrameElement&);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Web::DOM {
|
||||||
|
template<>
|
||||||
|
inline bool Node::fast_is<HTML::HTMLIFrameElement>() const { return is_html_iframe_element(); }
|
||||||
|
}
|
||||||
|
|
|
@ -182,6 +182,8 @@ protected:
|
||||||
private:
|
private:
|
||||||
friend SourceElementSelector;
|
friend SourceElementSelector;
|
||||||
|
|
||||||
|
virtual bool is_html_media_element() const final { return true; }
|
||||||
|
|
||||||
struct EntireResource { };
|
struct EntireResource { };
|
||||||
using ByteRange = Variant<EntireResource>; // FIXME: This will need to include "until end" and an actual byte range.
|
using ByteRange = Variant<EntireResource>; // FIXME: This will need to include "until end" and an actual byte range.
|
||||||
|
|
||||||
|
@ -324,3 +326,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Web::DOM {
|
||||||
|
template<>
|
||||||
|
inline bool Node::fast_is<HTML::HTMLMediaElement>() const { return is_html_media_element(); }
|
||||||
|
}
|
||||||
|
|
|
@ -23,8 +23,14 @@ public:
|
||||||
private:
|
private:
|
||||||
HTMLTitleElement(DOM::Document&, DOM::QualifiedName);
|
HTMLTitleElement(DOM::Document&, DOM::QualifiedName);
|
||||||
|
|
||||||
|
virtual bool is_html_title_element() const override { return true; }
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
virtual void children_changed(ChildrenChangedMetadata const*) override;
|
virtual void children_changed(ChildrenChangedMetadata const*) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Web::DOM {
|
||||||
|
template<>
|
||||||
|
inline bool Node::fast_is<HTML::HTMLTitleElement>() const { return is_html_title_element(); }
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@ private:
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
|
virtual bool is_svg_a_element() const override { return true; }
|
||||||
|
|
||||||
// ^DOM::Element
|
// ^DOM::Element
|
||||||
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
||||||
virtual i32 default_tab_index_value() const override;
|
virtual i32 default_tab_index_value() const override;
|
||||||
|
@ -39,3 +41,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Web::DOM {
|
||||||
|
template<>
|
||||||
|
inline bool Node::fast_is<SVG::SVGAElement>() const { return is_svg_a_element(); }
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ public:
|
||||||
private:
|
private:
|
||||||
SVGForeignObjectElement(DOM::Document& document, DOM::QualifiedName qualified_name);
|
SVGForeignObjectElement(DOM::Document& document, DOM::QualifiedName qualified_name);
|
||||||
|
|
||||||
|
virtual bool is_svg_foreign_object_element() const override { return true; }
|
||||||
|
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
|
@ -41,3 +43,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Web::DOM {
|
||||||
|
template<>
|
||||||
|
inline bool Node::fast_is<SVG::SVGForeignObjectElement>() const { return is_svg_foreign_object_element(); }
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue