From cf5fed63ad81701735dad9890e93cb7f512055ed Mon Sep 17 00:00:00 2001 From: "alexsavulov%netscape.com" Date: Thu, 24 Jan 2002 01:30:50 +0000 Subject: [PATCH] fix for bug 70972 (object element does not respect CSS width and height for non-plugins) r= peter lubczynski sr= attinasi --- layout/generic/nsObjectFrame.cpp | 71 ++++++++++---------------- layout/html/base/src/nsObjectFrame.cpp | 71 ++++++++++---------------- 2 files changed, 52 insertions(+), 90 deletions(-) diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 201a5c83b8e7..7c4ba8b53ae9 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -1372,56 +1372,37 @@ nsObjectFrame::HandleChild(nsIPresContext* aPresContext, nsReflowStatus& aStatus, nsIFrame* child) { - nsSize availSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); - nsHTMLReflowMetrics kidDesiredSize(nsnull); + nsSize availSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); + nsHTMLReflowMetrics kidDesiredSize(nsnull); - nsReflowReason reflowReason; - nsFrameState frameState; - child->GetFrameState(&frameState); - if (frameState & NS_FRAME_FIRST_REFLOW) - reflowReason = eReflowReason_Initial; - else - reflowReason = eReflowReason_Resize; + nsReflowReason reflowReason; + nsFrameState frameState; + child->GetFrameState(&frameState); + if (frameState & NS_FRAME_FIRST_REFLOW) + reflowReason = eReflowReason_Initial; + else + reflowReason = eReflowReason_Resize; - nsHTMLReflowState kidReflowState(aPresContext, aReflowState, child, - availSize, reflowReason); + nsHTMLReflowState kidReflowState(aPresContext, aReflowState, child, + availSize, reflowReason); - nsReflowStatus status; - - if(PR_TRUE)//reflowReason == eReflowReason_Initial) - { - kidDesiredSize.width = NS_UNCONSTRAINEDSIZE; - kidDesiredSize.height = NS_UNCONSTRAINEDSIZE; - } - - // adjust kidReflowState - nsIHTMLContent* hc = nsnull; - mContent->QueryInterface(NS_GET_IID(nsIHTMLContent), (void**) &hc); - - if(hc != nsnull) - { - float p2t; - aPresContext->GetScaledPixelsToTwips(&p2t); - - nsHTMLValue val; - if(NS_CONTENT_ATTR_HAS_VALUE == hc->GetHTMLAttribute(nsHTMLAtoms::width, val)) - { - if(eHTMLUnit_Pixel == val.GetUnit()) - { - nscoord width = val.GetPixelValue(); - kidReflowState.mComputedWidth = NSIntPixelsToTwips(width, p2t); - } - } - if(NS_CONTENT_ATTR_HAS_VALUE == hc->GetHTMLAttribute(nsHTMLAtoms::height, val)) - { - if(eHTMLUnit_Pixel == val.GetUnit()) - { - nscoord height = val.GetPixelValue(); - kidReflowState.mComputedHeight = NSIntPixelsToTwips(height, p2t); - } - } + if(kidReflowState.mStylePosition->mWidth.GetUnit() == eStyleUnit_Coord || + kidReflowState.mStylePosition->mWidth.GetUnit() == eStyleUnit_Percent) { + //the object frame has already calculated the constraints + kidReflowState.mComputedWidth = aMetrics.width; } + if(kidReflowState.mStylePosition->mHeight.GetUnit() == eStyleUnit_Coord || + kidReflowState.mStylePosition->mHeight.GetUnit() == eStyleUnit_Percent) { + //the object frame has already calculated the constraints + kidReflowState.mComputedHeight = aMetrics.height; + } + + nsReflowStatus status; + + kidDesiredSize.width = NS_UNCONSTRAINEDSIZE; + kidDesiredSize.height = NS_UNCONSTRAINEDSIZE; + ReflowChild(child, aPresContext, kidDesiredSize, kidReflowState, 0, 0, 0, status); FinishReflowChild(child, aPresContext, &kidReflowState, kidDesiredSize, 0, 0, 0); diff --git a/layout/html/base/src/nsObjectFrame.cpp b/layout/html/base/src/nsObjectFrame.cpp index 201a5c83b8e7..7c4ba8b53ae9 100644 --- a/layout/html/base/src/nsObjectFrame.cpp +++ b/layout/html/base/src/nsObjectFrame.cpp @@ -1372,56 +1372,37 @@ nsObjectFrame::HandleChild(nsIPresContext* aPresContext, nsReflowStatus& aStatus, nsIFrame* child) { - nsSize availSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); - nsHTMLReflowMetrics kidDesiredSize(nsnull); + nsSize availSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); + nsHTMLReflowMetrics kidDesiredSize(nsnull); - nsReflowReason reflowReason; - nsFrameState frameState; - child->GetFrameState(&frameState); - if (frameState & NS_FRAME_FIRST_REFLOW) - reflowReason = eReflowReason_Initial; - else - reflowReason = eReflowReason_Resize; + nsReflowReason reflowReason; + nsFrameState frameState; + child->GetFrameState(&frameState); + if (frameState & NS_FRAME_FIRST_REFLOW) + reflowReason = eReflowReason_Initial; + else + reflowReason = eReflowReason_Resize; - nsHTMLReflowState kidReflowState(aPresContext, aReflowState, child, - availSize, reflowReason); + nsHTMLReflowState kidReflowState(aPresContext, aReflowState, child, + availSize, reflowReason); - nsReflowStatus status; - - if(PR_TRUE)//reflowReason == eReflowReason_Initial) - { - kidDesiredSize.width = NS_UNCONSTRAINEDSIZE; - kidDesiredSize.height = NS_UNCONSTRAINEDSIZE; - } - - // adjust kidReflowState - nsIHTMLContent* hc = nsnull; - mContent->QueryInterface(NS_GET_IID(nsIHTMLContent), (void**) &hc); - - if(hc != nsnull) - { - float p2t; - aPresContext->GetScaledPixelsToTwips(&p2t); - - nsHTMLValue val; - if(NS_CONTENT_ATTR_HAS_VALUE == hc->GetHTMLAttribute(nsHTMLAtoms::width, val)) - { - if(eHTMLUnit_Pixel == val.GetUnit()) - { - nscoord width = val.GetPixelValue(); - kidReflowState.mComputedWidth = NSIntPixelsToTwips(width, p2t); - } - } - if(NS_CONTENT_ATTR_HAS_VALUE == hc->GetHTMLAttribute(nsHTMLAtoms::height, val)) - { - if(eHTMLUnit_Pixel == val.GetUnit()) - { - nscoord height = val.GetPixelValue(); - kidReflowState.mComputedHeight = NSIntPixelsToTwips(height, p2t); - } - } + if(kidReflowState.mStylePosition->mWidth.GetUnit() == eStyleUnit_Coord || + kidReflowState.mStylePosition->mWidth.GetUnit() == eStyleUnit_Percent) { + //the object frame has already calculated the constraints + kidReflowState.mComputedWidth = aMetrics.width; } + if(kidReflowState.mStylePosition->mHeight.GetUnit() == eStyleUnit_Coord || + kidReflowState.mStylePosition->mHeight.GetUnit() == eStyleUnit_Percent) { + //the object frame has already calculated the constraints + kidReflowState.mComputedHeight = aMetrics.height; + } + + nsReflowStatus status; + + kidDesiredSize.width = NS_UNCONSTRAINEDSIZE; + kidDesiredSize.height = NS_UNCONSTRAINEDSIZE; + ReflowChild(child, aPresContext, kidDesiredSize, kidReflowState, 0, 0, 0, status); FinishReflowChild(child, aPresContext, &kidReflowState, kidDesiredSize, 0, 0, 0);