diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp index 276ff3d3c37..3c16fc4020c 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp @@ -104,27 +104,24 @@ nsTableCellFrame::AttributeChanged(nsIPresContext* aPresContext, return NS_OK; } -void nsTableCellFrame::SetPass1MaxElementSize(const nsSize& aMaxElementSize) +void nsTableCellFrame::SetPass1MaxElementSize(nscoord aMaxWidth, + const nsSize& aMaxElementSize) { mPass1MaxElementSize.height = aMaxElementSize.height; nscoord maxElemWidth = aMaxElementSize.width; - // the max elem width needs to be set to the max of aMaxElementSize.width and - // the width attribute if both nowrap and width are present on the cell. - const nsStylePosition* stylePosition; - GetStyleData(eStyleStruct_Position, ((const nsStyleStruct *&)stylePosition)); - if (stylePosition->mWidth.GetUnit() == eStyleUnit_Coord) { - nscoord styleWidth = stylePosition->mWidth.GetCoordValue(); - if (styleWidth > 0) { - nsIDOMHTMLTableCellElement* cellContent = nsnull; - nsresult rv = mContent->QueryInterface(NS_GET_IID(nsIDOMHTMLTableCellElement), (void **)&cellContent); - if (cellContent && NS_SUCCEEDED(rv)) { - PRBool nowrap = PR_FALSE; - cellContent->GetNoWrap(&nowrap); - if (nowrap) { - maxElemWidth = PR_MAX(maxElemWidth, styleWidth); - } - NS_RELEASE(cellContent); - } + // the max elem width needs to take into account a cell that is NOWRAP + const nsStyleText* styleText; + GetStyleData(eStyleStruct_Text, (const nsStyleStruct*&) styleText); + if (NS_STYLE_WHITESPACE_NOWRAP == styleText->mWhiteSpace) { + const nsStylePosition* stylePosition; + GetStyleData(eStyleStruct_Position, ((const nsStyleStruct *&)stylePosition)); + if (stylePosition->mWidth.GetUnit() == eStyleUnit_Coord) { + nscoord styleWidth = stylePosition->mWidth.GetCoordValue(); + // Nav and IE only honor the nowrap up to the style width, if present + maxElemWidth = PR_MAX(maxElemWidth, styleWidth); + } + else { + maxElemWidth = PR_MAX(maxElemWidth, aMaxWidth); } } mPass1MaxElementSize.width = maxElemWidth; diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.h b/mozilla/layout/html/table/src/nsTableCellFrame.h index 81a5df3c58c..54062378e81 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.h +++ b/mozilla/layout/html/table/src/nsTableCellFrame.h @@ -222,7 +222,8 @@ public: /** set the MaxElement size returned by this frame during its last reflow. * should never be called with a null MaxElementSize */ - virtual void SetPass1MaxElementSize(const nsSize & aMaxElementSize); + virtual void SetPass1MaxElementSize(nscoord aMaxWidth, + const nsSize& aMaxElementSize); PRBool GetContentEmpty(); void SetContentEmpty(PRBool aContentEmpty); diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.cpp b/mozilla/layout/html/table/src/nsTableRowFrame.cpp index 70625fe777f..1b1c11536c0 100644 --- a/mozilla/layout/html/table/src/nsTableRowFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowFrame.cpp @@ -970,7 +970,7 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext, aReflowState.tableFrame->InvalidateMaximumWidth(); } if (kidMaxElementSize) { - ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(*kidMaxElementSize); + ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(desiredSize.width, *kidMaxElementSize); } // XXX if we did an unconstrained reflow, do we need to do another one // there needs to be more test cases to show this @@ -1134,7 +1134,7 @@ nsTableRowFrame::InitialReflow(nsIPresContext* aPresContext, } ((nsTableCellFrame *)kidFrame)->SetMaximumWidth(kidSize.width); - ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize); + ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidSize.width, kidMaxElementSize); NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "unexpected child reflow status"); // Place the child @@ -1357,7 +1357,7 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext, // Update the cell layout data.. If the cell's maximum width changed, // then inform the table that its maximum width needs to be recomputed - ((nsTableCellFrame *)aNextFrame)->SetPass1MaxElementSize(kidMaxElementSize); + ((nsTableCellFrame *)aNextFrame)->SetPass1MaxElementSize(cellMet.width, kidMaxElementSize); if (cellMet.mFlags & NS_REFLOW_CALC_MAX_WIDTH) { ((nsTableCellFrame *)aNextFrame)->SetMaximumWidth(cellMet.mMaximumWidth); if (oldCellMaximumWidth != cellMet.mMaximumWidth) { diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index 276ff3d3c37..3c16fc4020c 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -104,27 +104,24 @@ nsTableCellFrame::AttributeChanged(nsIPresContext* aPresContext, return NS_OK; } -void nsTableCellFrame::SetPass1MaxElementSize(const nsSize& aMaxElementSize) +void nsTableCellFrame::SetPass1MaxElementSize(nscoord aMaxWidth, + const nsSize& aMaxElementSize) { mPass1MaxElementSize.height = aMaxElementSize.height; nscoord maxElemWidth = aMaxElementSize.width; - // the max elem width needs to be set to the max of aMaxElementSize.width and - // the width attribute if both nowrap and width are present on the cell. - const nsStylePosition* stylePosition; - GetStyleData(eStyleStruct_Position, ((const nsStyleStruct *&)stylePosition)); - if (stylePosition->mWidth.GetUnit() == eStyleUnit_Coord) { - nscoord styleWidth = stylePosition->mWidth.GetCoordValue(); - if (styleWidth > 0) { - nsIDOMHTMLTableCellElement* cellContent = nsnull; - nsresult rv = mContent->QueryInterface(NS_GET_IID(nsIDOMHTMLTableCellElement), (void **)&cellContent); - if (cellContent && NS_SUCCEEDED(rv)) { - PRBool nowrap = PR_FALSE; - cellContent->GetNoWrap(&nowrap); - if (nowrap) { - maxElemWidth = PR_MAX(maxElemWidth, styleWidth); - } - NS_RELEASE(cellContent); - } + // the max elem width needs to take into account a cell that is NOWRAP + const nsStyleText* styleText; + GetStyleData(eStyleStruct_Text, (const nsStyleStruct*&) styleText); + if (NS_STYLE_WHITESPACE_NOWRAP == styleText->mWhiteSpace) { + const nsStylePosition* stylePosition; + GetStyleData(eStyleStruct_Position, ((const nsStyleStruct *&)stylePosition)); + if (stylePosition->mWidth.GetUnit() == eStyleUnit_Coord) { + nscoord styleWidth = stylePosition->mWidth.GetCoordValue(); + // Nav and IE only honor the nowrap up to the style width, if present + maxElemWidth = PR_MAX(maxElemWidth, styleWidth); + } + else { + maxElemWidth = PR_MAX(maxElemWidth, aMaxWidth); } } mPass1MaxElementSize.width = maxElemWidth; diff --git a/mozilla/layout/tables/nsTableCellFrame.h b/mozilla/layout/tables/nsTableCellFrame.h index 81a5df3c58c..54062378e81 100644 --- a/mozilla/layout/tables/nsTableCellFrame.h +++ b/mozilla/layout/tables/nsTableCellFrame.h @@ -222,7 +222,8 @@ public: /** set the MaxElement size returned by this frame during its last reflow. * should never be called with a null MaxElementSize */ - virtual void SetPass1MaxElementSize(const nsSize & aMaxElementSize); + virtual void SetPass1MaxElementSize(nscoord aMaxWidth, + const nsSize& aMaxElementSize); PRBool GetContentEmpty(); void SetContentEmpty(PRBool aContentEmpty); diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp index 70625fe777f..1b1c11536c0 100644 --- a/mozilla/layout/tables/nsTableRowFrame.cpp +++ b/mozilla/layout/tables/nsTableRowFrame.cpp @@ -970,7 +970,7 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext, aReflowState.tableFrame->InvalidateMaximumWidth(); } if (kidMaxElementSize) { - ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(*kidMaxElementSize); + ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(desiredSize.width, *kidMaxElementSize); } // XXX if we did an unconstrained reflow, do we need to do another one // there needs to be more test cases to show this @@ -1134,7 +1134,7 @@ nsTableRowFrame::InitialReflow(nsIPresContext* aPresContext, } ((nsTableCellFrame *)kidFrame)->SetMaximumWidth(kidSize.width); - ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize); + ((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidSize.width, kidMaxElementSize); NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "unexpected child reflow status"); // Place the child @@ -1357,7 +1357,7 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext, // Update the cell layout data.. If the cell's maximum width changed, // then inform the table that its maximum width needs to be recomputed - ((nsTableCellFrame *)aNextFrame)->SetPass1MaxElementSize(kidMaxElementSize); + ((nsTableCellFrame *)aNextFrame)->SetPass1MaxElementSize(cellMet.width, kidMaxElementSize); if (cellMet.mFlags & NS_REFLOW_CALC_MAX_WIDTH) { ((nsTableCellFrame *)aNextFrame)->SetMaximumWidth(cellMet.mMaximumWidth); if (oldCellMaximumWidth != cellMet.mMaximumWidth) {