mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWeb/CSS: Wrap calc()-resolution data in a struct
Initially I added this to the existing CalculationContext, but in reality, we have some data at parse-time and different data at resolve-time, so it made more sense to keep those separate. Instead of needing a variety of methods for resolving a Foo, depending on whether we have a Layout::Node available, or a percentage basis, or a length resolution context... put those in a CalculationResolutionContext, and just pass that one thing to these methods. This also removes the need for separate resolve_*_percentage() methods, because we can just pass the percentage basis in to the regular resolve_foo() method. This also corrects the issue that *any* calculation may need to resolve lengths, but we previously only passed a length resolution context to specific types in some situations. Now, they can all have one available, though it's up to the caller to provide it.
This commit is contained in:
parent
ad9d9bb684
commit
1d71662f31
Notes:
github-actions[bot]
2025-01-30 18:33:58 +00:00
Author: https://github.com/AtkinsSJ
Commit: 1d71662f31
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3383
18 changed files with 256 additions and 309 deletions
|
@ -1963,11 +1963,10 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
|
|||
} else if (font_size.is_length()) {
|
||||
maybe_length = font_size.as_length().length();
|
||||
} else if (font_size.is_calculated()) {
|
||||
if (font_size.as_calculated().contains_percentage()) {
|
||||
maybe_length = font_size.as_calculated().resolve_length_percentage(length_resolution_context, Length::make_px(parent_font_size()));
|
||||
} else {
|
||||
maybe_length = font_size.as_calculated().resolve_length(length_resolution_context);
|
||||
}
|
||||
maybe_length = font_size.as_calculated().resolve_length({
|
||||
.percentage_basis = Length::make_px(parent_font_size()),
|
||||
.length_resolution_context = length_resolution_context,
|
||||
});
|
||||
}
|
||||
if (maybe_length.has_value()) {
|
||||
font_size_in_px = maybe_length.value().to_px(length_resolution_context);
|
||||
|
@ -3034,7 +3033,7 @@ void StyleComputer::compute_math_depth(ComputedProperties& style, DOM::Element c
|
|||
if (integer_value.is_integer())
|
||||
return integer_value.as_integer().integer();
|
||||
if (integer_value.is_calculated())
|
||||
return integer_value.as_calculated().resolve_integer().value();
|
||||
return integer_value.as_calculated().resolve_integer({}).value();
|
||||
VERIFY_NOT_REACHED();
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue