| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 { | 291 class FormKeyGenerator FINAL : public NoBaseWillBeGarbageCollectedFinalized<Form
KeyGenerator> { |
| 292 WTF_MAKE_NONCOPYABLE(FormKeyGenerator); | 292 WTF_MAKE_NONCOPYABLE(FormKeyGenerator); |
| 293 WTF_MAKE_FAST_ALLOCATED; | 293 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
| 294 | 294 |
| 295 public: | 295 public: |
| 296 static PassOwnPtr<FormKeyGenerator> create() { return adoptPtr(new FormKeyGe
nerator); } | 296 static PassOwnPtrWillBeRawPtr<FormKeyGenerator> create() { return adoptPtrWi
llBeNoop(new FormKeyGenerator); } |
| 297 void trace(Visitor* visitor) { visitor->trace(m_formToKeyMap); } |
| 297 const AtomicString& formKey(const HTMLFormControlElementWithState&); | 298 const AtomicString& formKey(const HTMLFormControlElementWithState&); |
| 298 void willDeleteForm(HTMLFormElement*); | 299 void willDeleteForm(HTMLFormElement*); |
| 299 | 300 |
| 300 private: | 301 private: |
| 301 FormKeyGenerator() { } | 302 FormKeyGenerator() { } |
| 302 | 303 |
| 303 typedef HashMap<HTMLFormElement*, AtomicString> FormToKeyMap; | 304 typedef WillBeHeapHashMap<RawPtrWillBeMember<HTMLFormElement>, AtomicString>
FormToKeyMap; |
| 304 typedef HashMap<String, unsigned> FormSignatureToNextIndexMap; | 305 typedef HashMap<String, unsigned> FormSignatureToNextIndexMap; |
| 305 FormToKeyMap m_formToKeyMap; | 306 FormToKeyMap m_formToKeyMap; |
| 306 FormSignatureToNextIndexMap m_formSignatureToNextIndexMap; | 307 FormSignatureToNextIndexMap m_formSignatureToNextIndexMap; |
| 307 }; | 308 }; |
| 308 | 309 |
| 309 static inline void recordFormStructure(const HTMLFormElement& form, StringBuilde
r& builder) | 310 static inline void recordFormStructure(const HTMLFormElement& form, StringBuilde
r& builder) |
| 310 { | 311 { |
| 311 // 2 is enough to distinguish forms in webkit.org/b/91209#c0 | 312 // 2 is enough to distinguish forms in webkit.org/b/91209#c0 |
| 312 const size_t namedControlsToBeRecorded = 2; | 313 const size_t namedControlsToBeRecorded = 2; |
| 313 const FormAssociatedElement::List& controls = form.associatedElements(); | 314 const FormAssociatedElement::List& controls = form.associatedElements(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 { | 405 { |
| 405 // In the legacy version of serialized state, the first item was a name | 406 // In the legacy version of serialized state, the first item was a name |
| 406 // attribute value of a form control. The following string literal should | 407 // attribute value of a form control. The following string literal should |
| 407 // contain some characters which are rarely used for name attribute values. | 408 // contain some characters which are rarely used for name attribute values. |
| 408 DEFINE_STATIC_LOCAL(String, signature, ("\n\r?% WebKit serialized form state
version 8 \n\r=&")); | 409 DEFINE_STATIC_LOCAL(String, signature, ("\n\r?% WebKit serialized form state
version 8 \n\r=&")); |
| 409 return signature; | 410 return signature; |
| 410 } | 411 } |
| 411 | 412 |
| 412 Vector<String> DocumentState::toStateVector() | 413 Vector<String> DocumentState::toStateVector() |
| 413 { | 414 { |
| 414 OwnPtr<FormKeyGenerator> keyGenerator = FormKeyGenerator::create(); | 415 OwnPtrWillBeRawPtr<FormKeyGenerator> keyGenerator = FormKeyGenerator::create
(); |
| 415 OwnPtr<SavedFormStateMap> stateMap = adoptPtr(new SavedFormStateMap); | 416 OwnPtr<SavedFormStateMap> stateMap = adoptPtr(new SavedFormStateMap); |
| 416 for (FormElementListHashSet::const_iterator it = m_formControls.begin(); it
!= m_formControls.end(); ++it) { | 417 for (FormElementListHashSet::const_iterator it = m_formControls.begin(); it
!= m_formControls.end(); ++it) { |
| 417 HTMLFormControlElementWithState* control = (*it).get(); | 418 HTMLFormControlElementWithState* control = (*it).get(); |
| 418 ASSERT(control->inDocument()); | 419 ASSERT(control->inDocument()); |
| 419 if (!control->shouldSaveAndRestoreFormControlState()) | 420 if (!control->shouldSaveAndRestoreFormControlState()) |
| 420 continue; | 421 continue; |
| 421 SavedFormStateMap::AddResult result = stateMap->add(keyGenerator->formKe
y(*control), nullptr); | 422 SavedFormStateMap::AddResult result = stateMap->add(keyGenerator->formKe
y(*control), nullptr); |
| 422 if (result.isNewEntry) | 423 if (result.isNewEntry) |
| 423 result.storedValue->value = SavedFormState::create(); | 424 result.storedValue->value = SavedFormState::create(); |
| 424 result.storedValue->value->appendControlState(control->name(), control->
type(), control->saveFormControlState()); | 425 result.storedValue->value->appendControlState(control->name(), control->
type(), control->saveFormControlState()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 444 { | 445 { |
| 445 } | 446 } |
| 446 | 447 |
| 447 FormController::~FormController() | 448 FormController::~FormController() |
| 448 { | 449 { |
| 449 } | 450 } |
| 450 | 451 |
| 451 void FormController::trace(Visitor* visitor) | 452 void FormController::trace(Visitor* visitor) |
| 452 { | 453 { |
| 453 visitor->trace(m_documentState); | 454 visitor->trace(m_documentState); |
| 455 visitor->trace(m_formKeyGenerator); |
| 454 } | 456 } |
| 455 | 457 |
| 456 DocumentState* FormController::formElementsState() const | 458 DocumentState* FormController::formElementsState() const |
| 457 { | 459 { |
| 458 return m_documentState.get(); | 460 return m_documentState.get(); |
| 459 } | 461 } |
| 460 | 462 |
| 461 void FormController::setStateForNewFormElements(const Vector<String>& stateVecto
r) | 463 void FormController::setStateForNewFormElements(const Vector<String>& stateVecto
r) |
| 462 { | 464 { |
| 463 formStatesFromStateVector(stateVector, m_savedFormStateMap); | 465 formStatesFromStateVector(stateVector, m_savedFormStateMap); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 { | 552 { |
| 551 m_documentState->addControl(&control); | 553 m_documentState->addControl(&control); |
| 552 } | 554 } |
| 553 | 555 |
| 554 void FormController::unregisterStatefulFormControl(HTMLFormControlElementWithSta
te& control) | 556 void FormController::unregisterStatefulFormControl(HTMLFormControlElementWithSta
te& control) |
| 555 { | 557 { |
| 556 m_documentState->removeControl(&control); | 558 m_documentState->removeControl(&control); |
| 557 } | 559 } |
| 558 | 560 |
| 559 } // namespace WebCore | 561 } // namespace WebCore |
| OLD | NEW |