All pastes #97938 Raw Edit

non-compiling diff

public text v1 · immutable
#97938 ·published 2006-07-24 05:50 UTC
rendered paste body
? dom/public/idl/web-forms-full
? dom/public/idl/web-forms/nsIDOMWF2InputElement.idl
Index: dom/public/idl/Makefile.in
===================================================================
RCS file: /cvsroot/mozilla/dom/public/idl/Makefile.in,v
retrieving revision 1.15
diff -p -u -8 -r1.15 Makefile.in
--- dom/public/idl/Makefile.in	19 May 2006 05:57:35 -0000	1.15
+++ dom/public/idl/Makefile.in	24 Jul 2006 05:49:43 -0000
@@ -41,16 +41,17 @@ VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 DIRS =						\
 	base					\
 	canvas					\
 	core					\
 	html					\
+	web-forms				\
 	events					\
 	stylesheets				\
 	views					\
 	sidebar                                 \
 	css					\
 	traversal				\
 	range					\
 	xbl					\
Index: dom/public/idl/web-forms/Makefile.in
===================================================================
RCS file: dom/public/idl/web-forms/Makefile.in
diff -N dom/public/idl/web-forms/Makefile.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ dom/public/idl/web-forms/Makefile.in	24 Jul 2006 05:49:44 -0000
@@ -0,0 +1,54 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Web Forms 2.0.
+#
+# The Initial Developer of the Original Code is
+# Alexander J. Vincent <ajvincent@gmail.com>.
+# Portions created by the Initial Developer are Copyright (C) 2006
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either of the GNU General Public License Version 2 or later (the "GPL"),
+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH		= ../../../..
+topsrcdir	= @top_srcdir@
+srcdir		= @srcdir@
+VPATH		= @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE		= dom
+XPIDL_MODULE	= dom_web_forms
+GRE_MODULE	= 1
+
+SDK_XPIDLSRCS =				\
+	nsIDOMWF2ValidityState.idl	\
+	nsIDOMWF2FormControl.idl	\
+	nsIDOMWF2FormElement.idl	\
+	$(NULL)
+
+include $(topsrcdir)/config/rules.mk
Index: dom/public/idl/web-forms/nsIDOMWF2FormControl.idl
===================================================================
RCS file: dom/public/idl/web-forms/nsIDOMWF2FormControl.idl
diff -N dom/public/idl/web-forms/nsIDOMWF2FormControl.idl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ dom/public/idl/web-forms/nsIDOMWF2FormControl.idl	24 Jul 2006 05:49:44 -0000
@@ -0,0 +1,61 @@
+/* ***** BEGIN LICENSE BLOCK *****

+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1

+ *

+ * The contents of this file are subject to the Mozilla Public License Version

+ * 1.1 (the "License"); you may not use this file except in compliance with

+ * the License. You may obtain a copy of the License at

+ * http://www.mozilla.org/MPL/

+ *

+ * Software distributed under the License is distributed on an "AS IS" basis,

+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License

+ * for the specific language governing rights and limitations under the

+ * License.

+ *

+ * The Original Code is Web Forms 2.0.

+ *

+ * The Initial Developer of the Original Code is

+ * Alexander J. Vincent <ajvincent@gmail.com>

+ * Portions created by the Initial Developer are Copyright (C) 2006

+ * the Initial Developer. All Rights Reserved.

+ *

+ * Contributor(s):

+ *

+ * Alternatively, the contents of this file may be used under the terms of

+ * either of the GNU General Public License Version 2 or later (the "GPL"),

+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),

+ * in which case the provisions of the GPL or the LGPL are applicable instead

+ * of those above. If you wish to allow use of your version of this file only

+ * under the terms of either the GPL or the LGPL, and not to allow others to

+ * use your version of this file under the terms of the MPL, indicate your

+ * decision by deleting the provisions above and replace them with the notice

+ * and other provisions required by the GPL or the LGPL. If you do not delete

+ * the provisions above, a recipient may use your version of this file under

+ * the terms of any one of the MPL, the GPL or the LGPL.

+ *

+ * ***** END LICENSE BLOCK ***** */

+

+#include "nsISupports.idl"

+#include "nsIDOMWF2ValidityState.idl"

+

+/* Because these properties and method are reused very frequently, they have

+ * been extracted into these common interfaces.

+ */

+

+[scriptable, uuid(29360af0-f012-45d3-a339-d7fce8a2634c)]

+interface nsIDOMWF2FormControl : nsISupports

+{

+  /**

+   * Indicates if this control will be validated.

+   */

+  readonly attribute boolean willValidate;

+

+  /**

+   * The validity state of this control.

+   */

+  readonly attribute nsIDOMWF2ValidityState validity;

+

+  /**

+   * Check the validity of this control.

+   */

+  boolean checkValidity();

+};

Index: dom/public/idl/web-forms/nsIDOMWF2FormElement.idl
===================================================================
RCS file: dom/public/idl/web-forms/nsIDOMWF2FormElement.idl
diff -N dom/public/idl/web-forms/nsIDOMWF2FormElement.idl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ dom/public/idl/web-forms/nsIDOMWF2FormElement.idl	24 Jul 2006 05:49:44 -0000
@@ -0,0 +1,51 @@
+/* ***** BEGIN LICENSE BLOCK *****

+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1

+ *

+ * The contents of this file are subject to the Mozilla Public License Version

+ * 1.1 (the "License"); you may not use this file except in compliance with

+ * the License. You may obtain a copy of the License at

+ * http://www.mozilla.org/MPL/

+ *

+ * Software distributed under the License is distributed on an "AS IS" basis,

+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License

+ * for the specific language governing rights and limitations under the

+ * License.

+ *

+ * The Original Code is Web Forms 2.0.

+ *

+ * The Initial Developer of the Original Code is

+ * Alexander J. Vincent <ajvincent@gmail.com>

+ * Portions created by the Initial Developer are Copyright (C) 2006

+ * the Initial Developer. All Rights Reserved.

+ *

+ * Contributor(s):

+ *

+ * Alternatively, the contents of this file may be used under the terms of

+ * either of the GNU General Public License Version 2 or later (the "GPL"),

+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),

+ * in which case the provisions of the GPL or the LGPL are applicable instead

+ * of those above. If you wish to allow use of your version of this file only

+ * under the terms of either the GPL or the LGPL, and not to allow others to

+ * use your version of this file under the terms of the MPL, indicate your

+ * decision by deleting the provisions above and replace them with the notice

+ * and other provisions required by the GPL or the LGPL. If you do not delete

+ * the provisions above, a recipient may use your version of this file under

+ * the terms of any one of the MPL, the GPL or the LGPL.

+ *

+ * ***** END LICENSE BLOCK ***** */

+

+#include "nsISupports.idl"

+#include "nsIDOMHTMLFormElement.idl"

+

+/* Because these properties and method are reused very frequently, they have

+ * been extracted into these common interfaces.

+ */

+

+[scriptable, uuid(c6fa8507-6f41-4ce0-9350-2b1c3431f828)]

+interface nsIDOMWF2FormElement : nsISupports

+{

+  /**

+   * Check the validity of all active elements in this form.

+   */

+  PRBool               checkValidity();

+};

Index: dom/public/idl/web-forms/nsIDOMWF2ValidityState.idl
===================================================================
RCS file: dom/public/idl/web-forms/nsIDOMWF2ValidityState.idl
diff -N dom/public/idl/web-forms/nsIDOMWF2ValidityState.idl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ dom/public/idl/web-forms/nsIDOMWF2ValidityState.idl	24 Jul 2006 05:49:44 -0000
@@ -0,0 +1,45 @@
+/* ***** BEGIN LICENSE BLOCK *****

+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1

+ *

+ * The contents of this file are subject to the Mozilla Public License Version

+ * 1.1 (the "License"); you may not use this file except in compliance with

+ * the License. You may obtain a copy of the License at

+ * http://www.mozilla.org/MPL/

+ *

+ * Software distributed under the License is distributed on an "AS IS" basis,

+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License

+ * for the specific language governing rights and limitations under the

+ * License.

+ *

+ * The Original Code is Web Forms 2.0.

+ *

+ * The Initial Developer of the Original Code is

+ * Alexander J. Vincent <ajvincent@gmail.com>

+ * Portions created by the Initial Developer are Copyright (C) 2006

+ * the Initial Developer. All Rights Reserved.

+ *

+ * Contributor(s):

+ *

+ * Alternatively, the contents of this file may be used under the terms of

+ * either of the GNU General Public License Version 2 or later (the "GPL"),

+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),

+ * in which case the provisions of the GPL or the LGPL are applicable instead

+ * of those above. If you wish to allow use of your version of this file only

+ * under the terms of either the GPL or the LGPL, and not to allow others to

+ * use your version of this file under the terms of the MPL, indicate your

+ * decision by deleting the provisions above and replace them with the notice

+ * and other provisions required by the GPL or the LGPL. If you do not delete

+ * the provisions above, a recipient may use your version of this file under

+ * the terms of any one of the MPL, the GPL or the LGPL.

+ *

+ * ***** END LICENSE BLOCK ***** */

+

+#include "nsISupports.idl"

+

+[scriptable, uuid(5a2e9790-3b72-4512-b3bf-203cec7b3379)]

+interface nsIDOMWF2ValidityState : nsISupports {

+  /**

+   * True if this control meets all constraints on it.

+   */

+  readonly attribute boolean         valid; 

+};

Index: dom/src/base/nsDOMClassInfo.cpp
===================================================================
RCS file: /cvsroot/mozilla/dom/src/base/nsDOMClassInfo.cpp,v
retrieving revision 1.400
diff -p -u -8 -r1.400 nsDOMClassInfo.cpp
--- dom/src/base/nsDOMClassInfo.cpp	13 Jul 2006 18:27:35 -0000	1.400
+++ dom/src/base/nsDOMClassInfo.cpp	24 Jul 2006 05:49:52 -0000
@@ -293,16 +293,17 @@
 #include "nsIDOMHTMLTableColElement.h"
 #include "nsIDOMHTMLTableElement.h"
 #include "nsIDOMHTMLTableRowElement.h"
 #include "nsIDOMHTMLTableSectionElem.h"
 #include "nsIDOMHTMLTextAreaElement.h"
 #include "nsIDOMNSHTMLTextAreaElement.h"
 #include "nsIDOMHTMLTitleElement.h"
 #include "nsIDOMHTMLUListElement.h"
+#include "nsIDOMWF2FormControl.h"
 #include "nsIDOMNSUIEvent.h"
 #include "nsIDOMCSS2Properties.h"
 #include "nsIDOMCSSCharsetRule.h"
 #include "nsIDOMCSSImportRule.h"
 #include "nsIDOMCSSMediaRule.h"
 #include "nsIDOMCSSMozDocumentRule.h"
 #include "nsIDOMCSSPrimitiveValue.h"
 #include "nsIDOMCSSStyleRule.h"
@@ -753,16 +754,20 @@ static nsDOMClassInfoData sClassInfoData
                            ELEMENT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(HTMLUListElement, nsHTMLElementSH,
                            ELEMENT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(HTMLUnknownElement, nsHTMLElementSH,
                            ELEMENT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(HTMLWBRElement, nsHTMLElementSH,
                            ELEMENT_SCRIPTABLE_FLAGS)
 
+  // Web Forms 2.0
+  NS_DEFINE_CLASSINFO_DATA(DOMWF2ValidityState, nsDOMGenericSH,
+                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
+
   // CSS classes
   NS_DEFINE_CLASSINFO_DATA(CSSStyleRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(CSSCharsetRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(CSSImportRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(CSSMediaRule, nsDOMGenericSH,
@@ -1931,16 +1936,17 @@ nsDOMClassInfo::Init()
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSmartCardEvent)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(PageTransitionEvent, nsIDOMPageTransitionEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPageTransitionEvent)
     DOM_CLASSINFO_EVENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
+
   DOM_CLASSINFO_MAP_BEGIN(MutationEvent, nsIDOMMutationEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMutationEvent)
     DOM_CLASSINFO_EVENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(UIEvent, nsIDOMUIEvent)
     DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
@@ -5207,16 +5213,17 @@ nsDOMClassInfo::PreserveNodeWrapper(nsIX
   info->GetHelperForLanguage(nsIProgrammingLanguage::JAVASCRIPT,
                              getter_AddRefs(sup));
 
   nsCOMPtr<nsIXPCScriptable> scriptable = do_QueryInterface(sup);
   NS_ASSERTION(scriptable, "Must have scriptable");
 
   PRUint32 flags;
   scriptable->GetScriptableFlags(&flags);
+
   NS_ASSERTION(flags & nsIXPCScriptable::WANT_FINALIZE,
                "We'll never get cleaned up!");
 #endif
 
   return nsDOMClassInfo::PreserveWrapper(aWrapper, IdentityKeyToWrapperFunc,
                                          participant,
                                          aRootWhenExternallyReferenced);
 }
@@ -8999,16 +9006,17 @@ nsHTMLSelectElementSH::GetProperty(nsIXP
 
   return rv;
 }
 
 // static
 nsresult
 nsHTMLSelectElementSH::SetOption(JSContext *cx, jsval *vp, PRUint32 aIndex,
                                  nsIDOMNSHTMLOptionCollection *aOptCollection)
+
 {
   JSAutoRequest ar(cx);
 
   // vp must refer to an object
   if (!JSVAL_IS_OBJECT(*vp) && !::JS_ConvertValue(cx, *vp, JSTYPE_OBJECT, vp)) {
     return NS_ERROR_UNEXPECTED;
   }
 
Index: content/html/content/public/Makefile.in
===================================================================
RCS file: /cvsroot/mozilla/content/html/content/public/Makefile.in,v
retrieving revision 1.36
diff -p -u -8 -r1.36 Makefile.in
--- content/html/content/public/Makefile.in	25 Apr 2006 09:18:29 -0000	1.36
+++ content/html/content/public/Makefile.in	24 Jul 2006 05:49:52 -0000
@@ -59,12 +59,13 @@ EXPORTS		= \
 		nsIOptionElement.h \
 		nsIRadioControlElement.h \
 		nsIRadioVisitor.h \
 		nsIRadioGroupContainer.h \
 		nsITextControlElement.h \
 		nsIFileControlElement.h \
 		nsIFormSubmission.h \
 		nsIFrameSetElement.h \
+		nsDOMWF2ValidityState.h \
                 $(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
Index: content/html/content/public/nsDOMWF2ValidityState.h
===================================================================
RCS file: content/html/content/public/nsDOMWF2ValidityState.h
diff -N content/html/content/public/nsDOMWF2ValidityState.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ content/html/content/public/nsDOMWF2ValidityState.h	24 Jul 2006 05:49:52 -0000
@@ -0,0 +1,53 @@
+/* ***** BEGIN LICENSE BLOCK *****

+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1

+ *

+ * The contents of this file are subject to the Mozilla Public License Version

+ * 1.1 (the "License"); you may not use this file except in compliance with

+ * the License. You may obtain a copy of the License at

+ * http://www.mozilla.org/MPL/

+ *

+ * Software distributed under the License is distributed on an "AS IS" basis,

+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License

+ * for the specific language governing rights and limitations under the

+ * License.

+ *

+ * The Original Code is Web Forms 2.0.

+ *

+ * The Initial Developer of the Original Code is

+ * Alexander J. Vincent <ajvincent@gmail.com>

+ * Portions created by the Initial Developer are Copyright (C) 2006

+ * the Initial Developer. All Rights Reserved.

+ *

+ * Contributor(s):

+ *

+ * Alternatively, the contents of this file may be used under the terms of

+ * either of the GNU General Public License Version 2 or later (the "GPL"),

+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),

+ * in which case the provisions of the GPL or the LGPL are applicable instead

+ * of those above. If you wish to allow use of your version of this file only

+ * under the terms of either the GPL or the LGPL, and not to allow others to

+ * use your version of this file under the terms of the MPL, indicate your

+ * decision by deleting the provisions above and replace them with the notice

+ * and other provisions required by the GPL or the LGPL. If you do not delete

+ * the provisions above, a recipient may use your version of this file under

+ * the terms of any one of the MPL, the GPL or the LGPL.

+ *

+ * ***** END LICENSE BLOCK ***** */

+

+#include "nsIContent.h"

+#include "nsIDOMWF2ValidityState.h"

+

+class nsDOMWF2ValidityState : public nsIDOMWF2ValidityState

+{

+public:

+  NS_DECL_ISUPPORTS

+  NS_DECL_NSIDOMWF2VALIDITYSTATE

+

+  nsDOMWF2ValidityState();

+

+private:

+  ~nsDOMWF2ValidityState();

+

+protected:

+  /* additional members */

+};

Index: content/html/content/src/Makefile.in
===================================================================
RCS file: /cvsroot/mozilla/content/html/content/src/Makefile.in,v
retrieving revision 1.70
diff -p -u -8 -r1.70 Makefile.in
--- content/html/content/src/Makefile.in	21 May 2006 21:00:09 -0000	1.70
+++ content/html/content/src/Makefile.in	24 Jul 2006 05:49:52 -0000
@@ -79,16 +79,17 @@ EXPORTS		= \
 		nsImageMapUtils.h \
 		$(NULL)
 
 CPPSRCS		= \
 		nsGenericHTMLElement.cpp \
 		nsGenericDOMHTMLCollection.cpp \
 		nsFormSubmission.cpp \
 		nsImageMapUtils.cpp \
+		nsDOMWF2ValidityState.cpp \
 		nsHTMLAnchorElement.cpp \
 		nsHTMLAreaElement.cpp \
 		nsHTMLBRElement.cpp \
 		nsHTMLBodyElement.cpp \
 		nsHTMLButtonElement.cpp \
 		nsHTMLCanvasElement.cpp \
 		nsHTMLDelElement.cpp \
 		nsHTMLDivElement.cpp \
Index: content/html/content/src/nsDOMWF2ValidityState.cpp
===================================================================
RCS file: content/html/content/src/nsDOMWF2ValidityState.cpp
diff -N content/html/content/src/nsDOMWF2ValidityState.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ content/html/content/src/nsDOMWF2ValidityState.cpp	24 Jul 2006 05:49:52 -0000
@@ -0,0 +1,67 @@
+/* ***** BEGIN LICENSE BLOCK *****

+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1

+ *

+ * The contents of this file are subject to the Mozilla Public License Version

+ * 1.1 (the "License"); you may not use this file except in compliance with

+ * the License. You may obtain a copy of the License at

+ * http://www.mozilla.org/MPL/

+ *

+ * Software distributed under the License is distributed on an "AS IS" basis,

+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License

+ * for the specific language governing rights and limitations under the

+ * License.

+ *

+ * The Original Code is Web Forms 2.0.

+ *

+ * The Initial Developer of the Original Code is

+ * Alexander J. Vincent <ajvincent@gmail.com>

+ * Portions created by the Initial Developer are Copyright (C) 2006

+ * the Initial Developer. All Rights Reserved.

+ *

+ * Contributor(s):

+ *

+ * Alternatively, the contents of this file may be used under the terms of

+ * either of the GNU General Public License Version 2 or later (the "GPL"),

+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),

+ * in which case the provisions of the GPL or the LGPL are applicable instead

+ * of those above. If you wish to allow use of your version of this file only

+ * under the terms of either the GPL or the LGPL, and not to allow others to

+ * use your version of this file under the terms of the MPL, indicate your

+ * decision by deleting the provisions above and replace them with the notice

+ * and other provisions required by the GPL or the LGPL. If you do not delete

+ * the provisions above, a recipient may use your version of this file under

+ * the terms of any one of the MPL, the GPL or the LGPL.

+ *

+*  * ***** END LICENSE BLOCK ***** */

+

+#include "nsISupports.h"

+#include "nsContentUtils.h"

+#include "nsDOMClassInfoID.h"

+#include "nsDOMWF2ValidityState.h"

+

+nsDOMWF2ValidityState::nsDOMWF2ValidityState()

+{

+  /* member initializers and constructor code */

+}

+

+nsDOMWF2ValidityState::~nsDOMWF2ValidityState()

+{

+  /* destructor code */

+}

+

+// QueryInterface implementation for nsDOMWF2ValidityState

+NS_INTERFACE_MAP_BEGIN(nsDOMWF2ValidityState)

+  NS_INTERFACE_MAP_ENTRY(nsISupports)

+  NS_INTERFACE_MAP_ENTRY(nsIDOMWF2ValidityState)

+  NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(DOMWF2ValidityState)

+NS_INTERFACE_MAP_END

+

+NS_IMPL_ADDREF(nsDOMWF2ValidityState)

+NS_IMPL_RELEASE(nsDOMWF2ValidityState)

+

+/* readonly attribute boolean valid; */

+NS_IMETHODIMP nsDOMWF2ValidityState::GetValid(PRBool *aValid)

+{

+  *aValid = PR_TRUE;

+  return NS_OK;

+}

Index: content/html/content/src/nsHTMLFormElement.cpp
===================================================================
RCS file: /cvsroot/mozilla/content/html/content/src/nsHTMLFormElement.cpp,v
retrieving revision 1.206
diff -p -u -8 -r1.206 nsHTMLFormElement.cpp
--- content/html/content/src/nsHTMLFormElement.cpp	22 Jul 2006 11:07:29 -0000	1.206
+++ content/html/content/src/nsHTMLFormElement.cpp	24 Jul 2006 05:49:54 -0000
@@ -35,16 +35,18 @@
  *
  * ***** END LICENSE BLOCK ***** */
 #include "nsCOMPtr.h"
 #include "nsIForm.h"
 #include "nsIFormControl.h"
 #include "nsIFormSubmission.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsIDOMNSHTMLFormElement.h"
+#include "nsIDOMWF2FormElement.h"
+#include "nsIDOMWF2FormControl.h"
 #include "nsIHTMLDocument.h"
 #include "nsIDOMNSHTMLFormControlList.h"
 #include "nsIDOMEventReceiver.h"
 #include "nsGenericHTMLElement.h"
 #include "nsEventStateManager.h"
 #include "nsHTMLAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
@@ -127,16 +129,17 @@ private:
 
 
 // nsHTMLFormElement
 
 class nsHTMLFormElement : public nsGenericHTMLElement,
                           public nsSupportsWeakReference,
                           public nsIDOMHTMLFormElement,
                           public nsIDOMNSHTMLFormElement,
+                          public nsIDOMWF2FormElement,
                           public nsIWebProgressListener,
                           public nsIForm,
                           public nsIRadioGroupContainer
 {
 public:
   nsHTMLFormElement(nsINodeInfo *aNodeInfo);
   virtual ~nsHTMLFormElement();
 
@@ -155,16 +158,19 @@ public:
   NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLFormElement
   NS_DECL_NSIDOMHTMLFORMELEMENT
 
   // nsIDOMNSHTMLFormElement
   NS_DECL_NSIDOMNSHTMLFORMELEMENT  
 
+  // nsIDOMWF2FormElement
+  NS_DECL_NSIDOMWF2FORMELEMENT
+
   // nsIWebProgressListener
   NS_DECL_NSIWEBPROGRESSLISTENER
 
   // nsIForm
   NS_IMETHOD AddElement(nsIFormControl* aElement);
   NS_IMETHOD AddElementToTable(nsIFormControl* aChild,
                                const nsAString& aName);
   NS_IMETHOD GetElementAt(PRInt32 aIndex, nsIFormControl** aElement) const;
@@ -534,16 +540,17 @@ NS_IMPL_ADDREF_INHERITED(nsHTMLFormEleme
 NS_IMPL_RELEASE_INHERITED(nsHTMLFormElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLFormElement
 NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLFormElement, nsGenericHTMLElement)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
   NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLFormElement)
   NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLFormElement)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMWF2FormElement)
   NS_INTERFACE_MAP_ENTRY(nsIForm)
   NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
   NS_INTERFACE_MAP_ENTRY(nsIRadioGroupContainer)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLFormElement)
 NS_HTML_CONTENT_INTERFACE_MAP_END
 
 
 // nsIDOMHTMLFormElement
@@ -1781,16 +1788,61 @@ nsHTMLFormElement::RemoveFromRadioGroup(
 }
 
 PRUint32
 nsHTMLFormElement::ElementCount() const
 {
   return mControls->mElements.Count();
 }
 
+// nsIDOMWF2FormElement
+NS_IMETHODIMP
+nsHTMLFormElement::CheckValidity(PRBool *_retval)
+{
+  *_retval = PR_TRUE;
+
+  nsCOMPtr<nsISimpleEnumerator> formControls;
+  nsresult rv = GetControlEnumerator(getter_AddRefs(formControls));
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  //
+  // Walk the list of nodes and call SubmitNamesValues() on the controls
+  //
+  PRBool hasMoreElements;
+  nsCOMPtr<nsISupports> controlSupports;
+  nsCOMPtr<nsIDOMWF2FormControl> control;
+  while (NS_SUCCEEDED(formControls->HasMoreElements(&hasMoreElements)) &&
+         hasMoreElements) {
+    rv = formControls->GetNext(getter_AddRefs(controlSupports));
+    NS_ENSURE_SUCCESS(rv, rv);
+    control = do_QueryInterface(controlSupports);
+
+    if (control)
+    {
+      PRBool willValidate;
+      rv = control->GetWillValidate(&willValidate);
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      if (willValidate)
+      {
+        // Every form control that can be checked for validity gets checked.
+        PRBool validity;
+        rv = control->CheckValidity(&validity);
+        NS_ENSURE_SUCCESS(rv, rv);
+        if (*_retval && !validity)
+        {
+          *_retval = PR_FALSE;
+        }
+      }
+    }
+  }
+
+  return NS_OK;
+}
+
 //----------------------------------------------------------------------
 // nsFormControlList implementation, this could go away if there were
 // a lightweight collection implementation somewhere
 
 nsFormControlList::nsFormControlList(nsHTMLFormElement* aForm) :
   mForm(aForm)
 {
 }
Index: content/html/content/src/nsHTMLInputElement.cpp
===================================================================
RCS file: /cvsroot/mozilla/content/html/content/src/nsHTMLInputElement.cpp,v
retrieving revision 1.435
diff -p -u -8 -r1.435 nsHTMLInputElement.cpp
--- content/html/content/src/nsHTMLInputElement.cpp	18 Jul 2006 19:32:00 -0000	1.435
+++ content/html/content/src/nsHTMLInputElement.cpp	24 Jul 2006 05:49:56 -0000
@@ -55,16 +55,19 @@
 #include "nsGenericHTMLElement.h"
 #include "nsHTMLAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsMappedAttributes.h"
 #include "nsIFormControl.h"
 #include "nsIForm.h"
 #include "nsIFormSubmission.h"
+#include "nsIDOMWF2FormControl.h"
+#include "nsIDOMWF2ValidityState.h"
+#include "nsDOMWF2ValidityState.h"
 #include "nsITextControlFrame.h"
 #include "nsIRadioControlFrame.h"
 #include "nsIDocument.h"
 #include "nsIPresShell.h"
 #include "nsIFormControlFrame.h"
 #include "nsIFrame.h"
 #include "nsIEventStateManager.h"
 #include "nsIServiceManager.h"
@@ -142,16 +145,17 @@ static NS_DEFINE_CID(kXULControllersCID,
   NS_OUTER_ACTIVATE_EVENT | NS_ORIGINAL_CHECKED_VALUE | NS_NO_CONTENT_DISPATCH))
 
 static const char kWhitespace[] = "\n\r\t\b";
 
 class nsHTMLInputElement : public nsGenericHTMLFormElement,
                            public nsImageLoadingContent,
                            public nsIDOMHTMLInputElement,
                            public nsIDOMNSHTMLInputElement,
+                           public nsIDOMWF2FormControl,
                            public nsITextControlElement,
                            public nsIRadioControlElement,
                            public nsIPhonetic,
                            public nsIDOMNSEditableElement,
                            public nsIFileControlElement
 {
 public:
   nsHTMLInputElement(nsINodeInfo *aNodeInfo, PRBool aFromParser);
@@ -170,16 +174,19 @@ public:
   NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFormElement::)
 
   // nsIDOMHTMLInputElement
   NS_DECL_NSIDOMHTMLINPUTELEMENT
 
   // nsIDOMNSHTMLInputElement
   NS_DECL_NSIDOMNSHTMLINPUTELEMENT
 
+  // nsIDOMWF2FormControl
+  NS_DECL_NSIDOMWF2FORMCONTROL
+
   // nsIPhonetic
   NS_DECL_NSIPHONETIC
 
   // nsIDOMNSEditableElement
   NS_FORWARD_NSIDOMNSEDITABLEELEMENT(nsGenericHTMLElement::)
 
   // Overriden nsIFormControl methods
   NS_IMETHOD_(PRInt32) GetType() const { return mType; }
@@ -329,16 +336,21 @@ protected:
    * so that it won't be possible to 'leak' the value from a text-input to a
    * file-input. Additionally, the logic for this value is kept as simple as
    * possible to avoid accidental errors where the wrong filename is used.
    * Therefor the filename is always owned by this member, never by the frame.
    * Whenever the frame wants to change the filename it has to call
    * SetFileName to update this member.
    */
   nsAutoPtr<nsString>      mFileName;
+
+  /**
+   * Validity state object for this control.
+   */
+  nsCOMPtr<nsIDOMWF2ValidityState> mValidity;
 };
 
 #ifdef ACCESSIBILITY
 //Helper method
 static nsresult FireEventForAccessibility(nsIDOMHTMLInputElement* aTarget,
                                           nsPresContext* aPresContext,
                                           const nsAString& aEventType);
 #endif
@@ -352,16 +364,18 @@ NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER
 nsHTMLInputElement::nsHTMLInputElement(nsINodeInfo *aNodeInfo,
                                        PRBool aFromParser)
   : nsGenericHTMLFormElement(aNodeInfo),
     mType(NS_FORM_INPUT_TEXT), // default value
     mBitField(0),
     mValue(nsnull)
 {
   SET_BOOLBIT(mBitField, BF_PARSER_CREATING, aFromParser);
+
+  mValidity = new nsDOMWF2ValidityState();
 }
 
 nsHTMLInputElement::~nsHTMLInputElement()
 {
   DestroyImageLoadingContent();
   if (mValue) {
     nsMemory::Free(mValue);
   }
@@ -374,16 +388,17 @@ NS_IMPL_ADDREF_INHERITED(nsHTMLInputElem
 NS_IMPL_RELEASE_INHERITED(nsHTMLInputElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLInputElement
 NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLInputElement,
                                     nsGenericHTMLFormElement)
   NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLInputElement)
   NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLInputElement)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMWF2FormControl)
   NS_INTERFACE_MAP_ENTRY(nsITextControlElement)
   NS_INTERFACE_MAP_ENTRY(nsIFileControlElement)
   NS_INTERFACE_MAP_ENTRY(nsIRadioControlElement)
   NS_INTERFACE_MAP_ENTRY(nsIPhonetic)
   NS_INTERFACE_MAP_ENTRY(imgIDecoderObserver)
   NS_INTERFACE_MAP_ENTRY(nsIImageLoadingContent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMNSEditableElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLInputElement)
@@ -2166,16 +2181,71 @@ FireEventForAccessibility(nsIDOMHTMLInpu
 
     nsEventDispatcher::DispatchDOMEvent(aTarget, nsnull, event, aPresContext, nsnull);
   }
 
   return NS_OK;
 }
 #endif
 
+// nsIDOMWF2FormControl
+
+NS_IMETHODIMP
+nsHTMLInputElement::GetWillValidate(PRBool *aWillValidate)
+{
+  *aWillValidate = PR_FALSE;
+
+  if (!mForm)
+    return NS_OK;
+
+  /* XXX ajvincent No ancestor of this node may be a repetition element or 
+     a datalist element, but those haven't been implemented yet.
+   */
+
+  if (!HasAttr(kNameSpaceID_None, nsHTMLAtoms::name))
+    return NS_OK;
+
+  if (HasAttr(kNameSpaceID_None, nsHTMLAtoms::disabled))
+    return NS_OK;
+
+  if (mType == NS_FORM_INPUT_RESET || mType == NS_FORM_INPUT_BUTTON)
+    return NS_OK;
+
+  *aWillValidate = PR_TRUE;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsHTMLInputElement::GetValidity(nsIDOMWF2ValidityState * *aValidity)
+{
+  NS_ADDREF(*aValidity = mValidity);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsHTMLInputElement::CheckValidity(PRBool *_retval)
+{
+  nsresult rv = mValidity->GetValid(_retval);
+  if (!_retval)
+  {
+    // Dispatch invalid event.
+/*
+    kXMLEventsNameSpaceURI = namespace
+    kNameSpaceID_XMLEvents
+ */
+
+    nsGUIEvent event(PR_TRUE, NS_FORM_INVALID, nsnull);
+    nsCOMPtr<nsPresContext> presContext = GetPresContext();
+    nsEventStatus status = nsEventStatus_eIgnore;
+    nsEventDispatcher::Dispatch(NS_STATIC_CAST(nsIContent*, this), presContext,
+                                &event, nsnull, &status);
+  }
+  return NS_OK;
+}
+
 nsresult
 nsHTMLInputElement::Reset()
 {
   nsresult rv = NS_OK;
 
   nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_FALSE);
 
   switch (mType) {