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

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

Issue 52553008: Eliminate the CALENDAR_PICKER compile time flag as only android uses this flag and the web facing p… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Fix winbot by eliminating last checks for CALENDAR_PICKER Created 7 years, 1 month 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 { 48 {
49 return LocaleICU::create(locale.string().utf8().data()); 49 return LocaleICU::create(locale.string().utf8().data());
50 } 50 }
51 51
52 LocaleICU::LocaleICU(const char* locale) 52 LocaleICU::LocaleICU(const char* locale)
53 : m_locale(locale) 53 : m_locale(locale)
54 , m_numberFormat(0) 54 , m_numberFormat(0)
55 , m_shortDateFormat(0) 55 , m_shortDateFormat(0)
56 , m_didCreateDecimalFormat(false) 56 , m_didCreateDecimalFormat(false)
57 , m_didCreateShortDateFormat(false) 57 , m_didCreateShortDateFormat(false)
58 #if ENABLE(CALENDAR_PICKER)
59 , m_firstDayOfWeek(0) 58 , m_firstDayOfWeek(0)
60 #endif
61 , m_mediumTimeFormat(0) 59 , m_mediumTimeFormat(0)
62 , m_shortTimeFormat(0) 60 , m_shortTimeFormat(0)
63 , m_didCreateTimeFormat(false) 61 , m_didCreateTimeFormat(false)
64 { 62 {
65 } 63 }
66 64
67 LocaleICU::~LocaleICU() 65 LocaleICU::~LocaleICU()
68 { 66 {
69 unum_close(m_numberFormat); 67 unum_close(m_numberFormat);
70 udat_close(m_shortDateFormat); 68 udat_close(m_shortDateFormat);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 StringBuffer<UChar> buffer(length); 183 StringBuffer<UChar> buffer(length);
186 status = U_ZERO_ERROR; 184 status = U_ZERO_ERROR;
187 udat_getSymbols(dateFormat, type, startIndex + i, buffer.characters(), l ength, &status); 185 udat_getSymbols(dateFormat, type, startIndex + i, buffer.characters(), l ength, &status);
188 if (U_FAILURE(status)) 186 if (U_FAILURE(status))
189 return PassOwnPtr<Vector<String> >(); 187 return PassOwnPtr<Vector<String> >();
190 labels->append(String::adopt(buffer)); 188 labels->append(String::adopt(buffer));
191 } 189 }
192 return labels.release(); 190 return labels.release();
193 } 191 }
194 192
195 #if ENABLE(CALENDAR_PICKER)
196 static PassOwnPtr<Vector<String> > createFallbackWeekDayShortLabels() 193 static PassOwnPtr<Vector<String> > createFallbackWeekDayShortLabels()
197 { 194 {
198 OwnPtr<Vector<String> > labels = adoptPtr(new Vector<String>()); 195 OwnPtr<Vector<String> > labels = adoptPtr(new Vector<String>());
199 labels->reserveCapacity(7); 196 labels->reserveCapacity(7);
200 labels->append("Sun"); 197 labels->append("Sun");
201 labels->append("Mon"); 198 labels->append("Mon");
202 labels->append("Tue"); 199 labels->append("Tue");
203 labels->append("Wed"); 200 labels->append("Wed");
204 labels->append("Thu"); 201 labels->append("Thu");
205 labels->append("Fri"); 202 labels->append("Fri");
(...skipping 10 matching lines...) Expand all
216 m_firstDayOfWeek = 0; 213 m_firstDayOfWeek = 0;
217 m_weekDayShortLabels = createFallbackWeekDayShortLabels(); 214 m_weekDayShortLabels = createFallbackWeekDayShortLabels();
218 return; 215 return;
219 } 216 }
220 m_firstDayOfWeek = ucal_getAttribute(udat_getCalendar(m_shortDateFormat), UC AL_FIRST_DAY_OF_WEEK) - UCAL_SUNDAY; 217 m_firstDayOfWeek = ucal_getAttribute(udat_getCalendar(m_shortDateFormat), UC AL_FIRST_DAY_OF_WEEK) - UCAL_SUNDAY;
221 218
222 m_weekDayShortLabels = createLabelVector(m_shortDateFormat, UDAT_SHORT_WEEKD AYS, UCAL_SUNDAY, 7); 219 m_weekDayShortLabels = createLabelVector(m_shortDateFormat, UDAT_SHORT_WEEKD AYS, UCAL_SUNDAY, 7);
223 if (!m_weekDayShortLabels) 220 if (!m_weekDayShortLabels)
224 m_weekDayShortLabels = createFallbackWeekDayShortLabels(); 221 m_weekDayShortLabels = createFallbackWeekDayShortLabels();
225 } 222 }
226 #endif
227 223
228 static PassOwnPtr<Vector<String> > createFallbackMonthLabels() 224 static PassOwnPtr<Vector<String> > createFallbackMonthLabels()
229 { 225 {
230 OwnPtr<Vector<String> > labels = adoptPtr(new Vector<String>()); 226 OwnPtr<Vector<String> > labels = adoptPtr(new Vector<String>());
231 labels->reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthFullName)); 227 labels->reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthFullName));
232 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthFullName); ++i) 228 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthFullName); ++i)
233 labels->append(WTF::monthFullName[i]); 229 labels->append(WTF::monthFullName[i]);
234 return labels.release(); 230 return labels.release();
235 } 231 }
236 232
237 const Vector<String>& LocaleICU::monthLabels() 233 const Vector<String>& LocaleICU::monthLabels()
238 { 234 {
239 if (m_monthLabels) 235 if (m_monthLabels)
240 return *m_monthLabels; 236 return *m_monthLabels;
241 if (initializeShortDateFormat()) { 237 if (initializeShortDateFormat()) {
242 m_monthLabels = createLabelVector(m_shortDateFormat, UDAT_MONTHS, UCAL_J ANUARY, 12); 238 m_monthLabels = createLabelVector(m_shortDateFormat, UDAT_MONTHS, UCAL_J ANUARY, 12);
243 if (m_monthLabels) 239 if (m_monthLabels)
244 return *m_monthLabels; 240 return *m_monthLabels;
245 } 241 }
246 m_monthLabels = createFallbackMonthLabels(); 242 m_monthLabels = createFallbackMonthLabels();
247 return *m_monthLabels; 243 return *m_monthLabels;
248 } 244 }
249 245
250 #if ENABLE(CALENDAR_PICKER)
251 const Vector<String>& LocaleICU::weekDayShortLabels() 246 const Vector<String>& LocaleICU::weekDayShortLabels()
252 { 247 {
253 initializeCalendar(); 248 initializeCalendar();
254 return *m_weekDayShortLabels; 249 return *m_weekDayShortLabels;
255 } 250 }
256 251
257 unsigned LocaleICU::firstDayOfWeek() 252 unsigned LocaleICU::firstDayOfWeek()
258 { 253 {
259 initializeCalendar(); 254 initializeCalendar();
260 return m_firstDayOfWeek; 255 return m_firstDayOfWeek;
261 } 256 }
262 257
263 bool LocaleICU::isRTL() 258 bool LocaleICU::isRTL()
264 { 259 {
265 UErrorCode status = U_ZERO_ERROR; 260 UErrorCode status = U_ZERO_ERROR;
266 return uloc_getCharacterOrientation(m_locale.data(), &status) == ULOC_LAYOUT _RTL; 261 return uloc_getCharacterOrientation(m_locale.data(), &status) == ULOC_LAYOUT _RTL;
267 } 262 }
268 #endif
269 263
270 static PassOwnPtr<Vector<String> > createFallbackAMPMLabels() 264 static PassOwnPtr<Vector<String> > createFallbackAMPMLabels()
271 { 265 {
272 OwnPtr<Vector<String> > labels = adoptPtr(new Vector<String>()); 266 OwnPtr<Vector<String> > labels = adoptPtr(new Vector<String>());
273 labels->reserveCapacity(2); 267 labels->reserveCapacity(2);
274 labels->append("AM"); 268 labels->append("AM");
275 labels->append("PM"); 269 labels->append("PM");
276 return labels.release(); 270 return labels.release();
277 } 271 }
278 272
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 419 }
426 420
427 const Vector<String>& LocaleICU::timeAMPMLabels() 421 const Vector<String>& LocaleICU::timeAMPMLabels()
428 { 422 {
429 initializeDateTimeFormat(); 423 initializeDateTimeFormat();
430 return m_timeAMPMLabels; 424 return m_timeAMPMLabels;
431 } 425 }
432 426
433 } // namespace WebCore 427 } // namespace WebCore
434 428
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698