зеркало из https://github.com/mozilla/gecko-dev.git
r=ftang (someday); fixed bug 17130 - the problem was that nbsp's were being mapped into spaces by the text-transformer which is normally good, but for the purposes of line-breaking look-ahead was bad. I added code to revert the post-transformed spaces into nbsp's before using the line-breaker
This commit is contained in:
Родитель
9e50fa5b4f
Коммит
80998e8d8c
|
@ -524,7 +524,7 @@ public:
|
|||
const nsHTMLReflowState& aReflowState,
|
||||
nsIFrame* aNextFrame,
|
||||
nscoord aBaseWidth,
|
||||
const PRUnichar* aWordBuf,
|
||||
PRUnichar* aWordBuf,
|
||||
PRUint32 aWordBufLen,
|
||||
PRUint32 aWordBufSize);
|
||||
|
||||
|
@ -3181,6 +3181,18 @@ nsTextFrame::TrimTrailingWhiteSpace(nsIPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
RevertSpacesToNBSP(PRUnichar* aBuffer, PRInt32 aWordLen)
|
||||
{
|
||||
PRUnichar* end = aBuffer + aWordLen;
|
||||
for (; aBuffer < end; aBuffer++) {
|
||||
PRUnichar ch = *aBuffer;
|
||||
if (ch == ' ') {
|
||||
*aBuffer = CH_NBSP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nscoord
|
||||
nsTextFrame::ComputeTotalWordWidth(nsIPresContext* aPresContext,
|
||||
nsILineBreaker* aLineBreaker,
|
||||
|
@ -3188,10 +3200,14 @@ nsTextFrame::ComputeTotalWordWidth(nsIPresContext* aPresContext,
|
|||
const nsHTMLReflowState& aReflowState,
|
||||
nsIFrame* aNextFrame,
|
||||
nscoord aBaseWidth,
|
||||
const PRUnichar* aWordBuf,
|
||||
PRUnichar* aWordBuf,
|
||||
PRUint32 aWordLen,
|
||||
PRUint32 aWordBufSize)
|
||||
{
|
||||
// Before we get going, convert any spaces in the current word back
|
||||
// to nbsp's. This keeps the breaking logic happy.
|
||||
RevertSpacesToNBSP(aWordBuf, (PRInt32) aWordLen);
|
||||
|
||||
nscoord addedWidth = 0;
|
||||
while (nsnull != aNextFrame) {
|
||||
nsIContent* content = nsnull;
|
||||
|
@ -3203,7 +3219,7 @@ nsTextFrame::ComputeTotalWordWidth(nsIPresContext* aPresContext,
|
|||
#endif
|
||||
nsITextContent* tc;
|
||||
if (NS_OK == content->QueryInterface(kITextContentIID, (void**)&tc)) {
|
||||
PRBool stop;
|
||||
PRBool stop = PR_FALSE;
|
||||
nscoord moreWidth = ComputeWordFragmentWidth(aPresContext,
|
||||
aLineBreaker,
|
||||
aLineLayout,
|
||||
|
@ -3270,6 +3286,10 @@ nsTextFrame::ComputeWordFragmentWidth(nsIPresContext* aPresContext,
|
|||
}
|
||||
*aStop = contentLen < tx.GetContentLength();
|
||||
|
||||
// Convert any spaces in the current word back to nbsp's. This keeps
|
||||
// the breaking logic happy.
|
||||
RevertSpacesToNBSP(bp, wordLen);
|
||||
|
||||
// We need to adjust the length by look at the two pieces together
|
||||
// XXX this should grow aWordBuf if necessary
|
||||
PRUint32 copylen = sizeof(PRUnichar) *
|
||||
|
|
|
@ -524,7 +524,7 @@ public:
|
|||
const nsHTMLReflowState& aReflowState,
|
||||
nsIFrame* aNextFrame,
|
||||
nscoord aBaseWidth,
|
||||
const PRUnichar* aWordBuf,
|
||||
PRUnichar* aWordBuf,
|
||||
PRUint32 aWordBufLen,
|
||||
PRUint32 aWordBufSize);
|
||||
|
||||
|
@ -3181,6 +3181,18 @@ nsTextFrame::TrimTrailingWhiteSpace(nsIPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
RevertSpacesToNBSP(PRUnichar* aBuffer, PRInt32 aWordLen)
|
||||
{
|
||||
PRUnichar* end = aBuffer + aWordLen;
|
||||
for (; aBuffer < end; aBuffer++) {
|
||||
PRUnichar ch = *aBuffer;
|
||||
if (ch == ' ') {
|
||||
*aBuffer = CH_NBSP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nscoord
|
||||
nsTextFrame::ComputeTotalWordWidth(nsIPresContext* aPresContext,
|
||||
nsILineBreaker* aLineBreaker,
|
||||
|
@ -3188,10 +3200,14 @@ nsTextFrame::ComputeTotalWordWidth(nsIPresContext* aPresContext,
|
|||
const nsHTMLReflowState& aReflowState,
|
||||
nsIFrame* aNextFrame,
|
||||
nscoord aBaseWidth,
|
||||
const PRUnichar* aWordBuf,
|
||||
PRUnichar* aWordBuf,
|
||||
PRUint32 aWordLen,
|
||||
PRUint32 aWordBufSize)
|
||||
{
|
||||
// Before we get going, convert any spaces in the current word back
|
||||
// to nbsp's. This keeps the breaking logic happy.
|
||||
RevertSpacesToNBSP(aWordBuf, (PRInt32) aWordLen);
|
||||
|
||||
nscoord addedWidth = 0;
|
||||
while (nsnull != aNextFrame) {
|
||||
nsIContent* content = nsnull;
|
||||
|
@ -3203,7 +3219,7 @@ nsTextFrame::ComputeTotalWordWidth(nsIPresContext* aPresContext,
|
|||
#endif
|
||||
nsITextContent* tc;
|
||||
if (NS_OK == content->QueryInterface(kITextContentIID, (void**)&tc)) {
|
||||
PRBool stop;
|
||||
PRBool stop = PR_FALSE;
|
||||
nscoord moreWidth = ComputeWordFragmentWidth(aPresContext,
|
||||
aLineBreaker,
|
||||
aLineLayout,
|
||||
|
@ -3270,6 +3286,10 @@ nsTextFrame::ComputeWordFragmentWidth(nsIPresContext* aPresContext,
|
|||
}
|
||||
*aStop = contentLen < tx.GetContentLength();
|
||||
|
||||
// Convert any spaces in the current word back to nbsp's. This keeps
|
||||
// the breaking logic happy.
|
||||
RevertSpacesToNBSP(bp, wordLen);
|
||||
|
||||
// We need to adjust the length by look at the two pieces together
|
||||
// XXX this should grow aWordBuf if necessary
|
||||
PRUint32 copylen = sizeof(PRUnichar) *
|
||||
|
|
Загрузка…
Ссылка в новой задаче