diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index 18fb99682071..dd5cfc470acc 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -1125,6 +1125,9 @@ nsresult HTMLContentSink::ProcessINPUTTag(nsIHTMLContent** aInstancePtrResult, else if (val.EqualsIgnoreCase("select2")) { // TEMP hack rv = NS_NewHTMLSelect(aInstancePtrResult, atom, mCurrentForm, 2); } + else if (val.EqualsIgnoreCase("select3")) { // TEMP hack + rv = NS_NewHTMLSelect(aInstancePtrResult, atom, mCurrentForm, 3); + } else { rv = NS_NewHTMLInputSubmit(aInstancePtrResult, atom, mCurrentForm); } diff --git a/layout/html/document/src/nsHTMLContentSink.cpp b/layout/html/document/src/nsHTMLContentSink.cpp index 18fb99682071..dd5cfc470acc 100644 --- a/layout/html/document/src/nsHTMLContentSink.cpp +++ b/layout/html/document/src/nsHTMLContentSink.cpp @@ -1125,6 +1125,9 @@ nsresult HTMLContentSink::ProcessINPUTTag(nsIHTMLContent** aInstancePtrResult, else if (val.EqualsIgnoreCase("select2")) { // TEMP hack rv = NS_NewHTMLSelect(aInstancePtrResult, atom, mCurrentForm, 2); } + else if (val.EqualsIgnoreCase("select3")) { // TEMP hack + rv = NS_NewHTMLSelect(aInstancePtrResult, atom, mCurrentForm, 3); + } else { rv = NS_NewHTMLInputSubmit(aInstancePtrResult, atom, mCurrentForm); } diff --git a/layout/html/forms/src/nsForm.cpp b/layout/html/forms/src/nsForm.cpp index d894c5980a83..3f186f5ae6dc 100644 --- a/layout/html/forms/src/nsForm.cpp +++ b/layout/html/forms/src/nsForm.cpp @@ -267,7 +267,7 @@ nsForm::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame) GetAttribute("action", href); nsString data(href); // this could be more efficient, by allocating a larger buffer - data += '$'; + data += '?'; PRBool firstTime = PR_TRUE; PRInt32 numChildren = mChildren.Count(); @@ -302,12 +302,7 @@ nsForm::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame) } } - char* out = data.ToNewCString(); - printf("\nsubmit data =\n%s\n", out); - delete [] out; - -#ifdef FIX_THIS - // cause the url + // make the url string nsILinkHandler* handler; if (NS_OK == aPresContext->GetLinkHandler(&handler)) { // Resolve url to an absolute url @@ -326,14 +321,13 @@ nsForm::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame) nsAutoString absURLSpec; nsAutoString base; - nsresult rv = NS_MakeAbsoluteURL(docURL, base, href, absURLSpec); + nsresult rv = NS_MakeAbsoluteURL(docURL, base, data, absURLSpec); NS_IF_RELEASE(docURL); // Now pass on absolute url to the click handler handler->OnLinkClick(aFrame, absURLSpec, target); +printf("\nurl=%s\n", absURLSpec.ToNewCString()); } -#endif - } void diff --git a/layout/html/forms/src/nsHTMLForms.h b/layout/html/forms/src/nsHTMLForms.h index 10ae6cac51d8..f094b081df1e 100644 --- a/layout/html/forms/src/nsHTMLForms.h +++ b/layout/html/forms/src/nsHTMLForms.h @@ -22,9 +22,9 @@ class nsIAtom; class nsIFormManager; -// fix these -#define CSS_NOTSET 0 -#define ATTR_NOTSET 0 +// fix this +#define CSS_NOTSET -1 +#define ATTR_NOTSET -1 // Form and Form Controls diff --git a/layout/html/forms/src/nsInputCheckbox.cpp b/layout/html/forms/src/nsInputCheckbox.cpp index 1f5e482f0217..61fc29be1a41 100644 --- a/layout/html/forms/src/nsInputCheckbox.cpp +++ b/layout/html/forms/src/nsInputCheckbox.cpp @@ -44,6 +44,8 @@ public: virtual const nsIID& GetIID(); virtual void MouseClicked(nsIPresContext* aPresContext); + virtual PRInt32 GetPadding() const; + NS_IMETHOD SetRect(const nsRect& aRect); protected: virtual ~nsInputCheckboxFrame(); @@ -66,6 +68,13 @@ nsInputCheckboxFrame::~nsInputCheckboxFrame() mCacheState = PR_FALSE; } +NS_METHOD nsInputCheckboxFrame::SetRect(const nsRect& aRect) +{ + PRInt32 padding = GetPadding(); + MoveTo(aRect.x + padding, aRect.y); + SizeTo(aRect.width - (2 * padding), aRect.height); + return NS_OK; +} const nsIID& nsInputCheckboxFrame::GetIID() @@ -81,6 +90,11 @@ nsInputCheckboxFrame::GetCID() return kCheckboxCID; } +PRInt32 nsInputCheckboxFrame::GetPadding() const +{ + return GetDefaultPadding(); +} + void nsInputCheckboxFrame::GetDesiredSize(nsIPresContext* aPresContext, const nsSize& aMaxSize, @@ -97,10 +111,11 @@ nsInputCheckboxFrame::GetDesiredSize(nsIPresContext* aPresContext, } float p2t = aPresContext->GetPixelsToTwips(); - aDesiredLayoutSize.width = (int)(13 * p2t); - aDesiredLayoutSize.height = (int)(13 * p2t); - aDesiredWidgetSize.width = aDesiredLayoutSize.width; - aDesiredWidgetSize.height = aDesiredLayoutSize.height; + aDesiredWidgetSize.width = (int)(12 * p2t); + aDesiredWidgetSize.height = (int)(12 * p2t); + PRInt32 padding = GetPadding(); + aDesiredLayoutSize.width = aDesiredWidgetSize.width + (2 * padding); + aDesiredLayoutSize.height = aDesiredWidgetSize.height; } void diff --git a/layout/html/forms/src/nsInputFrame.cpp b/layout/html/forms/src/nsInputFrame.cpp index 0147b5bd6d5c..a9538415f7d1 100644 --- a/layout/html/forms/src/nsInputFrame.cpp +++ b/layout/html/forms/src/nsInputFrame.cpp @@ -72,6 +72,12 @@ nsInputFrame::~nsInputFrame() { } +NS_METHOD nsInputFrame::SetRect(const nsRect& aRect) +{ + return super::SetRect(aRect); +} + + // XXX it would be cool if form element used our rendering sw, then // they could be blended, and bordered, and so on... NS_METHOD @@ -84,6 +90,9 @@ nsInputFrame::Paint(nsIPresContext& aPresContext, nsPoint offset; nsIView *parent; GetOffsetFromView(offset, parent); + + //offset.x += padding + GetPadding(); // add back the padding if present + if (nsnull == parent) { // a problem NS_ASSERTION(0, "parent view was null\n"); } else { @@ -195,8 +204,8 @@ nsInputFrame::ResizeReflow(nsIPresContext* aPresContext, nsReflowMetrics layoutSize; nsSize widgetSize; GetDesiredSize(aPresContext, aMaxSize, layoutSize, widgetSize); - mCacheBounds.width = widgetSize.width; // YYY what about caching widget size? - mCacheBounds.height = widgetSize.height; + mCacheBounds.width = layoutSize.width; // YYY what about caching widget size? + mCacheBounds.height = layoutSize.height; nsRect boundBox(0, 0, widgetSize.width, widgetSize.height); @@ -260,6 +269,11 @@ nsInputFrame::GetWidgetInitData() return nsnull; } +PRInt32 nsInputFrame::GetPadding() const +{ + return 0; +} + void nsInputFrame::PostCreateWidget(nsIPresContext* aPresContext, nsIView *aView) { @@ -423,6 +437,7 @@ nsInputFrame::CalculateSize (nsIPresContext* aPresContext, nsInputFrame* aFrame, PRBool& aHeightExplicit, PRInt32& aRowHeight) { PRInt32 charWidth = 0; + PRInt32 numRows = 1; aWidthExplicit = PR_FALSE; aHeightExplicit = PR_FALSE; @@ -487,6 +502,7 @@ nsInputFrame::CalculateSize (nsIPresContext* aPresContext, nsInputFrame* aFrame, charWidth = GetTextSize(*aPresContext, aFrame, 1, textSize); aBounds.height = textSize.height * rowAttr; aRowHeight = textSize.height; + numRows = rowAttr; } else { aBounds.height = aBounds.height * rowAttr; @@ -519,8 +535,7 @@ nsInputFrame::CalculateSize (nsIPresContext* aPresContext, nsInputFrame* aFrame, NS_RELEASE(content); - // return number of rows that the calcuated size can support - return (int)(((float)aBounds.height) / ((float)aRowHeight)); + return numRows; } diff --git a/layout/html/forms/src/nsInputFrame.h b/layout/html/forms/src/nsInputFrame.h index 3d4125ed6ead..3d5363637695 100644 --- a/layout/html/forms/src/nsInputFrame.h +++ b/layout/html/forms/src/nsInputFrame.h @@ -73,6 +73,7 @@ struct nsInputDimensionSpec * @see nsLeafFrame and its base classes for more info */ class nsInputFrame : public nsLeafFrame { + typedef nsLeafFrame super; public: /** * Main constructor @@ -98,6 +99,8 @@ public: nsGUIEvent* aEvent, nsEventStatus& aEventStatus); + NS_IMETHOD SetRect(const nsRect& aRect); + virtual PRBool IsHidden(); /** @@ -132,6 +135,8 @@ public: */ virtual const nsIID& GetIID(); + PRInt32 GetDefaultPadding() const { return 40; } + virtual PRInt32 GetPadding() const; /** * Get the widget associated with this frame * @param aView the view associated with the frame. It is a convience parm. diff --git a/layout/html/forms/src/nsInputRadio.cpp b/layout/html/forms/src/nsInputRadio.cpp index 79ff71b50dc7..7a892326cd6c 100644 --- a/layout/html/forms/src/nsInputRadio.cpp +++ b/layout/html/forms/src/nsInputRadio.cpp @@ -46,6 +46,8 @@ public: virtual const nsIID& GetIID(); virtual void MouseClicked(nsIPresContext* aPresContext); + virtual PRInt32 GetPadding() const; + NS_IMETHOD SetRect(const nsRect& aRect); protected: @@ -69,6 +71,19 @@ nsInputRadioFrame::~nsInputRadioFrame() } +PRInt32 nsInputRadioFrame::GetPadding() const +{ + return GetDefaultPadding(); +} + +NS_METHOD nsInputRadioFrame::SetRect(const nsRect& aRect) +{ + PRInt32 padding = GetPadding(); + MoveTo(aRect.x + padding, aRect.y); + SizeTo(aRect.width - (2 * padding), aRect.height); + return NS_OK; +} + const nsIID& nsInputRadioFrame::GetIID() { @@ -90,10 +105,11 @@ nsInputRadioFrame::GetDesiredSize(nsIPresContext* aPresContext, nsSize& aDesiredWidgetSize) { float p2t = aPresContext->GetPixelsToTwips(); - aDesiredLayoutSize.width = (int)(12 * p2t); - aDesiredLayoutSize.height = (int)(12 * p2t); - aDesiredWidgetSize.width = aDesiredLayoutSize.width; - aDesiredWidgetSize.height = aDesiredLayoutSize.height; + aDesiredWidgetSize.width = (int)(12 * p2t); + aDesiredWidgetSize.height = (int)(12 * p2t); + PRInt32 padding = GetPadding(); + aDesiredLayoutSize.width = aDesiredWidgetSize.width + (2 * padding); + aDesiredLayoutSize.height = aDesiredWidgetSize.height; } void diff --git a/layout/html/forms/src/nsSelect.cpp b/layout/html/forms/src/nsSelect.cpp index 8f7b2a063d6e..6eebdacd7458 100644 --- a/layout/html/forms/src/nsSelect.cpp +++ b/layout/html/forms/src/nsSelect.cpp @@ -227,7 +227,8 @@ nsSelectFrame::GetDesiredSize(nsIPresContext* aPresContext, aDesiredWidgetSize.width = aDesiredLayoutSize.width; aDesiredWidgetSize.height = - (isCombo && !heightExplicit) ? rowHeight + 100 : aDesiredLayoutSize.height; + (isCombo && !heightExplicit) ? aDesiredLayoutSize.height + (rowHeight * numChildren) + 100 + : aDesiredLayoutSize.height; NS_RELEASE(select); @@ -269,13 +270,12 @@ nsSelectFrame::PostCreateWidget(nsIPresContext* aPresContext, nsIView *aView) if (PR_TRUE != option->GetText(text)) { text = " "; } - if (isCombo) { - printf("\n ** text = %s", text.ToNewCString()); - list->AddItemAt(text, 1); - } - else { - list->AddItemAt(text, i); - } +// if (isCombo) { +// printf("\n ** text = %s", text.ToNewCString()); +// list->AddItemAt(text, 1); +// } + printf("\n item=%s\n", text.ToNewCString()); + list->AddItemAt(text, i); } NS_RELEASE(view); @@ -598,13 +598,16 @@ void HACK(nsSelect* aSel, PRInt32 aIndex) if (aIndex == 1) { nsString size("2"); aSel->SetAttribute(sizeAttr, size); - } else { + } else if (aIndex == 2) { nsString size("4"); aSel->SetAttribute(sizeAttr, size); nsIAtom* multAttr = NS_NewAtom("MULTIPLE"); nsString mult("1"); aSel->SetAttribute(multAttr, mult); numOpt = 8; + } else { + nsString size("1"); + aSel->SetAttribute(sizeAttr, size); } for (int i = 0; i < numOpt; i++) { diff --git a/webshell/tests/viewer/samples/test8.html b/webshell/tests/viewer/samples/test8.html index 104ceae74c66..425810a60b7f 100644 --- a/webshell/tests/viewer/samples/test8.html +++ b/webshell/tests/viewer/samples/test8.html @@ -2,36 +2,33 @@ Example 8 -

Example 8: Form Controls

- -
+

Example 8: Forms


-a text field -
- -
-a text area -
- -
-a checkbox:
-
-

radio buttons

+ +

hey yahoo

+ + + +   password:   +
+
+
+ +   a checkbox: +   radio buttons: radio1 radio2
-select/option hack1 - +

select/option hacks; why don't these line up

+   +   +
-select/option hack2 - -

- diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 0dfa2d43d806..f6323e84b8de 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -169,6 +169,7 @@ nsWindow::nsWindow(nsISupports *aOuter) : nsObject(aOuter) mIsShiftDown = PR_FALSE; mIsControlDown = PR_FALSE; mIsAltDown = PR_FALSE; + mIsDestroying = PR_FALSE; } @@ -179,6 +180,7 @@ nsWindow::nsWindow(nsISupports *aOuter) : nsObject(aOuter) //------------------------------------------------------------------------- nsWindow::~nsWindow() { + mIsDestroying = PR_TRUE; Destroy(); } @@ -1437,7 +1439,7 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType) if (rect.Contains(event.point.x, event.point.y)) { if (mCurrentWindow == NULL || mCurrentWindow != this) { - if (nsnull != mCurrentWindow) { + if ((nsnull != mCurrentWindow) && (!mCurrentWindow->mIsDestroying)) { mCurrentWindow->DispatchMouseEvent(NS_MOUSE_EXIT); } mCurrentWindow = this; diff --git a/widget/src/windows/nsWindow.h b/widget/src/windows/nsWindow.h index 99911ed099f8..a3641e5d2691 100644 --- a/widget/src/windows/nsWindow.h +++ b/widget/src/windows/nsWindow.h @@ -171,6 +171,7 @@ protected: PRBool mIsShiftDown; PRBool mIsControlDown; PRBool mIsAltDown; + PRBool mIsDestroying; // keep the list of children class Enumerator : public nsIEnumerator {