Repository: LadybirdBrowser/ladybird
File: Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp (C++)

Code before:
        }

        if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl)) {
            if (used_direction == Direction::Ltr)
                return PropertyID::@top-right:titlecase@;
            return PropertyID::@bottom-right:titlecase@;
        }

        if (mapping_context.writing_mode == WritingMode::VerticalLr) {
            if (used_direction == Direction::Ltr)
                return PropertyID::@top-left:titlecase@;
            return PropertyID::@bottom-left:titlecase@;
        }
        if (used_direction == Direction::Ltr)
            return PropertyID::@bottom-left:titlecase@;
        return PropertyID::@top-left:titlecase@;
)~~~");
            } else if (mapping == "overflow-block"sv) {
                property_generator.set("x:titlecase", mapped_property("x"sv));
                property_generator.set("y:titlecase", mapped_property("y"sv));
                property_generator.append(R"~~~(
        if (mapping_context.writing_mode == WritingMode::HorizontalTb)
            return PropertyID::@y:titlecase@;
        return PropertyID::@x:titlecase@;
)~~~");
            } else if (mapping == "overflow-inline"sv) {
                property_generator.set("x:titlecase", mapped_property("x"sv));
                property_generator.set("y:titlecase", mapped_property("y"sv));
                property_generator.append(R"~~~(
        if (mapping_context.writing_mode == WritingMode::HorizontalTb)
            return PropertyID::@x:titlecase@;
        return PropertyID::@y:titlecase@;
)~~~");
            } else {
                dbgln("Logical alias '{}' has unrecognized mapping '{}'", property_name, mapping.value());
                VERIFY_NOT_REACHED();
            }
        }
    });

    generator.append(R"~~~(
    default:
        VERIFY(!property_is_logical_alias(property_id));
        return property_id;
    }
}
)~~~");

    generator.append(R"~~~(
Optional<LogicalPropertyGroup> logical_property_group_for_property(PropertyID property_id)
{

Review comment (bug):
If this could have a non-property-specific name, I'd prefer that. eg, `inline-xy` or something. Then it's clearer how other properties would use the same thing. (eg, I can see there are `overflow-behavior-x` and `overflow-behaviour-block` etc. which would use the same mapping.)

It's confusing because a few of these mapping names *are* property names, just because that happened to be the most descriptive to what the mapping is. :sweat_smile: 

Code after:
        }

        if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl)) {
            if (used_direction == Direction::Ltr)
                return PropertyID::@top-right:titlecase@;
            return PropertyID::@bottom-right:titlecase@;
        }

        if (mapping_context.writing_mode == WritingMode::VerticalLr) {
            if (used_direction == Direction::Ltr)
                return PropertyID::@top-left:titlecase@;
            return PropertyID::@bottom-left:titlecase@;
        }
        if (used_direction == Direction::Ltr)
            return PropertyID::@bottom-left:titlecase@;
        return PropertyID::@top-left:titlecase@;
)~~~");
            } else if (mapping == "block-xy"sv) {
                property_generator.set("x:titlecase", mapped_property("x"sv));
                property_generator.set("y:titlecase", mapped_property("y"sv));
                property_generator.append(R"~~~(
        if (mapping_context.writing_mode == WritingMode::HorizontalTb)
            return PropertyID::@y:titlecase@;
        return PropertyID::@x:titlecase@;
)~~~");
            } else if (mapping == "inline-xy"sv) {
                property_generator.set("x:titlecase", mapped_property("x"sv));
                property_generator.set("y:titlecase", mapped_property("y"sv));
                property_generator.append(R"~~~(
        if (mapping_context.writing_mode == WritingMode::HorizontalTb)
            return PropertyID::@x:titlecase@;
        return PropertyID::@y:titlecase@;
)~~~");
            } else {
                dbgln("Logical alias '{}' has unrecognized mapping '{}'", property_name, mapping.value());
                VERIFY_NOT_REACHED();
            }
        }
    });

    generator.append(R"~~~(
    default:
        VERIFY(!property_is_logical_alias(property_id));
        return property_id;
    }
}
)~~~");

    generator.append(R"~~~(
Optional<LogicalPropertyGroup> logical_property_group_for_property(PropertyID property_id)
{