Skip to content
Browse files
Fix calculation of direction for text form control elements with dir=…

Reviewed by Ryosuke Niwa.

For elements with dir="auto", HTMLTextFormControlElement::directionForFormData()
is relying on HTMLElement::directionalityIfDirIsAuto() but this function may
sometimes return a nullopt, so add a fallback value.

* Source/WebCore/html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::directionForFormData const): Fallback to
  LTR when directionalityIfDirIsAuto() returns a nullopt.

Canonical link:
  • Loading branch information
fred-wang committed Sep 28, 2022
1 parent fbf76ef commit 3c75189741bc8cd3c2be86fa3e299ba977ab2b9c
Showing 1 changed file with 1 addition and 1 deletion.
@@ -822,7 +822,7 @@ String HTMLTextFormControlElement::directionForFormData() const
if (equalLettersIgnoringASCIICase(value, "ltr"_s))
return TextDirection::LTR;
if (equalLettersIgnoringASCIICase(value, "auto"_s))
return element.directionalityIfDirIsAuto().value();
return element.directionalityIfDirIsAuto().value_or(TextDirection::LTR);
return TextDirection::LTR;

0 comments on commit 3c75189

Please sign in to comment.