From 128348933b7a2ce44ed649c225cdd8608fabbdca Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Thu, 15 May 2003 01:42:53 +0000 Subject: [PATCH] Bug 204531. Remove bogus RTL listbox reflow hack. Fix border computation for desired size of combobox dropdowns. git-svn-id: svn://10.0.0.236/trunk@142482 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/forms/nsListControlFrame.cpp | 50 ++++--------------- .../html/forms/src/nsListControlFrame.cpp | 50 ++++--------------- 2 files changed, 22 insertions(+), 78 deletions(-) diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index eeaed7e4e0e..7ccc32699e0 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -1131,12 +1131,12 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, // Compute the bounding box of the contents of the list using the area // calculated by the first reflow as a starting point. // - // The nsGfxScrollFrame::Reflow adds in the scrollbar width and border dimensions - // to the maxElementWidth, so these need to be subtracted - nscoord scrolledAreaWidth = scrolledAreaDesiredSize.width - - (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right); - nscoord scrolledAreaHeight = scrolledAreaDesiredSize.height - - (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom); + // The nsGfxScrollFrame::Reflow adds border and padding to the + // maxElementWidth, so these need to be subtracted + nscoord scrolledAreaWidth = scrolledAreaDesiredSize.width - + (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right); + nscoord scrolledAreaHeight = scrolledAreaDesiredSize.height - + (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom); // Set up max values mMaxWidth = scrolledAreaWidth; @@ -1336,37 +1336,6 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, } } - const nsStyleVisibility* vis; - GetStyleData(eStyleStruct_Visibility, (const nsStyleStruct*&)vis); - -#ifdef IBMBIDI - // Retrieve the scrollbar's width and height - float sbWidth = 0.0; - float sbHeight = 0.0;; - nsCOMPtr dc; - aPresContext->GetDeviceContext(getter_AddRefs(dc)); - dc->GetScrollBarDimensions(sbWidth, sbHeight); - // Convert to nscoord's by rounding - nscoord scrollbarWidth = NSToCoordRound(sbWidth); - - if (vis->mDirection == NS_STYLE_DIRECTION_RTL) { - nscoord bidiScrolledAreaWidth = scrolledAreaDesiredSize.mMaxElementWidth; - firstPassState.reason = eReflowReason_StyleChange; - if (aReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE) { - bidiScrolledAreaWidth = aReflowState.mComputedWidth; - } - if (needsVerticalScrollbar) { - bidiScrolledAreaWidth -= scrollbarWidth; - } - bidiScrolledAreaWidth -= (aReflowState.mComputedBorderPadding.left + - aReflowState.mComputedBorderPadding.right); - - firstPassState.mComputedWidth = bidiScrolledAreaWidth; - firstPassState.availableWidth = bidiScrolledAreaWidth; - nsGfxScrollFrame::Reflow(aPresContext, aDesiredSize, firstPassState, aStatus); - } -#endif // IBMBIDI - // Do a second reflow with the adjusted width and height settings // This sets up all of the frames with the correct width and height. secondPassState.mComputedWidth = visibleWidth; @@ -1384,8 +1353,11 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, // Set the max element size to be the same as the desired element size. } else { - aDesiredSize.width = visibleWidth; - aDesiredSize.height = visibleHeight; + // aDesiredSize is the desired frame size, so includes border and padding + aDesiredSize.width = visibleWidth + + (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right); + aDesiredSize.height = visibleHeight + + (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom); aDesiredSize.ascent = scrolledAreaDesiredSize.ascent + aReflowState.mComputedBorderPadding.top; aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent; diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index eeaed7e4e0e..7ccc32699e0 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -1131,12 +1131,12 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, // Compute the bounding box of the contents of the list using the area // calculated by the first reflow as a starting point. // - // The nsGfxScrollFrame::Reflow adds in the scrollbar width and border dimensions - // to the maxElementWidth, so these need to be subtracted - nscoord scrolledAreaWidth = scrolledAreaDesiredSize.width - - (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right); - nscoord scrolledAreaHeight = scrolledAreaDesiredSize.height - - (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom); + // The nsGfxScrollFrame::Reflow adds border and padding to the + // maxElementWidth, so these need to be subtracted + nscoord scrolledAreaWidth = scrolledAreaDesiredSize.width - + (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right); + nscoord scrolledAreaHeight = scrolledAreaDesiredSize.height - + (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom); // Set up max values mMaxWidth = scrolledAreaWidth; @@ -1336,37 +1336,6 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, } } - const nsStyleVisibility* vis; - GetStyleData(eStyleStruct_Visibility, (const nsStyleStruct*&)vis); - -#ifdef IBMBIDI - // Retrieve the scrollbar's width and height - float sbWidth = 0.0; - float sbHeight = 0.0;; - nsCOMPtr dc; - aPresContext->GetDeviceContext(getter_AddRefs(dc)); - dc->GetScrollBarDimensions(sbWidth, sbHeight); - // Convert to nscoord's by rounding - nscoord scrollbarWidth = NSToCoordRound(sbWidth); - - if (vis->mDirection == NS_STYLE_DIRECTION_RTL) { - nscoord bidiScrolledAreaWidth = scrolledAreaDesiredSize.mMaxElementWidth; - firstPassState.reason = eReflowReason_StyleChange; - if (aReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE) { - bidiScrolledAreaWidth = aReflowState.mComputedWidth; - } - if (needsVerticalScrollbar) { - bidiScrolledAreaWidth -= scrollbarWidth; - } - bidiScrolledAreaWidth -= (aReflowState.mComputedBorderPadding.left + - aReflowState.mComputedBorderPadding.right); - - firstPassState.mComputedWidth = bidiScrolledAreaWidth; - firstPassState.availableWidth = bidiScrolledAreaWidth; - nsGfxScrollFrame::Reflow(aPresContext, aDesiredSize, firstPassState, aStatus); - } -#endif // IBMBIDI - // Do a second reflow with the adjusted width and height settings // This sets up all of the frames with the correct width and height. secondPassState.mComputedWidth = visibleWidth; @@ -1384,8 +1353,11 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, // Set the max element size to be the same as the desired element size. } else { - aDesiredSize.width = visibleWidth; - aDesiredSize.height = visibleHeight; + // aDesiredSize is the desired frame size, so includes border and padding + aDesiredSize.width = visibleWidth + + (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right); + aDesiredSize.height = visibleHeight + + (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom); aDesiredSize.ascent = scrolledAreaDesiredSize.ascent + aReflowState.mComputedBorderPadding.top; aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;