diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp
index 453aad09db9e..2c401dceafdd 100644
--- a/layout/generic/nsHTMLReflowState.cpp
+++ b/layout/generic/nsHTMLReflowState.cpp
@@ -191,6 +191,14 @@ nsHTMLReflowState::GetContainingBlockReflowState(const nsHTMLReflowState* aParen
// reflow state...
nsresult rv = aParentRS->frame->IsPercentageBase(isContainingBlock);
if (NS_SUCCEEDED(rv) && isContainingBlock) {
+ // a block inside a table cell needs to use the table cell
+ if (aParentRS->parentReflowState) {
+ nsCOMPtr fType;
+ aParentRS->parentReflowState->frame->GetFrameType(getter_AddRefs(fType));
+ if (nsLayoutAtoms::tableCellFrame == fType.get()) {
+ aParentRS = aParentRS->parentReflowState;
+ }
+ }
return aParentRS;
}
}
diff --git a/layout/html/base/src/nsHTMLReflowState.cpp b/layout/html/base/src/nsHTMLReflowState.cpp
index 453aad09db9e..2c401dceafdd 100644
--- a/layout/html/base/src/nsHTMLReflowState.cpp
+++ b/layout/html/base/src/nsHTMLReflowState.cpp
@@ -191,6 +191,14 @@ nsHTMLReflowState::GetContainingBlockReflowState(const nsHTMLReflowState* aParen
// reflow state...
nsresult rv = aParentRS->frame->IsPercentageBase(isContainingBlock);
if (NS_SUCCEEDED(rv) && isContainingBlock) {
+ // a block inside a table cell needs to use the table cell
+ if (aParentRS->parentReflowState) {
+ nsCOMPtr fType;
+ aParentRS->parentReflowState->frame->GetFrameType(getter_AddRefs(fType));
+ if (nsLayoutAtoms::tableCellFrame == fType.get()) {
+ aParentRS = aParentRS->parentReflowState;
+ }
+ }
return aParentRS;
}
}