mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-16 13:09:41 +00:00
LibWeb/CSS: Allow setting StyleValues on CSSStyleProperties directly
This is used by StylePropertyMap - we already have verified that the value is acceptable for the property before this point.
This commit is contained in:
parent
2de4fe8104
commit
7778f3b279
Notes:
github-actions[bot]
2025-10-04 20:58:25 +00:00
Author: https://github.com/AtkinsSJ
Commit: 7778f3b279
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6370
3 changed files with 32 additions and 0 deletions
|
@ -402,6 +402,35 @@ RefPtr<StyleValue const> CSSStyleProperties::get_property_style_value(PropertyID
|
|||
return get_property_style_value(PropertyNameAndID::from_id(property_id));
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> CSSStyleProperties::set_property_style_value(PropertyNameAndID const& property, NonnullRefPtr<StyleValue const> style_value)
|
||||
{
|
||||
if (is_computed()) {
|
||||
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot modify properties in result of getComputedStyle()"_utf16);
|
||||
}
|
||||
|
||||
if (property.is_custom_property()) {
|
||||
m_custom_properties.remove(property.name());
|
||||
m_custom_properties.set(property.name(),
|
||||
StyleProperty {
|
||||
Important::No,
|
||||
PropertyID::Custom,
|
||||
style_value,
|
||||
property.name() });
|
||||
return {};
|
||||
}
|
||||
|
||||
m_properties.remove_first_matching([&property](StyleProperty const& style_property) {
|
||||
return style_property.property_id == property.id();
|
||||
});
|
||||
m_properties.append(StyleProperty {
|
||||
.important = Important::No,
|
||||
.property_id = property.id(),
|
||||
.value = move(style_value),
|
||||
});
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertyvalue
|
||||
Optional<StyleProperty> CSSStyleProperties::get_property_internal(PropertyNameAndID const& property) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue