Chromium Code Reviews| Index: Source/bindings/v8/custom/V8FileCustom.cpp |
| diff --git a/Source/bindings/v8/custom/V8FileCustom.cpp b/Source/bindings/v8/custom/V8FileCustom.cpp |
| index 6983ef2188946414cbbeb6a688c5b9914d1d3b51..1971063bc7f820f7c02c3399768e38e2cae97f6e 100644 |
| --- a/Source/bindings/v8/custom/V8FileCustom.cpp |
| +++ b/Source/bindings/v8/custom/V8FileCustom.cpp |
| @@ -62,25 +62,46 @@ void V8File::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
| V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, fileName, info[1]); |
| - String contentType; |
| - String endings = "transparent"; // default if no BlobPropertyBag is passed |
| + V8BlobCustomHelpers::ParsedProperties properties(true); |
| if (info.Length() > 2) { |
| if (!info[2]->IsObject()) { |
| throwTypeError(ExceptionMessages::failedToConstruct("File", "The 3rd argument is not of type Object."), info.GetIsolate()); |
| return; |
| } |
| - if (!V8BlobCustomHelpers::processBlobPropertyBag(info[2], "File", contentType, endings, info.GetIsolate())) |
| + if (!properties.parseBlobPropertyBag(info[2], "File", info.GetIsolate())) |
| return; |
| + } else { |
| + properties.setDefaultLastModifiedDate(); |
| } |
| BlobBuilder blobBuilder; |
| v8::Local<v8::Object> blobParts = v8::Local<v8::Object>::Cast(info[0]); |
| - if (!V8BlobCustomHelpers::processBlobParts(blobParts, length, endings, blobBuilder, info.GetIsolate())) |
| + if (!V8BlobCustomHelpers::processBlobParts(blobParts, length, properties.endings, blobBuilder, info.GetIsolate())) |
| return; |
| - RefPtr<File> file = blobBuilder.createFile(contentType, fileName, currentTime()); |
| + RefPtr<File> file = blobBuilder.createFile(properties.contentType, fileName, properties.lastModifiedDate()); |
| v8SetReturnValue(info, file.release()); |
| } |
| +void V8File::lastModifiedDateAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info) |
| +{ |
| + // The auto-generated getters return null when the method in the underlying |
| + // implementation returns NaN. Here, we need to return a Date whose value |
| + // is NaN when the File constructor receives such a Date. WebIDL calls it |
| + // an "undefined date". Fortunately, lastModifiedDate never needs to return |
| + // null, so we can get away with mapping NaN to "new Date(NaN)" instead of |
| + // "null". |
| + // |
| + // See step 3.3 in Section 7.1, and Section 7.2 of the File API spec: |
| + // http://dev.w3.org/2006/webapi/FileAPI/ |
| + // |
| + // See the following sections of the WebIDL ED: |
| + // 3.10.26: http://heycam.github.io/webidl/#idl-Date |
| + // 4.2.27: http://heycam.github.io/webidl/#es-Date |
| + |
| + File* file = V8File::toNative(info.Holder()); |
| + v8SetReturnValue(info, v8::Date::New(file->lastModifiedDate())); |
|
kinuko
2013/11/18 14:16:59
(Going back to this one) so for NaN case should we
pwnall-personal
2013/11/18 14:44:35
Thank you for pointing this out again! I think I j
|
| +} |
| + |
| } // namespace WebCore |