예제 #1
0
OwnPtr<FormController::SavedFormStateMap> FormController::createSavedFormStateMap(const FormElementListHashSet& controlList)
{
    OwnPtr<FormKeyGenerator> keyGenerator = FormKeyGenerator::create();
    OwnPtr<SavedFormStateMap> stateMap = adoptPtr(new SavedFormStateMap);
    for (FormElementListHashSet::const_iterator it = controlList.begin(); it != controlList.end(); ++it) {
        HTMLFormControlElementWithState* control = it->get();
        if (!control->shouldSaveAndRestoreFormControlState())
            continue;
        SavedFormStateMap::AddResult result = stateMap->add(keyGenerator->formKey(*control).impl(), nullptr);
        if (result.isNewEntry)
            result.iterator->value = SavedFormState::create();
        result.iterator->value->appendControlState(control->name(), control->type(), control->saveFormControlState());
    }
    return stateMap.release();
}
예제 #2
0
std::unique_ptr<FormController::SavedFormStateMap> FormController::createSavedFormStateMap(const FormElementListHashSet& controlList)
{
    FormKeyGenerator keyGenerator;
    auto stateMap = std::make_unique<SavedFormStateMap>();
    for (FormElementListHashSet::const_iterator it = controlList.begin(); it != controlList.end(); ++it) {
        HTMLFormControlElementWithState* control = it->get();
        if (!control->shouldSaveAndRestoreFormControlState())
            continue;
        auto& formState = stateMap->add(keyGenerator.formKey(*control).impl(), nullptr).iterator->value;
        if (!formState)
            formState = std::make_unique<SavedFormState>();
        formState->appendControlState(control->name(), control->type(), control->saveFormControlState());
    }
    return stateMap;
}