Changeset 52434 in webkit
- Timestamp:
- Dec 20, 2009 10:20:29 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r52419 r52434 1 2009-12-20 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 A test for Date binding. 6 https://bugs.webkit.org/show_bug.cgi?id=32698 7 8 * fast/forms/input-valueasdate-expected.txt: Added. 9 * fast/forms/input-valueasdate.html: Added. 10 * fast/forms/script-tests/input-valueasdate.js: Added. 11 1 12 2009-12-20 Alejandro G. Castro <alex@igalia.com> 2 13 -
trunk/WebCore/ChangeLog
r52432 r52434 1 2009-12-20 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Add support for JavaScriptCore Date binding. 6 https://bugs.webkit.org/show_bug.cgi?id=32698 7 8 This is needed for HTMLInputElement::valueAsDate and 9 HTMLTimeElement::valueAsDate. 10 11 A Date instance is mapped to a double value in C++. 12 - If null or undefined is set to a JavaScript property, C++ setter 13 function receives NaN. 14 - If a getter C++ function returns NaN or infinity, a JavaScript 15 property returns null. 16 17 Test: fast/forms/input-valueasdate.html 18 19 * bindings/js/JSDOMBinding.cpp: 20 (WebCore::jsDateOrNull): Implement the above. 21 (WebCore::valueToDate): ditto. 22 * bindings/js/JSDOMBinding.h: Declare them. 23 * bindings/scripts/CodeGeneratorJS.pm: Produce jsDateOrNull() or 24 valueToDate() for Date type. 25 * html/HTMLInputElement.cpp: 26 (WebCore::HTMLInputElement::valueAsDate): Temporal implementation. 27 (WebCore::HTMLInputElement::setValueAsDate): ditto. 28 * html/HTMLInputElement.h: 29 * html/HTMLInputElement.idl: Declare valueAsDate. 30 1 31 2009-12-20 Kent Tamura <tkent@chromium.org> 2 32 -
trunk/WebCore/bindings/js/JSDOMBinding.cpp
r52082 r52434 50 50 #include "Settings.h" 51 51 #include "XMLHttpRequestException.h" 52 #include <runtime/DateInstance.h> 52 53 #include <runtime/Error.h> 53 54 #include <runtime/JSFunction.h> 54 55 #include <runtime/PrototypeFunction.h> 56 #include <wtf/MathExtras.h> 55 57 #include <wtf/StdLibExtras.h> 56 58 … … 597 599 } 598 600 601 JSValue jsDateOrNull(ExecState* exec, double value) 602 { 603 if (!isfinite(value)) 604 return jsNull(); 605 return new (exec) DateInstance(exec, value); 606 } 607 608 double valueToDate(ExecState* exec, JSValue value) 609 { 610 if (value.isNumber()) 611 return value.uncheckedGetNumber(); 612 if (!value.inherits(&DateInstance::info)) 613 return std::numeric_limits<double>::quiet_NaN(); 614 return static_cast<DateInstance*>(value.toObject(exec))->internalNumber(); 615 } 616 599 617 void reportException(ExecState* exec, JSValue exception) 600 618 { -
trunk/WebCore/bindings/js/JSDOMBinding.h
r52281 r52434 357 357 JSC::UString valueToStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null or undefined 358 358 359 // Returns a Date instance for the specified value, or null if the value is NaN or infinity. 360 JSC::JSValue jsDateOrNull(JSC::ExecState*, double); 361 // NaN if the value can't be converted to a date. 362 double valueToDate(JSC::ExecState*, JSC::JSValue); 363 359 364 // FIXME: These are a stop-gap until all toJS calls can be converted to pass a globalObject 360 365 template <typename T> -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r52373 r52434 188 188 if ($codeGenerator->IsPrimitiveType($type) or AvoidInclusionOfType($type) 189 189 or $type eq "DOMString" or $type eq "DOMObject" or $type eq "Array") { 190 } elsif ($type eq "Date") { 191 $implIncludes{"<runtime/DateInstance.h>"} = 1; 190 192 } elsif ($type =~ /SVGPathSeg/) { 191 193 $joinedName = $type; … … 1864 1866 return "$value.toInt32(exec)" if $type eq "unsigned long" or $type eq "long" or $type eq "unsigned short"; 1865 1867 1868 return "valueToDate(exec, $value)" if $type eq "Date"; 1866 1869 return "static_cast<Range::CompareHow>($value.toInt32(exec))" if $type eq "CompareHow"; 1867 1870 return "static_cast<SVGPaint::SVGPaintType>($value.toInt32(exec))" if $type eq "SVGPaintType"; … … 1988 1991 $implIncludes{"$type.h"} = 1; 1989 1992 return "$value->deserialize(exec)"; 1993 } elsif ($type eq "Date") { 1994 $implIncludes{"<runtime/DateInstance.h>"} = 1; 1995 return "jsDateOrNull(exec, $value)"; 1990 1996 } else { 1991 1997 # Default, include header with same name. -
trunk/WebCore/html/HTMLInputElement.cpp
r52302 r52434 1373 1373 InputElement::notifyFormStateChanged(this); 1374 1374 updateValidity(); 1375 } 1376 1377 double HTMLInputElement::valueAsDate() const 1378 { 1379 // FIXME: This is a temporary implementation to check Date binding. 1380 if (inputType() == MONTH) 1381 return 0.0; 1382 return std::numeric_limits<double>::quiet_NaN(); 1383 } 1384 1385 void HTMLInputElement::setValueAsDate(double value, ExceptionCode& ec) 1386 { 1387 // FIXME: This is a temporary implementation to check Date binding. 1388 if (!isnan(value) && !isinf(value) && inputType() == MONTH) { 1389 setValue(String("1970-01")); 1390 return; 1391 } 1392 ec = INVALID_STATE_ERR; 1375 1393 } 1376 1394 -
trunk/WebCore/html/HTMLInputElement.h
r52204 r52434 145 145 virtual void setValueForUser(const String&); 146 146 147 double valueAsDate() const; 148 void setValueAsDate(double, ExceptionCode&); 149 147 150 virtual String placeholder() const; 148 151 virtual void setPlaceholder(const String&); -
trunk/WebCore/html/HTMLInputElement.idl
r51822 r52434 68 68 attribute [ConvertNullToNullString] DOMString useMap; 69 69 attribute [ConvertNullToNullString] DOMString value; 70 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT && !(defined(V8_BINDING) && V8_BINDING) 71 // FIXME: Add Date support for V8, Objective-C, and COM. 72 attribute Date valueAsDate setter raises(DOMException); 73 #endif 70 74 #if defined(ENABLE_DATALIST) && ENABLE_DATALIST 71 75 readonly attribute HTMLOptionElement selectedOption;
Note: See TracChangeset
for help on using the changeset viewer.