HTMLFormControlElementWithState.cpp [plain text]
#include "config.h"
#include "HTMLFormControlElementWithState.h"
#include "HTMLFormElement.h"
namespace WebCore {
HTMLFormControlElementWithState::HTMLFormControlElementWithState(const QualifiedName& tagName, Document* doc, HTMLFormElement* f)
: HTMLFormControlElement(tagName, doc, f)
{
document()->registerFormElementWithState(this);
}
HTMLFormControlElementWithState::~HTMLFormControlElementWithState()
{
document()->unregisterFormElementWithState(this);
}
void HTMLFormControlElementWithState::didMoveToNewDocument(Document* oldDocument)
{
if (oldDocument)
oldDocument->unregisterFormElementWithState(this);
document()->registerFormElementWithState(this);
HTMLFormControlElement::didMoveToNewDocument(oldDocument);
}
bool HTMLFormControlElementWithState::shouldAutocomplete() const
{
if (!form())
return true;
return form()->shouldAutocomplete();
}
bool HTMLFormControlElementWithState::shouldSaveAndRestoreFormControlState() const
{
return attached() && shouldAutocomplete();
}
void HTMLFormControlElementWithState::finishParsingChildren()
{
HTMLFormControlElement::finishParsingChildren();
if (!shouldSaveAndRestoreFormControlState())
return;
Document* doc = document();
if (doc->hasStateForNewFormElements()) {
String state;
if (doc->takeStateForFormElement(name().impl(), type().impl(), state))
restoreFormControlState(state);
}
}
}