Add support for multiple-char operators#59196
Conversation
https://bugs.webkit.org/show_bug.cgi?id=124828 rdar://170907545 Reviewed by NOBODY (OOPS!). When an operator contains a base character followed by combining characters (e.g., "≠" which is "=" + U+0338), use the base character for dictionary lookup. This matches MathML Core spec behavior and other browser engines. Previously, parseOperatorChar() only handled single code points via convertToSingleCodePoint(), which returned nullopt for multi-character operators, causing them to use default spacing instead of the base character's dictionary properties. The fix iterates through code points and checks if all characters after the first are combining marks (Unicode categories Mn, Mc, Me). If so, the first character is used for dictionary lookup. * LayoutTests/imported/w3c/web-platform-tests/mathml/presentation-markup/operators/operator-dictionary-combining-expected.txt: Progression * Source/WebCore/mathml/MathMLOperatorElement.cpp: (WebCore::MathMLOperatorElement::parseOperatorChar):
|
EWS run on current version of this PR (hash 439c815) Details |
| // Try single code point first. | ||
| if (auto codePoint = StringView(trimmed).convertToSingleCodePoint()) { | ||
| auto character = codePoint.value(); | ||
| // The minus sign renders better than the hyphen sign used in some MathML formulas. |
There was a problem hiding this comment.
Why is this comment removed? That seems unrelated to this patch
| } | ||
|
|
||
| // Handle base character followed by combining character(s). | ||
| // Per MathML Core spec, use the base character for dictionary lookup. |
There was a problem hiding this comment.
From https://w3c.github.io/mathml-core/#dfn-algorithm-to-determine-the-category-of-an-operator I only see the case when there are two characters with the first one being U+0338 COMBINING LONG SOLIDUS OVERLAY or U+20D2 COMBINING LONG VERTICAL LINE OVERLAY (other cases were not in the MathML 3 dictionary), so we can probably simplify.
That probably means test coverage is not enough, as we are not testing that the category for multiple combining or other combining characters would be "Default" instead.
There was a problem hiding this comment.
Nice! Will explore.
| if (firstChar == hyphenMinus) | ||
| firstChar = minusSign; | ||
| operatorChar.character = firstChar; | ||
| operatorChar.isVertical = isVertical(operatorChar.character); |
There was a problem hiding this comment.
Would be nice to factor out the shared code in a helper function/lambda.
439c815
439c815