bugs 642, 643; also removed unused files.

This commit is contained in:
karnaze@netscape.com
1998-09-28 21:32:24 +00:00
parent 39aa20c7df
commit bcd6d1bb45
11 changed files with 155 additions and 1880 deletions

View File

@@ -309,6 +309,22 @@ nsFormControlFrame::GetWidgetInitData(nsIPresContext& aPresContext)
return nsnull; return nsnull;
} }
void
nsFormControlFrame::SetColors()
{
if (mWidget) {
const nsStyleColor* color = nsStyleUtil::FindNonTransparentBackground(mStyleContext);
if (nsnull != color) {
mWidget->SetBackgroundColor(color->mBackgroundColor);
} else {
mWidget->SetBackgroundColor(NS_RGB(0xFF, 0xFF, 0xFF));
}
const nsStyleColor* myColor =
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
mWidget->SetForegroundColor(myColor->mColor);
}
}
void void
nsFormControlFrame::PostCreateWidget(nsIPresContext* aPresContext) nsFormControlFrame::PostCreateWidget(nsIPresContext* aPresContext)
{ {
@@ -549,11 +565,25 @@ void nsFormControlFrame::GetStyleSize(nsIPresContext& aPresContext,
} }
} }
void
GetRepChars(nsIPresContext& aPresContext, char& char1, char& char2)
{
nsCompatibility mode;
aPresContext.GetCompatibilityMode(mode);
if (eCompatibility_Standard == mode) {
char1 = 'm';
char2 = 'a';
} else {
char1 = '%';
char2 = '%';
}
}
nscoord nscoord
nsFormControlFrame::GetTextSize(nsIPresContext& aPresContext, nsFormControlFrame* aFrame, nsFormControlFrame::GetTextSize(nsIPresContext& aPresContext, nsFormControlFrame* aFrame,
const nsString& aString, nsSize& aSize) const nsString& aString, nsSize& aSize)
{ {
nsFont font = aPresContext.GetDefaultFixedFont(); nsFont font(aPresContext.GetDefaultFixedFont());
aFrame->GetFont(&aPresContext, font); aFrame->GetFont(&aPresContext, font);
//printf("\n GetTextSize %s", aString.ToNewCString()); //printf("\n GetTextSize %s", aString.ToNewCString());
nsIDeviceContext* deviceContext = aPresContext.GetDeviceContext(); nsIDeviceContext* deviceContext = aPresContext.GetDeviceContext();
@@ -565,14 +595,17 @@ nsFormControlFrame::GetTextSize(nsIPresContext& aPresContext, nsFormControlFrame
fontMet->GetWidth(aString, aSize.width); fontMet->GetWidth(aString, aSize.width);
fontMet->GetHeight(aSize.height); fontMet->GetHeight(aSize.height);
nscoord charWidth; char char1, char2;
fontMet->GetWidth("W", charWidth); GetRepChars(aPresContext, char1, char2);
nscoord char1Width, char2Width;
fontMet->GetWidth(char1, char1Width);
fontMet->GetWidth(char2, char2Width);
NS_RELEASE(fontMet); NS_RELEASE(fontMet);
NS_RELEASE(fontCache); NS_RELEASE(fontCache);
NS_RELEASE(deviceContext); NS_RELEASE(deviceContext);
return charWidth; return ((char1Width + char2Width) / 2) + 1;
} }
nscoord nscoord
@@ -580,10 +613,13 @@ nsFormControlFrame::GetTextSize(nsIPresContext& aPresContext, nsFormControlFrame
PRInt32 aNumChars, nsSize& aSize) PRInt32 aNumChars, nsSize& aSize)
{ {
nsAutoString val; nsAutoString val;
//char repChar = (kBackwardMode == aFrame->GetMode()) ? '%' : 'e'; char char1, char2;
char repChar = '%'; GetRepChars(aPresContext, char1, char2);
for (int i = 0; i < aNumChars; i++) { for (int i = 0; i < aNumChars; i+=2) {
val += repChar; val += char1;
}
for (i = 1; i < aNumChars; i+=2) {
val += char2;
} }
return GetTextSize(aPresContext, aFrame, val, aSize); return GetTextSize(aPresContext, aFrame, val, aSize);
} }
@@ -629,15 +665,13 @@ nsFormControlFrame::CalculateSize (nsIPresContext* aPresContext, nsFormControlFr
// determine the width // determine the width
nscoord adjSize; nscoord adjSize;
if (NS_CONTENT_ATTR_HAS_VALUE == colStatus) { // col attr will provide width if (NS_CONTENT_ATTR_HAS_VALUE == colStatus) { // col attr will provide width
PRInt32 col = ((colAttr.GetUnit() == eHTMLUnit_Pixel) ? colAttr.GetPixelValue() : colAttr.GetIntValue());
if (aSpec.mColSizeAttrInPixels) { if (aSpec.mColSizeAttrInPixels) {
adjSize = (colAttr.GetPixelValue() > 0) ? colAttr.GetPixelValue() : 15; col = (col <= 0) ? 15 : col;
aBounds.width = NSIntPixelsToTwips(adjSize, p2t); aBounds.width = NSIntPixelsToTwips(col, p2t);
} }
else { else {
PRInt32 col = ((colAttr.GetUnit() == eHTMLUnit_Pixel) ? colAttr.GetPixelValue() : colAttr.GetIntValue()); col = (col <= 0) ? 1 : col;
if (col <= 0) {
col = 1;
}
charWidth = GetTextSize(*aPresContext, aFrame, col, aBounds); charWidth = GetTextSize(*aPresContext, aFrame, col, aBounds);
aRowHeight = aBounds.height; // XXX aBounds.height has CSS_NOTSET aRowHeight = aBounds.height; // XXX aBounds.height has CSS_NOTSET
} }
@@ -731,6 +765,14 @@ nsFormControlFrame::GetFont(nsIPresContext* aPresContext, nsFont& aFont)
{ {
const nsStyleFont* styleFont = (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font); const nsStyleFont* styleFont = (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font);
nsCompatibility mode;
aPresContext->GetCompatibilityMode(mode);
if (eCompatibility_Standard == mode) {
aFont = styleFont->mFont;
return NS_OK;
}
PRInt32 type; PRInt32 type;
GetType(&type); GetType(&type);
switch (type) { switch (type) {

View File

@@ -167,6 +167,7 @@ public:
* created. * created.
*/ */
virtual void PostCreateWidget(nsIPresContext* aPresContext); virtual void PostCreateWidget(nsIPresContext* aPresContext);
void SetColors();
virtual void Reset(); virtual void Reset();
virtual PRBool IsSuccessful(); virtual PRBool IsSuccessful();

View File

@@ -173,6 +173,9 @@ nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredLayoutSize, nsReflowMetrics& aDesiredLayoutSize,
nsSize& aDesiredWidgetSize) nsSize& aDesiredWidgetSize)
{ {
nsCompatibility mode;
aPresContext->GetCompatibilityMode(mode);
// get the css size and let the frame use or override it // get the css size and let the frame use or override it
nsSize styleSize; nsSize styleSize;
GetStyleSize(*aPresContext, aReflowState, styleSize); GetStyleSize(*aPresContext, aReflowState, styleSize);
@@ -188,8 +191,9 @@ nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
if (NS_CONTENT_ATTR_HAS_VALUE != GetSize(&width)) { if (NS_CONTENT_ATTR_HAS_VALUE != GetSize(&width)) {
width = 20; width = 20;
} }
// Nav Quirk!! if (eCompatibility_NavQuirks == mode) {
width += 1; width += 1;
}
nsInputDimensionSpec textSpec(nsnull, PR_FALSE, nsnull, nsInputDimensionSpec textSpec(nsnull, PR_FALSE, nsnull,
nsnull, width, PR_FALSE, nsnull, 1); nsnull, width, PR_FALSE, nsnull, 1);
CalculateSize(aPresContext, this, styleSize, textSpec, size, CalculateSize(aPresContext, this, styleSize, textSpec, size,
@@ -273,9 +277,10 @@ nsTextControlFrame::PostCreateWidget(nsIPresContext* aPresContext)
PRInt32 type; PRInt32 type;
GetType(&type); GetType(&type);
const nsStyleFont* fontStyle = (const nsStyleFont*)(mStyleContext->GetStyleData(eStyleStruct_Font)); nsFont font(aPresContext->GetDefaultFixedFont());
mWidget->SetFont(fontStyle->mFixedFont); GetFont(aPresContext, font);
mWidget->SetBackgroundColor(NS_RGB(0xFF, 0xFF, 0xFF)); mWidget->SetFont(font);
SetColors();
PRUint32 ignore; PRUint32 ignore;

View File

@@ -356,50 +356,25 @@ nsButtonControlFrame::PostCreateWidget(nsIPresContext* aPresContext)
nsIButton* button = nsnull; nsIButton* button = nsnull;
if (mWidget && (NS_OK == mWidget->QueryInterface(kIButtonIID,(void**)&button))) { if (mWidget && (NS_OK == mWidget->QueryInterface(kIButtonIID,(void**)&button))) {
if (NS_FORM_BROWSE != type) { // browse button always uses default nsFont font(aPresContext->GetDefaultFixedFont());
const nsStyleFont* styleFont = (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font); GetFont(aPresContext, font);
if ((styleFont->mFlags & NS_STYLE_FONT_FACE_EXPLICIT) || mWidget->SetFont(font);
(styleFont->mFlags & NS_STYLE_FONT_SIZE_EXPLICIT)) { SetColors();
nsFont widgetFont(styleFont->mFixedFont);
widgetFont.weight = NS_FONT_WEIGHT_NORMAL; // always normal weight
widgetFont.size = styleFont->mFont.size; // normal font size
if (0 == (styleFont->mFlags & NS_STYLE_FONT_FACE_EXPLICIT)) {
widgetFont.name = "Arial"; // XXX windows specific font
}
mWidget->SetFont(widgetFont);
}
else {
// use arial, scaled down one HTML size
// italics, decoration & variant(?) get used
nsFont widgetFont(styleFont->mFont);
widgetFont.name = "Arial"; // XXX windows specific font
widgetFont.weight = NS_FONT_WEIGHT_NORMAL;
const nsFont& normal = aPresContext->GetDefaultFont();
PRInt32 scaler = aPresContext->GetFontScaler();
float scaleFactor = nsStyleUtil::GetScalingFactor(scaler);
PRInt32 fontIndex = nsStyleUtil::FindNextSmallerFontSize(widgetFont.size, (PRInt32)normal.size, scaleFactor);
widgetFont.size = nsStyleUtil::CalcFontPointSize(fontIndex, (PRInt32)normal.size, scaleFactor);
mWidget->SetFont(widgetFont);
}
}
}
else {
NS_ASSERTION(0, "no widget in button control");
}
nsString value; nsString value;
nsresult result = GetValue(&value); nsresult result = GetValue(&value);
if (button != nsnull) { if (button != nsnull) {
if (NS_CONTENT_ATTR_HAS_VALUE == result) { if (NS_CONTENT_ATTR_HAS_VALUE == result) {
button->SetLabel(value); button->SetLabel(value);
} else { } else {
nsAutoString label; nsAutoString label;
GetDefaultLabel(label); GetDefaultLabel(label);
button->SetLabel(label); button->SetLabel(label);
}
} }
} NS_RELEASE(button);
NS_IF_RELEASE(button); }
} }
const nsIID& const nsIID&

View File

@@ -151,16 +151,7 @@ nsCheckboxControlFrame::PostCreateWidget(nsIPresContext* aPresContext)
if (mWidget && (NS_OK == mWidget->QueryInterface(GetIID(),(void**)&checkbox))) { if (mWidget && (NS_OK == mWidget->QueryInterface(GetIID(),(void**)&checkbox))) {
checkbox->SetState(checked); checkbox->SetState(checked);
SetColors();
const nsStyleColor* color =
nsStyleUtil::FindNonTransparentBackground(mStyleContext);
if (nsnull != color) {
mWidget->SetBackgroundColor(color->mBackgroundColor);
} else {
mWidget->SetBackgroundColor(NS_RGB(0xFF, 0xFF, 0xFF));
}
NS_IF_RELEASE(checkbox); NS_IF_RELEASE(checkbox);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -309,6 +309,22 @@ nsFormControlFrame::GetWidgetInitData(nsIPresContext& aPresContext)
return nsnull; return nsnull;
} }
void
nsFormControlFrame::SetColors()
{
if (mWidget) {
const nsStyleColor* color = nsStyleUtil::FindNonTransparentBackground(mStyleContext);
if (nsnull != color) {
mWidget->SetBackgroundColor(color->mBackgroundColor);
} else {
mWidget->SetBackgroundColor(NS_RGB(0xFF, 0xFF, 0xFF));
}
const nsStyleColor* myColor =
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
mWidget->SetForegroundColor(myColor->mColor);
}
}
void void
nsFormControlFrame::PostCreateWidget(nsIPresContext* aPresContext) nsFormControlFrame::PostCreateWidget(nsIPresContext* aPresContext)
{ {
@@ -549,11 +565,25 @@ void nsFormControlFrame::GetStyleSize(nsIPresContext& aPresContext,
} }
} }
void
GetRepChars(nsIPresContext& aPresContext, char& char1, char& char2)
{
nsCompatibility mode;
aPresContext.GetCompatibilityMode(mode);
if (eCompatibility_Standard == mode) {
char1 = 'm';
char2 = 'a';
} else {
char1 = '%';
char2 = '%';
}
}
nscoord nscoord
nsFormControlFrame::GetTextSize(nsIPresContext& aPresContext, nsFormControlFrame* aFrame, nsFormControlFrame::GetTextSize(nsIPresContext& aPresContext, nsFormControlFrame* aFrame,
const nsString& aString, nsSize& aSize) const nsString& aString, nsSize& aSize)
{ {
nsFont font = aPresContext.GetDefaultFixedFont(); nsFont font(aPresContext.GetDefaultFixedFont());
aFrame->GetFont(&aPresContext, font); aFrame->GetFont(&aPresContext, font);
//printf("\n GetTextSize %s", aString.ToNewCString()); //printf("\n GetTextSize %s", aString.ToNewCString());
nsIDeviceContext* deviceContext = aPresContext.GetDeviceContext(); nsIDeviceContext* deviceContext = aPresContext.GetDeviceContext();
@@ -565,14 +595,17 @@ nsFormControlFrame::GetTextSize(nsIPresContext& aPresContext, nsFormControlFrame
fontMet->GetWidth(aString, aSize.width); fontMet->GetWidth(aString, aSize.width);
fontMet->GetHeight(aSize.height); fontMet->GetHeight(aSize.height);
nscoord charWidth; char char1, char2;
fontMet->GetWidth("W", charWidth); GetRepChars(aPresContext, char1, char2);
nscoord char1Width, char2Width;
fontMet->GetWidth(char1, char1Width);
fontMet->GetWidth(char2, char2Width);
NS_RELEASE(fontMet); NS_RELEASE(fontMet);
NS_RELEASE(fontCache); NS_RELEASE(fontCache);
NS_RELEASE(deviceContext); NS_RELEASE(deviceContext);
return charWidth; return ((char1Width + char2Width) / 2) + 1;
} }
nscoord nscoord
@@ -580,10 +613,13 @@ nsFormControlFrame::GetTextSize(nsIPresContext& aPresContext, nsFormControlFrame
PRInt32 aNumChars, nsSize& aSize) PRInt32 aNumChars, nsSize& aSize)
{ {
nsAutoString val; nsAutoString val;
//char repChar = (kBackwardMode == aFrame->GetMode()) ? '%' : 'e'; char char1, char2;
char repChar = '%'; GetRepChars(aPresContext, char1, char2);
for (int i = 0; i < aNumChars; i++) { for (int i = 0; i < aNumChars; i+=2) {
val += repChar; val += char1;
}
for (i = 1; i < aNumChars; i+=2) {
val += char2;
} }
return GetTextSize(aPresContext, aFrame, val, aSize); return GetTextSize(aPresContext, aFrame, val, aSize);
} }
@@ -629,15 +665,13 @@ nsFormControlFrame::CalculateSize (nsIPresContext* aPresContext, nsFormControlFr
// determine the width // determine the width
nscoord adjSize; nscoord adjSize;
if (NS_CONTENT_ATTR_HAS_VALUE == colStatus) { // col attr will provide width if (NS_CONTENT_ATTR_HAS_VALUE == colStatus) { // col attr will provide width
PRInt32 col = ((colAttr.GetUnit() == eHTMLUnit_Pixel) ? colAttr.GetPixelValue() : colAttr.GetIntValue());
if (aSpec.mColSizeAttrInPixels) { if (aSpec.mColSizeAttrInPixels) {
adjSize = (colAttr.GetPixelValue() > 0) ? colAttr.GetPixelValue() : 15; col = (col <= 0) ? 15 : col;
aBounds.width = NSIntPixelsToTwips(adjSize, p2t); aBounds.width = NSIntPixelsToTwips(col, p2t);
} }
else { else {
PRInt32 col = ((colAttr.GetUnit() == eHTMLUnit_Pixel) ? colAttr.GetPixelValue() : colAttr.GetIntValue()); col = (col <= 0) ? 1 : col;
if (col <= 0) {
col = 1;
}
charWidth = GetTextSize(*aPresContext, aFrame, col, aBounds); charWidth = GetTextSize(*aPresContext, aFrame, col, aBounds);
aRowHeight = aBounds.height; // XXX aBounds.height has CSS_NOTSET aRowHeight = aBounds.height; // XXX aBounds.height has CSS_NOTSET
} }
@@ -731,6 +765,14 @@ nsFormControlFrame::GetFont(nsIPresContext* aPresContext, nsFont& aFont)
{ {
const nsStyleFont* styleFont = (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font); const nsStyleFont* styleFont = (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font);
nsCompatibility mode;
aPresContext->GetCompatibilityMode(mode);
if (eCompatibility_Standard == mode) {
aFont = styleFont->mFont;
return NS_OK;
}
PRInt32 type; PRInt32 type;
GetType(&type); GetType(&type);
switch (type) { switch (type) {

View File

@@ -167,6 +167,7 @@ public:
* created. * created.
*/ */
virtual void PostCreateWidget(nsIPresContext* aPresContext); virtual void PostCreateWidget(nsIPresContext* aPresContext);
void SetColors();
virtual void Reset(); virtual void Reset();
virtual PRBool IsSuccessful(); virtual PRBool IsSuccessful();

View File

@@ -1,224 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsInput_h___
#define nsInput_h___
#include "nsHTMLContainer.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIFormControl.h"
#include "nsPoint.h"
class nsIFormManager;
class nsIWidget;
class nsIView;
class nsIPresContext;
/**
* nsInput represents an html Input element. This is a base class for
* the various Input types (button, checkbox, file, hidden, password,
* reset, radio, submit, text)
*/
class nsInput : public nsHTMLContainer, public nsIDOMHTMLInputElement {
public:
typedef nsHTMLContainer nsInputSuper;
/**
* main constructor
* @param aTag the html tag associated with this object
* @param aManager the form manager to manage this input
*/
nsInput(nsIAtom* aTag, nsIFormManager* aManager);
NS_IMETHOD GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) const;
static void MapAttributesInto(nsIHTMLAttributes* aAttributes,
nsIStyleContext* aContext,
nsIPresContext* aPresContext);
/**
* @see nsISupports QueryInterface
*/
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
/**
* @see nsISupports Release
*/
NS_IMETHOD_(nsrefcnt) Release(void);
/**
* @see nsISupports Release
*/
NS_IMETHOD_(nsrefcnt) AddRef(void);
// nsIFormControl methods
virtual PRBool GetCanSubmit() const;
virtual PRBool GetContent(nsString& aResult) const;
/**
* @see nsIFormControl GetFormManager
*/
virtual nsIFormManager* GetFormManager() const;
/**
* @see nsIFormControl GetFormManager
*/
virtual PRInt32 GetMaxNumValues();
/**
* @see nsIFormControl GetFormManager
*/
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
nsString* aValues, nsString* aNames);
virtual PRBool IsHidden();
virtual PRBool IsSuccessful(nsIFormControl* aSubmitter) const;
/**
* @see nsIFormControl GetFormManager
*/
virtual void Reset();
virtual void SetCanSubmit(PRBool aFlag);
virtual void SetContent(const nsString& aValue);
/**
* @see nsIFormControl GetFormManager
*/
virtual void SetFormManager(nsIFormManager* aFormMan, PRBool aDecrementRef = PR_TRUE);
// attribute methods
/**
* Get a named attribute of this input
* @param aAttribute the name of the attribute
* @param aValue the value of the attribute
* @return eContentAttr_HasValue if there is a value, eContentAttr_NoValue
* if there is an attribute but no value, or eContentAttr_HasValue
* if there is no attribute.
*/
NS_IMETHOD GetAttribute(nsIAtom* aAttribute,
nsHTMLValue& aValue) const;
NS_IMETHOD GetAttribute(nsIAtom* aAttribute, PRInt32& aValue) const;
/**
* Set the named attribute of this input
* @param aAttribute the name of the attribute
* @param aValue the value of the attribute
*/
NS_IMETHOD SetAttribute(nsIAtom* aAttribute, const nsString& aValue,
PRBool aNotify);
NS_FORWARD_IDOMNODE(nsHTMLContainer::)
NS_FORWARD_IDOMELEMENT(nsHTMLContainer::)
NS_FORWARD_IDOMHTMLELEMENT(nsHTMLContainer::)
NS_DECL_IDOMHTMLINPUTELEMENT
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
// misc methods
/**
* Get the number of references to this input
* @return the number of references
**/
virtual nsrefcnt GetRefCount() const;
/**
* Get the widget associated with this input
* @return the widget, not a copy
**/
nsIWidget* GetWidget();
nsISupports* GetWidgetSupports();
/**
* Set the widget associated with this input
* @param aWidget the widget
**/
void SetWidget(nsIWidget* aWidget);
// this should not be public
static PRInt32 GetOuterOffset() {
return offsetof(nsInput,mControl);
}
virtual void GetType(nsString& aResult) const = 0;
PRInt32 GetSize() const { return mSize; }
virtual PRBool GetChecked(PRBool aGetInitialValue) const;
virtual void SetChecked(PRBool aState, PRBool aSetInitialValue);
virtual void SetClickPoint(nscoord aX, nscoord aY);
protected:
virtual ~nsInput();
/**
* Get the type of this control
*/
nsIWidget* mWidget;
nsISupports* mWidgetSupports;
nsIFormManager* mFormMan;
nsPoint mLastClickPoint;
PRBool mCanSubmit;
void CacheAttribute(const nsString& aValue, nsString*& aLoc);
void CacheAttribute(const nsString& aValue, PRInt32 aMinValue, PRInt32& aLoc);
nsresult GetCacheAttribute(nsString* const& aLoc, nsHTMLValue& aValue) const;
nsresult GetCacheAttribute(PRInt32 aLoc, nsHTMLValue& aValue, nsHTMLUnit aUnit) const;
// Attributes common to all html form elements
nsString* mName;
nsString* mValue;
PRInt32 mSize;
PRUint8 mAlign;
// Aggregator class and instance variable used to aggregate in the
// nsIFormControl interface to nsInput w/o using multiple
// inheritance.
class AggInputControl : public nsIFormControl {
public:
AggInputControl();
~AggInputControl();
// nsISupports
NS_DECL_ISUPPORTS
// nsIFormControl
virtual PRBool GetCanSubmit() const;
virtual PRBool GetContent(nsString& aResult) const;
virtual nsresult GetName(nsString& aName);
virtual void GetType(nsString& aType) const;
virtual PRInt32 GetMaxNumValues();
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
nsString* aValues, nsString* aNames);
virtual void Reset();
virtual void SetCanSubmit(PRBool aFlag);
virtual void SetContent(const nsString& aValue);
virtual void SetFormManager(nsIFormManager* aFormMan, PRBool aDecrementRef = PR_TRUE);
virtual nsIFormManager* GetFormManager() const;
virtual nsrefcnt GetRefCount() const;
virtual PRBool GetChecked(PRBool aGetInitialValue) const;
virtual void SetChecked(PRBool aState, PRBool aSetInitialValue);
virtual PRBool IsSuccessful(nsIFormControl* aSubmitter) const;
};
AggInputControl mControl;
};
#endif

View File

@@ -351,31 +351,11 @@ nsSelectControlFrame::PostCreateWidget(nsIPresContext* aPresContext)
NS_ASSERTION(PR_FALSE, "invalid widget"); NS_ASSERTION(PR_FALSE, "invalid widget");
return; return;
} }
mWidget->SetBackgroundColor(NS_RGB(0xFF, 0xFF, 0xFF));
const nsStyleFont* styleFont = (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font); nsFont font(aPresContext->GetDefaultFixedFont());
if ((styleFont->mFlags & NS_STYLE_FONT_FACE_EXPLICIT) || GetFont(aPresContext, font);
(styleFont->mFlags & NS_STYLE_FONT_SIZE_EXPLICIT)) { mWidget->SetFont(font);
nsFont widgetFont(styleFont->mFixedFont); SetColors();
widgetFont.weight = NS_FONT_WEIGHT_NORMAL; // always normal weight
widgetFont.size = styleFont->mFont.size; // normal font size
if (0 == (styleFont->mFlags & NS_STYLE_FONT_FACE_EXPLICIT)) {
widgetFont.name = "Arial"; // XXX windows specific font
}
mWidget->SetFont(widgetFont);
} else {
// use arial, scaled down one HTML size
// italics, decoration & variant(?) get used
nsFont widgetFont(styleFont->mFont);
widgetFont.name = "Arial"; // XXX windows specific font
widgetFont.weight = NS_FONT_WEIGHT_NORMAL;
const nsFont& normal = aPresContext->GetDefaultFont();
PRInt32 scaler = aPresContext->GetFontScaler();
float scaleFactor = nsStyleUtil::GetScalingFactor(scaler);
PRInt32 fontIndex = nsStyleUtil::FindNextSmallerFontSize(widgetFont.size, (PRInt32)normal.size, scaleFactor);
widgetFont.size = nsStyleUtil::CalcFontPointSize(fontIndex, (PRInt32)normal.size, scaleFactor);
mWidget->SetFont(widgetFont);
}
// add the options // add the options
if (!mOptionsAdded) { if (!mOptionsAdded) {

View File

@@ -173,6 +173,9 @@ nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
nsReflowMetrics& aDesiredLayoutSize, nsReflowMetrics& aDesiredLayoutSize,
nsSize& aDesiredWidgetSize) nsSize& aDesiredWidgetSize)
{ {
nsCompatibility mode;
aPresContext->GetCompatibilityMode(mode);
// get the css size and let the frame use or override it // get the css size and let the frame use or override it
nsSize styleSize; nsSize styleSize;
GetStyleSize(*aPresContext, aReflowState, styleSize); GetStyleSize(*aPresContext, aReflowState, styleSize);
@@ -188,8 +191,9 @@ nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
if (NS_CONTENT_ATTR_HAS_VALUE != GetSize(&width)) { if (NS_CONTENT_ATTR_HAS_VALUE != GetSize(&width)) {
width = 20; width = 20;
} }
// Nav Quirk!! if (eCompatibility_NavQuirks == mode) {
width += 1; width += 1;
}
nsInputDimensionSpec textSpec(nsnull, PR_FALSE, nsnull, nsInputDimensionSpec textSpec(nsnull, PR_FALSE, nsnull,
nsnull, width, PR_FALSE, nsnull, 1); nsnull, width, PR_FALSE, nsnull, 1);
CalculateSize(aPresContext, this, styleSize, textSpec, size, CalculateSize(aPresContext, this, styleSize, textSpec, size,
@@ -273,9 +277,10 @@ nsTextControlFrame::PostCreateWidget(nsIPresContext* aPresContext)
PRInt32 type; PRInt32 type;
GetType(&type); GetType(&type);
const nsStyleFont* fontStyle = (const nsStyleFont*)(mStyleContext->GetStyleData(eStyleStruct_Font)); nsFont font(aPresContext->GetDefaultFixedFont());
mWidget->SetFont(fontStyle->mFixedFont); GetFont(aPresContext, font);
mWidget->SetBackgroundColor(NS_RGB(0xFF, 0xFF, 0xFF)); mWidget->SetFont(font);
SetColors();
PRUint32 ignore; PRUint32 ignore;