mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:07:35 +00:00
LibWeb: Fix grid line name placement when repeat() is used
Before this change, parsed grid-template-columns/grid-template-rows were represented as two lists: line names and track sizes. The problem with this approach is that it erases the relationship between tracks and their names, which results in unnecessarily complicated code that restores this data (incorrectly if repeat() is involved) during layout. This change solves that by representing line definitions as a list of sizes and names in the order they were defined. Visual progression https://genius.com/
This commit is contained in:
parent
c4d75ac11a
commit
cfcc459140
7 changed files with 168 additions and 104 deletions
|
@ -84,25 +84,28 @@ private:
|
|||
GridSize m_max_grid_size;
|
||||
};
|
||||
|
||||
struct GridLineNames {
|
||||
Vector<String> names;
|
||||
|
||||
String to_string() const;
|
||||
bool operator==(GridLineNames const& other) const { return names == other.names; }
|
||||
};
|
||||
|
||||
class GridTrackSizeList {
|
||||
public:
|
||||
GridTrackSizeList(Vector<CSS::ExplicitGridTrack> track_list, Vector<Vector<String>> line_names);
|
||||
GridTrackSizeList(Vector<Variant<ExplicitGridTrack, GridLineNames>>&& list);
|
||||
GridTrackSizeList();
|
||||
|
||||
static GridTrackSizeList make_none();
|
||||
|
||||
Vector<CSS::ExplicitGridTrack> track_list() const { return m_track_list; }
|
||||
Vector<Vector<String>> line_names() const { return m_line_names; }
|
||||
Vector<CSS::ExplicitGridTrack> track_list() const;
|
||||
Vector<Variant<ExplicitGridTrack, GridLineNames>> list() const { return m_list; }
|
||||
|
||||
String to_string() const;
|
||||
bool operator==(GridTrackSizeList const& other) const
|
||||
{
|
||||
return m_line_names == other.line_names() && m_track_list == other.track_list();
|
||||
}
|
||||
bool operator==(GridTrackSizeList const& other) const;
|
||||
|
||||
private:
|
||||
Vector<CSS::ExplicitGridTrack> m_track_list;
|
||||
Vector<Vector<String>> m_line_names;
|
||||
Vector<Variant<ExplicitGridTrack, GridLineNames>> m_list;
|
||||
};
|
||||
|
||||
class GridRepeat {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue