LibWeb: Make Node::parent_element() an inline function

Also remove a redundant verify_cast<Element> while we're here.
This commit is contained in:
Andreas Kling 2024-03-19 10:32:16 +01:00
parent d7e2894e57
commit b40f0415ef
2 changed files with 16 additions and 14 deletions

View file

@ -454,6 +454,22 @@ private:
template<>
inline bool Node::fast_is<Element>() const { return is_element(); }
inline Element* Node::parent_element()
{
auto* parent = this->parent();
if (!parent || !is<Element>(parent))
return nullptr;
return static_cast<Element*>(parent);
}
inline Element const* Node::parent_element() const
{
auto const* parent = this->parent();
if (!parent || !is<Element>(parent))
return nullptr;
return static_cast<Element const*>(parent);
}
WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Realm&, Optional<FlyString> namespace_, FlyString const& qualified_name);
}

View file

@ -330,20 +330,6 @@ bool Node::is_connected() const
return shadow_including_root().is_document();
}
Element* Node::parent_element()
{
if (!parent() || !is<Element>(parent()))
return nullptr;
return verify_cast<Element>(parent());
}
Element const* Node::parent_element() const
{
if (!parent() || !is<Element>(parent()))
return nullptr;
return verify_cast<Element>(parent());
}
// https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
WebIDL::ExceptionOr<void> Node::ensure_pre_insertion_validity(JS::NonnullGCPtr<Node> node, JS::GCPtr<Node> child) const
{