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

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

Issue 1835773002: Rename AtomicString::string() to AtomicString::getString(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows Created 4 years, 8 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 bool DOMTokenList::contains(const AtomicString& token, ExceptionState& exception State) const 95 bool DOMTokenList::contains(const AtomicString& token, ExceptionState& exception State) const
96 { 96 {
97 if (!validateToken(token, exceptionState)) 97 if (!validateToken(token, exceptionState))
98 return false; 98 return false;
99 return containsInternal(token); 99 return containsInternal(token);
100 } 100 }
101 101
102 void DOMTokenList::add(const AtomicString& token, ExceptionState& exceptionState ) 102 void DOMTokenList::add(const AtomicString& token, ExceptionState& exceptionState )
103 { 103 {
104 Vector<String> tokens; 104 Vector<String> tokens;
105 tokens.append(token.string()); 105 tokens.append(token.getString());
106 add(tokens, exceptionState); 106 add(tokens, exceptionState);
107 } 107 }
108 108
109 // Optimally, this should take a Vector<AtomicString> const ref in argument but the 109 // Optimally, this should take a Vector<AtomicString> const ref in argument but the
110 // bindings generator does not handle that. 110 // bindings generator does not handle that.
111 void DOMTokenList::add(const Vector<String>& tokens, ExceptionState& exceptionSt ate) 111 void DOMTokenList::add(const Vector<String>& tokens, ExceptionState& exceptionSt ate)
112 { 112 {
113 Vector<String> filteredTokens; 113 Vector<String> filteredTokens;
114 filteredTokens.reserveCapacity(tokens.size()); 114 filteredTokens.reserveCapacity(tokens.size());
115 for (size_t i = 0; i < tokens.size(); ++i) { 115 for (size_t i = 0; i < tokens.size(); ++i) {
116 if (!validateToken(tokens[i], exceptionState)) 116 if (!validateToken(tokens[i], exceptionState))
117 return; 117 return;
118 if (containsInternal(AtomicString(tokens[i]))) 118 if (containsInternal(AtomicString(tokens[i])))
119 continue; 119 continue;
120 if (filteredTokens.contains(tokens[i])) 120 if (filteredTokens.contains(tokens[i]))
121 continue; 121 continue;
122 filteredTokens.append(tokens[i]); 122 filteredTokens.append(tokens[i]);
123 } 123 }
124 124
125 if (!filteredTokens.isEmpty()) 125 if (!filteredTokens.isEmpty())
126 setValue(addTokens(value(), filteredTokens)); 126 setValue(addTokens(value(), filteredTokens));
127 } 127 }
128 128
129 void DOMTokenList::remove(const AtomicString& token, ExceptionState& exceptionSt ate) 129 void DOMTokenList::remove(const AtomicString& token, ExceptionState& exceptionSt ate)
130 { 130 {
131 Vector<String> tokens; 131 Vector<String> tokens;
132 tokens.append(token.string()); 132 tokens.append(token.getString());
133 remove(tokens, exceptionState); 133 remove(tokens, exceptionState);
134 } 134 }
135 135
136 // Optimally, this should take a Vector<AtomicString> const ref in argument but the 136 // Optimally, this should take a Vector<AtomicString> const ref in argument but the
137 // bindings generator does not handle that. 137 // bindings generator does not handle that.
138 void DOMTokenList::remove(const Vector<String>& tokens, ExceptionState& exceptio nState) 138 void DOMTokenList::remove(const Vector<String>& tokens, ExceptionState& exceptio nState)
139 { 139 {
140 if (!validateTokens(tokens, exceptionState)) 140 if (!validateTokens(tokens, exceptionState))
141 return; 141 return;
142 142
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // Check using contains first since it uses AtomicString comparisons instead 196 // Check using contains first since it uses AtomicString comparisons instead
197 // of character by character testing. 197 // of character by character testing.
198 if (!containsInternal(token)) 198 if (!containsInternal(token))
199 return; 199 return;
200 setValue(removeToken(value(), token)); 200 setValue(removeToken(value(), token));
201 } 201 }
202 202
203 AtomicString DOMTokenList::addToken(const AtomicString& input, const AtomicStrin g& token) 203 AtomicString DOMTokenList::addToken(const AtomicString& input, const AtomicStrin g& token)
204 { 204 {
205 Vector<String> tokens; 205 Vector<String> tokens;
206 tokens.append(token.string()); 206 tokens.append(token.getString());
207 return addTokens(input, tokens); 207 return addTokens(input, tokens);
208 } 208 }
209 209
210 // This returns an AtomicString because it is always passed as argument to setVa lue() and setValue() 210 // This returns an AtomicString because it is always passed as argument to setVa lue() and setValue()
211 // takes an AtomicString in argument. 211 // takes an AtomicString in argument.
212 AtomicString DOMTokenList::addTokens(const AtomicString& input, const Vector<Str ing>& tokens) 212 AtomicString DOMTokenList::addTokens(const AtomicString& input, const Vector<Str ing>& tokens)
213 { 213 {
214 bool needsSpace = false; 214 bool needsSpace = false;
215 215
216 StringBuilder builder; 216 StringBuilder builder;
217 if (!input.isEmpty()) { 217 if (!input.isEmpty()) {
218 builder.append(input); 218 builder.append(input);
219 needsSpace = !isHTMLSpace<UChar>(input[input.length() - 1]); 219 needsSpace = !isHTMLSpace<UChar>(input[input.length() - 1]);
220 } 220 }
221 221
222 for (size_t i = 0; i < tokens.size(); ++i) { 222 for (size_t i = 0; i < tokens.size(); ++i) {
223 if (needsSpace) 223 if (needsSpace)
224 builder.append(' '); 224 builder.append(' ');
225 builder.append(tokens[i]); 225 builder.append(tokens[i]);
226 needsSpace = true; 226 needsSpace = true;
227 } 227 }
228 228
229 return builder.toAtomicString(); 229 return builder.toAtomicString();
230 } 230 }
231 231
232 AtomicString DOMTokenList::removeToken(const AtomicString& input, const AtomicSt ring& token) 232 AtomicString DOMTokenList::removeToken(const AtomicString& input, const AtomicSt ring& token)
233 { 233 {
234 Vector<String> tokens; 234 Vector<String> tokens;
235 tokens.append(token.string()); 235 tokens.append(token.getString());
236 return removeTokens(input, tokens); 236 return removeTokens(input, tokens);
237 } 237 }
238 238
239 // This returns an AtomicString because it is always passed as argument to setVa lue() and setValue() 239 // This returns an AtomicString because it is always passed as argument to setVa lue() and setValue()
240 // takes an AtomicString in argument. 240 // takes an AtomicString in argument.
241 AtomicString DOMTokenList::removeTokens(const AtomicString& input, const Vector< String>& tokens) 241 AtomicString DOMTokenList::removeTokens(const AtomicString& input, const Vector< String>& tokens)
242 { 242 {
243 // Algorithm defined at http://www.whatwg.org/specs/web-apps/current-work/mu ltipage/common-microsyntaxes.html#remove-a-token-from-a-string 243 // Algorithm defined at http://www.whatwg.org/specs/web-apps/current-work/mu ltipage/common-microsyntaxes.html#remove-a-token-from-a-string
244 // New spec is at https://dom.spec.whatwg.org/#remove-a-token-from-a-string 244 // New spec is at https://dom.spec.whatwg.org/#remove-a-token-from-a-string
245 245
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 306 }
307 307
308 const AtomicString DOMTokenList::item(unsigned index) const 308 const AtomicString DOMTokenList::item(unsigned index) const
309 { 309 {
310 if (index >= length()) 310 if (index >= length())
311 return AtomicString(); 311 return AtomicString();
312 return m_tokens[index]; 312 return m_tokens[index];
313 } 313 }
314 314
315 } // namespace blink 315 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp ('k') | third_party/WebKit/Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698