Commit f551cd31 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Fix more CJK characters not to skip ink for text decorations

The CL[1] disabled skipping inks for characters of
IsCJKIdeographOrSymbol(). This does not cover all characters in CJK.

This patch adds other CJK characters from Unicode blocks, in the
same way as WebKit does.

[1] https://codereview.chromium.org/2598393002

Bug: 793762
Change-Id: I20e10588adc988399c900b336d0c22ad984bb011
Reviewed-on: https://chromium-review.googlesource.com/820210
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarDominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523241}
parent bdf4ac0e
<!DOCTYPE html> <!DOCTYPE html>
<meta charset="utf-8">
<style> <style>
p { p {
text-decoration: underline; text-decoration: underline;
...@@ -16,3 +17,6 @@ p { ...@@ -16,3 +17,6 @@ p {
<p>aaa &#x696D; <p>aaa &#x696D;
<p>&#x696D; aaa &#x696D; <p>&#x696D; aaa &#x696D;
<p>&#x696D; aaa &#x696D; aaa &#x696D; <p>&#x696D; aaa &#x696D; aaa &#x696D;
<p>바른정당 서울 지지율
<p>ㄱㄲㄳㄴㄵ
<p>ㄅㄆㄇㄈㄉ
<!DOCTYPE html> <!DOCTYPE html>
<meta charset="utf-8">
<style> <style>
p { p {
text-decoration: underline; text-decoration: underline;
...@@ -15,3 +16,6 @@ p { ...@@ -15,3 +16,6 @@ p {
<p>aaa &#x696D; <p>aaa &#x696D;
<p>&#x696D; aaa &#x696D; <p>&#x696D; aaa &#x696D;
<p>&#x696D; aaa &#x696D; aaa &#x696D; <p>&#x696D; aaa &#x696D; aaa &#x696D;
<p>바른정당 서울 지지율
<p>ㄱㄲㄳㄴㄵ
<p>ㄅㄆㄇㄈㄉ
...@@ -171,7 +171,8 @@ inline bool IsSkipInkException(const ShapeResultBloberizer& bloberizer, ...@@ -171,7 +171,8 @@ inline bool IsSkipInkException(const ShapeResultBloberizer& bloberizer,
// CJK characters. // CJK characters.
return bloberizer.GetType() == ShapeResultBloberizer::Type::kTextIntercepts && return bloberizer.GetType() == ShapeResultBloberizer::Type::kTextIntercepts &&
!text.Is8Bit() && !text.Is8Bit() &&
Character::IsCJKIdeographOrSymbol(text.CodepointAt(character_index)); !Character::CanTextDecorationSkipInk(
text.CodepointAt(character_index));
} }
template <typename TextContainerType> template <typename TextContainerType>
......
...@@ -211,6 +211,30 @@ unsigned Character::ExpansionOpportunityCount(const UChar* characters, ...@@ -211,6 +211,30 @@ unsigned Character::ExpansionOpportunityCount(const UChar* characters,
return count; return count;
} }
bool Character::CanTextDecorationSkipInk(UChar32 codepoint) {
if (Character::IsCJKIdeographOrSymbol(codepoint))
return false;
UBlockCode block = ublock_getCode(codepoint);
switch (block) {
// These blocks contain CJK characters we don't want to skip ink, but are
// not ideograph that IsCJKIdeographOrSymbol() does not cover.
case UBLOCK_BOPOMOFO:
case UBLOCK_BOPOMOFO_EXTENDED:
case UBLOCK_HANGUL_JAMO:
case UBLOCK_HANGUL_COMPATIBILITY_JAMO:
case UBLOCK_HANGUL_SYLLABLES:
case UBLOCK_HANGUL_JAMO_EXTENDED_A:
case UBLOCK_HANGUL_JAMO_EXTENDED_B:
case UBLOCK_LINEAR_B_IDEOGRAMS:
case UBLOCK_TANGUT:
case UBLOCK_TANGUT_COMPONENTS:
return false;
default:
return true;
}
}
bool Character::CanReceiveTextEmphasis(UChar32 c) { bool Character::CanReceiveTextEmphasis(UChar32 c) {
WTF::Unicode::CharCategory category = WTF::Unicode::Category(c); WTF::Unicode::CharCategory category = WTF::Unicode::Category(c);
if (category & if (category &
......
...@@ -122,6 +122,7 @@ class PLATFORM_EXPORT Character { ...@@ -122,6 +122,7 @@ class PLATFORM_EXPORT Character {
c == kZeroWidthNoBreakSpaceCharacter || c == kZeroWidthNoBreakSpaceCharacter ||
c == kObjectReplacementCharacter; c == kObjectReplacementCharacter;
} }
static bool CanTextDecorationSkipInk(UChar32);
static bool CanReceiveTextEmphasis(UChar32); static bool CanReceiveTextEmphasis(UChar32);
static bool IsGraphemeExtended(UChar32 c) { static bool IsGraphemeExtended(UChar32 c) {
......
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