Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: Source/core/html/forms/FormController.cpp

Issue 138643003: Simpler return value of HashTable::add/HashMap:add and others (Closed)
Patch Set: Daily master update (now with base url?) Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 DEFINE_STATIC_LOCAL(const AtomicString, formKeyForNoOwner, ("No owner", AtomicString::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.storedValue->value++;
360 360
361 StringBuilder formKeyBuilder; 361 StringBuilder formKeyBuilder;
362 formKeyBuilder.append(signature); 362 formKeyBuilder.append(signature);
363 formKeyBuilder.appendLiteral(" #"); 363 formKeyBuilder.appendLiteral(" #");
364 formKeyBuilder.appendNumber(nextIndex); 364 formKeyBuilder.appendNumber(nextIndex);
365 FormToKeyMap::AddResult addFormKeyresult = m_formToKeyMap.add(form, formKeyB uilder.toAtomicString()); 365 FormToKeyMap::AddResult addFormKeyresult = m_formToKeyMap.add(form, formKeyB uilder.toAtomicString());
366 return addFormKeyresult.iterator->value; 366 return addFormKeyresult.storedValue->value;
367 } 367 }
368 368
369 void FormKeyGenerator::willDeleteForm(HTMLFormElement* form) 369 void FormKeyGenerator::willDeleteForm(HTMLFormElement* form)
370 { 370 {
371 ASSERT(form); 371 ASSERT(form);
372 m_formToKeyMap.remove(form); 372 m_formToKeyMap.remove(form);
373 } 373 }
374 374
375 // ---------------------------------------------------------------------------- 375 // ----------------------------------------------------------------------------
376 376
(...skipping 18 matching lines...) Expand all
395 { 395 {
396 OwnPtr<FormKeyGenerator> keyGenerator = FormKeyGenerator::create(); 396 OwnPtr<FormKeyGenerator> keyGenerator = FormKeyGenerator::create();
397 OwnPtr<SavedFormStateMap> stateMap = adoptPtr(new SavedFormStateMap); 397 OwnPtr<SavedFormStateMap> stateMap = adoptPtr(new SavedFormStateMap);
398 for (FormElementListHashSet::const_iterator it = controlList.begin(); it != controlList.end(); ++it) { 398 for (FormElementListHashSet::const_iterator it = controlList.begin(); it != controlList.end(); ++it) {
399 HTMLFormControlElementWithState* control = (*it).get(); 399 HTMLFormControlElementWithState* control = (*it).get();
400 ASSERT(control->inDocument()); 400 ASSERT(control->inDocument());
401 if (!control->shouldSaveAndRestoreFormControlState()) 401 if (!control->shouldSaveAndRestoreFormControlState())
402 continue; 402 continue;
403 SavedFormStateMap::AddResult result = stateMap->add(keyGenerator->formKe y(*control), nullptr); 403 SavedFormStateMap::AddResult result = stateMap->add(keyGenerator->formKe y(*control), nullptr);
404 if (result.isNewEntry) 404 if (result.isNewEntry)
405 result.iterator->value = SavedFormState::create(); 405 result.storedValue->value = SavedFormState::create();
406 result.iterator->value->appendControlState(control->name(), control->typ e(), control->saveFormControlState()); 406 result.storedValue->value->appendControlState(control->name(), control-> type(), control->saveFormControlState());
407 } 407 }
408 return stateMap.release(); 408 return stateMap.release();
409 } 409 }
410 410
411 Vector<String> FormController::formElementsState() const 411 Vector<String> FormController::formElementsState() const
412 { 412 {
413 OwnPtr<SavedFormStateMap> stateMap = createSavedFormStateMap(m_formControls) ; 413 OwnPtr<SavedFormStateMap> stateMap = createSavedFormStateMap(m_formControls) ;
414 Vector<String> stateVector; 414 Vector<String> stateVector;
415 stateVector.reserveInitialCapacity(m_formControls.size() * 4); 415 stateVector.reserveInitialCapacity(m_formControls.size() * 4);
416 stateVector.append(formStateSignature()); 416 stateVector.append(formStateSignature());
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 m_formControls.add(&control); 518 m_formControls.add(&control);
519 } 519 }
520 520
521 void FormController::unregisterStatefulFormControl(HTMLFormControlElementWithSta te& control) 521 void FormController::unregisterStatefulFormControl(HTMLFormControlElementWithSta te& control)
522 { 522 {
523 RELEASE_ASSERT(m_formControls.contains(&control)); 523 RELEASE_ASSERT(m_formControls.contains(&control));
524 m_formControls.remove(&control); 524 m_formControls.remove(&control);
525 } 525 }
526 526
527 } // namespace WebCore 527 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/forms/CheckedRadioButtons.cpp ('k') | Source/core/inspector/AsyncCallStackTracker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698