зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1590022 - Use union return value for FileReader.result, r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D49876 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
809db7ead1
Коммит
7c8a14a29d
|
@ -143,31 +143,25 @@ FileReader::GetInterface(const nsIID& aIID, void** aResult) {
|
|||
return QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
void FileReader::GetResult(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
|
||||
ErrorResult& aRv) {
|
||||
void FileReader::GetResult(JSContext* aCx,
|
||||
Nullable<OwningStringOrArrayBuffer>& aResult) {
|
||||
JS::Rooted<JS::Value> result(aCx);
|
||||
|
||||
if (mDataFormat == FILE_AS_ARRAYBUFFER) {
|
||||
if (mReadyState == DONE && mResultArrayBuffer) {
|
||||
result.setObject(*mResultArrayBuffer);
|
||||
} else {
|
||||
result.setNull();
|
||||
if (mReadyState != DONE || !mResultArrayBuffer ||
|
||||
!aResult.SetValue().SetAsArrayBuffer().Init(mResultArrayBuffer)) {
|
||||
aResult.SetNull();
|
||||
}
|
||||
|
||||
if (!JS_WrapValue(aCx, &result)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
aResult.set(result);
|
||||
return;
|
||||
}
|
||||
|
||||
nsString tmpResult = mResult;
|
||||
if (!xpc::StringToJsval(aCx, tmpResult, aResult)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
if (mResult.IsVoid()) {
|
||||
aResult.SetNull();
|
||||
return;
|
||||
}
|
||||
|
||||
aResult.SetValue().SetAsString() = mResult;
|
||||
}
|
||||
|
||||
void FileReader::OnLoadEndArrayBuffer() {
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace dom {
|
|||
|
||||
class Blob;
|
||||
class DOMException;
|
||||
class OwningStringOrArrayBuffer;
|
||||
class StrongWorkerRef;
|
||||
class WeakWorkerRef;
|
||||
|
||||
|
@ -93,8 +94,7 @@ class FileReader final : public DOMEventTargetHelper,
|
|||
|
||||
DOMException* GetError() const { return mError; }
|
||||
|
||||
void GetResult(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
|
||||
ErrorResult& aRv);
|
||||
void GetResult(JSContext* aCx, Nullable<OwningStringOrArrayBuffer>& aResult);
|
||||
|
||||
IMPL_EVENT_HANDLER(loadstart)
|
||||
IMPL_EVENT_HANDLER(progress)
|
||||
|
|
|
@ -34,10 +34,7 @@ interface FileReader : EventTarget {
|
|||
|
||||
readonly attribute unsigned short readyState;
|
||||
|
||||
// File or Blob data
|
||||
// bug 858217: readonly attribute (DOMString or ArrayBuffer)? result;
|
||||
[Throws]
|
||||
readonly attribute any result;
|
||||
readonly attribute (DOMString or ArrayBuffer)? result;
|
||||
|
||||
readonly attribute DOMException? error;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче