|
Lines 27-32
a/WebCore/html/HTMLFormElement.cpp_sec1
|
| 27 |
|
27 |
|
| 28 |
#include "CSSHelper.h" |
28 |
#include "CSSHelper.h" |
| 29 |
#include "DOMFormData.h" |
29 |
#include "DOMFormData.h" |
|
|
30 |
#include "DOMWindow.h" |
| 30 |
#include "Document.h" |
31 |
#include "Document.h" |
| 31 |
#include "Event.h" |
32 |
#include "Event.h" |
| 32 |
#include "EventNames.h" |
33 |
#include "EventNames.h" |
|
Lines 188-194
void HTMLFormElement::submitClick(Event* event)
a/WebCore/html/HTMLFormElement.cpp_sec2
|
| 188 |
} |
189 |
} |
| 189 |
} |
190 |
} |
| 190 |
if (!submitFound) // submit the form without a submit or image input |
191 |
if (!submitFound) // submit the form without a submit or image input |
| 191 |
prepareSubmit(event); |
192 |
prepareSubmit(event, 0); |
| 192 |
} |
193 |
} |
| 193 |
|
194 |
|
| 194 |
TextEncoding HTMLFormElement::dataEncoding() const |
195 |
TextEncoding HTMLFormElement::dataEncoding() const |
|
Lines 219-225
bool HTMLFormElement::isMailtoForm() const
a/WebCore/html/HTMLFormElement.cpp_sec3
|
| 219 |
return protocolIs(m_url, "mailto"); |
220 |
return protocolIs(m_url, "mailto"); |
| 220 |
} |
221 |
} |
| 221 |
|
222 |
|
| 222 |
bool HTMLFormElement::prepareSubmit(Event* event) |
223 |
bool HTMLFormElement::prepareSubmit(Event* event, HTMLFormControlElement* submitElement) |
| 223 |
{ |
224 |
{ |
| 224 |
Frame* frame = document()->frame(); |
225 |
Frame* frame = document()->frame(); |
| 225 |
if (m_insubmit || !frame) |
226 |
if (m_insubmit || !frame) |
|
Lines 228-233
bool HTMLFormElement::prepareSubmit(Event* event)
a/WebCore/html/HTMLFormElement.cpp_sec4
|
| 228 |
m_insubmit = true; |
229 |
m_insubmit = true; |
| 229 |
m_doingsubmit = false; |
230 |
m_doingsubmit = false; |
| 230 |
|
231 |
|
|
|
232 |
// Interactive validation must be done before dispatching the submit event. |
| 233 |
if (!noValidate() && (!submitElement || !submitElement->formNoValidate())) { |
| 234 |
Vector<HTMLFormControlElement*> unhandledInvalidControls; |
| 235 |
// If the form has invalid controls, abort submission. |
| 236 |
if (!checkValidity(unhandledInvalidControls)) { |
| 237 |
// Focus on the first forcusable control. |
| 238 |
for (unsigned i = 0; i < unhandledInvalidControls.size(); ++i) { |
| 239 |
HTMLFormControlElement* unhandled = unhandledInvalidControls[i]; |
| 240 |
if (unhandled->isFocusable()) { |
| 241 |
unhandled->scrollIntoViewIfNeeded(false); |
| 242 |
unhandled->focus(); |
| 243 |
break; |
| 244 |
} |
| 245 |
} |
| 246 |
// Warn about all of unforcusable controls. |
| 247 |
Frame* frame = document()->frame(); |
| 248 |
for (unsigned i = 0; frame && i < unhandledInvalidControls.size(); ++i) { |
| 249 |
HTMLFormControlElement* unhandled = unhandledInvalidControls[i]; |
| 250 |
if (unhandled->isFocusable()) |
| 251 |
continue; |
| 252 |
String message("An invalid form control with name='%name' is not user-editable."); |
| 253 |
message.replace("%name", unhandled->name()); |
| 254 |
frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, ErrorMessageLevel, message, 0, document()->url().string()); |
| 255 |
} |
| 256 |
m_insubmit = false; |
| 257 |
return false; |
| 258 |
} |
| 259 |
} |
| 260 |
|
| 231 |
if (dispatchEvent(Event::create(eventNames().submitEvent, true, true)) && !m_doingsubmit) |
261 |
if (dispatchEvent(Event::create(eventNames().submitEvent, true, true)) && !m_doingsubmit) |
| 232 |
m_doingsubmit = true; |
262 |
m_doingsubmit = true; |
| 233 |
|
263 |
|
|
Lines 541-556
HTMLFormControlElement* HTMLFormElement::defaultButton() const
a/WebCore/html/HTMLFormElement.cpp_sec5
|
| 541 |
|
571 |
|
| 542 |
bool HTMLFormElement::checkValidity() |
572 |
bool HTMLFormElement::checkValidity() |
| 543 |
{ |
573 |
{ |
| 544 |
// TODO: Check for unhandled invalid controls, see #27452 for tips. |
574 |
Vector<HTMLFormControlElement*> unhandled; |
|
|
575 |
return checkValidity(unhandled); |
| 576 |
} |
| 545 |
|
577 |
|
| 546 |
bool hasOnlyValidControls = true; |
578 |
bool HTMLFormElement::checkValidity(Vector<HTMLFormControlElement*>& unhandledInvalidControls) |
|
|
579 |
{ |
| 547 |
for (unsigned i = 0; i < formElements.size(); ++i) { |
580 |
for (unsigned i = 0; i < formElements.size(); ++i) { |
| 548 |
HTMLFormControlElement* control = formElements[i]; |
581 |
HTMLFormControlElement* control = formElements[i]; |
| 549 |
if (!control->checkValidity()) |
582 |
control->checkValidity(&unhandledInvalidControls); |
| 550 |
hasOnlyValidControls = false; |
|
|
| 551 |
} |
583 |
} |
| 552 |
|
584 |
return !unhandledInvalidControls.size(); |
| 553 |
return hasOnlyValidControls; |
|
|
| 554 |
} |
585 |
} |
| 555 |
|
586 |
|
| 556 |
PassRefPtr<HTMLFormControlElement> HTMLFormElement::elementForAlias(const AtomicString& alias) |
587 |
PassRefPtr<HTMLFormControlElement> HTMLFormElement::elementForAlias(const AtomicString& alias) |