Backed out changeset 5ae8ad2a0901 (bug 1722763) for causing wpt failures in /css/selectors/first-letter-flag-001. CLOSED TREE

This commit is contained in:
Sandor Molnar
2021-07-31 01:47:09 +03:00
parent a9244ab8af
commit c1a16b0ea1
5 changed files with 20 additions and 36 deletions

View File

@@ -1679,6 +1679,22 @@ bool nsContentUtils::IsAlphanumericOrSymbol(uint32_t aChar) {
cat == nsUGenCategory::kSymbol; cat == nsUGenCategory::kSymbol;
} }
// static
bool nsContentUtils::IsAlphanumericOrSymbolAt(const nsTextFragment* aFrag,
uint32_t aOffset) {
char16_t h = aFrag->CharAt(aOffset);
if (!IS_SURROGATE(h)) {
return IsAlphanumericOrSymbol(h);
}
if (NS_IS_HIGH_SURROGATE(h) && aOffset + 1 < aFrag->GetLength()) {
char16_t l = aFrag->CharAt(aOffset + 1);
if (NS_IS_LOW_SURROGATE(l)) {
return IsAlphanumericOrSymbol(SURROGATE_TO_UCS4(h, l));
}
}
return false;
}
/* static */ /* static */
bool nsContentUtils::IsHTMLWhitespace(char16_t aChar) { bool nsContentUtils::IsHTMLWhitespace(char16_t aChar) {
return aChar == char16_t(0x0009) || aChar == char16_t(0x000A) || return aChar == char16_t(0x0009) || aChar == char16_t(0x000A) ||

View File

@@ -626,6 +626,8 @@ class nsContentUtils {
* Returns true if aChar is of class L*, N* or S* (for first-letter). * Returns true if aChar is of class L*, N* or S* (for first-letter).
*/ */
static bool IsAlphanumericOrSymbol(uint32_t aChar); static bool IsAlphanumericOrSymbol(uint32_t aChar);
static bool IsAlphanumericOrSymbolAt(const nsTextFragment* aFrag,
uint32_t aOffset);
/* /*
* Is the character an HTML whitespace character? * Is the character an HTML whitespace character?

View File

@@ -8230,8 +8230,7 @@ static bool FindFirstLetterRange(const nsTextFragment* aFrag,
// If the next character is not a letter, number or symbol, there is no // If the next character is not a letter, number or symbol, there is no
// first-letter. // first-letter.
// Return true so that we don't go on looking, but set aLength to 0. // Return true so that we don't go on looking, but set aLength to 0.
uint32_t usv = aFrag->ScalarValueAt(aOffset + i); if (!nsContentUtils::IsAlphanumericOrSymbolAt(aFrag, aOffset + i)) {
if (!nsContentUtils::IsAlphanumericOrSymbol(usv)) {
*aLength = 0; *aLength = 0;
return true; return true;
} }
@@ -8244,17 +8243,12 @@ static bool FindFirstLetterRange(const nsTextFragment* aFrag,
bool allowSplitLigature; bool allowSplitLigature;
typedef unicode::Script Script; typedef unicode::Script Script;
Script script = unicode::GetScriptCode(usv); Script script = unicode::GetScriptCode(aFrag->CharAt(aOffset + i));
switch (script) { switch (script) {
default: default:
allowSplitLigature = true; allowSplitLigature = true;
break; break;
// Don't break regional-indicator ligatures.
case Script::COMMON:
allowSplitLigature = !gfxFontUtils::IsRegionalIndicator(usv);
break;
// For now, lacking any definitive specification of when to apply this // For now, lacking any definitive specification of when to apply this
// behavior, we'll base the decision on the HarfBuzz shaping engine // behavior, we'll base the decision on the HarfBuzz shaping engine
// used for each script: those that are handled by the Indic, Tibetan, // used for each script: those that are handled by the Indic, Tibetan,

View File

@@ -1,12 +0,0 @@
<!doctype html>
<meta charset=utf-8>
<title>::first-letter with a Regional-Indicator flag symbol - reference</title>
<style>
p {
font: 24px/3 serif;
}
span {
font-size: 2em;
}
</style>
<p><span>&#x1F1EC;&#x1F1E7;</span> UK flag

View File

@@ -1,16 +0,0 @@
<!doctype html>
<meta charset=utf-8>
<title>::first-letter with a Regional-Indicator flag symbol</title>
<meta name="assert" content="::first-letter should apply to symbol characters">
<link rel=help href="https://drafts.csswg.org/css-pseudo-4/#first-letter-pseudo">
<link rel=help href="https://github.com/w3c/csswg-drafts/issues/5099#issuecomment-759612015">
<link rel=match href=first-letter-flag-001-ref.html>
<style>
p {
font: 24px/3 serif;
}
p::first-letter {
font-size: 2em;
}
</style>
<p>&#x1F1EC;&#x1F1E7; UK flag