bug 57828 - better handling of nowrap in table cell. sr=buster, r=attinasi.
This commit is contained in:
@@ -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.
|
||||
// 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();
|
||||
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) {
|
||||
// Nav and IE only honor the nowrap up to the style width, if present
|
||||
maxElemWidth = PR_MAX(maxElemWidth, styleWidth);
|
||||
}
|
||||
NS_RELEASE(cellContent);
|
||||
}
|
||||
else {
|
||||
maxElemWidth = PR_MAX(maxElemWidth, aMaxWidth);
|
||||
}
|
||||
}
|
||||
mPass1MaxElementSize.width = maxElemWidth;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
// 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();
|
||||
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) {
|
||||
// Nav and IE only honor the nowrap up to the style width, if present
|
||||
maxElemWidth = PR_MAX(maxElemWidth, styleWidth);
|
||||
}
|
||||
NS_RELEASE(cellContent);
|
||||
}
|
||||
else {
|
||||
maxElemWidth = PR_MAX(maxElemWidth, aMaxWidth);
|
||||
}
|
||||
}
|
||||
mPass1MaxElementSize.width = maxElemWidth;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user