diff options
Diffstat (limited to 'WebCore/html/HTMLFormControlElement.cpp')
-rw-r--r-- | WebCore/html/HTMLFormControlElement.cpp | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/WebCore/html/HTMLFormControlElement.cpp b/WebCore/html/HTMLFormControlElement.cpp index eb25c40..6f24e0c 100644 --- a/WebCore/html/HTMLFormControlElement.cpp +++ b/WebCore/html/HTMLFormControlElement.cpp @@ -52,6 +52,7 @@ using namespace HTMLNames; HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Document* doc, HTMLFormElement* f) : HTMLElement(tagName, doc) , m_form(f) + , m_hasName(false) , m_disabled(false) , m_readOnly(false) , m_required(false) @@ -89,8 +90,9 @@ ValidityState* HTMLFormControlElement::validity() void HTMLFormControlElement::parseMappedAttribute(MappedAttribute *attr) { + bool oldWillValidate = willValidate(); if (attr->name() == nameAttr) - setNeedsStyleRecalc(); + m_hasName = !attr->isEmpty(); else if (attr->name() == disabledAttr) { bool oldDisabled = m_disabled; m_disabled = !attr->isNull(); @@ -114,6 +116,8 @@ void HTMLFormControlElement::parseMappedAttribute(MappedAttribute *attr) setNeedsStyleRecalc(); } else HTMLElement::parseMappedAttribute(attr); + if (oldWillValidate != willValidate()) + setNeedsWillValidateCheck(); } void HTMLFormControlElement::attach() @@ -149,9 +153,10 @@ void HTMLFormControlElement::insertedIntoTree(bool deep) // setting a form, we will already have a non-null value for m_form, // and so we don't need to do anything. m_form = findFormAncestor(); - if (m_form) + if (m_form) { m_form->registerFormElement(this); - else + setNeedsWillValidateCheck(); + } else document()->checkedRadioButtons().addButton(this); } @@ -178,11 +183,19 @@ void HTMLFormControlElement::removedFromTree(bool deep) if (m_form && !(parser && parser->isHandlingResidualStyleAcrossBlocks()) && findRoot(this) != findRoot(m_form)) { m_form->removeFormElement(this); m_form = 0; + setNeedsWillValidateCheck(); } HTMLElement::removedFromTree(deep); } +void HTMLFormControlElement::formDestroyed() +{ + if (m_form) + setNeedsWillValidateCheck(); + m_form = 0; +} + const AtomicString& HTMLFormControlElement::formControlName() const { const AtomicString& n = getAttribute(nameAttr); @@ -199,11 +212,6 @@ void HTMLFormControlElement::dispatchFormControlChangeEvent() dispatchEvent(Event::create(eventNames().changeEvent, true, false)); } -bool HTMLFormControlElement::disabled() const -{ - return m_disabled; -} - void HTMLFormControlElement::setDisabled(bool b) { setAttribute(disabledAttr, b ? "" : 0); @@ -297,7 +305,7 @@ bool HTMLFormControlElement::willValidate() const // The control does not have a repetition template as an ancestor. // The control does not have a datalist element as an ancestor. // The control is not an output element. - return form() && !name().isEmpty() && !disabled() && !isReadOnlyFormControl(); + return m_form && m_hasName && !m_disabled && !m_readOnly; } String HTMLFormControlElement::validationMessage() @@ -305,6 +313,12 @@ String HTMLFormControlElement::validationMessage() return validity()->validationMessage(); } +void HTMLFormControlElement::setNeedsWillValidateCheck() +{ + setNeedsStyleRecalc(); + // FIXME: Show/hide a validation message. +} + bool HTMLFormControlElement::checkValidity() { if (willValidate() && !isValidFormControlElement()) { @@ -315,12 +329,13 @@ bool HTMLFormControlElement::checkValidity() return true; } -void HTMLFormControlElement::updateValidity() +void HTMLFormControlElement::setNeedsValidityCheck() { if (willValidate()) { // Update style for pseudo classes such as :valid :invalid. setNeedsStyleRecalc(); } + // FIXME: show/hide a validation message. } void HTMLFormControlElement::setCustomValidity(const String& error) |