Bug 372768: {inc}Setting nowrap attribute dynamically does not change layout like it should. r=bzbarsky,sr=dbaron.
--- a/layout/tables/BasicTableLayoutStrategy.cpp
+++ b/layout/tables/BasicTableLayoutStrategy.cpp
@@ -123,16 +123,18 @@ GetWidthInfo(nsIRenderingContext *aRende
nsStyleUnit unit = aStylePos->mWidth.GetUnit();
if (unit == eStyleUnit_Coord || unit == eStyleUnit_Chars) {
hasSpecifiedWidth = PR_TRUE;
nscoord w = nsLayoutUtils::ComputeWidthValue(aRenderingContext,
aFrame, 0, 0, 0, aStylePos->mWidth);
// Quirk: A cell with "nowrap" set and a coord value for the
// width which is bigger than the intrinsic minimum width uses
// that coord value as the minimum width.
+ // This is kept up-to-date with dynamic chnages to nowrap by code in
+ // nsTableCellFrame::AttributeChanged
if (aIsCell && w > minCoord &&
aFrame->PresContext()->CompatibilityMode() ==
eCompatibility_NavQuirks &&
aFrame->GetContent()->HasAttr(kNameSpaceID_None,
nsGkAtoms::nowrap)) {
minCoord = w;
}
prefCoord = PR_MAX(w, minCoord);
--- a/layout/tables/nsTableCellFrame.cpp
+++ b/layout/tables/nsTableCellFrame.cpp
@@ -216,16 +216,23 @@ nsTableCellFrame::GetColIndex(PRInt32 &a
}
}
NS_IMETHODIMP
nsTableCellFrame::AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)
{
+ // We need to recalculate in this case because of the nowrap quirk in
+ // BasicTableLayoutStrategy
+ if (aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::nowrap &&
+ PresContext()->CompatibilityMode() == eCompatibility_NavQuirks) {
+ PresContext()->PresShell()->
+ FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_IS_DIRTY);
+ }
// let the table frame decide what to do
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
if (tableFrame) {
tableFrame->AttributeChangedFor(this, mContent, aAttribute);
}
return NS_OK;
}