mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibWeb/CSS: Parse @page bleed, marks, page-orientation
descriptors
These don't have WPT tests so I've added some myself.
This commit is contained in:
parent
9415bffd9b
commit
3a235e9050
Notes:
github-actions[bot]
2025-05-15 08:54:25 +00:00
Author: https://github.com/AtkinsSJ
Commit: 3a235e9050
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4735
10 changed files with 190 additions and 1 deletions
|
@ -118,8 +118,10 @@ RefPtr<CSSStyleValue const> descriptor_initial_value(AtRuleID, DescriptorID);
|
|||
struct DescriptorMetadata {
|
||||
enum class ValueType {
|
||||
// FIXME: Parse the grammar instead of hard-coding all the options!
|
||||
CropOrCross,
|
||||
FamilyName,
|
||||
FontSrcList,
|
||||
Length,
|
||||
OptionalDeclarationValue,
|
||||
PageSize,
|
||||
PositivePercentage,
|
||||
|
@ -387,6 +389,8 @@ DescriptorMetadata get_descriptor_metadata(AtRuleID at_rule_id, DescriptorID des
|
|||
return "FontSrcList"_string;
|
||||
if (syntax_string == "<declaration-value>?"sv)
|
||||
return "OptionalDeclarationValue"_string;
|
||||
if (syntax_string == "<length>"sv)
|
||||
return "Length"_string;
|
||||
if (syntax_string == "<page-size>"sv)
|
||||
return "PageSize"_string;
|
||||
if (syntax_string == "<percentage [0,∞]>"sv)
|
||||
|
@ -395,13 +399,18 @@ DescriptorMetadata get_descriptor_metadata(AtRuleID at_rule_id, DescriptorID des
|
|||
return "String"_string;
|
||||
if (syntax_string == "<unicode-range-token>#"sv)
|
||||
return "UnicodeRangeTokens"_string;
|
||||
dbgln("Unrecognized value type: `{}`", syntax_string);
|
||||
VERIFY_NOT_REACHED();
|
||||
}();
|
||||
option_generator.set("value_type"sv, value_type);
|
||||
option_generator.append(R"~~~(
|
||||
metadata.syntax.empend(DescriptorMetadata::ValueType::@value_type@);
|
||||
)~~~");
|
||||
|
||||
} else if (syntax_string == "crop || cross"sv) {
|
||||
// FIXME: This is extra hacky.
|
||||
option_generator.append(R"~~~(
|
||||
metadata.syntax.empend(DescriptorMetadata::ValueType::CropOrCross);
|
||||
)~~~");
|
||||
} else {
|
||||
// Keyword
|
||||
option_generator.set("keyword:titlecase"sv, title_casify(syntax_string));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue