mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Make division of CSSPixels
by integers create a fraction
This also adds some additional operators to `CSSPixelsFraction` to allow this change to build, since some places were using equations like `(a / b) + (c / d)` or `-(x / y)`.
This commit is contained in:
parent
607a398917
commit
fc05cda8cf
Notes:
sideshowbarker
2024-07-17 20:22:04 +09:00
Author: https://github.com/Zaggy1024 Commit: https://github.com/SerenityOS/serenity/commit/fc05cda8cf Pull-request: https://github.com/SerenityOS/serenity/pull/20898 Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/MacDue Reviewed-by: https://github.com/kalenikaliaksandr ✅
2 changed files with 16 additions and 2 deletions
|
@ -849,7 +849,7 @@ void GridFormattingContext::distribute_extra_space_across_spanned_tracks_base_si
|
|||
// Find the item-incurred increase for each spanned track with an affected size by: distributing the space
|
||||
// equally among such tracks, freezing a track’s item-incurred increase as its affected size + item-incurred
|
||||
// increase reaches its limit
|
||||
CSSPixels increase_per_track = max(extra_space / affected_tracks.size(), CSSPixels::smallest_positive_value());
|
||||
CSSPixels increase_per_track = max(CSSPixels::smallest_positive_value(), extra_space / affected_tracks.size());
|
||||
for (auto& track : affected_tracks) {
|
||||
if (track.base_size_frozen)
|
||||
continue;
|
||||
|
|
|
@ -324,6 +324,20 @@ public:
|
|||
return CSSPixels::from_raw(AK::clamp_to_int(wide_value));
|
||||
}
|
||||
|
||||
constexpr CSSPixels operator-(CSSPixels const& other) const
|
||||
{
|
||||
return CSSPixels(*this) - other;
|
||||
}
|
||||
constexpr CSSPixels operator+(CSSPixels const& other) const
|
||||
{
|
||||
return CSSPixels(*this) + other;
|
||||
}
|
||||
|
||||
constexpr CSSPixelFraction operator-() const
|
||||
{
|
||||
return CSSPixelFraction(-numerator(), denominator());
|
||||
}
|
||||
|
||||
constexpr int operator<=>(CSSPixelFraction const& other) const
|
||||
{
|
||||
auto left = static_cast<i64>(m_numerator.raw_value()) * other.m_denominator.raw_value();
|
||||
|
@ -375,7 +389,7 @@ constexpr CSSPixels CSSPixels::operator/(CSSPixelFraction const& other) const
|
|||
}
|
||||
|
||||
template<Integral T>
|
||||
constexpr CSSPixels operator/(CSSPixels left, T right) { return left / CSSPixels(right); }
|
||||
constexpr CSSPixelFraction operator/(CSSPixels left, T right) { return left / CSSPixels(right); }
|
||||
inline float operator/(CSSPixels left, float right) { return left.to_float() / right; }
|
||||
inline double operator/(CSSPixels left, double right) { return left.to_double() / right; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue