1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:28:11 +00:00

LibWeb: Bring Selector terminology in line with the CSS spec

- CompoundSelector -> *deleted*
- ComplexSelector -> CompoundSelector
- Relation -> Combinator

Our Selector is really a ComplexSelector, but only the Parser and
SelectorEngine need to know that, so keeping it named Selector makes it
more understandable for users.

Our CompoundSelector is really a CompoundSelectorAndCombinator.
Combining the two makes sense in our codebase, but the accurate name is
so long that I think it makes the code less readable.

Renamed some Combinators to also match the spec terminology:

- AdjacentSibling -> NextSibling
- GeneralSibling -> SubsequentSibling

The previous names are somewhat ambiguous, so hopefully this is clearer.
This commit is contained in:
Sam Atkins 2021-07-23 15:24:33 +01:00 committed by Andreas Kling
parent ca436afeb5
commit 6ea5d03f43
6 changed files with 67 additions and 63 deletions

View file

@ -11,8 +11,8 @@
namespace Web::CSS {
Selector::Selector(Vector<ComplexSelector>&& component_lists)
: m_complex_selectors(move(component_lists))
Selector::Selector(Vector<CompoundSelector>&& compound_selectors)
: m_compound_selectors(move(compound_selectors))
{
}
@ -26,8 +26,8 @@ u32 Selector::specificity() const
unsigned tag_names = 0;
unsigned classes = 0;
for (auto& list : m_complex_selectors) {
for (auto& simple_selector : list.compound_selector) {
for (auto& list : m_compound_selectors) {
for (auto& simple_selector : list.simple_selectors) {
switch (simple_selector.type) {
case SimpleSelector::Type::Id:
++ids;