Commit 224e825b authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

[LayoutNG] Don't remove segment break between Hangul characters

Spec (https://drafts.csswg.org/css-text-3/#line-break-transform)
says that, during whitespace collapsing, segment break between
Hangul characters should be converted into a space instead of
removed. This patch implements that.

Bug: 636993
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng;luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ie61a223ea400a20166ea3ecd779904d4ae57d67a
Reviewed-on: https://chromium-review.googlesource.com/1112756Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570130}
parent a0c8a3f9
......@@ -146,9 +146,6 @@ crbug.com/591099 external/wpt/css/css-text/line-breaking/line-breaking-011.html
crbug.com/591099 external/wpt/css/css-text/line-breaking/line-breaking-ic-002.html [ Pass ]
crbug.com/591099 external/wpt/css/css-text/line-breaking/line-breaking-ic-003.html [ Pass ]
crbug.com/591099 external/wpt/css/css-text/white-space/pre-wrap-002.html [ Pass ]
crbug.com/591099 external/wpt/css/css-text/white-space/seg-break-transformation-010.html [ Failure ]
crbug.com/591099 external/wpt/css/css-text/white-space/seg-break-transformation-011.html [ Failure ]
crbug.com/591099 external/wpt/css/css-text/white-space/seg-break-transformation-012.html [ Failure ]
crbug.com/591099 external/wpt/css/css-text/word-break/word-break-break-all-004.html [ Pass ]
crbug.com/591099 external/wpt/css/css-transforms/transform-transformed-tr-percent-height-child.html [ Failure ]
crbug.com/591099 external/wpt/css/css-transforms/transform3d-perspective-008.html [ Pass ]
......
......@@ -95,19 +95,21 @@ bool ShouldRemoveNewlineSlow(const StringBuilder& before,
if (before.Is8Bit() || after.Is8Bit())
return false;
// Remove if East Asian Widths of both before/after the newline are Wide.
// Remove if East Asian Widths of both before/after the newline are Wide, and
// neither side is Hangul.
// TODO(layout-dev): Don't remove if any side is Emoji.
if (U16_IS_TRAIL(last) && space_index >= 2) {
UChar last_last = before[space_index - 2];
if (U16_IS_LEAD(last_last))
last = U16_GET_SUPPLEMENTARY(last_last, last);
}
if (IsEastAsianWidthWide(last, before_style)) {
if (!Character::IsHangul(last) && IsEastAsianWidthWide(last, before_style)) {
if (U16_IS_LEAD(next) && after.length() > 1) {
UChar next_next = after[1];
if (U16_IS_TRAIL(next_next))
next = U16_GET_SUPPLEMENTARY(next, next_next);
}
if (IsEastAsianWidthWide(next, after_style))
if (!Character::IsHangul(next) && IsEastAsianWidthWide(next, after_style))
return true;
}
......
......@@ -122,6 +122,10 @@ bool Character::IsBidiControl(UChar32 character) {
RETURN_HAS_PROPERTY(character, kIsBidiControl);
}
bool Character::IsHangulSlow(UChar32 character) {
RETURN_HAS_PROPERTY(character, kIsHangul);
}
unsigned Character::ExpansionOpportunityCount(const LChar* characters,
size_t length,
TextDirection direction,
......
......@@ -72,6 +72,11 @@ class PLATFORM_EXPORT Character {
!(U_GET_GC_MASK(c) & (U_GC_M_MASK | U_GC_LM_MASK | U_GC_SK_MASK));
}
static bool IsHangul(UChar32 c) {
// Below U+1100 is likely a common case.
return c < 0x1100 ? false : IsHangulSlow(c);
}
static unsigned ExpansionOpportunityCount(const LChar*,
size_t length,
TextDirection,
......@@ -182,6 +187,7 @@ class PLATFORM_EXPORT Character {
private:
static bool IsCJKIdeographOrSymbolSlow(UChar32);
static bool IsHangulSlow(UChar32);
};
} // namespace blink
......
......@@ -16,6 +16,7 @@ enum class CharacterProperty : CharacterPropertyType {
kIsUprightInMixedVertical = 0x0002,
kIsPotentialCustomElementNameChar = 0x0004,
kIsBidiControl = 0x0008,
kIsHangul = 0x0010
};
inline CharacterProperty operator|(CharacterProperty a, CharacterProperty b) {
......
......@@ -82,6 +82,7 @@ static void Generate(FILE* fp) {
SET(kIsUprightInMixedVertical);
SET(kIsPotentialCustomElementNameChar);
SET(kIsBidiControl);
SET(kIsHangul);
// Create a trie from the value array.
UErrorCode error = U_ZERO_ERROR;
......
......@@ -230,6 +230,25 @@ static const UChar32 kIsBidiControlRanges[] = {
0x202A, 0x202E, 0x2066, 0x2069,
};
// https://unicode.org/Public/UNIDATA/Blocks.txt
static const UChar32 kIsHangulRanges[] = {
// Hangul Jamo
0x1100, 0x11FF,
// Hangul Compatibility Jamo
0x3130, 0x318F,
// Hangul Jamo Extended-A
0xA960, 0xA97F,
// Hangul Syllables
0xAC00, 0xD7AF,
// Hangul Jamo Extended-B
0xD7B0, 0xD7FF,
// Halfwidth Hangul Jamo
// https://www.unicode.org/charts/nameslist/c_FF00.html
0xFFA0, 0xFFDC,
};
static const UChar32 kIsHangulArray[] = {};
} // namespace blink
#endif
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