Align text inputs, buttons, comboboxes to baseline with respect to the

text around them (bug 167236).  Fix width sizing issues for <input
type="button/reset/submit"> (bugs 79927, 36364).  Fix nonuniform heights
of form controls (bug 70251).  Patch is on bug 167236, r=jkeiser,
sr=roc+moz, moa=rods
This commit is contained in:
bzbarsky%mit.edu 2002-11-12 19:17:51 +00:00
Родитель 2035538e9c
Коммит d33d3708fe
21 изменённых файлов: 187 добавлений и 582 удалений

Просмотреть файл

@ -291,6 +291,7 @@ nsComboboxControlFrame::nsComboboxControlFrame()
mCacheSize.width = kSizeNotSet; mCacheSize.width = kSizeNotSet;
mCacheSize.height = kSizeNotSet; mCacheSize.height = kSizeNotSet;
mCachedAscent = kSizeNotSet;
mCachedMaxElementSize.width = kSizeNotSet; mCachedMaxElementSize.width = kSizeNotSet;
mCachedMaxElementSize.height = kSizeNotSet; mCachedMaxElementSize.height = kSizeNotSet;
mCachedAvailableSize.width = kSizeNotSet; mCachedAvailableSize.width = kSizeNotSet;
@ -968,6 +969,7 @@ nsComboboxControlFrame::ReflowCombobox(nsIPresContext * aPresContext,
SetChildFrameSize(aDropDownBtn, aBtnWidth, aDesiredSize.height); SetChildFrameSize(aDropDownBtn, aBtnWidth, aDesiredSize.height);
aDesiredSize.width = 0; aDesiredSize.width = 0;
aDesiredSize.height = dispHeight; aDesiredSize.height = dispHeight;
// XXX What about ascent and descent?
return; return;
} }
@ -1129,6 +1131,11 @@ nsComboboxControlFrame::ReflowCombobox(nsIPresContext * aPresContext,
aDesiredSize.maxElementSize->width = aDesiredSize.width; aDesiredSize.maxElementSize->width = aDesiredSize.width;
aDesiredSize.maxElementSize->height = aDesiredSize.height; aDesiredSize.maxElementSize->height = aDesiredSize.height;
} }
aDesiredSize.ascent =
txtKidSize.ascent + aReflowState.mComputedBorderPadding.top;
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
// Now cache the available height as our height without border and padding // Now cache the available height as our height without border and padding
// This sets up the optimization for if a new available width comes in and we are equal or // This sets up the optimization for if a new available width comes in and we are equal or
// less than it we can bail // less than it we can bail
@ -1139,7 +1146,8 @@ nsComboboxControlFrame::ReflowCombobox(nsIPresContext * aPresContext,
if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) { if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) {
mCachedAvailableSize.height = aDesiredSize.height - (aBorderPadding.top + aBorderPadding.bottom); mCachedAvailableSize.height = aDesiredSize.height - (aBorderPadding.top + aBorderPadding.bottom);
} }
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize); nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedAscent,
mCachedMaxElementSize, aDesiredSize);
} }
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
@ -1239,7 +1247,8 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
// cached AvailableSize.width == aCacheSize.width // cached AvailableSize.width == aCacheSize.width
// //
// NOTE: this returns whether we are doing an Incremental reflow // NOTE: this returns whether we are doing an Incremental reflow
nsFormControlFrame::SkipResizeReflow(mCacheSize, nsFormControlFrame::SkipResizeReflow(mCacheSize,
mCachedAscent,
mCachedMaxElementSize, mCachedMaxElementSize,
mCachedAvailableSize, mCachedAvailableSize,
aDesiredSize, aReflowState, aDesiredSize, aReflowState,
@ -1284,12 +1293,6 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
nsRect buttonRect; nsRect buttonRect;
nsRect dropdownRect; nsRect dropdownRect;
// get our border and padding,
// XXX - should be the same mComputedBorderPadding?
// maybe we should use that?
nsMargin borderPadding(0, 0, 0, 0);
CalcBorderPadding(borderPadding);
// Get the current sizes of the combo box child frames // Get the current sizes of the combo box child frames
mDisplayFrame->GetRect(displayRect); mDisplayFrame->GetRect(displayRect);
mButtonFrame->GetRect(buttonRect); mButtonFrame->GetRect(buttonRect);
@ -1340,7 +1343,7 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
REFLOW_DEBUG_MSG("------------Reflowing AreaFrame and bailing----\n\n"); REFLOW_DEBUG_MSG("------------Reflowing AreaFrame and bailing----\n\n");
ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus, ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus,
mDisplayFrame, mButtonFrame, mItemDisplayWidth, mDisplayFrame, mButtonFrame, mItemDisplayWidth,
scrollbarWidth, borderPadding); scrollbarWidth, aReflowState.mComputedBorderPadding);
REFLOW_COUNTER(); REFLOW_COUNTER();
UNCONSTRAINED_CHECK(); UNCONSTRAINED_CHECK();
REFLOW_DEBUG_MSG3("&** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height)); REFLOW_DEBUG_MSG3("&** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));
@ -1397,8 +1400,10 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
REFLOW_DEBUG_MSG("---- Doing AreaFrame Reflow and then bailing out\n"); REFLOW_DEBUG_MSG("---- Doing AreaFrame Reflow and then bailing out\n");
// Do simple reflow and bail out // Do simple reflow and bail out
ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus, ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus,
mDisplayFrame, mButtonFrame, mDisplayFrame, mButtonFrame,
mItemDisplayWidth, scrollbarWidth, borderPadding, kSizeNotSet, PR_TRUE); mItemDisplayWidth, scrollbarWidth,
aReflowState.mComputedBorderPadding,
kSizeNotSet, PR_TRUE);
REFLOW_DEBUG_MSG3("+** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height)); REFLOW_DEBUG_MSG3("+** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));
REFLOW_COUNTER(); REFLOW_COUNTER();
UNCONSTRAINED_CHECK(); UNCONSTRAINED_CHECK();
@ -1422,6 +1427,8 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
aDesiredSize.width = mCacheSize.width; aDesiredSize.width = mCacheSize.width;
aDesiredSize.height = mCacheSize.height; aDesiredSize.height = mCacheSize.height;
aDesiredSize.ascent = mCachedAscent;
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
if (aDesiredSize.maxElementSize != nsnull) { if (aDesiredSize.maxElementSize != nsnull) {
aDesiredSize.maxElementSize->width = mCachedMaxElementSize.width; aDesiredSize.maxElementSize->width = mCachedMaxElementSize.width;
@ -1556,7 +1563,7 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
// for the display area // for the display area
mDropdownFrame->GetRect(dropdownRect); mDropdownFrame->GetRect(dropdownRect);
if (eReflowReason_Resize == aReflowState.reason) { if (eReflowReason_Resize == aReflowState.reason) {
dropdownRect.Deflate(borderPadding); dropdownRect.Deflate(aReflowState.mComputedBorderPadding);
} }
// Get maximum size of the largest item in the dropdown // Get maximum size of the largest item in the dropdown
@ -1627,7 +1634,7 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
// this reflows and makes and last minute adjustments // this reflows and makes and last minute adjustments
ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus, ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus,
mDisplayFrame, mButtonFrame, mItemDisplayWidth, scrollbarWidth, mDisplayFrame, mButtonFrame, mItemDisplayWidth, scrollbarWidth,
borderPadding, size.height); aReflowState.mComputedBorderPadding, size.height);
// The dropdown was reflowed UNCONSTRAINED before, now we need to check to see // The dropdown was reflowed UNCONSTRAINED before, now we need to check to see
// if it needs to be resized. // if it needs to be resized.
@ -1703,13 +1710,17 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
// this is so if our cached avilable size is ever equal to or less // this is so if our cached avilable size is ever equal to or less
// than the real avilable size we can bail out // than the real avilable size we can bail out
if (aReflowState.availableWidth != NS_UNCONSTRAINEDSIZE) { if (aReflowState.availableWidth != NS_UNCONSTRAINEDSIZE) {
mCachedAvailableSize.width = aDesiredSize.width - (borderPadding.left + borderPadding.right); mCachedAvailableSize.width = aDesiredSize.width -
(aReflowState.mComputedBorderPadding.left +
aReflowState.mComputedBorderPadding.right);
} }
if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) { if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) {
mCachedAvailableSize.height = aDesiredSize.height - (borderPadding.top + borderPadding.bottom); mCachedAvailableSize.height = aDesiredSize.height -
(aReflowState.mComputedBorderPadding.top +
aReflowState.mComputedBorderPadding.bottom);
} }
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize); nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedAscent, mCachedMaxElementSize, aDesiredSize);
REFLOW_DEBUG_MSG3("** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height)); REFLOW_DEBUG_MSG3("** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));
REFLOW_COUNTER(); REFLOW_COUNTER();
@ -1951,7 +1962,10 @@ nsComboboxControlFrame::ActuallyDisplayText(nsAString& aText, PRBool aNotify)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (aText.IsEmpty()) { if (aText.IsEmpty()) {
nsAutoString space(PRUnichar(' ')); // Have to use a non-breaking space for line-height calculations
// to be right
static const PRUnichar spaceArr[] = { 0xA0, 0x00 };
nsDependentString space(spaceArr);
rv = mDisplayContent->SetText(space.get(), space.Length(), aNotify); rv = mDisplayContent->SetText(space.get(), space.Length(), aNotify);
} else { } else {
const nsAFlatString& flat = PromiseFlatString(aText); const nsAFlatString& flat = PromiseFlatString(aText);

Просмотреть файл

@ -281,6 +281,7 @@ protected:
nsSize mCacheSize; nsSize mCacheSize;
nsSize mCachedMaxElementSize; nsSize mCachedMaxElementSize;
nsSize mCachedAvailableSize; nsSize mCachedAvailableSize;
nscoord mCachedAscent;
nsSize mCachedUncDropdownSize; nsSize mCachedUncDropdownSize;
nsSize mCachedUncComboSize; nsSize mCachedUncComboSize;

Просмотреть файл

@ -149,11 +149,13 @@ nsFormControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
} }
void nsFormControlFrame::SetupCachedSizes(nsSize& aCacheSize, void nsFormControlFrame::SetupCachedSizes(nsSize& aCacheSize,
nsSize& aCachedMaxElementSize, nscoord& aCachedAscent,
nsHTMLReflowMetrics& aDesiredSize) nsSize& aCachedMaxElementSize,
nsHTMLReflowMetrics& aDesiredSize)
{ {
aCacheSize.width = aDesiredSize.width; aCacheSize.width = aDesiredSize.width;
aCacheSize.height = aDesiredSize.height; aCacheSize.height = aDesiredSize.height;
aCachedAscent = aDesiredSize.ascent;
if (aDesiredSize.maxElementSize != nsnull) { if (aDesiredSize.maxElementSize != nsnull) {
aCachedMaxElementSize.width = aDesiredSize.maxElementSize->width; aCachedMaxElementSize.width = aDesiredSize.maxElementSize->width;
aCachedMaxElementSize.height = aDesiredSize.maxElementSize->height; aCachedMaxElementSize.height = aDesiredSize.maxElementSize->height;
@ -254,6 +256,7 @@ void nsFormControlFrame::SkipResizeReflow(nsSize& aCacheSize,
#else #else
//------------------------------------------------------------ //------------------------------------------------------------
void nsFormControlFrame::SkipResizeReflow(nsSize& aCacheSize, void nsFormControlFrame::SkipResizeReflow(nsSize& aCacheSize,
nscoord& aCachedAscent,
nsSize& aCachedMaxElementSize, nsSize& aCachedMaxElementSize,
nsSize& aCachedAvailableSize, nsSize& aCachedAvailableSize,
nsHTMLReflowMetrics& aDesiredSize, nsHTMLReflowMetrics& aDesiredSize,
@ -362,13 +365,13 @@ void nsFormControlFrame::SkipResizeReflow(nsSize& aCacheSize,
if (aBailOnWidth || aBailOnHeight) { if (aBailOnWidth || aBailOnHeight) {
aDesiredSize.width = aCacheSize.width; aDesiredSize.width = aCacheSize.width;
aDesiredSize.height = aCacheSize.height; aDesiredSize.height = aCacheSize.height;
aDesiredSize.ascent = aCachedAscent;
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
if (aDesiredSize.maxElementSize != nsnull) { if (aDesiredSize.maxElementSize != nsnull) {
aDesiredSize.maxElementSize->width = aCachedMaxElementSize.width; aDesiredSize.maxElementSize->width = aCachedMaxElementSize.width;
aDesiredSize.maxElementSize->height = aCachedMaxElementSize.height; aDesiredSize.maxElementSize->height = aCachedMaxElementSize.height;
} }
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
} }
} }
} }
@ -555,7 +558,7 @@ nsFormControlFrame::Reflow(nsIPresContext* aPresContext,
nsresult rv = nsLeafFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); nsresult rv = nsLeafFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
aStatus = NS_FRAME_COMPLETE; aStatus = NS_FRAME_COMPLETE;
SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize); SetupCachedSizes(mCacheSize, mCachedAscent, mCachedMaxElementSize, aDesiredSize);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize); NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return rv; return rv;
} }

Просмотреть файл

@ -219,10 +219,12 @@ public:
NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue);
// Resize Reflow Optimiaztion Methods // Resize Reflow Optimiaztion Methods
static void SetupCachedSizes(nsSize& aCacheSize, static void SetupCachedSizes(nsSize& aCacheSize,
nscoord& aCachedAscent,
nsSize& aCachedMaxElementSize, nsSize& aCachedMaxElementSize,
nsHTMLReflowMetrics& aDesiredSize); nsHTMLReflowMetrics& aDesiredSize);
static void SkipResizeReflow(nsSize& aCacheSize, static void SkipResizeReflow(nsSize& aCacheSize,
nscoord& aCachedAscent,
nsSize& aCachedMaxElementSize, nsSize& aCachedMaxElementSize,
nsSize& aCachedAvailableSize, nsSize& aCachedAvailableSize,
nsHTMLReflowMetrics& aDesiredSize, nsHTMLReflowMetrics& aDesiredSize,
@ -329,6 +331,7 @@ protected:
// Reflow Optimization // Reflow Optimization
nsSize mCacheSize; nsSize mCacheSize;
nscoord mCachedAscent;
nsSize mCachedMaxElementSize; nsSize mCachedMaxElementSize;
private: private:

Просмотреть файл

@ -171,163 +171,6 @@ nsGfxButtonControlFrame::AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetri
return NS_OK; return NS_OK;
} }
nsresult
nsGfxButtonControlFrame::DoNavQuirksReflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
nsIFrame* firstKid = mFrames.FirstChild();
nsCOMPtr<nsIFontMetrics> fontMet;
nsresult res = nsFormControlHelper::GetFrameFontFM(aPresContext, (nsIFormControlFrame *)this, getter_AddRefs(fontMet));
nsSize desiredSize;
if (NS_SUCCEEDED(res) && fontMet) {
aReflowState.rendContext->SetFont(fontMet);
// Get the text from the "value" attribute
// for measuring the height, width of the text
nsAutoString value;
res = GetValue(&value);
if (res != NS_CONTENT_ATTR_HAS_VALUE && value.IsEmpty()) {
// Generate localized label.
// We can't make any assumption as to what the default would be
// because the value is localized for non-english platforms, thus
// it might not be the string "Reset", "Submit Query", or "Browse..."
res = GetDefaultLabel(value);
if (NS_FAILED(res)) {
return res;
}
}
const nsStyleText* textStyle;
GetStyleData(eStyleStruct_Text, (const nsStyleStruct *&)textStyle);
if (!textStyle->WhiteSpaceIsSignificant()) {
value.CompressWhitespace();
}
if (value.IsEmpty()) {
// Have to have _something_ or we won't be drawn
value.Assign(NS_LITERAL_STRING(" "));
}
CalcNavQuirkSizing(aPresContext, aReflowState.rendContext, value,
desiredSize);
// Note: The Quirks sizing includes a 2px border in its calculation of "desiredSize"
// So we must subtract off the 2 pixel border.
// Quirk sizing also assumes a 0px padding
float p2t;
aPresContext->GetPixelsToTwips(&p2t);
nscoord borderTwips = NSIntPixelsToTwips(4, p2t);
desiredSize.width -= borderTwips;
desiredSize.height -= borderTwips;
// Now figure out how much vertical padding was added and
// then subtract it, so we can add in the padding later
// horizontal pading is 0px;
nscoord hgt;
fontMet->GetHeight(hgt);
desiredSize.height -= PR_MAX(0, desiredSize.height - hgt);
// This calculates the reflow size
// get the css size and let the frame use or override it
nsSize styleSize;
nsFormControlFrame::GetStyleSize(aPresContext, aReflowState, styleSize);
if (CSS_NOTSET != styleSize.width) { // css provides width
NS_ASSERTION(styleSize.width+aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right >= 0, "form control's computed width is < 0");
if (NS_INTRINSICSIZE != styleSize.width) {
desiredSize.width = styleSize.width;
desiredSize.width += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
}
} else {
desiredSize.width += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
}
if (CSS_NOTSET != styleSize.height) { // css provides height
NS_ASSERTION(styleSize.height > 0, "form control's computed height is <= 0");
if (NS_INTRINSICSIZE != styleSize.height) {
desiredSize.height = styleSize.height;
desiredSize.height += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
}
} else {
desiredSize.height += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
}
aDesiredSize.width = desiredSize.width;
aDesiredSize.height = desiredSize.height;
} else {
// XXX ASSERT HERE
desiredSize.width = 0;
desiredSize.height = 0;
}
// remove it from the the desired size
// because the content need to fit inside of it
desiredSize.width -= (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right);
desiredSize.height -= (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom);
// Ok, now we think we know what size we are so we can reflow our contents
// But we need to make sure we aren't smaller or larger then the min/max
if (desiredSize.width < aReflowState.mComputedMinWidth) {
desiredSize.width = aReflowState.mComputedMinWidth - (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right);
} else if (desiredSize.width > aReflowState.mComputedMaxWidth) {
desiredSize.width = aReflowState.mComputedMaxWidth - (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right);
}
if (desiredSize.height < aReflowState.mComputedMinHeight) {
desiredSize.height = aReflowState.mComputedMinHeight - (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom);
} else if (desiredSize.height > aReflowState.mComputedMaxHeight) {
desiredSize.height = aReflowState.mComputedMaxHeight - (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom);
}
// XXX Proper handling of incremental reflow...
nsReflowReason reason = aReflowState.reason;
if (eReflowReason_Incremental == reason) {
// See if it's targeted at us
nsHTMLReflowCommand *command = aReflowState.path->mReflowCommand;
if (command) {
Invalidate(aPresContext, nsRect(0,0,mRect.width,mRect.height), PR_FALSE);
nsReflowType reflowType;
command->GetType(reflowType);
if (eReflowType_StyleChanged == reflowType) {
reason = eReflowReason_StyleChange;
}
else {
reason = eReflowReason_Resize;
}
}
}
// now reflow the first child (generated content)
nsHTMLReflowState reflowState(aPresContext, aReflowState, firstKid, desiredSize, reason);
reflowState.mComputedWidth = desiredSize.width;
reflowState.mComputedHeight = desiredSize.height;
nsHTMLReflowMetrics childReflowMetrics(aDesiredSize);
nsRect kidRect;
firstKid->GetRect(kidRect);
ReflowChild(firstKid, aPresContext, childReflowMetrics, reflowState, kidRect.x, kidRect.y, 0, aStatus);
aDesiredSize.ascent = childReflowMetrics.ascent +
aReflowState.mComputedBorderPadding.top;
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
// Center the child and add back in the border and badding
// our inner area frame is already doing centering so we only need to center vertically.
nsRect rect = nsRect(aReflowState.mComputedBorderPadding.left,
aReflowState.mComputedBorderPadding.top,
desiredSize.width,
desiredSize.height);
firstKid->SetRect(aPresContext, rect);
return NS_OK;
}
// Create the text content used as label for the button. // Create the text content used as label for the button.
// The frame will be generated by the frame constructor. // The frame will be generated by the frame constructor.
NS_IMETHODIMP NS_IMETHODIMP
@ -359,11 +202,6 @@ nsGfxButtonControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
value.CompressWhitespace(); value.CompressWhitespace();
} }
if (value.IsEmpty()) {
// Have to have _something_ or we won't be drawn
value.Assign(NS_LITERAL_STRING(" "));
}
// Add a child text content node for the label // Add a child text content node for the label
nsCOMPtr<nsIContent> labelContent(do_CreateInstance(kTextNodeCID,&result)); nsCOMPtr<nsIContent> labelContent(do_CreateInstance(kTextNodeCID,&result));
if (NS_SUCCEEDED(result) && labelContent) { if (NS_SUCCEEDED(result) && labelContent) {
@ -475,7 +313,7 @@ nsGfxButtonControlFrame::GetDefaultLabel(nsString& aString)
rv = nsFormControlHelper::GetLocalizedString(propname, NS_LITERAL_STRING("Browse").get(), aString); rv = nsFormControlHelper::GetLocalizedString(propname, NS_LITERAL_STRING("Browse").get(), aString);
} }
else { else {
aString.Assign(NS_LITERAL_STRING(" ")); aString.Assign(NS_LITERAL_STRING(""));
rv = NS_OK; rv = NS_OK;
} }
return rv; return rv;
@ -519,17 +357,6 @@ nsGfxButtonControlFrame::Reflow(nsIPresContext* aPresContext,
DO_GLOBAL_REFLOW_COUNT("nsGfxButtonControlFrame", aReflowState.reason); DO_GLOBAL_REFLOW_COUNT("nsGfxButtonControlFrame", aReflowState.reason);
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
nsresult rv = NS_OK;
#if 0
nsresult skiprv = nsFormControlFrame::SkipResizeReflow(mCacheSize, mCachedMaxElementSize, aPresContext,
aDesiredSize, aReflowState, aStatus);
if (NS_SUCCEEDED(skiprv)) {
return skiprv;
}
#endif
if ((kSuggestedNotSet != mSuggestedWidth) || if ((kSuggestedNotSet != mSuggestedWidth) ||
(kSuggestedNotSet != mSuggestedHeight)) { (kSuggestedNotSet != mSuggestedHeight)) {
nsHTMLReflowState suggestedReflowState(aReflowState); nsHTMLReflowState suggestedReflowState(aReflowState);
@ -543,76 +370,13 @@ nsGfxButtonControlFrame::Reflow(nsIPresContext* aPresContext,
suggestedReflowState.mComputedHeight = mSuggestedHeight; suggestedReflowState.mComputedHeight = mSuggestedHeight;
} }
rv = nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, suggestedReflowState, aStatus); return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, suggestedReflowState, aStatus);
} else { // Normal reflow.
#if 1
// nsHTMLButtonControlFrame::Reflow registers it for Standard Mode
// and sets up mPresContext
if (eReflowReason_Initial == aReflowState.reason) {
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE);
}
// Do NavQuirks Sizing and layout
rv = DoNavQuirksReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
// Make sure we obey min/max-width and min/max-height
if (aDesiredSize.width > aReflowState.mComputedMaxWidth) {
aDesiredSize.width = aReflowState.mComputedMaxWidth;
}
if (aDesiredSize.width < aReflowState.mComputedMinWidth) {
aDesiredSize.width = aReflowState.mComputedMinWidth;
}
if (aDesiredSize.height > aReflowState.mComputedMaxHeight) {
aDesiredSize.height = aReflowState.mComputedMaxHeight;
}
if (aDesiredSize.height < aReflowState.mComputedMinHeight) {
aDesiredSize.height = aReflowState.mComputedMinHeight;
}
#else
// Do Standard mode sizing and layout
rv = nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
#endif
} }
// Normal reflow.
#ifdef DEBUG_rodsXXXX return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
COMPARE_QUIRK_SIZE("nsGfxButtonControlFrame", 84, 24) // with the text "Press Me" in it
#endif
aStatus = NS_FRAME_COMPLETE;
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize);
if (aDesiredSize.maxElementSize != nsnull) {
aDesiredSize.maxElementSize->width = aDesiredSize.width;
aDesiredSize.maxElementSize->height = aDesiredSize.height;
}
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return rv;
}
void
nsGfxButtonControlFrame::CalcNavQuirkSizing(nsIPresContext* aPresContext,
nsIRenderingContext* aRendContext,
nsString& aLabel,
nsSize& aSize)
{
float p2t;
float t2p;
aPresContext->GetPixelsToTwips(&p2t);
aPresContext->GetTwipsToPixels(&t2p);
// Get text size, round to nearest pixel, multiply by 3/2
// XXX this algorithm seems suspect: rounding before multiply can't be good,
// and 3/2 seems ... arbitrary
nsFormControlHelper::GetTextSize(aPresContext, this,
aLabel, aSize,
aRendContext);
aSize.width = NSToCoordRound(aSize.width * t2p);
aSize.height = NSToCoordRound(aSize.height * t2p);
aSize.width = NSIntPixelsToTwips(3 * aSize.width / 2, p2t);
aSize.height = NSIntPixelsToTwips(3 * aSize.height / 2, p2t);
} }
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -410,6 +410,7 @@ nsHTMLButtonControlFrame::Paint(nsIPresContext* aPresContext,
static static
void ButtonHack(nsHTMLReflowState& aReflowState, const char* aMessage) void ButtonHack(nsHTMLReflowState& aReflowState, const char* aMessage)
{ {
// XXXbz is this still relevant?
if (aReflowState.mComputedWidth == 0) { if (aReflowState.mComputedWidth == 0) {
aReflowState.mComputedWidth = aReflowState.availableWidth; aReflowState.mComputedWidth = aReflowState.availableWidth;
} }
@ -551,7 +552,7 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext,
focusPadding.left + aReflowState.mComputedBorderPadding.left, focusPadding.left + aReflowState.mComputedBorderPadding.left,
focusPadding.top + aReflowState.mComputedBorderPadding.top, focusPadding.top + aReflowState.mComputedBorderPadding.top,
0, aStatus); 0, aStatus);
// calculate the min internal size so the contents gets centered correctly // calculate the min internal size so the contents gets centered correctly
// minInternalWidth is not being used at all and causes a warning--commenting // minInternalWidth is not being used at all and causes a warning--commenting
// out until someone wants it. // out until someone wants it.
@ -573,7 +574,7 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext,
// Place the child // Place the child
FinishReflowChild(firstKid, aPresContext, &reflowState, aDesiredSize, FinishReflowChild(firstKid, aPresContext, &reflowState, aDesiredSize,
focusPadding.left + aReflowState.mComputedBorderPadding.right, focusPadding.left + aReflowState.mComputedBorderPadding.left,
yoff + focusPadding.top + aReflowState.mComputedBorderPadding.top, 0); yoff + focusPadding.top + aReflowState.mComputedBorderPadding.top, 0);
#if 0 // old way #if 0 // old way
@ -602,6 +603,7 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext,
#endif #endif
AddComputedBorderPaddingToDesiredSize(aDesiredSize, aReflowState); AddComputedBorderPaddingToDesiredSize(aDesiredSize, aReflowState);
//aDesiredSize.width += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right; //aDesiredSize.width += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
//aDesiredSize.height += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom; //aDesiredSize.height += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
@ -612,9 +614,6 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext,
} }
#endif #endif
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
if (nsnull != aDesiredSize.maxElementSize) { if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = aDesiredSize.width; aDesiredSize.maxElementSize->width = aDesiredSize.width;
aDesiredSize.maxElementSize->height = aDesiredSize.height; aDesiredSize.maxElementSize->height = aDesiredSize.height;
@ -633,10 +632,15 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext,
} }
if (aDesiredSize.height < aReflowState.mComputedMinHeight) { if (aDesiredSize.height < aReflowState.mComputedMinHeight) {
aDesiredSize.height = aReflowState.mComputedMinHeight; aDesiredSize.height = aReflowState.mComputedMinHeight;
} }
aDesiredSize.ascent += aReflowState.mComputedBorderPadding.top + focusPadding.top;
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
aStatus = NS_FRAME_COMPLETE; aStatus = NS_FRAME_COMPLETE;
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize); nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedAscent,
mCachedMaxElementSize, aDesiredSize);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize); NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -170,6 +170,7 @@ protected:
//Resize Reflow OpitmizationSize; //Resize Reflow OpitmizationSize;
nsSize mCacheSize; nsSize mCacheSize;
nscoord mCachedAscent;
nsSize mCachedMaxElementSize; nsSize mCachedMaxElementSize;
}; };

Просмотреть файл

@ -837,7 +837,8 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
// so we can check timings against the old version // so we can check timings against the old version
#if 1 #if 1
nsFormControlFrame::SkipResizeReflow(mCacheSize, nsFormControlFrame::SkipResizeReflow(mCacheSize,
mCachedAscent,
mCachedMaxElementSize, mCachedMaxElementSize,
mCachedAvailableSize, mCachedAvailableSize,
aDesiredSize, aReflowState, aDesiredSize, aReflowState,
@ -999,6 +1000,7 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
} }
mCachedUnconstrainedSize.width = scrolledAreaDesiredSize.width; mCachedUnconstrainedSize.width = scrolledAreaDesiredSize.width;
mCachedUnconstrainedSize.height = scrolledAreaDesiredSize.height; mCachedUnconstrainedSize.height = scrolledAreaDesiredSize.height;
mCachedAscent = scrolledAreaDesiredSize.ascent;
mCachedDesiredMaxSize.width = scrolledAreaDesiredSize.maxElementSize->width; mCachedDesiredMaxSize.width = scrolledAreaDesiredSize.maxElementSize->width;
mCachedDesiredMaxSize.height = scrolledAreaDesiredSize.maxElementSize->height; mCachedDesiredMaxSize.height = scrolledAreaDesiredSize.maxElementSize->height;
} else { } else {
@ -1280,8 +1282,9 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
} else { } else {
aDesiredSize.width = visibleWidth; aDesiredSize.width = visibleWidth;
aDesiredSize.height = visibleHeight; aDesiredSize.height = visibleHeight;
aDesiredSize.ascent = aDesiredSize.height; aDesiredSize.ascent =
aDesiredSize.descent = 0; scrolledAreaDesiredSize.ascent + aReflowState.mComputedBorderPadding.top;
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
} }
if (nsnull != aDesiredSize.maxElementSize) { if (nsnull != aDesiredSize.maxElementSize) {
@ -1319,7 +1322,8 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
//REFLOW_DEBUG_MSG3("** nsLCF Caching AW: %d AH: %d\n", PX(mCachedAvailableSize.width), PX(mCachedAvailableSize.height)); //REFLOW_DEBUG_MSG3("** nsLCF Caching AW: %d AH: %d\n", PX(mCachedAvailableSize.width), PX(mCachedAvailableSize.height));
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize); nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedAscent,
mCachedMaxElementSize, aDesiredSize);
REFLOW_DEBUG_MSG3("** Done nsLCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height)); REFLOW_DEBUG_MSG3("** Done nsLCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));

Просмотреть файл

@ -423,6 +423,7 @@ protected:
//Resize Reflow OpitmizationSize; //Resize Reflow OpitmizationSize;
nsSize mCacheSize; nsSize mCacheSize;
nscoord mCachedAscent;
nsSize mCachedMaxElementSize; nsSize mCachedMaxElementSize;
nsSize mCachedUnconstrainedSize; nsSize mCachedUnconstrainedSize;
nsSize mCachedAvailableSize; nsSize mCachedAvailableSize;

Просмотреть файл

@ -955,8 +955,9 @@ nsScrollFrame::Reflow(nsIPresContext* aPresContext,
aDesiredSize.maxElementSize->height = maxHeight; aDesiredSize.maxElementSize->height = maxHeight;
} }
aDesiredSize.ascent = aDesiredSize.height; aDesiredSize.ascent =
aDesiredSize.descent = 0; kidDesiredSize.ascent + aReflowState.mComputedBorderPadding.top;
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
NS_FRAME_TRACE_MSG(NS_FRAME_TRACE_CALLS, NS_FRAME_TRACE_MSG(NS_FRAME_TRACE_CALLS,
("exit nsScrollFrame::Reflow: status=%d width=%d height=%d", ("exit nsScrollFrame::Reflow: status=%d width=%d height=%d",

Просмотреть файл

@ -74,6 +74,9 @@ label {
/* default inputs, text inputs, and selects */ /* default inputs, text inputs, and selects */
input { input {
-moz-appearance: textfield; -moz-appearance: textfield;
/* The sum of border-top, border-bottom, padding-top, padding-bottom
must be the same here, for buttons, and for <select> (including its
internal padding magic) */
padding: 1px 0 1px 0; padding: 1px 0 1px 0;
border: 2px inset ThreeDFace; border: 2px inset ThreeDFace;
background-color: -moz-Field; background-color: -moz-Field;
@ -82,7 +85,6 @@ input {
line-height: normal !important; line-height: normal !important;
text-align: start; text-align: start;
text-transform: none; text-transform: none;
vertical-align: text-bottom;
cursor: text; cursor: text;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
-moz-user-focus: normal; -moz-user-focus: normal;
@ -126,7 +128,6 @@ select {
line-height: normal !important; line-height: normal !important;
white-space: nowrap; white-space: nowrap;
text-align: start; text-align: start;
vertical-align: text-bottom;
cursor: default; cursor: default;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
-moz-user-select: none; -moz-user-select: none;
@ -138,10 +139,14 @@ select {
} }
select[size] { select[size] {
/* Different alignment and padding for listbox vs combobox */
vertical-align: text-bottom;
padding: 1px 0 1px 0; padding: 1px 0 1px 0;
} }
select[size="1"] { select[size="1"] {
/* Except this is not a listbox */
vertical-align: baseline;
padding: 0; padding: 0;
-moz-appearance: menulist; -moz-appearance: menulist;
} }
@ -178,6 +183,8 @@ select:-moz-dummy-option {
*|*:-moz-display-comboboxcontrol-frame { *|*:-moz-display-comboboxcontrol-frame {
overflow: hidden; overflow: hidden;
/* This top/bottom padding plus the combobox top/bottom border need to
add up to the top/bottom borderpadding of text inputs and buttons */
padding: 1px 0 1px 4px; padding: 1px 0 1px 4px;
background-color: inherit; background-color: inherit;
color: inherit; color: inherit;
@ -263,7 +270,6 @@ input[type="image"] {
padding: 0; padding: 0;
border: none; border: none;
background-color: transparent; background-color: transparent;
vertical-align: baseline;
font-family: sans-serif; font-family: sans-serif;
font-size: small; font-size: small;
cursor: pointer; cursor: pointer;
@ -293,17 +299,14 @@ input[type="file"] > input[type="text"] {
border-color: inherit; border-color: inherit;
background-color: inherit; background-color: inherit;
color: inherit; color: inherit;
font-size: inherit;
height: inherit;
} }
/* button part of file selector */ /* button part of file selector */
input[type="file"] > input[type="button"] { input[type="file"] > input[type="button"] {
height: inherit; height: inherit;
} font-size: inherit;
input[type="file"] > input[type="button"]:-moz-focus-inner
{
padding: 0px 2px 0px 2px;
border: 1px dotted transparent;
} }
/* radio buttons */ /* radio buttons */
@ -313,7 +316,6 @@ input[type="radio"] {
height: 13px; height: 13px;
margin: 3px 3px 0px 5px; margin: 3px 3px 0px 5px;
padding: 0; padding: 0;
vertical-align: baseline;
cursor: default; cursor: default;
-moz-binding: none; -moz-binding: none;
@ -383,14 +385,16 @@ input[type="reset"],
input[type="button"], input[type="button"],
input[type="submit"] { input[type="submit"] {
-moz-appearance: button; -moz-appearance: button;
padding: 2px 0 2px 0; /* The sum of border-top, border-bottom, padding-top, padding-bottom
must be the same here, for text inputs, and for <select>. For
buttons, make sure to include the -moz-focus-inner border/padding. */
padding: 0px 8px 0px 8px;
border: 2px outset ButtonFace; border: 2px outset ButtonFace;
background-color: ButtonFace; background-color: ButtonFace;
color: ButtonText; color: ButtonText;
font: -moz-button; font: -moz-button;
line-height: normal !important; line-height: normal !important;
white-space: pre; white-space: pre;
vertical-align: text-bottom;
cursor: default; cursor: default;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
-moz-user-select: none; -moz-user-select: none;
@ -407,15 +411,16 @@ button:active:hover,
input[type="reset"]:active:hover, input[type="reset"]:active:hover,
input[type="button"]:active:hover, input[type="button"]:active:hover,
input[type="submit"]:active:hover { input[type="submit"]:active:hover {
padding: 3px 0 1px 0; padding: 0px 7px 0px 9px;
border-style: inset; border-style: inset;
} }
button:-moz-focus-inner, button:-moz-focus-inner,
input[type="reset"]:-moz-focus-inner, input[type="reset"]:-moz-focus-inner,
input[type="button"]:-moz-focus-inner, input[type="button"]:-moz-focus-inner,
input[type="submit"]:-moz-focus-inner { input[type="submit"]:-moz-focus-inner,
padding: 1px 2px 1px 2px; input[type="file"] > input[type="button"]:-moz-focus-inner {
padding: 0px 2px 0px 2px;
border: 1px dotted transparent; border: 1px dotted transparent;
} }
@ -436,7 +441,9 @@ select[disabled] > input[type="button"],
select[disabled] > input[type="button"]:active, select[disabled] > input[type="button"]:active,
input[type="submit"][disabled]:active, input[type="submit"][disabled]:active,
input[type="submit"][disabled] { input[type="submit"][disabled] {
padding: 3px 1px 3px 1px; /* The sum of border-top, border-bottom, padding-top, padding-bottom
must be the same here and for text inputs */
padding: 1px 8px 1px 8px;
border: 1px outset ButtonShadow; border: 1px outset ButtonShadow;
color: GrayText; color: GrayText;
} }

Просмотреть файл

@ -291,6 +291,7 @@ nsComboboxControlFrame::nsComboboxControlFrame()
mCacheSize.width = kSizeNotSet; mCacheSize.width = kSizeNotSet;
mCacheSize.height = kSizeNotSet; mCacheSize.height = kSizeNotSet;
mCachedAscent = kSizeNotSet;
mCachedMaxElementSize.width = kSizeNotSet; mCachedMaxElementSize.width = kSizeNotSet;
mCachedMaxElementSize.height = kSizeNotSet; mCachedMaxElementSize.height = kSizeNotSet;
mCachedAvailableSize.width = kSizeNotSet; mCachedAvailableSize.width = kSizeNotSet;
@ -968,6 +969,7 @@ nsComboboxControlFrame::ReflowCombobox(nsIPresContext * aPresContext,
SetChildFrameSize(aDropDownBtn, aBtnWidth, aDesiredSize.height); SetChildFrameSize(aDropDownBtn, aBtnWidth, aDesiredSize.height);
aDesiredSize.width = 0; aDesiredSize.width = 0;
aDesiredSize.height = dispHeight; aDesiredSize.height = dispHeight;
// XXX What about ascent and descent?
return; return;
} }
@ -1129,6 +1131,11 @@ nsComboboxControlFrame::ReflowCombobox(nsIPresContext * aPresContext,
aDesiredSize.maxElementSize->width = aDesiredSize.width; aDesiredSize.maxElementSize->width = aDesiredSize.width;
aDesiredSize.maxElementSize->height = aDesiredSize.height; aDesiredSize.maxElementSize->height = aDesiredSize.height;
} }
aDesiredSize.ascent =
txtKidSize.ascent + aReflowState.mComputedBorderPadding.top;
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
// Now cache the available height as our height without border and padding // Now cache the available height as our height without border and padding
// This sets up the optimization for if a new available width comes in and we are equal or // This sets up the optimization for if a new available width comes in and we are equal or
// less than it we can bail // less than it we can bail
@ -1139,7 +1146,8 @@ nsComboboxControlFrame::ReflowCombobox(nsIPresContext * aPresContext,
if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) { if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) {
mCachedAvailableSize.height = aDesiredSize.height - (aBorderPadding.top + aBorderPadding.bottom); mCachedAvailableSize.height = aDesiredSize.height - (aBorderPadding.top + aBorderPadding.bottom);
} }
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize); nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedAscent,
mCachedMaxElementSize, aDesiredSize);
} }
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
@ -1239,7 +1247,8 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
// cached AvailableSize.width == aCacheSize.width // cached AvailableSize.width == aCacheSize.width
// //
// NOTE: this returns whether we are doing an Incremental reflow // NOTE: this returns whether we are doing an Incremental reflow
nsFormControlFrame::SkipResizeReflow(mCacheSize, nsFormControlFrame::SkipResizeReflow(mCacheSize,
mCachedAscent,
mCachedMaxElementSize, mCachedMaxElementSize,
mCachedAvailableSize, mCachedAvailableSize,
aDesiredSize, aReflowState, aDesiredSize, aReflowState,
@ -1284,12 +1293,6 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
nsRect buttonRect; nsRect buttonRect;
nsRect dropdownRect; nsRect dropdownRect;
// get our border and padding,
// XXX - should be the same mComputedBorderPadding?
// maybe we should use that?
nsMargin borderPadding(0, 0, 0, 0);
CalcBorderPadding(borderPadding);
// Get the current sizes of the combo box child frames // Get the current sizes of the combo box child frames
mDisplayFrame->GetRect(displayRect); mDisplayFrame->GetRect(displayRect);
mButtonFrame->GetRect(buttonRect); mButtonFrame->GetRect(buttonRect);
@ -1340,7 +1343,7 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
REFLOW_DEBUG_MSG("------------Reflowing AreaFrame and bailing----\n\n"); REFLOW_DEBUG_MSG("------------Reflowing AreaFrame and bailing----\n\n");
ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus, ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus,
mDisplayFrame, mButtonFrame, mItemDisplayWidth, mDisplayFrame, mButtonFrame, mItemDisplayWidth,
scrollbarWidth, borderPadding); scrollbarWidth, aReflowState.mComputedBorderPadding);
REFLOW_COUNTER(); REFLOW_COUNTER();
UNCONSTRAINED_CHECK(); UNCONSTRAINED_CHECK();
REFLOW_DEBUG_MSG3("&** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height)); REFLOW_DEBUG_MSG3("&** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));
@ -1397,8 +1400,10 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
REFLOW_DEBUG_MSG("---- Doing AreaFrame Reflow and then bailing out\n"); REFLOW_DEBUG_MSG("---- Doing AreaFrame Reflow and then bailing out\n");
// Do simple reflow and bail out // Do simple reflow and bail out
ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus, ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus,
mDisplayFrame, mButtonFrame, mDisplayFrame, mButtonFrame,
mItemDisplayWidth, scrollbarWidth, borderPadding, kSizeNotSet, PR_TRUE); mItemDisplayWidth, scrollbarWidth,
aReflowState.mComputedBorderPadding,
kSizeNotSet, PR_TRUE);
REFLOW_DEBUG_MSG3("+** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height)); REFLOW_DEBUG_MSG3("+** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));
REFLOW_COUNTER(); REFLOW_COUNTER();
UNCONSTRAINED_CHECK(); UNCONSTRAINED_CHECK();
@ -1422,6 +1427,8 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
aDesiredSize.width = mCacheSize.width; aDesiredSize.width = mCacheSize.width;
aDesiredSize.height = mCacheSize.height; aDesiredSize.height = mCacheSize.height;
aDesiredSize.ascent = mCachedAscent;
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
if (aDesiredSize.maxElementSize != nsnull) { if (aDesiredSize.maxElementSize != nsnull) {
aDesiredSize.maxElementSize->width = mCachedMaxElementSize.width; aDesiredSize.maxElementSize->width = mCachedMaxElementSize.width;
@ -1556,7 +1563,7 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
// for the display area // for the display area
mDropdownFrame->GetRect(dropdownRect); mDropdownFrame->GetRect(dropdownRect);
if (eReflowReason_Resize == aReflowState.reason) { if (eReflowReason_Resize == aReflowState.reason) {
dropdownRect.Deflate(borderPadding); dropdownRect.Deflate(aReflowState.mComputedBorderPadding);
} }
// Get maximum size of the largest item in the dropdown // Get maximum size of the largest item in the dropdown
@ -1627,7 +1634,7 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
// this reflows and makes and last minute adjustments // this reflows and makes and last minute adjustments
ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus, ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus,
mDisplayFrame, mButtonFrame, mItemDisplayWidth, scrollbarWidth, mDisplayFrame, mButtonFrame, mItemDisplayWidth, scrollbarWidth,
borderPadding, size.height); aReflowState.mComputedBorderPadding, size.height);
// The dropdown was reflowed UNCONSTRAINED before, now we need to check to see // The dropdown was reflowed UNCONSTRAINED before, now we need to check to see
// if it needs to be resized. // if it needs to be resized.
@ -1703,13 +1710,17 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
// this is so if our cached avilable size is ever equal to or less // this is so if our cached avilable size is ever equal to or less
// than the real avilable size we can bail out // than the real avilable size we can bail out
if (aReflowState.availableWidth != NS_UNCONSTRAINEDSIZE) { if (aReflowState.availableWidth != NS_UNCONSTRAINEDSIZE) {
mCachedAvailableSize.width = aDesiredSize.width - (borderPadding.left + borderPadding.right); mCachedAvailableSize.width = aDesiredSize.width -
(aReflowState.mComputedBorderPadding.left +
aReflowState.mComputedBorderPadding.right);
} }
if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) { if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE) {
mCachedAvailableSize.height = aDesiredSize.height - (borderPadding.top + borderPadding.bottom); mCachedAvailableSize.height = aDesiredSize.height -
(aReflowState.mComputedBorderPadding.top +
aReflowState.mComputedBorderPadding.bottom);
} }
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize); nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedAscent, mCachedMaxElementSize, aDesiredSize);
REFLOW_DEBUG_MSG3("** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height)); REFLOW_DEBUG_MSG3("** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));
REFLOW_COUNTER(); REFLOW_COUNTER();
@ -1951,7 +1962,10 @@ nsComboboxControlFrame::ActuallyDisplayText(nsAString& aText, PRBool aNotify)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (aText.IsEmpty()) { if (aText.IsEmpty()) {
nsAutoString space(PRUnichar(' ')); // Have to use a non-breaking space for line-height calculations
// to be right
static const PRUnichar spaceArr[] = { 0xA0, 0x00 };
nsDependentString space(spaceArr);
rv = mDisplayContent->SetText(space.get(), space.Length(), aNotify); rv = mDisplayContent->SetText(space.get(), space.Length(), aNotify);
} else { } else {
const nsAFlatString& flat = PromiseFlatString(aText); const nsAFlatString& flat = PromiseFlatString(aText);

Просмотреть файл

@ -281,6 +281,7 @@ protected:
nsSize mCacheSize; nsSize mCacheSize;
nsSize mCachedMaxElementSize; nsSize mCachedMaxElementSize;
nsSize mCachedAvailableSize; nsSize mCachedAvailableSize;
nscoord mCachedAscent;
nsSize mCachedUncDropdownSize; nsSize mCachedUncDropdownSize;
nsSize mCachedUncComboSize; nsSize mCachedUncComboSize;

Просмотреть файл

@ -149,11 +149,13 @@ nsFormControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
} }
void nsFormControlFrame::SetupCachedSizes(nsSize& aCacheSize, void nsFormControlFrame::SetupCachedSizes(nsSize& aCacheSize,
nsSize& aCachedMaxElementSize, nscoord& aCachedAscent,
nsHTMLReflowMetrics& aDesiredSize) nsSize& aCachedMaxElementSize,
nsHTMLReflowMetrics& aDesiredSize)
{ {
aCacheSize.width = aDesiredSize.width; aCacheSize.width = aDesiredSize.width;
aCacheSize.height = aDesiredSize.height; aCacheSize.height = aDesiredSize.height;
aCachedAscent = aDesiredSize.ascent;
if (aDesiredSize.maxElementSize != nsnull) { if (aDesiredSize.maxElementSize != nsnull) {
aCachedMaxElementSize.width = aDesiredSize.maxElementSize->width; aCachedMaxElementSize.width = aDesiredSize.maxElementSize->width;
aCachedMaxElementSize.height = aDesiredSize.maxElementSize->height; aCachedMaxElementSize.height = aDesiredSize.maxElementSize->height;
@ -254,6 +256,7 @@ void nsFormControlFrame::SkipResizeReflow(nsSize& aCacheSize,
#else #else
//------------------------------------------------------------ //------------------------------------------------------------
void nsFormControlFrame::SkipResizeReflow(nsSize& aCacheSize, void nsFormControlFrame::SkipResizeReflow(nsSize& aCacheSize,
nscoord& aCachedAscent,
nsSize& aCachedMaxElementSize, nsSize& aCachedMaxElementSize,
nsSize& aCachedAvailableSize, nsSize& aCachedAvailableSize,
nsHTMLReflowMetrics& aDesiredSize, nsHTMLReflowMetrics& aDesiredSize,
@ -362,13 +365,13 @@ void nsFormControlFrame::SkipResizeReflow(nsSize& aCacheSize,
if (aBailOnWidth || aBailOnHeight) { if (aBailOnWidth || aBailOnHeight) {
aDesiredSize.width = aCacheSize.width; aDesiredSize.width = aCacheSize.width;
aDesiredSize.height = aCacheSize.height; aDesiredSize.height = aCacheSize.height;
aDesiredSize.ascent = aCachedAscent;
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
if (aDesiredSize.maxElementSize != nsnull) { if (aDesiredSize.maxElementSize != nsnull) {
aDesiredSize.maxElementSize->width = aCachedMaxElementSize.width; aDesiredSize.maxElementSize->width = aCachedMaxElementSize.width;
aDesiredSize.maxElementSize->height = aCachedMaxElementSize.height; aDesiredSize.maxElementSize->height = aCachedMaxElementSize.height;
} }
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
} }
} }
} }
@ -555,7 +558,7 @@ nsFormControlFrame::Reflow(nsIPresContext* aPresContext,
nsresult rv = nsLeafFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); nsresult rv = nsLeafFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
aStatus = NS_FRAME_COMPLETE; aStatus = NS_FRAME_COMPLETE;
SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize); SetupCachedSizes(mCacheSize, mCachedAscent, mCachedMaxElementSize, aDesiredSize);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize); NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return rv; return rv;
} }

Просмотреть файл

@ -219,10 +219,12 @@ public:
NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue);
// Resize Reflow Optimiaztion Methods // Resize Reflow Optimiaztion Methods
static void SetupCachedSizes(nsSize& aCacheSize, static void SetupCachedSizes(nsSize& aCacheSize,
nscoord& aCachedAscent,
nsSize& aCachedMaxElementSize, nsSize& aCachedMaxElementSize,
nsHTMLReflowMetrics& aDesiredSize); nsHTMLReflowMetrics& aDesiredSize);
static void SkipResizeReflow(nsSize& aCacheSize, static void SkipResizeReflow(nsSize& aCacheSize,
nscoord& aCachedAscent,
nsSize& aCachedMaxElementSize, nsSize& aCachedMaxElementSize,
nsSize& aCachedAvailableSize, nsSize& aCachedAvailableSize,
nsHTMLReflowMetrics& aDesiredSize, nsHTMLReflowMetrics& aDesiredSize,
@ -329,6 +331,7 @@ protected:
// Reflow Optimization // Reflow Optimization
nsSize mCacheSize; nsSize mCacheSize;
nscoord mCachedAscent;
nsSize mCachedMaxElementSize; nsSize mCachedMaxElementSize;
private: private:

Просмотреть файл

@ -171,163 +171,6 @@ nsGfxButtonControlFrame::AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetri
return NS_OK; return NS_OK;
} }
nsresult
nsGfxButtonControlFrame::DoNavQuirksReflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
nsIFrame* firstKid = mFrames.FirstChild();
nsCOMPtr<nsIFontMetrics> fontMet;
nsresult res = nsFormControlHelper::GetFrameFontFM(aPresContext, (nsIFormControlFrame *)this, getter_AddRefs(fontMet));
nsSize desiredSize;
if (NS_SUCCEEDED(res) && fontMet) {
aReflowState.rendContext->SetFont(fontMet);
// Get the text from the "value" attribute
// for measuring the height, width of the text
nsAutoString value;
res = GetValue(&value);
if (res != NS_CONTENT_ATTR_HAS_VALUE && value.IsEmpty()) {
// Generate localized label.
// We can't make any assumption as to what the default would be
// because the value is localized for non-english platforms, thus
// it might not be the string "Reset", "Submit Query", or "Browse..."
res = GetDefaultLabel(value);
if (NS_FAILED(res)) {
return res;
}
}
const nsStyleText* textStyle;
GetStyleData(eStyleStruct_Text, (const nsStyleStruct *&)textStyle);
if (!textStyle->WhiteSpaceIsSignificant()) {
value.CompressWhitespace();
}
if (value.IsEmpty()) {
// Have to have _something_ or we won't be drawn
value.Assign(NS_LITERAL_STRING(" "));
}
CalcNavQuirkSizing(aPresContext, aReflowState.rendContext, value,
desiredSize);
// Note: The Quirks sizing includes a 2px border in its calculation of "desiredSize"
// So we must subtract off the 2 pixel border.
// Quirk sizing also assumes a 0px padding
float p2t;
aPresContext->GetPixelsToTwips(&p2t);
nscoord borderTwips = NSIntPixelsToTwips(4, p2t);
desiredSize.width -= borderTwips;
desiredSize.height -= borderTwips;
// Now figure out how much vertical padding was added and
// then subtract it, so we can add in the padding later
// horizontal pading is 0px;
nscoord hgt;
fontMet->GetHeight(hgt);
desiredSize.height -= PR_MAX(0, desiredSize.height - hgt);
// This calculates the reflow size
// get the css size and let the frame use or override it
nsSize styleSize;
nsFormControlFrame::GetStyleSize(aPresContext, aReflowState, styleSize);
if (CSS_NOTSET != styleSize.width) { // css provides width
NS_ASSERTION(styleSize.width+aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right >= 0, "form control's computed width is < 0");
if (NS_INTRINSICSIZE != styleSize.width) {
desiredSize.width = styleSize.width;
desiredSize.width += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
}
} else {
desiredSize.width += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
}
if (CSS_NOTSET != styleSize.height) { // css provides height
NS_ASSERTION(styleSize.height > 0, "form control's computed height is <= 0");
if (NS_INTRINSICSIZE != styleSize.height) {
desiredSize.height = styleSize.height;
desiredSize.height += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
}
} else {
desiredSize.height += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
}
aDesiredSize.width = desiredSize.width;
aDesiredSize.height = desiredSize.height;
} else {
// XXX ASSERT HERE
desiredSize.width = 0;
desiredSize.height = 0;
}
// remove it from the the desired size
// because the content need to fit inside of it
desiredSize.width -= (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right);
desiredSize.height -= (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom);
// Ok, now we think we know what size we are so we can reflow our contents
// But we need to make sure we aren't smaller or larger then the min/max
if (desiredSize.width < aReflowState.mComputedMinWidth) {
desiredSize.width = aReflowState.mComputedMinWidth - (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right);
} else if (desiredSize.width > aReflowState.mComputedMaxWidth) {
desiredSize.width = aReflowState.mComputedMaxWidth - (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right);
}
if (desiredSize.height < aReflowState.mComputedMinHeight) {
desiredSize.height = aReflowState.mComputedMinHeight - (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom);
} else if (desiredSize.height > aReflowState.mComputedMaxHeight) {
desiredSize.height = aReflowState.mComputedMaxHeight - (aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom);
}
// XXX Proper handling of incremental reflow...
nsReflowReason reason = aReflowState.reason;
if (eReflowReason_Incremental == reason) {
// See if it's targeted at us
nsHTMLReflowCommand *command = aReflowState.path->mReflowCommand;
if (command) {
Invalidate(aPresContext, nsRect(0,0,mRect.width,mRect.height), PR_FALSE);
nsReflowType reflowType;
command->GetType(reflowType);
if (eReflowType_StyleChanged == reflowType) {
reason = eReflowReason_StyleChange;
}
else {
reason = eReflowReason_Resize;
}
}
}
// now reflow the first child (generated content)
nsHTMLReflowState reflowState(aPresContext, aReflowState, firstKid, desiredSize, reason);
reflowState.mComputedWidth = desiredSize.width;
reflowState.mComputedHeight = desiredSize.height;
nsHTMLReflowMetrics childReflowMetrics(aDesiredSize);
nsRect kidRect;
firstKid->GetRect(kidRect);
ReflowChild(firstKid, aPresContext, childReflowMetrics, reflowState, kidRect.x, kidRect.y, 0, aStatus);
aDesiredSize.ascent = childReflowMetrics.ascent +
aReflowState.mComputedBorderPadding.top;
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
// Center the child and add back in the border and badding
// our inner area frame is already doing centering so we only need to center vertically.
nsRect rect = nsRect(aReflowState.mComputedBorderPadding.left,
aReflowState.mComputedBorderPadding.top,
desiredSize.width,
desiredSize.height);
firstKid->SetRect(aPresContext, rect);
return NS_OK;
}
// Create the text content used as label for the button. // Create the text content used as label for the button.
// The frame will be generated by the frame constructor. // The frame will be generated by the frame constructor.
NS_IMETHODIMP NS_IMETHODIMP
@ -359,11 +202,6 @@ nsGfxButtonControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
value.CompressWhitespace(); value.CompressWhitespace();
} }
if (value.IsEmpty()) {
// Have to have _something_ or we won't be drawn
value.Assign(NS_LITERAL_STRING(" "));
}
// Add a child text content node for the label // Add a child text content node for the label
nsCOMPtr<nsIContent> labelContent(do_CreateInstance(kTextNodeCID,&result)); nsCOMPtr<nsIContent> labelContent(do_CreateInstance(kTextNodeCID,&result));
if (NS_SUCCEEDED(result) && labelContent) { if (NS_SUCCEEDED(result) && labelContent) {
@ -475,7 +313,7 @@ nsGfxButtonControlFrame::GetDefaultLabel(nsString& aString)
rv = nsFormControlHelper::GetLocalizedString(propname, NS_LITERAL_STRING("Browse").get(), aString); rv = nsFormControlHelper::GetLocalizedString(propname, NS_LITERAL_STRING("Browse").get(), aString);
} }
else { else {
aString.Assign(NS_LITERAL_STRING(" ")); aString.Assign(NS_LITERAL_STRING(""));
rv = NS_OK; rv = NS_OK;
} }
return rv; return rv;
@ -519,17 +357,6 @@ nsGfxButtonControlFrame::Reflow(nsIPresContext* aPresContext,
DO_GLOBAL_REFLOW_COUNT("nsGfxButtonControlFrame", aReflowState.reason); DO_GLOBAL_REFLOW_COUNT("nsGfxButtonControlFrame", aReflowState.reason);
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
nsresult rv = NS_OK;
#if 0
nsresult skiprv = nsFormControlFrame::SkipResizeReflow(mCacheSize, mCachedMaxElementSize, aPresContext,
aDesiredSize, aReflowState, aStatus);
if (NS_SUCCEEDED(skiprv)) {
return skiprv;
}
#endif
if ((kSuggestedNotSet != mSuggestedWidth) || if ((kSuggestedNotSet != mSuggestedWidth) ||
(kSuggestedNotSet != mSuggestedHeight)) { (kSuggestedNotSet != mSuggestedHeight)) {
nsHTMLReflowState suggestedReflowState(aReflowState); nsHTMLReflowState suggestedReflowState(aReflowState);
@ -543,76 +370,13 @@ nsGfxButtonControlFrame::Reflow(nsIPresContext* aPresContext,
suggestedReflowState.mComputedHeight = mSuggestedHeight; suggestedReflowState.mComputedHeight = mSuggestedHeight;
} }
rv = nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, suggestedReflowState, aStatus); return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, suggestedReflowState, aStatus);
} else { // Normal reflow.
#if 1
// nsHTMLButtonControlFrame::Reflow registers it for Standard Mode
// and sets up mPresContext
if (eReflowReason_Initial == aReflowState.reason) {
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE);
}
// Do NavQuirks Sizing and layout
rv = DoNavQuirksReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
// Make sure we obey min/max-width and min/max-height
if (aDesiredSize.width > aReflowState.mComputedMaxWidth) {
aDesiredSize.width = aReflowState.mComputedMaxWidth;
}
if (aDesiredSize.width < aReflowState.mComputedMinWidth) {
aDesiredSize.width = aReflowState.mComputedMinWidth;
}
if (aDesiredSize.height > aReflowState.mComputedMaxHeight) {
aDesiredSize.height = aReflowState.mComputedMaxHeight;
}
if (aDesiredSize.height < aReflowState.mComputedMinHeight) {
aDesiredSize.height = aReflowState.mComputedMinHeight;
}
#else
// Do Standard mode sizing and layout
rv = nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
#endif
} }
// Normal reflow.
#ifdef DEBUG_rodsXXXX return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
COMPARE_QUIRK_SIZE("nsGfxButtonControlFrame", 84, 24) // with the text "Press Me" in it
#endif
aStatus = NS_FRAME_COMPLETE;
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize);
if (aDesiredSize.maxElementSize != nsnull) {
aDesiredSize.maxElementSize->width = aDesiredSize.width;
aDesiredSize.maxElementSize->height = aDesiredSize.height;
}
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return rv;
}
void
nsGfxButtonControlFrame::CalcNavQuirkSizing(nsIPresContext* aPresContext,
nsIRenderingContext* aRendContext,
nsString& aLabel,
nsSize& aSize)
{
float p2t;
float t2p;
aPresContext->GetPixelsToTwips(&p2t);
aPresContext->GetTwipsToPixels(&t2p);
// Get text size, round to nearest pixel, multiply by 3/2
// XXX this algorithm seems suspect: rounding before multiply can't be good,
// and 3/2 seems ... arbitrary
nsFormControlHelper::GetTextSize(aPresContext, this,
aLabel, aSize,
aRendContext);
aSize.width = NSToCoordRound(aSize.width * t2p);
aSize.height = NSToCoordRound(aSize.height * t2p);
aSize.width = NSIntPixelsToTwips(3 * aSize.width / 2, p2t);
aSize.height = NSIntPixelsToTwips(3 * aSize.height / 2, p2t);
} }
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -410,6 +410,7 @@ nsHTMLButtonControlFrame::Paint(nsIPresContext* aPresContext,
static static
void ButtonHack(nsHTMLReflowState& aReflowState, const char* aMessage) void ButtonHack(nsHTMLReflowState& aReflowState, const char* aMessage)
{ {
// XXXbz is this still relevant?
if (aReflowState.mComputedWidth == 0) { if (aReflowState.mComputedWidth == 0) {
aReflowState.mComputedWidth = aReflowState.availableWidth; aReflowState.mComputedWidth = aReflowState.availableWidth;
} }
@ -551,7 +552,7 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext,
focusPadding.left + aReflowState.mComputedBorderPadding.left, focusPadding.left + aReflowState.mComputedBorderPadding.left,
focusPadding.top + aReflowState.mComputedBorderPadding.top, focusPadding.top + aReflowState.mComputedBorderPadding.top,
0, aStatus); 0, aStatus);
// calculate the min internal size so the contents gets centered correctly // calculate the min internal size so the contents gets centered correctly
// minInternalWidth is not being used at all and causes a warning--commenting // minInternalWidth is not being used at all and causes a warning--commenting
// out until someone wants it. // out until someone wants it.
@ -573,7 +574,7 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext,
// Place the child // Place the child
FinishReflowChild(firstKid, aPresContext, &reflowState, aDesiredSize, FinishReflowChild(firstKid, aPresContext, &reflowState, aDesiredSize,
focusPadding.left + aReflowState.mComputedBorderPadding.right, focusPadding.left + aReflowState.mComputedBorderPadding.left,
yoff + focusPadding.top + aReflowState.mComputedBorderPadding.top, 0); yoff + focusPadding.top + aReflowState.mComputedBorderPadding.top, 0);
#if 0 // old way #if 0 // old way
@ -602,6 +603,7 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext,
#endif #endif
AddComputedBorderPaddingToDesiredSize(aDesiredSize, aReflowState); AddComputedBorderPaddingToDesiredSize(aDesiredSize, aReflowState);
//aDesiredSize.width += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right; //aDesiredSize.width += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
//aDesiredSize.height += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom; //aDesiredSize.height += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
@ -612,9 +614,6 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext,
} }
#endif #endif
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
if (nsnull != aDesiredSize.maxElementSize) { if (nsnull != aDesiredSize.maxElementSize) {
aDesiredSize.maxElementSize->width = aDesiredSize.width; aDesiredSize.maxElementSize->width = aDesiredSize.width;
aDesiredSize.maxElementSize->height = aDesiredSize.height; aDesiredSize.maxElementSize->height = aDesiredSize.height;
@ -633,10 +632,15 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext,
} }
if (aDesiredSize.height < aReflowState.mComputedMinHeight) { if (aDesiredSize.height < aReflowState.mComputedMinHeight) {
aDesiredSize.height = aReflowState.mComputedMinHeight; aDesiredSize.height = aReflowState.mComputedMinHeight;
} }
aDesiredSize.ascent += aReflowState.mComputedBorderPadding.top + focusPadding.top;
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
aStatus = NS_FRAME_COMPLETE; aStatus = NS_FRAME_COMPLETE;
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize); nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedAscent,
mCachedMaxElementSize, aDesiredSize);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize); NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -170,6 +170,7 @@ protected:
//Resize Reflow OpitmizationSize; //Resize Reflow OpitmizationSize;
nsSize mCacheSize; nsSize mCacheSize;
nscoord mCachedAscent;
nsSize mCachedMaxElementSize; nsSize mCachedMaxElementSize;
}; };

Просмотреть файл

@ -837,7 +837,8 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
// so we can check timings against the old version // so we can check timings against the old version
#if 1 #if 1
nsFormControlFrame::SkipResizeReflow(mCacheSize, nsFormControlFrame::SkipResizeReflow(mCacheSize,
mCachedAscent,
mCachedMaxElementSize, mCachedMaxElementSize,
mCachedAvailableSize, mCachedAvailableSize,
aDesiredSize, aReflowState, aDesiredSize, aReflowState,
@ -999,6 +1000,7 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
} }
mCachedUnconstrainedSize.width = scrolledAreaDesiredSize.width; mCachedUnconstrainedSize.width = scrolledAreaDesiredSize.width;
mCachedUnconstrainedSize.height = scrolledAreaDesiredSize.height; mCachedUnconstrainedSize.height = scrolledAreaDesiredSize.height;
mCachedAscent = scrolledAreaDesiredSize.ascent;
mCachedDesiredMaxSize.width = scrolledAreaDesiredSize.maxElementSize->width; mCachedDesiredMaxSize.width = scrolledAreaDesiredSize.maxElementSize->width;
mCachedDesiredMaxSize.height = scrolledAreaDesiredSize.maxElementSize->height; mCachedDesiredMaxSize.height = scrolledAreaDesiredSize.maxElementSize->height;
} else { } else {
@ -1280,8 +1282,9 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
} else { } else {
aDesiredSize.width = visibleWidth; aDesiredSize.width = visibleWidth;
aDesiredSize.height = visibleHeight; aDesiredSize.height = visibleHeight;
aDesiredSize.ascent = aDesiredSize.height; aDesiredSize.ascent =
aDesiredSize.descent = 0; scrolledAreaDesiredSize.ascent + aReflowState.mComputedBorderPadding.top;
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
} }
if (nsnull != aDesiredSize.maxElementSize) { if (nsnull != aDesiredSize.maxElementSize) {
@ -1319,7 +1322,8 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
//REFLOW_DEBUG_MSG3("** nsLCF Caching AW: %d AH: %d\n", PX(mCachedAvailableSize.width), PX(mCachedAvailableSize.height)); //REFLOW_DEBUG_MSG3("** nsLCF Caching AW: %d AH: %d\n", PX(mCachedAvailableSize.width), PX(mCachedAvailableSize.height));
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize); nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedAscent,
mCachedMaxElementSize, aDesiredSize);
REFLOW_DEBUG_MSG3("** Done nsLCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height)); REFLOW_DEBUG_MSG3("** Done nsLCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height));

Просмотреть файл

@ -423,6 +423,7 @@ protected:
//Resize Reflow OpitmizationSize; //Resize Reflow OpitmizationSize;
nsSize mCacheSize; nsSize mCacheSize;
nscoord mCachedAscent;
nsSize mCachedMaxElementSize; nsSize mCachedMaxElementSize;
nsSize mCachedUnconstrainedSize; nsSize mCachedUnconstrainedSize;
nsSize mCachedAvailableSize; nsSize mCachedAvailableSize;

Просмотреть файл

@ -74,6 +74,9 @@ label {
/* default inputs, text inputs, and selects */ /* default inputs, text inputs, and selects */
input { input {
-moz-appearance: textfield; -moz-appearance: textfield;
/* The sum of border-top, border-bottom, padding-top, padding-bottom
must be the same here, for buttons, and for <select> (including its
internal padding magic) */
padding: 1px 0 1px 0; padding: 1px 0 1px 0;
border: 2px inset ThreeDFace; border: 2px inset ThreeDFace;
background-color: -moz-Field; background-color: -moz-Field;
@ -82,7 +85,6 @@ input {
line-height: normal !important; line-height: normal !important;
text-align: start; text-align: start;
text-transform: none; text-transform: none;
vertical-align: text-bottom;
cursor: text; cursor: text;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
-moz-user-focus: normal; -moz-user-focus: normal;
@ -126,7 +128,6 @@ select {
line-height: normal !important; line-height: normal !important;
white-space: nowrap; white-space: nowrap;
text-align: start; text-align: start;
vertical-align: text-bottom;
cursor: default; cursor: default;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
-moz-user-select: none; -moz-user-select: none;
@ -138,10 +139,14 @@ select {
} }
select[size] { select[size] {
/* Different alignment and padding for listbox vs combobox */
vertical-align: text-bottom;
padding: 1px 0 1px 0; padding: 1px 0 1px 0;
} }
select[size="1"] { select[size="1"] {
/* Except this is not a listbox */
vertical-align: baseline;
padding: 0; padding: 0;
-moz-appearance: menulist; -moz-appearance: menulist;
} }
@ -178,6 +183,8 @@ select:-moz-dummy-option {
*|*:-moz-display-comboboxcontrol-frame { *|*:-moz-display-comboboxcontrol-frame {
overflow: hidden; overflow: hidden;
/* This top/bottom padding plus the combobox top/bottom border need to
add up to the top/bottom borderpadding of text inputs and buttons */
padding: 1px 0 1px 4px; padding: 1px 0 1px 4px;
background-color: inherit; background-color: inherit;
color: inherit; color: inherit;
@ -263,7 +270,6 @@ input[type="image"] {
padding: 0; padding: 0;
border: none; border: none;
background-color: transparent; background-color: transparent;
vertical-align: baseline;
font-family: sans-serif; font-family: sans-serif;
font-size: small; font-size: small;
cursor: pointer; cursor: pointer;
@ -293,17 +299,14 @@ input[type="file"] > input[type="text"] {
border-color: inherit; border-color: inherit;
background-color: inherit; background-color: inherit;
color: inherit; color: inherit;
font-size: inherit;
height: inherit;
} }
/* button part of file selector */ /* button part of file selector */
input[type="file"] > input[type="button"] { input[type="file"] > input[type="button"] {
height: inherit; height: inherit;
} font-size: inherit;
input[type="file"] > input[type="button"]:-moz-focus-inner
{
padding: 0px 2px 0px 2px;
border: 1px dotted transparent;
} }
/* radio buttons */ /* radio buttons */
@ -313,7 +316,6 @@ input[type="radio"] {
height: 13px; height: 13px;
margin: 3px 3px 0px 5px; margin: 3px 3px 0px 5px;
padding: 0; padding: 0;
vertical-align: baseline;
cursor: default; cursor: default;
-moz-binding: none; -moz-binding: none;
@ -383,14 +385,16 @@ input[type="reset"],
input[type="button"], input[type="button"],
input[type="submit"] { input[type="submit"] {
-moz-appearance: button; -moz-appearance: button;
padding: 2px 0 2px 0; /* The sum of border-top, border-bottom, padding-top, padding-bottom
must be the same here, for text inputs, and for <select>. For
buttons, make sure to include the -moz-focus-inner border/padding. */
padding: 0px 8px 0px 8px;
border: 2px outset ButtonFace; border: 2px outset ButtonFace;
background-color: ButtonFace; background-color: ButtonFace;
color: ButtonText; color: ButtonText;
font: -moz-button; font: -moz-button;
line-height: normal !important; line-height: normal !important;
white-space: pre; white-space: pre;
vertical-align: text-bottom;
cursor: default; cursor: default;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
-moz-user-select: none; -moz-user-select: none;
@ -407,15 +411,16 @@ button:active:hover,
input[type="reset"]:active:hover, input[type="reset"]:active:hover,
input[type="button"]:active:hover, input[type="button"]:active:hover,
input[type="submit"]:active:hover { input[type="submit"]:active:hover {
padding: 3px 0 1px 0; padding: 0px 7px 0px 9px;
border-style: inset; border-style: inset;
} }
button:-moz-focus-inner, button:-moz-focus-inner,
input[type="reset"]:-moz-focus-inner, input[type="reset"]:-moz-focus-inner,
input[type="button"]:-moz-focus-inner, input[type="button"]:-moz-focus-inner,
input[type="submit"]:-moz-focus-inner { input[type="submit"]:-moz-focus-inner,
padding: 1px 2px 1px 2px; input[type="file"] > input[type="button"]:-moz-focus-inner {
padding: 0px 2px 0px 2px;
border: 1px dotted transparent; border: 1px dotted transparent;
} }
@ -436,7 +441,9 @@ select[disabled] > input[type="button"],
select[disabled] > input[type="button"]:active, select[disabled] > input[type="button"]:active,
input[type="submit"][disabled]:active, input[type="submit"][disabled]:active,
input[type="submit"][disabled] { input[type="submit"][disabled] {
padding: 3px 1px 3px 1px; /* The sum of border-top, border-bottom, padding-top, padding-bottom
must be the same here and for text inputs */
padding: 1px 8px 1px 8px;
border: 1px outset ButtonShadow; border: 1px outset ButtonShadow;
color: GrayText; color: GrayText;
} }