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

Side by Side Diff: third_party/WebKit/Source/core/dom/SpaceSplitString.cpp

Issue 2895903002: DOMTokenList: Update serialization algorithm on add()/remove() (Closed)
Patch Set: Apply review comments Created 3 years, 7 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) 2007 David Smith (catfish.man@gmail.com) 2 * Copyright (C) 2007 David Smith (catfish.man@gmail.com)
3 * Copyright (C) 2007, 2008, 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2007, 2008, 2011, 2012 Apple 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 vector_.erase(index); 109 vector_.erase(index);
110 } 110 }
111 111
112 void SpaceSplitString::Add(const AtomicString& string) { 112 void SpaceSplitString::Add(const AtomicString& string) {
113 // FIXME: add() does not allow duplicates but createVector() does. 113 // FIXME: add() does not allow duplicates but createVector() does.
114 if (Contains(string)) 114 if (Contains(string))
115 return; 115 return;
116 EnsureUnique(); 116 EnsureUnique();
117 if (data_) 117 if (data_)
118 data_->Add(string); 118 data_->Add(string);
119 else
120 data_ = Data::Create(string);
119 } 121 }
120 122
121 bool SpaceSplitString::Remove(const AtomicString& string) { 123 bool SpaceSplitString::Remove(const AtomicString& string) {
122 if (!data_) 124 if (!data_)
123 return false; 125 return false;
124 unsigned i = 0; 126 unsigned i = 0;
125 bool changed = false; 127 bool changed = false;
126 while (i < data_->size()) { 128 while (i < data_->size()) {
127 if ((*data_)[i] == string) { 129 if ((*data_)[i] == string) {
128 if (!changed) 130 if (!changed)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 CreateVector(string); 185 CreateVector(string);
184 } 186 }
185 187
186 SpaceSplitString::Data::Data(const SpaceSplitString::Data& other) 188 SpaceSplitString::Data::Data(const SpaceSplitString::Data& other)
187 : RefCounted<Data>(), vector_(other.vector_) { 189 : RefCounted<Data>(), vector_(other.vector_) {
188 // Note that we don't copy m_keyString to indicate to the destructor that 190 // Note that we don't copy m_keyString to indicate to the destructor that
189 // there's nothing to be removed from the sharedDataMap(). 191 // there's nothing to be removed from the sharedDataMap().
190 } 192 }
191 193
192 } // namespace blink 194 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMTokenList.cpp ('k') | third_party/WebKit/Source/core/html/ClassList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698