mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-15 14:51:52 +00:00
LibWeb/CSS: Serialize font-variant property closer to spec
It also needs special handling when reading it from CSSStyleDeclaration.
This commit is contained in:
parent
8236022152
commit
62c18d1dec
Notes:
github-actions[bot]
2025-02-12 16:01:55 +00:00
Author: https://github.com/AtkinsSJ
Commit: 62c18d1dec
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3482
Reviewed-by: https://github.com/jdahlin
4 changed files with 65 additions and 97 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/StyleComputer.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
|
||||
|
@ -343,6 +344,40 @@ Optional<StyleProperty> CSSStyleDeclaration::get_property_internal(PropertyID pr
|
|||
auto left = get_property_internal(PropertyID::BorderLeftWidth);
|
||||
return style_property_for_sided_shorthand(property_id, top, right, bottom, left);
|
||||
}
|
||||
case PropertyID::FontVariant: {
|
||||
auto ligatures = get_property_internal(PropertyID::FontVariantLigatures);
|
||||
auto caps = get_property_internal(PropertyID::FontVariantCaps);
|
||||
auto alternates = get_property_internal(PropertyID::FontVariantAlternates);
|
||||
auto numeric = get_property_internal(PropertyID::FontVariantNumeric);
|
||||
auto east_asian = get_property_internal(PropertyID::FontVariantEastAsian);
|
||||
auto position = get_property_internal(PropertyID::FontVariantPosition);
|
||||
auto emoji = get_property_internal(PropertyID::FontVariantEmoji);
|
||||
|
||||
if (!ligatures.has_value() || !caps.has_value() || !alternates.has_value() || !numeric.has_value() || !east_asian.has_value() || !position.has_value() || !emoji.has_value())
|
||||
return {};
|
||||
|
||||
if (ligatures->important != caps->important || ligatures->important != alternates->important || ligatures->important != numeric->important || ligatures->important != east_asian->important || ligatures->important != position->important || ligatures->important != emoji->important)
|
||||
return {};
|
||||
|
||||
// If ligatures is `none` and any other value isn't `normal`, that's invalid.
|
||||
if (ligatures->value->to_keyword() == Keyword::None
|
||||
&& (caps->value->to_keyword() != Keyword::Normal
|
||||
|| alternates->value->to_keyword() != Keyword::Normal
|
||||
|| numeric->value->to_keyword() != Keyword::Normal
|
||||
|| east_asian->value->to_keyword() != Keyword::Normal
|
||||
|| position->value->to_keyword() != Keyword::Normal
|
||||
|| emoji->value->to_keyword() != Keyword::Normal)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return StyleProperty {
|
||||
.important = ligatures->important,
|
||||
.property_id = property_id,
|
||||
.value = ShorthandStyleValue::create(property_id,
|
||||
{ PropertyID::FontVariantLigatures, PropertyID::FontVariantCaps, PropertyID::FontVariantAlternates, PropertyID::FontVariantNumeric, PropertyID::FontVariantEastAsian, PropertyID::FontVariantPosition, PropertyID::FontVariantEmoji },
|
||||
{ ligatures->value, caps->value, alternates->value, numeric->value, east_asian->value, position->value, emoji->value })
|
||||
};
|
||||
}
|
||||
case PropertyID::Margin: {
|
||||
auto top = get_property_internal(PropertyID::MarginTop);
|
||||
auto right = get_property_internal(PropertyID::MarginRight);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue