Bug 441418. Instead of guessing when frame broke at a first-letter boundary, explicitly record that in a reflow status bit. r+sr=dbaron

This commit is contained in:
Robert O'Callahan 2008-08-06 12:31:25 +12:00
parent 05b3a72a9c
commit bb9a3c58d4
6 changed files with 47 additions and 15 deletions

View File

@ -3568,14 +3568,12 @@ nsBlockFrame::ReflowInlineFrame(nsBlockReflowState& aState,
*aLineReflowStatus = LINE_REFLOW_OK;
// If it's currently ok to be reflowing in first-letter style then
// we must be about to reflow a frame that has first-letter style.
PRBool reflowingFirstLetter = aLineLayout.GetFirstLetterStyleOK();
#ifdef NOISY_FIRST_LETTER
ListTag(stdout);
printf(": reflowing ");
nsFrame::ListTag(stdout, aFrame);
printf(" reflowingFirstLetter=%s\n", reflowingFirstLetter ? "on" : "off");
printf(" reflowingFirstLetter=%s\n",
aLineLayout.GetFirstLetterStyleOK() ? "on" : "off");
#endif
// Reflow the inline frame
@ -3715,18 +3713,10 @@ nsBlockFrame::ReflowInlineFrame(nsBlockReflowState& aState,
aLine->SetLineWrapped(PR_TRUE);
}
// If we are reflowing the first letter frame or a placeholder then
// If we just ended a first-letter frame or reflowed a placeholder then
// don't split the line and don't stop the line reflow...
PRBool splitLine = !reflowingFirstLetter &&
nsGkAtoms::placeholderFrame != frameType;
if (reflowingFirstLetter) {
if ((nsGkAtoms::inlineFrame == frameType) ||
(nsGkAtoms::lineFrame == frameType)) {
splitLine = PR_TRUE;
}
}
if (splitLine) {
if (!(frameReflowStatus & NS_INLINE_BREAK_FIRST_LETTER_COMPLETE) &&
nsGkAtoms::placeholderFrame != frameType) {
// Split line after the current frame
*aLineReflowStatus = LINE_REFLOW_STOP;
rv = SplitLine(aState, aLineLayout, aLine, aFrame->GetNextSibling(), aLineReflowStatus);

View File

@ -374,6 +374,9 @@ typedef PRUint32 nsReflowStatus;
// The type of break requested can be found in these bits.
#define NS_INLINE_BREAK_TYPE_MASK 0xF000
// Set when a break was induced by completion of a first-letter
#define NS_INLINE_BREAK_FIRST_LETTER_COMPLETE 0x10000
//----------------------------------------
// Macros that use those bits

View File

@ -5895,6 +5895,10 @@ nsTextFrame::Reflow(nsPresContext* aPresContext,
} else if (breakAfter) {
aStatus = NS_INLINE_LINE_BREAK_AFTER(aStatus);
}
if (completedFirstLetter) {
lineLayout.SetFirstLetterStyleOK(PR_FALSE);
aStatus |= NS_INLINE_BREAK_FIRST_LETTER_COMPLETE;
}
// Compute space and letter counts for justification, if required
if (NS_STYLE_TEXT_ALIGN_JUSTIFY == textStyle->mTextAlign &&

View File

@ -0,0 +1,16 @@
<!DOCTYPE HTML>
<html>
<head>
<style>
p { color:black; }
</style>
</head>
<body>
<p><br>
Hello
<p>"<br>
Hello
<p>"<br>
Hello
</body>
</html>

View File

@ -0,0 +1,18 @@
<!DOCTYPE HTML>
<html>
<head>
<style>
p { width:0; color:black; }
p::first-letter { color:yellow; }
p.pre { white-space:pre; }
</style>
</head>
<body>
<p class="pre">
Hello
<p class="pre">"
Hello
<p>"
Hello
</body>
</html>

View File

@ -43,3 +43,4 @@ random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 329069-1.html 329069-1-ref.html # failu
== 399941-7.html 399941-7-ref.html
== 399941-8.html 399941-8-ref.html
== 399941-9.html 399941-9-ref.html
== 441418-1.html 441418-1-ref.html