mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-17 05:29:56 +00:00
LibWeb: Don't deduplicate font-variation-settings
values at parse time
We now only deduplicate and sort the computed value of the `font-variation-settings` property.
This commit is contained in:
parent
6cb0f0fbcd
commit
83ad5ce8a2
Notes:
github-actions[bot]
2025-09-26 10:22:16 +00:00
Author: https://github.com/tcl3
Commit: 83ad5ce8a2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6245
Reviewed-by: https://github.com/AtkinsSJ ✅
4 changed files with 38 additions and 20 deletions
|
@ -62,6 +62,7 @@
|
|||
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/OpenTypeTaggedStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PendingSubstitutionStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PositionStyleValue.h>
|
||||
|
@ -3211,6 +3212,8 @@ NonnullRefPtr<StyleValue const> StyleComputer::compute_value_of_property(Propert
|
|||
return compute_border_or_outline_width(specified_value, get_property_specified_value(PropertyID::BorderTopStyle), computation_context);
|
||||
case PropertyID::OutlineWidth:
|
||||
return compute_border_or_outline_width(specified_value, get_property_specified_value(PropertyID::OutlineStyle), computation_context);
|
||||
case PropertyID::FontVariationSettings:
|
||||
return compute_font_variation_settings(specified_value);
|
||||
case PropertyID::LetterSpacing:
|
||||
case PropertyID::WordSpacing:
|
||||
if (specified_value->to_keyword() == Keyword::Normal)
|
||||
|
@ -3257,6 +3260,35 @@ NonnullRefPtr<StyleValue const> StyleComputer::compute_animation_name(NonnullRef
|
|||
});
|
||||
}
|
||||
|
||||
NonnullRefPtr<StyleValue const> StyleComputer::compute_font_variation_settings(NonnullRefPtr<StyleValue const> const& specified_value)
|
||||
{
|
||||
if (specified_value->is_keyword())
|
||||
return specified_value;
|
||||
|
||||
// https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def
|
||||
// If the same axis name appears more than once, the value associated with the last appearance supersedes any
|
||||
// previous value for that axis. This deduplication is observable by accessing the computed value of this property."
|
||||
// So, we deduplicate them here using a HashSet.
|
||||
auto const& value_list = specified_value->as_value_list();
|
||||
OrderedHashMap<FlyString, NonnullRefPtr<OpenTypeTaggedStyleValue const>> axis_tags_map;
|
||||
for (size_t i = 0; i < value_list.values().size(); i++) {
|
||||
auto const& axis_tag = value_list.values().at(i)->as_open_type_tagged();
|
||||
axis_tags_map.set(axis_tag.tag(), axis_tag);
|
||||
}
|
||||
|
||||
StyleValueVector axis_tags;
|
||||
|
||||
// The computed value contains the de-duplicated axis names, sorted in ascending order by code unit.
|
||||
for (auto const& [key, axis_tag] : axis_tags_map)
|
||||
axis_tags.append(axis_tag);
|
||||
|
||||
quick_sort(axis_tags, [](auto& a, auto& b) {
|
||||
return a->as_open_type_tagged().tag() < b->as_open_type_tagged().tag();
|
||||
});
|
||||
|
||||
return StyleValueList::create(move(axis_tags), StyleValueList::Separator::Comma);
|
||||
}
|
||||
|
||||
NonnullRefPtr<StyleValue const> StyleComputer::compute_border_or_outline_width(NonnullRefPtr<StyleValue const> const& specified_value, NonnullRefPtr<StyleValue const> const& style_specified_value, PropertyValueComputationContext const& computation_context)
|
||||
{
|
||||
// https://drafts.csswg.org/css-backgrounds/#border-width
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue