Coverage Report

Created: 2025-03-04 07:22

/src/serenity/Userland/Libraries/LibWeb/CSS/StyleValues/MathDepthStyleValue.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#include "MathDepthStyleValue.h"
8
9
namespace Web::CSS {
10
11
ValueComparingNonnullRefPtr<MathDepthStyleValue> MathDepthStyleValue::create_auto_add()
12
0
{
13
0
    return adopt_ref(*new (nothrow) MathDepthStyleValue(MathDepthType::AutoAdd));
14
0
}
15
16
ValueComparingNonnullRefPtr<MathDepthStyleValue> MathDepthStyleValue::create_add(ValueComparingNonnullRefPtr<CSSStyleValue const> integer_value)
17
0
{
18
0
    return adopt_ref(*new (nothrow) MathDepthStyleValue(MathDepthType::Add, move(integer_value)));
19
0
}
20
21
ValueComparingNonnullRefPtr<MathDepthStyleValue> MathDepthStyleValue::create_integer(ValueComparingNonnullRefPtr<CSSStyleValue const> integer_value)
22
0
{
23
0
    return adopt_ref(*new (nothrow) MathDepthStyleValue(MathDepthType::Integer, move(integer_value)));
24
0
}
25
26
MathDepthStyleValue::MathDepthStyleValue(MathDepthType type, ValueComparingRefPtr<CSSStyleValue const> integer_value)
27
0
    : StyleValueWithDefaultOperators(Type::MathDepth)
28
0
    , m_type(type)
29
0
    , m_integer_value(move(integer_value))
30
0
{
31
0
}
32
33
bool MathDepthStyleValue::properties_equal(MathDepthStyleValue const& other) const
34
0
{
35
0
    return m_type == other.m_type
36
0
        && m_integer_value == other.m_integer_value;
37
0
}
38
39
String MathDepthStyleValue::to_string() const
40
0
{
41
0
    switch (m_type) {
42
0
    case MathDepthType::AutoAdd:
43
0
        return "auto-add"_string;
44
0
    case MathDepthType::Add:
45
0
        return MUST(String::formatted("add({})", m_integer_value->to_string()));
46
0
    case MathDepthType::Integer:
47
0
        return m_integer_value->to_string();
48
0
    }
49
0
    VERIFY_NOT_REACHED();
50
0
}
51
52
}