FormControlElementWithState.cpp [plain text]
#include "config.h"
#include "FormControlElementWithState.h"
#include "Document.h"
#include "Element.h"
#include "HTMLFormControlElement.h"
#include <wtf/Assertions.h>
#if ENABLE(WML)
#include "WMLFormControlElement.h"
#endif
namespace WebCore {
void FormControlElementWithState::registerFormControlElementWithState(FormControlElementWithState* element, Document* document)
{
document->registerFormElementWithState(element);
}
void FormControlElementWithState::unregisterFormControlElementWithState(FormControlElementWithState* element, Document* document)
{
document->unregisterFormElementWithState(element);
}
void FormControlElementWithState::finishParsingChildren(FormControlElementWithState* element, Document* document)
{
if (!document->hasStateForNewFormElements())
return;
FormControlElement* formControlElement = element->toFormControlElement();
ASSERT(formControlElement);
String state;
if (document->takeStateForFormElement(formControlElement->name().impl(), formControlElement->type().impl(), state))
element->restoreState(state);
}
FormControlElementWithState* toFormControlElementWithState(Element* element)
{
if (!element->isFormControlElementWithState())
return 0;
if (element->isHTMLElement())
return static_cast<HTMLFormControlElementWithState*>(element);
#if ENABLE(WML)
if (element->isWMLElement())
return static_cast<WMLFormControlElementWithState*>(element);
#endif
return 0;
}
}