mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Shave 168 bytes off of ARIAMixin
Instead of keeping the vectors inside ARIAMixin, point to the heap using OwnPtrs.
This commit is contained in:
parent
9d26626200
commit
b6f5c91a35
Notes:
github-actions[bot]
2025-11-07 16:00:28 +00:00
Author: https://github.com/gmta
Commit: b6f5c91a35
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6733
4 changed files with 31 additions and 23 deletions
|
|
@ -1,9 +1,11 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Jonah Shafran <jonahshafran@gmail.com>
|
||||
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibWeb/ARIA/ARIAMixin.h>
|
||||
#include <LibWeb/ARIA/Roles.h>
|
||||
|
|
@ -247,25 +249,31 @@ Vector<String> ARIAMixin::parse_id_reference_list(Optional<String> const& id_lis
|
|||
ENUMERATE_ARIA_ELEMENT_REFERENCING_ATTRIBUTES
|
||||
#undef __ENUMERATE_ARIA_ATTRIBUTE
|
||||
|
||||
#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \
|
||||
Optional<Vector<GC::Weak<DOM::Element>>> const& ARIAMixin::attribute() const \
|
||||
{ \
|
||||
return m_##attribute; \
|
||||
} \
|
||||
\
|
||||
void ARIAMixin::set_##attribute(Optional<Vector<GC::Weak<DOM::Element>>> value) \
|
||||
{ \
|
||||
m_##attribute = move(value); \
|
||||
} \
|
||||
\
|
||||
GC::Ptr<JS::Array> ARIAMixin::cached_##attribute() const \
|
||||
{ \
|
||||
return m_cached_##attribute; \
|
||||
} \
|
||||
\
|
||||
void ARIAMixin::set_cached_##attribute(GC::Ptr<JS::Array> value) \
|
||||
{ \
|
||||
m_cached_##attribute = value; \
|
||||
#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \
|
||||
Optional<Vector<GC::Weak<DOM::Element>> const&> ARIAMixin::attribute() const \
|
||||
{ \
|
||||
if (!m_##attribute) \
|
||||
return {}; \
|
||||
return *m_##attribute; \
|
||||
} \
|
||||
\
|
||||
void ARIAMixin::set_##attribute(Optional<Vector<GC::Weak<DOM::Element>>> value) \
|
||||
{ \
|
||||
if (!value.has_value()) { \
|
||||
m_##attribute.clear(); \
|
||||
return; \
|
||||
} \
|
||||
m_##attribute = make<Vector<GC::Weak<DOM::Element>>>(value.release_value()); \
|
||||
} \
|
||||
\
|
||||
GC::Ptr<JS::Array> ARIAMixin::cached_##attribute() const \
|
||||
{ \
|
||||
return m_cached_##attribute; \
|
||||
} \
|
||||
\
|
||||
void ARIAMixin::set_cached_##attribute(GC::Ptr<JS::Array> value) \
|
||||
{ \
|
||||
m_cached_##attribute = value; \
|
||||
}
|
||||
ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES
|
||||
#undef __ENUMERATE_ARIA_ATTRIBUTE
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public:
|
|||
#undef __ENUMERATE_ARIA_ATTRIBUTE
|
||||
|
||||
#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \
|
||||
Optional<Vector<GC::Weak<DOM::Element>>> const& attribute() const; \
|
||||
Optional<Vector<GC::Weak<DOM::Element>> const&> attribute() const; \
|
||||
void set_##attribute(Optional<Vector<GC::Weak<DOM::Element>>>); \
|
||||
\
|
||||
GC::Ptr<JS::Array> cached_##attribute() const; \
|
||||
|
|
@ -90,7 +90,7 @@ private:
|
|||
#undef __ENUMERATE_ARIA_ATTRIBUTE
|
||||
|
||||
#define __ENUMERATE_ARIA_ATTRIBUTE(attribute, referencing_attribute) \
|
||||
Optional<Vector<GC::Weak<DOM::Element>>> m_##attribute; \
|
||||
OwnPtr<Vector<GC::Weak<DOM::Element>>> m_##attribute; \
|
||||
GC::Ptr<JS::Array> m_cached_##attribute;
|
||||
ENUMERATE_ARIA_ELEMENT_LIST_REFERENCING_ATTRIBUTES
|
||||
#undef __ENUMERATE_ARIA_ATTRIBUTE
|
||||
|
|
|
|||
|
|
@ -566,7 +566,7 @@ GC::Ptr<DOM::Element> Element::get_the_attribute_associated_element(FlyString co
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#attr-associated-elements
|
||||
Optional<GC::RootVector<GC::Ref<DOM::Element>>> Element::get_the_attribute_associated_elements(FlyString const& content_attribute, Optional<Vector<GC::Weak<DOM::Element>>> const& explicitly_set_attribute_elements) const
|
||||
Optional<GC::RootVector<GC::Ref<DOM::Element>>> Element::get_the_attribute_associated_elements(FlyString const& content_attribute, Optional<Vector<GC::Weak<DOM::Element>> const&> explicitly_set_attribute_elements) const
|
||||
{
|
||||
// 1. Let elements be an empty list.
|
||||
GC::RootVector<GC::Ref<DOM::Element>> elements(heap());
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ public:
|
|||
GC::Ptr<Attr> get_attribute_node_ns(Optional<FlyString> const& namespace_, FlyString const& name) const;
|
||||
|
||||
GC::Ptr<DOM::Element> get_the_attribute_associated_element(FlyString const& content_attribute, GC::Ptr<DOM::Element> explicitly_set_attribute_element) const;
|
||||
Optional<GC::RootVector<GC::Ref<DOM::Element>>> get_the_attribute_associated_elements(FlyString const& content_attribute, Optional<Vector<GC::Weak<DOM::Element>>> const& explicitly_set_attribute_elements) const;
|
||||
Optional<GC::RootVector<GC::Ref<DOM::Element>>> get_the_attribute_associated_elements(FlyString const& content_attribute, Optional<Vector<GC::Weak<DOM::Element>> const&> explicitly_set_attribute_elements) const;
|
||||
|
||||
DOMTokenList* class_list();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue