diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp
index d1fac274114..1618d3d2d8d 100644
--- a/mozilla/layout/generic/nsFrame.cpp
+++ b/mozilla/layout/generic/nsFrame.cpp
@@ -5463,10 +5463,15 @@ GetCorrectedParent(nsPresContext* aPresContext, nsIFrame* aFrame,
if (!parent) {
*aSpecialParent = nsnull;
} else {
- *aSpecialParent =
- nsFrame::CorrectStyleParentFrame(parent,
- aFrame->GetStyleContext()->
- GetPseudoType());
+ nsIAtom* pseudo = aFrame->GetStyleContext()->GetPseudoType();
+ // Outer tables are always anon boxes; if we're in here for an outer
+ // table, that actually means its the _inner_ table that wants to
+ // know its parent. So get the pseudo of the inner in that case.
+ if (pseudo == nsCSSAnonBoxes::tableOuter) {
+ pseudo =
+ aFrame->GetFirstChild(nsnull)->GetStyleContext()->GetPseudoType();
+ }
+ *aSpecialParent = nsFrame::CorrectStyleParentFrame(parent, pseudo);
}
return NS_OK;
diff --git a/mozilla/layout/reftests/bugs/377603-1-ref.html b/mozilla/layout/reftests/bugs/377603-1-ref.html
new file mode 100644
index 00000000000..a87cdb7891d
--- /dev/null
+++ b/mozilla/layout/reftests/bugs/377603-1-ref.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mozilla/layout/reftests/bugs/377603-1.html b/mozilla/layout/reftests/bugs/377603-1.html
new file mode 100644
index 00000000000..e45672e5ebe
--- /dev/null
+++ b/mozilla/layout/reftests/bugs/377603-1.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mozilla/layout/reftests/bugs/reftest.list b/mozilla/layout/reftests/bugs/reftest.list
index a84d2ab7e9a..42a3c52f484 100644
--- a/mozilla/layout/reftests/bugs/reftest.list
+++ b/mozilla/layout/reftests/bugs/reftest.list
@@ -216,3 +216,4 @@ fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == 372037-1.html 372037-1-ref.html # bug 3
== 374038-2.xul 374038-2-ref.xul
== 374193-1.xhtml about:blank
fails == 376484-1.html 376484-1-ref.html
+== 377603-1.html 377603-1-ref.html