From 8ff4467f7844567c8fe48b3feaf063781d95dcc0 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Thu, 27 Nov 2008 10:44:47 -0800 Subject: [PATCH] Bug 457398. Don't treat empty lines as the first line for text-indent or first-letter/first-line purposes. r+sr=dbaron --- layout/generic/nsBlockFrame.cpp | 4 ++++ layout/generic/nsBlockReflowState.h | 9 ++++++++- layout/reftests/bugs/457398-1-ref.html | 11 +++++++++++ layout/reftests/bugs/457398-1.html | 11 +++++++++++ layout/reftests/bugs/457398-2-ref.html | 11 +++++++++++ layout/reftests/bugs/457398-2.html | 11 +++++++++++ layout/reftests/bugs/reftest.list | 2 ++ 7 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 layout/reftests/bugs/457398-1-ref.html create mode 100644 layout/reftests/bugs/457398-1.html create mode 100644 layout/reftests/bugs/457398-2-ref.html create mode 100644 layout/reftests/bugs/457398-2.html diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 8e708d62926..48e4c8955e7 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -3375,6 +3375,8 @@ nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState& aState, impactedByFloats, PR_FALSE /*XXX isTopOfPage*/); + aState.SetFlag(BRS_LINE_LAYOUT_EMPTY, PR_FALSE); + // XXX Unfortunately we need to know this before reflowing the first // inline frame in the line. FIX ME. if ((0 == aLineLayout.GetLineNumber()) && @@ -3462,6 +3464,8 @@ nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState& aState, } } + aState.SetFlag(BRS_LINE_LAYOUT_EMPTY, aLineLayout.LineIsEmpty()); + // We only need to backup if the line isn't going to be reflowed again anyway PRBool needsBackup = aLineLayout.NeedsBackup() && (lineReflowStatus == LINE_REFLOW_STOP || lineReflowStatus == LINE_REFLOW_OK); diff --git a/layout/generic/nsBlockReflowState.h b/layout/generic/nsBlockReflowState.h index 8c2a49920bb..bc2acad0a58 100644 --- a/layout/generic/nsBlockReflowState.h +++ b/layout/generic/nsBlockReflowState.h @@ -58,6 +58,9 @@ #define BRS_HAVELINEADJACENTTOTOP 0x00000020 // Set when the block has the equivalent of NS_BLOCK_SPACE_MGR #define BRS_SPACE_MGR 0x00000040 +// Set when nsLineLayout::LineIsEmpty was true at the end of reflowing +// the current line +#define BRS_LINE_LAYOUT_EMPTY 0x00000080 #define BRS_ISOVERFLOWCONTAINER 0x00000100 #define BRS_LASTFLAG BRS_ISOVERFLOWCONTAINER @@ -164,7 +167,11 @@ public: void RecoverStateFrom(nsLineList::iterator aLine, nscoord aDeltaY); void AdvanceToNextLine() { - mLineNumber++; + if (GetFlag(BRS_LINE_LAYOUT_EMPTY)) { + SetFlag(BRS_LINE_LAYOUT_EMPTY, PR_FALSE); + } else { + mLineNumber++; + } } PRBool IsImpactedByFloat() const; diff --git a/layout/reftests/bugs/457398-1-ref.html b/layout/reftests/bugs/457398-1-ref.html new file mode 100644 index 00000000000..de5db31db13 --- /dev/null +++ b/layout/reftests/bugs/457398-1-ref.html @@ -0,0 +1,11 @@ + + + + +
Test
+
+
Test
+ + diff --git a/layout/reftests/bugs/457398-1.html b/layout/reftests/bugs/457398-1.html new file mode 100644 index 00000000000..4576e1d42e9 --- /dev/null +++ b/layout/reftests/bugs/457398-1.html @@ -0,0 +1,11 @@ + + + + +
Test
+ +
Test
+ + diff --git a/layout/reftests/bugs/457398-2-ref.html b/layout/reftests/bugs/457398-2-ref.html new file mode 100644 index 00000000000..25a03a0202b --- /dev/null +++ b/layout/reftests/bugs/457398-2-ref.html @@ -0,0 +1,11 @@ + + + + +
Test
+
+
Test
+ + diff --git a/layout/reftests/bugs/457398-2.html b/layout/reftests/bugs/457398-2.html new file mode 100644 index 00000000000..1951ce0aabc --- /dev/null +++ b/layout/reftests/bugs/457398-2.html @@ -0,0 +1,11 @@ + + + + +
Test
+ +
Test
+ + diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index b90639ae222..f366f1c399b 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -950,6 +950,8 @@ fails == 441259-2.html 441259-2-ref.html # bug 441400 fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == 456147.xul 456147-ref.html # bug 456147, but not caused by it == 456330-1.gif 456330-1-ref.png == 456484-1.html 456484-1-ref.html +== 457398-1.html 457398-1-ref.html +== 457398-2.html 457398-2-ref.html == 458487-1a.html 458487-1-ref.html == 458487-1b.html 458487-1-ref.html == 458487-1c.html 458487-1-ref.html