mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1260366 - Include the punctuation classes Pd and Pc in ::first-letter because the CSS Pseudo-Elements spec says so. r=jfkthame
https://www.w3.org/TR/css-pseudo-4/#first-letter-pseudo "Punctuation (i.e, characters that belong to the Punctuation (P*) Unicode general category [UAX44]) that precedes or follows the first typographic letter unit must also be included in the ::first-letter pseudo-element."
This commit is contained in:
parent
de075da893
commit
f54caaaa16
@ -1528,23 +1528,32 @@ nsContentUtils::CopyNewlineNormalizedUnicodeTo(nsReadingIterator<char16_t>& aSrc
|
||||
}
|
||||
|
||||
/**
|
||||
* This is used to determine whether a character is in one of the punctuation
|
||||
* mark classes which CSS says should be part of the first-letter.
|
||||
* See http://www.w3.org/TR/CSS2/selector.html#first-letter and
|
||||
* http://www.w3.org/TR/selectors/#first-letter
|
||||
* This is used to determine whether a character is in one of the classes
|
||||
* which CSS says should be part of the first-letter. Currently, that is
|
||||
* all punctuation classes (P*). Note that this is a change from CSS2
|
||||
* which excluded Pc and Pd.
|
||||
*
|
||||
* https://www.w3.org/TR/css-pseudo-4/#first-letter-pseudo
|
||||
* "Punctuation (i.e, characters that belong to the Punctuation (P*) Unicode
|
||||
* general category [UAX44]) [...]"
|
||||
*/
|
||||
|
||||
// static
|
||||
bool
|
||||
nsContentUtils::IsFirstLetterPunctuation(uint32_t aChar)
|
||||
{
|
||||
uint8_t cat = mozilla::unicode::GetGeneralCategory(aChar);
|
||||
|
||||
return (cat == HB_UNICODE_GENERAL_CATEGORY_OPEN_PUNCTUATION || // Ps
|
||||
cat == HB_UNICODE_GENERAL_CATEGORY_CLOSE_PUNCTUATION || // Pe
|
||||
cat == HB_UNICODE_GENERAL_CATEGORY_INITIAL_PUNCTUATION || // Pi
|
||||
cat == HB_UNICODE_GENERAL_CATEGORY_FINAL_PUNCTUATION || // Pf
|
||||
cat == HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION); // Po
|
||||
switch (mozilla::unicode::GetGeneralCategory(aChar)) {
|
||||
case HB_UNICODE_GENERAL_CATEGORY_CONNECT_PUNCTUATION: /* Pc */
|
||||
case HB_UNICODE_GENERAL_CATEGORY_DASH_PUNCTUATION: /* Pd */
|
||||
case HB_UNICODE_GENERAL_CATEGORY_CLOSE_PUNCTUATION: /* Pe */
|
||||
case HB_UNICODE_GENERAL_CATEGORY_FINAL_PUNCTUATION: /* Pf */
|
||||
case HB_UNICODE_GENERAL_CATEGORY_INITIAL_PUNCTUATION: /* Pi */
|
||||
case HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION: /* Po */
|
||||
case HB_UNICODE_GENERAL_CATEGORY_OPEN_PUNCTUATION: /* Ps */
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>Test case for bug 399941.html</title>
|
||||
<title>Test case for bug 399941, revised in bug 1260366 due to spec changes</title>
|
||||
<style type="text/css">
|
||||
span.fake-first-letter {
|
||||
color: lime;
|
||||
@ -11,7 +11,9 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Punctuation in class Pc should not be included: there is no first-letter here -->
|
||||
<p>_I_, said the Fly,</p>
|
||||
<!-- Punctuation in class Pc should be included: there is a first-letter here -->
|
||||
<p><span class="fake-first-letter">_I_,</span> said the Fly,</p>
|
||||
<!-- Punctuation in class Pd should be included: there is a first-letter here -->
|
||||
<p><span class="fake-first-letter">-I-,</span> said the Fly,</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>Test case for bug 399941.html</title>
|
||||
<title>Reference: Test case for bug 399941, revised in bug 1260366 due to spec changes</title>
|
||||
<style type="text/css">
|
||||
p:first-letter {
|
||||
color: lime;
|
||||
@ -11,7 +11,9 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Punctuation in class Pc should not be included: there is no first-letter here -->
|
||||
<!-- Punctuation in class Pc should be included: there is a first-letter here -->
|
||||
<p>_I_, said the Fly,</p>
|
||||
<!-- Punctuation in class Pd should be included: there is a first-letter here -->
|
||||
<p>-I-, said the Fly,</p>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user