mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-08 02:26:10 +00:00
LibWeb: Make Node::parent_element() an inline function
Also remove a redundant verify_cast<Element> while we're here.
This commit is contained in:
parent
d7e2894e57
commit
b40f0415ef
Notes:
sideshowbarker
2024-07-17 03:18:29 +09:00
Author: https://github.com/awesomekling
Commit: b40f0415ef
Pull-request: https://github.com/SerenityOS/serenity/pull/23637
2 changed files with 16 additions and 14 deletions
|
@ -454,6 +454,22 @@ private:
|
||||||
template<>
|
template<>
|
||||||
inline bool Node::fast_is<Element>() const { return is_element(); }
|
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);
|
WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Realm&, Optional<FlyString> namespace_, FlyString const& qualified_name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -330,20 +330,6 @@ bool Node::is_connected() const
|
||||||
return shadow_including_root().is_document();
|
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
|
// 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
|
WebIDL::ExceptionOr<void> Node::ensure_pre_insertion_validity(JS::NonnullGCPtr<Node> node, JS::GCPtr<Node> child) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue