Bug 463242. Ideographic spaces should not get CSS word-spacing, but nonbreaking spaces should. r+sr=dbaron

This commit is contained in:
Robert O'Callahan 2008-12-08 14:11:38 +13:00
parent f66d4d802b
commit 2ef6819018
4 changed files with 107 additions and 4 deletions

View File

@ -481,14 +481,19 @@ static PRBool IsSpaceCombiningSequenceTail(const nsTextFragment* aFrag, PRUint32
// Check whether aPos is a space for CSS 'word-spacing' purposes
static PRBool IsCSSWordSpacingSpace(const nsTextFragment* aFrag,
PRUint32 aPos)
PRUint32 aPos, const nsStyleText* aStyleText)
{
NS_ASSERTION(aPos < aFrag->GetLength(), "No text for IsSpace!");
PRUnichar ch = aFrag->CharAt(aPos);
if (ch == ' ' || ch == CH_CJKSP)
switch (ch) {
case ' ':
case CH_NBSP:
return !IsSpaceCombiningSequenceTail(aFrag, aPos + 1);
return ch == '\t' || ch == '\f' || ch == '\n';
case '\t': return !aStyleText->WhiteSpaceIsSignificant();
case '\n': return !aStyleText->NewlineIsSignificant();
default: return PR_FALSE;
}
}
// Check whether the string aChars/aLength starts with space that's
@ -2327,7 +2332,8 @@ PropertyProvider::GetSpacingInternal(PRUint32 aStart, PRUint32 aLength,
// End of a cluster, not in a ligature: put letter-spacing after it
aSpacing[runOffsetInSubstring + i].mAfter += mLetterSpacing;
}
if (IsCSSWordSpacingSpace(mFrag, i + run.GetOriginalOffset())) {
if (IsCSSWordSpacingSpace(mFrag, i + run.GetOriginalOffset(),
mTextStyle)) {
// It kinda sucks, but space characters can be part of clusters,
// and even still be whitespace (I think!)
iter.SetSkippedOffset(run.GetSkippedOffset() + i);

View File

@ -25,6 +25,7 @@ random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == wordwrap-03.html wordwrap-03-ref.html #
== wordwrap-08.html wordwrap-08-ref.html
!= wordwrap-09.html wordwrap-01-ref.html
== wordwrap-09.html wordwrap-09-ref.html
+== word-spacing-01.html word-spacing-01-ref.html
== zwnj-01.html zwnj-01-ref.html
HTTP(..) == zwnj-02.xhtml zwnj-02-ref.xhtml # HTTP(..) for ../filters.svg
random-if(MOZ_WIDGET_TOOLKIT=="gtk2") != zwnj-01.html zwnj-01-notref.html # Bad fonts on the tinderbox -- works locally

View File

@ -0,0 +1,50 @@
<!DOCTYPE HTML>
<html>
<head>
<style>
span { display:inline-block; width:10em; }
</style>
</head>
<body>
<table border="1">
<tr><td>space <span></span>.</td>
<tr><td>nonbreaking-space&nbsp;<span></span>.</td>
<tr><td>ideographic-space&#x3000;.</td>
<tr><td>newline
<span></span>.</td>
<tr><td>tab&#9;<span></span>.</td>
<tr><td>form-feed&#12;.</td>
</table>
<table border="1" style="white-space:pre">
<tr><td>space <span></span>.</td>
<tr><td>nonbreaking-space&nbsp;<span></span>.</td>
<tr><td>ideographic-space&#x3000;.</td>
<tr><td>newline
.</td>
<tr><td>tab&#9;.</td>
<tr><td>form-feed&#12;.</td>
</table>
<table border="1" style="white-space:nowrap">
<tr><td>space <span></span>.</td>
<tr><td>nonbreaking-space&nbsp;<span></span>.</td>
<tr><td>ideographic-space&#x3000;.</td>
<tr><td>newline <span></span>.</td>
<tr><td>tab&#9;<span></span>.</td>
<tr><td>form-feed&#12;.</td>
</table>
<table border="1" style="white-space:pre-wrap">
<tr><td>space <span></span>.</td>
<tr><td>nonbreaking-space&nbsp;<span></span>.</td>
<tr><td>ideographic-space&#x3000;.</td>
<tr><td>newline
.</td>
<tr><td>tab&#9;.</td>
<tr><td>form-feed&#12;.</td>
</table>
</body>
</html>

View File

@ -0,0 +1,46 @@
<!DOCTYPE HTML>
<html>
<body style="word-spacing:10em;">
<table border="1">
<tr><td>space .</td>
<tr><td>nonbreaking-space&nbsp;.</td>
<tr><td>ideographic-space&#x3000;.</td>
<tr><td>newline
.</td>
<tr><td>tab&#9;.</td>
<tr><td>form-feed&#12;.</td>
</table>
<table border="1" style="white-space:pre">
<tr><td>space .</td>
<tr><td>nonbreaking-space&nbsp;.</td>
<tr><td>ideographic-space&#x3000;.</td>
<tr><td>newline
.</td>
<tr><td>tab&#9;.</td>
<tr><td>form-feed&#12;.</td>
</table>
<table border="1" style="white-space:nowrap">
<tr><td>space .</td>
<tr><td>nonbreaking-space&nbsp;.</td>
<tr><td>ideographic-space&#x3000;.</td>
<tr><td>newline
.</td>
<tr><td>tab&#9;.</td>
<tr><td>form-feed&#12;.</td>
</table>
<table border="1" style="white-space:pre-wrap">
<tr><td>space .</td>
<tr><td>nonbreaking-space&nbsp;.</td>
<tr><td>ideographic-space&#x3000;.</td>
<tr><td>newline
.</td>
<tr><td>tab&#9;.</td>
<tr><td>form-feed&#12;.</td>
</table>
</body>
</html>