Coverage Report

Created: 2025-09-05 06:52

/src/serenity/Userland/Libraries/LibWeb/HTML/ScrollOptions.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <LibWeb/Bindings/WindowGlobalMixin.h>
10
11
namespace Web::HTML {
12
13
// https://w3c.github.io/csswg-drafts/cssom-view/#dictdef-scrolloptions
14
struct ScrollOptions {
15
    Bindings::ScrollBehavior behavior { Bindings::ScrollBehavior::Auto };
16
};
17
18
// https://drafts.csswg.org/cssom-view/#normalize-non-finite-values
19
[[nodiscard]] inline double normalize_non_finite_values(double value)
20
0
{
21
    // When asked to normalize non-finite values for a value x, if x is one of the three special floating point
22
    // literal values (Infinity, -Infinity or NaN), then x must be changed to the value 0. [WEBIDL]
23
0
    if (isinf(value) || isnan(value))
24
0
        return 0;
25
26
0
    return value;
27
0
}
28
29
// https://drafts.csswg.org/cssom-view/#normalize-non-finite-values
30
[[nodiscard]] inline double normalize_non_finite_values(Optional<double> const& value)
31
0
{
32
0
    if (!value.has_value())
33
0
        return 0;
34
0
    return normalize_non_finite_values(value.value());
35
0
}
36
37
}