summaryrefslogtreecommitdiff
path: root/Source/WebCore/fileapi
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-06-01 10:36:58 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-06-01 10:36:58 +0200
commitb1e9e47fa11f608ae16bc07f97a2acf95bf80272 (patch)
treec88c45e80c9c44506e7cdf9a3bb39ebf82a8cd5b /Source/WebCore/fileapi
parentbe01689f43cf6882cf670d33df49ead1f570c53a (diff)
downloadqtwebkit-b1e9e47fa11f608ae16bc07f97a2acf95bf80272.tar.gz
Imported WebKit commit 499c84c99aa98e9870fa7eaa57db476c6d160d46 (http://svn.webkit.org/repository/webkit/trunk@119200)
Weekly update :). Particularly relevant changes for Qt are the use of the WebCore image decoders and direct usage of libpng/libjpeg if available in the system.
Diffstat (limited to 'Source/WebCore/fileapi')
-rw-r--r--Source/WebCore/fileapi/File.cpp12
-rw-r--r--Source/WebCore/fileapi/File.h15
-rw-r--r--Source/WebCore/fileapi/File.idl2
-rw-r--r--Source/WebCore/fileapi/FileReader.cpp9
4 files changed, 27 insertions, 11 deletions
diff --git a/Source/WebCore/fileapi/File.cpp b/Source/WebCore/fileapi/File.cpp
index 098084807..86d59894f 100644
--- a/Source/WebCore/fileapi/File.cpp
+++ b/Source/WebCore/fileapi/File.cpp
@@ -130,7 +130,7 @@ File::File(const String& name, const FileMetadata& metadata)
double File::lastModifiedDate() const
{
#if ENABLE(FILE_SYSTEM)
- if (m_snapshotSize >= 0 && m_snapshotModificationTime)
+ if (hasValidSnapshotMetadata())
return m_snapshotModificationTime * 1000.0;
#endif
@@ -142,10 +142,16 @@ double File::lastModifiedDate() const
return modificationTime * 1000.0;
}
+double File::lastModifiedDateForBinding() const
+{
+ double value = lastModifiedDate();
+ return (!value) ? std::numeric_limits<double>::quiet_NaN() : value;
+}
+
unsigned long long File::size() const
{
#if ENABLE(FILE_SYSTEM)
- if (m_snapshotSize >= 0 && m_snapshotModificationTime)
+ if (hasValidSnapshotMetadata())
return m_snapshotSize;
#endif
@@ -160,7 +166,7 @@ unsigned long long File::size() const
void File::captureSnapshot(long long& snapshotSize, double& snapshotModificationTime) const
{
#if ENABLE(FILE_SYSTEM)
- if (m_snapshotSize >= 0 && m_snapshotModificationTime) {
+ if (hasValidSnapshotMetadata()) {
snapshotSize = m_snapshotSize;
snapshotModificationTime = m_snapshotModificationTime;
return;
diff --git a/Source/WebCore/fileapi/File.h b/Source/WebCore/fileapi/File.h
index e852c6adf..67f31f6a7 100644
--- a/Source/WebCore/fileapi/File.h
+++ b/Source/WebCore/fileapi/File.h
@@ -54,7 +54,7 @@ public:
#endif
#if ENABLE(FILE_SYSTEM)
- // If filesystem files live in the remote filesystem, the port might pass the valid metadata (non-zero modificationTime and non-negative file size) and cache in the File object.
+ // If filesystem files live in the remote filesystem, the port might pass the valid metadata (whose length field is non-negative) and cache in the File object.
//
// Otherwise calling size(), lastModifiedTime() and webkitSlice() will synchronously query the file metadata.
static PassRefPtr<File> createForFileSystemFile(const String& name, const FileMetadata& metadata)
@@ -76,7 +76,13 @@ public:
const String& path() const { return m_path; }
const String& name() const { return m_name; }
+
+ // This may return zero if getFileModificationTime() platform call has failed or zero snapshot lastModifiedTime is given at construction time.
double lastModifiedDate() const;
+
+ // For binding. We want to return null Date if we get the value 0 Date (which is used to indicate the information is unavailable).
+ double lastModifiedDateForBinding() const;
+
#if ENABLE(DIRECTORY_UPLOAD)
// Returns the relative path of this file in the context of a directory selection.
const String& webkitRelativePath() const { return m_relativePath; }
@@ -94,14 +100,17 @@ private:
# if ENABLE(FILE_SYSTEM)
File(const String& name, const FileMetadata&);
+
+ // Returns true if this has a valid snapshot metadata (i.e. m_snapshotSize >= 0).
+ bool hasValidSnapshotMetadata() const { return m_snapshotSize >= 0; }
#endif
String m_path;
String m_name;
#if ENABLE(FILE_SYSTEM)
- // If non-zero modificationTime and non-negative file size are given at construction time we use them in size(), lastModifiedTime() and webkitSlice().
- // By default we initialize m_snapshotSize to -1 and m_snapshotModificationTime to 0 (so that we don't use them unless they are given).
+ // If m_snapshotSize is negative (initialized to -1 by default), the snapshot metadata is invalid and we retrieve the latest metadata synchronously in size(), lastModifiedTime() and webkitSlice().
+ // Otherwise, the snapshot metadata are used directly in those methods.
const long long m_snapshotSize;
const double m_snapshotModificationTime;
#endif
diff --git a/Source/WebCore/fileapi/File.idl b/Source/WebCore/fileapi/File.idl
index 7c0de4309..00bdde6f5 100644
--- a/Source/WebCore/fileapi/File.idl
+++ b/Source/WebCore/fileapi/File.idl
@@ -32,7 +32,7 @@ module html {
] File : Blob {
readonly attribute DOMString name;
#if !defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT
- readonly attribute Date lastModifiedDate;
+ readonly attribute [ImplementedAs=lastModifiedDateForBinding] Date lastModifiedDate;
#endif
#if defined(ENABLE_DIRECTORY_UPLOAD) && ENABLE_DIRECTORY_UPLOAD
readonly attribute DOMString webkitRelativePath;
diff --git a/Source/WebCore/fileapi/FileReader.cpp b/Source/WebCore/fileapi/FileReader.cpp
index ab7c2b3b2..bdae05942 100644
--- a/Source/WebCore/fileapi/FileReader.cpp
+++ b/Source/WebCore/fileapi/FileReader.cpp
@@ -250,15 +250,16 @@ void FileReader::fireEvent(const AtomicString& type)
PassRefPtr<ArrayBuffer> FileReader::arrayBufferResult() const
{
- return m_loader ? m_loader->arrayBufferResult() : 0;
+ if (!m_loader || m_error)
+ return 0;
+ return m_loader->arrayBufferResult();
}
String FileReader::stringResult()
{
- String ret = m_loader ? m_loader->stringResult() : "";
- if (ret.isEmpty())
+ if (!m_loader || m_error)
return String();
- return ret;
+ return m_loader->stringResult();
}
} // namespace WebCore