HTMLFormControlElementWithState.cpp [plain text]
#include "config.h"
#include "HTMLFormControlElementWithState.h"
#include "FormController.h"
#include "Frame.h"
#include "HTMLFormElement.h"
#include <wtf/IsoMallocInlines.h>
namespace WebCore {
WTF_MAKE_ISO_ALLOCATED_IMPL(HTMLFormControlElementWithState);
HTMLFormControlElementWithState::HTMLFormControlElementWithState(const QualifiedName& tagName, Document& document, HTMLFormElement* form)
: HTMLFormControlElement(tagName, document, form)
{
}
HTMLFormControlElementWithState::~HTMLFormControlElementWithState() = default;
Node::InsertedIntoAncestorResult HTMLFormControlElementWithState::insertedIntoAncestor(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
{
if (insertionType.connectedToDocument && !containingShadowRoot())
document().formController().registerFormElementWithState(*this);
return HTMLFormControlElement::insertedIntoAncestor(insertionType, parentOfInsertedTree);
}
void HTMLFormControlElementWithState::removedFromAncestor(RemovalType removalType, ContainerNode& oldParentOfRemovedTree)
{
if (removalType.disconnectedFromDocument && !containingShadowRoot() && !oldParentOfRemovedTree.containingShadowRoot())
document().formController().unregisterFormElementWithState(*this);
HTMLFormControlElement::removedFromAncestor(removalType, oldParentOfRemovedTree);
}
bool HTMLFormControlElementWithState::shouldAutocomplete() const
{
if (!form())
return true;
return form()->shouldAutocomplete();
}
bool HTMLFormControlElementWithState::shouldSaveAndRestoreFormControlState() const
{
return isConnected() && shouldAutocomplete();
}
FormControlState HTMLFormControlElementWithState::saveFormControlState() const
{
return FormControlState();
}
void HTMLFormControlElementWithState::finishParsingChildren()
{
HTMLFormControlElement::finishParsingChildren();
document().formController().restoreControlStateFor(*this);
}
bool HTMLFormControlElementWithState::isFormControlElementWithState() const
{
return true;
}
}