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
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

@ -10,36 +10,36 @@
#pragma once
#include <LibWeb/CSS/CSSStyleValue.h>
#include <LibWeb/CSS/ValueID.h>
#include <LibWeb/CSS/Keyword.h>
namespace Web::CSS {
// https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue
class CSSKeywordValue final : public StyleValueWithDefaultOperators<CSSKeywordValue> {
public:
static ValueComparingNonnullRefPtr<CSSKeywordValue> create(ValueID id)
static ValueComparingNonnullRefPtr<CSSKeywordValue> create(Keyword keyword)
{
return adopt_ref(*new (nothrow) CSSKeywordValue(id));
return adopt_ref(*new (nothrow) CSSKeywordValue(keyword));
}
virtual ~CSSKeywordValue() override = default;
ValueID id() const { return m_id; }
Keyword keyword() const { return m_keyword; }
static bool is_color(ValueID);
static bool is_color(Keyword);
virtual bool has_color() const override;
virtual Color to_color(Optional<Layout::NodeWithStyle const&> node) const override;
virtual String to_string() const override;
bool properties_equal(CSSKeywordValue const& other) const { return m_id == other.m_id; }
bool properties_equal(CSSKeywordValue const& other) const { return m_keyword == other.m_keyword; }
private:
explicit CSSKeywordValue(ValueID id)
explicit CSSKeywordValue(Keyword keyword)
: StyleValueWithDefaultOperators(Type::Keyword)
, m_id(id)
, m_keyword(keyword)
{
}
ValueID m_id { ValueID::Invalid };
Keyword m_keyword { Keyword::Invalid };
};
}