Skip to content

Commit

Permalink
Sync input specific unicode-bidi rendering from Web Specification
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=285252
rdar://142191490

Reviewed by NOBODY (OOPS!).

This patch aligns WebKit with Web Specification [1]:

[1] https://html.spec.whatwg.org/multipage/rendering.html#bidi-rendering

This patch implements `input` specific rules for directionality being `auto`
and move `textarea` and `pre` rules in UA stylesheet. The rationale is that `is:`
can be lead to performance concern, so did the change in C++, it also
matches Blink / Chromium.

Despite aligning with specification, there is still ambiguity on how to deal with
`password` and `text` input types for which following issue is raised [2].

[2] whatwg/html#10896

* Source/WebCore/css/html.css:
(textarea[dir=auto i], pre[dir=auto i]):
* Source/WebCore/html/HTMLElement.cpp:
(WebCore::unicodeBidiAttributeForDirAuto):
* LayoutTests/imported/w3c/web-platform-tests/html/rendering/bidi-rendering/unicode-bidi-ua-rules-expected.txt: Rebaselined
(WebCore::HTMLElement::collectPresentationalHintsForAttribute):
  • Loading branch information
Ahmad-S792 committed Jan 7, 2025
1 parent 70d6fcb commit e1e6a10
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ PASS UA stylesheet rule for unicode-bidi, for <wbr>
PASS UA stylesheet rule for unicode-bidi, for <bdo>
PASS UA stylesheet rule for unicode-bidi, for <input type=hidden>
PASS UA stylesheet rule for unicode-bidi, for <input type=text>
FAIL UA stylesheet rule for unicode-bidi, for <input type=search> assert_equals: with dir=auto expected "plaintext" but got "isolate"
FAIL UA stylesheet rule for unicode-bidi, for <input type=tel> assert_equals: with dir=auto expected "plaintext" but got "isolate"
FAIL UA stylesheet rule for unicode-bidi, for <input type=url> assert_equals: with dir=auto expected "plaintext" but got "isolate"
FAIL UA stylesheet rule for unicode-bidi, for <input type=email> assert_equals: with dir=auto expected "plaintext" but got "isolate"
PASS UA stylesheet rule for unicode-bidi, for <input type=search>
PASS UA stylesheet rule for unicode-bidi, for <input type=tel>
PASS UA stylesheet rule for unicode-bidi, for <input type=url>
PASS UA stylesheet rule for unicode-bidi, for <input type=email>
PASS UA stylesheet rule for unicode-bidi, for <input type=password>
PASS UA stylesheet rule for unicode-bidi, for <input type=date>
PASS UA stylesheet rule for unicode-bidi, for <input type=time>
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/css/html.css
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,10 @@ thead, tbody, tfoot, tr, td, th, dir, dd, dl, dt, menu, ol, ul, li, bdi, output,
unicode-bidi: isolate;
}

textarea[dir=auto i], pre[dir=auto i] {
unicode-bidi: plaintext;
}

input[type=tel i]:dir(ltr) { direction: ltr; }

bdo, bdo[dir] {
Expand Down
6 changes: 4 additions & 2 deletions Source/WebCore/html/HTMLElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ String HTMLElement::nodeName() const
static inline CSSValueID unicodeBidiAttributeForDirAuto(HTMLElement& element)
{
ASSERT(!element.hasTagName(bdoTag));
if (element.hasTagName(preTag) || element.hasTagName(textareaTag))
ASSERT(!element.hasTagName(preTag));
ASSERT(!element.hasTagName(textareaTag));
if (RefPtr input = dynamicDowncast<HTMLInputElement>(element); input && (input->isTelephoneField() || input->isEmailField() || input->isSearchField() || input->isURLField()))
return CSSValuePlaintext;
return CSSValueIsolate;
}
Expand Down Expand Up @@ -246,7 +248,7 @@ void HTMLElement::collectPresentationalHintsForAttribute(const QualifiedName& na
break;
case AttributeNames::dirAttr:
if (equalLettersIgnoringASCIICase(value, "auto"_s)) {
if (!hasTagName(bdoTag))
if (!hasTagName(bdoTag) && !hasTagName(preTag) && !hasTagName(textareaTag))
addPropertyToPresentationalHintStyle(style, CSSPropertyUnicodeBidi, unicodeBidiAttributeForDirAuto(*this));
} else if (equalLettersIgnoringASCIICase(value, "rtl"_s) || equalLettersIgnoringASCIICase(value, "ltr"_s))
addPropertyToPresentationalHintStyle(style, CSSPropertyDirection, value);
Expand Down

0 comments on commit e1e6a10

Please sign in to comment.