mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1360340 - IPCBlob must contain isDirectory boolean in order to support Drag&Drop of directories, r=smaug
This commit is contained in:
parent
37a5962246
commit
9cc9f87380
@ -42,6 +42,7 @@ StreamBlobImpl::StreamBlobImpl(nsIInputStream* aInputStream,
|
||||
uint64_t aLength)
|
||||
: BaseBlobImpl(aContentType, aLength)
|
||||
, mInputStream(aInputStream)
|
||||
, mIsDirectory(false)
|
||||
{
|
||||
mImmutable = true;
|
||||
}
|
||||
@ -51,6 +52,7 @@ StreamBlobImpl::StreamBlobImpl(StreamBlobImpl* aOther,
|
||||
uint64_t aStart, uint64_t aLength)
|
||||
: BaseBlobImpl(aContentType, aOther->mStart + aStart, aLength)
|
||||
, mInputStream(new SlicedInputStream(aOther->mInputStream, aStart, aLength))
|
||||
, mIsDirectory(false)
|
||||
{
|
||||
mImmutable = true;
|
||||
}
|
||||
@ -62,6 +64,7 @@ StreamBlobImpl::StreamBlobImpl(nsIInputStream* aInputStream,
|
||||
uint64_t aLength)
|
||||
: BaseBlobImpl(aName, aContentType, aLength, aLastModifiedDate)
|
||||
, mInputStream(aInputStream)
|
||||
, mIsDirectory(false)
|
||||
{
|
||||
mImmutable = true;
|
||||
}
|
||||
|
@ -46,6 +46,27 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetFullPath(const nsAString& aFullPath)
|
||||
{
|
||||
mFullPath = aFullPath;
|
||||
}
|
||||
|
||||
void GetMozFullPathInternal(nsAString& aFullPath,
|
||||
ErrorResult& aRv) const override
|
||||
{
|
||||
aFullPath = mFullPath;
|
||||
}
|
||||
|
||||
void SetIsDirectory(bool aIsDirectory)
|
||||
{
|
||||
mIsDirectory = aIsDirectory;
|
||||
}
|
||||
|
||||
bool IsDirectory() const override
|
||||
{
|
||||
return mIsDirectory;
|
||||
}
|
||||
|
||||
private:
|
||||
StreamBlobImpl(nsIInputStream* aInputStream,
|
||||
const nsAString& aContentType,
|
||||
@ -67,6 +88,9 @@ private:
|
||||
void MaybeRegisterMemoryReporter();
|
||||
|
||||
nsCOMPtr<nsIInputStream> mInputStream;
|
||||
|
||||
nsString mFullPath;
|
||||
bool mIsDirectory;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -24,6 +24,10 @@ struct IPCFile
|
||||
nsString name;
|
||||
int64_t lastModified;
|
||||
nsString DOMPath;
|
||||
nsString fullPath;
|
||||
|
||||
// Useful for Entries API.
|
||||
bool isDirectory;
|
||||
};
|
||||
|
||||
// Union for blob vs file.
|
||||
|
@ -47,7 +47,7 @@ Deserialize(const IPCBlob& aIPCBlob)
|
||||
|
||||
MOZ_ASSERT(inputStream);
|
||||
|
||||
RefPtr<BlobImpl> blobImpl;
|
||||
RefPtr<StreamBlobImpl> blobImpl;
|
||||
|
||||
if (aIPCBlob.file().type() == IPCFileUnion::Tvoid_t) {
|
||||
blobImpl = StreamBlobImpl::Create(inputStream,
|
||||
@ -61,6 +61,8 @@ Deserialize(const IPCBlob& aIPCBlob)
|
||||
file.lastModified(),
|
||||
aIPCBlob.size());
|
||||
blobImpl->SetDOMPath(file.DOMPath());
|
||||
blobImpl->SetFullPath(file.fullPath());
|
||||
blobImpl->SetIsDirectory(file.isDirectory());
|
||||
}
|
||||
|
||||
return blobImpl.forget();
|
||||
@ -165,6 +167,14 @@ SerializeInternal(BlobImpl* aBlobImpl, M* aManager, IPCBlob& aIPCBlob)
|
||||
aBlobImpl->GetDOMPath(value);
|
||||
file.DOMPath() = value;
|
||||
|
||||
aBlobImpl->GetMozFullPathInternal(value, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
file.fullPath() = value;
|
||||
|
||||
file.isDirectory() = aBlobImpl->IsDirectory();
|
||||
|
||||
aIPCBlob.file() = file;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user