mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 16:58:58 +00:00
LibWeb: Handle nested shorthands in all-same-CSS-wide-keyword to_string
Previously we only checked direct sub-properties, not accounting for the nested case.
This commit is contained in:
parent
e1d2582680
commit
335190e925
Notes:
github-actions[bot]
2025-06-16 11:39:18 +00:00
Author: https://github.com/Calme1709
Commit: 335190e925
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5066
Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 26 additions and 8 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "ShorthandStyleValue.h"
|
||||
#include <LibGfx/Font/FontWeight.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
#include <LibWeb/CSS/StyleComputer.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GridTemplateAreaStyleValue.h>
|
||||
|
@ -43,23 +44,25 @@ String ShorthandStyleValue::to_string(SerializationMode mode) const
|
|||
// If all the longhands are the same CSS-wide keyword, just return that once.
|
||||
Optional<Keyword> built_in_keyword;
|
||||
bool all_same_keyword = true;
|
||||
for (auto& value : m_properties.values) {
|
||||
if (!value->is_css_wide_keyword()) {
|
||||
StyleComputer::for_each_property_expanding_shorthands(m_properties.shorthand_property, *this, [&](PropertyID name, CSSStyleValue const& value) {
|
||||
(void)name;
|
||||
if (!value.is_css_wide_keyword()) {
|
||||
all_same_keyword = false;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
auto keyword = value->to_keyword();
|
||||
auto keyword = value.to_keyword();
|
||||
if (!built_in_keyword.has_value()) {
|
||||
built_in_keyword = keyword;
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
if (built_in_keyword != keyword) {
|
||||
all_same_keyword = false;
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (all_same_keyword && built_in_keyword.has_value())
|
||||
return m_properties.values.first()->to_string(mode);
|
||||
return MUST(String::from_utf8(string_from_keyword(built_in_keyword.value())));
|
||||
|
||||
auto default_to_string = [&]() {
|
||||
auto all_properties_same_value = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue