LibWeb: Rename "identifier" and "ValueID" to "Keyword" where correct

For a long time, we've used two terms, inconsistently:
- "Identifier" is a spec term, but refers to a sequence of alphanumeric
  characters, which may or may not be a keyword. (Keywords are a
  subset of all identifiers.)
- "ValueID" is entirely non-spec, and is directly called a "keyword" in
  the CSS specs.

So to avoid confusion as much as possible, let's align with the spec
terminology. I've attempted to change variable names as well, but
obviously we use Keywords in a lot of places in LibWeb and so I may
have missed some.

One exception is that I've not renamed "valid-identifiers" in
Properties.json... I'd like to combine that and the "valid-types" array
together eventually, so there's no benefit to doing an extra rename
now.
This commit is contained in:
Sam Atkins 2024-08-14 14:06:03 +01:00 committed by Sam Atkins
parent 9559f0f123
commit 6a74b01644
Notes: github-actions[bot] 2024-08-15 12:59:33 +00:00
48 changed files with 702 additions and 702 deletions

View file

@ -26,7 +26,7 @@ enum class Mode {
};
// https://html.spec.whatwg.org/multipage/rendering.html#rules-for-parsing-a-legacy-font-size
static Optional<CSS::ValueID> parse_legacy_font_size(StringView string)
static Optional<CSS::Keyword> parse_legacy_font_size(StringView string)
{
// 1. Let input be the attribute's value.
// 2. Let position be a pointer into input, initially pointing at the start of the string.
@ -81,19 +81,19 @@ static Optional<CSS::ValueID> parse_legacy_font_size(StringView string)
// 12. Set 'font-size' to the keyword corresponding to the value of value according to the following table:
switch (value) {
case 1:
return CSS::ValueID::XSmall;
return CSS::Keyword::XSmall;
case 2:
return CSS::ValueID::Small;
return CSS::Keyword::Small;
case 3:
return CSS::ValueID::Medium;
return CSS::Keyword::Medium;
case 4:
return CSS::ValueID::Large;
return CSS::Keyword::Large;
case 5:
return CSS::ValueID::XLarge;
return CSS::Keyword::XLarge;
case 6:
return CSS::ValueID::XxLarge;
return CSS::Keyword::XxLarge;
case 7:
return CSS::ValueID::XxxLarge;
return CSS::Keyword::XxxLarge;
default:
VERIFY_NOT_REACHED();
}
@ -124,7 +124,7 @@ void HTMLFontElement::apply_presentational_hints(CSS::StyleProperties& style) co
// When a font element has a size attribute, the user agent is expected to use the following steps, known as the rules for parsing a legacy font size, to treat the attribute as a presentational hint setting the element's 'font-size' property:
auto font_size_or_empty = parse_legacy_font_size(value);
if (font_size_or_empty.has_value()) {
auto font_size = string_from_value_id(font_size_or_empty.release_value());
auto font_size = string_from_keyword(font_size_or_empty.release_value());
if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, font_size, CSS::PropertyID::FontSize))
style.set_property(CSS::PropertyID::FontSize, parsed_value.release_nonnull());
}