This source file includes following definitions.
- m_documentVersion
- create
- invalidateDisabledStateUnder
- disabledAttributeChanged
- childrenChanged
- supportsFocus
- formControlType
- createRenderer
- legend
- elements
- refreshElementsIfNeeded
- associatedElements
#include "config.h"
#include "core/html/HTMLFieldSetElement.h"
#include "HTMLNames.h"
#include "core/dom/ElementTraversal.h"
#include "core/html/HTMLCollection.h"
#include "core/html/HTMLLegendElement.h"
#include "core/html/HTMLObjectElement.h"
#include "core/rendering/RenderFieldset.h"
#include "wtf/StdLibExtras.h"
namespace WebCore {
using namespace HTMLNames;
inline HTMLFieldSetElement::HTMLFieldSetElement(Document& document, HTMLFormElement* form)
: HTMLFormControlElement(fieldsetTag, document, form)
, m_documentVersion(0)
{
ScriptWrappable::init(this);
}
PassRefPtr<HTMLFieldSetElement> HTMLFieldSetElement::create(Document& document, HTMLFormElement* form)
{
return adoptRef(new HTMLFieldSetElement(document, form));
}
void HTMLFieldSetElement::invalidateDisabledStateUnder(Element& base)
{
for (Element* element = ElementTraversal::firstWithin(base); element; element = ElementTraversal::next(*element, &base)) {
if (element->isFormControlElement())
toHTMLFormControlElement(element)->ancestorDisabledStateWasChanged();
}
}
void HTMLFieldSetElement::disabledAttributeChanged()
{
HTMLFormControlElement::disabledAttributeChanged();
invalidateDisabledStateUnder(*this);
}
void HTMLFieldSetElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
{
HTMLFormControlElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
for (HTMLLegendElement* legend = Traversal<HTMLLegendElement>::firstChild(*this); legend; legend = Traversal<HTMLLegendElement>::nextSibling(*legend))
invalidateDisabledStateUnder(*legend);
}
bool HTMLFieldSetElement::supportsFocus() const
{
return HTMLElement::supportsFocus();
}
const AtomicString& HTMLFieldSetElement::formControlType() const
{
DEFINE_STATIC_LOCAL(const AtomicString, fieldset, ("fieldset", AtomicString::ConstructFromLiteral));
return fieldset;
}
RenderObject* HTMLFieldSetElement::createRenderer(RenderStyle*)
{
return new RenderFieldset(this);
}
HTMLLegendElement* HTMLFieldSetElement::legend() const
{
return Traversal<HTMLLegendElement>::firstChild(*this);
}
PassRefPtr<HTMLCollection> HTMLFieldSetElement::elements()
{
return ensureCachedHTMLCollection(FormControls);
}
void HTMLFieldSetElement::refreshElementsIfNeeded() const
{
uint64_t docVersion = document().domTreeVersion();
if (m_documentVersion == docVersion)
return;
m_documentVersion = docVersion;
m_associatedElements.clear();
for (HTMLElement* element = Traversal<HTMLElement>::firstWithin(*this); element; element = Traversal<HTMLElement>::next(*element, this)) {
if (isHTMLObjectElement(*element)) {
m_associatedElements.append(toHTMLObjectElement(element));
continue;
}
if (!element->isFormControlElement())
continue;
m_associatedElements.append(toHTMLFormControlElement(element));
}
}
const Vector<FormAssociatedElement*>& HTMLFieldSetElement::associatedElements() const
{
refreshElementsIfNeeded();
return m_associatedElements;
}
}