mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-19 08:51:57 +00:00
LibWeb/CSS: Parse and propagate font-variation-settings property
This commit is contained in:
parent
1a127c9d37
commit
55812aaed2
Notes:
github-actions[bot]
2024-10-02 15:37:43 +00:00
Author: https://github.com/AtkinsSJ
Commit: 55812aaed2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1599
8 changed files with 102 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2024, Andreas Kling <andreas@ladybird.org>
|
||||
* Copyright (c) 2021-2024, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -23,6 +23,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/PercentageStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PositionStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/RectStyleValue.h>
|
||||
|
@ -1027,6 +1028,33 @@ Optional<FlyString> StyleProperties::font_language_override() const
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<HashMap<FlyString, NumberOrCalculated>> StyleProperties::font_variation_settings() const
|
||||
{
|
||||
auto value = property(CSS::PropertyID::FontVariationSettings);
|
||||
|
||||
if (value->is_keyword())
|
||||
return {}; // normal
|
||||
|
||||
if (value->is_value_list()) {
|
||||
auto const& axis_tags = value->as_value_list().values();
|
||||
HashMap<FlyString, NumberOrCalculated> result;
|
||||
result.ensure_capacity(axis_tags.size());
|
||||
for (auto const& tag_value : axis_tags) {
|
||||
auto const& axis_tag = tag_value->as_open_type_tagged();
|
||||
|
||||
if (axis_tag.value()->is_number()) {
|
||||
result.set(axis_tag.tag(), axis_tag.value()->as_number().value());
|
||||
} else {
|
||||
VERIFY(axis_tag.value()->is_math());
|
||||
result.set(axis_tag.tag(), NumberOrCalculated { axis_tag.value()->as_math() });
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
CSS::GridTrackSizeList StyleProperties::grid_auto_columns() const
|
||||
{
|
||||
auto value = property(CSS::PropertyID::GridAutoColumns);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue