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

Side by Side Diff: Source/core/html/shadow/DateTimeNumericFieldElement.cpp

Issue 191293011: Value set in onblur should not keep element in focus (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Code review updates Created 6 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
« no previous file with comments | « Source/core/html/shadow/DateTimeNumericFieldElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 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 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 int DateTimeNumericFieldElement::defaultValueForStepDown() const 84 int DateTimeNumericFieldElement::defaultValueForStepDown() const
85 { 85 {
86 return m_range.maximum; 86 return m_range.maximum;
87 } 87 }
88 88
89 int DateTimeNumericFieldElement::defaultValueForStepUp() const 89 int DateTimeNumericFieldElement::defaultValueForStepUp() const
90 { 90 {
91 return m_range.minimum; 91 return m_range.minimum;
92 } 92 }
93 93
94 void DateTimeNumericFieldElement::didBlur() 94 void DateTimeNumericFieldElement::setFocus(bool value)
95 { 95 {
96 int value = typeAheadValue(); 96 if (!value) {
97 m_typeAheadBuffer.clear(); 97 int value = typeAheadValue();
98 if (value >= 0) 98 m_typeAheadBuffer.clear();
99 setValueAsInteger(value, DispatchEvent); 99 if (value >= 0)
100 DateTimeFieldElement::didBlur(); 100 setValueAsInteger(value, DispatchEvent);
101 }
102 DateTimeFieldElement::setFocus(value);
101 } 103 }
102 104
103 String DateTimeNumericFieldElement::formatValue(int value) const 105 String DateTimeNumericFieldElement::formatValue(int value) const
104 { 106 {
105 Locale& locale = localeForOwner(); 107 Locale& locale = localeForOwner();
106 if (m_hardLimits.maximum > 999) 108 if (m_hardLimits.maximum > 999)
107 return locale.convertToLocalizedNumber(String::format("%04d", value)); 109 return locale.convertToLocalizedNumber(String::format("%04d", value));
108 if (m_hardLimits.maximum > 99) 110 if (m_hardLimits.maximum > 99)
109 return locale.convertToLocalizedNumber(String::format("%03d", value)); 111 return locale.convertToLocalizedNumber(String::format("%03d", value));
110 return locale.convertToLocalizedNumber(String::format("%02d", value)); 112 return locale.convertToLocalizedNumber(String::format("%02d", value));
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 if (n >= 0) 237 if (n >= 0)
236 n = (n + m_step.step - 1) / m_step.step * m_step.step; 238 n = (n + m_step.step - 1) / m_step.step * m_step.step;
237 else 239 else
238 n = -(-n / m_step.step * m_step.step); 240 n = -(-n / m_step.step * m_step.step);
239 return n + m_step.stepBase; 241 return n + m_step.stepBase;
240 } 242 }
241 243
242 } // namespace WebCore 244 } // namespace WebCore
243 245
244 #endif 246 #endif
OLDNEW
« no previous file with comments | « Source/core/html/shadow/DateTimeNumericFieldElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698