HTMLLegendElement.cpp [plain text]
#include "config.h"
#include "HTMLLegendElement.h"
#include "HTMLFormControlElement.h"
#include "HTMLNames.h"
#include <wtf/StdLibExtras.h>
namespace WebCore {
using namespace HTMLNames;
inline HTMLLegendElement::HTMLLegendElement(const QualifiedName& tagName, Document* document)
: HTMLElement(tagName, document)
{
ASSERT(hasTagName(legendTag));
}
PassRefPtr<HTMLLegendElement> HTMLLegendElement::create(const QualifiedName& tagName, Document* document)
{
return adoptRef(new HTMLLegendElement(tagName, document));
}
HTMLFormControlElement* HTMLLegendElement::associatedControl()
{
ContainerNode* fieldset = parentNode();
while (fieldset && !fieldset->hasTagName(fieldsetTag))
fieldset = fieldset->parentNode();
if (!fieldset)
return 0;
Node* node = fieldset;
while ((node = node->traverseNextNode(fieldset))) {
if (node->isElementNode()) {
Element* element = static_cast<Element*>(node);
if (element->isFormControlElement())
return static_cast<HTMLFormControlElement*>(element);
}
}
return 0;
}
void HTMLLegendElement::focus(bool)
{
if (isFocusable())
Element::focus();
if (HTMLFormControlElement* control = associatedControl())
control->focus(false);
}
void HTMLLegendElement::accessKeyAction(bool sendMouseEvents)
{
if (HTMLFormControlElement* control = associatedControl())
control->accessKeyAction(sendMouseEvents);
}
}