mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 09:46:04 -05:00
583ca6af89
In conformance with the requirements of the spec PR at https://github.com/whatwg/html/pull/9546, this change adds support for the “switch” attribute for type=checkbox “input” elements — which is shipping in Safari (since Safari 17.4). This change also implements support for exposing it to AT users with role=switch.
90 lines
4.3 KiB
C++
90 lines
4.3 KiB
C++
/*
|
|
* Copyright (c) 2020, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/HTML/AttributeNames.h>
|
|
|
|
namespace Web::HTML {
|
|
namespace AttributeNames {
|
|
|
|
#define __ENUMERATE_HTML_ATTRIBUTE(name) FlyString name;
|
|
ENUMERATE_HTML_ATTRIBUTES
|
|
#undef __ENUMERATE_HTML_ATTRIBUTE
|
|
|
|
void initialize_strings()
|
|
{
|
|
static bool s_initialized = false;
|
|
VERIFY(!s_initialized);
|
|
|
|
#define __ENUMERATE_HTML_ATTRIBUTE(name) \
|
|
name = #name##_fly_string;
|
|
ENUMERATE_HTML_ATTRIBUTES
|
|
#undef __ENUMERATE_HTML_ATTRIBUTE
|
|
|
|
// NOTE: Special cases for C++ keywords.
|
|
class_ = "class"_fly_string;
|
|
for_ = "for"_fly_string;
|
|
default_ = "default"_fly_string;
|
|
char_ = "char"_fly_string;
|
|
switch_ = "switch"_fly_string;
|
|
|
|
// NOTE: Special cases for attributes with dashes in them.
|
|
accept_charset = "accept-charset"_fly_string;
|
|
http_equiv = "http-equiv"_fly_string;
|
|
|
|
s_initialized = true;
|
|
}
|
|
|
|
}
|
|
|
|
// https://html.spec.whatwg.org/#boolean-attribute
|
|
bool is_boolean_attribute(FlyString const& attribute)
|
|
{
|
|
// NOTE: For web compatibility, this matches the list of attributes which Chromium considers to be booleans,
|
|
// excluding attributes that are only used by Chromium itself:
|
|
// https://source.chromium.org/chromium/chromium/src/+/460b7c003cf89fc9493e721701906f19e5f6a387:chrome/test/chromedriver/element_commands.cc;l=48-94
|
|
return attribute.equals_ignoring_ascii_case(AttributeNames::allowfullscreen)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::async)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::autofocus)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::autoplay)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::checked)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::compact)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::controls)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::declare)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::default_)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::defaultchecked)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::defaultselected)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::defer)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::disabled)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::ended)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::formnovalidate)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::hidden)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::indeterminate)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::iscontenteditable)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::ismap)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::itemscope)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::loop)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::multiple)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::muted)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::nohref)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::nomodule)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::noresize)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::noshade)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::novalidate)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::nowrap)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::open)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::paused)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::playsinline)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::readonly)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::required)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::reversed)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::seeking)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::selected)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::switch_)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::truespeed)
|
|
|| attribute.equals_ignoring_ascii_case(AttributeNames::willvalidate);
|
|
}
|
|
|
|
}
|