bugs 642, 643; also removed unused files.
This commit is contained in:
@@ -309,6 +309,22 @@ nsFormControlFrame::GetWidgetInitData(nsIPresContext& aPresContext)
|
||||
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
|
||||
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
|
||||
nsFormControlFrame::GetTextSize(nsIPresContext& aPresContext, nsFormControlFrame* aFrame,
|
||||
const nsString& aString, nsSize& aSize)
|
||||
{
|
||||
nsFont font = aPresContext.GetDefaultFixedFont();
|
||||
nsFont font(aPresContext.GetDefaultFixedFont());
|
||||
aFrame->GetFont(&aPresContext, font);
|
||||
//printf("\n GetTextSize %s", aString.ToNewCString());
|
||||
nsIDeviceContext* deviceContext = aPresContext.GetDeviceContext();
|
||||
@@ -565,14 +595,17 @@ nsFormControlFrame::GetTextSize(nsIPresContext& aPresContext, nsFormControlFrame
|
||||
fontMet->GetWidth(aString, aSize.width);
|
||||
fontMet->GetHeight(aSize.height);
|
||||
|
||||
nscoord charWidth;
|
||||
fontMet->GetWidth("W", charWidth);
|
||||
char char1, char2;
|
||||
GetRepChars(aPresContext, char1, char2);
|
||||
nscoord char1Width, char2Width;
|
||||
fontMet->GetWidth(char1, char1Width);
|
||||
fontMet->GetWidth(char2, char2Width);
|
||||
|
||||
NS_RELEASE(fontMet);
|
||||
NS_RELEASE(fontCache);
|
||||
NS_RELEASE(deviceContext);
|
||||
|
||||
return charWidth;
|
||||
return ((char1Width + char2Width) / 2) + 1;
|
||||
}
|
||||
|
||||
nscoord
|
||||
@@ -580,10 +613,13 @@ nsFormControlFrame::GetTextSize(nsIPresContext& aPresContext, nsFormControlFrame
|
||||
PRInt32 aNumChars, nsSize& aSize)
|
||||
{
|
||||
nsAutoString val;
|
||||
//char repChar = (kBackwardMode == aFrame->GetMode()) ? '%' : 'e';
|
||||
char repChar = '%';
|
||||
for (int i = 0; i < aNumChars; i++) {
|
||||
val += repChar;
|
||||
char char1, char2;
|
||||
GetRepChars(aPresContext, char1, char2);
|
||||
for (int i = 0; i < aNumChars; i+=2) {
|
||||
val += char1;
|
||||
}
|
||||
for (i = 1; i < aNumChars; i+=2) {
|
||||
val += char2;
|
||||
}
|
||||
return GetTextSize(aPresContext, aFrame, val, aSize);
|
||||
}
|
||||
@@ -629,15 +665,13 @@ nsFormControlFrame::CalculateSize (nsIPresContext* aPresContext, nsFormControlFr
|
||||
// determine the width
|
||||
nscoord adjSize;
|
||||
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) {
|
||||
adjSize = (colAttr.GetPixelValue() > 0) ? colAttr.GetPixelValue() : 15;
|
||||
aBounds.width = NSIntPixelsToTwips(adjSize, p2t);
|
||||
col = (col <= 0) ? 15 : col;
|
||||
aBounds.width = NSIntPixelsToTwips(col, p2t);
|
||||
}
|
||||
else {
|
||||
PRInt32 col = ((colAttr.GetUnit() == eHTMLUnit_Pixel) ? colAttr.GetPixelValue() : colAttr.GetIntValue());
|
||||
if (col <= 0) {
|
||||
col = 1;
|
||||
}
|
||||
col = (col <= 0) ? 1 : col;
|
||||
charWidth = GetTextSize(*aPresContext, aFrame, col, aBounds);
|
||||
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);
|
||||
|
||||
nsCompatibility mode;
|
||||
aPresContext->GetCompatibilityMode(mode);
|
||||
|
||||
if (eCompatibility_Standard == mode) {
|
||||
aFont = styleFont->mFont;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
switch (type) {
|
||||
|
||||
@@ -167,6 +167,7 @@ public:
|
||||
* created.
|
||||
*/
|
||||
virtual void PostCreateWidget(nsIPresContext* aPresContext);
|
||||
void SetColors();
|
||||
|
||||
virtual void Reset();
|
||||
virtual PRBool IsSuccessful();
|
||||
|
||||
@@ -173,6 +173,9 @@ nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
||||
nsReflowMetrics& aDesiredLayoutSize,
|
||||
nsSize& aDesiredWidgetSize)
|
||||
{
|
||||
nsCompatibility mode;
|
||||
aPresContext->GetCompatibilityMode(mode);
|
||||
|
||||
// get the css size and let the frame use or override it
|
||||
nsSize styleSize;
|
||||
GetStyleSize(*aPresContext, aReflowState, styleSize);
|
||||
@@ -188,8 +191,9 @@ nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE != GetSize(&width)) {
|
||||
width = 20;
|
||||
}
|
||||
// Nav Quirk!!
|
||||
if (eCompatibility_NavQuirks == mode) {
|
||||
width += 1;
|
||||
}
|
||||
nsInputDimensionSpec textSpec(nsnull, PR_FALSE, nsnull,
|
||||
nsnull, width, PR_FALSE, nsnull, 1);
|
||||
CalculateSize(aPresContext, this, styleSize, textSpec, size,
|
||||
@@ -273,9 +277,10 @@ nsTextControlFrame::PostCreateWidget(nsIPresContext* aPresContext)
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
|
||||
const nsStyleFont* fontStyle = (const nsStyleFont*)(mStyleContext->GetStyleData(eStyleStruct_Font));
|
||||
mWidget->SetFont(fontStyle->mFixedFont);
|
||||
mWidget->SetBackgroundColor(NS_RGB(0xFF, 0xFF, 0xFF));
|
||||
nsFont font(aPresContext->GetDefaultFixedFont());
|
||||
GetFont(aPresContext, font);
|
||||
mWidget->SetFont(font);
|
||||
SetColors();
|
||||
|
||||
PRUint32 ignore;
|
||||
|
||||
|
||||
@@ -356,36 +356,10 @@ nsButtonControlFrame::PostCreateWidget(nsIPresContext* aPresContext)
|
||||
|
||||
nsIButton* button = nsnull;
|
||||
if (mWidget && (NS_OK == mWidget->QueryInterface(kIButtonIID,(void**)&button))) {
|
||||
if (NS_FORM_BROWSE != type) { // browse button always uses default
|
||||
const nsStyleFont* styleFont = (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font);
|
||||
if ((styleFont->mFlags & NS_STYLE_FONT_FACE_EXPLICIT) ||
|
||||
(styleFont->mFlags & NS_STYLE_FONT_SIZE_EXPLICIT)) {
|
||||
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");
|
||||
}
|
||||
nsFont font(aPresContext->GetDefaultFixedFont());
|
||||
GetFont(aPresContext, font);
|
||||
mWidget->SetFont(font);
|
||||
SetColors();
|
||||
|
||||
nsString value;
|
||||
nsresult result = GetValue(&value);
|
||||
@@ -399,7 +373,8 @@ nsButtonControlFrame::PostCreateWidget(nsIPresContext* aPresContext)
|
||||
button->SetLabel(label);
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(button);
|
||||
NS_RELEASE(button);
|
||||
}
|
||||
}
|
||||
|
||||
const nsIID&
|
||||
|
||||
@@ -151,16 +151,7 @@ nsCheckboxControlFrame::PostCreateWidget(nsIPresContext* aPresContext)
|
||||
|
||||
if (mWidget && (NS_OK == mWidget->QueryInterface(GetIID(),(void**)&checkbox))) {
|
||||
checkbox->SetState(checked);
|
||||
|
||||
const nsStyleColor* color =
|
||||
nsStyleUtil::FindNonTransparentBackground(mStyleContext);
|
||||
|
||||
if (nsnull != color) {
|
||||
mWidget->SetBackgroundColor(color->mBackgroundColor);
|
||||
} else {
|
||||
mWidget->SetBackgroundColor(NS_RGB(0xFF, 0xFF, 0xFF));
|
||||
}
|
||||
|
||||
SetColors();
|
||||
NS_IF_RELEASE(checkbox);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -309,6 +309,22 @@ nsFormControlFrame::GetWidgetInitData(nsIPresContext& aPresContext)
|
||||
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
|
||||
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
|
||||
nsFormControlFrame::GetTextSize(nsIPresContext& aPresContext, nsFormControlFrame* aFrame,
|
||||
const nsString& aString, nsSize& aSize)
|
||||
{
|
||||
nsFont font = aPresContext.GetDefaultFixedFont();
|
||||
nsFont font(aPresContext.GetDefaultFixedFont());
|
||||
aFrame->GetFont(&aPresContext, font);
|
||||
//printf("\n GetTextSize %s", aString.ToNewCString());
|
||||
nsIDeviceContext* deviceContext = aPresContext.GetDeviceContext();
|
||||
@@ -565,14 +595,17 @@ nsFormControlFrame::GetTextSize(nsIPresContext& aPresContext, nsFormControlFrame
|
||||
fontMet->GetWidth(aString, aSize.width);
|
||||
fontMet->GetHeight(aSize.height);
|
||||
|
||||
nscoord charWidth;
|
||||
fontMet->GetWidth("W", charWidth);
|
||||
char char1, char2;
|
||||
GetRepChars(aPresContext, char1, char2);
|
||||
nscoord char1Width, char2Width;
|
||||
fontMet->GetWidth(char1, char1Width);
|
||||
fontMet->GetWidth(char2, char2Width);
|
||||
|
||||
NS_RELEASE(fontMet);
|
||||
NS_RELEASE(fontCache);
|
||||
NS_RELEASE(deviceContext);
|
||||
|
||||
return charWidth;
|
||||
return ((char1Width + char2Width) / 2) + 1;
|
||||
}
|
||||
|
||||
nscoord
|
||||
@@ -580,10 +613,13 @@ nsFormControlFrame::GetTextSize(nsIPresContext& aPresContext, nsFormControlFrame
|
||||
PRInt32 aNumChars, nsSize& aSize)
|
||||
{
|
||||
nsAutoString val;
|
||||
//char repChar = (kBackwardMode == aFrame->GetMode()) ? '%' : 'e';
|
||||
char repChar = '%';
|
||||
for (int i = 0; i < aNumChars; i++) {
|
||||
val += repChar;
|
||||
char char1, char2;
|
||||
GetRepChars(aPresContext, char1, char2);
|
||||
for (int i = 0; i < aNumChars; i+=2) {
|
||||
val += char1;
|
||||
}
|
||||
for (i = 1; i < aNumChars; i+=2) {
|
||||
val += char2;
|
||||
}
|
||||
return GetTextSize(aPresContext, aFrame, val, aSize);
|
||||
}
|
||||
@@ -629,15 +665,13 @@ nsFormControlFrame::CalculateSize (nsIPresContext* aPresContext, nsFormControlFr
|
||||
// determine the width
|
||||
nscoord adjSize;
|
||||
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) {
|
||||
adjSize = (colAttr.GetPixelValue() > 0) ? colAttr.GetPixelValue() : 15;
|
||||
aBounds.width = NSIntPixelsToTwips(adjSize, p2t);
|
||||
col = (col <= 0) ? 15 : col;
|
||||
aBounds.width = NSIntPixelsToTwips(col, p2t);
|
||||
}
|
||||
else {
|
||||
PRInt32 col = ((colAttr.GetUnit() == eHTMLUnit_Pixel) ? colAttr.GetPixelValue() : colAttr.GetIntValue());
|
||||
if (col <= 0) {
|
||||
col = 1;
|
||||
}
|
||||
col = (col <= 0) ? 1 : col;
|
||||
charWidth = GetTextSize(*aPresContext, aFrame, col, aBounds);
|
||||
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);
|
||||
|
||||
nsCompatibility mode;
|
||||
aPresContext->GetCompatibilityMode(mode);
|
||||
|
||||
if (eCompatibility_Standard == mode) {
|
||||
aFont = styleFont->mFont;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
switch (type) {
|
||||
|
||||
@@ -167,6 +167,7 @@ public:
|
||||
* created.
|
||||
*/
|
||||
virtual void PostCreateWidget(nsIPresContext* aPresContext);
|
||||
void SetColors();
|
||||
|
||||
virtual void Reset();
|
||||
virtual PRBool IsSuccessful();
|
||||
|
||||
@@ -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
|
||||
@@ -351,31 +351,11 @@ nsSelectControlFrame::PostCreateWidget(nsIPresContext* aPresContext)
|
||||
NS_ASSERTION(PR_FALSE, "invalid widget");
|
||||
return;
|
||||
}
|
||||
mWidget->SetBackgroundColor(NS_RGB(0xFF, 0xFF, 0xFF));
|
||||
|
||||
const nsStyleFont* styleFont = (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font);
|
||||
if ((styleFont->mFlags & NS_STYLE_FONT_FACE_EXPLICIT) ||
|
||||
(styleFont->mFlags & NS_STYLE_FONT_SIZE_EXPLICIT)) {
|
||||
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);
|
||||
}
|
||||
nsFont font(aPresContext->GetDefaultFixedFont());
|
||||
GetFont(aPresContext, font);
|
||||
mWidget->SetFont(font);
|
||||
SetColors();
|
||||
|
||||
// add the options
|
||||
if (!mOptionsAdded) {
|
||||
|
||||
@@ -173,6 +173,9 @@ nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
||||
nsReflowMetrics& aDesiredLayoutSize,
|
||||
nsSize& aDesiredWidgetSize)
|
||||
{
|
||||
nsCompatibility mode;
|
||||
aPresContext->GetCompatibilityMode(mode);
|
||||
|
||||
// get the css size and let the frame use or override it
|
||||
nsSize styleSize;
|
||||
GetStyleSize(*aPresContext, aReflowState, styleSize);
|
||||
@@ -188,8 +191,9 @@ nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE != GetSize(&width)) {
|
||||
width = 20;
|
||||
}
|
||||
// Nav Quirk!!
|
||||
if (eCompatibility_NavQuirks == mode) {
|
||||
width += 1;
|
||||
}
|
||||
nsInputDimensionSpec textSpec(nsnull, PR_FALSE, nsnull,
|
||||
nsnull, width, PR_FALSE, nsnull, 1);
|
||||
CalculateSize(aPresContext, this, styleSize, textSpec, size,
|
||||
@@ -273,9 +277,10 @@ nsTextControlFrame::PostCreateWidget(nsIPresContext* aPresContext)
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
|
||||
const nsStyleFont* fontStyle = (const nsStyleFont*)(mStyleContext->GetStyleData(eStyleStruct_Font));
|
||||
mWidget->SetFont(fontStyle->mFixedFont);
|
||||
mWidget->SetBackgroundColor(NS_RGB(0xFF, 0xFF, 0xFF));
|
||||
nsFont font(aPresContext->GetDefaultFixedFont());
|
||||
GetFont(aPresContext, font);
|
||||
mWidget->SetFont(font);
|
||||
SetColors();
|
||||
|
||||
PRUint32 ignore;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user