| 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 } | 287 } |
| 288 | 288 |
| 289 // ---------------------------------------------------------------------------- | 289 // ---------------------------------------------------------------------------- |
| 290 | 290 |
| 291 class FormKeyGenerator { | 291 class FormKeyGenerator { |
| 292 WTF_MAKE_NONCOPYABLE(FormKeyGenerator); | 292 WTF_MAKE_NONCOPYABLE(FormKeyGenerator); |
| 293 WTF_MAKE_FAST_ALLOCATED; | 293 WTF_MAKE_FAST_ALLOCATED; |
| 294 | 294 |
| 295 public: | 295 public: |
| 296 static PassOwnPtr<FormKeyGenerator> create() { return adoptPtr(new FormKeyGe
nerator); } | 296 static PassOwnPtr<FormKeyGenerator> create() { return adoptPtr(new FormKeyGe
nerator); } |
| 297 AtomicString formKey(const HTMLFormControlElementWithState&); | 297 const AtomicString& formKey(const HTMLFormControlElementWithState&); |
| 298 void willDeleteForm(HTMLFormElement*); | 298 void willDeleteForm(HTMLFormElement*); |
| 299 | 299 |
| 300 private: | 300 private: |
| 301 FormKeyGenerator() { } | 301 FormKeyGenerator() { } |
| 302 | 302 |
| 303 typedef HashMap<HTMLFormElement*, AtomicString> FormToKeyMap; | 303 typedef HashMap<HTMLFormElement*, AtomicString> FormToKeyMap; |
| 304 typedef HashMap<String, unsigned> FormSignatureToNextIndexMap; | 304 typedef HashMap<String, unsigned> FormSignatureToNextIndexMap; |
| 305 FormToKeyMap m_formToKeyMap; | 305 FormToKeyMap m_formToKeyMap; |
| 306 FormSignatureToNextIndexMap m_formSignatureToNextIndexMap; | 306 FormSignatureToNextIndexMap m_formSignatureToNextIndexMap; |
| 307 }; | 307 }; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 335 // as a session key. | 335 // as a session key. |
| 336 actionURL.setQuery(String()); | 336 actionURL.setQuery(String()); |
| 337 StringBuilder builder; | 337 StringBuilder builder; |
| 338 if (!actionURL.isEmpty()) | 338 if (!actionURL.isEmpty()) |
| 339 builder.append(actionURL.string()); | 339 builder.append(actionURL.string()); |
| 340 | 340 |
| 341 recordFormStructure(form, builder); | 341 recordFormStructure(form, builder); |
| 342 return builder.toString(); | 342 return builder.toString(); |
| 343 } | 343 } |
| 344 | 344 |
| 345 AtomicString FormKeyGenerator::formKey(const HTMLFormControlElementWithState& co
ntrol) | 345 const AtomicString& FormKeyGenerator::formKey(const HTMLFormControlElementWithSt
ate& control) |
| 346 { | 346 { |
| 347 HTMLFormElement* form = ownerFormForState(control); | 347 HTMLFormElement* form = ownerFormForState(control); |
| 348 if (!form) { | 348 if (!form) { |
| 349 DEFINE_STATIC_LOCAL(AtomicString, formKeyForNoOwner, ("No owner", Atomic
String::ConstructFromLiteral)); | 349 DEFINE_STATIC_LOCAL(const AtomicString, formKeyForNoOwner, ("No owner",
AtomicString::ConstructFromLiteral)); |
| 350 return formKeyForNoOwner; | 350 return formKeyForNoOwner; |
| 351 } | 351 } |
| 352 FormToKeyMap::const_iterator it = m_formToKeyMap.find(form); | 352 FormToKeyMap::const_iterator it = m_formToKeyMap.find(form); |
| 353 if (it != m_formToKeyMap.end()) | 353 if (it != m_formToKeyMap.end()) |
| 354 return it->value; | 354 return it->value; |
| 355 | 355 |
| 356 String signature = formSignature(*form); | 356 String signature = formSignature(*form); |
| 357 ASSERT(!signature.isNull()); | 357 ASSERT(!signature.isNull()); |
| 358 FormSignatureToNextIndexMap::AddResult result = m_formSignatureToNextIndexMa
p.add(signature, 0); | 358 FormSignatureToNextIndexMap::AddResult result = m_formSignatureToNextIndexMa
p.add(signature, 0); |
| 359 unsigned nextIndex = result.iterator->value++; | 359 unsigned nextIndex = result.iterator->value++; |
| 360 | 360 |
| 361 StringBuilder builder; | 361 StringBuilder formKeyBuilder; |
| 362 builder.append(signature); | 362 formKeyBuilder.append(signature); |
| 363 builder.appendLiteral(" #"); | 363 formKeyBuilder.appendLiteral(" #"); |
| 364 builder.appendNumber(nextIndex); | 364 formKeyBuilder.appendNumber(nextIndex); |
| 365 AtomicString formKey = builder.toAtomicString(); | 365 FormToKeyMap::AddResult addFormKeyresult = m_formToKeyMap.add(form, formKeyB
uilder.toAtomicString()); |
| 366 m_formToKeyMap.add(form, formKey); | 366 return addFormKeyresult.iterator->value; |
| 367 return formKey; | |
| 368 } | 367 } |
| 369 | 368 |
| 370 void FormKeyGenerator::willDeleteForm(HTMLFormElement* form) | 369 void FormKeyGenerator::willDeleteForm(HTMLFormElement* form) |
| 371 { | 370 { |
| 372 ASSERT(form); | 371 ASSERT(form); |
| 373 m_formToKeyMap.remove(form); | 372 m_formToKeyMap.remove(form); |
| 374 } | 373 } |
| 375 | 374 |
| 376 // ---------------------------------------------------------------------------- | 375 // ---------------------------------------------------------------------------- |
| 377 | 376 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 m_formElementsWithState.add(control); | 518 m_formElementsWithState.add(control); |
| 520 } | 519 } |
| 521 | 520 |
| 522 void FormController::unregisterFormElementWithState(HTMLFormControlElementWithSt
ate* control) | 521 void FormController::unregisterFormElementWithState(HTMLFormControlElementWithSt
ate* control) |
| 523 { | 522 { |
| 524 RELEASE_ASSERT(m_formElementsWithState.contains(control)); | 523 RELEASE_ASSERT(m_formElementsWithState.contains(control)); |
| 525 m_formElementsWithState.remove(control); | 524 m_formElementsWithState.remove(control); |
| 526 } | 525 } |
| 527 | 526 |
| 528 } // namespace WebCore | 527 } // namespace WebCore |
| OLD | NEW |