diff --git a/mozilla/layout/generic/nsFirstLetterFrame.cpp b/mozilla/layout/generic/nsFirstLetterFrame.cpp index 7d41c7e62b8..6d12d5737a1 100644 --- a/mozilla/layout/generic/nsFirstLetterFrame.cpp +++ b/mozilla/layout/generic/nsFirstLetterFrame.cpp @@ -224,23 +224,25 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext, ll.BeginLineReflow(bp.left, bp.top, availSize.width, NS_UNCONSTRAINEDSIZE, PR_FALSE, PR_TRUE); rs.mLineLayout = ≪ + ll.SetInFirstLetter(PR_TRUE); ll.SetFirstLetterStyleOK(PR_TRUE); kid->WillReflow(aPresContext); kid->Reflow(aPresContext, aMetrics, rs, aReflowStatus); ll.EndLineReflow(); + ll.SetInFirstLetter(PR_FALSE); } else { // Pretend we are a span and reflow the child frame nsLineLayout* ll = aReflowState.mLineLayout; PRBool pushedFrame; - NS_ASSERTION(ll->GetFirstLetterStyleOK() || GetPrevInFlow(), - "First-in-flow first-letter should have first-letter style enabled in nsLineLayout!"); + ll->SetInFirstLetter(GetPrevContinuation() == nsnull); ll->BeginSpan(this, &aReflowState, bp.left, availSize.width); ll->ReflowFrame(kid, aReflowStatus, &aMetrics, pushedFrame); ll->EndSpan(this); + ll->SetInFirstLetter(PR_FALSE); } // Place and size the child and update the output metrics diff --git a/mozilla/layout/generic/nsLineLayout.h b/mozilla/layout/generic/nsLineLayout.h index ae3c470faf0..c6182f0c56e 100644 --- a/mozilla/layout/generic/nsLineLayout.h +++ b/mozilla/layout/generic/nsLineLayout.h @@ -153,7 +153,8 @@ protected: #define LL_NEEDBACKUP 0x00000400 #define LL_INFIRSTLINE 0x00000800 #define LL_GOTLINEBOX 0x00001000 -#define LL_LASTFLAG LL_GOTLINEBOX +#define LL_INFIRSTLETTER 0x00002000 +#define LL_LASTFLAG LL_INFIRSTLETTER PRUint16 mFlags; @@ -223,6 +224,14 @@ public: SetFlag(LL_FIRSTLETTERSTYLEOK, aSetting); } + PRBool GetInFirstLetter() const { + return GetFlag(LL_INFIRSTLETTER); + } + + void SetInFirstLetter(PRBool aSetting) { + SetFlag(LL_INFIRSTLETTER, aSetting); + } + PRBool GetInFirstLine() const { return GetFlag(LL_INFIRSTLINE); } diff --git a/mozilla/layout/generic/nsTextFrameThebes.cpp b/mozilla/layout/generic/nsTextFrameThebes.cpp index 56e34aa3bf6..e39fea52ca6 100644 --- a/mozilla/layout/generic/nsTextFrameThebes.cpp +++ b/mozilla/layout/generic/nsTextFrameThebes.cpp @@ -5518,10 +5518,10 @@ nsTextFrame::Reflow(nsPresContext* aPresContext, PRBool completedFirstLetter = PR_FALSE; // Layout dependent styles are a problem because we need to reconstruct // the gfxTextRun based on our layout. - if (lineLayout.GetFirstLetterStyleOK() || lineLayout.GetInFirstLine()) { + if (lineLayout.GetInFirstLetter() || lineLayout.GetInFirstLine()) { SetLength(maxContentLength); - if (lineLayout.GetFirstLetterStyleOK()) { + if (lineLayout.GetInFirstLetter()) { // floating first-letter boundaries are significant in textrun // construction, so clear the textrun out every time we hit a first-letter // and have changed our length (which controls the first-letter boundary) @@ -5531,7 +5531,18 @@ nsTextFrame::Reflow(nsPresContext* aPresContext, EnsureTextRun(ctx, lineContainer, lineLayout.GetLine(), &flowEndInTextRun); if (mTextRun) { - completedFirstLetter = FindFirstLetterRange(frag, mTextRun, offset, iter, &length); + if (lineLayout.GetFirstLetterStyleOK()) { + completedFirstLetter = + FindFirstLetterRange(frag, mTextRun, offset, iter, &length); + } else { + // We're in a first-letter frame's first in flow, so if there + // was a first-letter, we'd be it. However, for one reason + // or another (e.g., preformatted line break before this text), + // we're not actually supposed to have first-letter style. So + // just make a zero-length first-letter. + length = 0; + completedFirstLetter = PR_TRUE; + } if (length) { AddStateBits(TEXT_FIRST_LETTER); } @@ -5797,9 +5808,6 @@ nsTextFrame::Reflow(nsPresContext* aPresContext, lineLayout.NotifyOptionalBreakPosition(mContent, offset + length, PR_TRUE); } } - if (completedFirstLetter) { - lineLayout.SetFirstLetterStyleOK(PR_FALSE); - } // Compute reflow status aStatus = contentLength == maxContentLength diff --git a/mozilla/layout/reftests/first-letter/429968-1-ref.html b/mozilla/layout/reftests/first-letter/429968-1-ref.html new file mode 100644 index 00000000000..be914274734 --- /dev/null +++ b/mozilla/layout/reftests/first-letter/429968-1-ref.html @@ -0,0 +1,10 @@ + + + + + + +AB + diff --git a/mozilla/layout/reftests/first-letter/429968-1a.html b/mozilla/layout/reftests/first-letter/429968-1a.html new file mode 100644 index 00000000000..db0013832b5 --- /dev/null +++ b/mozilla/layout/reftests/first-letter/429968-1a.html @@ -0,0 +1,11 @@ + + + + + +
+AB
+ diff --git a/mozilla/layout/reftests/first-letter/429968-1b.html b/mozilla/layout/reftests/first-letter/429968-1b.html new file mode 100644 index 00000000000..72dd1095a3b --- /dev/null +++ b/mozilla/layout/reftests/first-letter/429968-1b.html @@ -0,0 +1,15 @@ + + + + + +
+AB
+ + diff --git a/mozilla/layout/reftests/first-letter/429968-2-ref.html b/mozilla/layout/reftests/first-letter/429968-2-ref.html new file mode 100644 index 00000000000..b541822a4d5 --- /dev/null +++ b/mozilla/layout/reftests/first-letter/429968-2-ref.html @@ -0,0 +1,10 @@ + + + + + +AB + diff --git a/mozilla/layout/reftests/first-letter/429968-2a.html b/mozilla/layout/reftests/first-letter/429968-2a.html new file mode 100644 index 00000000000..dd7d4091c34 --- /dev/null +++ b/mozilla/layout/reftests/first-letter/429968-2a.html @@ -0,0 +1,15 @@ + + + + + +
+AB
+ + diff --git a/mozilla/layout/reftests/first-letter/429968-2b.html b/mozilla/layout/reftests/first-letter/429968-2b.html new file mode 100644 index 00000000000..4f3daffa101 --- /dev/null +++ b/mozilla/layout/reftests/first-letter/429968-2b.html @@ -0,0 +1,15 @@ + + + + + +
+AB
+ + diff --git a/mozilla/layout/reftests/first-letter/429968-2c.html b/mozilla/layout/reftests/first-letter/429968-2c.html new file mode 100644 index 00000000000..65bb91d3db6 --- /dev/null +++ b/mozilla/layout/reftests/first-letter/429968-2c.html @@ -0,0 +1,15 @@ + + + + + +
+AB
+ + diff --git a/mozilla/layout/reftests/first-letter/reftest.list b/mozilla/layout/reftests/first-letter/reftest.list index 34a8442bfb5..2cca7b71e62 100644 --- a/mozilla/layout/reftests/first-letter/reftest.list +++ b/mozilla/layout/reftests/first-letter/reftest.list @@ -31,3 +31,8 @@ random == dynamic-3b.html dynamic-3-ref.html random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 329069-1.html 329069-1-ref.html # failure is font-dependent, may be related to bug 404848 == 342120-1.xhtml 342120-1-ref.xhtml == 379799-1.html 379799-1-ref.html +== 429968-1a.html 429968-1-ref.html +== 429968-1b.html 429968-1-ref.html +== 429968-2a.html 429968-2-ref.html +== 429968-2b.html 429968-2-ref.html +== 429968-2c.html 429968-2-ref.html