diff --git a/layout/generic/nsFirstLetterFrame.cpp b/layout/generic/nsFirstLetterFrame.cpp
index 699c58387e6a..a23a12408655 100644
--- a/layout/generic/nsFirstLetterFrame.cpp
+++ b/layout/generic/nsFirstLetterFrame.cpp
@@ -226,6 +226,15 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
aMetrics.SetSize(wm, convertedSize);
aMetrics.SetBlockStartAscent(kidMetrics.BlockStartAscent() +
bp.BStart(wm));
+
+ // Ensure that the overflow rect contains the child textframe's
+ // overflow rect.
+ // Note that if this is floating, the overline/underline drawable
+ // area is in the overflow rect of the child textframe.
+ aMetrics.UnionOverflowAreasWithDesiredBounds();
+ ConsiderChildOverflow(aMetrics.mOverflowAreas, kid);
+
+ FinishAndStoreOverflow(&aMetrics);
}
else {
// Pretend we are a span and reflow the child frame
@@ -247,12 +256,6 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
nsLayoutUtils::SetBSizeFromFontMetrics(this, aMetrics, bp, lineWM, wm);
}
- // Ensure that the overflow rect contains the child textframe's overflow rect.
- // Note that if this is floating, the overline/underline drawable area is in
- // the overflow rect of the child textframe.
- aMetrics.UnionOverflowAreasWithDesiredBounds();
- ConsiderChildOverflow(aMetrics.mOverflowAreas, kid);
-
if (!NS_INLINE_IS_BREAK_BEFORE(aReflowStatus)) {
// Create a continuation or remove existing continuations based on
// the reflow completion status.
@@ -287,8 +290,6 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
}
}
- FinishAndStoreOverflow(&aMetrics);
-
NS_FRAME_SET_TRUNCATION(aReflowStatus, aReflowState, aMetrics);
}
diff --git a/layout/reftests/first-letter/overflow-float-nooverflow-ref.html b/layout/reftests/first-letter/overflow-float-nooverflow-ref.html
new file mode 100644
index 000000000000..fad9f0e63d40
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-float-nooverflow-ref.html
@@ -0,0 +1,14 @@
+
::first-letter and overflow
+
+
+Hello world, testing, testing, testing, testing
diff --git a/layout/reftests/first-letter/overflow-float-nooverflow.html b/layout/reftests/first-letter/overflow-float-nooverflow.html
new file mode 100644
index 000000000000..ff9020344346
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-float-nooverflow.html
@@ -0,0 +1,15 @@
+::first-letter and overflow
+
+
+Hello world, testing, testing, testing, testing
diff --git a/layout/reftests/first-letter/overflow-float-overflow-notref.html b/layout/reftests/first-letter/overflow-float-overflow-notref.html
new file mode 100644
index 000000000000..7eb0bca37a76
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-float-overflow-notref.html
@@ -0,0 +1,14 @@
+::first-letter and overflow
+
+
+Hello
diff --git a/layout/reftests/first-letter/overflow-float-overflow.html b/layout/reftests/first-letter/overflow-float-overflow.html
new file mode 100644
index 000000000000..0d0d1ee933bb
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-float-overflow.html
@@ -0,0 +1,15 @@
+::first-letter and overflow
+
+
+Hello
diff --git a/layout/reftests/first-letter/overflow-inline-nooverflow-ref.html b/layout/reftests/first-letter/overflow-inline-nooverflow-ref.html
new file mode 100644
index 000000000000..856c3a8a07be
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-inline-nooverflow-ref.html
@@ -0,0 +1,14 @@
+::first-letter and overflow
+
+
+Hello world, testing, testing, testing, testing
diff --git a/layout/reftests/first-letter/overflow-inline-nooverflow.html b/layout/reftests/first-letter/overflow-inline-nooverflow.html
new file mode 100644
index 000000000000..7a48a3c4c0d0
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-inline-nooverflow.html
@@ -0,0 +1,15 @@
+::first-letter and overflow
+
+
+Hello world, testing, testing, testing, testing
diff --git a/layout/reftests/first-letter/overflow-inline-overflow-notref.html b/layout/reftests/first-letter/overflow-inline-overflow-notref.html
new file mode 100644
index 000000000000..772d835266ff
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-inline-overflow-notref.html
@@ -0,0 +1,14 @@
+::first-letter and overflow
+
+
+Hello
diff --git a/layout/reftests/first-letter/overflow-inline-overflow-ref.html b/layout/reftests/first-letter/overflow-inline-overflow-ref.html
new file mode 100644
index 000000000000..196168c804ae
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-inline-overflow-ref.html
@@ -0,0 +1,15 @@
+::first-letter and overflow
+
+
+Hello
diff --git a/layout/reftests/first-letter/overflow-inline-overflow.html b/layout/reftests/first-letter/overflow-inline-overflow.html
new file mode 100644
index 000000000000..a7b95c1e9b0f
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-inline-overflow.html
@@ -0,0 +1,15 @@
+::first-letter and overflow
+
+
+Hello
diff --git a/layout/reftests/first-letter/reftest.list b/layout/reftests/first-letter/reftest.list
index defd14ebeccd..62247aaa8918 100644
--- a/layout/reftests/first-letter/reftest.list
+++ b/layout/reftests/first-letter/reftest.list
@@ -67,3 +67,8 @@ fails-if(winWidget||cocoaWidget) == 617869-1.html 617869-1-ref.html
fails-if(gtk2Widget) random-if(winWidget&&!d2d) == font-text-styles-floater.html font-text-styles-floater-ref.html # bug 992846
== inline-height-empty.html inline-height-empty-ref.html
HTTP(..) == indic-clusters-1.html indic-clusters-1-ref.html
+== overflow-float-nooverflow.html overflow-float-nooverflow-ref.html
+== overflow-float-overflow.html overflow-float-overflow-notref.html
+== overflow-inline-nooverflow.html overflow-inline-nooverflow-ref.html
+!= overflow-inline-overflow.html overflow-inline-overflow-notref.html
+== overflow-inline-overflow.html overflow-inline-overflow-ref.html