1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:17:44 +00:00

LibWeb: Define if identifier represent area or line during layout [GFC]

This fixes regression introduced in
c03e025a32 by assuming that it is
possible to determine whether identifier stands for line or area
during parsing.
This commit is contained in:
Aliaksandr Kalenik 2023-08-27 16:27:35 +02:00 committed by Andreas Kling
parent 5d7e73adfe
commit b66f65dc9e
10 changed files with 104 additions and 145 deletions

View file

@ -18,14 +18,9 @@ public:
return GridTrackPlacement();
}
static GridTrackPlacement make_area(String name)
static GridTrackPlacement make_line(Optional<int> line_number, Optional<String> name)
{
return GridTrackPlacement(Area { .name = name });
}
static GridTrackPlacement make_line(int value, Optional<String> name)
{
return GridTrackPlacement(Line { .value = value, .name = name });
return GridTrackPlacement(AreaOrLine { .line_number = line_number, .name = name });
}
static GridTrackPlacement make_span(int value)
@ -34,21 +29,25 @@ public:
}
bool is_auto() const { return m_value.has<Auto>(); }
bool is_area() const { return m_value.has<Area>(); }
bool is_line() const { return m_value.has<Line>(); }
bool is_span() const { return m_value.has<Span>(); }
bool is_area_or_line() const { return m_value.has<AreaOrLine>(); }
bool is_auto_positioned() const { return is_auto() || is_span(); }
bool is_positioned() const { return !is_auto_positioned(); }
bool has_line_name() const
bool has_identifier() const
{
return is_line() && m_value.get<Line>().name.has_value();
return is_area_or_line() && m_value.get<AreaOrLine>().name.has_value();
}
String area_name() const { return m_value.get<Area>().name; }
String line_name() const { return m_value.get<Line>().name.value(); }
int line_number() const { return m_value.get<Line>().value; }
bool has_line_number() const
{
return is_area_or_line() && m_value.get<AreaOrLine>().line_number.has_value();
}
String identifier() const { return *m_value.get<AreaOrLine>().name; }
int line_number() const { return *m_value.get<AreaOrLine>().line_number; }
int span() const { return m_value.get<Span>().value; }
String to_string() const;
@ -60,15 +59,10 @@ private:
bool operator==(Auto const&) const = default;
};
struct Area {
String name;
bool operator==(Area const& other) const = default;
};
struct Line {
int value;
struct AreaOrLine {
Optional<int> line_number;
Optional<String> name;
bool operator==(Line const& other) const = default;
bool operator==(AreaOrLine const& other) const = default;
};
struct Span {
@ -78,14 +72,12 @@ private:
GridTrackPlacement()
: m_value(Auto {}) {};
GridTrackPlacement(Area value)
: m_value(value) {};
GridTrackPlacement(Line value)
GridTrackPlacement(AreaOrLine value)
: m_value(value) {};
GridTrackPlacement(Span value)
: m_value(value) {};
Variant<Auto, Area, Line, Span> m_value;
Variant<Auto, AreaOrLine, Span> m_value;
};
}