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

Side by Side Diff: Source/core/html/forms/BaseDateAndTimeInputType.cpp

Issue 149413004: HTMLInputElement.valueAsNumber compliance (NaN handling.) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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/forms/BaseDateAndTimeInputType.h ('k') | Source/core/html/forms/InputType.cpp » ('j') | 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) 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 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 { 57 {
58 element().setValue(serializeWithMilliseconds(value)); 58 element().setValue(serializeWithMilliseconds(value));
59 } 59 }
60 60
61 double BaseDateAndTimeInputType::valueAsDouble() const 61 double BaseDateAndTimeInputType::valueAsDouble() const
62 { 62 {
63 const Decimal value = parseToNumber(element().value(), Decimal::nan()); 63 const Decimal value = parseToNumber(element().value(), Decimal::nan());
64 return value.isFinite() ? value.toDouble() : DateComponents::invalidMillisec onds(); 64 return value.isFinite() ? value.toDouble() : DateComponents::invalidMillisec onds();
65 } 65 }
66 66
67 void BaseDateAndTimeInputType::setValueAsDecimal(const Decimal& newValue, TextFi eldEventBehavior eventBehavior, ExceptionState&) const 67 void BaseDateAndTimeInputType::setValueAsDouble(double newValue, TextFieldEventB ehavior eventBehavior, ExceptionState& exceptionState) const
Mike West 2014/01/29 19:31:37 Why did this change from `Decimal` to `double`?
sof 2014/01/29 19:53:41 Good question, not sure I have a succinct answer,
68 { 68 {
69 element().setValue(serialize(newValue), eventBehavior); 69 setValueAsDecimal(Decimal::fromDouble(newValue), eventBehavior, exceptionSta te);
70 } 70 }
71 71
72 bool BaseDateAndTimeInputType::typeMismatchFor(const String& value) const 72 bool BaseDateAndTimeInputType::typeMismatchFor(const String& value) const
73 { 73 {
74 return !value.isEmpty() && !parseToDateComponents(value, 0); 74 return !value.isEmpty() && !parseToDateComponents(value, 0);
75 } 75 }
76 76
77 bool BaseDateAndTimeInputType::typeMismatch() const 77 bool BaseDateAndTimeInputType::typeMismatch() const
78 { 78 {
79 return typeMismatchFor(element().value()); 79 return typeMismatchFor(element().value());
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 { 184 {
185 return element().isRequired() && value.isEmpty(); 185 return element().isRequired() && value.isEmpty();
186 } 186 }
187 187
188 bool BaseDateAndTimeInputType::shouldShowFocusRingOnMouseFocus() const 188 bool BaseDateAndTimeInputType::shouldShowFocusRingOnMouseFocus() const
189 { 189 {
190 return true; 190 return true;
191 } 191 }
192 192
193 } // namespace WebCore 193 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/forms/BaseDateAndTimeInputType.h ('k') | Source/core/html/forms/InputType.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698