From eefaa620cb93b8a4d72be814d0961ef9338a8e2b Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Tue, 15 Apr 2003 19:28:06 +0000 Subject: [PATCH] Make iframes and objects obey CSS max-width/height and min-width/height if their sizes are unconstrained. Bug 181875, r+sr=roc+moz git-svn-id: svn://10.0.0.236/trunk@141192 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsFrameFrame.cpp | 8 ++++++-- mozilla/layout/generic/nsObjectFrame.cpp | 16 ++++++++++++---- mozilla/layout/html/base/src/nsObjectFrame.cpp | 16 ++++++++++++---- .../layout/html/document/src/nsFrameFrame.cpp | 8 ++++++-- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 3aa7c6c9a57..2e528be01d3 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -457,13 +457,17 @@ nsHTMLFrameOuterFrame::GetDesiredSize(nsIPresContext* aPresContext, aDesiredSize.width = aReflowState.mComputedWidth; } else { - aDesiredSize.width = NSIntPixelsToTwips(300, p2t); + aDesiredSize.width = PR_MIN(PR_MAX(NSIntPixelsToTwips(300, p2t), + aReflowState.mComputedMinWidth), + aReflowState.mComputedMaxWidth); } if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) { aDesiredSize.height = aReflowState.mComputedHeight; } else { - aDesiredSize.height = NSIntPixelsToTwips(150, p2t); + aDesiredSize.height = PR_MIN(PR_MAX(NSIntPixelsToTwips(150, p2t), + aReflowState.mComputedMinHeight), + aReflowState.mComputedMaxHeight); } aDesiredSize.ascent = aDesiredSize.height; aDesiredSize.descent = 0; diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index f9f1574a9e7..57193c89575 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -921,10 +921,14 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext, float p2t; aPresContext->GetScaledPixelsToTwips(&p2t); if (aMetrics.width == NS_UNCONSTRAINEDSIZE) { - aMetrics.width = NSIntPixelsToTwips(EMBED_DEF_WIDTH, p2t); + aMetrics.width = PR_MIN(PR_MAX(NSIntPixelsToTwips(EMBED_DEF_WIDTH, p2t), + aReflowState.mComputedMinWidth), + aReflowState.mComputedMaxWidth); } if (aMetrics.height == NS_UNCONSTRAINEDSIZE) { - aMetrics.height = NSIntPixelsToTwips(EMBED_DEF_HEIGHT, p2t); + aMetrics.height = PR_MIN(PR_MAX(NSIntPixelsToTwips(EMBED_DEF_HEIGHT, p2t), + aReflowState.mComputedMinHeight), + aReflowState.mComputedMaxHeight); } } @@ -932,7 +936,9 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext, // nothing to go on (no width set, no information from the plugin, nothing). // Make up a number. if (aMetrics.width == NS_UNCONSTRAINEDSIZE) { - aMetrics.width = 0; + aMetrics.width = + (aReflowState.mComputedMinWidth != NS_UNCONSTRAINEDSIZE) ? + aReflowState.mComputedMinWidth : 0; } // At this point, the height has an unconstrained value only in two cases: @@ -940,7 +946,9 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext, // b) We have no height information at all. // In either case, we have to make up a number. if (aMetrics.height == NS_UNCONSTRAINEDSIZE) { - aMetrics.height = 0; + aMetrics.height = + (aReflowState.mComputedMinHeight != NS_UNCONSTRAINEDSIZE) ? + aReflowState.mComputedMinHeight : 0; } // XXXbz don't add in the border and padding, because we screw up our diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index f9f1574a9e7..57193c89575 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -921,10 +921,14 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext, float p2t; aPresContext->GetScaledPixelsToTwips(&p2t); if (aMetrics.width == NS_UNCONSTRAINEDSIZE) { - aMetrics.width = NSIntPixelsToTwips(EMBED_DEF_WIDTH, p2t); + aMetrics.width = PR_MIN(PR_MAX(NSIntPixelsToTwips(EMBED_DEF_WIDTH, p2t), + aReflowState.mComputedMinWidth), + aReflowState.mComputedMaxWidth); } if (aMetrics.height == NS_UNCONSTRAINEDSIZE) { - aMetrics.height = NSIntPixelsToTwips(EMBED_DEF_HEIGHT, p2t); + aMetrics.height = PR_MIN(PR_MAX(NSIntPixelsToTwips(EMBED_DEF_HEIGHT, p2t), + aReflowState.mComputedMinHeight), + aReflowState.mComputedMaxHeight); } } @@ -932,7 +936,9 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext, // nothing to go on (no width set, no information from the plugin, nothing). // Make up a number. if (aMetrics.width == NS_UNCONSTRAINEDSIZE) { - aMetrics.width = 0; + aMetrics.width = + (aReflowState.mComputedMinWidth != NS_UNCONSTRAINEDSIZE) ? + aReflowState.mComputedMinWidth : 0; } // At this point, the height has an unconstrained value only in two cases: @@ -940,7 +946,9 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext, // b) We have no height information at all. // In either case, we have to make up a number. if (aMetrics.height == NS_UNCONSTRAINEDSIZE) { - aMetrics.height = 0; + aMetrics.height = + (aReflowState.mComputedMinHeight != NS_UNCONSTRAINEDSIZE) ? + aReflowState.mComputedMinHeight : 0; } // XXXbz don't add in the border and padding, because we screw up our diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 3aa7c6c9a57..2e528be01d3 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -457,13 +457,17 @@ nsHTMLFrameOuterFrame::GetDesiredSize(nsIPresContext* aPresContext, aDesiredSize.width = aReflowState.mComputedWidth; } else { - aDesiredSize.width = NSIntPixelsToTwips(300, p2t); + aDesiredSize.width = PR_MIN(PR_MAX(NSIntPixelsToTwips(300, p2t), + aReflowState.mComputedMinWidth), + aReflowState.mComputedMaxWidth); } if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) { aDesiredSize.height = aReflowState.mComputedHeight; } else { - aDesiredSize.height = NSIntPixelsToTwips(150, p2t); + aDesiredSize.height = PR_MIN(PR_MAX(NSIntPixelsToTwips(150, p2t), + aReflowState.mComputedMinHeight), + aReflowState.mComputedMaxHeight); } aDesiredSize.ascent = aDesiredSize.height; aDesiredSize.descent = 0;