mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Add CustomStateSet IDL type
This commit is contained in:
committed by
Tim Ledbetter
parent
bc94431b99
commit
e63d81b36e
Notes:
github-actions[bot]
2025-07-04 17:11:54 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/e63d81b36ec Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5302 Reviewed-by: https://github.com/tcl3 ✅
53
Libraries/LibWeb/HTML/CustomElements/CustomStateSet.cpp
Normal file
53
Libraries/LibWeb/HTML/CustomElements/CustomStateSet.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibGC/CellAllocator.h>
|
||||
#include <LibJS/Runtime/PrimitiveString.h>
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/HTML/CustomElements/CustomStateSet.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(CustomStateSet);
|
||||
|
||||
GC::Ref<CustomStateSet> CustomStateSet::create(JS::Realm& realm, GC::Ref<DOM::Element> element)
|
||||
{
|
||||
return realm.create<CustomStateSet>(realm, element);
|
||||
}
|
||||
|
||||
CustomStateSet::CustomStateSet(JS::Realm& realm, GC::Ref<DOM::Element> element)
|
||||
: Bindings::PlatformObject(realm)
|
||||
, m_set_entries(JS::Set::create(realm))
|
||||
, m_element(element)
|
||||
{
|
||||
}
|
||||
|
||||
void CustomStateSet::initialize(JS::Realm& realm)
|
||||
{
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(CustomStateSet);
|
||||
Base::initialize(realm);
|
||||
}
|
||||
|
||||
void CustomStateSet::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_set_entries);
|
||||
visitor.visit(m_element);
|
||||
}
|
||||
|
||||
bool CustomStateSet::has_state(FlyString const& state) const
|
||||
{
|
||||
return m_set_entries->set_has(JS::PrimitiveString::create(realm().vm(), state));
|
||||
}
|
||||
|
||||
void CustomStateSet::on_set_modified_from_js(Badge<Bindings::CustomStateSetPrototype>)
|
||||
{
|
||||
m_element->invalidate_style(DOM::StyleInvalidationReason::CustomStateSetChange);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user