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

Side by Side Diff: third_party/WebKit/Source/platform/text/LocaleICU.cpp

Issue 1983793002: Remove OwnPtr::release() calls in platform/ (part 2). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add one more file. Created 4 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) 2011,2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011,2012 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 status = U_ZERO_ERROR; 206 status = U_ZERO_ERROR;
207 if (isStandAloneMonth) { 207 if (isStandAloneMonth) {
208 udat_format(dateFormat, kEpoch + i * kMonth, buffer.characters(), le ngth, 0, &status); 208 udat_format(dateFormat, kEpoch + i * kMonth, buffer.characters(), le ngth, 0, &status);
209 } else { 209 } else {
210 udat_getSymbols(dateFormat, type, startIndex + i, buffer.characters( ), length, &status); 210 udat_getSymbols(dateFormat, type, startIndex + i, buffer.characters( ), length, &status);
211 } 211 }
212 if (U_FAILURE(status)) 212 if (U_FAILURE(status))
213 return PassOwnPtr<Vector<String>>(); 213 return PassOwnPtr<Vector<String>>();
214 labels->append(String::adopt(buffer)); 214 labels->append(String::adopt(buffer));
215 } 215 }
216 return labels.release(); 216 return labels;
217 } 217 }
218 218
219 static PassOwnPtr<Vector<String>> createFallbackWeekDayShortLabels() 219 static PassOwnPtr<Vector<String>> createFallbackWeekDayShortLabels()
220 { 220 {
221 OwnPtr<Vector<String>> labels = adoptPtr(new Vector<String>()); 221 OwnPtr<Vector<String>> labels = adoptPtr(new Vector<String>());
222 labels->reserveCapacity(7); 222 labels->reserveCapacity(7);
223 labels->append("Sun"); 223 labels->append("Sun");
224 labels->append("Mon"); 224 labels->append("Mon");
225 labels->append("Tue"); 225 labels->append("Tue");
226 labels->append("Wed"); 226 labels->append("Wed");
227 labels->append("Thu"); 227 labels->append("Thu");
228 labels->append("Fri"); 228 labels->append("Fri");
229 labels->append("Sat"); 229 labels->append("Sat");
230 return labels.release(); 230 return labels;
231 } 231 }
232 232
233 void LocaleICU::initializeCalendar() 233 void LocaleICU::initializeCalendar()
234 { 234 {
235 if (m_weekDayShortLabels) 235 if (m_weekDayShortLabels)
236 return; 236 return;
237 237
238 if (!initializeShortDateFormat()) { 238 if (!initializeShortDateFormat()) {
239 m_firstDayOfWeek = 0; 239 m_firstDayOfWeek = 0;
240 m_weekDayShortLabels = createFallbackWeekDayShortLabels(); 240 m_weekDayShortLabels = createFallbackWeekDayShortLabels();
241 return; 241 return;
242 } 242 }
243 m_firstDayOfWeek = ucal_getAttribute(udat_getCalendar(m_shortDateFormat), UC AL_FIRST_DAY_OF_WEEK) - UCAL_SUNDAY; 243 m_firstDayOfWeek = ucal_getAttribute(udat_getCalendar(m_shortDateFormat), UC AL_FIRST_DAY_OF_WEEK) - UCAL_SUNDAY;
244 244
245 m_weekDayShortLabels = createLabelVector(m_shortDateFormat, UDAT_SHORT_WEEKD AYS, UCAL_SUNDAY, 7); 245 m_weekDayShortLabels = createLabelVector(m_shortDateFormat, UDAT_SHORT_WEEKD AYS, UCAL_SUNDAY, 7);
246 if (!m_weekDayShortLabels) 246 if (!m_weekDayShortLabels)
247 m_weekDayShortLabels = createFallbackWeekDayShortLabels(); 247 m_weekDayShortLabels = createFallbackWeekDayShortLabels();
248 } 248 }
249 249
250 static PassOwnPtr<Vector<String>> createFallbackMonthLabels() 250 static PassOwnPtr<Vector<String>> createFallbackMonthLabels()
251 { 251 {
252 OwnPtr<Vector<String>> labels = adoptPtr(new Vector<String>()); 252 OwnPtr<Vector<String>> labels = adoptPtr(new Vector<String>());
253 labels->reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthFullName)); 253 labels->reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthFullName));
254 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthFullName); ++i) 254 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthFullName); ++i)
255 labels->append(WTF::monthFullName[i]); 255 labels->append(WTF::monthFullName[i]);
256 return labels.release(); 256 return labels;
257 } 257 }
258 258
259 const Vector<String>& LocaleICU::monthLabels() 259 const Vector<String>& LocaleICU::monthLabels()
260 { 260 {
261 if (m_monthLabels) 261 if (m_monthLabels)
262 return *m_monthLabels; 262 return *m_monthLabels;
263 if (initializeShortDateFormat()) { 263 if (initializeShortDateFormat()) {
264 m_monthLabels = createLabelVector(m_shortDateFormat, UDAT_MONTHS, UCAL_J ANUARY, 12); 264 m_monthLabels = createLabelVector(m_shortDateFormat, UDAT_MONTHS, UCAL_J ANUARY, 12);
265 if (m_monthLabels) 265 if (m_monthLabels)
266 return *m_monthLabels; 266 return *m_monthLabels;
(...skipping 19 matching lines...) Expand all
286 UErrorCode status = U_ZERO_ERROR; 286 UErrorCode status = U_ZERO_ERROR;
287 return uloc_getCharacterOrientation(m_locale.data(), &status) == ULOC_LAYOUT _RTL; 287 return uloc_getCharacterOrientation(m_locale.data(), &status) == ULOC_LAYOUT _RTL;
288 } 288 }
289 289
290 static PassOwnPtr<Vector<String>> createFallbackAMPMLabels() 290 static PassOwnPtr<Vector<String>> createFallbackAMPMLabels()
291 { 291 {
292 OwnPtr<Vector<String>> labels = adoptPtr(new Vector<String>()); 292 OwnPtr<Vector<String>> labels = adoptPtr(new Vector<String>());
293 labels->reserveCapacity(2); 293 labels->reserveCapacity(2);
294 labels->append("AM"); 294 labels->append("AM");
295 labels->append("PM"); 295 labels->append("PM");
296 return labels.release(); 296 return labels;
297 } 297 }
298 298
299 void LocaleICU::initializeDateTimeFormat() 299 void LocaleICU::initializeDateTimeFormat()
300 { 300 {
301 if (m_didCreateTimeFormat) 301 if (m_didCreateTimeFormat)
302 return; 302 return;
303 303
304 // We assume ICU medium time pattern and short time pattern are compatible 304 // We assume ICU medium time pattern and short time pattern are compatible
305 // with LDML, because ICU specific pattern character "V" doesn't appear 305 // with LDML, because ICU specific pattern character "V" doesn't appear
306 // in both medium and short time pattern. 306 // in both medium and short time pattern.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } 451 }
452 452
453 const Vector<String>& LocaleICU::timeAMPMLabels() 453 const Vector<String>& LocaleICU::timeAMPMLabels()
454 { 454 {
455 initializeDateTimeFormat(); 455 initializeDateTimeFormat();
456 return m_timeAMPMLabels; 456 return m_timeAMPMLabels;
457 } 457 }
458 458
459 } // namespace blink 459 } // namespace blink
460 460
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698