From ef08d853f8c0271ea41ccfc513bef1c34d383d93 Mon Sep 17 00:00:00 2001 From: "buster%netscape.com" Date: Mon, 3 Aug 1998 20:27:59 +0000 Subject: [PATCH] fixed this case: (an image tag with no width attribute) inside (a specified-width column) inside (a nested table with specified width) inside (an auto-width column) inside (a specified-width table). Got that? The problem was that we we not setting state correctly during incremental reflow when the image returned its proper metrics after giving default metrics that were for its ALT text. git-svn-id: svn://10.0.0.236/trunk@7132 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/table/src/BasicTableLayoutStrategy.cpp | 16 +++++++++++++++- .../layout/html/table/src/nsTableCellFrame.cpp | 6 ++---- mozilla/layout/html/table/src/nsTableFrame.cpp | 5 +++++ .../layout/html/table/src/nsTableRowFrame.cpp | 8 +++++--- .../layout/tables/BasicTableLayoutStrategy.cpp | 16 +++++++++++++++- mozilla/layout/tables/nsTableCellFrame.cpp | 6 ++---- mozilla/layout/tables/nsTableFrame.cpp | 5 +++++ mozilla/layout/tables/nsTableRowFrame.cpp | 8 +++++--- 8 files changed, 54 insertions(+), 16 deletions(-) diff --git a/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp b/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp index 5022e964847..dee15836d66 100644 --- a/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp +++ b/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp @@ -141,7 +141,20 @@ PRBool BasicTableLayoutStrategy::Initialize(nsSize* aMaxElementSize) if (nsnull!=aMaxElementSize) { aMaxElementSize->height = 0; - aMaxElementSize->width = mMinTableWidth; + + // begin REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! + nsIFrame * parent = nsnull; + mTableFrame->GetGeometricParent(parent); + const nsStylePosition* tablePosition; + parent->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)tablePosition)); + // end REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! + nsMargin borderPadding; + const nsStyleSpacing* spacing; + if (tablePosition->mWidth.GetUnit()==eStyleUnit_Coord) + aMaxElementSize->width = tablePosition->mWidth.GetCoordValue(); + else + aMaxElementSize->width = mMinTableWidth; + if (PR_TRUE==gsDebug) printf("BTLS::Init setting aMaxElementSize->width = %d\n", aMaxElementSize->width); } @@ -302,6 +315,7 @@ PRBool BasicTableLayoutStrategy::AssignPreliminaryColumnWidths() nsSize cellDesiredSize = cellFrame->GetPass1DesiredSize(); nscoord cellDesiredWidth = cellDesiredSize.width; nscoord cellMinWidth = cellMinSize.width; + if (1==colSpan) { if (0==minColContentWidth) diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp index 45247adb7a7..f99a50e6c6b 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp @@ -310,13 +310,11 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext, if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT) { if (nsnull!=pMaxElementSize) - printf(" %p cellFrame child returned desiredSize=%d,%d,\ - and maxElementSize=%d,%d\n", + printf(" %p cellFrame child returned desiredSize=%d,%d, and maxElementSize=%d,%d\n", this, kidSize.width, kidSize.height, pMaxElementSize->width, pMaxElementSize->height); else - printf(" %p cellFrame child returned desiredSize=%d,%d,\ - and maxElementSize=nsnull\n", + printf(" %p cellFrame child returned desiredSize=%d,%d, and maxElementSize=nsnull\n", this, kidSize.width, kidSize.height); } diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index 4c16f63c6c3..bfef44df0d7 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -1651,6 +1651,11 @@ void nsTableFrame::PlaceChild(nsIPresContext* aPresContext, aState.availSize.height -= aKidRect.height; } + if (nsnull!=aMaxElementSize) { + aMaxElementSize->width = aKidMaxElementSize.width; + aMaxElementSize->height = aKidMaxElementSize.height; + } + // If this is a footer row group, add it to the list of footer row groups const nsStyleDisplay *childDisplay; aKidFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay)); diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.cpp b/mozilla/layout/html/table/src/nsTableRowFrame.cpp index bc570e5ac4c..12767c31369 100644 --- a/mozilla/layout/html/table/src/nsTableRowFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowFrame.cpp @@ -576,8 +576,8 @@ nsTableRowFrame::InitialReflow(nsIPresContext& aPresContext, if (gsDebug1) printf ("%p InitR: avail=%d\n", this, kidAvailSize.width); status = ReflowChild(kidFrame, &aPresContext, kidSize, kidReflowState); if (gsDebug1) - printf ("%p Initial Reflow: desired=%d, MES=%d\n", - this, kidSize.width, kidMaxElementSize.width); + printf ("TR %p for cell %p Initial Reflow: desired=%d, MES=%d\n", + this, kidFrame, kidSize.width, kidMaxElementSize.width); ((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(kidSize); ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize); NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected child reflow status"); @@ -785,7 +785,9 @@ nsresult nsTableRowFrame::IncrementalReflow(nsIPresContext& aPresContext, kidReflowState.reflowCommand = nsnull; kidReflowState.maxSize.width = NS_UNCONSTRAINEDSIZE; status = ReflowChild(kidFrame, &aPresContext, desiredSize, kidReflowState); - + if (gsDebug1) + printf ("TR %p for cell %p Incremental Reflow: desired=%d, MES=%d\n", + this, kidFrame, desiredSize.width, kidMaxElementSize.width); // Update the cell layout data. ((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(desiredSize); ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize); diff --git a/mozilla/layout/tables/BasicTableLayoutStrategy.cpp b/mozilla/layout/tables/BasicTableLayoutStrategy.cpp index 5022e964847..dee15836d66 100644 --- a/mozilla/layout/tables/BasicTableLayoutStrategy.cpp +++ b/mozilla/layout/tables/BasicTableLayoutStrategy.cpp @@ -141,7 +141,20 @@ PRBool BasicTableLayoutStrategy::Initialize(nsSize* aMaxElementSize) if (nsnull!=aMaxElementSize) { aMaxElementSize->height = 0; - aMaxElementSize->width = mMinTableWidth; + + // begin REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! + nsIFrame * parent = nsnull; + mTableFrame->GetGeometricParent(parent); + const nsStylePosition* tablePosition; + parent->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)tablePosition)); + // end REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! + nsMargin borderPadding; + const nsStyleSpacing* spacing; + if (tablePosition->mWidth.GetUnit()==eStyleUnit_Coord) + aMaxElementSize->width = tablePosition->mWidth.GetCoordValue(); + else + aMaxElementSize->width = mMinTableWidth; + if (PR_TRUE==gsDebug) printf("BTLS::Init setting aMaxElementSize->width = %d\n", aMaxElementSize->width); } @@ -302,6 +315,7 @@ PRBool BasicTableLayoutStrategy::AssignPreliminaryColumnWidths() nsSize cellDesiredSize = cellFrame->GetPass1DesiredSize(); nscoord cellDesiredWidth = cellDesiredSize.width; nscoord cellMinWidth = cellMinSize.width; + if (1==colSpan) { if (0==minColContentWidth) diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index 45247adb7a7..f99a50e6c6b 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -310,13 +310,11 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext, if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT) { if (nsnull!=pMaxElementSize) - printf(" %p cellFrame child returned desiredSize=%d,%d,\ - and maxElementSize=%d,%d\n", + printf(" %p cellFrame child returned desiredSize=%d,%d, and maxElementSize=%d,%d\n", this, kidSize.width, kidSize.height, pMaxElementSize->width, pMaxElementSize->height); else - printf(" %p cellFrame child returned desiredSize=%d,%d,\ - and maxElementSize=nsnull\n", + printf(" %p cellFrame child returned desiredSize=%d,%d, and maxElementSize=nsnull\n", this, kidSize.width, kidSize.height); } diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index 4c16f63c6c3..bfef44df0d7 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -1651,6 +1651,11 @@ void nsTableFrame::PlaceChild(nsIPresContext* aPresContext, aState.availSize.height -= aKidRect.height; } + if (nsnull!=aMaxElementSize) { + aMaxElementSize->width = aKidMaxElementSize.width; + aMaxElementSize->height = aKidMaxElementSize.height; + } + // If this is a footer row group, add it to the list of footer row groups const nsStyleDisplay *childDisplay; aKidFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay)); diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp index bc570e5ac4c..12767c31369 100644 --- a/mozilla/layout/tables/nsTableRowFrame.cpp +++ b/mozilla/layout/tables/nsTableRowFrame.cpp @@ -576,8 +576,8 @@ nsTableRowFrame::InitialReflow(nsIPresContext& aPresContext, if (gsDebug1) printf ("%p InitR: avail=%d\n", this, kidAvailSize.width); status = ReflowChild(kidFrame, &aPresContext, kidSize, kidReflowState); if (gsDebug1) - printf ("%p Initial Reflow: desired=%d, MES=%d\n", - this, kidSize.width, kidMaxElementSize.width); + printf ("TR %p for cell %p Initial Reflow: desired=%d, MES=%d\n", + this, kidFrame, kidSize.width, kidMaxElementSize.width); ((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(kidSize); ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize); NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected child reflow status"); @@ -785,7 +785,9 @@ nsresult nsTableRowFrame::IncrementalReflow(nsIPresContext& aPresContext, kidReflowState.reflowCommand = nsnull; kidReflowState.maxSize.width = NS_UNCONSTRAINEDSIZE; status = ReflowChild(kidFrame, &aPresContext, desiredSize, kidReflowState); - + if (gsDebug1) + printf ("TR %p for cell %p Incremental Reflow: desired=%d, MES=%d\n", + this, kidFrame, desiredSize.width, kidMaxElementSize.width); // Update the cell layout data. ((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(desiredSize); ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize);