Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 96ef023b19399f2fc5f975c239c7fe9d3e821205
https://github.com/WebKit/WebKit/commit/96ef023b19399f2fc5f975c239c7fe9d3e821205
Author: Ahmad Saleem <[email protected]>
Date: 2026-05-12 (Tue, 12 May 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/mathml/presentation-markup/operators/operator-dictionary-multi-char-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/mathml/presentation-markup/operators/operator-dictionary-multi-char.html
M Source/WebCore/accessibility/AccessibilityMathMLElement.cpp
M Source/WebCore/mathml/MathMLOperatorDictionary.cpp
M Source/WebCore/mathml/MathMLOperatorDictionary.h
M Source/WebCore/mathml/MathMLOperatorElement.cpp
M Source/WebCore/mathml/MathMLOperatorElement.h
M Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.h
M Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp
M Source/WebCore/rendering/mathml/RenderMathMLOperator.h
Log Message:
-----------
[MathML] Support operator dictionary entries for multi-character operators
https://bugs.webkit.org/show_bug.cgi?id=314388
rdar://176543727
Reviewed by Frédéric Wang Nélar.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
The MathML Core operator dictionary [1] contains twenty entries whose key is
a two-character ASCII string (e.g. "&&" infix, "!=" infix, "->" infix, "||"
prefix/infix/postfix, "!!" postfix, "++" postfix, "--" postfix). These
cannot be found by the existing single-codepoint search() because the main
dictionary is keyed by char32_t.
Previously, parseOperatorChar() would return an empty OperatorChar for such
strings and computeDictionaryProperty() would fall through to the Default
category (5/18em lspace and rspace, no flags). This was spec-incorrect for
entries whose spacing differs from the 5/5 default:
&& infix 4/18em
** infix 3/18em
<> infix 3/18em
!! postfix 0
++ postfix 0
-- postfix 0
|| prefix 0
|| postfix 0
The remaining 5/18em entries (!=, ==, <=, >=, +=, -=, *=, /=, :=, ->, //,
|| infix) happened to match the fallback by coincidence, but were not
semantically looked up either.
This patch adds a small 20-entry secondary dictionary keyed by the two
characters plus form, sorted by (firstCharacter, secondCharacter, form) so
it can be consulted via tryBinarySearch, introduces a std::array<char16_t,
2> overload of search(), and threads the two code units through
OperatorChar so computeDictionaryProperty() can consult the new table when
the char lookup misses. OperatorChar stores the code units in a union with
its single-codepoint character field and a hasTwoCharacters discriminator,
keeping the struct size unchanged. The array-keyed search applies the same
fallback semantics as the single-char search: when the exact (firstChar,
secondChar, form) entry is not found and the form was not set explicitly,
the lowest-form-enum entry for the same pair is returned (Infix < Prefix
< Postfix). This matches how "||", which has all three forms in the
dictionary, must resolve.
Rename RenderMathMLOperator::textContent() to singleCharCodePoint() since
it now returns 0 for multi-character operators; the new name makes the
single-code-point contract explicit at each callsite.
[1] https://w3c.github.io/mathml-core/#operator-dictionary
* Source/WebCore/accessibility/AccessibilityMathMLElement.cpp:
(WebCore::AccessibilityMathMLElement::textUnderElement const):
* Source/WebCore/mathml/MathMLOperatorDictionary.cpp:
(WebCore::ExtractMultiCharKey):
(WebCore::ExtractMultiCharProperty):
(WebCore::MathMLOperatorDictionary::search):
* Source/WebCore/mathml/MathMLOperatorDictionary.h:
* Source/WebCore/mathml/MathMLOperatorElement.cpp:
(WebCore::MathMLOperatorElement::parseOperatorChar):
(WebCore::MathMLOperatorElement::computeDictionaryProperty):
* Source/WebCore/mathml/MathMLOperatorElement.h:
* Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.h:
* Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::singleCharCodePoint const):
(WebCore::RenderMathMLOperator::isInvisibleOperator const):
(WebCore::RenderMathMLOperator::computePreferredLogicalWidths):
(WebCore::RenderMathMLOperator::updateMathOperator):
(WebCore::RenderMathMLOperator::useMathOperator const):
(WebCore::RenderMathMLOperator::textContent const): Deleted.
* Source/WebCore/rendering/mathml/RenderMathMLOperator.h:
(WebCore::RenderMathMLOperator::isStretchy const):
*
LayoutTests/imported/w3c/web-platform-tests/mathml/presentation-markup/operators/operator-dictionary-multi-char-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/mathml/presentation-markup/operators/operator-dictionary-multi-char.html:
Added.
Canonical link: https://commits.webkit.org/313083@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications