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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 if (type.isEmpty() || type.find(isNotFormControlTypeCharacter) != kNotFo und || state.isFailure()) | 222 if (type.isEmpty() || type.find(isNotFormControlTypeCharacter) != kNotFo und || state.isFailure()) |
223 return nullptr; | 223 return nullptr; |
224 savedFormState->appendControlState(AtomicString(name), AtomicString(type ), state); | 224 savedFormState->appendControlState(AtomicString(name), AtomicString(type ), state); |
225 } | 225 } |
226 return savedFormState.release(); | 226 return savedFormState.release(); |
227 } | 227 } |
228 | 228 |
229 void SavedFormState::serializeTo(Vector<String>& stateVector) const | 229 void SavedFormState::serializeTo(Vector<String>& stateVector) const |
230 { | 230 { |
231 stateVector.append(String::number(m_controlStateCount)); | 231 stateVector.append(String::number(m_controlStateCount)); |
232 for (FormElementStateMap::const_iterator it = m_stateForNewFormElements.begi n(); it != m_stateForNewFormElements.end(); ++it) { | 232 for (const auto& formElementState : m_stateForNewFormElements) { |
233 const FormElementKey& key = it->key; | 233 const FormElementKey& key = formElementState.key; |
234 const Deque<FormControlState>& queue = it->value; | 234 const Deque<FormControlState>& queue = formElementState.value; |
235 for (Deque<FormControlState>::const_iterator queIterator = queue.begin() ; queIterator != queue.end(); ++queIterator) { | 235 for (const auto& queIterator : queue) { |
236 stateVector.append(key.name()); | 236 stateVector.append(key.name()); |
237 stateVector.append(key.type()); | 237 stateVector.append(key.type()); |
238 queIterator->serializeTo(stateVector); | 238 queIterator.serializeTo(stateVector); |
239 } | 239 } |
240 } | 240 } |
241 } | 241 } |
242 | 242 |
243 void SavedFormState::appendControlState(const AtomicString& name, const AtomicSt ring& type, const FormControlState& state) | 243 void SavedFormState::appendControlState(const AtomicString& name, const AtomicSt ring& type, const FormControlState& state) |
244 { | 244 { |
245 FormElementKey key(name.impl(), type.impl()); | 245 FormElementKey key(name.impl(), type.impl()); |
246 FormElementStateMap::iterator it = m_stateForNewFormElements.find(key); | 246 FormElementStateMap::iterator it = m_stateForNewFormElements.find(key); |
247 if (it != m_stateForNewFormElements.end()) { | 247 if (it != m_stateForNewFormElements.end()) { |
248 it->value.append(state); | 248 it->value.append(state); |
(...skipping 16 matching lines...) Expand all Loading... | |
265 FormControlState state = it->value.takeFirst(); | 265 FormControlState state = it->value.takeFirst(); |
266 m_controlStateCount--; | 266 m_controlStateCount--; |
267 if (!it->value.size()) | 267 if (!it->value.size()) |
268 m_stateForNewFormElements.remove(it); | 268 m_stateForNewFormElements.remove(it); |
269 return state; | 269 return state; |
270 } | 270 } |
271 | 271 |
272 Vector<String> SavedFormState::getReferencedFilePaths() const | 272 Vector<String> SavedFormState::getReferencedFilePaths() const |
273 { | 273 { |
274 Vector<String> toReturn; | 274 Vector<String> toReturn; |
275 for (FormElementStateMap::const_iterator it = m_stateForNewFormElements.begi n(); it != m_stateForNewFormElements.end(); ++it) { | 275 for (const auto& formElementState : m_stateForNewFormElements) { |
276 const FormElementKey& key = it->key; | 276 const FormElementKey& key = formElementState.key; |
277 if (!equal(key.type(), "file", 4)) | 277 if (!equal(key.type(), "file", 4)) |
278 continue; | 278 continue; |
279 const Deque<FormControlState>& queue = it->value; | 279 const Deque<FormControlState>& queue = formElementState.value; |
280 for (Deque<FormControlState>::const_iterator queIterator = queue.begin() ; queIterator != queue.end(); ++queIterator) { | 280 for (const auto& queIterator : queue) { |
sof
2014/10/21 09:58:43
sp? "element" or "formControl" might be clearer.
riju_
2014/11/04 17:50:52
Done.
| |
281 const Vector<FileChooserFileInfo>& selectedFiles = HTMLInputElement: :filesFromFileInputFormControlState(*queIterator); | 281 const Vector<FileChooserFileInfo>& selectedFiles = HTMLInputElement: :filesFromFileInputFormControlState(queIterator); |
282 for (size_t i = 0; i < selectedFiles.size(); ++i) | 282 for (size_t i = 0; i < selectedFiles.size(); ++i) |
283 toReturn.append(selectedFiles[i].path); | 283 toReturn.append(selectedFiles[i].path); |
284 } | 284 } |
285 } | 285 } |
286 return toReturn; | 286 return toReturn; |
287 } | 287 } |
288 | 288 |
289 // ---------------------------------------------------------------------------- | 289 // ---------------------------------------------------------------------------- |
290 | 290 |
291 class FormKeyGenerator final : public NoBaseWillBeGarbageCollectedFinalized<Form KeyGenerator> { | 291 class FormKeyGenerator final : public NoBaseWillBeGarbageCollectedFinalized<Form KeyGenerator> { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 // attribute value of a form control. The following string literal should | 414 // attribute value of a form control. The following string literal should |
415 // contain some characters which are rarely used for name attribute values. | 415 // contain some characters which are rarely used for name attribute values. |
416 DEFINE_STATIC_LOCAL(String, signature, ("\n\r?% Blink serialized form state version 9 \n\r=&")); | 416 DEFINE_STATIC_LOCAL(String, signature, ("\n\r?% Blink serialized form state version 9 \n\r=&")); |
417 return signature; | 417 return signature; |
418 } | 418 } |
419 | 419 |
420 Vector<String> DocumentState::toStateVector() | 420 Vector<String> DocumentState::toStateVector() |
421 { | 421 { |
422 OwnPtrWillBeRawPtr<FormKeyGenerator> keyGenerator = FormKeyGenerator::create (); | 422 OwnPtrWillBeRawPtr<FormKeyGenerator> keyGenerator = FormKeyGenerator::create (); |
423 OwnPtr<SavedFormStateMap> stateMap = adoptPtr(new SavedFormStateMap); | 423 OwnPtr<SavedFormStateMap> stateMap = adoptPtr(new SavedFormStateMap); |
424 for (FormElementListHashSet::const_iterator it = m_formControls.begin(); it != m_formControls.end(); ++it) { | 424 for (const auto& it : m_formControls) { |
425 HTMLFormControlElementWithState* control = it->get(); | 425 HTMLFormControlElementWithState* control = it.get(); |
426 ASSERT(control->inDocument()); | 426 ASSERT(control->inDocument()); |
427 if (!control->shouldSaveAndRestoreFormControlState()) | 427 if (!control->shouldSaveAndRestoreFormControlState()) |
428 continue; | 428 continue; |
429 SavedFormStateMap::AddResult result = stateMap->add(keyGenerator->formKe y(*control), nullptr); | 429 SavedFormStateMap::AddResult result = stateMap->add(keyGenerator->formKe y(*control), nullptr); |
430 if (result.isNewEntry) | 430 if (result.isNewEntry) |
431 result.storedValue->value = SavedFormState::create(); | 431 result.storedValue->value = SavedFormState::create(); |
432 result.storedValue->value->appendControlState(control->name(), control-> type(), control->saveFormControlState()); | 432 result.storedValue->value->appendControlState(control->name(), control-> type(), control->saveFormControlState()); |
433 } | 433 } |
434 | 434 |
435 Vector<String> stateVector; | 435 Vector<String> stateVector; |
436 stateVector.reserveInitialCapacity(m_formControls.size() * 4); | 436 stateVector.reserveInitialCapacity(m_formControls.size() * 4); |
437 stateVector.append(formStateSignature()); | 437 stateVector.append(formStateSignature()); |
438 for (SavedFormStateMap::const_iterator it = stateMap->begin(); it != stateMa p->end(); ++it) { | 438 for (const auto& savedFormState : *stateMap) { |
439 stateVector.append(it->key); | 439 stateVector.append(savedFormState.key); |
440 it->value->serializeTo(stateVector); | 440 savedFormState.value->serializeTo(stateVector); |
441 } | 441 } |
442 bool hasOnlySignature = stateVector.size() == 1; | 442 bool hasOnlySignature = stateVector.size() == 1; |
443 if (hasOnlySignature) | 443 if (hasOnlySignature) |
444 stateVector.clear(); | 444 stateVector.clear(); |
445 return stateVector; | 445 return stateVector; |
446 } | 446 } |
447 | 447 |
448 // ---------------------------------------------------------------------------- | 448 // ---------------------------------------------------------------------------- |
449 | 449 |
450 FormController::FormController() | 450 FormController::FormController() |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
544 if (state.valueSize() > 0) | 544 if (state.valueSize() > 0) |
545 control->restoreFormControlState(state); | 545 control->restoreFormControlState(state); |
546 } | 546 } |
547 } | 547 } |
548 | 548 |
549 Vector<String> FormController::getReferencedFilePaths(const Vector<String>& stat eVector) | 549 Vector<String> FormController::getReferencedFilePaths(const Vector<String>& stat eVector) |
550 { | 550 { |
551 Vector<String> toReturn; | 551 Vector<String> toReturn; |
552 SavedFormStateMap map; | 552 SavedFormStateMap map; |
553 formStatesFromStateVector(stateVector, map); | 553 formStatesFromStateVector(stateVector, map); |
554 for (SavedFormStateMap::const_iterator it = map.begin(); it != map.end(); ++ it) | 554 for (const auto& savedFormState : map) |
555 toReturn.appendVector(it->value->getReferencedFilePaths()); | 555 toReturn.appendVector(savedFormState.value->getReferencedFilePaths()); |
556 return toReturn; | 556 return toReturn; |
557 } | 557 } |
558 | 558 |
559 void FormController::registerStatefulFormControl(HTMLFormControlElementWithState & control) | 559 void FormController::registerStatefulFormControl(HTMLFormControlElementWithState & control) |
560 { | 560 { |
561 m_documentState->addControl(&control); | 561 m_documentState->addControl(&control); |
562 } | 562 } |
563 | 563 |
564 void FormController::unregisterStatefulFormControl(HTMLFormControlElementWithSta te& control) | 564 void FormController::unregisterStatefulFormControl(HTMLFormControlElementWithSta te& control) |
565 { | 565 { |
566 m_documentState->removeControl(&control); | 566 m_documentState->removeControl(&control); |
567 } | 567 } |
568 | 568 |
569 } // namespace blink | 569 } // namespace blink |
OLD | NEW |