Bug 372768: {inc}Setting nowrap attribute dynamically does not change layout like it should. r=bzbarsky,sr=dbaron.
authorsharparrow1@yahoo.com
Sun, 01 Jul 2007 11:42:18 -0700
changeset 3000 854f785cdee2c9ed74a26836dfba7b526aad5345
parent 2999 c09e02d9725f45be11c551e49a7bde6fe7acefc8
child 3001 23421ddbc416ec2d7601f7d8ef2ecb62b7a08729
push idunknown
push userunknown
push dateunknown
reviewersbzbarsky, dbaron
bugs372768
milestone1.9a6pre
Bug 372768: {inc}Setting nowrap attribute dynamically does not change layout like it should. r=bzbarsky,sr=dbaron.
layout/tables/BasicTableLayoutStrategy.cpp
layout/tables/nsTableCellFrame.cpp
--- 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;
 }