diff --git a/dom/file/Blob.cpp b/dom/file/Blob.cpp index 532468f8d69c..6b6b3910a795 100644 --- a/dom/file/Blob.cpp +++ b/dom/file/Blob.cpp @@ -189,11 +189,16 @@ Blob::GetType(nsAString &aType) already_AddRefed Blob::Slice(const Optional& aStart, const Optional& aEnd, - const nsAString& aContentType, + const Optional& aContentType, ErrorResult& aRv) { + nsAutoString contentType; + if (aContentType.WasPassed()) { + contentType = aContentType.Value(); + } + RefPtr impl = - mImpl->Slice(aStart, aEnd, aContentType, aRv); + mImpl->Slice(aStart, aEnd, contentType, aRv); if (aRv.Failed()) { return nullptr; } diff --git a/dom/file/Blob.h b/dom/file/Blob.h index a0c881944cb0..a62e5c95db97 100644 --- a/dom/file/Blob.h +++ b/dom/file/Blob.h @@ -122,7 +122,7 @@ public: already_AddRefed Slice(const Optional& aStart, const Optional& aEnd, - const nsAString& aContentType, + const Optional& aContentType, ErrorResult& aRv); size_t GetAllocationSize() const; diff --git a/dom/file/FileReader.h b/dom/file/FileReader.h index d330ae9202ee..d8b9c2a1897b 100644 --- a/dom/file/FileReader.h +++ b/dom/file/FileReader.h @@ -72,9 +72,14 @@ public: ReadFileContent(aBlob, EmptyString(), FILE_AS_ARRAYBUFFER, aRv); } - void ReadAsText(Blob& aBlob, const nsAString& aLabel, ErrorResult& aRv) + void ReadAsText(Blob& aBlob, const Optional& aLabel, + ErrorResult& aRv) { - ReadFileContent(aBlob, aLabel, FILE_AS_TEXT, aRv); + if (aLabel.WasPassed()) { + ReadFileContent(aBlob, aLabel.Value(), FILE_AS_TEXT, aRv); + } else { + ReadFileContent(aBlob, EmptyString(), FILE_AS_TEXT, aRv); + } } void ReadAsDataURL(Blob& aBlob, ErrorResult& aRv) diff --git a/dom/webidl/Blob.webidl b/dom/webidl/Blob.webidl index 07e96527b2d6..94812cd89c65 100644 --- a/dom/webidl/Blob.webidl +++ b/dom/webidl/Blob.webidl @@ -27,7 +27,7 @@ interface Blob { [Throws] Blob slice([Clamp] optional long long start, [Clamp] optional long long end, - optional DOMString contentType = ""); + optional DOMString contentType); }; enum EndingTypes { "transparent", "native" }; diff --git a/dom/webidl/FileReader.webidl b/dom/webidl/FileReader.webidl index 710f0c7b366b..1e79ba09fd9d 100644 --- a/dom/webidl/FileReader.webidl +++ b/dom/webidl/FileReader.webidl @@ -4,7 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * The origin of this IDL file is - * http://dev.w3.org/2006/webapi/FileAPI/#dfn-filereader + * https://w3c.github.io/FileAPI/#APIASynch * * Copyright © 2013 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C * liability, trademark and document use rules apply. @@ -17,7 +17,9 @@ interface FileReader : EventTarget { [Throws] void readAsArrayBuffer(Blob blob); [Throws] - void readAsText(Blob blob, optional DOMString label = ""); + void readAsBinaryString(Blob filedata); + [Throws] + void readAsText(Blob blob, optional DOMString label); [Throws] void readAsDataURL(Blob blob); @@ -46,9 +48,3 @@ interface FileReader : EventTarget { attribute EventHandler onerror; attribute EventHandler onloadend; }; - -// Mozilla extensions. -partial interface FileReader { - [Throws] - void readAsBinaryString(Blob filedata); -};