summaryrefslogtreecommitdiffstats
path: root/WebCore/html/HTMLFormElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/html/HTMLFormElement.cpp')
-rw-r--r--WebCore/html/HTMLFormElement.cpp46
1 files changed, 41 insertions, 5 deletions
diff --git a/WebCore/html/HTMLFormElement.cpp b/WebCore/html/HTMLFormElement.cpp
index 54986b0..ace0f2f 100644
--- a/WebCore/html/HTMLFormElement.cpp
+++ b/WebCore/html/HTMLFormElement.cpp
@@ -47,6 +47,7 @@
#include "MappedAttribute.h"
#include "Page.h"
#include "RenderTextControl.h"
+#include "ValidityState.h"
#include <limits>
#include <wtf/CurrentTime.h>
#include <wtf/RandomNumber.h>
@@ -149,14 +150,14 @@ void HTMLFormElement::removedFromDocument()
HTMLElement::removedFromDocument();
}
-void HTMLFormElement::handleLocalEvents(Event* event, bool useCapture)
+void HTMLFormElement::handleLocalEvents(Event* event)
{
Node* targetNode = event->target()->toNode();
- if (!useCapture && targetNode && targetNode != this && (event->type() == eventNames().submitEvent || event->type() == eventNames().resetEvent)) {
+ if (event->eventPhase() != Event::CAPTURING_PHASE && targetNode && targetNode != this && (event->type() == eventNames().submitEvent || event->type() == eventNames().resetEvent)) {
event->stopPropagation();
return;
}
- HTMLElement::handleLocalEvents(event, useCapture);
+ HTMLElement::handleLocalEvents(event);
}
unsigned HTMLFormElement::length() const
@@ -295,7 +296,7 @@ bool HTMLFormElement::prepareSubmit(Event* event)
m_insubmit = true;
m_doingsubmit = false;
- if (dispatchEvent(eventNames().submitEvent, true, true) && !m_doingsubmit)
+ if (dispatchEvent(Event::create(eventNames().submitEvent, true, true)) && !m_doingsubmit)
m_doingsubmit = true;
m_insubmit = false;
@@ -415,7 +416,7 @@ void HTMLFormElement::reset()
// ### DOM2 labels this event as not cancelable, however
// common browsers( sick! ) allow it be cancelled.
- if ( !dispatchEvent(eventNames().resetEvent, true, true) ) {
+ if (!dispatchEvent(Event::create(eventNames().resetEvent, true, true))) {
m_inreset = false;
return;
}
@@ -537,6 +538,16 @@ void HTMLFormElement::setName(const String &value)
setAttribute(nameAttr, value);
}
+bool HTMLFormElement::noValidate() const
+{
+ return !getAttribute(novalidateAttr).isNull();
+}
+
+void HTMLFormElement::setNoValidate(bool novalidate)
+{
+ setAttribute(novalidateAttr, novalidate ? "" : 0);
+}
+
void HTMLFormElement::setAcceptCharset(const String &value)
{
setAttribute(accept_charsetAttr, value);
@@ -577,6 +588,31 @@ void HTMLFormElement::setTarget(const String &value)
setAttribute(targetAttr, value);
}
+HTMLFormControlElement* HTMLFormElement::defaultButton() const
+{
+ for (unsigned i = 0; i < formElements.size(); ++i) {
+ HTMLFormControlElement* control = formElements[i];
+ if (control->isSuccessfulSubmitButton())
+ return control;
+ }
+
+ return 0;
+}
+
+bool HTMLFormElement::checkValidity()
+{
+ // TODO: Check for unhandled invalid controls, see #27452 for tips.
+
+ bool hasOnlyValidControls = true;
+ for (unsigned i = 0; i < formElements.size(); ++i) {
+ HTMLFormControlElement* control = formElements[i];
+ if (!control->checkValidity())
+ hasOnlyValidControls = false;
+ }
+
+ return hasOnlyValidControls;
+}
+
PassRefPtr<HTMLFormControlElement> HTMLFormElement::elementForAlias(const AtomicString& alias)
{
if (alias.isEmpty() || !m_elementAliases)