Coverage Report

Created: 2025-09-05 06:52

/src/serenity/Userland/Libraries/LibWeb/CSS/Ratio.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#include "Ratio.h"
8
#include <math.h>
9
10
namespace Web::CSS {
11
12
Ratio::Ratio(double first, double second)
13
0
    : m_first_value(first)
14
0
    , m_second_value(second)
15
0
{
16
0
}
17
18
// https://www.w3.org/TR/css-values-4/#degenerate-ratio
19
bool Ratio::is_degenerate() const
20
0
{
21
0
    return !isfinite(m_first_value) || m_first_value == 0
22
0
        || !isfinite(m_second_value) || m_second_value == 0;
23
0
}
24
25
String Ratio::to_string() const
26
0
{
27
0
    return MUST(String::formatted("{:.5} / {:.5}", m_first_value, m_second_value));
28
0
}
29
30
}