This commit is contained in:
Mounir Lamouri 2011-05-24 15:40:28 +02:00
Родитель b1ac5604f9 dd00e9d4ec
Коммит 77a4b8a2cf
25 изменённых файлов: 309 добавлений и 90 удалений

Просмотреть файл

@ -315,6 +315,7 @@ WARNINGS_AS_ERRORS = @WARNINGS_AS_ERRORS@
MOZ_OPTIMIZE = @MOZ_OPTIMIZE@ MOZ_OPTIMIZE = @MOZ_OPTIMIZE@
MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@ MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@
MOZ_PGO_OPTIMIZE_FLAGS = @MOZ_PGO_OPTIMIZE_FLAGS@
MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@ MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@
MOZ_OPTIMIZE_SIZE_TWEAK = @MOZ_OPTIMIZE_SIZE_TWEAK@ MOZ_OPTIMIZE_SIZE_TWEAK = @MOZ_OPTIMIZE_SIZE_TWEAK@

Просмотреть файл

@ -422,8 +422,13 @@ ifdef MODULE_OPTIMIZE_FLAGS
CFLAGS += $(MODULE_OPTIMIZE_FLAGS) CFLAGS += $(MODULE_OPTIMIZE_FLAGS)
CXXFLAGS += $(MODULE_OPTIMIZE_FLAGS) CXXFLAGS += $(MODULE_OPTIMIZE_FLAGS)
else else
ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
CFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS)
CXXFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS)
else
CFLAGS += $(MOZ_OPTIMIZE_FLAGS) CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS) CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS)
endif # neq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
endif # MODULE_OPTIMIZE_FLAGS endif # MODULE_OPTIMIZE_FLAGS
else else
CFLAGS += $(MOZ_OPTIMIZE_FLAGS) CFLAGS += $(MOZ_OPTIMIZE_FLAGS)

Просмотреть файл

@ -2188,10 +2188,12 @@ ia64*-hpux*)
esac esac
# If we're building with --enable-profiling, we need a frame pointer. # If we're building with --enable-profiling, we need a frame pointer.
if test -z "$MOZ_PROFILING"; then if test -z "$MOZ_PROFILING"; then
MOZ_OPTIMIZE_FLAGS="-O3 -fomit-frame-pointer" MOZ_FRAMEPTR_FLAGS="-fomit-frame-pointer"
else else
MOZ_OPTIMIZE_FLAGS="-O3 -fno-omit-frame-pointer" MOZ_FRAMEPTR_FLAGS="-fno-omit-frame-pointer"
fi 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" MOZ_DEBUG_FLAGS="-g"
fi fi
@ -7183,6 +7185,7 @@ AC_SUBST(MOZ_OPTIMIZE)
AC_SUBST(MOZ_OPTIMIZE_FLAGS) AC_SUBST(MOZ_OPTIMIZE_FLAGS)
AC_SUBST(MOZ_OPTIMIZE_LDFLAGS) AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK) AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS)
dnl ======================================================== dnl ========================================================
dnl = Enable generation of debug symbols dnl = Enable generation of debug symbols

Просмотреть файл

@ -41,9 +41,11 @@ interface nsIDOMEventListener;
interface nsIDOMBlob; interface nsIDOMBlob;
interface nsIDOMFileError; interface nsIDOMFileError;
[scriptable, uuid(f186170f-f07c-4f0b-9e3c-08f7dd496e74)] [scriptable, uuid(3d77e784-1459-4206-b8a2-0855d826f569)]
interface nsIDOMFileReader : nsISupports interface nsIDOMFileReader : nsISupports
{ {
[implicit_jscontext]
void readAsArrayBuffer(in nsIDOMBlob filedata);
void readAsBinaryString(in nsIDOMBlob filedata); void readAsBinaryString(in nsIDOMBlob filedata);
void readAsText(in nsIDOMBlob filedata, [optional] in DOMString encoding); void readAsText(in nsIDOMBlob filedata, [optional] in DOMString encoding);
void readAsDataURL(in nsIDOMBlob file); void readAsDataURL(in nsIDOMBlob file);
@ -55,7 +57,8 @@ interface nsIDOMFileReader : nsISupports
const unsigned short DONE = 2; const unsigned short DONE = 2;
readonly attribute unsigned short readyState; readonly attribute unsigned short readyState;
readonly attribute DOMString result; [implicit_jscontext]
readonly attribute jsval result;
readonly attribute nsIDOMFileError error; readonly attribute nsIDOMFileError error;
}; };

Просмотреть файл

@ -77,6 +77,9 @@
#include "nsLayoutStatics.h" #include "nsLayoutStatics.h"
#include "nsIScriptObjectPrincipal.h" #include "nsIScriptObjectPrincipal.h"
#include "nsFileDataProtocolHandler.h" #include "nsFileDataProtocolHandler.h"
#include "xpcprivate.h"
#include "xpcquickstubs.h"
#include "jstypedarray.h"
#define LOAD_STR "load" #define LOAD_STR "load"
#define ERROR_STR "error" #define ERROR_STR "error"
@ -101,12 +104,21 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMFileReader, NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMFileReader,
nsXHREventTarget) nsXHREventTarget)
tmp->mResultArrayBuffer = nsnull;
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFile) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFile)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mProgressNotifier) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mProgressNotifier)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mPrincipal) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mPrincipal)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChannel) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChannel)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END 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) DOMCI_DATA(FileReader, nsDOMFileReader)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(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_ADDREF_INHERITED(nsDOMFileReader, nsXHREventTarget)
NS_IMPL_RELEASE_INHERITED(nsDOMFileReader, nsXHREventTarget) NS_IMPL_RELEASE_INHERITED(nsDOMFileReader, nsXHREventTarget)
//array buffer holder root/unroot
void
nsDOMFileReader::RootResultArrayBuffer()
{
nsContentUtils::PreserveWrapper(static_cast<nsPIDOMEventTarget*>(this), this);
}
//nsICharsetDetectionObserver //nsICharsetDetectionObserver
NS_IMETHODIMP NS_IMETHODIMP
@ -137,12 +156,14 @@ nsDOMFileReader::Notify(const char *aCharset, nsDetectionConfident aConf)
nsDOMFileReader::nsDOMFileReader() nsDOMFileReader::nsDOMFileReader()
: mFileData(nsnull), : mFileData(nsnull),
mDataLen(0), mDataFormat(FILE_AS_BINARY), mDataLen(0), mDataFormat(FILE_AS_BINARY),
mResultArrayBuffer(nsnull),
mReadyState(nsIDOMFileReader::EMPTY), mReadyState(nsIDOMFileReader::EMPTY),
mProgressEventWasDelayed(PR_FALSE), mProgressEventWasDelayed(PR_FALSE),
mTimerIsActive(PR_FALSE), mTimerIsActive(PR_FALSE),
mReadTotal(0), mReadTransferred(0) mReadTotal(0), mReadTransferred(0)
{ {
nsLayoutStatics::AddRef(); nsLayoutStatics::AddRef();
SetDOMStringToNull(mResult);
} }
nsDOMFileReader::~nsDOMFileReader() nsDOMFileReader::~nsDOMFileReader()
@ -235,9 +256,21 @@ nsDOMFileReader::GetReadyState(PRUint16 *aReadyState)
} }
NS_IMETHODIMP 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; return NS_OK;
} }
@ -248,23 +281,29 @@ nsDOMFileReader::GetError(nsIDOMFileError** aError)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsDOMFileReader::ReadAsArrayBuffer(nsIDOMBlob* aFile, JSContext* aCx)
{
return ReadFileContent(aCx, aFile, EmptyString(), FILE_AS_ARRAYBUFFER);
}
NS_IMETHODIMP NS_IMETHODIMP
nsDOMFileReader::ReadAsBinaryString(nsIDOMBlob* aFile) nsDOMFileReader::ReadAsBinaryString(nsIDOMBlob* aFile)
{ {
return ReadFileContent(aFile, EmptyString(), FILE_AS_BINARY); return ReadFileContent(nsnull, aFile, EmptyString(), FILE_AS_BINARY);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMFileReader::ReadAsText(nsIDOMBlob* aFile, nsDOMFileReader::ReadAsText(nsIDOMBlob* aFile,
const nsAString &aCharset) const nsAString &aCharset)
{ {
return ReadFileContent(aFile, aCharset, FILE_AS_TEXT); return ReadFileContent(nsnull, aFile, aCharset, FILE_AS_TEXT);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDOMFileReader::ReadAsDataURL(nsIDOMBlob* aFile) nsDOMFileReader::ReadAsDataURL(nsIDOMBlob* aFile)
{ {
return ReadFileContent(aFile, EmptyString(), FILE_AS_DATAURL); return ReadFileContent(nsnull, aFile, EmptyString(), FILE_AS_DATAURL);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -282,6 +321,7 @@ nsDOMFileReader::Abort()
//Revert status, result and readystate attributes //Revert status, result and readystate attributes
SetDOMStringToNull(mResult); SetDOMStringToNull(mResult);
mResultArrayBuffer = nsnull;
mReadyState = nsIDOMFileReader::DONE; mReadyState = nsIDOMFileReader::DONE;
mError = new nsDOMFileError(nsIDOMFileError::ABORT_ERR); mError = new nsDOMFileError(nsIDOMFileError::ABORT_ERR);
@ -384,6 +424,14 @@ nsDOMFileReader::OnDataAvailable(nsIRequest *aRequest,
&bytesRead); &bytesRead);
NS_ASSERTION(bytesRead == aCount, "failed to read data"); 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 { else {
//Update memory buffer to reflect the contents of the file //Update memory buffer to reflect the contents of the file
mFileData = (char *)PR_Realloc(mFileData, aOffset + aCount); mFileData = (char *)PR_Realloc(mFileData, aOffset + aCount);
@ -439,6 +487,8 @@ nsDOMFileReader::OnStopRequest(nsIRequest *aRequest,
nsresult rv = NS_OK; nsresult rv = NS_OK;
switch (mDataFormat) { switch (mDataFormat) {
case FILE_AS_ARRAYBUFFER:
break; //Already accumulated mResultArrayBuffer
case FILE_AS_BINARY: case FILE_AS_BINARY:
break; //Already accumulated mResult break; //Already accumulated mResult
case FILE_AS_TEXT: case FILE_AS_TEXT:
@ -468,7 +518,8 @@ nsDOMFileReader::OnStopRequest(nsIRequest *aRequest,
// Helper methods // Helper methods
nsresult nsresult
nsDOMFileReader::ReadFileContent(nsIDOMBlob* aFile, nsDOMFileReader::ReadFileContent(JSContext* aCx,
nsIDOMBlob* aFile,
const nsAString &aCharset, const nsAString &aCharset,
eDataFormat aDataFormat) eDataFormat aDataFormat)
{ {
@ -513,6 +564,15 @@ nsDOMFileReader::ReadFileContent(nsIDOMBlob* aFile,
//FileReader should be in loading state here //FileReader should be in loading state here
mReadyState = nsIDOMFileReader::LOADING; mReadyState = nsIDOMFileReader::LOADING;
DispatchProgressEvent(NS_LITERAL_STRING(LOADSTART_STR)); 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; return NS_OK;
} }

Просмотреть файл

@ -80,7 +80,8 @@ public:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMFILEREADER 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::); NS_FORWARD_NSIXMLHTTPREQUESTEVENTTARGET(nsXHREventTarget::);
@ -109,15 +110,18 @@ public:
void DispatchProgressEvent(const nsAString& aType); void DispatchProgressEvent(const nsAString& aType);
nsresult Init(); nsresult Init();
void RootResultArrayBuffer();
protected: protected:
enum eDataFormat { enum eDataFormat {
FILE_AS_ARRAYBUFFER,
FILE_AS_BINARY, FILE_AS_BINARY,
FILE_AS_TEXT, FILE_AS_TEXT,
FILE_AS_DATAURL 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, nsresult GetAsText(const nsACString &aCharset,
const char *aFileData, PRUint32 aDataLen, nsAString &aResult); const char *aFileData, PRUint32 aDataLen, nsAString &aResult);
nsresult GetAsDataURL(nsIDOMBlob *aFile, 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; eDataFormat mDataFormat;
JSObject* mResultArrayBuffer;
nsString mResult; nsString mResult;
PRUint16 mReadyState; PRUint16 mReadyState;

Просмотреть файл

@ -426,7 +426,8 @@ nsXMLHttpRequest::nsXMLHttpRequest()
mErrorLoad(PR_FALSE), mTimerIsActive(PR_FALSE), mErrorLoad(PR_FALSE), mTimerIsActive(PR_FALSE),
mProgressEventWasDelayed(PR_FALSE), mProgressEventWasDelayed(PR_FALSE),
mLoadLengthComputable(PR_FALSE), mLoadTotal(0), mLoadLengthComputable(PR_FALSE), mLoadTotal(0),
mFirstStartRequestSeen(PR_FALSE) mFirstStartRequestSeen(PR_FALSE),
mResultArrayBuffer(nsnull)
{ {
mResponseBodyUnicode.SetIsVoid(PR_TRUE); mResponseBodyUnicode.SetIsVoid(PR_TRUE);
nsLayoutStatics::AddRef(); nsLayoutStatics::AddRef();
@ -450,6 +451,12 @@ nsXMLHttpRequest::~nsXMLHttpRequest()
nsLayoutStatics::Release(); nsLayoutStatics::Release();
} }
void
nsXMLHttpRequest::RootResultArrayBuffer()
{
nsContentUtils::PreserveWrapper(static_cast<nsPIDOMEventTarget*>(this), this);
}
/** /**
* This Init method is called from the factory constructor. * This Init method is called from the factory constructor.
*/ */
@ -572,9 +579,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXMLHttpRequest,
nsIXMLHttpRequestUpload) nsIXMLHttpRequestUpload)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXMLHttpRequest, NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXMLHttpRequest,
nsXHREventTarget) nsXHREventTarget)
tmp->mResultArrayBuffer = nsnull;
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mContext) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mContext)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChannel) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChannel)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mReadRequest) 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_NSCOMPTR(mUpload)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END 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) DOMCI_DATA(XMLHttpRequest, nsXMLHttpRequest)
// QueryInterface implementation for nsXMLHttpRequest // QueryInterface implementation for nsXMLHttpRequest
@ -839,27 +854,20 @@ NS_IMETHODIMP nsXMLHttpRequest::GetResponseText(nsAString& aResponseText)
return rv; return rv;
} }
nsresult nsXMLHttpRequest::GetResponseArrayBuffer(jsval *aResult) nsresult nsXMLHttpRequest::CreateResponseArrayBuffer(JSContext *aCx)
{ {
JSContext *cx = nsContentUtils::GetCurrentJSContext(); if (!aCx)
if (!cx)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
if (!(mState & (XML_HTTP_REQUEST_DONE |
XML_HTTP_REQUEST_LOADING))) {
*aResult = JSVAL_NULL;
return NS_OK;
}
PRInt32 dataLen = mResponseBody.Length(); PRInt32 dataLen = mResponseBody.Length();
JSObject *obj = js_CreateArrayBuffer(cx, dataLen); RootResultArrayBuffer();
if (!obj) mResultArrayBuffer = js_CreateArrayBuffer(aCx, dataLen);
if (!mResultArrayBuffer) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
}
*aResult = OBJECT_TO_JSVAL(obj);
if (dataLen > 0) { if (dataLen > 0) {
js::ArrayBuffer *abuf = js::ArrayBuffer::fromJSObject(obj); js::ArrayBuffer *abuf = js::ArrayBuffer::fromJSObject(mResultArrayBuffer);
NS_ASSERTION(abuf, "What happened?"); NS_ASSERTION(abuf, "What happened?");
memcpy(abuf->data, mResponseBody.BeginReading(), dataLen); memcpy(abuf->data, mResponseBody.BeginReading(), dataLen);
} }
@ -954,7 +962,11 @@ NS_IMETHODIMP nsXMLHttpRequest::GetResponse(JSContext *aCx, jsval *aResult)
case XML_HTTP_RESPONSE_TYPE_ARRAYBUFFER: case XML_HTTP_RESPONSE_TYPE_ARRAYBUFFER:
if (mState & XML_HTTP_REQUEST_DONE) { 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 { } else {
*aResult = JSVAL_NULL; *aResult = JSVAL_NULL;
} }
@ -1073,7 +1085,8 @@ nsXMLHttpRequest::Abort()
mResponseBodyUnicode.SetIsVoid(PR_TRUE); mResponseBodyUnicode.SetIsVoid(PR_TRUE);
mResponseBlob = nsnull; mResponseBlob = nsnull;
mState |= XML_HTTP_REQUEST_ABORTED; mState |= XML_HTTP_REQUEST_ABORTED;
mResultArrayBuffer = nsnull;
if (!(mState & (XML_HTTP_REQUEST_UNSENT | if (!(mState & (XML_HTTP_REQUEST_UNSENT |
XML_HTTP_REQUEST_OPENED | XML_HTTP_REQUEST_OPENED |
XML_HTTP_REQUEST_DONE))) { XML_HTTP_REQUEST_DONE))) {

Просмотреть файл

@ -208,11 +208,11 @@ public:
void SetRequestObserver(nsIRequestObserver* aObserver); void SetRequestObserver(nsIRequestObserver* aObserver);
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXMLHttpRequest, NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsXMLHttpRequest,
nsXHREventTarget) nsXHREventTarget)
PRBool AllowUploadProgress(); PRBool AllowUploadProgress();
void RootResultArrayBuffer();
protected: protected:
friend class nsMultipartProxyListener; friend class nsMultipartProxyListener;
@ -224,7 +224,7 @@ protected:
PRUint32 toOffset, PRUint32 toOffset,
PRUint32 count, PRUint32 count,
PRUint32 *writeCount); PRUint32 *writeCount);
nsresult GetResponseArrayBuffer(jsval *aResult); nsresult CreateResponseArrayBuffer(JSContext* aCx);
void CreateResponseBlob(nsIRequest *request); void CreateResponseBlob(nsIRequest *request);
// Change the state of the object with this. The broadcast argument // Change the state of the object with this. The broadcast argument
// determines if the onreadystatechange listener should be called. // determines if the onreadystatechange listener should be called.
@ -345,6 +345,8 @@ protected:
nsCOMPtr<nsIAsyncVerifyRedirectCallback> mRedirectCallback; nsCOMPtr<nsIAsyncVerifyRedirectCallback> mRedirectCallback;
nsCOMPtr<nsIChannel> mNewRedirectChannel; nsCOMPtr<nsIChannel> mNewRedirectChannel;
JSObject* mResultArrayBuffer;
}; };
// helper class to expose a progress DOM Event // helper class to expose a progress DOM Event

Просмотреть файл

@ -134,6 +134,16 @@ ab = xhr.response;
ok(ab != null, "should have a non-null arraybuffer"); 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"); 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') // test response (responseType='blob')
var onloadCount = 0; var onloadCount = 0;
function checkOnloadCount() { function checkOnloadCount() {

Просмотреть файл

@ -98,6 +98,18 @@ is(onloadHasRunBinary, false, "binary loading must be async");
is(onloadStartHasRunBinary, true, "binary loadstart should fire sync"); is(onloadStartHasRunBinary, true, "binary loadstart should fire sync");
expectedTestCount++; 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 // Test a variety of encodings, and make sure they work properly
r = new FileReader(); r = new FileReader();
@ -124,6 +136,14 @@ r.onload = getLoadHandler(testTextData,
"utf16 reading"); "utf16 reading");
expectedTestCount++; 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!) // Test loading an empty file works (and doesn't crash!)
var emptyFile = createFileWithData(""); var emptyFile = createFileWithData("");
@ -148,12 +168,16 @@ r.onload = getLoadHandler("", 0, "empty binary string reading");
r.readAsBinaryString(emptyFile); r.readAsBinaryString(emptyFile);
expectedTestCount++; expectedTestCount++;
r = new FileReader();
r.onload = getLoadHandlerForArrayBuffer("", 0, "empty array buffer reading");
r.readAsArrayBuffer(emptyFile);
expectedTestCount++;
r = new FileReader(); r = new FileReader();
r.onload = getLoadHandler(convertToDataURL(""), 0, "empt binary string reading"); r.onload = getLoadHandler(convertToDataURL(""), 0, "empt binary string reading");
r.readAsDataURL(emptyFile); r.readAsDataURL(emptyFile);
expectedTestCount++; expectedTestCount++;
// Test reusing a FileReader to read multiple times // Test reusing a FileReader to read multiple times
r = new FileReader(); r = new FileReader();
r.onload = getLoadHandler(testASCIIData, r.onload = getLoadHandler(testASCIIData,
@ -203,6 +227,39 @@ r.addEventListener("load", makeAnotherReadListener3, false);
r.readAsDataURL(binaryFile); r.readAsDataURL(binaryFile);
expectedTestCount += 2; 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 //Test data-URI encoding on differing file sizes
dataurldata = testBinaryData.substr(0, testBinaryData.length - dataurldata = testBinaryData.substr(0, testBinaryData.length -
@ -322,9 +379,37 @@ function getLoadHandler(expectedResult, expectedLength, testName) {
is(event.lengthComputable, true, is(event.lengthComputable, true,
"lengthComputable in test " + testName); "lengthComputable in test " + testName);
is(event.loaded, expectedLength, is(event.loaded, expectedLength,
"lengthComputable in test " + testName); "loaded in test " + testName);
is(event.total, expectedLength, 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); "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(); testHasRun();
} }
} }

Просмотреть файл

@ -867,6 +867,7 @@ ContentParent::RecvSetURITitle(const IPC::URI& uri,
bool bool
ContentParent::RecvShowFilePicker(const PRInt16& mode, ContentParent::RecvShowFilePicker(const PRInt16& mode,
const PRInt16& selectedType, const PRInt16& selectedType,
const PRBool& addToRecentDocs,
const nsString& title, const nsString& title,
const nsString& defaultFile, const nsString& defaultFile,
const nsString& defaultExtension, const nsString& defaultExtension,
@ -892,7 +893,9 @@ ContentParent::RecvShowFilePicker(const PRInt16& mode,
*result = filePicker->Init(window, title, mode); *result = filePicker->Init(window, title, mode);
if (NS_FAILED(*result)) if (NS_FAILED(*result))
return true; return true;
filePicker->SetAddToRecentDocs(addToRecentDocs);
PRUint32 count = filters.Length(); PRUint32 count = filters.Length();
for (PRUint32 i = 0; i < count; ++i) { for (PRUint32 i = 0; i < count; ++i) {
filePicker->AppendFilter(filterNames[i], filters[i]); filePicker->AppendFilter(filterNames[i], filters[i]);

Просмотреть файл

@ -178,6 +178,7 @@ private:
virtual bool RecvShowFilePicker(const PRInt16& mode, virtual bool RecvShowFilePicker(const PRInt16& mode,
const PRInt16& selectedType, const PRInt16& selectedType,
const PRBool& addToRecentDocs,
const nsString& title, const nsString& title,
const nsString& defaultFile, const nsString& defaultFile,
const nsString& defaultExtension, const nsString& defaultExtension,

Просмотреть файл

@ -144,7 +144,7 @@ parent:
async SetURITitle(URI uri, nsString title); async SetURITitle(URI uri, nsString title);
// filepicker remoting // filepicker remoting
sync ShowFilePicker(PRInt16 mode, PRInt16 selectedType, sync ShowFilePicker(PRInt16 mode, PRInt16 selectedType, PRBool addToRecentDocs,
nsString title, nsString defaultFile, nsString defaultExtension, nsString title, nsString defaultFile, nsString defaultExtension,
nsString[] filters, nsString[] filterNames) nsString[] filters, nsString[] filterNames)
returns (nsString[] files, PRInt16 retValue, nsresult result); returns (nsString[] files, PRInt16 retValue, nsresult result);

Просмотреть файл

@ -145,6 +145,7 @@ FAIL_ON_WARNINGS = @FAIL_ON_WARNINGS@
MOZ_OPTIMIZE = @MOZ_OPTIMIZE@ MOZ_OPTIMIZE = @MOZ_OPTIMIZE@
MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@ MOZ_OPTIMIZE_FLAGS = @MOZ_OPTIMIZE_FLAGS@
MOZ_PGO_OPTIMIZE_FLAGS = @MOZ_PGO_OPTIMIZE_FLAGS@
MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@ MOZ_OPTIMIZE_LDFLAGS = @MOZ_OPTIMIZE_LDFLAGS@
MOZ_OPTIMIZE_SIZE_TWEAK = @MOZ_OPTIMIZE_SIZE_TWEAK@ MOZ_OPTIMIZE_SIZE_TWEAK = @MOZ_OPTIMIZE_SIZE_TWEAK@

Просмотреть файл

@ -422,8 +422,13 @@ ifdef MODULE_OPTIMIZE_FLAGS
CFLAGS += $(MODULE_OPTIMIZE_FLAGS) CFLAGS += $(MODULE_OPTIMIZE_FLAGS)
CXXFLAGS += $(MODULE_OPTIMIZE_FLAGS) CXXFLAGS += $(MODULE_OPTIMIZE_FLAGS)
else else
ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
CFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS)
CXXFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS)
else
CFLAGS += $(MOZ_OPTIMIZE_FLAGS) CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS) CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS)
endif # neq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
endif # MODULE_OPTIMIZE_FLAGS endif # MODULE_OPTIMIZE_FLAGS
else else
CFLAGS += $(MOZ_OPTIMIZE_FLAGS) CFLAGS += $(MOZ_OPTIMIZE_FLAGS)

Просмотреть файл

@ -2102,10 +2102,12 @@ ia64*-hpux*)
esac esac
# If we're building with --enable-profiling, we need a frame pointer. # If we're building with --enable-profiling, we need a frame pointer.
if test -z "$MOZ_PROFILING"; then if test -z "$MOZ_PROFILING"; then
MOZ_OPTIMIZE_FLAGS="-O3 -fomit-frame-pointer" MOZ_FRAMEPTR_FLAGS="-fomit-frame-pointer"
else else
MOZ_OPTIMIZE_FLAGS="-O3 -fno-omit-frame-pointer" MOZ_FRAMEPTR_FLAGS="-fno-omit-frame-pointer"
fi 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" MOZ_DEBUG_FLAGS="-g"
fi fi
@ -4617,6 +4619,7 @@ AC_SUBST(MOZ_OPTIMIZE)
AC_SUBST(MOZ_OPTIMIZE_FLAGS) AC_SUBST(MOZ_OPTIMIZE_FLAGS)
AC_SUBST(MOZ_OPTIMIZE_LDFLAGS) AC_SUBST(MOZ_OPTIMIZE_LDFLAGS)
AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK) AC_SUBST(MOZ_OPTIMIZE_SIZE_TWEAK)
AC_SUBST(MOZ_PGO_OPTIMIZE_FLAGS)
dnl ======================================================== dnl ========================================================
dnl = Enable generation of debug symbols dnl = Enable generation of debug symbols

Просмотреть файл

@ -155,6 +155,10 @@ nsFilePicker.prototype = {
set filterIndex(a) { this.mFilterIndex = a; }, set filterIndex(a) { this.mFilterIndex = a; },
get filterIndex() { return this.mFilterIndex; }, get filterIndex() { return this.mFilterIndex; },
/* attribute boolean addToRecentDocs; */
set addToRecentDocs(a) {},
get addToRecentDocs() { return false; },
/* members */ /* members */
mFilesEnumerator: undefined, mFilesEnumerator: undefined,
mParentWindow: null, mParentWindow: null,

Просмотреть файл

@ -44,7 +44,7 @@ interface nsIURI;
interface nsIDOMWindow; interface nsIDOMWindow;
interface nsISimpleEnumerator; interface nsISimpleEnumerator;
[scriptable, uuid(d24ef0aa-d555-4117-84af-9cbbb7406909)] [scriptable, uuid(f2c0e216-5d07-4df4-bbcb-37683077ae7e)]
interface nsIFilePicker : nsISupports interface nsIFilePicker : nsISupports
{ {
const short modeOpen = 0; // Load a file or directory const short modeOpen = 0; // Load a file or directory
@ -162,6 +162,14 @@ interface nsIFilePicker : nsISupports
*/ */
readonly attribute nsISimpleEnumerator files; 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. * Show File Dialog. The dialog is displayed modally.
* *

Просмотреть файл

@ -46,6 +46,7 @@
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsIPlatformCharset.h" #include "nsIPlatformCharset.h"
#include "nsICharsetConverterManager.h" #include "nsICharsetConverterManager.h"
#include "nsIPrivateBrowsingService.h"
#include "nsFilePicker.h" #include "nsFilePicker.h"
#include "nsILocalFile.h" #include "nsILocalFile.h"
#include "nsIURL.h" #include "nsIURL.h"
@ -69,21 +70,11 @@ char nsFilePicker::mLastUsedDirectory[MAX_PATH+1] = { 0 };
#define MAX_EXTENSION_LENGTH 10 #define MAX_EXTENSION_LENGTH 10
//-------------------------------------------------------------------------
//
// nsFilePicker constructor
//
//-------------------------------------------------------------------------
nsFilePicker::nsFilePicker() nsFilePicker::nsFilePicker()
{ {
mSelectedType = 1; mSelectedType = 1;
} }
//-------------------------------------------------------------------------
//
// nsFilePicker destructor
//
//-------------------------------------------------------------------------
nsFilePicker::~nsFilePicker() nsFilePicker::~nsFilePicker()
{ {
if (mLastUsedUnicodeDirectory) { if (mLastUsedUnicodeDirectory) {
@ -92,12 +83,7 @@ nsFilePicker::~nsFilePicker()
} }
} }
//-------------------------------------------------------------------------
//
// Show - Display the file dialog // Show - Display the file dialog
//
//-------------------------------------------------------------------------
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{ {
if (uMsg == BFFM_INITIALIZED) if (uMsg == BFFM_INITIALIZED)
@ -195,7 +181,20 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
ofn.lpstrFile = fileBuffer; ofn.lpstrFile = fileBuffer;
ofn.nMaxFile = FILE_BUFFER_SIZE; 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<nsIPrivateBrowsingService> 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()) { if (!mDefaultExtension.IsEmpty()) {
ofn.lpstrDefExt = mDefaultExtension.get(); ofn.lpstrDefExt = mDefaultExtension.get();
@ -405,7 +404,6 @@ NS_IMETHODIMP nsFilePicker::GetFile(nsILocalFile **aFile)
return NS_OK; return NS_OK;
} }
//-------------------------------------------------------------------------
NS_IMETHODIMP nsFilePicker::GetFileURL(nsIURI **aFileURL) NS_IMETHODIMP nsFilePicker::GetFileURL(nsIURI **aFileURL)
{ {
*aFileURL = nsnull; *aFileURL = nsnull;
@ -423,11 +421,7 @@ NS_IMETHODIMP nsFilePicker::GetFiles(nsISimpleEnumerator **aFiles)
return NS_NewArrayEnumerator(aFiles, mFiles); return NS_NewArrayEnumerator(aFiles, mFiles);
} }
//-------------------------------------------------------------------------
//
// Get the file + path // Get the file + path
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsFilePicker::SetDefaultString(const nsAString& aString) NS_IMETHODIMP nsFilePicker::SetDefaultString(const nsAString& aString)
{ {
mDefault = aString; mDefault = aString;
@ -465,11 +459,7 @@ NS_IMETHODIMP nsFilePicker::GetDefaultString(nsAString& aString)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
//-------------------------------------------------------------------------
//
// The default extension to use for files // The default extension to use for files
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsFilePicker::GetDefaultExtension(nsAString& aExtension) NS_IMETHODIMP nsFilePicker::GetDefaultExtension(nsAString& aExtension)
{ {
aExtension = mDefaultExtension; aExtension = mDefaultExtension;
@ -482,11 +472,7 @@ NS_IMETHODIMP nsFilePicker::SetDefaultExtension(const nsAString& aExtension)
return NS_OK; return NS_OK;
} }
//-------------------------------------------------------------------------
//
// Set the filter index // Set the filter index
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsFilePicker::GetFilterIndex(PRInt32 *aFilterIndex) NS_IMETHODIMP nsFilePicker::GetFilterIndex(PRInt32 *aFilterIndex)
{ {
// Windows' filter index is 1-based, we use a 0-based system. // 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; return NS_OK;
} }
//-------------------------------------------------------------------------
void nsFilePicker::InitNative(nsIWidget *aParent, void nsFilePicker::InitNative(nsIWidget *aParent,
const nsAString& aTitle, const nsAString& aTitle,
PRInt16 aMode) PRInt16 aMode)

Просмотреть файл

@ -46,7 +46,7 @@
#include "GfxInfoX11.h" #include "GfxInfoX11.h"
#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) #ifdef MOZ_CRASHREPORTER
#include "nsExceptionHandler.h" #include "nsExceptionHandler.h"
#include "nsICrashReporter.h" #include "nsICrashReporter.h"
#endif #endif
@ -165,7 +165,7 @@ GfxInfo::GetData()
mAdapterDescription.Append(nsDependentCString(buf)); mAdapterDescription.Append(nsDependentCString(buf));
mAdapterDescription.AppendLiteral("\n"); mAdapterDescription.AppendLiteral("\n");
} }
#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) #ifdef MOZ_CRASHREPORTER
CrashReporter::AppendAppNotesToCrashReport(mAdapterDescription); CrashReporter::AppendAppNotesToCrashReport(mAdapterDescription);
#endif #endif
return; return;
@ -181,7 +181,7 @@ GfxInfo::GetData()
note.Append(" -- "); note.Append(" -- ");
note.Append(mVersion); note.Append(mVersion);
note.Append("\n"); note.Append("\n");
#if defined(MOZ_CRASHREPORTER) && defined(MOZ_ENABLE_LIBXUL) #ifdef MOZ_CRASHREPORTER
CrashReporter::AppendAppNotesToCrashReport(note); CrashReporter::AppendAppNotesToCrashReport(note);
#endif #endif

Просмотреть файл

@ -64,7 +64,8 @@ using namespace mozilla::widget;
#define FILEPICKER_TITLES "chrome://global/locale/filepicker.properties" #define FILEPICKER_TITLES "chrome://global/locale/filepicker.properties"
#define FILEPICKER_FILTERS "chrome://global/content/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, NS_IMETHODIMP nsBaseFilePicker::Init(nsIDOMWindow *aParent,
const nsAString& aTitle, const nsAString& aTitle,
PRInt16 aMode) PRInt16 aMode)
@ -161,11 +161,7 @@ nsBaseFilePicker::AppendFilters(PRInt32 aFilterMask)
return NS_OK; return NS_OK;
} }
//-------------------------------------------------------------------------
//
// Set the filter index // Set the filter index
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsBaseFilePicker::GetFilterIndex(PRInt32 *aFilterIndex) NS_IMETHODIMP nsBaseFilePicker::GetFilterIndex(PRInt32 *aFilterIndex)
{ {
*aFilterIndex = 0; *aFilterIndex = 0;
@ -197,11 +193,8 @@ NS_IMETHODIMP nsBaseFilePicker::GetFiles(nsISimpleEnumerator **aFiles)
} }
#ifdef BASEFILEPICKER_HAS_DISPLAYDIRECTORY #ifdef BASEFILEPICKER_HAS_DISPLAYDIRECTORY
//-------------------------------------------------------------------------
//
// Set the display directory // Set the display directory
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsBaseFilePicker::SetDisplayDirectory(nsILocalFile *aDirectory) NS_IMETHODIMP nsBaseFilePicker::SetDisplayDirectory(nsILocalFile *aDirectory)
{ {
if (!aDirectory) { if (!aDirectory) {
@ -216,11 +209,7 @@ NS_IMETHODIMP nsBaseFilePicker::SetDisplayDirectory(nsILocalFile *aDirectory)
return rv; return rv;
} }
//-------------------------------------------------------------------------
//
// Get the display directory // Get the display directory
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsBaseFilePicker::GetDisplayDirectory(nsILocalFile **aDirectory) NS_IMETHODIMP nsBaseFilePicker::GetDisplayDirectory(nsILocalFile **aDirectory)
{ {
*aDirectory = nsnull; *aDirectory = nsnull;
@ -233,3 +222,17 @@ NS_IMETHODIMP nsBaseFilePicker::GetDisplayDirectory(nsILocalFile **aDirectory)
return CallQueryInterface(directory, aDirectory); return CallQueryInterface(directory, aDirectory);
} }
#endif #endif
NS_IMETHODIMP
nsBaseFilePicker::GetAddToRecentDocs(PRBool *aFlag)
{
*aFlag = mAddToRecentDocs;
return NS_OK;
}
NS_IMETHODIMP
nsBaseFilePicker::SetAddToRecentDocs(PRBool aFlag)
{
mAddToRecentDocs = aFlag;
return NS_OK;
}

Просмотреть файл

@ -69,12 +69,15 @@ public:
NS_IMETHOD GetDisplayDirectory(nsILocalFile * *aDisplayDirectory); NS_IMETHOD GetDisplayDirectory(nsILocalFile * *aDisplayDirectory);
NS_IMETHOD SetDisplayDirectory(nsILocalFile * aDisplayDirectory); NS_IMETHOD SetDisplayDirectory(nsILocalFile * aDisplayDirectory);
#endif #endif
NS_IMETHOD GetAddToRecentDocs(PRBool *aFlag);
NS_IMETHOD SetAddToRecentDocs(PRBool aFlag);
protected: protected:
virtual void InitNative(nsIWidget *aParent, const nsAString& aTitle, virtual void InitNative(nsIWidget *aParent, const nsAString& aTitle,
PRInt16 aMode) = 0; PRInt16 aMode) = 0;
PRBool mAddToRecentDocs;
#ifdef BASEFILEPICKER_HAS_DISPLAYDIRECTORY #ifdef BASEFILEPICKER_HAS_DISPLAYDIRECTORY
nsCOMPtr<nsILocalFile> mDisplayDirectory; nsCOMPtr<nsILocalFile> mDisplayDirectory;
#endif #endif

Просмотреть файл

@ -175,7 +175,8 @@ NS_IMETHODIMP nsFilePickerProxy::Show(PRInt16* aReturn)
InfallibleTArray<nsString> filePaths; InfallibleTArray<nsString> filePaths;
nsresult rv; nsresult rv;
cc->SendShowFilePicker(mMode, mSelectedType, mTitle, cc->SendShowFilePicker(mMode, mSelectedType,
mAddToRecentDocs, mTitle,
mDefault, mDefaultExtension, mDefault, mDefaultExtension,
mFilters, mFilterNames, mFilters, mFilterNames,
&filePaths, aReturn, &rv); &filePaths, aReturn, &rv);

Просмотреть файл

@ -436,6 +436,20 @@ public:
"not the nsISupports pointer we expect"); \ "not the nsISupports pointer we expect"); \
_class *tmp = Downcast(s); _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<nsISupports*>(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) \ #define NS_IMPL_CYCLE_COLLECTION_TRACE_NATIVE_BEGIN(_class) \
void \ void \
NS_CYCLE_COLLECTION_CLASSNAME(_class)::Trace(void *p, \ NS_CYCLE_COLLECTION_CLASSNAME(_class)::Trace(void *p, \

Просмотреть файл

@ -51,7 +51,7 @@ MOZILLA_INTERNAL_API = 1
# work around bug 408258 # work around bug 408258
ifdef GNU_CC ifdef GNU_CC
ifneq ($(OS_ARCH), Darwin) ifneq ($(OS_ARCH), Darwin)
MODULE_OPTIMIZE_FLAGS = -O3 -fno-strict-aliasing MODULE_OPTIMIZE_FLAGS = $(MOZ_OPTIMIZE_FLAGS) -fno-strict-aliasing
endif endif
endif endif