From 32c9507c4f105a7b2f61d676f5bc6f92ffa6f6b1 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 24 May 2011 12:56:04 +0200 Subject: [PATCH 1/5] Bug 655003 - On Linux, use -Os on normal builds and -O3 when PGO is enabled. r=ted,a=sheriff --- config/autoconf.mk.in | 1 + config/config.mk | 5 +++++ configure.in | 7 +++++-- js/src/config/autoconf.mk.in | 1 + js/src/config/config.mk | 5 +++++ js/src/configure.in | 7 +++++-- xpcom/io/Makefile.in | 2 +- 7 files changed, 23 insertions(+), 5 deletions(-) diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in index ba7b3de491d..2f1f37ca3b5 100644 --- a/config/autoconf.mk.in +++ b/config/autoconf.mk.in @@ -315,6 +315,7 @@ WARNINGS_AS_ERRORS = @WARNINGS_AS_ERRORS@ MOZ_OPTIMIZE = @MOZ_OPTIMIZE@ MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@ +MOZ_PGO_OPTIMIZE_FLAGS = @MOZ_PGO_OPTIMIZE_FLAGS@ MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@ MOZ_OPTIMIZE_SIZE_TWEAK = @MOZ_OPTIMIZE_SIZE_TWEAK@ diff --git a/config/config.mk b/config/config.mk index fc871c511fc..dca26461318 100644 --- a/config/config.mk +++ b/config/config.mk @@ -422,8 +422,13 @@ ifdef MODULE_OPTIMIZE_FLAGS CFLAGS += $(MODULE_OPTIMIZE_FLAGS) CXXFLAGS += $(MODULE_OPTIMIZE_FLAGS) else +ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE)) +CFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS) +CXXFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS) +else CFLAGS += $(MOZ_OPTIMIZE_FLAGS) CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS) +endif # neq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE)) endif # MODULE_OPTIMIZE_FLAGS else CFLAGS += $(MOZ_OPTIMIZE_FLAGS) diff --git a/configure.in b/configure.in index 42a6c05de63..363320b7436 100644 --- a/configure.in +++ b/configure.in @@ -2188,10 +2188,12 @@ ia64*-hpux*) esac # If we're building with --enable-profiling, we need a frame pointer. if test -z "$MOZ_PROFILING"; then - MOZ_OPTIMIZE_FLAGS="-O3 -fomit-frame-pointer" + MOZ_FRAMEPTR_FLAGS="-fomit-frame-pointer" else - MOZ_OPTIMIZE_FLAGS="-O3 -fno-omit-frame-pointer" + MOZ_FRAMEPTR_FLAGS="-fno-omit-frame-pointer" fi + MOZ_PGO_OPTIMIZE_FLAGS="-O3 $MOZ_FRAMEPTR_FLAGS" + MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK $MOZ_FRAMEPTR_FLAGS" MOZ_DEBUG_FLAGS="-g" fi @@ -7183,6 +7185,7 @@ AC_SUBST(MOZ_OPTIMIZE) AC_SUBST(MOZ_OPTIMIZE_FLAGS) AC_SUBST(MOZ_OPTIMIZE_LDFLAGS) AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK) +AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS) dnl ======================================================== dnl = Enable generation of debug symbols diff --git a/js/src/config/autoconf.mk.in b/js/src/config/autoconf.mk.in index b99e475ddc1..7f14a6b8d97 100644 --- a/js/src/config/autoconf.mk.in +++ b/js/src/config/autoconf.mk.in @@ -145,6 +145,7 @@ FAIL_ON_WARNINGS = @FAIL_ON_WARNINGS@ MOZ_OPTIMIZE = @MOZ_OPTIMIZE@ MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@ +MOZ_PGO_OPTIMIZE_FLAGS = @MOZ_PGO_OPTIMIZE_FLAGS@ MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@ MOZ_OPTIMIZE_SIZE_TWEAK = @MOZ_OPTIMIZE_SIZE_TWEAK@ diff --git a/js/src/config/config.mk b/js/src/config/config.mk index fc871c511fc..dca26461318 100644 --- a/js/src/config/config.mk +++ b/js/src/config/config.mk @@ -422,8 +422,13 @@ ifdef MODULE_OPTIMIZE_FLAGS CFLAGS += $(MODULE_OPTIMIZE_FLAGS) CXXFLAGS += $(MODULE_OPTIMIZE_FLAGS) else +ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE)) +CFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS) +CXXFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS) +else CFLAGS += $(MOZ_OPTIMIZE_FLAGS) CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS) +endif # neq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE)) endif # MODULE_OPTIMIZE_FLAGS else CFLAGS += $(MOZ_OPTIMIZE_FLAGS) diff --git a/js/src/configure.in b/js/src/configure.in index 4f99e2e623f..c29ea2a0fd8 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -2102,10 +2102,12 @@ ia64*-hpux*) esac # If we're building with --enable-profiling, we need a frame pointer. if test -z "$MOZ_PROFILING"; then - MOZ_OPTIMIZE_FLAGS="-O3 -fomit-frame-pointer" + MOZ_FRAMEPTR_FLAGS="-fomit-frame-pointer" else - MOZ_OPTIMIZE_FLAGS="-O3 -fno-omit-frame-pointer" + MOZ_FRAMEPTR_FLAGS="-fno-omit-frame-pointer" fi + MOZ_PGO_OPTIMIZE_FLAGS="-O3 $MOZ_FRAMEPTR_FLAGS" + MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks $MOZ_OPTIMIZE_SIZE_TWEAK $MOZ_FRAMEPTR_FLAGS" MOZ_DEBUG_FLAGS="-g" fi @@ -4617,6 +4619,7 @@ AC_SUBST(MOZ_OPTIMIZE) AC_SUBST(MOZ_OPTIMIZE_FLAGS) AC_SUBST(MOZ_OPTIMIZE_LDFLAGS) AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK) +AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS) dnl ======================================================== dnl = Enable generation of debug symbols diff --git a/xpcom/io/Makefile.in b/xpcom/io/Makefile.in index a9036fa164d..6c0d9f1980c 100644 --- a/xpcom/io/Makefile.in +++ b/xpcom/io/Makefile.in @@ -51,7 +51,7 @@ MOZILLA_INTERNAL_API = 1 # work around bug 408258 ifdef GNU_CC ifneq ($(OS_ARCH), Darwin) -MODULE_OPTIMIZE_FLAGS = -O3 -fno-strict-aliasing +MODULE_OPTIMIZE_FLAGS = $(MOZ_OPTIMIZE_FLAGS) -fno-strict-aliasing endif endif From e833a971c57e8101e208497ba5d4c74ed38bf525 Mon Sep 17 00:00:00 2001 From: Shawn Gong Date: Mon, 23 May 2011 18:09:28 -0700 Subject: [PATCH 2/5] Bug 658683: Make xhr.response not create a new ArrayBuffer every time it is accessed. r=sicking. Additional fixes by sicking, r=peterv --- content/base/src/nsXMLHttpRequest.cpp | 49 ++++++++++++++--------- content/base/src/nsXMLHttpRequest.h | 10 +++-- content/base/test/test_XHR.html | 10 +++++ xpcom/glue/nsCycleCollectionParticipant.h | 14 +++++++ 4 files changed, 61 insertions(+), 22 deletions(-) diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index 5b8395f1721..77e7d4b8fb9 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -426,7 +426,8 @@ nsXMLHttpRequest::nsXMLHttpRequest() mErrorLoad(PR_FALSE), mTimerIsActive(PR_FALSE), mProgressEventWasDelayed(PR_FALSE), mLoadLengthComputable(PR_FALSE), mLoadTotal(0), - mFirstStartRequestSeen(PR_FALSE) + mFirstStartRequestSeen(PR_FALSE), + mResultArrayBuffer(nsnull) { mResponseBodyUnicode.SetIsVoid(PR_TRUE); nsLayoutStatics::AddRef(); @@ -450,6 +451,12 @@ nsXMLHttpRequest::~nsXMLHttpRequest() nsLayoutStatics::Release(); } +void +nsXMLHttpRequest::RootResultArrayBuffer() +{ + nsContentUtils::PreserveWrapper(static_cast(this), this); +} + /** * This Init method is called from the factory constructor. */ @@ -572,9 +579,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXMLHttpRequest, nsIXMLHttpRequestUpload) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END - NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXMLHttpRequest, nsXHREventTarget) + tmp->mResultArrayBuffer = nsnull; NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mContext) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChannel) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mReadRequest) @@ -592,6 +599,14 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXMLHttpRequest, NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mUpload) NS_IMPL_CYCLE_COLLECTION_UNLINK_END +NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsXMLHttpRequest, + nsXHREventTarget) + if(tmp->mResultArrayBuffer) { + NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(tmp->mResultArrayBuffer, + "mResultArrayBuffer") + } +NS_IMPL_CYCLE_COLLECTION_TRACE_END + DOMCI_DATA(XMLHttpRequest, nsXMLHttpRequest) // QueryInterface implementation for nsXMLHttpRequest @@ -839,27 +854,20 @@ NS_IMETHODIMP nsXMLHttpRequest::GetResponseText(nsAString& aResponseText) return rv; } -nsresult nsXMLHttpRequest::GetResponseArrayBuffer(jsval *aResult) +nsresult nsXMLHttpRequest::CreateResponseArrayBuffer(JSContext *aCx) { - JSContext *cx = nsContentUtils::GetCurrentJSContext(); - if (!cx) + if (!aCx) return NS_ERROR_FAILURE; - if (!(mState & (XML_HTTP_REQUEST_DONE | - XML_HTTP_REQUEST_LOADING))) { - *aResult = JSVAL_NULL; - return NS_OK; - } - PRInt32 dataLen = mResponseBody.Length(); - JSObject *obj = js_CreateArrayBuffer(cx, dataLen); - if (!obj) + RootResultArrayBuffer(); + mResultArrayBuffer = js_CreateArrayBuffer(aCx, dataLen); + if (!mResultArrayBuffer) { return NS_ERROR_FAILURE; - - *aResult = OBJECT_TO_JSVAL(obj); + } if (dataLen > 0) { - js::ArrayBuffer *abuf = js::ArrayBuffer::fromJSObject(obj); + js::ArrayBuffer *abuf = js::ArrayBuffer::fromJSObject(mResultArrayBuffer); NS_ASSERTION(abuf, "What happened?"); memcpy(abuf->data, mResponseBody.BeginReading(), dataLen); } @@ -954,7 +962,11 @@ NS_IMETHODIMP nsXMLHttpRequest::GetResponse(JSContext *aCx, jsval *aResult) case XML_HTTP_RESPONSE_TYPE_ARRAYBUFFER: if (mState & XML_HTTP_REQUEST_DONE) { - rv = GetResponseArrayBuffer(aResult); + if (!mResultArrayBuffer) { + rv = CreateResponseArrayBuffer(aCx); + NS_ENSURE_SUCCESS(rv, rv); + } + *aResult = OBJECT_TO_JSVAL(mResultArrayBuffer); } else { *aResult = JSVAL_NULL; } @@ -1073,7 +1085,8 @@ nsXMLHttpRequest::Abort() mResponseBodyUnicode.SetIsVoid(PR_TRUE); mResponseBlob = nsnull; mState |= XML_HTTP_REQUEST_ABORTED; - + mResultArrayBuffer = nsnull; + if (!(mState & (XML_HTTP_REQUEST_UNSENT | XML_HTTP_REQUEST_OPENED | XML_HTTP_REQUEST_DONE))) { diff --git a/content/base/src/nsXMLHttpRequest.h b/content/base/src/nsXMLHttpRequest.h index 2ab09881ed2..8ee3039d738 100644 --- a/content/base/src/nsXMLHttpRequest.h +++ b/content/base/src/nsXMLHttpRequest.h @@ -208,11 +208,11 @@ public: void SetRequestObserver(nsIRequestObserver* aObserver); - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXMLHttpRequest, + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsXMLHttpRequest, nsXHREventTarget) - PRBool AllowUploadProgress(); - + void RootResultArrayBuffer(); + protected: friend class nsMultipartProxyListener; @@ -224,7 +224,7 @@ protected: PRUint32 toOffset, PRUint32 count, PRUint32 *writeCount); - nsresult GetResponseArrayBuffer(jsval *aResult); + nsresult CreateResponseArrayBuffer(JSContext* aCx); void CreateResponseBlob(nsIRequest *request); // Change the state of the object with this. The broadcast argument // determines if the onreadystatechange listener should be called. @@ -345,6 +345,8 @@ protected: nsCOMPtr mRedirectCallback; nsCOMPtr mNewRedirectChannel; + + JSObject* mResultArrayBuffer; }; // helper class to expose a progress DOM Event diff --git a/content/base/test/test_XHR.html b/content/base/test/test_XHR.html index 9052729e6b5..4f370b34969 100644 --- a/content/base/test/test_XHR.html +++ b/content/base/test/test_XHR.html @@ -134,6 +134,16 @@ ab = xhr.response; ok(ab != null, "should have a non-null arraybuffer"); arraybuffer_equals_to(ab, "\xaa\xee\0\x03\xff\xff\xff\xff\xbb\xbb\xbb\xbb"); +// test array buffer GetResult returns the same object +xhr = new XMLHttpRequest(); +xhr.open("GET", 'file_XHR_binary1.bin', false); +xhr.responseType = 'arraybuffer'; +xhr.send(null) +is(xhr.status, 200, "wrong status"); +checkResponseTextAccessThrows(xhr); +checkResponseXMLAccessThrows(xhr); +is(xhr.response, xhr.response, "returns the same ArrayBuffer"); + // test response (responseType='blob') var onloadCount = 0; function checkOnloadCount() { diff --git a/xpcom/glue/nsCycleCollectionParticipant.h b/xpcom/glue/nsCycleCollectionParticipant.h index 22d8308a578..02e1b77fe66 100644 --- a/xpcom/glue/nsCycleCollectionParticipant.h +++ b/xpcom/glue/nsCycleCollectionParticipant.h @@ -436,6 +436,20 @@ public: "not the nsISupports pointer we expect"); \ _class *tmp = Downcast(s); +#define NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(_class, _base_class) \ + void \ + NS_CYCLE_COLLECTION_CLASSNAME(_class)::Trace(void *p, \ + TraceCallback aCallback, \ + void *aClosure) \ + { \ + nsISupports *s = static_cast(p); \ + NS_ASSERTION(CheckForRightISupports(s), \ + "not the nsISupports pointer we expect"); \ + _class *tmp = static_cast<_class*>(Downcast(s)); \ + NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::Trace(s, \ + aCallback, \ + aClosure); + #define NS_IMPL_CYCLE_COLLECTION_TRACE_NATIVE_BEGIN(_class) \ void \ NS_CYCLE_COLLECTION_CLASSNAME(_class)::Trace(void *p, \ From 725884e9dbbec65cdcf35f25f073920d57b719c4 Mon Sep 17 00:00:00 2001 From: Shawn Gong Date: Mon, 23 May 2011 18:02:56 -0700 Subject: [PATCH 3/5] Bug 632255 - Implemented readAsArrayBuffer() for FileReader. r=sicking,bent. Additional fixes by sicking, r=peterv. a=sheriff. --- content/base/public/nsIDOMFileReader.idl | 7 +- content/base/src/nsDOMFileReader.cpp | 72 +++++++++++++++++-- content/base/src/nsDOMFileReader.h | 10 ++- content/base/test/test_fileapi.html | 89 +++++++++++++++++++++++- 4 files changed, 166 insertions(+), 12 deletions(-) diff --git a/content/base/public/nsIDOMFileReader.idl b/content/base/public/nsIDOMFileReader.idl index bbd6b06d3d8..d7b20a75ead 100644 --- a/content/base/public/nsIDOMFileReader.idl +++ b/content/base/public/nsIDOMFileReader.idl @@ -41,9 +41,11 @@ interface nsIDOMEventListener; interface nsIDOMBlob; interface nsIDOMFileError; -[scriptable, uuid(f186170f-f07c-4f0b-9e3c-08f7dd496e74)] +[scriptable, uuid(3d77e784-1459-4206-b8a2-0855d826f569)] interface nsIDOMFileReader : nsISupports { + [implicit_jscontext] + void readAsArrayBuffer(in nsIDOMBlob filedata); void readAsBinaryString(in nsIDOMBlob filedata); void readAsText(in nsIDOMBlob filedata, [optional] in DOMString encoding); void readAsDataURL(in nsIDOMBlob file); @@ -55,7 +57,8 @@ interface nsIDOMFileReader : nsISupports const unsigned short DONE = 2; readonly attribute unsigned short readyState; - readonly attribute DOMString result; + [implicit_jscontext] + readonly attribute jsval result; readonly attribute nsIDOMFileError error; }; diff --git a/content/base/src/nsDOMFileReader.cpp b/content/base/src/nsDOMFileReader.cpp index a00a5422047..6c1132a8e03 100644 --- a/content/base/src/nsDOMFileReader.cpp +++ b/content/base/src/nsDOMFileReader.cpp @@ -77,6 +77,9 @@ #include "nsLayoutStatics.h" #include "nsIScriptObjectPrincipal.h" #include "nsFileDataProtocolHandler.h" +#include "xpcprivate.h" +#include "xpcquickstubs.h" +#include "jstypedarray.h" #define LOAD_STR "load" #define ERROR_STR "error" @@ -101,12 +104,21 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMFileReader, nsXHREventTarget) + tmp->mResultArrayBuffer = nsnull; NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFile) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mProgressNotifier) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mPrincipal) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChannel) NS_IMPL_CYCLE_COLLECTION_UNLINK_END +NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsDOMFileReader, + nsXHREventTarget) + if(tmp->mResultArrayBuffer) { + NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(tmp->mResultArrayBuffer, + "mResultArrayBuffer") + } +NS_IMPL_CYCLE_COLLECTION_TRACE_END + DOMCI_DATA(FileReader, nsDOMFileReader) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMFileReader) @@ -123,6 +135,13 @@ NS_INTERFACE_MAP_END_INHERITING(nsXHREventTarget) NS_IMPL_ADDREF_INHERITED(nsDOMFileReader, nsXHREventTarget) NS_IMPL_RELEASE_INHERITED(nsDOMFileReader, nsXHREventTarget) +//array buffer holder root/unroot +void +nsDOMFileReader::RootResultArrayBuffer() +{ + nsContentUtils::PreserveWrapper(static_cast(this), this); +} + //nsICharsetDetectionObserver NS_IMETHODIMP @@ -137,12 +156,14 @@ nsDOMFileReader::Notify(const char *aCharset, nsDetectionConfident aConf) nsDOMFileReader::nsDOMFileReader() : mFileData(nsnull), mDataLen(0), mDataFormat(FILE_AS_BINARY), + mResultArrayBuffer(nsnull), mReadyState(nsIDOMFileReader::EMPTY), mProgressEventWasDelayed(PR_FALSE), mTimerIsActive(PR_FALSE), mReadTotal(0), mReadTransferred(0) { nsLayoutStatics::AddRef(); + SetDOMStringToNull(mResult); } nsDOMFileReader::~nsDOMFileReader() @@ -235,9 +256,21 @@ nsDOMFileReader::GetReadyState(PRUint16 *aReadyState) } NS_IMETHODIMP -nsDOMFileReader::GetResult(nsAString& aResult) +nsDOMFileReader::GetResult(JSContext* aCx, jsval* aResult) { - aResult = mResult; + if (mDataFormat == FILE_AS_ARRAYBUFFER) { + if (mReadyState == nsIDOMFileReader::DONE) { + *aResult = OBJECT_TO_JSVAL(mResultArrayBuffer); + } else { + *aResult = JSVAL_NULL; + } + return NS_OK; + } + + nsString tmpResult = mResult; + if (!xpc_qsStringToJsval(aCx, tmpResult, aResult)) { + return NS_ERROR_FAILURE; + } return NS_OK; } @@ -248,23 +281,29 @@ nsDOMFileReader::GetError(nsIDOMFileError** aError) return NS_OK; } +NS_IMETHODIMP +nsDOMFileReader::ReadAsArrayBuffer(nsIDOMBlob* aFile, JSContext* aCx) +{ + return ReadFileContent(aCx, aFile, EmptyString(), FILE_AS_ARRAYBUFFER); +} + NS_IMETHODIMP nsDOMFileReader::ReadAsBinaryString(nsIDOMBlob* aFile) { - return ReadFileContent(aFile, EmptyString(), FILE_AS_BINARY); + return ReadFileContent(nsnull, aFile, EmptyString(), FILE_AS_BINARY); } NS_IMETHODIMP nsDOMFileReader::ReadAsText(nsIDOMBlob* aFile, const nsAString &aCharset) { - return ReadFileContent(aFile, aCharset, FILE_AS_TEXT); + return ReadFileContent(nsnull, aFile, aCharset, FILE_AS_TEXT); } NS_IMETHODIMP nsDOMFileReader::ReadAsDataURL(nsIDOMBlob* aFile) { - return ReadFileContent(aFile, EmptyString(), FILE_AS_DATAURL); + return ReadFileContent(nsnull, aFile, EmptyString(), FILE_AS_DATAURL); } NS_IMETHODIMP @@ -282,6 +321,7 @@ nsDOMFileReader::Abort() //Revert status, result and readystate attributes SetDOMStringToNull(mResult); + mResultArrayBuffer = nsnull; mReadyState = nsIDOMFileReader::DONE; mError = new nsDOMFileError(nsIDOMFileError::ABORT_ERR); @@ -384,6 +424,14 @@ nsDOMFileReader::OnDataAvailable(nsIRequest *aRequest, &bytesRead); NS_ASSERTION(bytesRead == aCount, "failed to read data"); } + else if (mDataFormat == FILE_AS_ARRAYBUFFER) { + js::ArrayBuffer* abuf = js::ArrayBuffer::fromJSObject(mResultArrayBuffer); + NS_ASSERTION(abuf, "What happened?"); + + PRUint32 bytesRead = 0; + aInputStream->Read((char*)abuf->data + aOffset, aCount, &bytesRead); + NS_ASSERTION(bytesRead == aCount, "failed to read data"); + } else { //Update memory buffer to reflect the contents of the file mFileData = (char *)PR_Realloc(mFileData, aOffset + aCount); @@ -439,6 +487,8 @@ nsDOMFileReader::OnStopRequest(nsIRequest *aRequest, nsresult rv = NS_OK; switch (mDataFormat) { + case FILE_AS_ARRAYBUFFER: + break; //Already accumulated mResultArrayBuffer case FILE_AS_BINARY: break; //Already accumulated mResult case FILE_AS_TEXT: @@ -468,7 +518,8 @@ nsDOMFileReader::OnStopRequest(nsIRequest *aRequest, // Helper methods nsresult -nsDOMFileReader::ReadFileContent(nsIDOMBlob* aFile, +nsDOMFileReader::ReadFileContent(JSContext* aCx, + nsIDOMBlob* aFile, const nsAString &aCharset, eDataFormat aDataFormat) { @@ -513,6 +564,15 @@ nsDOMFileReader::ReadFileContent(nsIDOMBlob* aFile, //FileReader should be in loading state here mReadyState = nsIDOMFileReader::LOADING; DispatchProgressEvent(NS_LITERAL_STRING(LOADSTART_STR)); + + if (mDataFormat == FILE_AS_ARRAYBUFFER) { + RootResultArrayBuffer(); + mResultArrayBuffer = js_CreateArrayBuffer(aCx, mReadTotal); + if (!mResultArrayBuffer) { + NS_WARNING("Failed to create JS array buffer"); + return NS_ERROR_FAILURE; + } + } return NS_OK; } diff --git a/content/base/src/nsDOMFileReader.h b/content/base/src/nsDOMFileReader.h index 5d2aa6e44bd..aa2fe54fc07 100644 --- a/content/base/src/nsDOMFileReader.h +++ b/content/base/src/nsDOMFileReader.h @@ -80,7 +80,8 @@ public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIDOMFILEREADER - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMFileReader, nsXHREventTarget) + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsDOMFileReader, + nsXHREventTarget) NS_FORWARD_NSIXMLHTTPREQUESTEVENTTARGET(nsXHREventTarget::); @@ -109,15 +110,18 @@ public: void DispatchProgressEvent(const nsAString& aType); nsresult Init(); + + void RootResultArrayBuffer(); protected: enum eDataFormat { + FILE_AS_ARRAYBUFFER, FILE_AS_BINARY, FILE_AS_TEXT, FILE_AS_DATAURL }; - nsresult ReadFileContent(nsIDOMBlob *aFile, const nsAString &aCharset, eDataFormat aDataFormat); + nsresult ReadFileContent(JSContext* aCx, nsIDOMBlob *aFile, const nsAString &aCharset, eDataFormat aDataFormat); nsresult GetAsText(const nsACString &aCharset, const char *aFileData, PRUint32 aDataLen, nsAString &aResult); nsresult GetAsDataURL(nsIDOMBlob *aFile, const char *aFileData, PRUint32 aDataLen, nsAString &aResult); @@ -139,6 +143,8 @@ protected: eDataFormat mDataFormat; + JSObject* mResultArrayBuffer; + nsString mResult; PRUint16 mReadyState; diff --git a/content/base/test/test_fileapi.html b/content/base/test/test_fileapi.html index 0930c64eee8..b5a63412929 100644 --- a/content/base/test/test_fileapi.html +++ b/content/base/test/test_fileapi.html @@ -98,6 +98,18 @@ is(onloadHasRunBinary, false, "binary loading must be async"); is(onloadStartHasRunBinary, true, "binary loadstart should fire sync"); expectedTestCount++; +var onloadHasRunArrayBuffer = false; +var onloadStartHasRunArrayBuffer = false; +r = new FileReader(); +is(r.readyState, FileReader.EMPTY, "correct initial arrayBuffer readyState"); +r.addEventListener("load", function() { onloadHasRunArrayBuffer = true }, false); +r.addEventListener("loadstart", function() { onloadStartHasRunArrayBuffer = true }, false); +r.readAsArrayBuffer(binaryFile); +r.onload = getLoadHandlerForArrayBuffer(testBinaryData, testBinaryData.length, "array buffer reading"); +is(r.readyState, FileReader.LOADING, "correct loading arrayBuffer readyState"); +is(onloadHasRunArrayBuffer, false, "arrayBuffer loading must be async"); +is(onloadStartHasRunArrayBuffer, true, "arrayBuffer loadstart should fire sync"); +expectedTestCount++; // Test a variety of encodings, and make sure they work properly r = new FileReader(); @@ -124,6 +136,14 @@ r.onload = getLoadHandler(testTextData, "utf16 reading"); expectedTestCount++; +// Test get result without reading +r = new FileReader(); +is(r.readyState, FileReader.EMPTY, + "readyState in test reader get result without reading"); +is(r.error, null, + "no error in test reader get result without reading"); +is(r.result, null, + "result in test reader get result without reading"); // Test loading an empty file works (and doesn't crash!) var emptyFile = createFileWithData(""); @@ -148,12 +168,16 @@ r.onload = getLoadHandler("", 0, "empty binary string reading"); r.readAsBinaryString(emptyFile); expectedTestCount++; +r = new FileReader(); +r.onload = getLoadHandlerForArrayBuffer("", 0, "empty array buffer reading"); +r.readAsArrayBuffer(emptyFile); +expectedTestCount++; + r = new FileReader(); r.onload = getLoadHandler(convertToDataURL(""), 0, "empt binary string reading"); r.readAsDataURL(emptyFile); expectedTestCount++; - // Test reusing a FileReader to read multiple times r = new FileReader(); r.onload = getLoadHandler(testASCIIData, @@ -203,6 +227,39 @@ r.addEventListener("load", makeAnotherReadListener3, false); r.readAsDataURL(binaryFile); expectedTestCount += 2; +r = new FileReader(); +r.onload = getLoadHandlerForArrayBuffer(testBinaryData, + testBinaryData.length, + "to-be-reused reading arrayBuffer") +var makeAnotherReadListener4 = function(event) { + r = event.target; + r.removeEventListener("load", makeAnotherReadListener4, false); + r.onload = getLoadHandlerForArrayBuffer(testBinaryData, + testBinaryData.length, + "reused reading arrayBuffer"); + r.readAsArrayBuffer(binaryFile); +}; +r.addEventListener("load", makeAnotherReadListener4, false); +r.readAsArrayBuffer(binaryFile); +expectedTestCount += 2; + +// Test first reading as ArrayBuffer then read as something else +// (BinaryString) and doesn't crash +r = new FileReader(); +r.onload = getLoadHandlerForArrayBuffer(testBinaryData, + testBinaryData.length, + "to-be-reused reading arrayBuffer") +var makeAnotherReadListener5 = function(event) { + r = event.target; + r.removeEventListener("load", makeAnotherReadListener5, false); + r.onload = getLoadHandler(testBinaryData, + testBinaryData.length, + "reused reading binary string"); + r.readAsBinaryString(binaryFile); +}; +r.addEventListener("load", makeAnotherReadListener5, false); +r.readAsArrayBuffer(binaryFile); +expectedTestCount += 2; //Test data-URI encoding on differing file sizes dataurldata = testBinaryData.substr(0, testBinaryData.length - @@ -322,9 +379,37 @@ function getLoadHandler(expectedResult, expectedLength, testName) { is(event.lengthComputable, true, "lengthComputable in test " + testName); is(event.loaded, expectedLength, - "lengthComputable in test " + testName); + "loaded in test " + testName); is(event.total, expectedLength, + "total in test " + testName); + testHasRun(); + } +} + +function getLoadHandlerForArrayBuffer(expectedResult, expectedLength, testName) { + return function (event) { + is(event.target.readyState, FileReader.DONE, + "readyState in test " + testName); + is(event.target.error, null, + "no error in test " + testName); + is(event.lengthComputable, true, "lengthComputable in test " + testName); + is(event.loaded, expectedLength, + "loaded in test " + testName); + is(event.total, expectedLength, + "total in test " + testName); + is(event.target.result.byteLength, expectedLength, + "array buffer size in test " + testName); + var u8v = new Uint8Array(event.target.result); + is(String.fromCharCode.apply(String, u8v), expectedResult, + "array buffer contents in test " + testName); + u8v = null; + SpecialPowers.gc(); + is(event.target.result.byteLength, expectedLength, + "array buffer size after gc in test " + testName); + u8v = new Uint8Array(event.target.result); + is(String.fromCharCode.apply(String, u8v), expectedResult, + "array buffer contents after gc in test " + testName); testHasRun(); } } From 8c6a326bf0bd84a7d765d20e857f1b51f5d89a79 Mon Sep 17 00:00:00 2001 From: Matheus Kerschbaum Date: Tue, 24 May 2011 07:29:46 -0500 Subject: [PATCH 4/5] Bug 659229 - Remove MOZ_ENABLE_LIBXUL checks in GfxInfoX11.cpp r=ted,Callek a=mak --- widget/src/xpwidgets/GfxInfoX11.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/widget/src/xpwidgets/GfxInfoX11.cpp b/widget/src/xpwidgets/GfxInfoX11.cpp index 546a169fa04..90e63fdc007 100644 --- a/widget/src/xpwidgets/GfxInfoX11.cpp +++ b/widget/src/xpwidgets/GfxInfoX11.cpp @@ -46,7 +46,7 @@ #include "GfxInfoX11.h" -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" #include "nsICrashReporter.h" #endif @@ -165,7 +165,7 @@ GfxInfo::GetData() mAdapterDescription.Append(nsDependentCString(buf)); mAdapterDescription.AppendLiteral("\n"); } -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#ifdef MOZ_CRASHREPORTER CrashReporter::AppendAppNotesToCrashReport(mAdapterDescription); #endif return; @@ -181,7 +181,7 @@ GfxInfo::GetData() note.Append(" -- "); note.Append(mVersion); note.Append("\n"); -#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) +#ifdef MOZ_CRASHREPORTER CrashReporter::AppendAppNotesToCrashReport(note); #endif From dd00e9d4ec12965a5670d219cd4d9b8d911f1c72 Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Tue, 24 May 2011 07:28:19 -0500 Subject: [PATCH 5/5] Bug 651093 - Don't let the file picker on Windows add to the recent doc list when in privacy mode. Also expose a prop on the interface that gives devs control over 'add to recent docs' behavior. r=dougt, sr=gavin a=mak --- dom/ipc/ContentParent.cpp | 5 ++- dom/ipc/ContentParent.h | 1 + dom/ipc/PContent.ipdl | 2 +- toolkit/components/filepicker/nsFilePicker.js | 4 ++ widget/public/nsIFilePicker.idl | 10 ++++- widget/src/windows/nsFilePicker.cpp | 45 +++++++------------ widget/src/xpwidgets/nsBaseFilePicker.cpp | 31 +++++++------ widget/src/xpwidgets/nsBaseFilePicker.h | 3 ++ widget/src/xpwidgets/nsFilePickerProxy.cpp | 3 +- 9 files changed, 56 insertions(+), 48 deletions(-) diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 2eab028f7a6..49a915065f2 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -867,6 +867,7 @@ ContentParent::RecvSetURITitle(const IPC::URI& uri, bool ContentParent::RecvShowFilePicker(const PRInt16& mode, const PRInt16& selectedType, + const PRBool& addToRecentDocs, const nsString& title, const nsString& defaultFile, const nsString& defaultExtension, @@ -892,7 +893,9 @@ ContentParent::RecvShowFilePicker(const PRInt16& mode, *result = filePicker->Init(window, title, mode); if (NS_FAILED(*result)) return true; - + + filePicker->SetAddToRecentDocs(addToRecentDocs); + PRUint32 count = filters.Length(); for (PRUint32 i = 0; i < count; ++i) { filePicker->AppendFilter(filterNames[i], filters[i]); diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 36e832106ab..44771f0781d 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -178,6 +178,7 @@ private: virtual bool RecvShowFilePicker(const PRInt16& mode, const PRInt16& selectedType, + const PRBool& addToRecentDocs, const nsString& title, const nsString& defaultFile, const nsString& defaultExtension, diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index a2ca6a04d8d..9981c8fa304 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -144,7 +144,7 @@ parent: async SetURITitle(URI uri, nsString title); // filepicker remoting - sync ShowFilePicker(PRInt16 mode, PRInt16 selectedType, + sync ShowFilePicker(PRInt16 mode, PRInt16 selectedType, PRBool addToRecentDocs, nsString title, nsString defaultFile, nsString defaultExtension, nsString[] filters, nsString[] filterNames) returns (nsString[] files, PRInt16 retValue, nsresult result); diff --git a/toolkit/components/filepicker/nsFilePicker.js b/toolkit/components/filepicker/nsFilePicker.js index c0782860feb..332bbaf4f0f 100644 --- a/toolkit/components/filepicker/nsFilePicker.js +++ b/toolkit/components/filepicker/nsFilePicker.js @@ -155,6 +155,10 @@ nsFilePicker.prototype = { set filterIndex(a) { this.mFilterIndex = a; }, get filterIndex() { return this.mFilterIndex; }, + /* attribute boolean addToRecentDocs; */ + set addToRecentDocs(a) {}, + get addToRecentDocs() { return false; }, + /* members */ mFilesEnumerator: undefined, mParentWindow: null, diff --git a/widget/public/nsIFilePicker.idl b/widget/public/nsIFilePicker.idl index 4fa41f862a5..8223ec299e8 100644 --- a/widget/public/nsIFilePicker.idl +++ b/widget/public/nsIFilePicker.idl @@ -44,7 +44,7 @@ interface nsIURI; interface nsIDOMWindow; interface nsISimpleEnumerator; -[scriptable, uuid(d24ef0aa-d555-4117-84af-9cbbb7406909)] +[scriptable, uuid(f2c0e216-5d07-4df4-bbcb-37683077ae7e)] interface nsIFilePicker : nsISupports { const short modeOpen = 0; // Load a file or directory @@ -162,6 +162,14 @@ interface nsIFilePicker : nsISupports */ readonly attribute nsISimpleEnumerator files; + /** + * Controls whether the chosen file(s) should be added to the system's recent + * documents list. This attribute will be ignored if the system has no "Recent + * Docs" concept, or if the application is in private browsing mode (in which + * case the file will not be added). Defaults to true. + */ + attribute boolean addToRecentDocs; + /** * Show File Dialog. The dialog is displayed modally. * diff --git a/widget/src/windows/nsFilePicker.cpp b/widget/src/windows/nsFilePicker.cpp index 653c1b891fc..4ce495bef40 100644 --- a/widget/src/windows/nsFilePicker.cpp +++ b/widget/src/windows/nsFilePicker.cpp @@ -46,6 +46,7 @@ #include "nsIServiceManager.h" #include "nsIPlatformCharset.h" #include "nsICharsetConverterManager.h" +#include "nsIPrivateBrowsingService.h" #include "nsFilePicker.h" #include "nsILocalFile.h" #include "nsIURL.h" @@ -69,21 +70,11 @@ char nsFilePicker::mLastUsedDirectory[MAX_PATH+1] = { 0 }; #define MAX_EXTENSION_LENGTH 10 -//------------------------------------------------------------------------- -// -// nsFilePicker constructor -// -//------------------------------------------------------------------------- nsFilePicker::nsFilePicker() { mSelectedType = 1; } -//------------------------------------------------------------------------- -// -// nsFilePicker destructor -// -//------------------------------------------------------------------------- nsFilePicker::~nsFilePicker() { if (mLastUsedUnicodeDirectory) { @@ -92,12 +83,7 @@ nsFilePicker::~nsFilePicker() } } -//------------------------------------------------------------------------- -// // Show - Display the file dialog -// -//------------------------------------------------------------------------- - int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) { if (uMsg == BFFM_INITIALIZED) @@ -195,7 +181,20 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal) ofn.lpstrFile = fileBuffer; ofn.nMaxFile = FILE_BUFFER_SIZE; - ofn.Flags = OFN_NOCHANGEDIR | OFN_SHAREAWARE | OFN_LONGNAMES | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; + ofn.Flags = OFN_NOCHANGEDIR | OFN_SHAREAWARE | + OFN_LONGNAMES | OFN_OVERWRITEPROMPT | + OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; + + // Handle add to recent docs settings + nsCOMPtr pbs = + do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID); + PRBool privacyModeEnabled = PR_FALSE; + if (pbs) { + pbs->GetPrivateBrowsingEnabled(&privacyModeEnabled); + } + if (privacyModeEnabled || !mAddToRecentDocs) { + ofn.Flags |= OFN_DONTADDTORECENT; + } if (!mDefaultExtension.IsEmpty()) { ofn.lpstrDefExt = mDefaultExtension.get(); @@ -405,7 +404,6 @@ NS_IMETHODIMP nsFilePicker::GetFile(nsILocalFile **aFile) return NS_OK; } -//------------------------------------------------------------------------- NS_IMETHODIMP nsFilePicker::GetFileURL(nsIURI **aFileURL) { *aFileURL = nsnull; @@ -423,11 +421,7 @@ NS_IMETHODIMP nsFilePicker::GetFiles(nsISimpleEnumerator **aFiles) return NS_NewArrayEnumerator(aFiles, mFiles); } -//------------------------------------------------------------------------- -// // Get the file + path -// -//------------------------------------------------------------------------- NS_IMETHODIMP nsFilePicker::SetDefaultString(const nsAString& aString) { mDefault = aString; @@ -465,11 +459,7 @@ NS_IMETHODIMP nsFilePicker::GetDefaultString(nsAString& aString) return NS_ERROR_FAILURE; } -//------------------------------------------------------------------------- -// // The default extension to use for files -// -//------------------------------------------------------------------------- NS_IMETHODIMP nsFilePicker::GetDefaultExtension(nsAString& aExtension) { aExtension = mDefaultExtension; @@ -482,11 +472,7 @@ NS_IMETHODIMP nsFilePicker::SetDefaultExtension(const nsAString& aExtension) return NS_OK; } -//------------------------------------------------------------------------- -// // Set the filter index -// -//------------------------------------------------------------------------- NS_IMETHODIMP nsFilePicker::GetFilterIndex(PRInt32 *aFilterIndex) { // Windows' filter index is 1-based, we use a 0-based system. @@ -501,7 +487,6 @@ NS_IMETHODIMP nsFilePicker::SetFilterIndex(PRInt32 aFilterIndex) return NS_OK; } -//------------------------------------------------------------------------- void nsFilePicker::InitNative(nsIWidget *aParent, const nsAString& aTitle, PRInt16 aMode) diff --git a/widget/src/xpwidgets/nsBaseFilePicker.cpp b/widget/src/xpwidgets/nsBaseFilePicker.cpp index 319338ec7ec..9cb5a00d53a 100644 --- a/widget/src/xpwidgets/nsBaseFilePicker.cpp +++ b/widget/src/xpwidgets/nsBaseFilePicker.cpp @@ -64,7 +64,8 @@ using namespace mozilla::widget; #define FILEPICKER_TITLES "chrome://global/locale/filepicker.properties" #define FILEPICKER_FILTERS "chrome://global/content/filepicker.properties" -nsBaseFilePicker::nsBaseFilePicker() +nsBaseFilePicker::nsBaseFilePicker() : + mAddToRecentDocs(PR_TRUE) { } @@ -74,7 +75,6 @@ nsBaseFilePicker::~nsBaseFilePicker() } -//------------------------------------------------------------------------- NS_IMETHODIMP nsBaseFilePicker::Init(nsIDOMWindow *aParent, const nsAString& aTitle, PRInt16 aMode) @@ -161,11 +161,7 @@ nsBaseFilePicker::AppendFilters(PRInt32 aFilterMask) return NS_OK; } -//------------------------------------------------------------------------- -// // Set the filter index -// -//------------------------------------------------------------------------- NS_IMETHODIMP nsBaseFilePicker::GetFilterIndex(PRInt32 *aFilterIndex) { *aFilterIndex = 0; @@ -197,11 +193,8 @@ NS_IMETHODIMP nsBaseFilePicker::GetFiles(nsISimpleEnumerator **aFiles) } #ifdef BASEFILEPICKER_HAS_DISPLAYDIRECTORY -//------------------------------------------------------------------------- -// + // Set the display directory -// -//------------------------------------------------------------------------- NS_IMETHODIMP nsBaseFilePicker::SetDisplayDirectory(nsILocalFile *aDirectory) { if (!aDirectory) { @@ -216,11 +209,7 @@ NS_IMETHODIMP nsBaseFilePicker::SetDisplayDirectory(nsILocalFile *aDirectory) return rv; } -//------------------------------------------------------------------------- -// // Get the display directory -// -//------------------------------------------------------------------------- NS_IMETHODIMP nsBaseFilePicker::GetDisplayDirectory(nsILocalFile **aDirectory) { *aDirectory = nsnull; @@ -233,3 +222,17 @@ NS_IMETHODIMP nsBaseFilePicker::GetDisplayDirectory(nsILocalFile **aDirectory) return CallQueryInterface(directory, aDirectory); } #endif + +NS_IMETHODIMP +nsBaseFilePicker::GetAddToRecentDocs(PRBool *aFlag) +{ + *aFlag = mAddToRecentDocs; + return NS_OK; +} + +NS_IMETHODIMP +nsBaseFilePicker::SetAddToRecentDocs(PRBool aFlag) +{ + mAddToRecentDocs = aFlag; + return NS_OK; +} diff --git a/widget/src/xpwidgets/nsBaseFilePicker.h b/widget/src/xpwidgets/nsBaseFilePicker.h index 01a3bb3cbb4..63df5338873 100644 --- a/widget/src/xpwidgets/nsBaseFilePicker.h +++ b/widget/src/xpwidgets/nsBaseFilePicker.h @@ -69,12 +69,15 @@ public: NS_IMETHOD GetDisplayDirectory(nsILocalFile * *aDisplayDirectory); NS_IMETHOD SetDisplayDirectory(nsILocalFile * aDisplayDirectory); #endif + NS_IMETHOD GetAddToRecentDocs(PRBool *aFlag); + NS_IMETHOD SetAddToRecentDocs(PRBool aFlag); protected: virtual void InitNative(nsIWidget *aParent, const nsAString& aTitle, PRInt16 aMode) = 0; + PRBool mAddToRecentDocs; #ifdef BASEFILEPICKER_HAS_DISPLAYDIRECTORY nsCOMPtr mDisplayDirectory; #endif diff --git a/widget/src/xpwidgets/nsFilePickerProxy.cpp b/widget/src/xpwidgets/nsFilePickerProxy.cpp index d3148729b87..e0a6aa3d7fe 100644 --- a/widget/src/xpwidgets/nsFilePickerProxy.cpp +++ b/widget/src/xpwidgets/nsFilePickerProxy.cpp @@ -175,7 +175,8 @@ NS_IMETHODIMP nsFilePickerProxy::Show(PRInt16* aReturn) InfallibleTArray filePaths; nsresult rv; - cc->SendShowFilePicker(mMode, mSelectedType, mTitle, + cc->SendShowFilePicker(mMode, mSelectedType, + mAddToRecentDocs, mTitle, mDefault, mDefaultExtension, mFilters, mFilterNames, &filePaths, aReturn, &rv);