mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:37:46 +00:00
LibWeb+Base: Re-implement grid track span
Implement span correctly when indicated in the grid-column-start, grid-row-start, etc. CSS properties. Previously it had been implemented as if span was something that went alongside the position property, but actually it seems like if you do 'span 3' in the grid-column-start property, for example, this means it literally spans 3 blocks, and the 3 has nothing to do with position.
This commit is contained in:
parent
86ce1b64f0
commit
236795e931
5 changed files with 224 additions and 117 deletions
|
@ -12,38 +12,34 @@ namespace Web::CSS {
|
|||
|
||||
class GridTrackPlacement {
|
||||
public:
|
||||
GridTrackPlacement(int, bool);
|
||||
GridTrackPlacement(int);
|
||||
enum class Type {
|
||||
Span,
|
||||
Position,
|
||||
Auto
|
||||
};
|
||||
|
||||
GridTrackPlacement(int, bool = false);
|
||||
GridTrackPlacement();
|
||||
|
||||
static GridTrackPlacement make_auto() { return GridTrackPlacement(); };
|
||||
|
||||
void set_position(int position)
|
||||
{
|
||||
m_is_auto = false;
|
||||
m_position = position;
|
||||
}
|
||||
int position() const { return m_position; }
|
||||
bool is_span() const { return m_type == Type::Span; }
|
||||
bool is_position() const { return m_type == Type::Position; }
|
||||
bool is_auto() const { return m_type == Type::Auto; }
|
||||
bool is_auto_positioned() const { return m_type == Type::Auto || m_type == Type::Span; }
|
||||
|
||||
void set_has_span(bool has_span)
|
||||
{
|
||||
VERIFY(!m_is_auto);
|
||||
m_has_span = has_span;
|
||||
}
|
||||
bool has_span() const { return m_has_span; }
|
||||
|
||||
bool is_auto() const { return m_is_auto; }
|
||||
int raw_value() const { return m_value; }
|
||||
Type type() const { return m_type; }
|
||||
|
||||
String to_string() const;
|
||||
bool operator==(GridTrackPlacement const& other) const
|
||||
{
|
||||
return m_position == other.position() && m_has_span == other.has_span();
|
||||
return m_type == other.type() && m_value == other.raw_value();
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_is_auto { false };
|
||||
int m_position { 0 };
|
||||
bool m_has_span { false };
|
||||
Type m_type;
|
||||
int m_value { 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue