diff --git a/mozilla/layout/html/forms/src/nsInput.cpp b/mozilla/layout/html/forms/src/nsInput.cpp index 72fd43d2c61..4d16ff0c5c4 100644 --- a/mozilla/layout/html/forms/src/nsInput.cpp +++ b/mozilla/layout/html/forms/src/nsInput.cpp @@ -36,6 +36,7 @@ #include "nsHTMLForms.h" #include "nsStyleConsts.h" +#define ALIGN_UNSET PRUint8(-1); static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID); static NS_DEFINE_IID(kStyleTextSID, NS_STYLETEXT_SID); @@ -49,7 +50,7 @@ nsInput::nsInput(nsIAtom* aTag, nsIFormManager* aManager) mFormMan->AddFormControl(&mControl); } mSize = ATTR_NOTSET; - mAlign = nsnull; + mAlign = ALIGN_UNSET; mWidth = ATTR_NOTSET; mHeight= ATTR_NOTSET; mLastClickPoint.x = -1; @@ -88,11 +89,10 @@ void nsInput::SetContent(const nsString& aValue) } void nsInput::MapAttributesInto(nsIStyleContext* aContext, - nsIPresContext* aPresContext) + nsIPresContext* aPresContext) { -#if 0 - XXX - if (ATTR_NOTSET != mAlign) { + // if (ALIGN_UNSET != mAlign) { XXX why won't this compile + if (-1 != mAlign) { nsStyleDisplay* display = (nsStyleDisplay*) aContext->GetData(kStyleDisplaySID); nsStyleText* text = (nsStyleText*) @@ -104,16 +104,15 @@ void nsInput::MapAttributesInto(nsIStyleContext* aContext, case NS_STYLE_TEXT_ALIGN_RIGHT: display->mFloats = NS_STYLE_FLOAT_RIGHT; break; -#if 0 default: - text->mVerticalAlignFlags = mAlign; + text->mVerticalAlign.SetIntValue(mAlign, eStyleUnit_Enumerated); break; -#endif } } -#endif + MapImagePropertiesInto(aContext, aPresContext); } + static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID); nsresult nsInput::QueryInterface(REFNSIID aIID, void** aInstancePtr) @@ -290,16 +289,26 @@ void nsInput::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) } else if (aAttribute == nsHTMLAtoms::width) { CacheAttribute(aValue, ATTR_NOTSET, mWidth); + nsInputSuper::SetAttribute(aAttribute, aValue); // is this needed? } else if (aAttribute == nsHTMLAtoms::height) { CacheAttribute(aValue, ATTR_NOTSET, mHeight); + nsInputSuper::SetAttribute(aAttribute, aValue); // is this needed? } else if (aAttribute == nsHTMLAtoms::value) { CacheAttribute(aValue, mValue); } else if (aAttribute == nsHTMLAtoms::align) { - CacheAttribute(aValue, ATTR_NOTSET, mAlign); - } + nsHTMLValue val; + if (ParseAlignParam(aValue, val)) { + mAlign = val.GetIntValue(); + // Reflect the attribute into the syle system + nsHTMLTagContent::SetAttribute(aAttribute, val); // is this needed? + } else { + mAlign = ALIGN_UNSET; + } + return; + } else { nsInputSuper::SetAttribute(aAttribute, aValue); } diff --git a/mozilla/layout/html/forms/src/nsInput.h b/mozilla/layout/html/forms/src/nsInput.h index 75cc0be0027..afe3bf4aba6 100644 --- a/mozilla/layout/html/forms/src/nsInput.h +++ b/mozilla/layout/html/forms/src/nsInput.h @@ -177,7 +177,7 @@ protected: nsString* mName; nsString* mValue; PRInt32 mSize; - PRInt32 mAlign; + PRUint8 mAlign; PRInt32 mWidth; PRInt32 mHeight; diff --git a/mozilla/layout/html/forms/src/nsInputButton.cpp b/mozilla/layout/html/forms/src/nsInputButton.cpp index 43ec815eec2..fe659391b9c 100644 --- a/mozilla/layout/html/forms/src/nsInputButton.cpp +++ b/mozilla/layout/html/forms/src/nsInputButton.cpp @@ -424,7 +424,7 @@ nsInputButtonFrame::GetDesiredSize(nsIPresContext* aPresContext, } else { nsSize styleSize; - GetStyleSize(*aPresContext, aMaxSize, styleSize); + GetStyleSize(*aPresContext, styleSize); if (kButton_Image == GetButtonType()) { // there is an image float p2t = aPresContext->GetPixelsToTwips(); @@ -432,8 +432,8 @@ nsInputButtonFrame::GetDesiredSize(nsIPresContext* aPresContext, GetImage(*aPresContext, PR_FALSE); // Use dimensions from style attributes - aDesiredLayoutSize.width = nscoord(styleSize.width * p2t); - aDesiredLayoutSize.height = nscoord(styleSize.height * p2t); + aDesiredLayoutSize.width = nscoord(styleSize.width); + aDesiredLayoutSize.height = nscoord(styleSize.height); } else { nsIImage* image = GetImage(*aPresContext, PR_TRUE); if (nsnull == image) { diff --git a/mozilla/layout/html/forms/src/nsInputFrame.cpp b/mozilla/layout/html/forms/src/nsInputFrame.cpp index b066bea8b4d..091b7f60a1e 100644 --- a/mozilla/layout/html/forms/src/nsInputFrame.cpp +++ b/mozilla/layout/html/forms/src/nsInputFrame.cpp @@ -46,7 +46,7 @@ #include "nsHTMLForms.h" #include "nsStyleConsts.h" #include "nsUnitConversion.h" - +#include "nsCSSLayout.h" static NS_DEFINE_IID(kStyleFontSID, NS_STYLEFONT_SID); static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID); static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID); @@ -71,6 +71,8 @@ nsInputFrame::~nsInputFrame() { } +PRInt32 nsInputFrame::gScrollBarWidth = 360; + NS_METHOD nsInputFrame::SetRect(const nsRect& aRect) { return nsInputFrameSuper::SetRect(aRect); @@ -188,7 +190,7 @@ nsInputFrame::GetDesiredSize(nsIPresContext* aPresContext, { // get the css size and let the frame use or override it nsSize styleSize; - GetStyleSize(*aPresContext, aMaxSize, styleSize); + GetStyleSize(*aPresContext, styleSize); // subclasses should always override this method, but if not and no css, make it small aDesiredLayoutSize.width = (styleSize.width > CSS_NOTSET) ? styleSize.width : 144; @@ -236,10 +238,9 @@ nsInputFrame::ResizeReflow(nsIPresContext* aPresContext, nsIPresShell *presShell = aPresContext->GetShell(); // need to release nsIViewManager *viewMan = presShell->GetViewManager(); // need to release - nsSize widgetSize; - GetDesiredSize(aPresContext, aMaxSize, aDesiredSize, widgetSize); + GetDesiredSize(aPresContext, aMaxSize, aDesiredSize, mWidgetSize); - nsRect boundBox(0, 0, widgetSize.width, widgetSize.height); + nsRect boundBox(0, 0, mWidgetSize.width, mWidgetSize.height); nsIFrame* parWithView; nsIView *parView; @@ -283,8 +284,7 @@ nsInputFrame::ResizeReflow(nsIPresContext* aPresContext, NS_IF_RELEASE(presShell); } else { - nsSize widgetSize; - GetDesiredSize(aPresContext, aMaxSize, aDesiredSize, widgetSize); + GetDesiredSize(aPresContext, aMaxSize, aDesiredSize, mWidgetSize); // If we are being reflowed and have a view, hide the view until // we are told to paint (which is when our location will have @@ -414,6 +414,19 @@ NS_METHOD nsInputFrame::HandleEvent(nsIPresContext& aPresContext, return nsEventStatus_eConsumeDoDefault; } +void nsInputFrame::GetStyleSize(nsIPresContext& aPresContext, + nsSize& aSize) +{ + PRIntn ss = nsCSSLayout::GetStyleSize(&aPresContext, this, aSize); + if (0 == (ss & NS_SIZE_HAS_WIDTH)) { + aSize.width = CSS_NOTSET; + } + if (0 == (ss & NS_SIZE_HAS_HEIGHT)) { + aSize.height = CSS_NOTSET; + } +} + +#if 0 void nsInputFrame::GetStyleSize(nsIPresContext& aPresContext, const nsSize& aMaxSize, nsSize& aSize) { @@ -455,6 +468,7 @@ nsInputFrame::GetStyleDim(nsIPresContext& aPresContext, nscoord aMaxDim, return result; } +#endif nscoord nsInputFrame::GetTextSize(nsIPresContext& aPresContext, nsIFrame* aFrame, diff --git a/mozilla/layout/html/forms/src/nsInputFrame.h b/mozilla/layout/html/forms/src/nsInputFrame.h index ec6620b56e7..63d61a48d68 100644 --- a/mozilla/layout/html/forms/src/nsInputFrame.h +++ b/mozilla/layout/html/forms/src/nsInputFrame.h @@ -91,7 +91,7 @@ public: // nsLeafFrame overrides NS_IMETHOD MoveTo(nscoord aX, nscoord aY); - NS_METHOD SizeTo(nscoord aWidth, nscoord aHeight); + NS_IMETHOD SizeTo(nscoord aWidth, nscoord aHeight); /** * Respond to a gui event @@ -172,6 +172,8 @@ public: static nscoord GetTextSize(nsIPresContext& aContext, nsIFrame* aFrame, PRInt32 aNumChars, nsSize& aSize); + static PRInt32 gScrollBarWidth; + protected: virtual ~nsInputFrame(); @@ -203,16 +205,16 @@ protected: /** * Get the width and height of this control based on CSS * @param aPresContext the presentation context - * @param aMaxSize the maximum size that this frame can have * @param aSize the size that this frame wants, set by this method. values of -1 * for aSize.width or aSize.height indicate unset values. */ - void GetStyleSize(nsIPresContext& aContext, const nsSize& aMaxSize, nsSize& aSize); + void GetStyleSize(nsIPresContext& aContext, nsSize& aSize); nscoord GetStyleDim(nsIPresContext& aPresContext, nscoord aMaxDim, nscoord aMaxWidth, const nsStyleCoord& aCoord); nsMouseState mLastMouseState; + nsSize mWidgetSize; }; #endif diff --git a/mozilla/layout/html/forms/src/nsInputText.cpp b/mozilla/layout/html/forms/src/nsInputText.cpp index c221c2a0487..8f2f4a0a90c 100644 --- a/mozilla/layout/html/forms/src/nsInputText.cpp +++ b/mozilla/layout/html/forms/src/nsInputText.cpp @@ -113,15 +113,16 @@ nsInputTextFrame::GetDesiredSize(nsIPresContext* aPresContext, nsReflowMetrics& aDesiredLayoutSize, nsSize& aDesiredWidgetSize) { + nsInputTextType textType = GetTextType(); // get the css size and let the frame use or override it nsSize styleSize; - GetStyleSize(*aPresContext, aMaxSize, styleSize); + GetStyleSize(*aPresContext, styleSize); nsSize size; PRBool widthExplicit, heightExplicit; PRInt32 ignore; - if ((kInputTextText == GetTextType()) || (kInputTextPassword == GetTextType())) { + if ((kInputTextText == textType) || (kInputTextPassword == textType)) { nsInputDimensionSpec textSpec(nsHTMLAtoms::size, PR_FALSE, nsHTMLAtoms::value, 20, PR_FALSE, nsnull, 1); CalculateSize(aPresContext, this, styleSize, textSpec, size, @@ -133,8 +134,17 @@ nsInputTextFrame::GetDesiredSize(nsIPresContext* aPresContext, CalculateSize(aPresContext, this, styleSize, areaSpec, size, widthExplicit, heightExplicit, ignore); } - if (!heightExplicit && (kInputTextArea != GetTextType())) { - size.height += 100; + if (!heightExplicit) { + if (kInputTextArea == textType) { + size.height += gScrollBarWidth; + } + else { + size.height += 100; + } + } + + if (!widthExplicit && (kInputTextArea == textType)) { + size.width += gScrollBarWidth; } aDesiredLayoutSize.width = size.width; diff --git a/mozilla/layout/html/forms/src/nsSelect.cpp b/mozilla/layout/html/forms/src/nsSelect.cpp index b21338d5d39..74e76f02a46 100644 --- a/mozilla/layout/html/forms/src/nsSelect.cpp +++ b/mozilla/layout/html/forms/src/nsSelect.cpp @@ -56,6 +56,7 @@ public: virtual const nsIID& GetIID(); + NS_IMETHOD SizeTo(nscoord aWidth, nscoord aHeight); PRBool IsComboBox(); protected: @@ -192,7 +193,7 @@ nsSelectFrame::GetDesiredSize(nsIPresContext* aPresContext, // get the css size nsSize styleSize; - GetStyleSize(*aPresContext, aMaxSize, styleSize); + GetStyleSize(*aPresContext, styleSize); // get the size of the longest child PRInt32 maxWidth = 1; @@ -253,6 +254,13 @@ nsSelectFrame::GetWidgetInitData() return data; } +NS_METHOD +nsSelectFrame::SizeTo(nscoord aWidth, nscoord aHeight) +{ + nscoord height = (IsComboBox()) ? mWidgetSize.height : aHeight; + return nsInputFrame::SizeTo(aWidth, height); +} + void nsSelectFrame::PostCreateWidget(nsIPresContext* aPresContext, nsIView *aView) { diff --git a/mozilla/webshell/tests/viewer/samples/test8-1.html b/mozilla/webshell/tests/viewer/samples/test8-1.html new file mode 100644 index 00000000000..1709d7d0b36 --- /dev/null +++ b/mozilla/webshell/tests/viewer/samples/test8-1.html @@ -0,0 +1,36 @@ + +
+