mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 07:41:01 +00:00
LibWeb: Handle special cases of PseudoElement::Type correctly
There are some special values for CSS::Selector::PseudoElement::Type which are after `KnownPseudoElementCount` and therefore not present in various arrays of pseudo elements, this leads to some errors, if a type after `KnownPseudoElementCount` is used without checking first. This adds explicit checks to all usages
This commit is contained in:
parent
8620a2af47
commit
d21bfda900
Notes:
github-actions[bot]
2024-12-19 19:37:02 +00:00
Author: https://github.com/Totto16
Commit: d21bfda900
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2908
Reviewed-by: https://github.com/AtkinsSJ ✅
4 changed files with 59 additions and 7 deletions
|
@ -187,14 +187,21 @@ void Animatable::visit_edges(JS::Cell::Visitor& visitor)
|
|||
|
||||
GC::Ptr<CSS::CSSStyleDeclaration const> Animatable::cached_animation_name_source(Optional<CSS::Selector::PseudoElement::Type> pseudo_element) const
|
||||
{
|
||||
if (pseudo_element.has_value())
|
||||
if (pseudo_element.has_value()) {
|
||||
if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element.value())) {
|
||||
return {};
|
||||
}
|
||||
return m_cached_animation_name_source[to_underlying(pseudo_element.value()) + 1];
|
||||
}
|
||||
return m_cached_animation_name_source[0];
|
||||
}
|
||||
|
||||
void Animatable::set_cached_animation_name_source(GC::Ptr<CSS::CSSStyleDeclaration const> value, Optional<CSS::Selector::PseudoElement::Type> pseudo_element)
|
||||
{
|
||||
if (pseudo_element.has_value()) {
|
||||
if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element.value())) {
|
||||
return;
|
||||
}
|
||||
m_cached_animation_name_source[to_underlying(pseudo_element.value()) + 1] = value;
|
||||
} else {
|
||||
m_cached_animation_name_source[0] = value;
|
||||
|
@ -203,18 +210,27 @@ void Animatable::set_cached_animation_name_source(GC::Ptr<CSS::CSSStyleDeclarati
|
|||
|
||||
GC::Ptr<Animations::Animation> Animatable::cached_animation_name_animation(Optional<CSS::Selector::PseudoElement::Type> pseudo_element) const
|
||||
{
|
||||
if (pseudo_element.has_value())
|
||||
if (pseudo_element.has_value()) {
|
||||
if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element.value())) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return m_cached_animation_name_animation[to_underlying(pseudo_element.value()) + 1];
|
||||
}
|
||||
return m_cached_animation_name_animation[0];
|
||||
}
|
||||
|
||||
void Animatable::set_cached_animation_name_animation(GC::Ptr<Animations::Animation> value, Optional<CSS::Selector::PseudoElement::Type> pseudo_element)
|
||||
{
|
||||
|
||||
if (pseudo_element.has_value()) {
|
||||
if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element.value())) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_cached_animation_name_animation[to_underlying(pseudo_element.value()) + 1] = value;
|
||||
} else {
|
||||
m_cached_animation_name_animation[0] = value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue