Skip to content

Commit 2feff2b

Browse files
committed
LibWeb/HTML: Capitalize autocorrection and autocapitalization states
Only comment changes. Corresponds to: whatwg/html@ea29ce1
1 parent c0b8f47 commit 2feff2b

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

Libraries/LibWeb/HTML/HTMLElement.cpp

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,15 +2224,15 @@ HTMLElement::AutocapitalizationHint HTMLElement::own_autocapitalization_hint() c
22242224
{
22252225
// The autocapitalization processing model is based on selecting among five autocapitalization hints, defined as follows:
22262226
//
2227-
// default
2227+
// Default
22282228
// The user agent and input method should make their own determination of whether or not to enable autocapitalization.
22292229
// none
22302230
// No autocapitalization should be applied (all letters should default to lowercase).
2231-
// sentences
2231+
// Sentences
22322232
// The first letter of each sentence should default to a capital letter; all other letters should default to lowercase.
2233-
// words
2233+
// Words
22342234
// The first letter of each word should default to a capital letter; all other letters should default to lowercase.
2235-
// characters
2235+
// Characters
22362236
// All letters should default to uppercase.
22372237

22382238
// The autocapitalize attribute is an enumerated attribute whose states are the possible autocapitalization hints.
@@ -2241,14 +2241,14 @@ HTMLElement::AutocapitalizationHint HTMLElement::own_autocapitalization_hint() c
22412241
// their state mappings are as follows:
22422242

22432243
// Keyword | State
2244-
// off | none
2244+
// off | None
22452245
// none |
2246-
// on | sentences
2246+
// on | Sentences
22472247
// sentences |
2248-
// words | words
2249-
// characters | characters
2248+
// words | Words
2249+
// characters | Characters
22502250

2251-
// The attribute's missing value default is the default state, and its invalid value default is the sentences state.
2251+
// The attribute's missing value default is the Default state, and its invalid value default is the Sentences state.
22522252

22532253
// To compute the own autocapitalization hint of an element element, run the following steps:
22542254
// 1. If the autocapitalize content attribute is present on element, and its value is not the empty string, return the
@@ -2270,12 +2270,13 @@ HTMLElement::AutocapitalizationHint HTMLElement::own_autocapitalization_hint() c
22702270
return AutocapitalizationHint::Sentences;
22712271
}
22722272

2273-
// If element is an autocapitalize-and-autocorrect inheriting element and has a non-null form owner, return the own autocapitalization hint of element's form owner.
2273+
// 2. If element is an autocapitalize-and-autocorrect inheriting element and has a non-null form owner, return the
2274+
// own autocapitalization hint of element's form owner.
22742275
auto const* form_associated_element = as_if<FormAssociatedElement>(this);
22752276
if (form_associated_element && form_associated_element->is_autocapitalize_and_autocorrect_inheriting() && form_associated_element->form())
22762277
return form_associated_element->form()->own_autocapitalization_hint();
22772278

2278-
// 3. Return default.
2279+
// 3. Return Default.
22792280
return AutocapitalizationHint::Default;
22802281
}
22812282

@@ -2286,9 +2287,9 @@ String HTMLElement::autocapitalize() const
22862287
// 1. Let state be the own autocapitalization hint of this.
22872288
auto state = own_autocapitalization_hint();
22882289

2289-
// 2. If state is default, then return the empty string.
2290-
// 3. If state is none, then return "none".
2291-
// 4. If state is sentences, then return "sentences".
2290+
// 2. If state is Default, then return the empty string.
2291+
// 3. If state is None, then return "none".
2292+
// 4. If state is Sentences, then return "sentences".
22922293
// 5. Return the keyword value corresponding to state.
22932294
switch (state) {
22942295
case AutocapitalizationHint::Default:
@@ -2317,12 +2318,12 @@ HTMLElement::AutocorrectionState HTMLElement::used_autocorrection_state() const
23172318
{
23182319
// The autocorrect attribute is an enumerated attribute with the following keywords and states:
23192320
// Keyword | State | Brief description
2320-
// on | on | The user agent is permitted to automatically correct spelling errors while the user
2321+
// on | On | The user agent is permitted to automatically correct spelling errors while the user
23212322
// (the empty string) | | types. Whether spelling is automatically corrected while typing left is for the user
23222323
// | | agent to decide, and may depend on the element as well as the user's preferences.
2323-
// off | off | The user agent is not allowed to automatically correct spelling while the user types.
2324+
// off | Off | The user agent is not allowed to automatically correct spelling while the user types.
23242325

2325-
// The attribute's invalid value default and missing value default are both the on state.
2326+
// The attribute's invalid value default and missing value default are both the On state.
23262327

23272328
auto autocorrect_attribute_state = [](Optional<String> attribute) {
23282329
if (attribute.has_value() && attribute.value().equals_ignoring_ascii_case("off"sv))
@@ -2332,7 +2333,8 @@ HTMLElement::AutocorrectionState HTMLElement::used_autocorrection_state() const
23322333
};
23332334

23342335
// To compute the used autocorrection state of an element element, run these steps:
2335-
// 1. If element is an input element whose type attribute is in one of the URL, E-mail, or Password states, then return off.
2336+
// 1. If element is an input element whose type attribute is in one of the URL, E-mail, or Password states, then
2337+
// return Off.
23362338
if (auto const* input_element = as_if<HTMLInputElement>(this)) {
23372339
if (first_is_one_of(input_element->type_state(), HTMLInputElement::TypeAttributeState::URL, HTMLInputElement::TypeAttributeState::Email, HTMLInputElement::TypeAttributeState::Password))
23382340
return AutocorrectionState::Off;
@@ -2351,21 +2353,23 @@ HTMLElement::AutocorrectionState HTMLElement::used_autocorrection_state() const
23512353
return autocorrect_attribute_state(form_associated_element->form()->attribute(HTML::AttributeNames::autocorrect));
23522354
}
23532355

2354-
// 4. Return on.
2356+
// 4. Return On.
23552357
return AutocorrectionState::On;
23562358
}
23572359

23582360
// https://html.spec.whatwg.org/multipage/interaction.html#dom-autocorrect
23592361
bool HTMLElement::autocorrect() const
23602362
{
2361-
// The autocorrect getter steps are: return true if the element's used autocorrection state is on and false if the element's used autocorrection state is off.
2363+
// The autocorrect getter steps are: return true if the element's used autocorrection state is On and false if the
2364+
// element's used autocorrection state is Off.
23622365
return used_autocorrection_state() == AutocorrectionState::On;
23632366
}
23642367

23652368
// https://html.spec.whatwg.org/multipage/interaction.html#dom-autocorrect
23662369
void HTMLElement::set_autocorrect(bool given_value)
23672370
{
2368-
// The setter steps are: if the given value is true, then the element's autocorrect attribute must be set to "on"; otherwise it must be set to "off".
2371+
// The setter steps are: if the given value is true, then the element's autocorrect attribute must be set to "on";
2372+
// otherwise it must be set to "off".
23692373
if (given_value)
23702374
set_attribute_value(HTML::AttributeNames::autocorrect, "on"_string);
23712375
else

0 commit comments

Comments
 (0)