Serenity Operating System
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
9namespace Web {
10namespace HTML {
11namespace AttributeNames {
12
13#define __ENUMERATE_HTML_ATTRIBUTE(name) DeprecatedFlyString name;
14ENUMERATE_HTML_ATTRIBUTES
15#undef __ENUMERATE_HTML_ATTRIBUTE
16
17[[gnu::constructor]] static void initialize()
18{
19 static bool s_initialized = false;
20 if (s_initialized)
21 return;
22
23#define __ENUMERATE_HTML_ATTRIBUTE(name) \
24 name = #name;
25 ENUMERATE_HTML_ATTRIBUTES
26#undef __ENUMERATE_HTML_ATTRIBUTE
27
28 // NOTE: Special cases for C++ keywords.
29 class_ = "class";
30 for_ = "for";
31 default_ = "default";
32 char_ = "char";
33
34 // NOTE: Special cases for attributes with dashes in them.
35 accept_charset = "accept-charset";
36 http_equiv = "http-equiv";
37
38 s_initialized = true;
39}
40
41}
42
43// https://html.spec.whatwg.org/#boolean-attribute
44bool is_boolean_attribute(DeprecatedFlyString const& attribute)
45{
46 // NOTE: This is the list of attributes from https://html.spec.whatwg.org/#attributes-3
47 // with a Value column value of "Boolean attribute".
48 return attribute.is_one_of(
49 AttributeNames::allowfullscreen,
50 AttributeNames::async,
51 AttributeNames::autofocus,
52 AttributeNames::autoplay,
53 AttributeNames::checked,
54 AttributeNames::controls,
55 AttributeNames::default_,
56 AttributeNames::defer,
57 AttributeNames::disabled,
58 AttributeNames::formnovalidate,
59 AttributeNames::inert,
60 AttributeNames::ismap,
61 AttributeNames::itemscope,
62 AttributeNames::loop,
63 AttributeNames::multiple,
64 AttributeNames::muted,
65 AttributeNames::nomodule,
66 AttributeNames::novalidate,
67 AttributeNames::open,
68 AttributeNames::playsinline,
69 AttributeNames::readonly,
70 AttributeNames::required,
71 AttributeNames::reversed,
72 AttributeNames::selected);
73}
74
75}
76}