mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb: Parse grid track placements closer to spec
This brings parsing of grid-row-* and grid-column-* properties (and their associated shorthands) more inline with spec. Changes: - Only set omitted properties for combined-value shorthands (e.g. `grid-row: a` rather than `grid-row: a / b`) if the single value is `<custom-ident>`. - `[ [ <integer [-∞,-1]> | <integer [1,∞]> ] && <custom-ident>? ]`: - Properly resolve `calc`s for `<integer>` that rely on compute-time information. - `[ span && [ <integer [1,∞]> || <custom-ident> ] ]` - Allow `calc`s for `<integer>` - Allow `<custom-ident>` There is still work to be done to properly use these parsed values. Gains us 46 WPT tests.
This commit is contained in:
parent
a424a06d45
commit
36e2d25efa
Notes:
github-actions[bot]
2025-07-08 16:27:31 +00:00
Author: https://github.com/Calme1709
Commit: 36e2d25efa
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5346
Reviewed-by: https://github.com/tcl3 ✅
12 changed files with 153 additions and 171 deletions
|
@ -8,6 +8,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibWeb/CSS/CalculatedOr.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
@ -18,14 +19,14 @@ public:
|
|||
return GridTrackPlacement();
|
||||
}
|
||||
|
||||
static GridTrackPlacement make_line(Optional<int> line_number, Optional<String> name)
|
||||
static GridTrackPlacement make_line(Optional<IntegerOrCalculated> line_number, Optional<String> name)
|
||||
{
|
||||
return GridTrackPlacement(AreaOrLine { .line_number = line_number, .name = name });
|
||||
}
|
||||
|
||||
static GridTrackPlacement make_span(int value)
|
||||
static GridTrackPlacement make_span(IntegerOrCalculated value, Optional<String> name)
|
||||
{
|
||||
return GridTrackPlacement(Span { .value = value });
|
||||
return GridTrackPlacement(Span { .value = value, .name = name });
|
||||
}
|
||||
|
||||
bool is_auto() const { return m_value.has<Auto>(); }
|
||||
|
@ -35,6 +36,8 @@ public:
|
|||
bool is_auto_positioned() const { return is_auto() || is_span(); }
|
||||
bool is_positioned() const { return !is_auto_positioned(); }
|
||||
|
||||
bool is_custom_ident() const { return is_area_or_line() && !m_value.get<AreaOrLine>().line_number.has_value(); }
|
||||
|
||||
bool has_identifier() const
|
||||
{
|
||||
return is_area_or_line() && m_value.get<AreaOrLine>().name.has_value();
|
||||
|
@ -47,8 +50,8 @@ public:
|
|||
|
||||
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; }
|
||||
IntegerOrCalculated line_number() const { return *m_value.get<AreaOrLine>().line_number; }
|
||||
IntegerOrCalculated span() const { return m_value.get<Span>().value; }
|
||||
|
||||
String to_string() const;
|
||||
|
||||
|
@ -60,13 +63,14 @@ private:
|
|||
};
|
||||
|
||||
struct AreaOrLine {
|
||||
Optional<int> line_number;
|
||||
Optional<IntegerOrCalculated> line_number;
|
||||
Optional<String> name;
|
||||
bool operator==(AreaOrLine const& other) const = default;
|
||||
};
|
||||
|
||||
struct Span {
|
||||
int value;
|
||||
IntegerOrCalculated value;
|
||||
Optional<String> name;
|
||||
bool operator==(Span const& other) const = default;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue