mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb/CSS: Absolutize grid-related StyleValues
This commit is contained in:
parent
597fe8288c
commit
7de17dce9d
Notes:
github-actions[bot]
2025-11-19 23:47:02 +00:00
Author: https://github.com/AtkinsSJ
Commit: 7de17dce9d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6857
Reviewed-by: https://github.com/tcl3 ✅
12 changed files with 161 additions and 26 deletions
|
|
@ -1,12 +1,14 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
* Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com>
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "GridTrackPlacement.h"
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
|
@ -38,4 +40,34 @@ String GridTrackPlacement::to_string(SerializationMode mode) const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
GridTrackPlacement GridTrackPlacement::absolutized(ComputationContext const& context) const
|
||||
{
|
||||
auto absolutize_integer_or_calculated = [&context](IntegerOrCalculated const& integer_or_calculated) {
|
||||
if (!integer_or_calculated.is_calculated())
|
||||
return integer_or_calculated;
|
||||
auto absolutized = integer_or_calculated.calculated()->absolutized(context);
|
||||
if (absolutized->is_calculated())
|
||||
return IntegerOrCalculated { absolutized->as_calculated() };
|
||||
VERIFY(absolutized->is_integer());
|
||||
return IntegerOrCalculated { absolutized->as_integer().integer() };
|
||||
};
|
||||
|
||||
return m_value.visit(
|
||||
[this](Auto const&) {
|
||||
return *this;
|
||||
},
|
||||
[&](AreaOrLine const& area_or_line) -> GridTrackPlacement {
|
||||
return AreaOrLine {
|
||||
.line_number = area_or_line.line_number.map(absolutize_integer_or_calculated),
|
||||
.name = area_or_line.name,
|
||||
};
|
||||
},
|
||||
[&](Span const& span) -> GridTrackPlacement {
|
||||
return Span {
|
||||
.value = absolutize_integer_or_calculated(span.value),
|
||||
.name = span.name,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue