| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010, 2011, 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2010, 2011, 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 | 394 |
| 395 PassOwnPtr<FormController::SavedFormStateMap> FormController::createSavedFormSta
teMap(const FormElementListHashSet& controlList) | 395 PassOwnPtr<FormController::SavedFormStateMap> FormController::createSavedFormSta
teMap(const FormElementListHashSet& controlList) |
| 396 { | 396 { |
| 397 OwnPtr<FormKeyGenerator> keyGenerator = FormKeyGenerator::create(); | 397 OwnPtr<FormKeyGenerator> keyGenerator = FormKeyGenerator::create(); |
| 398 OwnPtr<SavedFormStateMap> stateMap = adoptPtr(new SavedFormStateMap); | 398 OwnPtr<SavedFormStateMap> stateMap = adoptPtr(new SavedFormStateMap); |
| 399 for (FormElementListHashSet::const_iterator it = controlList.begin(); it !=
controlList.end(); ++it) { | 399 for (FormElementListHashSet::const_iterator it = controlList.begin(); it !=
controlList.end(); ++it) { |
| 400 HTMLFormControlElementWithState* control = (*it).get(); | 400 HTMLFormControlElementWithState* control = (*it).get(); |
| 401 ASSERT(control->inDocument()); | 401 ASSERT(control->inDocument()); |
| 402 if (!control->shouldSaveAndRestoreFormControlState()) | 402 if (!control->shouldSaveAndRestoreFormControlState()) |
| 403 continue; | 403 continue; |
| 404 SavedFormStateMap::AddResult result = stateMap->add(keyGenerator->formKe
y(*control).impl(), nullptr); | 404 SavedFormStateMap::AddResult result = stateMap->add(keyGenerator->formKe
y(*control), nullptr); |
| 405 if (result.isNewEntry) | 405 if (result.isNewEntry) |
| 406 result.iterator->value = SavedFormState::create(); | 406 result.iterator->value = SavedFormState::create(); |
| 407 result.iterator->value->appendControlState(control->name(), control->typ
e(), control->saveFormControlState()); | 407 result.iterator->value->appendControlState(control->name(), control->typ
e(), control->saveFormControlState()); |
| 408 } | 408 } |
| 409 return stateMap.release(); | 409 return stateMap.release(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 Vector<String> FormController::formElementsState() const | 412 Vector<String> FormController::formElementsState() const |
| 413 { | 413 { |
| 414 OwnPtr<SavedFormStateMap> stateMap = createSavedFormStateMap(m_formElementsW
ithState); | 414 OwnPtr<SavedFormStateMap> stateMap = createSavedFormStateMap(m_formElementsW
ithState); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 429 { | 429 { |
| 430 formStatesFromStateVector(stateVector, m_savedFormStateMap); | 430 formStatesFromStateVector(stateVector, m_savedFormStateMap); |
| 431 } | 431 } |
| 432 | 432 |
| 433 FormControlState FormController::takeStateForFormElement(const HTMLFormControlEl
ementWithState& control) | 433 FormControlState FormController::takeStateForFormElement(const HTMLFormControlEl
ementWithState& control) |
| 434 { | 434 { |
| 435 if (m_savedFormStateMap.isEmpty()) | 435 if (m_savedFormStateMap.isEmpty()) |
| 436 return FormControlState(); | 436 return FormControlState(); |
| 437 if (!m_formKeyGenerator) | 437 if (!m_formKeyGenerator) |
| 438 m_formKeyGenerator = FormKeyGenerator::create(); | 438 m_formKeyGenerator = FormKeyGenerator::create(); |
| 439 SavedFormStateMap::iterator it = m_savedFormStateMap.find(m_formKeyGenerator
->formKey(control).impl()); | 439 SavedFormStateMap::iterator it = m_savedFormStateMap.find(m_formKeyGenerator
->formKey(control)); |
| 440 if (it == m_savedFormStateMap.end()) | 440 if (it == m_savedFormStateMap.end()) |
| 441 return FormControlState(); | 441 return FormControlState(); |
| 442 FormControlState state = it->value->takeControlState(control.name(), control
.type()); | 442 FormControlState state = it->value->takeControlState(control.name(), control
.type()); |
| 443 if (it->value->isEmpty()) | 443 if (it->value->isEmpty()) |
| 444 m_savedFormStateMap.remove(it); | 444 m_savedFormStateMap.remove(it); |
| 445 return state; | 445 return state; |
| 446 } | 446 } |
| 447 | 447 |
| 448 void FormController::formStatesFromStateVector(const Vector<String>& stateVector
, SavedFormStateMap& map) | 448 void FormController::formStatesFromStateVector(const Vector<String>& stateVector
, SavedFormStateMap& map) |
| 449 { | 449 { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 m_formElementsWithState.add(control); | 519 m_formElementsWithState.add(control); |
| 520 } | 520 } |
| 521 | 521 |
| 522 void FormController::unregisterFormElementWithState(HTMLFormControlElementWithSt
ate* control) | 522 void FormController::unregisterFormElementWithState(HTMLFormControlElementWithSt
ate* control) |
| 523 { | 523 { |
| 524 RELEASE_ASSERT(m_formElementsWithState.contains(control)); | 524 RELEASE_ASSERT(m_formElementsWithState.contains(control)); |
| 525 m_formElementsWithState.remove(control); | 525 m_formElementsWithState.remove(control); |
| 526 } | 526 } |
| 527 | 527 |
| 528 } // namespace WebCore | 528 } // namespace WebCore |
| OLD | NEW |