mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 08:39:22 +00:00
LibWeb: Don't crash on CSS all: revert
Not every value in a StyleProperties will be non-null by the time we perform `revert`, so let's make a specialized function for reverting a property instead of using the path that requires the value to be non-null.
This commit is contained in:
parent
96c0cbf584
commit
a10610a1ca
Notes:
github-actions[bot]
2024-08-04 09:50:34 +00:00
Author: https://github.com/awesomekling
Commit: a10610a1ca
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/953
5 changed files with 19 additions and 7 deletions
1
Tests/LibWeb/Text/expected/css/revert-all.txt
Normal file
1
Tests/LibWeb/Text/expected/css/revert-all.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
PASS (didn't crash)
|
9
Tests/LibWeb/Text/input/css/revert-all.html
Normal file
9
Tests/LibWeb/Text/input/css/revert-all.html
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<style>
|
||||||
|
div { all: revert; }
|
||||||
|
</style>
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
println("PASS (didn't crash)");
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -859,13 +859,7 @@ void StyleComputer::set_all_properties(DOM::Element& element, Optional<CSS::Sele
|
||||||
auto property_id = (CSS::PropertyID)i;
|
auto property_id = (CSS::PropertyID)i;
|
||||||
|
|
||||||
if (value.is_revert()) {
|
if (value.is_revert()) {
|
||||||
style.set_property(
|
style.revert_property(property_id, style_for_revert);
|
||||||
property_id,
|
|
||||||
style_for_revert.property(property_id),
|
|
||||||
style_for_revert.is_property_inherited(property_id)
|
|
||||||
? StyleProperties::Inherited::Yes
|
|
||||||
: StyleProperties::Inherited::No,
|
|
||||||
important);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,13 @@ void StyleProperties::set_property(CSS::PropertyID id, NonnullRefPtr<StyleValue
|
||||||
set_property_inherited(id, inherited);
|
set_property_inherited(id, inherited);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StyleProperties::revert_property(CSS::PropertyID id, StyleProperties const& style_for_revert)
|
||||||
|
{
|
||||||
|
m_property_values[to_underlying(id)] = style_for_revert.m_property_values[to_underlying(id)];
|
||||||
|
set_property_important(id, style_for_revert.is_property_important(id) ? Important::Yes : Important::No);
|
||||||
|
set_property_inherited(id, style_for_revert.is_property_inherited(id) ? Inherited::Yes : Inherited::No);
|
||||||
|
}
|
||||||
|
|
||||||
void StyleProperties::set_animated_property(CSS::PropertyID id, NonnullRefPtr<StyleValue const> value)
|
void StyleProperties::set_animated_property(CSS::PropertyID id, NonnullRefPtr<StyleValue const> value)
|
||||||
{
|
{
|
||||||
m_animated_property_values.set(id, move(value));
|
m_animated_property_values.set(id, move(value));
|
||||||
|
|
|
@ -54,6 +54,7 @@ public:
|
||||||
void set_animated_property(CSS::PropertyID, NonnullRefPtr<StyleValue const> value);
|
void set_animated_property(CSS::PropertyID, NonnullRefPtr<StyleValue const> value);
|
||||||
NonnullRefPtr<StyleValue const> property(CSS::PropertyID) const;
|
NonnullRefPtr<StyleValue const> property(CSS::PropertyID) const;
|
||||||
RefPtr<StyleValue const> maybe_null_property(CSS::PropertyID) const;
|
RefPtr<StyleValue const> maybe_null_property(CSS::PropertyID) const;
|
||||||
|
void revert_property(CSS::PropertyID, StyleProperties const& style_for_revert);
|
||||||
|
|
||||||
JS::GCPtr<CSS::CSSStyleDeclaration const> animation_name_source() const { return m_animation_name_source; }
|
JS::GCPtr<CSS::CSSStyleDeclaration const> animation_name_source() const { return m_animation_name_source; }
|
||||||
void set_animation_name_source(JS::GCPtr<CSS::CSSStyleDeclaration const> declaration) { m_animation_name_source = declaration; }
|
void set_animation_name_source(JS::GCPtr<CSS::CSSStyleDeclaration const> declaration) { m_animation_name_source = declaration; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue