mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:17:35 +00:00
LibWeb: Add a helper function for checking if element is a shadow host
This commit is contained in:
parent
2cc108a15e
commit
01e2cc5330
3 changed files with 9 additions and 1 deletions
|
@ -537,6 +537,13 @@ JS::NonnullGCPtr<HTMLCollection> Element::get_elements_by_class_name(DeprecatedF
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#element-shadow-host
|
||||||
|
bool Element::is_shadow_host() const
|
||||||
|
{
|
||||||
|
// An element is a shadow host if its shadow root is non-null.
|
||||||
|
return m_shadow_root != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void Element::set_shadow_root(JS::GCPtr<ShadowRoot> shadow_root)
|
void Element::set_shadow_root(JS::GCPtr<ShadowRoot> shadow_root)
|
||||||
{
|
{
|
||||||
if (m_shadow_root == shadow_root)
|
if (m_shadow_root == shadow_root)
|
||||||
|
|
|
@ -131,6 +131,7 @@ public:
|
||||||
|
|
||||||
JS::NonnullGCPtr<HTMLCollection> get_elements_by_class_name(DeprecatedFlyString const&);
|
JS::NonnullGCPtr<HTMLCollection> get_elements_by_class_name(DeprecatedFlyString const&);
|
||||||
|
|
||||||
|
bool is_shadow_host() const;
|
||||||
ShadowRoot* shadow_root_internal() { return m_shadow_root.ptr(); }
|
ShadowRoot* shadow_root_internal() { return m_shadow_root.ptr(); }
|
||||||
ShadowRoot const* shadow_root_internal() const { return m_shadow_root.ptr(); }
|
ShadowRoot const* shadow_root_internal() const { return m_shadow_root.ptr(); }
|
||||||
void set_shadow_root(JS::GCPtr<ShadowRoot>);
|
void set_shadow_root(JS::GCPtr<ShadowRoot>);
|
||||||
|
|
|
@ -210,7 +210,7 @@ void run_unfocusing_steps(DOM::Node* old_focus_target)
|
||||||
// with the focusing steps.
|
// with the focusing steps.
|
||||||
|
|
||||||
auto is_shadow_host = [](DOM::Node* node) {
|
auto is_shadow_host = [](DOM::Node* node) {
|
||||||
return is<DOM::Element>(node) && static_cast<DOM::Element*>(node)->shadow_root() != nullptr;
|
return is<DOM::Element>(node) && static_cast<DOM::Element*>(node)->is_shadow_host();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 1. If old focus target is a shadow host whose shadow root's delegates focus is true, and old focus target's
|
// 1. If old focus target is a shadow host whose shadow root's delegates focus is true, and old focus target's
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue