Commit 1f13259c authored by Rob Buis's avatar Rob Buis Committed by Commit Bot

[mathml] Add method to check whether operator should be stretched vertically

Add method to check whether operator should be stretched vertically [1] as well as a unit test. This method will be used in a follow-up CL.

[1] https://mathml-refresh.github.io/mathml-core/#stretchy-operator-axis

Bug: 6606
Change-Id: If57b13db6c8a710ff553ead6dff9157812122679
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2375346
Commit-Queue: Rob Buis <rbuis@igalia.com>
Reviewed-by: default avatarDominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801388}
parent 28166f09
......@@ -268,4 +268,28 @@ bool Character::HasDefiniteScript(UChar32 character) {
hint_char_script != USCRIPT_COMMON;
}
// https://mathml-refresh.github.io/mathml-core/#stretchy-operator-axis
static const UChar stretchy_operator_with_inline_axis[]{
0x003D, 0x005E, 0x005F, 0x007E, 0x00AF, 0x02C6, 0x02C7, 0x02C9, 0x02CD,
0x02DC, 0x02F7, 0x0302, 0x0332, 0x203E, 0x20D0, 0x20D1, 0x20D6, 0x20D7,
0x20E1, 0x2190, 0x2192, 0x2194, 0x2198, 0x2199, 0x219C, 0x219D, 0x219E,
0x21A0, 0x21A2, 0x21A3, 0x21A4, 0x21A6, 0x21A9, 0x21AA, 0x21AB, 0x21AC,
0x21AD, 0x21B4, 0x21B9, 0x21BC, 0x21BD, 0x21C0, 0x21C1, 0x21C4, 0x21C6,
0x21C7, 0x21C9, 0x21CB, 0x21CC, 0x21D0, 0x21D2, 0x21D4, 0x21DA, 0x21DB,
0x21DC, 0x21DD, 0x21E0, 0x21E2, 0x21E4, 0x21E5, 0x21E6, 0x21E8, 0x21F0,
0x21F6, 0x21FD, 0x21FE, 0x21FF, 0x23B4, 0x23B5, 0x23DC, 0x23DD, 0x23DE,
0x23DF, 0x23E0, 0x23E1, 0x2500, 0x27F5, 0x27F6, 0x27F7, 0x27F8, 0x27F9,
0x27FA, 0x27FB, 0x27FC, 0x27FD, 0x27FE, 0x27FF, 0x290C, 0x290D, 0x290E,
0x290F, 0x2910, 0x294E, 0x2950, 0x2952, 0x2953, 0x2956, 0x2957, 0x295A,
0x295B, 0x295E, 0x295F, 0x2B45, 0x2B46, 0xFE35, 0xFE36, 0xFE37, 0xFE38};
bool Character::IsVerticalMathCharacter(UChar32 text_content) {
return text_content != kArabicMathematicalOperatorMeemWithHahWithTatweel &&
text_content != kArabicMathematicalOperatorHahWithDal &&
!std::binary_search(stretchy_operator_with_inline_axis,
stretchy_operator_with_inline_axis +
base::size(stretchy_operator_with_inline_axis),
text_content);
}
} // namespace blink
......@@ -202,6 +202,8 @@ class PLATFORM_EXPORT Character {
return (c - (0x1C90 - 0x10D0));
}
static bool IsVerticalMathCharacter(UChar32);
private:
static bool IsCJKIdeographOrSymbolSlow(UChar32);
static bool IsHangulSlow(UChar32);
......
......@@ -411,4 +411,36 @@ TEST(CharacterTest, TransformedIsUprightInMixedVertical) {
}
}
TEST(CharacterTest, IsVerticalMathCharacter) {
// https://mathml-refresh.github.io/mathml-core/#stretchy-operator-axis
const UChar stretchy_operator_with_inline_axis[]{
0x003D, 0x005E, 0x005F, 0x007E, 0x00AF, 0x02C6, 0x02C7, 0x02C9, 0x02CD,
0x02DC, 0x02F7, 0x0302, 0x0332, 0x203E, 0x20D0, 0x20D1, 0x20D6, 0x20D7,
0x20E1, 0x2190, 0x2192, 0x2194, 0x2198, 0x2199, 0x219C, 0x219D, 0x219E,
0x21A0, 0x21A2, 0x21A3, 0x21A4, 0x21A6, 0x21A9, 0x21AA, 0x21AB, 0x21AC,
0x21AD, 0x21B4, 0x21B9, 0x21BC, 0x21BD, 0x21C0, 0x21C1, 0x21C4, 0x21C6,
0x21C7, 0x21C9, 0x21CB, 0x21CC, 0x21D0, 0x21D2, 0x21D4, 0x21DA, 0x21DB,
0x21DC, 0x21DD, 0x21E0, 0x21E2, 0x21E4, 0x21E5, 0x21E6, 0x21E8, 0x21F0,
0x21F6, 0x21FD, 0x21FE, 0x21FF, 0x23B4, 0x23B5, 0x23DC, 0x23DD, 0x23DE,
0x23DF, 0x23E0, 0x23E1, 0x2500, 0x27F5, 0x27F6, 0x27F7, 0x27F8, 0x27F9,
0x27FA, 0x27FB, 0x27FC, 0x27FD, 0x27FE, 0x27FF, 0x290C, 0x290D, 0x290E,
0x290F, 0x2910, 0x294E, 0x2950, 0x2952, 0x2953, 0x2956, 0x2957, 0x295A,
0x295B, 0x295E, 0x295F, 0x2B45, 0x2B46, 0xFE35, 0xFE36, 0xFE37, 0xFE38};
for (UChar32 test_char = 0; test_char < kMaxCodepoint; test_char++) {
if (test_char == kArabicMathematicalOperatorMeemWithHahWithTatweel) {
EXPECT_FALSE(Character::IsVerticalMathCharacter(test_char));
} else if (test_char == kArabicMathematicalOperatorHahWithDal) {
EXPECT_FALSE(Character::IsVerticalMathCharacter(test_char));
} else {
bool in_vertical = !std::binary_search(
stretchy_operator_with_inline_axis,
stretchy_operator_with_inline_axis +
base::size(stretchy_operator_with_inline_axis),
test_char);
EXPECT_TRUE(Character::IsVerticalMathCharacter(test_char) == in_vertical);
}
}
}
} // namespace blink
......@@ -41,6 +41,8 @@ const UChar kActivateSymmetricSwappingCharacter = 0x206B;
const UChar32 kAegeanWordSeparatorLineCharacter = 0x10100;
const UChar32 kAegeanWordSeparatorDotCharacter = 0x10101;
const UChar kArabicLetterMarkCharacter = 0x061C;
const UChar32 kArabicMathematicalOperatorMeemWithHahWithTatweel = 0x1EEF0;
const UChar32 kArabicMathematicalOperatorHahWithDal = 0x1EEF1;
const UChar kBlackCircleCharacter = 0x25CF;
const UChar kBlackSquareCharacter = 0x25A0;
const UChar kBlackUpPointingTriangleCharacter = 0x25B2;
......@@ -184,6 +186,8 @@ using WTF::unicode::kActivateSymmetricSwappingCharacter;
using WTF::unicode::kAegeanWordSeparatorDotCharacter;
using WTF::unicode::kAegeanWordSeparatorLineCharacter;
using WTF::unicode::kArabicLetterMarkCharacter;
using WTF::unicode::kArabicMathematicalOperatorHahWithDal;
using WTF::unicode::kArabicMathematicalOperatorMeemWithHahWithTatweel;
using WTF::unicode::kBlackCircleCharacter;
using WTF::unicode::kBlackSquareCharacter;
using WTF::unicode::kBlackUpPointingTriangleCharacter;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment