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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 state.m_values.reserveCapacity(valueSize); | 75 state.m_values.reserveCapacity(valueSize); |
76 for (size_t i = 0; i < valueSize; ++i) | 76 for (size_t i = 0; i < valueSize; ++i) |
77 state.append(stateVector[index++]); | 77 state.append(stateVector[index++]); |
78 return state; | 78 return state; |
79 } | 79 } |
80 | 80 |
81 // ---------------------------------------------------------------------------- | 81 // ---------------------------------------------------------------------------- |
82 | 82 |
83 class FormElementKey { | 83 class FormElementKey { |
84 public: | 84 public: |
85 FormElementKey(AtomicStringImpl* = 0, AtomicStringImpl* = 0); | 85 FormElementKey(StringImpl* = 0, StringImpl* = 0); |
86 ~FormElementKey(); | 86 ~FormElementKey(); |
87 FormElementKey(const FormElementKey&); | 87 FormElementKey(const FormElementKey&); |
88 FormElementKey& operator=(const FormElementKey&); | 88 FormElementKey& operator=(const FormElementKey&); |
89 | 89 |
90 AtomicStringImpl* name() const { return m_name; } | 90 StringImpl* name() const { return m_name; } |
91 AtomicStringImpl* type() const { return m_type; } | 91 StringImpl* type() const { return m_type; } |
92 | 92 |
93 // Hash table deleted values, which are only constructed and never copied or
destroyed. | 93 // Hash table deleted values, which are only constructed and never copied or
destroyed. |
94 FormElementKey(WTF::HashTableDeletedValueType) : m_name(hashTableDeletedValu
e()) { } | 94 FormElementKey(WTF::HashTableDeletedValueType) : m_name(hashTableDeletedValu
e()) { } |
95 bool isHashTableDeletedValue() const { return m_name == hashTableDeletedValu
e(); } | 95 bool isHashTableDeletedValue() const { return m_name == hashTableDeletedValu
e(); } |
96 | 96 |
97 private: | 97 private: |
98 void ref() const; | 98 void ref() const; |
99 void deref() const; | 99 void deref() const; |
100 | 100 |
101 static AtomicStringImpl* hashTableDeletedValue() { return reinterpret_cast<A
tomicStringImpl*>(-1); } | 101 static StringImpl* hashTableDeletedValue() { return reinterpret_cast<StringI
mpl*>(-1); } |
102 | 102 |
103 AtomicStringImpl* m_name; | 103 StringImpl* m_name; |
104 AtomicStringImpl* m_type; | 104 StringImpl* m_type; |
105 }; | 105 }; |
106 | 106 |
107 FormElementKey::FormElementKey(AtomicStringImpl* name, AtomicStringImpl* type) | 107 FormElementKey::FormElementKey(StringImpl* name, StringImpl* type) |
108 : m_name(name) | 108 : m_name(name) |
109 , m_type(type) | 109 , m_type(type) |
110 { | 110 { |
111 ref(); | 111 ref(); |
112 } | 112 } |
113 | 113 |
114 FormElementKey::~FormElementKey() | 114 FormElementKey::~FormElementKey() |
115 { | 115 { |
116 deref(); | 116 deref(); |
117 } | 117 } |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_formElementsW
ithState); | 413 OwnPtr<SavedFormStateMap> stateMap = createSavedFormStateMap(m_formElementsW
ithState); |
414 Vector<String> stateVector; | 414 Vector<String> stateVector; |
415 stateVector.reserveInitialCapacity(m_formElementsWithState.size() * 4); | 415 stateVector.reserveInitialCapacity(m_formElementsWithState.size() * 4); |
416 stateVector.append(formStateSignature()); | 416 stateVector.append(formStateSignature()); |
417 for (SavedFormStateMap::const_iterator it = stateMap->begin(); it != stateMa
p->end(); ++it) { | 417 for (SavedFormStateMap::const_iterator it = stateMap->begin(); it != stateMa
p->end(); ++it) { |
418 stateVector.append(it->key.get()); | 418 stateVector.append(it->key); |
419 it->value->serializeTo(stateVector); | 419 it->value->serializeTo(stateVector); |
420 } | 420 } |
421 bool hasOnlySignature = stateVector.size() == 1; | 421 bool hasOnlySignature = stateVector.size() == 1; |
422 if (hasOnlySignature) | 422 if (hasOnlySignature) |
423 stateVector.clear(); | 423 stateVector.clear(); |
424 return stateVector; | 424 return stateVector; |
425 } | 425 } |
426 | 426 |
427 void FormController::setStateForNewFormElements(const Vector<String>& stateVecto
r) | 427 void FormController::setStateForNewFormElements(const Vector<String>& stateVecto
r) |
428 { | 428 { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 m_formElementsWithState.add(control); | 518 m_formElementsWithState.add(control); |
519 } | 519 } |
520 | 520 |
521 void FormController::unregisterFormElementWithState(HTMLFormControlElementWithSt
ate* control) | 521 void FormController::unregisterFormElementWithState(HTMLFormControlElementWithSt
ate* control) |
522 { | 522 { |
523 RELEASE_ASSERT(m_formElementsWithState.contains(control)); | 523 RELEASE_ASSERT(m_formElementsWithState.contains(control)); |
524 m_formElementsWithState.remove(control); | 524 m_formElementsWithState.remove(control); |
525 } | 525 } |
526 | 526 |
527 } // namespace WebCore | 527 } // namespace WebCore |
OLD | NEW |