Coverage Report

Created: 2025-11-02 07:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWeb/HTML/AttributeNames.cpp
Line
Count
Source
1
/*
2
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#include <LibWeb/HTML/AttributeNames.h>
8
9
namespace Web::HTML {
10
namespace AttributeNames {
11
12
#define __ENUMERATE_HTML_ATTRIBUTE(name) FlyString name;
13
ENUMERATE_HTML_ATTRIBUTES
14
#undef __ENUMERATE_HTML_ATTRIBUTE
15
16
void initialize_strings()
17
0
{
18
0
    static bool s_initialized = false;
19
0
    VERIFY(!s_initialized);
20
21
0
#define __ENUMERATE_HTML_ATTRIBUTE(name) \
22
0
    name = #name##_fly_string;
23
0
    ENUMERATE_HTML_ATTRIBUTES
24
0
#undef __ENUMERATE_HTML_ATTRIBUTE
25
26
    // NOTE: Special cases for C++ keywords.
27
0
    class_ = "class"_fly_string;
28
0
    for_ = "for"_fly_string;
29
0
    default_ = "default"_fly_string;
30
0
    char_ = "char"_fly_string;
31
32
    // NOTE: Special cases for attributes with dashes in them.
33
0
    accept_charset = "accept-charset"_fly_string;
34
0
    http_equiv = "http-equiv"_fly_string;
35
36
0
    s_initialized = true;
37
0
}
38
39
}
40
41
// https://html.spec.whatwg.org/#boolean-attribute
42
bool is_boolean_attribute(FlyString const& attribute)
43
0
{
44
    // NOTE: This is the list of attributes from https://html.spec.whatwg.org/#attributes-3
45
    //       with a Value column value of "Boolean attribute".
46
0
    return attribute.is_one_of(
47
0
        AttributeNames::allowfullscreen,
48
0
        AttributeNames::async,
49
0
        AttributeNames::autofocus,
50
0
        AttributeNames::autoplay,
51
0
        AttributeNames::checked,
52
0
        AttributeNames::controls,
53
0
        AttributeNames::default_,
54
0
        AttributeNames::defer,
55
0
        AttributeNames::disabled,
56
0
        AttributeNames::formnovalidate,
57
0
        AttributeNames::inert,
58
0
        AttributeNames::ismap,
59
0
        AttributeNames::itemscope,
60
0
        AttributeNames::loop,
61
0
        AttributeNames::multiple,
62
0
        AttributeNames::muted,
63
0
        AttributeNames::nomodule,
64
0
        AttributeNames::novalidate,
65
0
        AttributeNames::open,
66
0
        AttributeNames::playsinline,
67
0
        AttributeNames::readonly,
68
0
        AttributeNames::required,
69
0
        AttributeNames::reversed,
70
0
        AttributeNames::selected);
71
0
}
72
73
}