From 1281428936298070f2ed3eb1bdfbcc680cc5e956 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Mon, 27 Jan 2014 08:27:04 -0800 Subject: [PATCH 001/296] Bug 964061 - Part 1: Convert CRMFObject to WebIDL bindings; r=bzbarsky --HG-- extra : rebase_source : 39a2b35df50cdd42624fb0e7a14383e8d40cea4b --- dom/base/Crypto.cpp | 2 +- dom/base/Crypto.h | 8 +++-- dom/base/nsDOMClassInfo.cpp | 19 ----------- dom/base/nsDOMClassInfoClasses.h | 5 --- dom/bindings/Bindings.conf | 5 +++ .../mochitest/general/test_interfaces.html | 2 -- dom/webidl/CRMFObject.webidl | 10 ++++++ dom/webidl/Crypto.webidl | 16 ++++----- dom/webidl/moz.build | 5 +++ security/manager/ssl/src/moz.build | 1 + security/manager/ssl/src/nsCrypto.cpp | 34 +++++++++---------- security/manager/ssl/src/nsCrypto.h | 18 ++++++---- 12 files changed, 64 insertions(+), 61 deletions(-) create mode 100644 dom/webidl/CRMFObject.webidl diff --git a/dom/base/Crypto.cpp b/dom/base/Crypto.cpp index f50979ae8d8..7678a2fca5f 100644 --- a/dom/base/Crypto.cpp +++ b/dom/base/Crypto.cpp @@ -150,7 +150,7 @@ Crypto::GetVersion(nsString& aVersion) { } -already_AddRefed +already_AddRefed Crypto::GenerateCRMFRequest(JSContext* aContext, const nsCString& aReqDN, const nsCString& aRegToken, diff --git a/dom/base/Crypto.h b/dom/base/Crypto.h index 8688ad9fe62..d17226cdf24 100644 --- a/dom/base/Crypto.h +++ b/dom/base/Crypto.h @@ -8,7 +8,11 @@ #include "nsIDOMCrypto.h" #else #include "nsIDOMCryptoLegacy.h" -class nsIDOMCRMFObject; +namespace mozilla { +namespace dom { +class CRMFObject; +} +} #endif #include "nsPIDOMWindow.h" @@ -46,7 +50,7 @@ public: virtual void GetVersion(nsString& aVersion); - virtual already_AddRefed + virtual already_AddRefed GenerateCRMFRequest(JSContext* aContext, const nsCString& aReqDN, const nsCString& aRegToken, diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 092f120899e..5c8cd1544e1 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -110,9 +110,6 @@ #include "nsIDOMCSSStyleRule.h" #include "nsIDOMCSSStyleSheet.h" #include "nsIDOMXULCommandDispatcher.h" -#ifndef MOZ_DISABLE_CRYPTOLEGACY -#include "nsIDOMCRMFObject.h" -#endif #include "nsIControllers.h" #include "nsIBoxObject.h" #ifdef MOZ_XUL @@ -228,10 +225,6 @@ static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); const uint32_t kDOMClassInfo_##_dom_class##_interfaces = \ 0; -#ifndef MOZ_DISABLE_CRYPTOLEGACY -DOMCI_DATA_NO_CLASS(CRMFObject) -#endif - DOMCI_DATA_NO_CLASS(ContentFrameMessageManager) DOMCI_DATA_NO_CLASS(ChromeMessageBroadcaster) DOMCI_DATA_NO_CLASS(ChromeMessageSender) @@ -354,12 +347,6 @@ static nsDOMClassInfoData sClassInfoData[] = { DEFAULT_SCRIPTABLE_FLAGS) #endif - // Crypto classes -#ifndef MOZ_DISABLE_CRYPTOLEGACY - NS_DEFINE_CLASSINFO_DATA(CRMFObject, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) -#endif - // DOM Chrome Window class. NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(ChromeWindow, nsWindowSH, DEFAULT_SCRIPTABLE_FLAGS | @@ -1016,12 +1003,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_END #endif -#ifndef MOZ_DISABLE_CRYPTOLEGACY - DOM_CLASSINFO_MAP_BEGIN(CRMFObject, nsIDOMCRMFObject) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMCRMFObject) - DOM_CLASSINFO_MAP_END -#endif - DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ChromeWindow, nsIDOMWindow) DOM_CLASSINFO_WINDOW_MAP_ENTRIES DOM_CLASSINFO_MAP_ENTRY(nsIDOMChromeWindow) diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index 0c477cd7d91..848c134b038 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -30,11 +30,6 @@ DOMCI_CLASS(TreeSelection) DOMCI_CLASS(TreeContentView) #endif -// Crypto classes -#ifndef MOZ_DISABLE_CRYPTOLEGACY -DOMCI_CLASS(CRMFObject) -#endif - // DOM Chrome Window class, almost identical to Window DOMCI_CLASS(ChromeWindow) diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 9de1d3990c9..9ec4b91e185 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -251,6 +251,11 @@ DOMInterfaces = { 'headerFile': 'nsGeoPosition.h' }, +'CRMFObject': { + 'headerFile': 'nsCrypto.h', + 'wrapperCache': False, +}, + 'Crypto' : { 'implicitJSContext': [ 'generateCRMFRequest', 'signText' ], 'headerFile': 'Crypto.h' diff --git a/dom/tests/mochitest/general/test_interfaces.html b/dom/tests/mochitest/general/test_interfaces.html index 41c42b2109b..b756f8d7fd8 100644 --- a/dom/tests/mochitest/general/test_interfaces.html +++ b/dom/tests/mochitest/general/test_interfaces.html @@ -210,8 +210,6 @@ var interfaceNamesInGlobalScope = "Controllers", // IMPORTANT: Do not change this list without review from a DOM peer! "ConvolverNode", -// IMPORTANT: Do not change this list without review from a DOM peer! - {name: "CRMFObject", desktop: true}, // IMPORTANT: Do not change this list without review from a DOM peer! "Crypto", // IMPORTANT: Do not change this list without review from a DOM peer! diff --git a/dom/webidl/CRMFObject.webidl b/dom/webidl/CRMFObject.webidl new file mode 100644 index 00000000000..388e88f3008 --- /dev/null +++ b/dom/webidl/CRMFObject.webidl @@ -0,0 +1,10 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +[NoInterfaceObject] +interface CRMFObject { + readonly attribute DOMString request; +}; diff --git a/dom/webidl/Crypto.webidl b/dom/webidl/Crypto.webidl index 04e9c463b4c..ff8bda87b0f 100644 --- a/dom/webidl/Crypto.webidl +++ b/dom/webidl/Crypto.webidl @@ -19,8 +19,6 @@ interface Crypto { }; #ifndef MOZ_DISABLE_CRYPTOLEGACY -interface CRMFObject; - [NoInterfaceObject] interface CryptoLegacy { readonly attribute DOMString version; @@ -28,13 +26,13 @@ interface CryptoLegacy { [SetterThrows] attribute boolean enableSmartCardEvents; - [Throws] - CRMFObject generateCRMFRequest(ByteString? reqDN, - ByteString? regToken, - ByteString? authenticator, - ByteString? eaCert, - ByteString? jsCallback, - any... args); + [Throws,NewObject] + CRMFObject? generateCRMFRequest(ByteString? reqDN, + ByteString? regToken, + ByteString? authenticator, + ByteString? eaCert, + ByteString? jsCallback, + any... args); [Throws] DOMString importUserCertificates(DOMString nickname, diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 13512539bc4..71971b81d49 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -552,6 +552,11 @@ if CONFIG['MOZ_B2G_FM']: 'FMRadio.webidl', ] +if not CONFIG['MOZ_DISABLE_CRYPTOLEGACY']: + WEBIDL_FILES += [ + 'CRMFObject.webidl', + ] + GENERATED_EVENTS_WEBIDL_FILES = [ 'BlobEvent.webidl', 'CallGroupErrorEvent.webidl', diff --git a/security/manager/ssl/src/moz.build b/security/manager/ssl/src/moz.build index 029a6d1fcde..d81692bc3f4 100644 --- a/security/manager/ssl/src/moz.build +++ b/security/manager/ssl/src/moz.build @@ -6,6 +6,7 @@ EXPORTS += [ 'CryptoTask.h', + 'nsCrypto.h', 'nsNSSShutDown.h', 'nsRandomGenerator.h', 'ScopedNSSTypes.h', diff --git a/security/manager/ssl/src/nsCrypto.cpp b/security/manager/ssl/src/nsCrypto.cpp index a5ee5c2286b..7aac6d0bc9a 100644 --- a/security/manager/ssl/src/nsCrypto.cpp +++ b/security/manager/ssl/src/nsCrypto.cpp @@ -79,6 +79,9 @@ #include #include "nsWrapperCacheInlines.h" #endif +#ifndef MOZ_DISABLE_CRYPTOLEGACY +#include "mozilla/dom/CRMFObjectBinding.h" +#endif using namespace mozilla; using namespace mozilla::dom; @@ -214,15 +217,14 @@ NS_INTERFACE_MAP_END_INHERITING(mozilla::dom::Crypto) NS_IMPL_ADDREF_INHERITED(nsCrypto, mozilla::dom::Crypto) NS_IMPL_RELEASE_INHERITED(nsCrypto, mozilla::dom::Crypto) -// QueryInterface implementation for nsCRMFObject -NS_INTERFACE_MAP_BEGIN(nsCRMFObject) +// QueryInterface implementation for CRMFObject +NS_INTERFACE_MAP_BEGIN(CRMFObject) NS_INTERFACE_MAP_ENTRY(nsIDOMCRMFObject) NS_INTERFACE_MAP_ENTRY(nsISupports) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CRMFObject) NS_INTERFACE_MAP_END -NS_IMPL_ADDREF(nsCRMFObject) -NS_IMPL_RELEASE(nsCRMFObject) +NS_IMPL_ADDREF(CRMFObject) +NS_IMPL_RELEASE(CRMFObject) // QueryInterface implementation for nsPkcs11 #endif // MOZ_DISABLE_CRYPTOLEGACY @@ -1858,7 +1860,7 @@ GetISupportsFromContext(JSContext *cx) //The top level method which is a member of nsIDOMCrypto //for generate a base64 encoded CRMF request. -already_AddRefed +already_AddRefed nsCrypto::GenerateCRMFRequest(JSContext* aContext, const nsCString& aReqDN, const nsCString& aRegToken, @@ -1869,7 +1871,6 @@ nsCrypto::GenerateCRMFRequest(JSContext* aContext, ErrorResult& aRv) { nsNSSShutDownPreventionLock locker; - nsCOMPtr crmf; nsresult nrv; uint32_t argc = aArgs.Length(); @@ -2029,9 +2030,8 @@ nsCrypto::GenerateCRMFRequest(JSContext* aContext, aRv.Throw(NS_ERROR_FAILURE); return nullptr; } - nsCRMFObject *newObject = new nsCRMFObject(); + nsRefPtr newObject = new CRMFObject(); newObject->SetCRMFRequest(encodedRequest); - crmf = newObject; nsFreeKeyPairInfo(keyids, numRequests); // Post an event on the UI queue so that the JS gets called after @@ -2080,7 +2080,7 @@ nsCrypto::GenerateCRMFRequest(JSContext* aContext, delete cryptoRunnable; } - return crmf.forget(); + return newObject.forget(); } // Reminder that we inherit the memory passed into us here. @@ -2855,29 +2855,29 @@ nsCrypto::DisableRightClick(ErrorResult& aRv) aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); } -nsCRMFObject::nsCRMFObject() +CRMFObject::CRMFObject() { } -nsCRMFObject::~nsCRMFObject() +CRMFObject::~CRMFObject() { } -nsresult -nsCRMFObject::init() +JSObject* +CRMFObject::WrapObject(JSContext *aCx, JS::Handle aScope) { - return NS_OK; + return CRMFObjectBinding::Wrap(aCx, aScope, this); } NS_IMETHODIMP -nsCRMFObject::GetRequest(nsAString& aRequest) +CRMFObject::GetRequest(nsAString& aRequest) { aRequest.Assign(mBase64Request); return NS_OK; } nsresult -nsCRMFObject::SetCRMFRequest(char *inRequest) +CRMFObject::SetCRMFRequest(char *inRequest) { mBase64Request.AssignWithConversion(inRequest); return NS_OK; diff --git a/security/manager/ssl/src/nsCrypto.h b/security/manager/ssl/src/nsCrypto.h index 9187a70c162..3c86d500385 100644 --- a/security/manager/ssl/src/nsCrypto.h +++ b/security/manager/ssl/src/nsCrypto.h @@ -24,23 +24,29 @@ class nsIPSMComponent; class nsIDOMScriptObjectFactory; -class nsCRMFObject : public nsIDOMCRMFObject +namespace mozilla { +namespace dom { + +class CRMFObject : public nsIDOMCRMFObject { public: - nsCRMFObject(); - virtual ~nsCRMFObject(); + CRMFObject(); + virtual ~CRMFObject(); NS_DECL_NSIDOMCRMFOBJECT NS_DECL_ISUPPORTS - nsresult init(); - nsresult SetCRMFRequest(char *inRequest); + + JSObject* WrapObject(JSContext *aCx, JS::Handle aScope); private: nsString mBase64Request; }; +} +} + class nsCrypto: public mozilla::dom::Crypto { public: @@ -59,7 +65,7 @@ public: virtual void GetVersion(nsString& aVersion) MOZ_OVERRIDE; - virtual already_AddRefed + virtual already_AddRefed GenerateCRMFRequest(JSContext* aContext, const nsCString& aReqDN, const nsCString& aRegToken, From 9a53bde08a23e55de10252cf2e7a07e0eb6df94b Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Mon, 27 Jan 2014 08:27:06 -0800 Subject: [PATCH 002/296] Bug 964061 - Part 2: Remove nsIDOMCRMFObject; r=bzbarsky --HG-- extra : rebase_source : 888e33d68bdcd6e03b56f75036ea00142831961d --- dom/base/Crypto.cpp | 2 +- dom/base/Crypto.h | 2 +- dom/bindings/Bindings.conf | 1 + dom/interfaces/base/domstubs.idl | 1 - dom/interfaces/base/moz.build | 1 - dom/interfaces/base/nsIDOMCRMFObject.idl | 12 ----------- dom/interfaces/base/nsIDOMCryptoLegacy.idl | 1 - security/manager/ssl/src/nsCrypto.cpp | 25 ++++++++-------------- security/manager/ssl/src/nsCrypto.h | 16 +++++++------- 9 files changed, 20 insertions(+), 41 deletions(-) delete mode 100644 dom/interfaces/base/nsIDOMCRMFObject.idl diff --git a/dom/base/Crypto.cpp b/dom/base/Crypto.cpp index 7678a2fca5f..b6a779a4103 100644 --- a/dom/base/Crypto.cpp +++ b/dom/base/Crypto.cpp @@ -150,7 +150,7 @@ Crypto::GetVersion(nsString& aVersion) { } -already_AddRefed +mozilla::dom::CRMFObject* Crypto::GenerateCRMFRequest(JSContext* aContext, const nsCString& aReqDN, const nsCString& aRegToken, diff --git a/dom/base/Crypto.h b/dom/base/Crypto.h index d17226cdf24..b72f488e200 100644 --- a/dom/base/Crypto.h +++ b/dom/base/Crypto.h @@ -50,7 +50,7 @@ public: virtual void GetVersion(nsString& aVersion); - virtual already_AddRefed + virtual mozilla::dom::CRMFObject* GenerateCRMFRequest(JSContext* aContext, const nsCString& aReqDN, const nsCString& aRegToken, diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 9ec4b91e185..a6608281dd8 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -253,6 +253,7 @@ DOMInterfaces = { 'CRMFObject': { 'headerFile': 'nsCrypto.h', + 'nativeOwnership': 'owned', 'wrapperCache': False, }, diff --git a/dom/interfaces/base/domstubs.idl b/dom/interfaces/base/domstubs.idl index 0f93e0e3ccd..14d8d8134ed 100644 --- a/dom/interfaces/base/domstubs.idl +++ b/dom/interfaces/base/domstubs.idl @@ -76,7 +76,6 @@ interface nsIDOMHTMLTableCaptionElement; interface nsIDOMRange; // Crypto -interface nsIDOMCRMFObject; interface nsIDOMCrypto; interface nsIDOMPkcs11; diff --git a/dom/interfaces/base/moz.build b/dom/interfaces/base/moz.build index f6c94b84877..fd7f03af561 100644 --- a/dom/interfaces/base/moz.build +++ b/dom/interfaces/base/moz.build @@ -16,7 +16,6 @@ XPIDL_SOURCES += [ 'nsIDOMClientRect.idl', 'nsIDOMClientRectList.idl', 'nsIDOMConstructor.idl', - 'nsIDOMCRMFObject.idl', 'nsIDOMGlobalObjectConstructor.idl', 'nsIDOMGlobalPropertyInitializer.idl', 'nsIDOMHistory.idl', diff --git a/dom/interfaces/base/nsIDOMCRMFObject.idl b/dom/interfaces/base/nsIDOMCRMFObject.idl deleted file mode 100644 index 4e3637cd4cd..00000000000 --- a/dom/interfaces/base/nsIDOMCRMFObject.idl +++ /dev/null @@ -1,12 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "domstubs.idl" - -[scriptable, uuid(16da46c0-208d-11d4-8a7c-006008c844c3)] -interface nsIDOMCRMFObject : nsISupports -{ - readonly attribute DOMString request; -}; diff --git a/dom/interfaces/base/nsIDOMCryptoLegacy.idl b/dom/interfaces/base/nsIDOMCryptoLegacy.idl index 071c676eefd..4af74bcf84f 100644 --- a/dom/interfaces/base/nsIDOMCryptoLegacy.idl +++ b/dom/interfaces/base/nsIDOMCryptoLegacy.idl @@ -5,7 +5,6 @@ #include "domstubs.idl" -interface nsIDOMCRMFObject; interface nsIDOMWindow; [uuid(c25ecf08-3f46-4420-bee4-8505792fd63a)] diff --git a/security/manager/ssl/src/nsCrypto.cpp b/security/manager/ssl/src/nsCrypto.cpp index 7aac6d0bc9a..3e72d3b3f1a 100644 --- a/security/manager/ssl/src/nsCrypto.cpp +++ b/security/manager/ssl/src/nsCrypto.cpp @@ -216,15 +216,6 @@ NS_INTERFACE_MAP_END_INHERITING(mozilla::dom::Crypto) NS_IMPL_ADDREF_INHERITED(nsCrypto, mozilla::dom::Crypto) NS_IMPL_RELEASE_INHERITED(nsCrypto, mozilla::dom::Crypto) - -// QueryInterface implementation for CRMFObject -NS_INTERFACE_MAP_BEGIN(CRMFObject) - NS_INTERFACE_MAP_ENTRY(nsIDOMCRMFObject) - NS_INTERFACE_MAP_ENTRY(nsISupports) -NS_INTERFACE_MAP_END - -NS_IMPL_ADDREF(CRMFObject) -NS_IMPL_RELEASE(CRMFObject) // QueryInterface implementation for nsPkcs11 #endif // MOZ_DISABLE_CRYPTOLEGACY @@ -1860,7 +1851,7 @@ GetISupportsFromContext(JSContext *cx) //The top level method which is a member of nsIDOMCrypto //for generate a base64 encoded CRMF request. -already_AddRefed +CRMFObject* nsCrypto::GenerateCRMFRequest(JSContext* aContext, const nsCString& aReqDN, const nsCString& aRegToken, @@ -2030,7 +2021,7 @@ nsCrypto::GenerateCRMFRequest(JSContext* aContext, aRv.Throw(NS_ERROR_FAILURE); return nullptr; } - nsRefPtr newObject = new CRMFObject(); + CRMFObject* newObject = new CRMFObject(); newObject->SetCRMFRequest(encodedRequest); nsFreeKeyPairInfo(keyids, numRequests); @@ -2080,7 +2071,7 @@ nsCrypto::GenerateCRMFRequest(JSContext* aContext, delete cryptoRunnable; } - return newObject.forget(); + return newObject; } // Reminder that we inherit the memory passed into us here. @@ -2857,23 +2848,25 @@ nsCrypto::DisableRightClick(ErrorResult& aRv) CRMFObject::CRMFObject() { + MOZ_COUNT_CTOR(CRMFObject); } CRMFObject::~CRMFObject() { + MOZ_COUNT_DTOR(CRMFObject); } JSObject* -CRMFObject::WrapObject(JSContext *aCx, JS::Handle aScope) +CRMFObject::WrapObject(JSContext *aCx, JS::Handle aScope, + bool* aTookOwnership) { - return CRMFObjectBinding::Wrap(aCx, aScope, this); + return CRMFObjectBinding::Wrap(aCx, aScope, this, aTookOwnership); } -NS_IMETHODIMP +void CRMFObject::GetRequest(nsAString& aRequest) { aRequest.Assign(mBase64Request); - return NS_OK; } nsresult diff --git a/security/manager/ssl/src/nsCrypto.h b/security/manager/ssl/src/nsCrypto.h index 3c86d500385..52a66226a0d 100644 --- a/security/manager/ssl/src/nsCrypto.h +++ b/security/manager/ssl/src/nsCrypto.h @@ -9,9 +9,9 @@ #include "mozilla/dom/BindingDeclarations.h" #include "mozilla/ErrorResult.h" #ifndef MOZ_DISABLE_CRYPTOLEGACY +#include "mozilla/dom/NonRefcountedDOMObject.h" #include "Crypto.h" #include "nsCOMPtr.h" -#include "nsIDOMCRMFObject.h" #include "nsIDOMCryptoLegacy.h" #include "nsIRunnable.h" #include "nsString.h" @@ -27,20 +27,20 @@ class nsIDOMScriptObjectFactory; namespace mozilla { namespace dom { -class CRMFObject : public nsIDOMCRMFObject +class CRMFObject : public NonRefcountedDOMObject { public: CRMFObject(); virtual ~CRMFObject(); - NS_DECL_NSIDOMCRMFOBJECT - NS_DECL_ISUPPORTS - nsresult SetCRMFRequest(char *inRequest); - JSObject* WrapObject(JSContext *aCx, JS::Handle aScope); -private: + JSObject* WrapObject(JSContext *aCx, JS::Handle aScope, + bool* aTookOwnership); + void GetRequest(nsAString& aRequest); + +private: nsString mBase64Request; }; @@ -65,7 +65,7 @@ public: virtual void GetVersion(nsString& aVersion) MOZ_OVERRIDE; - virtual already_AddRefed + virtual mozilla::dom::CRMFObject* GenerateCRMFRequest(JSContext* aContext, const nsCString& aReqDN, const nsCString& aRegToken, From 6f4127bb55c9f72050f5b467054928ebba319daf Mon Sep 17 00:00:00 2001 From: Robert Strong Date: Mon, 27 Jan 2014 10:35:38 -0800 Subject: [PATCH 003/296] Bug 963860 - fix macro redefinition when compiling TestAUSReadStrings.cpp. r=bbondy --- toolkit/mozapps/update/tests/TestAUSReadStrings.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/toolkit/mozapps/update/tests/TestAUSReadStrings.cpp b/toolkit/mozapps/update/tests/TestAUSReadStrings.cpp index 8bb58aa279d..83dc4d3a77d 100644 --- a/toolkit/mozapps/update/tests/TestAUSReadStrings.cpp +++ b/toolkit/mozapps/update/tests/TestAUSReadStrings.cpp @@ -11,7 +11,6 @@ #include #define NS_main wmain #define NS_tstrrchr wcsrchr - #define NS_tsnprintf _snwprintf #define NS_T(str) L ## str #define PATH_SEPARATOR_CHAR L'\\' // On Windows, argv[0] can also have forward slashes instead @@ -20,7 +19,6 @@ #include #define NS_main main #define NS_tstrrchr strrchr - #define NS_tsnprintf snprintf #define NS_T(str) str #ifdef XP_OS2 #define PATH_SEPARATOR_CHAR '\\' From d5ef9303de538181f5316c3b7f15a63bd996d5d3 Mon Sep 17 00:00:00 2001 From: Robert Strong Date: Mon, 27 Jan 2014 10:35:43 -0800 Subject: [PATCH 004/296] Bug 963848 - head_update.js is copied to unit_service_updater even when MOZ_MAINTENANCE_SERVICE is not defined. r=bbondy --- toolkit/mozapps/update/tests/Makefile.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/toolkit/mozapps/update/tests/Makefile.in b/toolkit/mozapps/update/tests/Makefile.in index 1930b12be5a..1d974ef90af 100644 --- a/toolkit/mozapps/update/tests/Makefile.in +++ b/toolkit/mozapps/update/tests/Makefile.in @@ -26,10 +26,12 @@ base-updater-head_TARGET := libs base-updater-head_DEST := $(XPCSHELLTESTROOT)/unit_base_updater base-updater-head_FILES := $(XPCSHELLTESTROOT)/unit_aus_update/head_update.js +ifdef MOZ_MAINTENANCE_SERVICE INSTALL_TARGETS += service-updater-head service-updater-head_TARGET := libs service-updater-head_DEST := $(XPCSHELLTESTROOT)/unit_service_updater service-updater-head_FILES := $(XPCSHELLTESTROOT)/unit_aus_update/head_update.js +endif # MOZ_MAINTENANCE_SERVICE ifndef MOZ_PROFILE_GENERATE ifdef COMPILE_ENVIRONMENT From d1f73790263c8c2e1b5300a3d7abf7ab8d12c431 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 27 Jan 2014 19:37:56 +0100 Subject: [PATCH 005/296] Bug 945292 - Fixed ANGLE compilation on mingw. r=jgilbert --HG-- extra : rebase_source : 84a48e83aab4a71d7be05d38874942ec89721d4d --- gfx/angle/angle-build-mingw.patch | 201 ++++++++++++++++++ gfx/angle/src/common/debug.h | 6 +- .../libGLESv2/{constants.h => Constants.h} | 0 gfx/angle/src/libGLESv2/Framebuffer.h | 2 +- gfx/angle/src/libGLESv2/precompiled.h | 2 +- .../src/libGLESv2/renderer/Renderer11.cpp | 2 +- gfx/angle/src/libGLESv2/renderer/Renderer11.h | 2 +- 7 files changed, 209 insertions(+), 6 deletions(-) create mode 100644 gfx/angle/angle-build-mingw.patch rename gfx/angle/src/libGLESv2/{constants.h => Constants.h} (100%) diff --git a/gfx/angle/angle-build-mingw.patch b/gfx/angle/angle-build-mingw.patch new file mode 100644 index 00000000000..d7a9724bfef --- /dev/null +++ b/gfx/angle/angle-build-mingw.patch @@ -0,0 +1,201 @@ +From: Jacek Caban +Bug 945292 - Fixed ANGLE compilation on mingw. + + +diff --git a/gfx/angle/src/common/debug.h b/gfx/angle/src/common/debug.h +index 23ee26d..060b727 100644 +--- a/gfx/angle/src/common/debug.h ++++ b/gfx/angle/src/common/debug.h +@@ -94,18 +94,20 @@ namespace gl + #define UNREACHABLE() do { \ + ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__); \ + assert(false); \ + } while(0) + #else + #define UNREACHABLE() ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__) + #endif + +-// A macro that determines whether an object has a given runtime type. +-#if !defined(NDEBUG) && (!defined(_MSC_VER) || defined(_CPPRTTI)) ++// A macro that determines whether an object has a given runtime type. MSVC uses _CPPRTTI. ++// GCC uses __GXX_RTTI, but the macro was introduced in version 4.3, so we assume that all older ++// versions support RTTI. ++#if !defined(NDEBUG) && (!defined(_MSC_VER) || defined(_CPPRTTI)) && (!defined(__GNUC__) || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) || defined(__GXX_RTTI)) + #define HAS_DYNAMIC_TYPE(type, obj) (dynamic_cast(obj) != NULL) + #else + #define HAS_DYNAMIC_TYPE(type, obj) true + #endif + + // A macro functioning as a compile-time assert to validate constant conditions + #define META_ASSERT(condition) typedef int COMPILE_TIME_ASSERT_##__LINE__[static_cast(condition)?1:-1] + +diff --git a/gfx/angle/src/libGLESv2/Constants.h b/gfx/angle/src/libGLESv2/Constants.h +new file mode 100644 +index 0000000..9f24d66 +--- /dev/null ++++ b/gfx/angle/src/libGLESv2/Constants.h +@@ -0,0 +1,34 @@ ++// ++// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++// ++ ++// Contants.h: Defines some implementation specific and gl constants ++ ++#ifndef LIBGLESV2_CONSTANTS_H_ ++#define LIBGLESV2_CONSTANTS_H_ ++ ++namespace gl ++{ ++ ++enum ++{ ++ MAX_VERTEX_ATTRIBS = 16, ++ MAX_TEXTURE_IMAGE_UNITS = 16, ++ ++ // Implementation upper limits, real maximums depend on the hardware ++ IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 16, ++ IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS = MAX_TEXTURE_IMAGE_UNITS + IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS, ++ ++ IMPLEMENTATION_MAX_VARYING_VECTORS = 32, ++ IMPLEMENTATION_MAX_DRAW_BUFFERS = 8 ++}; ++ ++const float ALIASED_LINE_WIDTH_RANGE_MIN = 1.0f; ++const float ALIASED_LINE_WIDTH_RANGE_MAX = 1.0f; ++const float ALIASED_POINT_SIZE_RANGE_MIN = 1.0f; ++ ++} ++ ++#endif // LIBGLESV2_CONSTANTS_H_ +diff --git a/gfx/angle/src/libGLESv2/Framebuffer.h b/gfx/angle/src/libGLESv2/Framebuffer.h +index b54e008..50bfd4f 100644 +--- a/gfx/angle/src/libGLESv2/Framebuffer.h ++++ b/gfx/angle/src/libGLESv2/Framebuffer.h +@@ -7,17 +7,17 @@ + // Framebuffer.h: Defines the gl::Framebuffer class. Implements GL framebuffer + // objects and related functionality. [OpenGL ES 2.0.24] section 4.4 page 105. + + #ifndef LIBGLESV2_FRAMEBUFFER_H_ + #define LIBGLESV2_FRAMEBUFFER_H_ + + #include "common/angleutils.h" + #include "common/RefCountObject.h" +-#include "constants.h" ++#include "Constants.h" + + namespace rx + { + class Renderer; + } + + namespace gl + { +diff --git a/gfx/angle/src/libGLESv2/constants.h b/gfx/angle/src/libGLESv2/constants.h +deleted file mode 100644 +index 9f24d66..0000000 +--- a/gfx/angle/src/libGLESv2/constants.h ++++ /dev/null +@@ -1,34 +0,0 @@ +-// +-// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. +-// Use of this source code is governed by a BSD-style license that can be +-// found in the LICENSE file. +-// +- +-// Contants.h: Defines some implementation specific and gl constants +- +-#ifndef LIBGLESV2_CONSTANTS_H_ +-#define LIBGLESV2_CONSTANTS_H_ +- +-namespace gl +-{ +- +-enum +-{ +- MAX_VERTEX_ATTRIBS = 16, +- MAX_TEXTURE_IMAGE_UNITS = 16, +- +- // Implementation upper limits, real maximums depend on the hardware +- IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 16, +- IMPLEMENTATION_MAX_COMBINED_TEXTURE_IMAGE_UNITS = MAX_TEXTURE_IMAGE_UNITS + IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS, +- +- IMPLEMENTATION_MAX_VARYING_VECTORS = 32, +- IMPLEMENTATION_MAX_DRAW_BUFFERS = 8 +-}; +- +-const float ALIASED_LINE_WIDTH_RANGE_MIN = 1.0f; +-const float ALIASED_LINE_WIDTH_RANGE_MAX = 1.0f; +-const float ALIASED_POINT_SIZE_RANGE_MIN = 1.0f; +- +-} +- +-#endif // LIBGLESV2_CONSTANTS_H_ +diff --git a/gfx/angle/src/libGLESv2/precompiled.h b/gfx/angle/src/libGLESv2/precompiled.h +index f62e71b..58ad181 100644 +--- a/gfx/angle/src/libGLESv2/precompiled.h ++++ b/gfx/angle/src/libGLESv2/precompiled.h +@@ -28,15 +28,15 @@ + #include + #include + #include + #include + #include + #include + + #include +-#include ++#include + #include + #include + + #ifdef _MSC_VER + #include + #endif +diff --git a/gfx/angle/src/libGLESv2/renderer/Renderer11.cpp b/gfx/angle/src/libGLESv2/renderer/Renderer11.cpp +index 774cd71..1f2b31d 100644 +--- a/gfx/angle/src/libGLESv2/renderer/Renderer11.cpp ++++ b/gfx/angle/src/libGLESv2/renderer/Renderer11.cpp +@@ -7,17 +7,17 @@ + + // Renderer11.cpp: Implements a back-end specific class for the D3D11 renderer. + + #include "libGLESv2/main.h" + #include "libGLESv2/utilities.h" + #include "libGLESv2/Buffer.h" + #include "libGLESv2/ProgramBinary.h" + #include "libGLESv2/Framebuffer.h" +-#include "libGLESv2/RenderBuffer.h" ++#include "libGLESv2/Renderbuffer.h" + #include "libGLESv2/renderer/Renderer11.h" + #include "libGLESv2/renderer/RenderTarget11.h" + #include "libGLESv2/renderer/renderer11_utils.h" + #include "libGLESv2/renderer/ShaderExecutable11.h" + #include "libGLESv2/renderer/SwapChain11.h" + #include "libGLESv2/renderer/Image11.h" + #include "libGLESv2/renderer/VertexBuffer11.h" + #include "libGLESv2/renderer/IndexBuffer11.h" +diff --git a/gfx/angle/src/libGLESv2/renderer/Renderer11.h b/gfx/angle/src/libGLESv2/renderer/Renderer11.h +index f024855..90ef04d 100644 +--- a/gfx/angle/src/libGLESv2/renderer/Renderer11.h ++++ b/gfx/angle/src/libGLESv2/renderer/Renderer11.h +@@ -230,17 +230,17 @@ class Renderer11 : public Renderer + bool mDepthTextureSupport; + + // Multisample format support + struct MultisampleSupportInfo + { + unsigned int qualityLevels[D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT]; + }; + +- typedef std::unordered_map MultisampleSupportMap; ++ typedef std::unordered_map > MultisampleSupportMap; + MultisampleSupportMap mMultisampleSupportMap; + + unsigned int mMaxSupportedSamples; + + // current render target states + unsigned int mAppliedRenderTargetSerials[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS]; + unsigned int mAppliedDepthbufferSerial; + unsigned int mAppliedStencilbufferSerial; diff --git a/gfx/angle/src/common/debug.h b/gfx/angle/src/common/debug.h index 23ee26d23ba..060b7272eb3 100644 --- a/gfx/angle/src/common/debug.h +++ b/gfx/angle/src/common/debug.h @@ -99,8 +99,10 @@ namespace gl #define UNREACHABLE() ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__) #endif -// A macro that determines whether an object has a given runtime type. -#if !defined(NDEBUG) && (!defined(_MSC_VER) || defined(_CPPRTTI)) +// A macro that determines whether an object has a given runtime type. MSVC uses _CPPRTTI. +// GCC uses __GXX_RTTI, but the macro was introduced in version 4.3, so we assume that all older +// versions support RTTI. +#if !defined(NDEBUG) && (!defined(_MSC_VER) || defined(_CPPRTTI)) && (!defined(__GNUC__) || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) || defined(__GXX_RTTI)) #define HAS_DYNAMIC_TYPE(type, obj) (dynamic_cast(obj) != NULL) #else #define HAS_DYNAMIC_TYPE(type, obj) true diff --git a/gfx/angle/src/libGLESv2/constants.h b/gfx/angle/src/libGLESv2/Constants.h similarity index 100% rename from gfx/angle/src/libGLESv2/constants.h rename to gfx/angle/src/libGLESv2/Constants.h diff --git a/gfx/angle/src/libGLESv2/Framebuffer.h b/gfx/angle/src/libGLESv2/Framebuffer.h index b54e008dd82..50bfd4fd0f8 100644 --- a/gfx/angle/src/libGLESv2/Framebuffer.h +++ b/gfx/angle/src/libGLESv2/Framebuffer.h @@ -12,7 +12,7 @@ #include "common/angleutils.h" #include "common/RefCountObject.h" -#include "constants.h" +#include "Constants.h" namespace rx { diff --git a/gfx/angle/src/libGLESv2/precompiled.h b/gfx/angle/src/libGLESv2/precompiled.h index f62e71b35f6..58ad181874b 100644 --- a/gfx/angle/src/libGLESv2/precompiled.h +++ b/gfx/angle/src/libGLESv2/precompiled.h @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include diff --git a/gfx/angle/src/libGLESv2/renderer/Renderer11.cpp b/gfx/angle/src/libGLESv2/renderer/Renderer11.cpp index 774cd714f2f..1f2b31df5f3 100644 --- a/gfx/angle/src/libGLESv2/renderer/Renderer11.cpp +++ b/gfx/angle/src/libGLESv2/renderer/Renderer11.cpp @@ -12,7 +12,7 @@ #include "libGLESv2/Buffer.h" #include "libGLESv2/ProgramBinary.h" #include "libGLESv2/Framebuffer.h" -#include "libGLESv2/RenderBuffer.h" +#include "libGLESv2/Renderbuffer.h" #include "libGLESv2/renderer/Renderer11.h" #include "libGLESv2/renderer/RenderTarget11.h" #include "libGLESv2/renderer/renderer11_utils.h" diff --git a/gfx/angle/src/libGLESv2/renderer/Renderer11.h b/gfx/angle/src/libGLESv2/renderer/Renderer11.h index f024855f97c..90ef04db7a3 100644 --- a/gfx/angle/src/libGLESv2/renderer/Renderer11.h +++ b/gfx/angle/src/libGLESv2/renderer/Renderer11.h @@ -235,7 +235,7 @@ class Renderer11 : public Renderer unsigned int qualityLevels[D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT]; }; - typedef std::unordered_map MultisampleSupportMap; + typedef std::unordered_map > MultisampleSupportMap; MultisampleSupportMap mMultisampleSupportMap; unsigned int mMaxSupportedSamples; From 895c82db13236a2462521ad484632a6f2adb6d66 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 27 Jan 2014 19:38:47 +0100 Subject: [PATCH 006/296] Bug 962354 - Fixed cross compilation on case sensitive OSes. --HG-- extra : rebase_source : 1fc397a1fc5086b04f79addf6c162f66b845b991 --- content/media/SharedThreadPool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/media/SharedThreadPool.cpp b/content/media/SharedThreadPool.cpp index ad5c8cb4473..f2a59081fc3 100644 --- a/content/media/SharedThreadPool.cpp +++ b/content/media/SharedThreadPool.cpp @@ -15,7 +15,7 @@ #ifdef XP_WIN // Required to init MSCOM by MSCOMInitThreadPoolListener. -#include +#include #endif namespace mozilla { From a14ed5adba2643c083ceedf504caa4e7eecd339a Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Mon, 27 Jan 2014 10:38:06 -0800 Subject: [PATCH 007/296] Bug 960255 - Emit 'change' event after adjusting range widgets. r=yzen --- accessible/src/jsat/content-script.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/accessible/src/jsat/content-script.js b/accessible/src/jsat/content-script.js index f2c68d8999e..9da70666b4c 100644 --- a/accessible/src/jsat/content-script.js +++ b/accessible/src/jsat/content-script.js @@ -344,13 +344,21 @@ function scroll(aMessage) { function adjustRange(aMessage) { function sendUpDownKey(aAccessible) { let acc = Utils.getEmbeddedControl(aAccessible) || aAccessible; - if (acc.DOMNode) { - let evt = content.document.createEvent('KeyboardEvent'); - let keycode = aMessage.json.direction == 'forward' ? - content.KeyEvent.DOM_VK_DOWN : content.KeyEvent.DOM_VK_UP; - evt.initKeyEvent( - "keypress", false, true, null, false, false, false, false, keycode, 0); - acc.DOMNode.dispatchEvent(evt); + let elem = acc.DOMNode; + if (elem) { + if (elem.tagName === 'INPUT' && elem.type === 'range') { + elem[aMessage.json.direction === 'forward' ? 'stepDown' : 'stepUp'](); + let changeEvent = content.document.createEvent('UIEvent'); + changeEvent.initEvent('change', true, true); + elem.dispatchEvent(changeEvent); + } else { + let evt = content.document.createEvent('KeyboardEvent'); + let keycode = aMessage.json.direction == 'forward' ? + content.KeyEvent.DOM_VK_DOWN : content.KeyEvent.DOM_VK_UP; + evt.initKeyEvent( + "keypress", false, true, null, false, false, false, false, keycode, 0); + elem.dispatchEvent(evt); + } } } From 83f301d2ff1d3e9eeeef2aecb04cf538e9333809 Mon Sep 17 00:00:00 2001 From: Shu-yu Guo Date: Mon, 27 Jan 2014 11:33:05 -0800 Subject: [PATCH 008/296] Bug 959163 - Fix debug asserts in PropertyTree::lookupChild. (r=jorendorff) --- js/src/jspropertytree.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/js/src/jspropertytree.cpp b/js/src/jspropertytree.cpp index 6e4d162576f..b28c4add48e 100644 --- a/js/src/jspropertytree.cpp +++ b/js/src/jspropertytree.cpp @@ -215,11 +215,13 @@ PropertyTree::lookupChild(ThreadSafeContext *cx, Shape *parent, const StackShape return nullptr; } -#ifdef JSGC_INCREMENTAL - mozilla::DebugOnly zone = shape->arenaHeader()->zone; - JS_ASSERT(!zone->needsBarrier()); - JS_ASSERT(!(zone->isGCSweeping() && !shape->isMarked() && - !shape->arenaHeader()->allocatedDuringIncremental)); +#if defined(JSGC_INCREMENTAL) && defined(DEBUG) + if (shape) { + JS::Zone *zone = shape->arenaHeader()->zone; + JS_ASSERT(!zone->needsBarrier()); + JS_ASSERT(!(zone->isGCSweeping() && !shape->isMarked() && + !shape->arenaHeader()->allocatedDuringIncremental)); + } #endif return shape; From 9e062ec7342f1bd04ee17484ab03b9aa259fe75e Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Mon, 27 Jan 2014 11:46:17 -0800 Subject: [PATCH 009/296] Bug 964075: Remove unused const variables from nsComponentManager.cpp, to fix clang warnings. r=froydnj --- xpcom/components/nsComponentManager.cpp | 28 ------------------------- 1 file changed, 28 deletions(-) diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index 1bc2e77d165..2547f4792f8 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -96,43 +96,15 @@ extern mozilla::Module const *const *const kPStaticModules[]; #define BIG_REGISTRY_BUFLEN (512*1024) // Common Key Names -const char classIDKeyName[]="classID"; -const char classesKeyName[]="contractID"; -const char componentsKeyName[]="components"; const char xpcomComponentsKeyName[]="software/mozilla/XPCOM/components"; const char xpcomKeyName[]="software/mozilla/XPCOM"; // Common Value Names -const char classIDValueName[]="ClassID"; -const char classNameValueName[]="ClassName"; -const char componentCountValueName[]="ComponentsCount"; -const char componentTypeValueName[]="ComponentType"; -const char contractIDValueName[]="ContractID"; const char fileSizeValueName[]="FileSize"; -const char inprocServerValueName[]="InprocServer"; const char lastModValueName[]="LastModTimeStamp"; const char nativeComponentType[]="application/x-mozilla-native"; const char staticComponentType[]="application/x-mozilla-static"; -const char jarComponentType[]="application/x-mozilla-jarjs"; -const char versionValueName[]="VersionString"; -const static char XPCOM_ABSCOMPONENT_PREFIX[] = "abs:"; -const static char XPCOM_RELCOMPONENT_PREFIX[] = "rel:"; -const static char XPCOM_GRECOMPONENT_PREFIX[] = "gre:"; - -static const char gIDFormat[] = - "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}"; - - -#define NS_EMPTY_IID \ -{ \ - 0x00000000, \ - 0x0000, \ - 0x0000, \ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} \ -} - -NS_DEFINE_CID(kEmptyCID, NS_EMPTY_IID); NS_DEFINE_CID(kCategoryManagerCID, NS_CATEGORYMANAGER_CID); #define UID_STRING_LENGTH 39 From ae79938400741816b9d107b0c5e0d79c8a9c4635 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Mon, 27 Jan 2014 11:46:25 -0800 Subject: [PATCH 010/296] Bug 964077: Mark xpcom/components as FAIL_ON_WARNINGS. r=froydnj --- xpcom/components/moz.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xpcom/components/moz.build b/xpcom/components/moz.build index 8075c7aac1d..0df6027afbd 100644 --- a/xpcom/components/moz.build +++ b/xpcom/components/moz.build @@ -38,6 +38,8 @@ SOURCES += [ 'nsNativeComponentLoader.cpp', ] +FAIL_ON_WARNINGS = True + MSVC_ENABLE_PGO = True FINAL_LIBRARY = 'xpcom_core' From 3a2b40d1f8f876a6b9a28588e571a642ffbea6f8 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Mon, 27 Jan 2014 11:35:59 -0500 Subject: [PATCH 011/296] Bug 936555 - make mozinfo use MozconfigLoader to locate the mozconfig; r=gps --- CLOBBER | 2 +- python/mozbuild/mozbuild/mozconfig.py | 8 +++---- python/mozbuild/mozbuild/mozinfo.py | 9 ++++---- python/mozbuild/mozbuild/test/test_mozinfo.py | 23 +++++++++++-------- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/CLOBBER b/CLOBBER index c52afa2e731..71d0c8c1d3e 100644 --- a/CLOBBER +++ b/CLOBBER @@ -22,4 +22,4 @@ # changes to stick? As of bug 928195, this shouldn't be necessary! Please # don't change CLOBBER for WebIDL changes any more. -bug 960811 - clobber to rebuild preprocessed files when enabling synthetic APKs +Bug 936555 - changes to mozconfig finding require clobbers, given that builds on try were green diff --git a/python/mozbuild/mozbuild/mozconfig.py b/python/mozbuild/mozbuild/mozconfig.py index bfd2f2f8cd7..2f36e592f57 100644 --- a/python/mozbuild/mozbuild/mozconfig.py +++ b/python/mozbuild/mozbuild/mozconfig.py @@ -75,7 +75,7 @@ class MozconfigLoader(ProcessExecutionMixin): return os.path.join(our_dir, 'mozconfig_loader') - def find_mozconfig(self): + def find_mozconfig(self, env=os.environ): """Find the active mozconfig file for the current environment. This emulates the logic in mozconfig-find. @@ -91,10 +91,10 @@ class MozconfigLoader(ProcessExecutionMixin): """ # Check for legacy methods first. - if 'MOZ_MYCONFIG' in os.environ: + if 'MOZ_MYCONFIG' in env: raise MozconfigFindException(MOZ_MYCONFIG_ERROR) - env_path = os.environ.get('MOZCONFIG', None) + env_path = env.get('MOZCONFIG', None) if env_path is not None: if not os.path.exists(env_path): raise MozconfigFindException( @@ -128,7 +128,7 @@ class MozconfigLoader(ProcessExecutionMixin): deprecated_paths = [os.path.join(self.topsrcdir, s) for s in self.DEPRECATED_TOPSRCDIR_PATHS] - home = os.environ.get('HOME', None) + home = env.get('HOME', None) if home is not None: deprecated_paths.extend([os.path.join(home, s) for s in self.DEPRECATED_HOME_PATHS]) diff --git a/python/mozbuild/mozbuild/mozinfo.py b/python/mozbuild/mozbuild/mozinfo.py index 23028188605..f73ae926b4a 100755 --- a/python/mozbuild/mozbuild/mozinfo.py +++ b/python/mozbuild/mozbuild/mozinfo.py @@ -8,7 +8,7 @@ import os import re import json - +import mozbuild.mozconfig as mozconfig def build_dict(config, env=os.environ): """ @@ -27,10 +27,9 @@ def build_dict(config, env=os.environ): d = {} d['topsrcdir'] = config.topsrcdir - if 'MOZCONFIG' in env: - mozconfig = env["MOZCONFIG"] - mozconfig = os.path.join(config.topsrcdir, mozconfig) - d['mozconfig'] = os.path.normpath(mozconfig) + the_mozconfig = mozconfig.MozconfigLoader(config.topsrcdir).find_mozconfig(env) + if the_mozconfig: + d['mozconfig'] = the_mozconfig # os o = substs["OS_TARGET"] diff --git a/python/mozbuild/mozbuild/test/test_mozinfo.py b/python/mozbuild/mozbuild/test/test_mozinfo.py index 870f0b6c305..80a8baeeaf8 100755 --- a/python/mozbuild/mozbuild/test/test_mozinfo.py +++ b/python/mozbuild/mozbuild/test/test_mozinfo.py @@ -19,6 +19,8 @@ from mozbuild.mozinfo import ( write_mozinfo, ) +from mozfile.mozfile import NamedTemporaryFile + class Base(object): def _config(self, substs={}): @@ -239,15 +241,18 @@ class TestWriteMozinfo(unittest.TestCase, Base): MOZ_WIDGET_TOOLKIT='windows', )) c.topsrcdir = '/tmp' - write_mozinfo(self.f, c, {'MOZCONFIG': 'foo'}) - with open(self.f) as f: - d = json.load(f) - self.assertEqual('win', d['os']) - self.assertEqual('x86', d['processor']) - self.assertEqual('windows', d['toolkit']) - self.assertEqual('/tmp', d['topsrcdir']) - self.assertEqual(os.path.normpath('/tmp/foo'), d['mozconfig']) - self.assertEqual(32, d['bits']) + with NamedTemporaryFile(dir=c.topsrcdir) as mozconfig: + mozconfig.write('unused contents') + mozconfig.flush() + write_mozinfo(self.f, c, {'MOZCONFIG': mozconfig.name}) + with open(self.f) as f: + d = json.load(f) + self.assertEqual('win', d['os']) + self.assertEqual('x86', d['processor']) + self.assertEqual('windows', d['toolkit']) + self.assertEqual('/tmp', d['topsrcdir']) + self.assertEqual(os.path.normpath(mozconfig.name), d['mozconfig']) + self.assertEqual(32, d['bits']) def test_fileobj(self): """ From bfbf3c5a3146201409d25d047654b500f8669d38 Mon Sep 17 00:00:00 2001 From: Malini Das Date: Mon, 27 Jan 2014 15:07:50 -0500 Subject: [PATCH 012/296] Bug 959520 - Make socket.timeout error messages more useful, r=jgriffin --- .../marionette/client/marionette/client.py | 14 ++- .../client/marionette/runner/base.py | 47 +++++++++- .../client/marionette/runner/mixins/b2g.py | 85 ++++++++++++++++--- .../marionette/runner/mixins/reporting.py | 1 + 4 files changed, 131 insertions(+), 16 deletions(-) diff --git a/testing/marionette/client/marionette/client.py b/testing/marionette/client/marionette/client.py index 6108be84f87..8af5daf5f84 100644 --- a/testing/marionette/client/marionette/client.py +++ b/testing/marionette/client/marionette/client.py @@ -2,6 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +import errno import json import socket @@ -52,9 +53,8 @@ class MarionetteClient(object): response += self._recv_n_bytes(int(length) + 1 + len(length) - 10) return json.loads(response) else: - raise InvalidResponseException("Could not successfully complete " - "transport of message to Gecko, " - "socket closed?", + raise InvalidResponseException("Could not communicate with Marionette server. " + "Is the Gecko process still running?", status=ErrorCodes.INVALID_RESPONSE) def connect(self, timeout=360.0): @@ -90,7 +90,13 @@ class MarionetteClient(object): for packet in [data[i:i + self.max_packet_length] for i in range(0, len(data), self.max_packet_length)]: - self.sock.send(packet) + try: + self.sock.send(packet) + except IOError as e: + if e.errno == errno.EPIPE: + raise IOError("%s: Connection to Marionette server is lost. Check gecko.log (desktop firefox) or logcat (b2g) for errors." % str(e)) + else: + raise e response = self.receive() return response diff --git a/testing/marionette/client/marionette/runner/base.py b/testing/marionette/client/marionette/runner/base.py index a4621562c4d..e9eeb5dc433 100644 --- a/testing/marionette/client/marionette/runner/base.py +++ b/testing/marionette/client/marionette/runner/base.py @@ -20,6 +20,7 @@ from manifestparser import TestManifest from mozhttpd import MozHttpd from marionette import Marionette from moztest.results import TestResultCollection, TestResult, relevant_line +from mixins.b2g import B2GTestResultMixin, get_b2g_pid, get_dm class MarionetteTest(TestResult): @@ -113,7 +114,7 @@ class MarionetteTestResult(unittest._TextTestResult, TestResultCollection): context=context, **kwargs) # call any registered result modifiers for modifier in self.result_modifiers: - modifier(t, result_expected, result_actual, output, context) + result_expected, result_actual, output, context = modifier(t, result_expected, result_actual, output, context) t.finish(result_actual, time_end=time.time() if test.start_time else 0, reason=relevant_line(output), @@ -238,6 +239,7 @@ class MarionetteTextTestRunner(unittest.TextTestRunner): def __init__(self, **kwargs): self.marionette = kwargs['marionette'] + self.capabilities = kwargs.pop('capabilities') del kwargs['marionette'] unittest.TextTestRunner.__init__(self, **kwargs) @@ -309,6 +311,40 @@ class MarionetteTextTestRunner(unittest.TextTestRunner): return result +class B2GMarionetteTestResult(MarionetteTestResult, B2GTestResultMixin): + + def __init__(self, *args, **kwargs): + # stupid hack because _TextTestRunner doesn't accept **kwargs + b2g_pid = kwargs.pop('b2g_pid') + MarionetteTestResult.__init__(self, *args, **kwargs) + kwargs['b2g_pid'] = b2g_pid + B2GTestResultMixin.__init__(self, *args, **kwargs) + + +class B2GMarionetteTextTestRunner(MarionetteTextTestRunner): + + resultclass = B2GMarionetteTestResult + + def __init__(self, **kwargs): + MarionetteTextTestRunner.__init__(self, **kwargs) + if self.capabilities['device'] != 'desktop': + self.resultclass = B2GMarionetteTestResult + self.b2g_pid = None + + def _makeResult(self): + return self.resultclass(self.stream, + self.descriptions, + self.verbosity, + marionette=self.marionette, + b2g_pid=self.b2g_pid) + + def run(self, test): + dm_type = os.environ.get('DM_TRANS', 'adb') + if dm_type == 'adb': + self.b2g_pid = get_b2g_pid(get_dm()) + return super(B2GMarionetteTextTestRunner, self).run(test) + + class BaseMarionetteOptions(OptionParser): def __init__(self, **kwargs): OptionParser.__init__(self, **kwargs) @@ -767,6 +803,12 @@ class BaseMarionetteTestRunner(object): self.start_marionette() if self.emulator: self.marionette.emulator.wait_for_homescreen(self.marionette) + # Retrieve capabilities for later use + if not self._capabilities: + self.capabilities + + if self.capabilities['device'] != 'desktop': + self.textrunnerclass = B2GMarionetteTextTestRunner testargs = {} if self.type is not None: @@ -849,7 +891,8 @@ class BaseMarionetteTestRunner(object): if suite.countTestCases(): runner = self.textrunnerclass(verbosity=3, - marionette=self.marionette) + marionette=self.marionette, + capabilities=self.capabilities) results = runner.run(suite) self.results.append(results) diff --git a/testing/marionette/client/marionette/runner/mixins/b2g.py b/testing/marionette/client/marionette/runner/mixins/b2g.py index 9a48cf267e9..6f83708acaa 100644 --- a/testing/marionette/client/marionette/runner/mixins/b2g.py +++ b/testing/marionette/client/marionette/runner/mixins/b2g.py @@ -4,6 +4,28 @@ import mozdevice import os +import re + + +def get_dm(**kwargs): + dm_type = os.environ.get('DM_TRANS', 'adb') + if dm_type == 'adb': + return mozdevice.DeviceManagerADB(**kwargs) + elif dm_type == 'sut': + host = os.environ.get('TEST_DEVICE') + if not host: + raise Exception('Must specify host with SUT!') + return mozdevice.DeviceManagerSUT(host=host) + else: + raise Exception('Unknown device manager type: %s' % dm_type) + + +def get_b2g_pid(dm): + b2g_output = dm.shellCheckOutput(['b2g-ps']) + pid_re = re.compile(r"""[\s\S]*b2g[\s]*root[\s]*([\d]+)[\s\S]*""") + if 'b2g' in b2g_output: + pid = pid_re.match(b2g_output) + return pid.group(1) class B2GTestCaseMixin(object): @@ -14,18 +36,61 @@ class B2GTestCaseMixin(object): def get_device_manager(self, *args, **kwargs): if not self._device_manager: - dm_type = os.environ.get('DM_TRANS', 'adb') - if dm_type == 'adb': - self._device_manager = mozdevice.DeviceManagerADB(**kwargs) - elif dm_type == 'sut': - host = os.environ.get('TEST_DEVICE') - if not host: - raise Exception('Must specify host with SUT!') - self._device_manager = mozdevice.DeviceManagerSUT(host=host) - else: - raise Exception('Unknown device manager type: %s' % dm_type) + self._device_manager = get_dm(**kwargs) return self._device_manager @property def device_manager(self): return self.get_device_manager() + +class B2GTestResultMixin(object): + + def __init__(self, *args, **kwargs): + self.result_modifiers.append(self.b2g_output_modifier) + self.b2g_pid = kwargs.pop('b2g_pid') + + def b2g_output_modifier(self, test, result_expected, result_actual, output, context): + # This function will check if b2g is running and report any recent errors. This is + # used in automation since a plaian 'socket.timeout' error doesn't tell you + # much information about what actually is going on + def diagnose_socket(output): + dm_type = os.environ.get('DM_TRANS', 'adb') + if dm_type == 'adb': + device_manager = get_dm() + pid = get_b2g_pid(device_manager) + if pid: + # find recent errors + message = "" + error_re = re.compile(r"""[\s\S]*(exception|error)[\s\S]*""", flags=re.IGNORECASE) + logcat = device_manager.getLogcat() + latest = [] + iters = len(logcat) - 1 + # reading from the latest line + while len(latest) < 5 and iters >= 0: + line = logcat[iters] + error_log_line = error_re.match(line) + if error_log_line is not None: + latest.append(line) + iters -= 1 + message += "\nMost recent errors/exceptions are:\n" + for line in reversed(latest): + message += "%s" % line + b2g_status = "" + if pid != self.b2g_pid: + b2g_status = "The B2G process has restarted after crashing during the tests so " + else: + b2g_status = "B2G is still running but " + output += "%s\n%sMarionette can't respond due to either a Gecko, Gaia or Marionette error. " \ + "Above, the 5 most recent errors are " \ + "listed. Check logcat for all errors if these errors are not the cause " \ + "of the failure." % (message, b2g_status) + else: + output += "B2G process has died" + return output + # For some reason, errno is not available for this exception + if "Broken pipe" in output: + output = diagnose_socket(output) + elif "socket.timeout" in output: + output = diagnose_socket(output) + return result_expected, result_actual, output, context + diff --git a/testing/marionette/client/marionette/runner/mixins/reporting.py b/testing/marionette/client/marionette/runner/mixins/reporting.py index 8d965553b92..bbfa7782151 100644 --- a/testing/marionette/client/marionette/runner/mixins/reporting.py +++ b/testing/marionette/client/marionette/runner/mixins/reporting.py @@ -174,6 +174,7 @@ class HTMLReportingTestResultMixin(object): test.debug = None if result_actual is not 'PASS': test.debug = self.gather_debug() + return result_expected, result_actual, output, context def gather_debug(self): debug = {} From 9bac52255bde87601c7762441c4ad319c9113d05 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Mon, 27 Jan 2014 15:25:19 -0500 Subject: [PATCH 013/296] Bug 952977: Perform some cleanup r=nical --- gfx/2d/Matrix.h | 9 +++++ gfx/layers/ImageLayers.cpp | 1 - gfx/layers/Layers.cpp | 18 ++++------ gfx/layers/LayersLogging.cpp | 26 -------------- gfx/layers/basic/BasicContainerLayer.cpp | 21 +++++------ gfx/layers/basic/BasicLayerManager.cpp | 36 ++++++++----------- gfx/layers/basic/BasicLayersImpl.cpp | 10 +++--- gfx/layers/basic/BasicLayersImpl.h | 1 - gfx/layers/client/ClientContainerLayer.h | 11 +++--- gfx/layers/composite/CanvasLayerComposite.cpp | 9 +++-- .../composite/ContainerLayerComposite.cpp | 11 +++--- gfx/layers/composite/ThebesLayerComposite.cpp | 1 - gfx/layers/d3d10/ContainerLayerD3D10.cpp | 18 +++++----- gfx/layers/d3d10/LayerManagerD3D10.cpp | 7 ++-- gfx/layers/d3d9/ContainerLayerD3D9.cpp | 13 +++---- gfx/layers/d3d9/DeviceManagerD3D9.cpp | 9 +++-- 16 files changed, 78 insertions(+), 123 deletions(-) diff --git a/gfx/2d/Matrix.h b/gfx/2d/Matrix.h index 2646bc45c54..70b5606e0f1 100644 --- a/gfx/2d/Matrix.h +++ b/gfx/2d/Matrix.h @@ -219,6 +219,15 @@ public: || (FuzzyEqual(_12, 0.0) && FuzzyEqual(_21, 0.0))); } + /** + * Returns true if the matrix has any transform other + * than a translation or scale; this is, if there is + * no rotation. + */ + bool HasNonAxisAlignedTransform() const { + return !FuzzyEqual(_21, 0.0) || !FuzzyEqual(_12, 0.0); + } + /** * Returns true if the matrix has non-integer scale */ diff --git a/gfx/layers/ImageLayers.cpp b/gfx/layers/ImageLayers.cpp index dc07966bd3c..4bc27b44c80 100644 --- a/gfx/layers/ImageLayers.cpp +++ b/gfx/layers/ImageLayers.cpp @@ -5,7 +5,6 @@ #include "ImageLayers.h" #include "ImageContainer.h" // for ImageContainer -#include "gfx3DMatrix.h" // for gfx3DMatrix #include "gfxRect.h" // for gfxRect #include "nsDebug.h" // for NS_ASSERTION #include "nsISupportsImpl.h" // for ImageContainer::Release, etc diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index 6c4575f2aa8..df20ec23348 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -584,15 +584,13 @@ Layer::CalculateScissorRect(const nsIntRect& aCurrentScissorRect, nsIntRect scissor = *clipRect; if (!container->UseIntermediateSurface()) { - gfxMatrix matrix; - gfx3DMatrix effectiveTransform; - To3DMatrix(container->GetEffectiveTransform(), effectiveTransform); - DebugOnly is2D = effectiveTransform.Is2D(&matrix); + gfx::Matrix matrix; + DebugOnly is2D = container->GetEffectiveTransform().Is2D(&matrix); // See DefaultComputeEffectiveTransforms below NS_ASSERTION(is2D && matrix.PreservesAxisAlignedRectangles(), "Non preserves axis aligned transform with clipped child should have forced intermediate surface"); - gfxRect r(scissor.x, scissor.y, scissor.width, scissor.height); - gfxRect trScissor = matrix.TransformBounds(r); + gfx::Rect r(scissor.x, scissor.y, scissor.width, scissor.height); + gfxRect trScissor = gfx::ThebesRect(matrix.TransformBounds(r)); trScissor.Round(); if (!gfxUtils::GfxRectToIntRect(trScissor, &scissor)) { return nsIntRect(currentClip.TopLeft(), nsIntSize(0, 0)); @@ -901,14 +899,12 @@ ContainerLayer::DefaultComputeEffectiveTransforms(const Matrix4x4& aTransformToS useIntermediateSurface = true; } else { useIntermediateSurface = false; - gfxMatrix contTransform; - gfx3DMatrix effectiveTransform; - To3DMatrix(mEffectiveTransform, effectiveTransform); - if (!effectiveTransform.Is2D(&contTransform) || + gfx::Matrix contTransform; + if (!mEffectiveTransform.Is2D(&contTransform) || #ifdef MOZ_GFX_OPTIMIZE_MOBILE !contTransform.PreservesAxisAlignedRectangles()) { #else - contTransform.HasNonIntegerTranslation()) { + gfx::ThebesMatrix(contTransform).HasNonIntegerTranslation()) { #endif for (Layer* child = GetFirstChild(); child; child = child->GetNextSibling()) { const nsIntRect *clipRect = child->GetEffectiveClipRect(); diff --git a/gfx/layers/LayersLogging.cpp b/gfx/layers/LayersLogging.cpp index 09a16ea8ab9..d170fb97c93 100644 --- a/gfx/layers/LayersLogging.cpp +++ b/gfx/layers/LayersLogging.cpp @@ -9,7 +9,6 @@ #include // for uint8_t #include "gfx3DMatrix.h" // for gfx3DMatrix #include "gfxColor.h" // for gfxRGBA -#include "gfxMatrix.h" // for gfxMatrix #include "mozilla/gfx/Matrix.h" // for Matrix4x4, Matrix #include "nsDebug.h" // for NS_ERROR #include "nsPoint.h" // for nsIntPoint @@ -69,31 +68,6 @@ AppendToString(nsACString& s, const gfxRGBA& c, return s += sfx; } -nsACString& -AppendToString(nsACString& s, const gfx3DMatrix& m, - const char* pfx, const char* sfx) -{ - s += pfx; - if (m.IsIdentity()) - s += "[ I ]"; - else { - gfxMatrix matrix; - if (m.Is2D(&matrix)) { - s += nsPrintfCString( - "[ %g %g; %g %g; %g %g; ]", - matrix.xx, matrix.yx, matrix.xy, matrix.yy, matrix.x0, matrix.y0); - } else { - s += nsPrintfCString( - "[ %g %g %g %g; %g %g %g %g; %g %g %g %g; %g %g %g %g; ]", - m._11, m._12, m._13, m._14, - m._21, m._22, m._23, m._24, - m._31, m._32, m._33, m._34, - m._41, m._42, m._43, m._44); - } - } - return s += sfx; -} - nsACString& AppendToString(nsACString& s, const nsIntPoint& p, const char* pfx, const char* sfx) diff --git a/gfx/layers/basic/BasicContainerLayer.cpp b/gfx/layers/basic/BasicContainerLayer.cpp index 69c9f3ba36a..84b662c0384 100644 --- a/gfx/layers/basic/BasicContainerLayer.cpp +++ b/gfx/layers/basic/BasicContainerLayer.cpp @@ -15,7 +15,6 @@ #include "nsISupportsImpl.h" // for Layer::AddRef, etc #include "nsPoint.h" // for nsIntPoint #include "nsRect.h" // for nsIntRect -#include "gfx3DMatrix.h" // for gfx3DMatrix #include "gfxMatrix.h" // for gfxMatrix #include "nsRegion.h" // for nsIntRegion @@ -81,14 +80,12 @@ BasicContainerLayer::ComputeEffectiveTransforms(const Matrix4x4& aTransformToSur bool BasicContainerLayer::ChildrenPartitionVisibleRegion(const nsIntRect& aInRect) { - gfxMatrix transform; - gfx3DMatrix effectiveTransform; - gfx::To3DMatrix(GetEffectiveTransform(), effectiveTransform); - if (!effectiveTransform.CanDraw2D(&transform) || - transform.HasNonIntegerTranslation()) + Matrix transform; + if (!GetEffectiveTransform().CanDraw2D(&transform) || + ThebesMatrix(transform).HasNonIntegerTranslation()) return false; - nsIntPoint offset(int32_t(transform.x0), int32_t(transform.y0)); + nsIntPoint offset(int32_t(transform._31), int32_t(transform._32)); nsIntRect rect = aInRect.Intersect(GetEffectiveVisibleRegion().GetBounds() + offset); nsIntRegion covered; @@ -96,15 +93,13 @@ BasicContainerLayer::ChildrenPartitionVisibleRegion(const nsIntRect& aInRect) if (ToData(l)->IsHidden()) continue; - gfxMatrix childTransform; - gfx3DMatrix effectiveTransform; - gfx::To3DMatrix(l->GetEffectiveTransform(), effectiveTransform); - if (!effectiveTransform.CanDraw2D(&childTransform) || - childTransform.HasNonIntegerTranslation() || + Matrix childTransform; + if (!l->GetEffectiveTransform().CanDraw2D(&childTransform) || + ThebesMatrix(childTransform).HasNonIntegerTranslation() || l->GetEffectiveOpacity() != 1.0) return false; nsIntRegion childRegion = l->GetEffectiveVisibleRegion(); - childRegion.MoveBy(int32_t(childTransform.x0), int32_t(childTransform.y0)); + childRegion.MoveBy(int32_t(childTransform._31), int32_t(childTransform._32)); childRegion.And(childRegion, rect); if (l->GetClipRect()) { childRegion.And(childRegion, *l->GetClipRect() + offset); diff --git a/gfx/layers/basic/BasicLayerManager.cpp b/gfx/layers/basic/BasicLayerManager.cpp index 0f6f811fc62..ee815a02978 100644 --- a/gfx/layers/basic/BasicLayerManager.cpp +++ b/gfx/layers/basic/BasicLayerManager.cpp @@ -160,17 +160,15 @@ public: // transform. bool Setup2DTransform() { - gfx3DMatrix effectiveTransform; - To3DMatrix(mLayer->GetEffectiveTransform(), effectiveTransform); // Will return an identity matrix for 3d transforms. - return effectiveTransform.CanDraw2D(&mTransform); + return mLayer->GetEffectiveTransform().CanDraw2D(&mTransform); } // Applies the effective transform if it's 2D. If it's a 3D transform then // it applies an identity. void Apply2DTransform() { - mTarget->SetMatrix(mTransform); + mTarget->SetMatrix(ThebesMatrix(mTransform)); } // Set the opaque rect to match the bounds of the visible region. @@ -232,7 +230,7 @@ public: LayerManager::DrawThebesLayerCallback mCallback; void* mCallbackData; ReadbackProcessor* mReadback; - gfxMatrix mTransform; + Matrix mTransform; bool mPushedOpaqueRect; }; @@ -354,12 +352,12 @@ BasicLayerManager::BeginTransactionWithTarget(gfxContext* aTarget) } static void -TransformIntRect(nsIntRect& aRect, const gfxMatrix& aMatrix, +TransformIntRect(nsIntRect& aRect, const Matrix& aMatrix, nsIntRect (*aRoundMethod)(const gfxRect&)) { - gfxRect gr = gfxRect(aRect.x, aRect.y, aRect.width, aRect.height); + Rect gr = Rect(aRect.x, aRect.y, aRect.width, aRect.height); gr = aMatrix.TransformBounds(gr); - aRect = (*aRoundMethod)(gr); + aRect = (*aRoundMethod)(ThebesRect(gr)); } /** @@ -403,10 +401,8 @@ MarkLayersHidden(Layer* aLayer, const nsIntRect& aClipRect, // clipRect is in the container's coordinate system. Get it into the // global coordinate system. if (aLayer->GetParent()) { - gfxMatrix tr; - gfx3DMatrix effectiveTransform; - gfx::To3DMatrix(aLayer->GetParent()->GetEffectiveTransform(), effectiveTransform); - if (effectiveTransform.CanDraw2D(&tr)) { + Matrix tr; + if (aLayer->GetParent()->GetEffectiveTransform().CanDraw2D(&tr)) { // Clip rect is applied after aLayer's transform, i.e., in the coordinate // system of aLayer's parent. TransformIntRect(cr, tr, ToInsideIntRect); @@ -424,10 +420,8 @@ MarkLayersHidden(Layer* aLayer, const nsIntRect& aClipRect, data->SetDrawAtomically(false); if (!aLayer->AsContainerLayer()) { - gfxMatrix transform; - gfx3DMatrix effectiveTransform; - gfx::To3DMatrix(aLayer->GetEffectiveTransform(), effectiveTransform); - if (!effectiveTransform.CanDraw2D(&transform)) { + Matrix transform; + if (!aLayer->GetEffectiveTransform().CanDraw2D(&transform)) { data->SetHidden(false); return; } @@ -487,13 +481,11 @@ ApplyDoubleBuffering(Layer* aLayer, const nsIntRect& aVisibleRect) // clipRect is in the container's coordinate system. Get it into the // global coordinate system. if (aLayer->GetParent()) { - gfxMatrix tr; - gfx3DMatrix effectiveTransform; - gfx::To3DMatrix(aLayer->GetParent()->GetEffectiveTransform(), effectiveTransform); - if (effectiveTransform.CanDraw2D(&tr)) { - NS_ASSERTION(!tr.HasNonIntegerTranslation(), + Matrix tr; + if (aLayer->GetParent()->GetEffectiveTransform().CanDraw2D(&tr)) { + NS_ASSERTION(!ThebesMatrix(tr).HasNonIntegerTranslation(), "Parent can only have an integer translation"); - cr += nsIntPoint(int32_t(tr.x0), int32_t(tr.y0)); + cr += nsIntPoint(int32_t(tr._31), int32_t(tr._32)); } else { NS_ERROR("Parent can only have an integer translation"); } diff --git a/gfx/layers/basic/BasicLayersImpl.cpp b/gfx/layers/basic/BasicLayersImpl.cpp index dbc7b70920d..19ce8a059a6 100644 --- a/gfx/layers/basic/BasicLayersImpl.cpp +++ b/gfx/layers/basic/BasicLayersImpl.cpp @@ -7,7 +7,6 @@ #include // for operator new #include "Layers.h" // for Layer, etc #include "basic/BasicImplData.h" // for BasicImplData -#include "gfx3DMatrix.h" // for gfx3DMatrix #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc #include "mozilla/DebugOnly.h" // for DebugOnly #include "mozilla/layers/CompositorTypes.h" @@ -70,15 +69,14 @@ GetMaskData(Layer* aMaskLayer, AutoMaskData* aMaskData) if (static_cast(aMaskLayer->ImplData()) ->GetAsSurface(getter_AddRefs(surface), &descriptor) && (surface || IsSurfaceDescriptorValid(descriptor))) { - gfxMatrix transform; - gfx3DMatrix effectiveTransform; - gfx::To3DMatrix(aMaskLayer->GetEffectiveTransform(), effectiveTransform); + Matrix transform; + Matrix4x4 effectiveTransform = aMaskLayer->GetEffectiveTransform(); DebugOnly maskIs2D = effectiveTransform.CanDraw2D(&transform); NS_ASSERTION(maskIs2D, "How did we end up with a 3D transform here?!"); if (surface) { - aMaskData->Construct(transform, surface); + aMaskData->Construct(ThebesMatrix(transform), surface); } else { - aMaskData->Construct(transform, descriptor); + aMaskData->Construct(ThebesMatrix(transform), descriptor); } return true; } diff --git a/gfx/layers/basic/BasicLayersImpl.h b/gfx/layers/basic/BasicLayersImpl.h index 13cf8624345..e414124725d 100644 --- a/gfx/layers/basic/BasicLayersImpl.h +++ b/gfx/layers/basic/BasicLayersImpl.h @@ -11,7 +11,6 @@ #include "ReadbackLayer.h" // for ReadbackLayer #include "gfxASurface.h" // for gfxASurface #include "gfxContext.h" // for gfxContext, etc -#include "gfxMatrix.h" // for gfxMatrix #include "ipc/AutoOpenSurface.h" // for AutoOpenSurface #include "mozilla/Attributes.h" // for MOZ_DELETE, MOZ_STACK_CLASS #include "mozilla/Maybe.h" // for Maybe diff --git a/gfx/layers/client/ClientContainerLayer.h b/gfx/layers/client/ClientContainerLayer.h index 10c1ba02d37..875f880684d 100644 --- a/gfx/layers/client/ClientContainerLayer.h +++ b/gfx/layers/client/ClientContainerLayer.h @@ -9,7 +9,6 @@ #include // for uint32_t #include "ClientLayerManager.h" // for ClientLayerManager, etc #include "Layers.h" // for Layer, ContainerLayer, etc -#include "gfx3DMatrix.h" // for gfx3DMatrix #include "gfxMatrix.h" // for gfxMatrix #include "gfxPlatform.h" // for gfxPlatform #include "nsDebug.h" // for NS_ASSERTION @@ -55,12 +54,10 @@ public: if (GetEffectiveVisibleRegion().GetNumRects() != 1 || !(GetContentFlags() & Layer::CONTENT_OPAQUE)) { - gfx3DMatrix transform3D; - gfx::To3DMatrix(GetEffectiveTransform(), transform3D); - gfxMatrix transform; + gfx::Matrix transform; if (HasOpaqueAncestorLayer(this) && - transform3D.Is2D(&transform) && - !transform.HasNonIntegerTranslation()) { + GetEffectiveTransform().Is2D(&transform) && + !gfx::ThebesMatrix(transform).HasNonIntegerTranslation()) { SetSupportsComponentAlphaChildren( gfxPlatform::ComponentAlphaEnabled()); } @@ -117,7 +114,7 @@ public: aAfter ? ClientManager()->Hold(aAfter) : nullptr); ContainerLayer::RepositionChild(aChild, aAfter); } - + virtual Layer* AsLayer() { return this; } virtual ShadowableLayer* AsShadowableLayer() { return this; } diff --git a/gfx/layers/composite/CanvasLayerComposite.cpp b/gfx/layers/composite/CanvasLayerComposite.cpp index 776f22d23c4..06de1f41f7a 100644 --- a/gfx/layers/composite/CanvasLayerComposite.cpp +++ b/gfx/layers/composite/CanvasLayerComposite.cpp @@ -22,6 +22,7 @@ using namespace mozilla; using namespace mozilla::layers; +using namespace mozilla::gfx; CanvasLayerComposite::CanvasLayerComposite(LayerManagerComposite* aManager) : CanvasLayer(aManager, nullptr) @@ -80,11 +81,9 @@ CanvasLayerComposite::RenderLayer(const nsIntRect& aClipRect) // Bug 691354 // Using the LINEAR filter we get unexplained artifacts. // Use NEAREST when no scaling is required. - gfxMatrix matrix; - gfx3DMatrix effectiveTransform; - gfx::To3DMatrix(GetEffectiveTransform(), effectiveTransform); - bool is2D = effectiveTransform.Is2D(&matrix); - if (is2D && !matrix.HasNonTranslationOrFlip()) { + Matrix matrix; + bool is2D = GetEffectiveTransform().Is2D(&matrix); + if (is2D && !ThebesMatrix(matrix).HasNonTranslationOrFlip()) { filter = GraphicsFilter::FILTER_NEAREST; } #endif diff --git a/gfx/layers/composite/ContainerLayerComposite.cpp b/gfx/layers/composite/ContainerLayerComposite.cpp index ed6a67705a7..5efd4d84322 100644 --- a/gfx/layers/composite/ContainerLayerComposite.cpp +++ b/gfx/layers/composite/ContainerLayerComposite.cpp @@ -242,18 +242,17 @@ ContainerRender(ContainerT* aContainer, aContainer->mSupportsComponentAlphaChildren = true; mode = INIT_MODE_NONE; } else { - gfx3DMatrix transform3D; - gfx::To3DMatrix(aContainer->GetEffectiveTransform(), transform3D); - gfxMatrix transform; + const gfx::Matrix4x4& transform3D = aContainer->GetEffectiveTransform(); + gfx::Matrix transform; // If we have an opaque ancestor layer, then we can be sure that // all the pixels we draw into are either opaque already or will be // covered by something opaque. Otherwise copying up the background is // not safe. if (HasOpaqueAncestorLayer(aContainer) && - transform3D.Is2D(&transform) && !transform.HasNonIntegerTranslation()) { + transform3D.Is2D(&transform) && !ThebesMatrix(transform).HasNonIntegerTranslation()) { surfaceCopyNeeded = gfxPlatform::ComponentAlphaEnabled(); - sourcePoint.x += transform.x0; - sourcePoint.y += transform.y0; + sourcePoint.x += transform._31; + sourcePoint.y += transform._32; aContainer->mSupportsComponentAlphaChildren = gfxPlatform::ComponentAlphaEnabled(); } diff --git a/gfx/layers/composite/ThebesLayerComposite.cpp b/gfx/layers/composite/ThebesLayerComposite.cpp index 0e6760dc88e..aebea2cfe53 100644 --- a/gfx/layers/composite/ThebesLayerComposite.cpp +++ b/gfx/layers/composite/ThebesLayerComposite.cpp @@ -8,7 +8,6 @@ #include "FrameMetrics.h" // for FrameMetrics #include "Units.h" // for CSSRect, LayerPixel, etc #include "gfx2DGlue.h" // for ToMatrix4x4 -#include "gfx3DMatrix.h" // for gfx3DMatrix #include "gfxUtils.h" // for gfxUtils, etc #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc #include "mozilla/gfx/Matrix.h" // for Matrix4x4 diff --git a/gfx/layers/d3d10/ContainerLayerD3D10.cpp b/gfx/layers/d3d10/ContainerLayerD3D10.cpp index 3c329ab80d6..965d60eccac 100644 --- a/gfx/layers/d3d10/ContainerLayerD3D10.cpp +++ b/gfx/layers/d3d10/ContainerLayerD3D10.cpp @@ -8,6 +8,8 @@ #include "ThebesLayerD3D10.h" #include "ReadbackProcessor.h" +using namespace mozilla::gfx; + namespace mozilla { namespace layers { @@ -106,9 +108,8 @@ ContainerLayerD3D10::RenderLayer() previousViewportSize = mD3DManager->GetViewport(); if (mVisibleRegion.GetNumRects() != 1 || !(GetContentFlags() & CONTENT_OPAQUE)) { - gfx3DMatrix transform3D; - gfx::To3DMatrix(GetEffectiveTransform(), transform3D); - gfxMatrix transform; + Matrix4x4 transform3D = GetEffectiveTransform(); + Matrix transform; // If we have an opaque ancestor layer, then we can be sure that // all the pixels we draw into are either opaque already or will be // covered by something opaque. Otherwise copying up the background is @@ -121,8 +122,8 @@ ContainerLayerD3D10::RenderLayer() // applied to use relative to our parent, and compensates for the offset // that was applied on our parent's rendering. D3D10_BOX srcBox; - srcBox.left = std::max(visibleRect.x + int32_t(transform.x0) - int32_t(previousRenderTargetOffset[0]), 0); - srcBox.top = std::max(visibleRect.y + int32_t(transform.y0) - int32_t(previousRenderTargetOffset[1]), 0); + srcBox.left = std::max(visibleRect.x + int32_t(transform._31) - int32_t(previousRenderTargetOffset[0]), 0); + srcBox.top = std::max(visibleRect.y + int32_t(transform._32) - int32_t(previousRenderTargetOffset[1]), 0); srcBox.right = std::min(srcBox.left + visibleRect.width, previousViewportSize.width); srcBox.bottom = std::min(srcBox.top + visibleRect.height, previousViewportSize.height); srcBox.back = 1; @@ -248,16 +249,15 @@ ContainerLayerD3D10::Validate() mSupportsComponentAlphaChildren = false; if (UseIntermediateSurface()) { - gfx3DMatrix transform3D; - gfx::To3DMatrix(GetEffectiveTransform(), transform3D); - gfxMatrix transform; + Matrix4x4 transform3D = GetEffectiveTransform(); + Matrix transform; if (mVisibleRegion.GetNumRects() == 1 && (GetContentFlags() & CONTENT_OPAQUE)) { // don't need a background, we're going to paint all opaque stuff mSupportsComponentAlphaChildren = true; } else { if (HasOpaqueAncestorLayer(this) && - transform3D.Is2D(&transform) && !transform.HasNonIntegerTranslation() && + transform3D.Is2D(&transform) && !ThebesMatrix(transform).HasNonIntegerTranslation() && GetParent()->GetEffectiveVisibleRegion().GetBounds().Contains(visibleRect)) { // In this case we can copy up the background. See RenderLayer. diff --git a/gfx/layers/d3d10/LayerManagerD3D10.cpp b/gfx/layers/d3d10/LayerManagerD3D10.cpp index be430699289..272c4227dbb 100644 --- a/gfx/layers/d3d10/LayerManagerD3D10.cpp +++ b/gfx/layers/d3d10/LayerManagerD3D10.cpp @@ -859,12 +859,11 @@ LayerD3D10::LoadMaskTexture() return SHADER_NO_MASK; } - gfxMatrix maskTransform; - gfx3DMatrix effectiveTransform; - gfx::To3DMatrix(maskLayer->GetEffectiveTransform(), effectiveTransform); + Matrix maskTransform; + Matrix4x4 effectiveTransform = maskLayer->GetEffectiveTransform(); bool maskIs2D = effectiveTransform.CanDraw2D(&maskTransform); NS_ASSERTION(maskIs2D, "How did we end up with a 3D transform here?!"); - gfxRect bounds = gfxRect(gfxPoint(), ThebesIntSize(size)); + Rect bounds = Rect(Point(), Size(size)); bounds = maskTransform.TransformBounds(bounds); effect()->GetVariableByName("vMaskQuad")->AsVector()->SetFloatVector( diff --git a/gfx/layers/d3d9/ContainerLayerD3D9.cpp b/gfx/layers/d3d9/ContainerLayerD3D9.cpp index aae7d3b7cbc..8a31f5cfbb7 100644 --- a/gfx/layers/d3d9/ContainerLayerD3D9.cpp +++ b/gfx/layers/d3d9/ContainerLayerD3D9.cpp @@ -8,6 +8,8 @@ #include "ThebesLayerD3D9.h" #include "ReadbackProcessor.h" +using namespace mozilla::gfx; + namespace mozilla { namespace layers { @@ -89,22 +91,21 @@ ContainerLayerD3D9::RenderLayer() // don't need a background, we're going to paint all opaque stuff mSupportsComponentAlphaChildren = true; } else { - gfx3DMatrix transform3D; - gfx::To3DMatrix(GetEffectiveTransform(), transform3D); - gfxMatrix transform; + Matrix4x4 transform3D = GetEffectiveTransform(); + Matrix transform; // If we have an opaque ancestor layer, then we can be sure that // all the pixels we draw into are either opaque already or will be // covered by something opaque. Otherwise copying up the background is // not safe. HRESULT hr = E_FAIL; if (HasOpaqueAncestorLayer(this) && - transform3D.Is2D(&transform) && !transform.HasNonIntegerTranslation()) { + transform3D.Is2D(&transform) && !ThebesMatrix(transform).HasNonIntegerTranslation()) { // Copy background up from below RECT dest = { 0, 0, visibleRect.width, visibleRect.height }; RECT src = dest; ::OffsetRect(&src, - visibleRect.x + int32_t(transform.x0), - visibleRect.y + int32_t(transform.y0)); + visibleRect.x + int32_t(transform._31), + visibleRect.y + int32_t(transform._32)); if (!mD3DManager->CompositingDisabled()) { hr = device()-> StretchRect(previousRenderTarget, &src, renderSurface, &dest, D3DTEXF_NONE); diff --git a/gfx/layers/d3d9/DeviceManagerD3D9.cpp b/gfx/layers/d3d9/DeviceManagerD3D9.cpp index 2db81259b46..935bab87e1d 100644 --- a/gfx/layers/d3d9/DeviceManagerD3D9.cpp +++ b/gfx/layers/d3d9/DeviceManagerD3D9.cpp @@ -549,7 +549,7 @@ bool LoadMaskTexture(Layer* aMask, IDirect3DDevice9* aDevice, uint32_t aMaskTexRegister) { - gfx::IntSize size; + IntSize size; nsRefPtr texture = static_cast(aMask->ImplData())->GetAsTexture(&size); @@ -557,12 +557,11 @@ LoadMaskTexture(Layer* aMask, IDirect3DDevice9* aDevice, return false; } - gfxMatrix maskTransform; - gfx3DMatrix effectiveTransform; - gfx::To3DMatrix(aMask->GetEffectiveTransform(), effectiveTransform); + Matrix maskTransform; + Matrix4x4 effectiveTransform = aMask->GetEffectiveTransform(); bool maskIs2D = effectiveTransform.CanDraw2D(&maskTransform); NS_ASSERTION(maskIs2D, "How did we end up with a 3D transform here?!"); - gfxRect bounds = gfxRect(gfxPoint(), gfx::ThebesIntSize(size)); + Rect bounds = Rect(Point(), Size(size)); bounds = maskTransform.TransformBounds(bounds); aDevice->SetVertexShaderConstantF(DeviceManagerD3D9::sMaskQuadRegister, From 0a543106f358ec7671d2e77d4663dca9c9b89ab7 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Mon, 27 Jan 2014 15:25:20 -0500 Subject: [PATCH 014/296] Bug 952977: Convert OGLShaderProgram to gfx::Matrix r=nical --- gfx/layers/opengl/CompositorOGL.cpp | 14 +++++++++----- gfx/layers/opengl/OGLShaderProgram.h | 8 -------- widget/cocoa/nsChildView.mm | 6 ++++-- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index e9c09bb1956..c34663f197a 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -231,8 +231,8 @@ FPSState::DrawFPS(TimeStamp aNow, aProgram->SetTextureUnit(0); aProgram->SetLayerQuadRect(gfx::Rect(0.f, 0.f, viewport[2], viewport[3])); aProgram->SetLayerOpacity(1.f); - aProgram->SetTextureTransform(gfx3DMatrix()); - aProgram->SetLayerTransform(gfx3DMatrix()); + aProgram->SetTextureTransform(Matrix4x4()); + aProgram->SetLayerTransform(Matrix4x4()); aProgram->SetRenderOffset(0, 0); aContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ZERO, @@ -628,10 +628,14 @@ CompositorOGL::BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg, gfx3DMatrix textureTransform; if (rects.IsSimpleQuad(textureTransform)) { - aProg->SetTextureTransform(aTextureTransform * textureTransform); + Matrix4x4 transform; + ToMatrix4x4(aTextureTransform * textureTransform, transform); + aProg->SetTextureTransform(transform); BindAndDrawQuad(aProg, false); } else { - aProg->SetTextureTransform(aTextureTransform); + Matrix4x4 transform; + ToMatrix4x4(aTextureTransform, transform); + aProg->SetTextureTransform(transform); DrawQuads(mGLContext, mVBOs, aProg, rects); } } @@ -1299,7 +1303,7 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect, program->Activate(); program->SetTextureUnit(0); program->SetLayerOpacity(aOpacity); - program->SetTextureTransform(gfx3DMatrix()); + program->SetTextureTransform(Matrix4x4()); AutoSaveTexture bindMask(mGLContext, LOCAL_GL_TEXTURE1); if (maskType != MaskNone) { diff --git a/gfx/layers/opengl/OGLShaderProgram.h b/gfx/layers/opengl/OGLShaderProgram.h index 8551d11bdc4..06a69867e79 100644 --- a/gfx/layers/opengl/OGLShaderProgram.h +++ b/gfx/layers/opengl/OGLShaderProgram.h @@ -255,10 +255,6 @@ public: * Not all uniforms may be set for all programs, and such uses will throw * an assertion. */ - void SetLayerTransform(const gfx3DMatrix& aMatrix) { - SetMatrixUniform(mProfile.LookupUniformLocation("uLayerTransform"), aMatrix); - } - void SetLayerTransform(const gfx::Matrix4x4& aMatrix) { SetMatrixUniform(mProfile.LookupUniformLocation("uLayerTransform"), aMatrix); } @@ -300,10 +296,6 @@ public: } // sets this program's texture transform, if it uses one - void SetTextureTransform(const gfx3DMatrix& aMatrix) { - SetMatrixUniform(mProfile.LookupUniformLocation("uTextureTransform"), aMatrix); - } - void SetTextureTransform(const gfx::Matrix4x4& aMatrix) { SetMatrixUniform(mProfile.LookupUniformLocation("uTextureTransform"), aMatrix); } diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 47398315d95..69534bfefbc 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -2762,8 +2762,10 @@ RectTextureImage::Draw(GLManager* aManager, program->Activate(); program->SetLayerQuadRect(nsIntRect(nsIntPoint(0, 0), mUsedSize)); - program->SetLayerTransform(aTransform * gfx3DMatrix::Translation(aLocation.x, aLocation.y, 0)); - program->SetTextureTransform(gfx3DMatrix()); + gfx::Matrix4x4 transform; + gfx::ToMatrix4x4(aTransform, transform); + program->SetLayerTransform(transform * gfx::Matrix4x4().Translate(aLocation.x, aLocation.y, 0)); + program->SetTextureTransform(gfx::Matrix4x4()); program->SetLayerOpacity(1.0); program->SetRenderOffset(nsIntPoint(0, 0)); program->SetTexCoordMultiplier(mUsedSize.width, mUsedSize.height); From ac7a35fed2f5b558dd0aa97adb6302a5f78dac51 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Mon, 27 Jan 2014 15:25:20 -0500 Subject: [PATCH 015/296] Bug 952977: Convert PrepareViewport to gfx::Matrix4x4 r=nical --- gfx/layers/Compositor.h | 2 +- gfx/layers/basic/BasicCompositor.h | 2 +- gfx/layers/d3d11/CompositorD3D11.cpp | 10 +++++----- gfx/layers/d3d11/CompositorD3D11.h | 2 +- gfx/layers/d3d9/CompositorD3D9.cpp | 8 ++++---- gfx/layers/d3d9/CompositorD3D9.h | 2 +- gfx/layers/opengl/CompositingRenderTargetOGL.cpp | 4 ++-- gfx/layers/opengl/CompositorOGL.cpp | 12 ++++++------ gfx/layers/opengl/CompositorOGL.h | 4 ++-- gfx/layers/opengl/OGLShaderProgram.h | 6 +++--- widget/cocoa/nsChildView.mm | 6 +++--- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/gfx/layers/Compositor.h b/gfx/layers/Compositor.h index 964ce9765df..9ee864aca50 100644 --- a/gfx/layers/Compositor.h +++ b/gfx/layers/Compositor.h @@ -363,7 +363,7 @@ public: * coordinate space. */ virtual void PrepareViewport(const gfx::IntSize& aSize, - const gfxMatrix& aWorldTransform) = 0; + const gfx::Matrix& aWorldTransform) = 0; /** * Whether textures created by this compositor can receive partial updates. diff --git a/gfx/layers/basic/BasicCompositor.h b/gfx/layers/basic/BasicCompositor.h index 8e807f23520..28ceed610ce 100644 --- a/gfx/layers/basic/BasicCompositor.h +++ b/gfx/layers/basic/BasicCompositor.h @@ -112,7 +112,7 @@ public: virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) { } virtual void PrepareViewport(const gfx::IntSize& aSize, - const gfxMatrix& aWorldTransform) MOZ_OVERRIDE { } + const gfx::Matrix& aWorldTransform) MOZ_OVERRIDE { } virtual void NotifyLayersTransaction() MOZ_OVERRIDE { } diff --git a/gfx/layers/d3d11/CompositorD3D11.cpp b/gfx/layers/d3d11/CompositorD3D11.cpp index 00ff3d571b7..11ee8285bec 100644 --- a/gfx/layers/d3d11/CompositorD3D11.cpp +++ b/gfx/layers/d3d11/CompositorD3D11.cpp @@ -457,7 +457,7 @@ CompositorD3D11::SetRenderTarget(CompositingRenderTarget* aRenderTarget) ID3D11RenderTargetView* view = newRT->mRTView; mCurrentRT = newRT; mContext->OMSetRenderTargets(1, &view, nullptr); - PrepareViewport(newRT->GetSize(), gfxMatrix()); + PrepareViewport(newRT->GetSize(), gfx::Matrix()); } void @@ -748,7 +748,7 @@ CompositorD3D11::EndFrame() void CompositorD3D11::PrepareViewport(const gfx::IntSize& aSize, - const gfxMatrix& aWorldTransform) + const gfx::Matrix& aWorldTransform) { D3D11_VIEWPORT viewport; viewport.MaxDepth = 1.0f; @@ -760,14 +760,14 @@ CompositorD3D11::PrepareViewport(const gfx::IntSize& aSize, mContext->RSSetViewports(1, &viewport); - gfxMatrix viewMatrix; - viewMatrix.Translate(-gfxPoint(1.0, -1.0)); + Matrix viewMatrix; + viewMatrix.Translate(-1.0, 1.0); viewMatrix.Scale(2.0f / float(aSize.width), 2.0f / float(aSize.height)); viewMatrix.Scale(1.0f, -1.0f); viewMatrix = aWorldTransform * viewMatrix; - gfx3DMatrix projection = gfx3DMatrix::From2D(viewMatrix); + Matrix4x4 projection = Matrix4x4::From2D(viewMatrix); projection._33 = 0.0f; memcpy(&mVSConstants.projection, &projection, sizeof(mVSConstants.projection)); diff --git a/gfx/layers/d3d11/CompositorD3D11.h b/gfx/layers/d3d11/CompositorD3D11.h index 106c99c4e35..7da8f3b375c 100644 --- a/gfx/layers/d3d11/CompositorD3D11.h +++ b/gfx/layers/d3d11/CompositorD3D11.h @@ -128,7 +128,7 @@ public: * to a window of the given dimensions. */ virtual void PrepareViewport(const gfx::IntSize& aSize, - const gfxMatrix& aWorldTransform) MOZ_OVERRIDE; + const gfx::Matrix& aWorldTransform) MOZ_OVERRIDE; virtual bool SupportsPartialTextureUpdate() MOZ_OVERRIDE { return true; } diff --git a/gfx/layers/d3d9/CompositorD3D9.cpp b/gfx/layers/d3d9/CompositorD3D9.cpp index 6c6402ecf3e..6c06dcd8582 100644 --- a/gfx/layers/d3d9/CompositorD3D9.cpp +++ b/gfx/layers/d3d9/CompositorD3D9.cpp @@ -188,7 +188,7 @@ CompositorD3D9::SetRenderTarget(CompositingRenderTarget *aRenderTarget) RefPtr oldRT = mCurrentRT; mCurrentRT = static_cast(aRenderTarget); mCurrentRT->BindRenderTarget(device()); - PrepareViewport(mCurrentRT->GetSize(), gfxMatrix()); + PrepareViewport(mCurrentRT->GetSize(), Matrix()); } static DeviceManagerD3D9::ShaderMode @@ -651,9 +651,9 @@ CompositorD3D9::EndFrame() void CompositorD3D9::PrepareViewport(const gfx::IntSize& aSize, - const gfxMatrix &aWorldTransform) + const Matrix &aWorldTransform) { - gfx3DMatrix viewMatrix; + Matrix4x4 viewMatrix; /* * Matrix to transform to viewport space ( <-1.0, 1.0> topleft, * <1.0, -1.0> bottomright) @@ -663,7 +663,7 @@ CompositorD3D9::PrepareViewport(const gfx::IntSize& aSize, viewMatrix._41 = -1.0f; viewMatrix._42 = 1.0f; - viewMatrix = gfx3DMatrix::From2D(aWorldTransform) * viewMatrix; + viewMatrix = Matrix4x4::From2D(aWorldTransform) * viewMatrix; HRESULT hr = device()->SetVertexShaderConstantF(CBmProjection, &viewMatrix._11, 4); diff --git a/gfx/layers/d3d9/CompositorD3D9.h b/gfx/layers/d3d9/CompositorD3D9.h index 0e2ee154c02..9c849112f19 100644 --- a/gfx/layers/d3d9/CompositorD3D9.h +++ b/gfx/layers/d3d9/CompositorD3D9.h @@ -75,7 +75,7 @@ public: virtual void AbortFrame() MOZ_OVERRIDE {} virtual void PrepareViewport(const gfx::IntSize& aSize, - const gfxMatrix& aWorldTransform) MOZ_OVERRIDE; + const gfx::Matrix& aWorldTransform) MOZ_OVERRIDE; virtual bool SupportsPartialTextureUpdate() MOZ_OVERRIDE{ return true; } diff --git a/gfx/layers/opengl/CompositingRenderTargetOGL.cpp b/gfx/layers/opengl/CompositingRenderTargetOGL.cpp index db2d26cf304..b4dddfbe3fb 100644 --- a/gfx/layers/opengl/CompositingRenderTargetOGL.cpp +++ b/gfx/layers/opengl/CompositingRenderTargetOGL.cpp @@ -55,7 +55,7 @@ CompositingRenderTargetOGL::BindRenderTarget() } } - mCompositor->PrepareViewport(mInitParams.mSize, mTransform); + mCompositor->PrepareViewport(mInitParams.mSize, ToMatrix(mTransform)); } } @@ -91,7 +91,7 @@ CompositingRenderTargetOGL::InitializeImpl() NS_ERROR(msg.get()); } - mCompositor->PrepareViewport(mInitParams.mSize, mTransform); + mCompositor->PrepareViewport(mInitParams.mSize, ToMatrix(mTransform)); mGL->fScissor(0, 0, mInitParams.mSize.width, mInitParams.mSize.height); if (mInitParams.mInit == INIT_MODE_CLEAR) { mGL->fClearColor(0.0, 0.0, 0.0, 0.0); diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index c34663f197a..4a4d22e9f9b 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -642,7 +642,7 @@ CompositorOGL::BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg, void CompositorOGL::PrepareViewport(const gfx::IntSize& aSize, - const gfxMatrix& aWorldTransform) + const Matrix& aWorldTransform) { // Set the viewport correctly. mGLContext->fViewport(0, 0, aSize.width, aSize.height); @@ -659,24 +659,24 @@ CompositorOGL::PrepareViewport(const gfx::IntSize& aSize, // Matrix to transform (0, 0, aWidth, aHeight) to viewport space (-1.0, 1.0, // 2, 2) and flip the contents. - gfxMatrix viewMatrix; - viewMatrix.Translate(-gfxPoint(1.0, -1.0)); + Matrix viewMatrix; + viewMatrix.Translate(-1.0, 1.0); viewMatrix.Scale(2.0f / float(aSize.width), 2.0f / float(aSize.height)); viewMatrix.Scale(1.0f, -1.0f); if (!mTarget) { - viewMatrix.Translate(gfxPoint(mRenderOffset.x, mRenderOffset.y)); + viewMatrix.Translate(mRenderOffset.x, mRenderOffset.y); } viewMatrix = aWorldTransform * viewMatrix; - gfx3DMatrix matrix3d = gfx3DMatrix::From2D(viewMatrix); + Matrix4x4 matrix3d = Matrix4x4::From2D(viewMatrix); matrix3d._33 = 0.0f; SetLayerProgramProjectionMatrix(matrix3d); } void -CompositorOGL::SetLayerProgramProjectionMatrix(const gfx3DMatrix& aMatrix) +CompositorOGL::SetLayerProgramProjectionMatrix(const Matrix4x4& aMatrix) { for (unsigned int i = 0; i < mPrograms.Length(); ++i) { for (uint32_t mask = MaskNone; mask < NumMaskTypes; ++mask) { diff --git a/gfx/layers/opengl/CompositorOGL.h b/gfx/layers/opengl/CompositorOGL.h index ea9bd34e7b6..6738af80644 100644 --- a/gfx/layers/opengl/CompositorOGL.h +++ b/gfx/layers/opengl/CompositorOGL.h @@ -145,7 +145,7 @@ public: } virtual void PrepareViewport(const gfx::IntSize& aSize, - const gfxMatrix& aWorldTransform) MOZ_OVERRIDE; + const gfx::Matrix& aWorldTransform) MOZ_OVERRIDE; #ifdef MOZ_DUMP_PAINTING @@ -272,7 +272,7 @@ private: /** * Updates all layer programs with a new projection matrix. */ - void SetLayerProgramProjectionMatrix(const gfx3DMatrix& aMatrix); + void SetLayerProgramProjectionMatrix(const gfx::Matrix4x4& aMatrix); /** * Helper method for Initialize, creates all valid variations of a program diff --git a/gfx/layers/opengl/OGLShaderProgram.h b/gfx/layers/opengl/OGLShaderProgram.h index 06a69867e79..ec36ac260aa 100644 --- a/gfx/layers/opengl/OGLShaderProgram.h +++ b/gfx/layers/opengl/OGLShaderProgram.h @@ -282,7 +282,7 @@ public: } // activates this program and sets its projection matrix, if the program uses one - void CheckAndSetProjectionMatrix(const gfx3DMatrix& aMatrix) + void CheckAndSetProjectionMatrix(const gfx::Matrix4x4& aMatrix) { if (mProfile.mHasMatrixProj) { mIsProjectionMatrixStale = true; @@ -290,7 +290,7 @@ public: } } - void SetProjectionMatrix(const gfx3DMatrix& aMatrix) { + void SetProjectionMatrix(const gfx::Matrix4x4& aMatrix) { SetMatrixUniform(mProfile.LookupUniformLocation("uMatrixProj"), aMatrix); mIsProjectionMatrixStale = false; } @@ -365,7 +365,7 @@ public: static const char* const TexCoordAttrib; protected: - gfx3DMatrix mProjectionMatrix; + gfx::Matrix4x4 mProjectionMatrix; // true if the projection matrix needs setting bool mIsProjectionMatrixStale; diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 69534bfefbc..971b874ffd9 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -2839,12 +2839,12 @@ GLPresenter::BeginFrame(nsIntSize aRenderSize) // Matrix to transform (0, 0, width, height) to viewport space (-1.0, 1.0, // 2, 2) and flip the contents. - gfxMatrix viewMatrix; - viewMatrix.Translate(-gfxPoint(1.0, -1.0)); + gfx::Matrix viewMatrix; + viewMatrix.Translate(-1.0, 1.0); viewMatrix.Scale(2.0f / float(aRenderSize.width), 2.0f / float(aRenderSize.height)); viewMatrix.Scale(1.0f, -1.0f); - gfx3DMatrix matrix3d = gfx3DMatrix::From2D(viewMatrix); + gfx::Matrix4x4 matrix3d = gfx::Matrix4x4::From2D(viewMatrix); matrix3d._33 = 0.0f; mRGBARectProgram->CheckAndSetProjectionMatrix(matrix3d); From 8cfe88a6c26920c9cdac714325b3987875e58ce5 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Mon, 27 Jan 2014 15:25:20 -0500 Subject: [PATCH 016/296] Bug 952977: Convert DrawTo to gfx::Matrix4x4 r=nical --- gfx/layers/RotatedBuffer.cpp | 4 ++-- gfx/layers/RotatedBuffer.h | 2 +- gfx/layers/basic/BasicThebesLayer.cpp | 8 ++++---- gfx/layers/client/ContentClient.h | 3 +-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/gfx/layers/RotatedBuffer.cpp b/gfx/layers/RotatedBuffer.cpp index e211c419a61..ae2b8124410 100644 --- a/gfx/layers/RotatedBuffer.cpp +++ b/gfx/layers/RotatedBuffer.cpp @@ -188,7 +188,7 @@ RotatedContentBuffer::DrawTo(ThebesLayer* aLayer, float aOpacity, CompositionOp aOp, gfxASurface* aMask, - const gfxMatrix* aMaskTransform) + const Matrix* aMaskTransform) { if (!EnsureBuffer()) { return; @@ -220,7 +220,7 @@ RotatedContentBuffer::DrawTo(ThebesLayer* aLayer, Matrix maskTransform; if (aMaskTransform) { - maskTransform = ToMatrix(*aMaskTransform); + maskTransform = *aMaskTransform; } DrawBufferWithRotation(aTarget, BUFFER_BLACK, aOpacity, aOp, mask, &maskTransform); diff --git a/gfx/layers/RotatedBuffer.h b/gfx/layers/RotatedBuffer.h index 3b27de98843..9e8f26bd966 100644 --- a/gfx/layers/RotatedBuffer.h +++ b/gfx/layers/RotatedBuffer.h @@ -292,7 +292,7 @@ public: float aOpacity, gfx::CompositionOp aOp, gfxASurface* aMask, - const gfxMatrix* aMaskTransform); + const gfx::Matrix* aMaskTransform); protected: TemporaryRef diff --git a/gfx/layers/basic/BasicThebesLayer.cpp b/gfx/layers/basic/BasicThebesLayer.cpp index b4193afee80..673a363ff67 100644 --- a/gfx/layers/basic/BasicThebesLayer.cpp +++ b/gfx/layers/basic/BasicThebesLayer.cpp @@ -126,16 +126,16 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext, // is internal to basic layers AutoMaskData mask; gfxASurface* maskSurface = nullptr; - const gfxMatrix* maskTransform = nullptr; + Matrix maskTransform; if (GetMaskData(aMaskLayer, &mask)) { maskSurface = mask.GetSurface(); - maskTransform = &mask.GetTransform(); + maskTransform = ToMatrix(mask.GetTransform()); } if (!IsHidden() && !clipExtents.IsEmpty()) { mContentClient->DrawTo(this, aContext->GetDrawTarget(), opacity, CompositionOpForOp(GetOperator()), - maskSurface, maskTransform); + maskSurface, &maskTransform); } for (uint32_t i = 0; i < readbackUpdates.Length(); ++i) { @@ -149,7 +149,7 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext, ctx->Translate(gfxPoint(offset.x, offset.y)); mContentClient->DrawTo(this, ctx->GetDrawTarget(), 1.0, CompositionOpForOp(ctx->CurrentOperator()), - maskSurface, maskTransform); + maskSurface, &maskTransform); update.mLayer->GetSink()->EndUpdate(ctx, update.mUpdateRect + offset); } } diff --git a/gfx/layers/client/ContentClient.h b/gfx/layers/client/ContentClient.h index f66aa9dbbf3..fbec50823e1 100644 --- a/gfx/layers/client/ContentClient.h +++ b/gfx/layers/client/ContentClient.h @@ -28,7 +28,6 @@ #include "nsTArray.h" // for nsTArray class gfxContext; -struct gfxMatrix; class gfxASurface; namespace mozilla { @@ -158,7 +157,7 @@ public: float aOpacity, gfx::CompositionOp aOp, gfxASurface* aMask, - const gfxMatrix* aMaskTransform) + const gfx::Matrix* aMaskTransform) { RotatedContentBuffer::DrawTo(aLayer, aTarget, aOpacity, aOp, aMask, aMaskTransform); From 92ffaedc7548d936cfff67384e9cfcfc0e1b3089 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Mon, 27 Jan 2014 15:25:21 -0500 Subject: [PATCH 017/296] Bug 952977: Convert CompositingRenderTargetOGL to gfx::Matrix4x4 r=nical --- gfx/layers/Compositor.h | 1 - gfx/layers/ReadbackProcessor.cpp | 1 - gfx/layers/basic/BasicContainerLayer.cpp | 1 - gfx/layers/basic/BasicThebesLayer.cpp | 2 -- gfx/layers/client/ClientContainerLayer.h | 1 - gfx/layers/composite/ContainerLayerComposite.cpp | 1 - gfx/layers/opengl/CompositingRenderTargetOGL.cpp | 4 ++-- gfx/layers/opengl/CompositingRenderTargetOGL.h | 7 +++---- gfx/layers/opengl/CompositorOGL.cpp | 8 ++++---- gfx/layers/opengl/CompositorOGL.h | 3 +-- gfx/layers/opengl/OGLShaderProgram.cpp | 1 - 11 files changed, 10 insertions(+), 20 deletions(-) diff --git a/gfx/layers/Compositor.h b/gfx/layers/Compositor.h index 9ee864aca50..37a71283563 100644 --- a/gfx/layers/Compositor.h +++ b/gfx/layers/Compositor.h @@ -104,7 +104,6 @@ */ class nsIWidget; -struct gfxMatrix; struct nsIntSize; class nsIntRegion; diff --git a/gfx/layers/ReadbackProcessor.cpp b/gfx/layers/ReadbackProcessor.cpp index cd4b02a54ec..947f06a57d3 100644 --- a/gfx/layers/ReadbackProcessor.cpp +++ b/gfx/layers/ReadbackProcessor.cpp @@ -10,7 +10,6 @@ #include "gfx3DMatrix.h" // for gfx3DMatrix #include "gfxColor.h" // for gfxRGBA #include "gfxContext.h" // for gfxContext -#include "gfxMatrix.h" // for gfxMatrix #include "gfxRect.h" // for gfxRect #include "mozilla/gfx/BasePoint.h" // for BasePoint #include "mozilla/gfx/BaseRect.h" // for BaseRect diff --git a/gfx/layers/basic/BasicContainerLayer.cpp b/gfx/layers/basic/BasicContainerLayer.cpp index 84b662c0384..46672bc8465 100644 --- a/gfx/layers/basic/BasicContainerLayer.cpp +++ b/gfx/layers/basic/BasicContainerLayer.cpp @@ -15,7 +15,6 @@ #include "nsISupportsImpl.h" // for Layer::AddRef, etc #include "nsPoint.h" // for nsIntPoint #include "nsRect.h" // for nsIntRect -#include "gfxMatrix.h" // for gfxMatrix #include "nsRegion.h" // for nsIntRegion using namespace mozilla::gfx; diff --git a/gfx/layers/basic/BasicThebesLayer.cpp b/gfx/layers/basic/BasicThebesLayer.cpp index 673a363ff67..a75e2b7b161 100644 --- a/gfx/layers/basic/BasicThebesLayer.cpp +++ b/gfx/layers/basic/BasicThebesLayer.cpp @@ -29,8 +29,6 @@ #include "AutoMaskData.h" #include "gfx2DGlue.h" -struct gfxMatrix; - using namespace mozilla::gfx; namespace mozilla { diff --git a/gfx/layers/client/ClientContainerLayer.h b/gfx/layers/client/ClientContainerLayer.h index 875f880684d..33715bf65db 100644 --- a/gfx/layers/client/ClientContainerLayer.h +++ b/gfx/layers/client/ClientContainerLayer.h @@ -9,7 +9,6 @@ #include // for uint32_t #include "ClientLayerManager.h" // for ClientLayerManager, etc #include "Layers.h" // for Layer, ContainerLayer, etc -#include "gfxMatrix.h" // for gfxMatrix #include "gfxPlatform.h" // for gfxPlatform #include "nsDebug.h" // for NS_ASSERTION #include "nsISupportsUtils.h" // for NS_ADDREF, NS_RELEASE diff --git a/gfx/layers/composite/ContainerLayerComposite.cpp b/gfx/layers/composite/ContainerLayerComposite.cpp index 5efd4d84322..cfc722c4147 100644 --- a/gfx/layers/composite/ContainerLayerComposite.cpp +++ b/gfx/layers/composite/ContainerLayerComposite.cpp @@ -10,7 +10,6 @@ #include "gfx2DGlue.h" // for ToMatrix4x4 #include "gfx3DMatrix.h" // for gfx3DMatrix #include "gfxImageSurface.h" // for gfxImageSurface -#include "gfxMatrix.h" // for gfxMatrix #include "gfxPlatform.h" // for gfxPlatform #include "gfxUtils.h" // for gfxUtils, etc #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc diff --git a/gfx/layers/opengl/CompositingRenderTargetOGL.cpp b/gfx/layers/opengl/CompositingRenderTargetOGL.cpp index b4dddfbe3fb..db2d26cf304 100644 --- a/gfx/layers/opengl/CompositingRenderTargetOGL.cpp +++ b/gfx/layers/opengl/CompositingRenderTargetOGL.cpp @@ -55,7 +55,7 @@ CompositingRenderTargetOGL::BindRenderTarget() } } - mCompositor->PrepareViewport(mInitParams.mSize, ToMatrix(mTransform)); + mCompositor->PrepareViewport(mInitParams.mSize, mTransform); } } @@ -91,7 +91,7 @@ CompositingRenderTargetOGL::InitializeImpl() NS_ERROR(msg.get()); } - mCompositor->PrepareViewport(mInitParams.mSize, ToMatrix(mTransform)); + mCompositor->PrepareViewport(mInitParams.mSize, mTransform); mGL->fScissor(0, 0, mInitParams.mSize.width, mInitParams.mSize.height); if (mInitParams.mInit == INIT_MODE_CLEAR) { mGL->fClearColor(0.0, 0.0, 0.0, 0.0); diff --git a/gfx/layers/opengl/CompositingRenderTargetOGL.h b/gfx/layers/opengl/CompositingRenderTargetOGL.h index c6e9f9ce0f1..0febfe88343 100644 --- a/gfx/layers/opengl/CompositingRenderTargetOGL.h +++ b/gfx/layers/opengl/CompositingRenderTargetOGL.h @@ -8,7 +8,6 @@ #include "GLContextTypes.h" // for GLContext #include "GLDefs.h" // for GLenum, LOCAL_GL_FRAMEBUFFER, etc -#include "gfxMatrix.h" // for gfxMatrix #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc #include "mozilla/Attributes.h" // for MOZ_OVERRIDE #include "mozilla/RefPtr.h" // for RefPtr, TemporaryRef @@ -85,7 +84,7 @@ public: static TemporaryRef RenderTargetForWindow(CompositorOGL* aCompositor, const gfx::IntSize& aSize, - const gfxMatrix& aTransform) + const gfx::Matrix& aTransform) { RefPtr result = new CompositingRenderTargetOGL(aCompositor, gfx::IntPoint(0, 0), 0, 0); @@ -150,7 +149,7 @@ public: return gfx::SurfaceFormat::UNKNOWN; } - const gfxMatrix& GetTransform() { + const gfx::Matrix& GetTransform() { return mTransform; } @@ -166,7 +165,7 @@ private: void InitializeImpl(); InitParams mInitParams; - gfxMatrix mTransform; + gfx::Matrix mTransform; CompositorOGL* mCompositor; GLContext* mGL; GLuint mTextureHandle; diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index 4a4d22e9f9b..9156cf2f92f 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -850,7 +850,7 @@ CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion, mCurrentRenderTarget = CompositingRenderTargetOGL::RenderTargetForWindow(this, IntSize(width, height), - ThebesMatrix(aTransform)); + aTransform); mCurrentRenderTarget->BindRenderTarget(); #ifdef DEBUG mWindowRenderTarget = mCurrentRenderTarget; @@ -1457,7 +1457,7 @@ CompositorOGL::EndFrameForExternalComposition(const gfx::Matrix& aTransform) // This lets us reftest and screenshot content rendered externally if (mTarget) { MakeCurrent(); - CopyToTarget(mTarget, ThebesMatrix(aTransform)); + CopyToTarget(mTarget, aTransform); mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0); } } @@ -1478,7 +1478,7 @@ CompositorOGL::SetDestinationSurfaceSize(const gfx::IntSize& aSize) } void -CompositorOGL::CopyToTarget(DrawTarget *aTarget, const gfxMatrix& aTransform) +CompositorOGL::CopyToTarget(DrawTarget *aTarget, const gfx::Matrix& aTransform) { IntRect rect; if (mUseExternalSurfaceSize) { @@ -1517,7 +1517,7 @@ CompositorOGL::CopyToTarget(DrawTarget *aTarget, const gfxMatrix& aTransform) source->Unmap(); // Map from GL space to Cairo space and reverse the world transform. - Matrix glToCairoTransform = ToMatrix(aTransform); + Matrix glToCairoTransform = aTransform; glToCairoTransform.Invert(); glToCairoTransform.Scale(1.0, -1.0); glToCairoTransform.Translate(0.0, -height); diff --git a/gfx/layers/opengl/CompositorOGL.h b/gfx/layers/opengl/CompositorOGL.h index 6738af80644..1a3ed0c1b5d 100644 --- a/gfx/layers/opengl/CompositorOGL.h +++ b/gfx/layers/opengl/CompositorOGL.h @@ -34,7 +34,6 @@ class gfx3DMatrix; class nsIWidget; -struct gfxMatrix; namespace mozilla { class TimeStamp; @@ -324,7 +323,7 @@ private: * Copies the content of our backbuffer to the set transaction target. * Does not restore the target FBO, so only call from EndFrame. */ - void CopyToTarget(gfx::DrawTarget* aTarget, const gfxMatrix& aWorldMatrix); + void CopyToTarget(gfx::DrawTarget* aTarget, const gfx::Matrix& aWorldMatrix); /** * Records the passed frame timestamp and returns the current estimated FPS. diff --git a/gfx/layers/opengl/OGLShaderProgram.cpp b/gfx/layers/opengl/OGLShaderProgram.cpp index f1436c3d65e..49b75fb9492 100644 --- a/gfx/layers/opengl/OGLShaderProgram.cpp +++ b/gfx/layers/opengl/OGLShaderProgram.cpp @@ -4,7 +4,6 @@ #include "OGLShaderProgram.h" #include // for uint32_t -#include "gfxMatrix.h" // for gfxMatrix #include "gfxRect.h" // for gfxRect #include "mozilla/DebugOnly.h" // for DebugOnly #include "nsAString.h" From 0a9d96599956e42715fbffd3d9086e6625c26263 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Mon, 27 Jan 2014 15:25:21 -0500 Subject: [PATCH 018/296] Bug 952977: Convert AutoMaskData to gfx::Matrix4x4 r=nical --- gfx/layers/RotatedBuffer.cpp | 1 - gfx/layers/RotatedBuffer.h | 1 - gfx/layers/basic/AutoMaskData.h | 10 +++++----- gfx/layers/basic/BasicLayersImpl.cpp | 16 ++++++++-------- gfx/layers/basic/BasicThebesLayer.cpp | 2 +- gfx/layers/basic/BasicThebesLayer.h | 1 - 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/gfx/layers/RotatedBuffer.cpp b/gfx/layers/RotatedBuffer.cpp index ae2b8124410..c038b10418b 100644 --- a/gfx/layers/RotatedBuffer.cpp +++ b/gfx/layers/RotatedBuffer.cpp @@ -11,7 +11,6 @@ #include "BufferUnrotate.h" // for BufferUnrotate #include "GeckoProfiler.h" // for PROFILER_LABEL #include "Layers.h" // for ThebesLayer, Layer, etc -#include "gfxMatrix.h" // for gfxMatrix #include "gfxPlatform.h" // for gfxPlatform #include "gfxUtils.h" // for gfxUtils #include "mozilla/ArrayUtils.h" // for ArrayLength diff --git a/gfx/layers/RotatedBuffer.h b/gfx/layers/RotatedBuffer.h index 9e8f26bd966..a5a4876e63b 100644 --- a/gfx/layers/RotatedBuffer.h +++ b/gfx/layers/RotatedBuffer.h @@ -21,7 +21,6 @@ #include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc #include "LayersTypes.h" -struct gfxMatrix; struct nsIntSize; namespace mozilla { diff --git a/gfx/layers/basic/AutoMaskData.h b/gfx/layers/basic/AutoMaskData.h index 11fd6e09d78..3c168262966 100644 --- a/gfx/layers/basic/AutoMaskData.h +++ b/gfx/layers/basic/AutoMaskData.h @@ -34,20 +34,20 @@ public: * been constructed. */ - void Construct(const gfxMatrix& aTransform, + void Construct(const gfx::Matrix& aTransform, gfxASurface* aSurface); - void Construct(const gfxMatrix& aTransform, + void Construct(const gfx::Matrix& aTransform, const SurfaceDescriptor& aSurface); /** The returned surface can't escape the scope of |this|. */ gfxASurface* GetSurface(); - const gfxMatrix& GetTransform(); + const gfx::Matrix& GetTransform(); private: bool IsConstructed(); - gfxMatrix mTransform; + gfx::Matrix mTransform; nsRefPtr mSurface; Maybe mSurfaceOpener; @@ -58,4 +58,4 @@ private: } } -#endif // GFX_AUTOMASKDATA_H_ \ No newline at end of file +#endif // GFX_AUTOMASKDATA_H_ diff --git a/gfx/layers/basic/BasicLayersImpl.cpp b/gfx/layers/basic/BasicLayersImpl.cpp index 19ce8a059a6..d7ad34643fb 100644 --- a/gfx/layers/basic/BasicLayersImpl.cpp +++ b/gfx/layers/basic/BasicLayersImpl.cpp @@ -19,7 +19,7 @@ namespace mozilla { namespace layers { void -AutoMaskData::Construct(const gfxMatrix& aTransform, +AutoMaskData::Construct(const gfx::Matrix& aTransform, gfxASurface* aSurface) { MOZ_ASSERT(!IsConstructed()); @@ -28,7 +28,7 @@ AutoMaskData::Construct(const gfxMatrix& aTransform, } void -AutoMaskData::Construct(const gfxMatrix& aTransform, +AutoMaskData::Construct(const gfx::Matrix& aTransform, const SurfaceDescriptor& aSurface) { MOZ_ASSERT(!IsConstructed()); @@ -46,7 +46,7 @@ AutoMaskData::GetSurface() return mSurfaceOpener.ref().Get(); } -const gfxMatrix& +const gfx::Matrix& AutoMaskData::GetTransform() { MOZ_ASSERT(IsConstructed()); @@ -74,9 +74,9 @@ GetMaskData(Layer* aMaskLayer, AutoMaskData* aMaskData) DebugOnly maskIs2D = effectiveTransform.CanDraw2D(&transform); NS_ASSERTION(maskIs2D, "How did we end up with a 3D transform here?!"); if (surface) { - aMaskData->Construct(ThebesMatrix(transform), surface); + aMaskData->Construct(transform, surface); } else { - aMaskData->Construct(ThebesMatrix(transform), descriptor); + aMaskData->Construct(transform, descriptor); } return true; } @@ -94,7 +94,7 @@ PaintWithMask(gfxContext* aContext, float aOpacity, Layer* aMaskLayer) aContext->Paint(aOpacity); aContext->PopGroupToSource(); } - aContext->SetMatrix(mask.GetTransform()); + aContext->SetMatrix(ThebesMatrix(mask.GetTransform())); aContext->Mask(mask.GetSurface()); return; } @@ -112,12 +112,12 @@ FillWithMask(gfxContext* aContext, float aOpacity, Layer* aMaskLayer) aContext->PushGroup(gfxContentType::COLOR_ALPHA); aContext->FillWithOpacity(aOpacity); aContext->PopGroupToSource(); - aContext->SetMatrix(mask.GetTransform()); + aContext->SetMatrix(ThebesMatrix(mask.GetTransform())); aContext->Mask(mask.GetSurface()); } else { aContext->Save(); aContext->Clip(); - aContext->SetMatrix(mask.GetTransform()); + aContext->SetMatrix(ThebesMatrix(mask.GetTransform())); aContext->Mask(mask.GetSurface()); aContext->NewPath(); aContext->Restore(); diff --git a/gfx/layers/basic/BasicThebesLayer.cpp b/gfx/layers/basic/BasicThebesLayer.cpp index a75e2b7b161..84a606dc401 100644 --- a/gfx/layers/basic/BasicThebesLayer.cpp +++ b/gfx/layers/basic/BasicThebesLayer.cpp @@ -127,7 +127,7 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext, Matrix maskTransform; if (GetMaskData(aMaskLayer, &mask)) { maskSurface = mask.GetSurface(); - maskTransform = ToMatrix(mask.GetTransform()); + maskTransform = mask.GetTransform(); } if (!IsHidden() && !clipExtents.IsEmpty()) { diff --git a/gfx/layers/basic/BasicThebesLayer.h b/gfx/layers/basic/BasicThebesLayer.h index 9f293bb8d21..c9b1d62ab2b 100644 --- a/gfx/layers/basic/BasicThebesLayer.h +++ b/gfx/layers/basic/BasicThebesLayer.h @@ -10,7 +10,6 @@ #include "RotatedBuffer.h" // for RotatedContentBuffer, etc #include "BasicImplData.h" // for BasicImplData #include "BasicLayers.h" // for BasicLayerManager -#include "gfx3DMatrix.h" // for gfx3DMatrix #include "gfxPoint.h" // for gfxPoint #include "mozilla/RefPtr.h" // for RefPtr #include "mozilla/gfx/BasePoint.h" // for BasePoint From 19bde4952b4b7e1092fd49e5d8b1786a2fc0af99 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Mon, 27 Jan 2014 15:25:21 -0500 Subject: [PATCH 019/296] Bug 952977: Convert AsyncCompositionManager to gfx::Matrix4x4 r=nical --- .../composite/AsyncCompositionManager.cpp | 39 +++++++++---------- .../composite/AsyncCompositionManager.h | 2 +- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/gfx/layers/composite/AsyncCompositionManager.cpp b/gfx/layers/composite/AsyncCompositionManager.cpp index 074be17c39d..5e7ca476535 100644 --- a/gfx/layers/composite/AsyncCompositionManager.cpp +++ b/gfx/layers/composite/AsyncCompositionManager.cpp @@ -11,7 +11,6 @@ #include "FrameMetrics.h" // for FrameMetrics #include "LayerManagerComposite.h" // for LayerManagerComposite, etc #include "Layers.h" // for Layer, ContainerLayer, etc -#include "gfxMatrix.h" // for gfxMatrix #include "gfxPoint.h" // for gfxPoint, gfxSize #include "gfxPoint3D.h" // for gfxPoint3D #include "mozilla/WidgetUtils.h" // for ComputeTransformForRotation @@ -172,7 +171,7 @@ TranslateShadowLayer2D(Layer* aLayer, static bool AccumulateLayerTransforms2D(Layer* aLayer, Layer* aAncestor, - gfxMatrix& aMatrix) + Matrix& aMatrix) { // Accumulate the transforms between this layer and the subtree root layer. for (Layer* l = aLayer; l && l != aAncestor; l = l->GetParent()) { @@ -180,7 +179,7 @@ AccumulateLayerTransforms2D(Layer* aLayer, if (!GetBaseTransform2D(l, &l2D)) { return false; } - aMatrix.Multiply(ThebesMatrix(l2D)); + aMatrix *= l2D; } return true; @@ -231,7 +230,7 @@ IntervalOverlap(gfxFloat aTranslation, gfxFloat aMin, gfxFloat aMax) void AsyncCompositionManager::AlignFixedAndStickyLayers(Layer* aLayer, Layer* aTransformedSubtreeRoot, - const gfx3DMatrix& aPreviousTransformForRoot, + const Matrix4x4& aPreviousTransformForRoot, const LayerMargin& aFixedLayerMargins) { bool isRootFixed = aLayer->GetIsFixedPosition() && @@ -246,13 +245,13 @@ AsyncCompositionManager::AlignFixedAndStickyLayers(Layer* aLayer, // This currently only works for fixed layers with 2D transforms. // Accumulate the transforms between this layer and the subtree root layer. - gfxMatrix ancestorTransform; + Matrix ancestorTransform; if (!AccumulateLayerTransforms2D(aLayer->GetParent(), aTransformedSubtreeRoot, ancestorTransform)) { return; } - gfxMatrix oldRootTransform; + Matrix oldRootTransform; Matrix newRootTransform; if (!aPreviousTransformForRoot.Is2D(&oldRootTransform) || !aTransformedSubtreeRoot->GetLocalTransform().Is2D(&newRootTransform)) { @@ -261,12 +260,12 @@ AsyncCompositionManager::AlignFixedAndStickyLayers(Layer* aLayer, // Calculate the cumulative transforms between the subtree root with the // old transform and the current transform. - gfxMatrix oldCumulativeTransform = ancestorTransform * oldRootTransform; - gfxMatrix newCumulativeTransform = ancestorTransform * ThebesMatrix(newRootTransform); + Matrix oldCumulativeTransform = ancestorTransform * oldRootTransform; + Matrix newCumulativeTransform = ancestorTransform * newRootTransform; if (newCumulativeTransform.IsSingular()) { return; } - gfxMatrix newCumulativeTransformInverse = newCumulativeTransform; + Matrix newCumulativeTransformInverse = newCumulativeTransform; newCumulativeTransformInverse.Invert(); // Now work out the translation necessary to make sure the layer doesn't @@ -300,10 +299,9 @@ AsyncCompositionManager::AlignFixedAndStickyLayers(Layer* aLayer, // to the layer's parent, which is the same coordinate space as // locallyTransformedAnchor again, allowing us to subtract them and find // out the offset necessary to make sure the layer stays stationary. - gfxPoint oldAnchorPositionInNewSpace = - newCumulativeTransformInverse.Transform( - oldCumulativeTransform.Transform(ThebesPoint(locallyTransformedOffsetAnchor))); - gfxPoint translation = oldAnchorPositionInNewSpace - ThebesPoint(locallyTransformedAnchor); + Point oldAnchorPositionInNewSpace = + newCumulativeTransformInverse * (oldCumulativeTransform * locallyTransformedOffsetAnchor); + Point translation = oldAnchorPositionInNewSpace - locallyTransformedAnchor; if (aLayer->GetIsStickyPosition()) { // For sticky positioned layers, the difference between the two rectangles @@ -321,7 +319,7 @@ AsyncCompositionManager::AlignFixedAndStickyLayers(Layer* aLayer, } // Finally, apply the 2D translation to the layer transform. - TranslateShadowLayer2D(aLayer, translation); + TranslateShadowLayer2D(aLayer, ThebesPoint(translation)); // The transform has now been applied, so there's no need to iterate over // child layers. @@ -334,9 +332,7 @@ AsyncCompositionManager::AlignFixedAndStickyLayers(Layer* aLayer, if (aLayer->AsContainerLayer() && aLayer->AsContainerLayer()->GetFrameMetrics().IsScrollable() && aLayer != aTransformedSubtreeRoot) { - gfx3DMatrix matrix; - To3DMatrix(aLayer->GetTransform(), matrix); - AlignFixedAndStickyLayers(aLayer, aLayer, matrix, LayerMargin(0, 0, 0, 0)); + AlignFixedAndStickyLayers(aLayer, aLayer, aLayer->GetTransform(), LayerMargin(0, 0, 0, 0)); return; } @@ -492,8 +488,7 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFram if (AsyncPanZoomController* controller = container->GetAsyncPanZoomController()) { LayerComposite* layerComposite = aLayer->AsLayerComposite(); - gfx3DMatrix oldTransform; - To3DMatrix(aLayer->GetTransform(), oldTransform); + Matrix4x4 oldTransform = aLayer->GetTransform(); ViewTransform treeTransform; ScreenPoint scrollOffset; @@ -641,7 +636,7 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer) // GetTransform here. gfx3DMatrix currentTransform; To3DMatrix(aLayer->GetTransform(), currentTransform); - gfx3DMatrix oldTransform = currentTransform; + Matrix4x4 oldTransform = aLayer->GetTransform(); gfx3DMatrix treeTransform; @@ -746,7 +741,9 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer) overscrollTranslation.y = contentScreenRect.YMost() - (userScroll.y + metrics.mCompositionBounds.height); } - oldTransform.Translate(overscrollTranslation); + oldTransform.Translate(overscrollTranslation.x, + overscrollTranslation.y, + overscrollTranslation.z); gfx::Size underZoomScale(1.0f, 1.0f); if (mContentRect.width * userZoom.scale < metrics.mCompositionBounds.width) { diff --git a/gfx/layers/composite/AsyncCompositionManager.h b/gfx/layers/composite/AsyncCompositionManager.h index 705c9f0d794..0fb2382acb5 100644 --- a/gfx/layers/composite/AsyncCompositionManager.h +++ b/gfx/layers/composite/AsyncCompositionManager.h @@ -163,7 +163,7 @@ private: * zooming. */ void AlignFixedAndStickyLayers(Layer* aLayer, Layer* aTransformedSubtreeRoot, - const gfx3DMatrix& aPreviousTransformForRoot, + const gfx::Matrix4x4& aPreviousTransformForRoot, const LayerMargin& aFixedLayerMargins); /** From 0731f3e17d8e20a5939b1a7e51a461204219a266 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Fri, 24 Jan 2014 11:34:30 -0800 Subject: [PATCH 020/296] Bug 963327 - Improve profile-dependent handling of OS.Constants.Path; r=Yoric Many properties in OS.Constants.Path are dependent on the profile being available. This patch improves their handling. Previously, we had some repeated and boilerplate code for making OS.Constants.Paths. a lazy getter. This patch eliminates the boilerplate by iterating over the properties that need to be lazy getters. AppData and UAppData are now lazy getters. test_profiledir.js has been rolled into test_path_constants.js. test_path_constants.js now emits a warning when a comparison doesn't test anything. This should help identify ineffective tests going forward. --HG-- extra : rebase_source : d142c5fc78eb894f78f9ac8745de3413e4919f09 --- .../osfile/modules/osfile_async_front.jsm | 61 ++++++++++--------- .../tests/xpcshell/test_path_constants.js | 33 +++++++++- .../osfile/tests/xpcshell/test_profiledir.js | 43 ------------- .../osfile/tests/xpcshell/xpcshell.ini | 1 - 4 files changed, 62 insertions(+), 76 deletions(-) delete mode 100644 toolkit/components/osfile/tests/xpcshell/test_profiledir.js diff --git a/toolkit/components/osfile/modules/osfile_async_front.jsm b/toolkit/components/osfile/modules/osfile_async_front.jsm index e6dddb21d07..53407193748 100644 --- a/toolkit/components/osfile/modules/osfile_async_front.jsm +++ b/toolkit/components/osfile/modules/osfile_async_front.jsm @@ -58,39 +58,42 @@ Cu.import("resource://gre/modules/Services.jsm", this); Cu.import("resource://gre/modules/TelemetryStopwatch.jsm", this); Cu.import("resource://gre/modules/AsyncShutdown.jsm", this); -// If profileDir is not available, osfile.jsm has been imported before the -// profile is setup. In this case, make this a lazy getter. -if (!("profileDir" in SharedAll.Constants.Path)) { - Object.defineProperty(SharedAll.Constants.Path, "profileDir", { - get: function() { - let path = undefined; - try { - path = Services.dirsvc.get("ProfD", Ci.nsIFile).path; - delete SharedAll.Constants.Path.profileDir; - SharedAll.Constants.Path.profileDir = path; - } catch (ex) { - // Ignore errors: profileDir is still not available - } - return path; +// It's possible for osfile.jsm to get imported before the profile is +// set up. In this case, some path constants aren't yet available. +// Here, we make them lazy loaders. + +function lazyPathGetter(constProp, dirKey) { + return function () { + let path; + try { + path = Services.dirsvc.get(dirKey, Ci.nsIFile).path; + delete SharedAll.Constants.Path[constProp]; + SharedAll.Constants.Path[constProp] = path; + } catch (ex) { + // Ignore errors if the value still isn't available. Hopefully + // the next access will return it. } - }); + + return path; + } } -LOG("Checking localProfileDir"); +for (let [constProp, dirKey] of [ + ["localProfileDir", "ProfLD"], + ["profileDir", "ProfD"], + ["userApplicationDataDir", "UAppData"], + ["winAppDataDir", "AppData"], + ["winStartMenuProgsDir", "Progs"], + ]) { -if (!("localProfileDir" in SharedAll.Constants.Path)) { - Object.defineProperty(SharedAll.Constants.Path, "localProfileDir", { - get: function() { - let path = undefined; - try { - path = Services.dirsvc.get("ProfLD", Ci.nsIFile).path; - delete SharedAll.Constants.Path.localProfileDir; - SharedAll.Constants.Path.localProfileDir = path; - } catch (ex) { - // Ignore errors: localProfileDir is still not available - } - return path; - } + if (constProp in SharedAll.Constants.Path) { + continue; + } + + LOG("Installing lazy getter for OS.Constants.Path." + constProp + + " because it isn't defined and profile may not be loaded."); + Object.defineProperty(SharedAll.Constants.Path, constProp, { + get: lazyPathGetter(constProp, dirKey), }); } diff --git a/toolkit/components/osfile/tests/xpcshell/test_path_constants.js b/toolkit/components/osfile/tests/xpcshell/test_path_constants.js index 02a84b9085c..6c75ed23919 100644 --- a/toolkit/components/osfile/tests/xpcshell/test_path_constants.js +++ b/toolkit/components/osfile/tests/xpcshell/test_path_constants.js @@ -4,9 +4,13 @@ "use strict"; -Components.utils.import("resource://gre/modules/osfile.jsm"); -Components.utils.import("resource://gre/modules/Services.jsm"); -Components.utils.import("resource://gre/modules/ctypes.jsm"); +const Cu = Components.utils; + +Cu.import("resource://gre/modules/osfile.jsm", this); +Cu.import("resource://gre/modules/Services.jsm", this); +Cu.import("resource://gre/modules/ctypes.jsm", this); +Cu.import("resource://testing-common/AppData.jsm", this); + function run_test() { run_next_test(); @@ -22,10 +26,33 @@ function compare_paths(ospath, key) { do_check_true(!!ospath); do_check_eq(ospath, file.path); } else { + do_print("WARNING: " + key + " is not defined. Test may not be testing anything!"); do_check_false(!!ospath); } } +// Some path constants aren't set up until the profile is available. This +// test verifies that behavior. +add_task(function* test_before_after_profile() { + do_check_null(OS.Constants.Path.profileDir); + do_check_null(OS.Constants.Path.localProfileDir); + do_check_null(OS.Constants.Path.userApplicationDataDir); + + do_get_profile(); + do_check_true(!!OS.Constants.Path.profileDir); + do_check_true(!!OS.Constants.Path.localProfileDir); + + // UAppData is still null because the xpcshell profile doesn't set it up. + // This test is mostly here to fail in case behavior of do_get_profile() ever + // changes. We want to know if our assumptions no longer hold! + do_check_null(OS.Constants.Path.userApplicationDataDir); + + yield makeFakeAppDir(); + do_check_true(!!OS.Constants.Path.userApplicationDataDir); + + // FUTURE: verify AppData too (bug 964291). +}); + // Test simple paths add_task(function() { do_check_true(!!OS.Constants.Path.tmpDir); diff --git a/toolkit/components/osfile/tests/xpcshell/test_profiledir.js b/toolkit/components/osfile/tests/xpcshell/test_profiledir.js deleted file mode 100644 index 00c0d4a9329..00000000000 --- a/toolkit/components/osfile/tests/xpcshell/test_profiledir.js +++ /dev/null @@ -1,43 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -Components.utils.import("resource://gre/modules/osfile.jsm"); -Components.utils.import("resource://gre/modules/Services.jsm"); - -function run_test() { - run_next_test(); -} - -add_test(function test_initialize_profileDir() { - // Profile has not been set up yet, check that "profileDir" isn't either. - do_check_false(!!OS.Constants.Path.profileDir); - do_check_false(!!OS.Constants.Path.localProfileDir); - - // Set up profile. - do_get_profile(); - - // Now that profile has been set up, check that "profileDir" is set. - do_check_true(!!OS.Constants.Path.profileDir); - do_check_eq(OS.Constants.Path.profileDir, - Services.dirsvc.get("ProfD", Components.interfaces.nsIFile).path); - - do_check_true(!!OS.Constants.Path.localProfileDir); - do_check_eq(OS.Constants.Path.localProfileDir, - Services.dirsvc.get("ProfLD", Components.interfaces.nsIFile).path); - - let promise = OS.File.makeDir(OS.Path.join(OS.Constants.Path.profileDir, "foobar")); - promise.then( - function onSuccess() { - do_print("Directory creation succeeded"); - run_next_test(); - }, - - function onFailure(reason) { - do_fail(reason); - run_next_test(); - } - ); -}); diff --git a/toolkit/components/osfile/tests/xpcshell/xpcshell.ini b/toolkit/components/osfile/tests/xpcshell/xpcshell.ini index 4d5bcd286a5..1dcf67789d0 100644 --- a/toolkit/components/osfile/tests/xpcshell/xpcshell.ini +++ b/toolkit/components/osfile/tests/xpcshell/xpcshell.ini @@ -12,7 +12,6 @@ tail = [test_osfile_async_setDates.js] [test_removeEmptyDir.js] [test_makeDir.js] -[test_profiledir.js] [test_file_URL_conversion.js] [test_logging.js] [test_creationDate.js] From f4f2d2baf540ee6634a9418b87e0ca3f96c1e11e Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Tue, 19 Nov 2013 14:08:25 -0800 Subject: [PATCH 021/296] Bug 875562 - Part 2: Create CrashManager API for managing crash data; r=ted, Yoric The tree doesn't have a robust and reusable API for interfacing with crash data. This patch is the start of a new API. In this patch, the CrashManager type is introduced. It has APIs for retrieving the lists of files related to crash dumps. In subsequent patches, I will convert existing code in the tree that does similar things to the new API. I will also build the events/timeline API onto this type. I made CrashManager generic because I hate, hate, hate singletons and global variables. Allowing it to be instantiated multiple times with different options (instead of say binding a global instance to ProfD) makes the testing story much, much nicer. That is reason enough, IMO. In a subsequent patch, I'll add an XPCOM service that instantiates the "global" instance of CrashManager with the appropriate options. It was tempting to add this code into the existing CrashReports.jsm. However, this file does not import cleanly in xpcshell tests and I didn't want to bloat scope to include fixing that file... yet. CrashReports.jsm is using synchronous I/O. So, depending on how adventerous I feel, I may replace consumers of CrashReports.jsm with the new CrashManager.jsm, remove CrashReports.jsm, and eliminate another source of synchronous I/O in the tree. --HG-- extra : rebase_source : 379fa6a78b53bc0dea0c7c64e8b1bdcf85b61a7c --- toolkit/components/crashes/CrashManager.jsm | 157 ++++++++++++++++ toolkit/components/crashes/moz.build | 11 ++ .../tests/xpcshell/test_crash_manager.js | 173 ++++++++++++++++++ .../crashes/tests/xpcshell/xpcshell.ini | 5 + toolkit/components/moz.build | 3 + 5 files changed, 349 insertions(+) create mode 100644 toolkit/components/crashes/CrashManager.jsm create mode 100644 toolkit/components/crashes/moz.build create mode 100644 toolkit/components/crashes/tests/xpcshell/test_crash_manager.js create mode 100644 toolkit/components/crashes/tests/xpcshell/xpcshell.ini diff --git a/toolkit/components/crashes/CrashManager.jsm b/toolkit/components/crashes/CrashManager.jsm new file mode 100644 index 00000000000..0fb27140625 --- /dev/null +++ b/toolkit/components/crashes/CrashManager.jsm @@ -0,0 +1,157 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +const {utils: Cu} = Components; + +Cu.import("resource://gre/modules/osfile.jsm", this) +Cu.import("resource://gre/modules/Task.jsm", this); + +this.EXPORTED_SYMBOLS = [ + "CrashManager", +]; + +/** + * A gateway to crash-related data. + * + * This type is generic and can be instantiated any number of times. + * However, most applications will typically only have one instance + * instantiated and that instance will point to profile and user appdata + * directories. + * + * Instances are created by passing an object with properties. + * Recognized properties are: + * + * pendingDumpsDir (string) (required) + * Where dump files that haven't been uploaded are located. + * + * submittedDumpsDir (string) (required) + * Where records of uploaded dumps are located. + */ +this.CrashManager = function (options) { + for (let k of ["pendingDumpsDir", "submittedDumpsDir"]) { + if (!(k in options)) { + throw new Error("Required key not present in options: " + k); + } + } + + for (let [k, v] of Iterator(options)) { + switch (k) { + case "pendingDumpsDir": + this._pendingDumpsDir = v; + break; + + case "submittedDumpsDir": + this._submittedDumpsDir = v; + break; + + default: + throw new Error("Unknown property in options: " + k); + } + } +}; + +this.CrashManager.prototype = Object.freeze({ + DUMP_REGEX: /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.dmp$/i, + SUBMITTED_REGEX: /^bp-(?:hr-)?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.txt$/i, + + /** + * Obtain a list of all dumps pending upload. + * + * The returned value is a promise that resolves to an array of objects + * on success. Each element in the array has the following properties: + * + * id (string) + * The ID of the crash (a UUID). + * + * path (string) + * The filename of the crash () + * + * date (Date) + * When this dump was created + * + * The returned arry is sorted by the modified time of the file backing + * the entry, oldest to newest. + * + * @return Promise + */ + pendingDumps: function () { + return this._getDirectoryEntries(this._pendingDumpsDir, this.DUMP_REGEX); + }, + + /** + * Obtain a list of all dump files corresponding to submitted crashes. + * + * The returned value is a promise that resolves to an Array of + * objects. Each object has the following properties: + * + * path (string) + * The path of the file this entry comes from. + * + * id (string) + * The crash UUID. + * + * date (Date) + * The (estimated) date this crash was submitted. + * + * The returned array is sorted by the modified time of the file backing + * the entry, oldest to newest. + * + * @return Promise + */ + submittedDumps: function () { + return this._getDirectoryEntries(this._submittedDumpsDir, + this.SUBMITTED_REGEX); + }, + + /** + * Helper to obtain all directory entries in a path that match a regexp. + * + * The resolved promise is an array of objects with the properties: + * + * path -- String filename + * id -- regexp.match()[1] (likely the crash ID) + * date -- Date mtime of the file + */ + _getDirectoryEntries: function (path, re) { + return Task.spawn(function* () { + try { + yield OS.File.stat(path); + } catch (ex if ex instanceof OS.File.Error && ex.becauseNoSuchFile) { + return []; + } + + let it = new OS.File.DirectoryIterator(path); + let entries = []; + + try { + yield it.forEach((entry, index, it) => { + if (entry.isDir) { + return; + } + + let match = re.exec(entry.name); + if (!match) { + return; + } + + return OS.File.stat(entry.path).then((info) => { + entries.push({ + path: entry.path, + id: match[1], + date: info.lastModificationDate, + }); + }); + }); + } finally { + it.close(); + } + + entries.sort((a, b) => { return a.date - b.date; }); + + return entries; + }.bind(this)); + }, +}); diff --git a/toolkit/components/crashes/moz.build b/toolkit/components/crashes/moz.build new file mode 100644 index 00000000000..f597f64c77c --- /dev/null +++ b/toolkit/components/crashes/moz.build @@ -0,0 +1,11 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +EXTRA_JS_MODULES += [ + 'CrashManager.jsm', +] + +XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini'] diff --git a/toolkit/components/crashes/tests/xpcshell/test_crash_manager.js b/toolkit/components/crashes/tests/xpcshell/test_crash_manager.js new file mode 100644 index 00000000000..f54e0defe22 --- /dev/null +++ b/toolkit/components/crashes/tests/xpcshell/test_crash_manager.js @@ -0,0 +1,173 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const {classes: Cc, interfaces: Ci, utils: Cu} = Components; + +Cu.import("resource://gre/modules/CrashManager.jsm", this); +Cu.import("resource://gre/modules/Task.jsm", this); +Cu.import("resource://gre/modules/osfile.jsm", this); + +let DUMMY_DIR_COUNT = 0; + +function getManager() { + function mkdir(f) { + if (f.exists()) { + return; + } + + dump("Creating directory: " + f.path + "\n"); + f.create(Ci.nsIFile.DIRECTORY_TYPE, dirMode); + } + + const dirMode = OS.Constants.libc.S_IRWXU; + let baseFile = do_get_tempdir(); + let pendingD = baseFile.clone(); + let submittedD = baseFile.clone(); + pendingD.append("dummy-dir-" + DUMMY_DIR_COUNT++); + submittedD.append("dummy-dir-" + DUMMY_DIR_COUNT++); + mkdir(pendingD); + mkdir(submittedD); + + let m = new CrashManager({ + pendingDumpsDir: pendingD.path, + submittedDumpsDir: submittedD.path, + }); + + m.create_dummy_dump = function (submitted=false, date=new Date(), hr=false) { + let uuid = Cc["@mozilla.org/uuid-generator;1"] + .getService(Ci.nsIUUIDGenerator) + .generateUUID() + .toString(); + uuid = uuid.substring(1, uuid.length - 1); + + let file; + let mode; + if (submitted) { + file = submittedD.clone(); + if (hr) { + file.append("bp-hr-" + uuid + ".txt"); + } else { + file.append("bp-" + uuid + ".txt"); + } + mode = OS.Constants.libc.S_IRUSR | OS.Constants.libc.S_IWUSR | + OS.Constants.libc.S_IRGRP | OS.Constants.libc.S_IROTH; + } else { + file = pendingD.clone(); + file.append(uuid + ".dmp"); + mode = OS.Constants.libc.S_IRUSR | OS.Constants.libc.S_IWUSR; + } + + file.create(file.NORMAL_FILE_TYPE, mode); + file.lastModifiedTime = date.getTime(); + dump("Created fake crash: " + file.path + "\n"); + + return uuid; + }; + + m.create_ignored_dump_file = function (filename, submitted=false) { + let file; + if (submitted) { + file = submittedD.clone(); + } else { + file = pendingD.clone(); + } + + file.append(filename); + file.create(file.NORMAL_FILE_TYPE, + OS.Constants.libc.S_IRUSR | OS.Constants.libc.S_IWUSR); + dump("Created ignored dump file: " + file.path + "\n"); + }; + + return m; +} + +function run_test() { + run_next_test(); +} + +add_task(function* test_constructor_ok() { + let m = new CrashManager({ + pendingDumpsDir: "/foo", + submittedDumpsDir: "/bar", + }); + Assert.ok(m); +}); + +add_task(function* test_constructor_invalid() { + Assert.throws(() => { + new CrashManager({foo: true}); + }); +}); + +add_task(function* test_get_manager() { + let m = getManager(); + Assert.ok(m); + + m.create_dummy_dump(true); + m.create_dummy_dump(false); +}); + +add_task(function* test_pending_dumps() { + let m = getManager(); + let now = Date.now(); + let ids = []; + const COUNT = 5; + + for (let i = 0; i < COUNT; i++) { + ids.push(m.create_dummy_dump(false, new Date(now - i * 86400000))); + } + m.create_ignored_dump_file("ignored", false); + + let entries = yield m.pendingDumps(); + Assert.equal(entries.length, COUNT, "proper number detected."); + + for (let entry of entries) { + Assert.equal(typeof(entry), "object", "entry is an object"); + Assert.ok("id" in entry, "id in entry"); + Assert.ok("path" in entry, "path in entry"); + Assert.ok("date" in entry, "date in entry"); + Assert.notEqual(ids.indexOf(entry.id), -1, "ID is known"); + } + + for (let i = 0; i < COUNT; i++) { + Assert.equal(entries[i].id, ids[COUNT-i-1], "Entries sorted by mtime"); + } +}); + +add_task(function* test_submitted_dumps() { + let m = getManager(); + let COUNT = 5; + + for (let i = 0; i < COUNT; i++) { + m.create_dummy_dump(true); + } + m.create_ignored_dump_file("ignored", true); + + let entries = yield m.submittedDumps(); + Assert.equal(entries.length, COUNT, "proper number detected."); + + let hrID = m.create_dummy_dump(true, new Date(), true); + entries = yield m.submittedDumps(); + Assert.equal(entries.length, COUNT + 1, "hr- in filename detected."); + + let gotIDs = new Set([e.id for (e of entries)]); + Assert.ok(gotIDs.has(hrID)); +}); + +add_task(function* test_submitted_and_pending() { + let m = getManager(); + let pendingIDs = []; + let submittedIDs = []; + + pendingIDs.push(m.create_dummy_dump(false)); + pendingIDs.push(m.create_dummy_dump(false)); + submittedIDs.push(m.create_dummy_dump(true)); + + let submitted = yield m.submittedDumps(); + let pending = yield m.pendingDumps(); + + Assert.equal(submitted.length, submittedIDs.length); + Assert.equal(pending.length, pendingIDs.length); +}); diff --git a/toolkit/components/crashes/tests/xpcshell/xpcshell.ini b/toolkit/components/crashes/tests/xpcshell/xpcshell.ini new file mode 100644 index 00000000000..ef3e3565a26 --- /dev/null +++ b/toolkit/components/crashes/tests/xpcshell/xpcshell.ini @@ -0,0 +1,5 @@ +[DEFAULT] +head = +tail = + +[test_crash_manager.js] diff --git a/toolkit/components/moz.build b/toolkit/components/moz.build index fcce72309ae..62b69a9d59f 100644 --- a/toolkit/components/moz.build +++ b/toolkit/components/moz.build @@ -48,6 +48,9 @@ PARALLEL_DIRS += [ 'workerlz4', ] +if CONFIG['MOZ_CRASHREPORTER']: + PARALLEL_DIRS += ['crashes'] + if CONFIG['MOZ_SOCIAL']: PARALLEL_DIRS += ['social'] From 18cff6bdb6336c2dc4ff85a76cd5fd0f06961327 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 28 Jan 2014 17:19:29 +0900 Subject: [PATCH 022/296] Bug 962005 Make mozilla::TextComposition ref-countable class r=smaug --- dom/events/TextComposition.cpp | 39 ++++++++++------------------ dom/events/TextComposition.h | 12 ++++++--- dom/events/nsIMEStateManager.cpp | 43 ++++++++++++++----------------- dom/events/nsIMEStateManager.h | 2 +- widget/xpwidgets/PuppetWidget.cpp | 4 +-- 5 files changed, 43 insertions(+), 57 deletions(-) diff --git a/dom/events/TextComposition.cpp b/dom/events/TextComposition.cpp index 2513dfe0ef7..77920d4ebee 100644 --- a/dom/events/TextComposition.cpp +++ b/dom/events/TextComposition.cpp @@ -31,17 +31,6 @@ TextComposition::TextComposition(nsPresContext* aPresContext, { } -TextComposition::TextComposition(const TextComposition& aOther) -{ - mNativeContext = aOther.mNativeContext; - mPresContext = aOther.mPresContext; - mNode = aOther.mNode; - mLastData = aOther.mLastData; - mCompositionStartOffset = aOther.mCompositionStartOffset; - mCompositionTargetOffset = aOther.mCompositionTargetOffset; - mIsSynthesizedForTests = aOther.mIsSynthesizedForTests; -} - bool TextComposition::MatchesNativeContext(nsIWidget* aWidget) const { @@ -118,15 +107,13 @@ TextComposition::DispatchCompsotionEventRunnable(uint32_t aEventMessage, void TextComposition::SynthesizeCommit(bool aDiscard) { - // backup this instance and use it since this instance might be destroyed - // by nsIMEStateManager if this is managed by it. - TextComposition composition = *this; - nsAutoString data(aDiscard ? EmptyString() : composition.mLastData); - if (composition.mLastData != data) { - composition.DispatchCompsotionEventRunnable(NS_COMPOSITION_UPDATE, data); - composition.DispatchCompsotionEventRunnable(NS_TEXT_TEXT, data); + nsRefPtr kungFuDeathGrip(this); + nsAutoString data(aDiscard ? EmptyString() : mLastData); + if (mLastData != data) { + DispatchCompsotionEventRunnable(NS_COMPOSITION_UPDATE, data); + DispatchCompsotionEventRunnable(NS_TEXT_TEXT, data); } - composition.DispatchCompsotionEventRunnable(NS_COMPOSITION_END, data); + DispatchCompsotionEventRunnable(NS_COMPOSITION_END, data); } nsresult @@ -202,7 +189,7 @@ TextCompositionArray::index_type TextCompositionArray::IndexOf(nsIWidget* aWidget) { for (index_type i = Length(); i > 0; --i) { - if (ElementAt(i - 1).MatchesNativeContext(aWidget)) { + if (ElementAt(i - 1)->MatchesNativeContext(aWidget)) { return i - 1; } } @@ -213,7 +200,7 @@ TextCompositionArray::index_type TextCompositionArray::IndexOf(nsPresContext* aPresContext) { for (index_type i = Length(); i > 0; --i) { - if (ElementAt(i - 1).GetPresContext() == aPresContext) { + if (ElementAt(i - 1)->GetPresContext() == aPresContext) { return i - 1; } } @@ -228,7 +215,7 @@ TextCompositionArray::IndexOf(nsPresContext* aPresContext, if (index == NoIndex) { return NoIndex; } - nsINode* node = ElementAt(index).GetEventTargetNode(); + nsINode* node = ElementAt(index)->GetEventTargetNode(); return node == aNode ? index : NoIndex; } @@ -236,7 +223,7 @@ TextComposition* TextCompositionArray::GetCompositionFor(nsIWidget* aWidget) { index_type i = IndexOf(aWidget); - return i != NoIndex ? &ElementAt(i) : nullptr; + return i != NoIndex ? ElementAt(i) : nullptr; } TextComposition* @@ -244,7 +231,7 @@ TextCompositionArray::GetCompositionFor(nsPresContext* aPresContext, nsINode* aNode) { index_type i = IndexOf(aPresContext, aNode); - return i != NoIndex ? &ElementAt(i) : nullptr; + return i != NoIndex ? ElementAt(i) : nullptr; } TextComposition* @@ -253,9 +240,9 @@ TextCompositionArray::GetCompositionInContent(nsPresContext* aPresContext, { // There should be only one composition per content object. for (index_type i = Length(); i > 0; --i) { - nsINode* node = ElementAt(i - 1).GetEventTargetNode(); + nsINode* node = ElementAt(i - 1)->GetEventTargetNode(); if (node && nsContentUtils::ContentIsDescendantOf(node, aContent)) { - return &ElementAt(i - 1); + return ElementAt(i - 1); } } return nullptr; diff --git a/dom/events/TextComposition.h b/dom/events/TextComposition.h index 142771db91d..ccd42342fb2 100644 --- a/dom/events/TextComposition.h +++ b/dom/events/TextComposition.h @@ -31,13 +31,14 @@ namespace mozilla { class TextComposition MOZ_FINAL { friend class ::nsIMEStateManager; + + NS_INLINE_DECL_REFCOUNTING(TextComposition) + public: TextComposition(nsPresContext* aPresContext, nsINode* aNode, WidgetGUIEvent* aEvent); - TextComposition(const TextComposition& aOther); - ~TextComposition() { // WARNING: mPresContext may be destroying, so, be careful if you touch it. @@ -97,8 +98,10 @@ private: // See the comment for IsSynthesizedForTests(). bool mIsSynthesizedForTests; - // Hide the default constructor + // Hide the default constructor and copy constructor. TextComposition() {} + TextComposition(const TextComposition& aOther); + /** * DispatchEvent() dispatches the aEvent to the mContent synchronously. @@ -163,7 +166,8 @@ private: * in the array can be destroyed by calling some methods of itself. */ -class TextCompositionArray MOZ_FINAL : public nsAutoTArray +class TextCompositionArray MOZ_FINAL : + public nsAutoTArray, 2> { public: index_type IndexOf(nsIWidget* aWidget); diff --git a/dom/events/nsIMEStateManager.cpp b/dom/events/nsIMEStateManager.cpp index 89733fcc84b..5ee5267431d 100644 --- a/dom/events/nsIMEStateManager.cpp +++ b/dom/events/nsIMEStateManager.cpp @@ -148,12 +148,10 @@ nsIMEStateManager::OnRemoveContent(nsPresContext* aPresContext, // First, if there is a composition in the aContent, clean up it. if (sTextCompositions) { - TextComposition* compositionInContent = + nsRefPtr compositionInContent = sTextCompositions->GetCompositionInContent(aPresContext, aContent); if (compositionInContent) { - // Store the composition before accessing the native IME. - TextComposition storedComposition = *compositionInContent; // Try resetting the native IME state. Be aware, typically, this method // is called during the content being removed. Then, the native // composition events which are caused by following APIs are ignored due @@ -161,15 +159,15 @@ nsIMEStateManager::OnRemoveContent(nsPresContext* aPresContext, nsCOMPtr widget = aPresContext->GetRootWidget(); if (widget) { nsresult rv = - storedComposition.NotifyIME(REQUEST_TO_CANCEL_COMPOSITION); + compositionInContent->NotifyIME(REQUEST_TO_CANCEL_COMPOSITION); if (NS_FAILED(rv)) { - storedComposition.NotifyIME(REQUEST_TO_COMMIT_COMPOSITION); + compositionInContent->NotifyIME(REQUEST_TO_COMMIT_COMPOSITION); } // By calling the APIs, the composition may have been finished normally. compositionInContent = sTextCompositions->GetCompositionFor( - storedComposition.GetPresContext(), - storedComposition.GetEventTargetNode()); + compositionInContent->GetPresContext(), + compositionInContent->GetEventTargetNode()); } } @@ -558,12 +556,12 @@ nsIMEStateManager::DispatchCompositionEvent(nsINode* aEventTargetNode, WidgetGUIEvent* GUIEvent = aEvent->AsGUIEvent(); - TextComposition* composition = + nsRefPtr composition = sTextCompositions->GetCompositionFor(GUIEvent->widget); if (!composition) { MOZ_ASSERT(GUIEvent->message == NS_COMPOSITION_START); - TextComposition newComposition(aPresContext, aEventTargetNode, GUIEvent); - composition = sTextCompositions->AppendElement(newComposition); + composition = new TextComposition(aPresContext, aEventTargetNode, GUIEvent); + sTextCompositions->AppendElement(composition); } #ifdef DEBUG else { @@ -593,7 +591,7 @@ nsIMEStateManager::NotifyIME(NotificationToIME aNotification, { NS_ENSURE_TRUE(aWidget, NS_ERROR_INVALID_ARG); - TextComposition* composition = nullptr; + nsRefPtr composition; if (sTextCompositions) { composition = sTextCompositions->GetCompositionFor(aWidget); } @@ -618,12 +616,10 @@ nsIMEStateManager::NotifyIME(NotificationToIME aNotification, switch (aNotification) { case REQUEST_TO_COMMIT_COMPOSITION: { nsCOMPtr widget(aWidget); - TextComposition backup = *composition; - nsEventStatus status = nsEventStatus_eIgnore; - if (!backup.GetLastData().IsEmpty()) { + if (!composition->GetLastData().IsEmpty()) { WidgetTextEvent textEvent(true, NS_TEXT_TEXT, widget); - textEvent.theText = backup.GetLastData(); + textEvent.theText = composition->GetLastData(); textEvent.mFlags.mIsSynthesizedForTests = true; widget->DispatchEvent(&textEvent, status); if (widget->Destroyed()) { @@ -633,7 +629,7 @@ nsIMEStateManager::NotifyIME(NotificationToIME aNotification, status = nsEventStatus_eIgnore; WidgetCompositionEvent endEvent(true, NS_COMPOSITION_END, widget); - endEvent.data = backup.GetLastData(); + endEvent.data = composition->GetLastData(); endEvent.mFlags.mIsSynthesizedForTests = true; widget->DispatchEvent(&endEvent, status); @@ -641,12 +637,10 @@ nsIMEStateManager::NotifyIME(NotificationToIME aNotification, } case REQUEST_TO_CANCEL_COMPOSITION: { nsCOMPtr widget(aWidget); - TextComposition backup = *composition; - nsEventStatus status = nsEventStatus_eIgnore; - if (!backup.GetLastData().IsEmpty()) { + if (!composition->GetLastData().IsEmpty()) { WidgetCompositionEvent updateEvent(true, NS_COMPOSITION_UPDATE, widget); - updateEvent.data = backup.GetLastData(); + updateEvent.data = composition->GetLastData(); updateEvent.mFlags.mIsSynthesizedForTests = true; widget->DispatchEvent(&updateEvent, status); if (widget->Destroyed()) { @@ -655,7 +649,7 @@ nsIMEStateManager::NotifyIME(NotificationToIME aNotification, status = nsEventStatus_eIgnore; WidgetTextEvent textEvent(true, NS_TEXT_TEXT, widget); - textEvent.theText = backup.GetLastData(); + textEvent.theText = composition->GetLastData(); textEvent.mFlags.mIsSynthesizedForTests = true; widget->DispatchEvent(&textEvent, status); if (widget->Destroyed()) { @@ -665,7 +659,7 @@ nsIMEStateManager::NotifyIME(NotificationToIME aNotification, status = nsEventStatus_eIgnore; WidgetCompositionEvent endEvent(true, NS_COMPOSITION_END, widget); - endEvent.data = backup.GetLastData(); + endEvent.data = composition->GetLastData(); endEvent.mFlags.mIsSynthesizedForTests = true; widget->DispatchEvent(&endEvent, status); @@ -1133,7 +1127,8 @@ nsIMEStateManager::GetFocusSelectionAndRoot(nsISelection** aSel, } TextComposition* -nsIMEStateManager::GetTextComposition(nsIWidget* aWidget) +nsIMEStateManager::GetTextCompositionFor(nsIWidget* aWidget) { - return sTextCompositions->GetCompositionFor(aWidget); + return sTextCompositions ? + sTextCompositions->GetCompositionFor(aWidget) : nullptr; } diff --git a/dom/events/nsIMEStateManager.h b/dom/events/nsIMEStateManager.h index c442be983b6..f349cd952e0 100644 --- a/dom/events/nsIMEStateManager.h +++ b/dom/events/nsIMEStateManager.h @@ -98,7 +98,7 @@ public: /** * Get TextComposition from widget. */ - static mozilla::TextComposition* GetTextComposition(nsIWidget* aWidget); + static mozilla::TextComposition* GetTextCompositionFor(nsIWidget* aWidget); /** * Send a notification to IME. It depends on the IME or platform spec what diff --git a/widget/xpwidgets/PuppetWidget.cpp b/widget/xpwidgets/PuppetWidget.cpp index dffd49e0302..cfc556a853b 100644 --- a/widget/xpwidgets/PuppetWidget.cpp +++ b/widget/xpwidgets/PuppetWidget.cpp @@ -490,8 +490,8 @@ PuppetWidget::NotifyIMEOfUpdateComposition() NS_ENSURE_TRUE(mTabChild, NS_ERROR_FAILURE); - mozilla::TextComposition* textComposition = - nsIMEStateManager::GetTextComposition(this); + nsRefPtr textComposition = + nsIMEStateManager::GetTextCompositionFor(this); NS_ENSURE_TRUE(textComposition, NS_ERROR_FAILURE); nsEventStatus status; From 5a4d989e5480f9165363b5707f50cf47b4360349 Mon Sep 17 00:00:00 2001 From: Nicholas Cameron Date: Tue, 28 Jan 2014 21:44:15 +1300 Subject: [PATCH 023/296] Bug 944087. Missing comment change addressing reviewer comment. r=Bas DONTBUILD (comment only) --- gfx/layers/d3d9/DeviceManagerD3D9.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/layers/d3d9/DeviceManagerD3D9.h b/gfx/layers/d3d9/DeviceManagerD3D9.h index 0ce98da7b1c..70914a93cf8 100644 --- a/gfx/layers/d3d9/DeviceManagerD3D9.h +++ b/gfx/layers/d3d9/DeviceManagerD3D9.h @@ -39,8 +39,8 @@ enum DeviceManagerState { DeviceOK, // The device or swap chain are in a bad state, and we should not render. DeviceFail, - // The device is lost, the user should forget the current device manager - // and create a new one. + // The device is lost and cannot be reset, the user should forget the + // current device manager and create a new one. DeviceMustRecreate, }; From 8363b356e0f0a1026c5283b56559b03ea14d386b Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 28 Jan 2014 18:02:08 +0900 Subject: [PATCH 024/296] Bug 931378 Set input purpose to IM context r=karlt --- widget/gtk/compat/gtk/gtkenums.h | 28 +++++++++++++++++++++++ widget/gtk/nsGtkIMModule.cpp | 38 +++++++++++++++++++++++++++----- 2 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 widget/gtk/compat/gtk/gtkenums.h diff --git a/widget/gtk/compat/gtk/gtkenums.h b/widget/gtk/compat/gtk/gtkenums.h new file mode 100644 index 00000000000..68e4d736d94 --- /dev/null +++ b/widget/gtk/compat/gtk/gtkenums.h @@ -0,0 +1,28 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef GTKENUMS_WRAPPER_H +#define GTKENUMS_WRAPPER_H + +#include_next + +#include + +#if !GTK_CHECK_VERSION(3, 6, 0) +enum GtkInputPurpose +{ + GTK_INPUT_PURPOSE_FREE_FORM, + GTK_INPUT_PURPOSE_ALPHA, + GTK_INPUT_PURPOSE_DIGITS, + GTK_INPUT_PURPOSE_NUMBER, + GTK_INPUT_PURPOSE_PHONE, + GTK_INPUT_PURPOSE_URL, + GTK_INPUT_PURPOSE_EMAIL, + GTK_INPUT_PURPOSE_NAME, + GTK_INPUT_PURPOSE_PASSWORD, + GTK_INPUT_PURPOSE_PIN +}; +#endif // 3.6.0 + +#endif /* GTKENUMS_WRAPPER_H */ diff --git a/widget/gtk/nsGtkIMModule.cpp b/widget/gtk/nsGtkIMModule.cpp index 508dac89957..25a11c0dfd4 100644 --- a/widget/gtk/nsGtkIMModule.cpp +++ b/widget/gtk/nsGtkIMModule.cpp @@ -549,7 +549,8 @@ nsGtkIMModule::SetInputContext(nsWindow* aCaller, } bool changingEnabledState = - aContext->mIMEState.mEnabled != mInputContext.mIMEState.mEnabled; + aContext->mIMEState.mEnabled != mInputContext.mIMEState.mEnabled || + aContext->mHTMLInputType != mInputContext.mHTMLInputType; // Release current IME focus if IME is enabled. if (changingEnabledState && IsEditable()) { @@ -559,12 +560,39 @@ nsGtkIMModule::SetInputContext(nsWindow* aCaller, mInputContext = *aContext; - // Even when aState is not enabled state, we need to set IME focus. - // Because some IMs are updating the status bar of them at this time. - // Be aware, don't use aWindow here because this method shouldn't move - // focus actually. if (changingEnabledState) { +#if (MOZ_WIDGET_GTK == 3) + static bool sInputPurposeSupported = !gtk_check_version(3, 6, 0); + if (sInputPurposeSupported && IsEditable()) { + GtkIMContext* context = GetContext(); + if (context) { + GtkInputPurpose purpose = GTK_INPUT_PURPOSE_FREE_FORM; + const nsString& inputType = mInputContext.mHTMLInputType; + if (inputType.EqualsLiteral("password")) { + purpose = GTK_INPUT_PURPOSE_PASSWORD; + } else if (inputType.EqualsLiteral("email")) { + purpose = GTK_INPUT_PURPOSE_EMAIL; + } else if (inputType.EqualsLiteral("url")) { + purpose = GTK_INPUT_PURPOSE_URL; + } else if (inputType.EqualsLiteral("tel")) { + purpose = GTK_INPUT_PURPOSE_PHONE; + } else if (inputType.EqualsLiteral("number")) { + purpose = GTK_INPUT_PURPOSE_NUMBER; + } + + g_object_set(context, "input-purpose", purpose, nullptr); + } + } +#endif // #if (MOZ_WIDGET_GTK == 3) + + // Even when aState is not enabled state, we need to set IME focus. + // Because some IMs are updating the status bar of them at this time. + // Be aware, don't use aWindow here because this method shouldn't move + // focus actually. Focus(); + + // XXX Should we call Blur() when it's not editable? E.g., it might be + // better to close VKB automatically. } } From d710c5e8b2945d009e02e05ae888eb7ecc1e0ae9 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 28 Jan 2014 18:02:08 +0900 Subject: [PATCH 025/296] Bug 749123 Don't use GtkIMContextSimple for IME disabled editor (GTK3 build) r=karlt --- modules/libpref/src/init/all.js | 6 +++ widget/gtk/nsGtkIMModule.cpp | 77 +++++++++++++++++++++++---------- widget/gtk/nsGtkIMModule.h | 11 +++-- 3 files changed, 69 insertions(+), 25 deletions(-) diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index edadc5fd4fc..5311322719a 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -3847,6 +3847,12 @@ pref("mousewheel.system_scroll_override_on_root_content.enabled", false); pref("ui.key.menuAccessKeyFocuses", true); +#if MOZ_WIDGET_GTK == 2 +pref("intl.ime.use_simple_context_on_password_field", true); +#else +pref("intl.ime.use_simple_context_on_password_field", false); +#endif + # XP_UNIX #endif #endif diff --git a/widget/gtk/nsGtkIMModule.cpp b/widget/gtk/nsGtkIMModule.cpp index 25a11c0dfd4..be360095e40 100644 --- a/widget/gtk/nsGtkIMModule.cpp +++ b/widget/gtk/nsGtkIMModule.cpp @@ -60,7 +60,10 @@ GetEnabledStateName(uint32_t aState) } #endif +const static bool kUseSimpleContextDefault = MOZ_WIDGET_GTK == 2; + nsGtkIMModule* nsGtkIMModule::sLastFocusedModule = nullptr; +bool nsGtkIMModule::sUseSimpleContext; nsGtkIMModule::nsGtkIMModule(nsWindow* aOwnerWindow) : mOwnerWindow(aOwnerWindow), mLastFocusedWindow(nullptr), @@ -77,6 +80,14 @@ nsGtkIMModule::nsGtkIMModule(nsWindow* aOwnerWindow) : gGtkIMLog = PR_NewLogModule("nsGtkIMModuleWidgets"); } #endif + static bool sFirstInstance = true; + if (sFirstInstance) { + sFirstInstance = false; + sUseSimpleContext = + Preferences::GetBool( + "intl.ime.use_simple_context_on_password_field", + kUseSimpleContextDefault); + } Init(); } @@ -117,26 +128,28 @@ nsGtkIMModule::Init() this); // Simple context - mSimpleContext = gtk_im_context_simple_new(); - gtk_im_context_set_client_window(mSimpleContext, gdkWindow); - g_signal_connect(mSimpleContext, "preedit_changed", - G_CALLBACK(&nsGtkIMModule::OnChangeCompositionCallback), - this); - g_signal_connect(mSimpleContext, "retrieve_surrounding", - G_CALLBACK(&nsGtkIMModule::OnRetrieveSurroundingCallback), - this); - g_signal_connect(mSimpleContext, "delete_surrounding", - G_CALLBACK(&nsGtkIMModule::OnDeleteSurroundingCallback), - this); - g_signal_connect(mSimpleContext, "commit", - G_CALLBACK(&nsGtkIMModule::OnCommitCompositionCallback), - this); - g_signal_connect(mSimpleContext, "preedit_start", - G_CALLBACK(nsGtkIMModule::OnStartCompositionCallback), - this); - g_signal_connect(mSimpleContext, "preedit_end", - G_CALLBACK(nsGtkIMModule::OnEndCompositionCallback), - this); + if (sUseSimpleContext) { + mSimpleContext = gtk_im_context_simple_new(); + gtk_im_context_set_client_window(mSimpleContext, gdkWindow); + g_signal_connect(mSimpleContext, "preedit_changed", + G_CALLBACK(&nsGtkIMModule::OnChangeCompositionCallback), + this); + g_signal_connect(mSimpleContext, "retrieve_surrounding", + G_CALLBACK(&nsGtkIMModule::OnRetrieveSurroundingCallback), + this); + g_signal_connect(mSimpleContext, "delete_surrounding", + G_CALLBACK(&nsGtkIMModule::OnDeleteSurroundingCallback), + this); + g_signal_connect(mSimpleContext, "commit", + G_CALLBACK(&nsGtkIMModule::OnCommitCompositionCallback), + this); + g_signal_connect(mSimpleContext, "preedit_start", + G_CALLBACK(nsGtkIMModule::OnStartCompositionCallback), + this); + g_signal_connect(mSimpleContext, "preedit_end", + G_CALLBACK(nsGtkIMModule::OnEndCompositionCallback), + this); + } // Dummy context mDummyContext = gtk_im_multicontext_new(); @@ -568,7 +581,25 @@ nsGtkIMModule::SetInputContext(nsWindow* aCaller, if (context) { GtkInputPurpose purpose = GTK_INPUT_PURPOSE_FREE_FORM; const nsString& inputType = mInputContext.mHTMLInputType; - if (inputType.EqualsLiteral("password")) { + // Password case has difficult issue. Desktop IMEs disable + // composition if input-purpose is password. + // For disabling IME on |ime-mode: disabled;|, we need to check + // mEnabled value instead of inputType value. This hack also + // enables composition on + // . + // This is right behavior of ime-mode on desktop. + // + // On the other hand, IME for tablet devices may provide a + // specific software keyboard for password field. If so, + // the behavior might look strange on both: + // + // + // + // Temporarily, we should focus on desktop environment for now. + // I.e., let's ignore tablet devices for now. When somebody + // reports actual trouble on tablet devices, we should try to + // look for a way to solve actual problem. + if (mInputContext.mIMEState.mEnabled == IMEState::PASSWORD) { purpose = GTK_INPUT_PURPOSE_PASSWORD; } else if (inputType.EqualsLiteral("email")) { purpose = GTK_INPUT_PURPOSE_EMAIL; @@ -626,7 +657,9 @@ bool nsGtkIMModule::IsEnabled() { return mInputContext.mIMEState.mEnabled == IMEState::ENABLED || - mInputContext.mIMEState.mEnabled == IMEState::PLUGIN; + mInputContext.mIMEState.mEnabled == IMEState::PLUGIN || + (!sUseSimpleContext && + mInputContext.mIMEState.mEnabled == IMEState::PASSWORD); } bool diff --git a/widget/gtk/nsGtkIMModule.h b/widget/gtk/nsGtkIMModule.h index 704339d2c1d..c883791c42a 100644 --- a/widget/gtk/nsGtkIMModule.h +++ b/widget/gtk/nsGtkIMModule.h @@ -106,9 +106,9 @@ protected: GtkIMContext *mContext; // mSimpleContext is used for the password field and - // the |ime-mode: disabled;| editors. These editors disable IME. - // But dead keys should work. Fortunately, the simple IM context of - // GTK2 support only them. + // the |ime-mode: disabled;| editors if sUseSimpleContext is true. + // These editors disable IME. But dead keys should work. Fortunately, + // the simple IM context of GTK2 support only them. GtkIMContext *mSimpleContext; // mDummyContext is a dummy context and will be used in Focus() @@ -203,6 +203,11 @@ protected: // this is cleared. So, this refers valid pointer always. static nsGtkIMModule* sLastFocusedModule; + // sUseSimpleContext indeicates if password editors and editors with + // |ime-mode: disabled;| should use GtkIMContextSimple. + // If true, they use GtkIMContextSimple. Otherwise, not. + static bool sUseSimpleContext; + // Callback methods for native IME events. These methods should call // the related instance methods simply. static gboolean OnRetrieveSurroundingCallback(GtkIMContext *aContext, From 9b69255a112f4aacfa4549af996e4da131e7b2c2 Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Tue, 28 Jan 2014 10:35:07 +0000 Subject: [PATCH 026/296] Bug 959787 - Fix OOM crash added by previous patch r=terrence --- js/src/jsapi.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index e7219a594ac..462c6fe1fc7 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -3494,8 +3494,10 @@ JS_PUBLIC_API(bool) JS_SetProperty(JSContext *cx, HandleObject obj, const char *name, HandleValue v) { JSAtom *atom = Atomize(cx, name, strlen(name)); + if (!atom) + return false; RootedId id(cx, AtomToId(atom)); - return atom && JS_SetPropertyById(cx, obj, id, v); + return JS_SetPropertyById(cx, obj, id, v); } JS_PUBLIC_API(bool) @@ -3503,8 +3505,10 @@ JS_SetUCProperty(JSContext *cx, HandleObject obj, const jschar *name, size_t nam HandleValue v) { JSAtom *atom = AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen)); + if (!atom) + return false; RootedId id(cx, AtomToId(atom)); - return atom && JS_SetPropertyById(cx, obj, id, v); + return JS_SetPropertyById(cx, obj, id, v); } JS_PUBLIC_API(bool) From 193ea8052708a03e0089ca1df1fa444220bfb2da Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Tue, 28 Jan 2014 10:35:53 +0000 Subject: [PATCH 027/296] Bug 961741 - Allow shape's parent to be null in postbarrier callback r=terrence --- js/src/jit-test/tests/gc/bug-961741.js | 5 +++++ js/src/vm/Shape.cpp | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 js/src/jit-test/tests/gc/bug-961741.js diff --git a/js/src/jit-test/tests/gc/bug-961741.js b/js/src/jit-test/tests/gc/bug-961741.js new file mode 100644 index 00000000000..a4d0ee7a9d8 --- /dev/null +++ b/js/src/jit-test/tests/gc/bug-961741.js @@ -0,0 +1,5 @@ +function r() { + for (var x in undefined) {} +} +setObjectMetadataCallback(true); +r(); diff --git a/js/src/vm/Shape.cpp b/js/src/vm/Shape.cpp index 73b92fa9f54..75bd0870a40 100644 --- a/js/src/vm/Shape.cpp +++ b/js/src/vm/Shape.cpp @@ -1621,7 +1621,8 @@ class InitialShapeSetRef : public BufferableRef JSObject *priorMetadata = metadata; if (proto.isObject()) Mark(trc, reinterpret_cast(&proto), "initialShapes set proto"); - Mark(trc, &parent, "initialShapes set parent"); + if (parent) + Mark(trc, &parent, "initialShapes set parent"); if (metadata) Mark(trc, &metadata, "initialShapes set metadata"); if (proto == priorProto && parent == priorParent && metadata == priorMetadata) From e1dfb36b4017fbee63cd53dfb84fcf64ce154227 Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Tue, 28 Jan 2014 10:36:56 +0000 Subject: [PATCH 028/296] Bug 964214 - Don't wait for background sweep to finish for minor GC r=terrence --- js/src/gc/Nursery.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/js/src/gc/Nursery.cpp b/js/src/gc/Nursery.cpp index 92c6f6ef04d..49be8e131e3 100644 --- a/js/src/gc/Nursery.cpp +++ b/js/src/gc/Nursery.cpp @@ -689,10 +689,6 @@ js::Nursery::collect(JSRuntime *rt, JS::gcreason::Reason reason, TypeObjectList AutoStopVerifyingBarriers av(rt, false); - TIME_START(waitBgSweep); - rt->gcHelperThread.waitBackgroundSweepEnd(); - TIME_END(waitBgSweep); - /* Move objects pointed to by roots from the nursery to the major heap. */ MinorCollectionTracer trc(rt, this); @@ -813,18 +809,17 @@ js::Nursery::collect(JSRuntime *rt, JS::gcreason::Reason reason, TypeObjectList static bool printedHeader = false; if (!printedHeader) { fprintf(stderr, - "MinorGC: Reason PRate Size Time WaitBg mkVals mkClls mkSlts mkWCll mkRVal mkRCll mkGnrc ckTbls mkRntm mkDbgr clrNOC collct updtIn resize pretnr frSlts clrSB sweep\n"); + "MinorGC: Reason PRate Size Time mkVals mkClls mkSlts mkWCll mkRVal mkRCll mkGnrc ckTbls mkRntm mkDbgr clrNOC collct updtIn resize pretnr frSlts clrSB sweep\n"); printedHeader = true; } #define FMT " %6" PRIu64 fprintf(stderr, - "MinorGC: %20s %5.1f%% %4d" FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT "\n", + "MinorGC: %20s %5.1f%% %4d" FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT FMT "\n", js::gcstats::ExplainReason(reason), promotionRate * 100, numActiveChunks_, totalTime, - TIME_TOTAL(waitBgSweep), TIME_TOTAL(markValues), TIME_TOTAL(markCells), TIME_TOTAL(markSlots), From 4b80ca0c0c780e5508dccfbf12084afae515d40f Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Tue, 28 Jan 2014 10:37:14 +0000 Subject: [PATCH 029/296] Bug 964214 - Don't recompact store buffer if there are no new entries r=terrence --- js/src/gc/StoreBuffer.cpp | 16 ++++++++++++---- js/src/gc/StoreBuffer.h | 7 ++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/js/src/gc/StoreBuffer.cpp b/js/src/gc/StoreBuffer.cpp index e74c274d8f3..c84f3f8a703 100644 --- a/js/src/gc/StoreBuffer.cpp +++ b/js/src/gc/StoreBuffer.cpp @@ -110,10 +110,18 @@ template void StoreBuffer::MonoTypeBuffer::compact(StoreBuffer *owner) { - if (!storage_) - return; - + JS_ASSERT(storage_); compactRemoveDuplicates(owner); + usedAtLastCompact_ = storage_->used(); +} + +template +void +StoreBuffer::MonoTypeBuffer::maybeCompact(StoreBuffer *owner) +{ + JS_ASSERT(storage_); + if (storage_->used() != usedAtLastCompact_) + compact(owner); } template @@ -125,7 +133,7 @@ StoreBuffer::MonoTypeBuffer::mark(StoreBuffer *owner, JSTracer *trc) if (!storage_) return; - compact(owner); + maybeCompact(owner); for (LifoAlloc::Enum e(*storage_); !e.empty(); e.popFront()) { T *edge = e.get(); if (edge->isNullEdge()) diff --git a/js/src/gc/StoreBuffer.h b/js/src/gc/StoreBuffer.h index 141f999bc7e..7a38e5938b6 100644 --- a/js/src/gc/StoreBuffer.h +++ b/js/src/gc/StoreBuffer.h @@ -91,8 +91,9 @@ class StoreBuffer struct MonoTypeBuffer { LifoAlloc *storage_; + size_t usedAtLastCompact_; - explicit MonoTypeBuffer() : storage_(nullptr) {} + explicit MonoTypeBuffer() : storage_(nullptr), usedAtLastCompact_(0) {} ~MonoTypeBuffer() { js_delete(storage_); } bool init() { @@ -107,6 +108,7 @@ class StoreBuffer return; storage_->used() ? storage_->releaseAll() : storage_->freeAll(); + usedAtLastCompact_ = 0; } bool isAboutToOverflow() const { @@ -122,6 +124,9 @@ class StoreBuffer */ virtual void compact(StoreBuffer *owner); + /* Compacts if any entries have been added since the last compaction. */ + void maybeCompact(StoreBuffer *owner); + /* Add one item to the buffer. */ void put(StoreBuffer *owner, const T &t) { JS_ASSERT(storage_); From 3542858f0a3e1554b5019d430a42cd9d53aeb281 Mon Sep 17 00:00:00 2001 From: Dave Hunt Date: Tue, 28 Jan 2014 13:02:43 +0000 Subject: [PATCH 030/296] Bug 963299 - Bump marionette_client version to 0.7.3. r=mdas --- testing/marionette/client/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/marionette/client/setup.py b/testing/marionette/client/setup.py index e1e1c43c0ea..93e5bb68f38 100644 --- a/testing/marionette/client/setup.py +++ b/testing/marionette/client/setup.py @@ -1,7 +1,7 @@ import os from setuptools import setup, find_packages -version = '0.7.2' +version = '0.7.3' # get documentation from the README try: From 806a1ed8bbe5a34266fbb87ded4b9505a38e135f Mon Sep 17 00:00:00 2001 From: Masatoshi Kimura Date: Tue, 28 Jan 2014 22:04:40 +0900 Subject: [PATCH 031/296] Bug 959958 - Implement ImageData constructor. r=bz --- content/canvas/src/ImageData.cpp | 54 +++++++++++++ content/canvas/src/ImageData.h | 13 ++++ content/canvas/test/mochitest.ini | 1 + content/canvas/test/test_ImageData_ctor.html | 80 ++++++++++++++++++++ content/canvas/test/test_canvas.html | 13 +++- dom/webidl/ImageData.webidl | 2 + 6 files changed, 160 insertions(+), 3 deletions(-) create mode 100644 content/canvas/test/test_ImageData_ctor.html diff --git a/content/canvas/src/ImageData.cpp b/content/canvas/src/ImageData.cpp index b211d416a4b..ed4595648e9 100644 --- a/content/canvas/src/ImageData.cpp +++ b/content/canvas/src/ImageData.cpp @@ -6,6 +6,7 @@ #include "mozilla/dom/ImageData.h" +#include "mozilla/CheckedInt.h" #include "mozilla/HoldDropJSObjects.h" #include "mozilla/dom/ImageDataBinding.h" @@ -35,6 +36,59 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ImageData) tmp->DropData(); NS_IMPL_CYCLE_COLLECTION_UNLINK_END +//static +ImageData* +ImageData::Constructor(const GlobalObject& aGlobal, + const uint32_t aWidth, + const uint32_t aHeight, + ErrorResult& aRv) +{ + if (aWidth == 0 || aHeight == 0) { + aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return nullptr; + } + CheckedInt length = CheckedInt(aWidth) * aHeight * 4; + if (!length.isValid()) { + aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return nullptr; + } + JS::Rooted obj(aGlobal.GetContext(), aGlobal.Get()); + JSObject* data = Uint8ClampedArray::Create(aGlobal.GetContext(), obj, + length.value()); + if (!data) { + aRv.Throw(NS_ERROR_OUT_OF_MEMORY); + return nullptr; + } + return new ImageData(aWidth, aHeight, *data); +} + +//static +ImageData* +ImageData::Constructor(const GlobalObject& aGlobal, + const Uint8ClampedArray& aData, + const uint32_t aWidth, + const Optional& aHeight, + ErrorResult& aRv) +{ + uint32_t length = aData.Length(); + if (length == 0 || length % 4) { + aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + return nullptr; + } + length /= 4; + if (aWidth == 0) { + aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return nullptr; + } + uint32_t height = length / aWidth; + if (length != aWidth * height || + (aHeight.WasPassed() && aHeight.Value() != height)) { + aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return nullptr; + } + return new ImageData(aWidth, height, *aData.Obj()); +} + void ImageData::HoldData() { diff --git a/content/canvas/src/ImageData.h b/content/canvas/src/ImageData.h index 40e6fb913f0..2e6eeb6bf28 100644 --- a/content/canvas/src/ImageData.h +++ b/content/canvas/src/ImageData.h @@ -10,6 +10,8 @@ #include "nsIDOMCanvasRenderingContext2D.h" #include "mozilla/Attributes.h" +#include "mozilla/dom/BindingUtils.h" +#include "mozilla/dom/TypedArray.h" #include #include "nsCycleCollectionParticipant.h" @@ -40,6 +42,17 @@ public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ImageData) + static ImageData* Constructor(const GlobalObject& aGlobal, + const uint32_t aWidth, + const uint32_t aHeight, + ErrorResult& aRv); + + static ImageData* Constructor(const GlobalObject& aGlobal, + const Uint8ClampedArray& aData, + const uint32_t aWidth, + const Optional& aHeight, + ErrorResult& aRv); + uint32_t Width() const { return mWidth; diff --git a/content/canvas/test/mochitest.ini b/content/canvas/test/mochitest.ini index 0543fd7b641..03dc3b88033 100644 --- a/content/canvas/test/mochitest.ini +++ b/content/canvas/test/mochitest.ini @@ -97,6 +97,7 @@ support-files = [test_drawImageIncomplete.html] [test_drawImage_document_domain.html] [test_drawImage_edge_cases.html] +[test_ImageData_ctor.html] [test_isPointInStroke.html] [test_mozDashOffset.html] [test_mozGetAsFile.html] diff --git a/content/canvas/test/test_ImageData_ctor.html b/content/canvas/test/test_ImageData_ctor.html new file mode 100644 index 00000000000..cb432945437 --- /dev/null +++ b/content/canvas/test/test_ImageData_ctor.html @@ -0,0 +1,80 @@ + +Canvas test: ImageData + + + +
+ + diff --git a/content/canvas/test/test_canvas.html b/content/canvas/test/test_canvas.html index 9a6bfefcd34..c73a4ac2003 100644 --- a/content/canvas/test/test_canvas.html +++ b/content/canvas/test/test_canvas.html @@ -8363,9 +8363,16 @@ var canvas = document.getElementById('c280'); var ctx = canvas.getContext('2d'); ok(window.ImageData !== undefined, "window.ImageData !== undefined"); -try { var _thrown = false; - new window.ImageData(1,1); -} catch (e) { _thrown = true; } finally { ok(_thrown, "should throw exception"); } + +var _thrown_outer = false; +try { + +new window.ImageData(1,1); + +} catch (e) { + _thrown_outer = true; +} +ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception'); } diff --git a/dom/webidl/ImageData.webidl b/dom/webidl/ImageData.webidl index 869aff7b02f..dae457594d8 100644 --- a/dom/webidl/ImageData.webidl +++ b/dom/webidl/ImageData.webidl @@ -10,6 +10,8 @@ * You are granted a license to use, reproduce and create derivative works of this document. */ +[Constructor(unsigned long sw, unsigned long sh), + Constructor(Uint8ClampedArray data, unsigned long sw, optional unsigned long sh)] interface ImageData { [Constant] readonly attribute unsigned long width; From d652c612a496fabedc95646042249c4376aa4016 Mon Sep 17 00:00:00 2001 From: Emanuel Hoogeveen Date: Tue, 28 Jan 2014 08:55:40 -0500 Subject: [PATCH 032/296] Bug 841646 - Part 1: Refactor allocProfileString to not require a JSContext and remove JSContext * parameters from functions that no longer require them as a result. r=jandem --- js/src/jit/BaselineBailouts.cpp | 2 +- js/src/jit/BaselineIC.cpp | 4 +- js/src/jit/CodeGenerator.cpp | 2 +- js/src/jit/VMFunctions.cpp | 6 +-- js/src/vm/Probes-inl.h | 4 +- js/src/vm/SPSProfiler.cpp | 80 ++++++++++++++++++--------------- js/src/vm/SPSProfiler.h | 14 +++--- 7 files changed, 60 insertions(+), 52 deletions(-) diff --git a/js/src/jit/BaselineBailouts.cpp b/js/src/jit/BaselineBailouts.cpp index 688fcddbce5..0adf78037ca 100644 --- a/js/src/jit/BaselineBailouts.cpp +++ b/js/src/jit/BaselineBailouts.cpp @@ -964,7 +964,7 @@ InitFromBailout(JSContext *cx, HandleScript caller, jsbytecode *callerPC, } else if (bailoutKind != Bailout_ArgumentCheck) { IonSpew(IonSpew_BaselineBailouts, " Popping SPS entry for innermost inlined frame's SPS entry"); - cx->runtime()->spsProfiler.exit(cx, script, fun); + cx->runtime()->spsProfiler.exit(script, fun); } } } else { diff --git a/js/src/jit/BaselineIC.cpp b/js/src/jit/BaselineIC.cpp index da926f3b8c4..ebde4d44f98 100644 --- a/js/src/jit/BaselineIC.cpp +++ b/js/src/jit/BaselineIC.cpp @@ -1041,7 +1041,7 @@ DoProfilerFallback(JSContext *cx, BaselineFrame *frame, ICProfiler_Fallback *stu // Manually enter SPS this time. JS_ASSERT(profiler->enabled()); - if (!cx->runtime()->spsProfiler.enter(cx, script, func)) + if (!cx->runtime()->spsProfiler.enter(script, func)) return false; frame->setPushedSPSFrame(); @@ -1054,7 +1054,7 @@ DoProfilerFallback(JSContext *cx, BaselineFrame *frame, ICProfiler_Fallback *stu JS_ASSERT(icEntry->firstStub() == stub); // Generate the string to use to identify this stack frame. - const char *string = profiler->profileString(cx, script, func); + const char *string = profiler->profileString(script, func); if (string == nullptr) return false; diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index 0fc982c241e..200538d2c4c 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -7764,7 +7764,7 @@ CodeGenerator::visitFunctionBoundary(LFunctionBoundary *lir) return true; } - return sps_.push(GetIonContext()->cx, lir->script(), masm, temp); + return sps_.push(lir->script(), masm, temp); case MFunctionBoundary::Inline_Exit: // all inline returns were covered with ::Exit, so we just need to diff --git a/js/src/jit/VMFunctions.cpp b/js/src/jit/VMFunctions.cpp index 00685d7e928..981974fe6c7 100644 --- a/js/src/jit/VMFunctions.cpp +++ b/js/src/jit/VMFunctions.cpp @@ -526,13 +526,13 @@ NewStringObject(JSContext *cx, HandleString str) bool SPSEnter(JSContext *cx, HandleScript script) { - return cx->runtime()->spsProfiler.enter(cx, script, script->functionNonDelazifying()); + return cx->runtime()->spsProfiler.enter(script, script->functionNonDelazifying()); } bool SPSExit(JSContext *cx, HandleScript script) { - cx->runtime()->spsProfiler.exit(cx, script, script->functionNonDelazifying()); + cx->runtime()->spsProfiler.exit(script, script->functionNonDelazifying()); return true; } @@ -732,7 +732,7 @@ DebugEpilogue(JSContext *cx, BaselineFrame *frame, jsbytecode *pc, bool ok) // If the frame has a pushed SPS frame, make sure to pop it. if (frame->hasPushedSPSFrame()) { - cx->runtime()->spsProfiler.exit(cx, frame->script(), frame->maybeFun()); + cx->runtime()->spsProfiler.exit(frame->script(), frame->maybeFun()); // Unset the pushedSPSFrame flag because DebugEpilogue may get called before // probes::ExitScript in baseline during exception handling, and we don't // want to double-pop SPS frames. diff --git a/js/src/vm/Probes-inl.h b/js/src/vm/Probes-inl.h index 7900ab2da9c..75bedac7a2a 100644 --- a/js/src/vm/Probes-inl.h +++ b/js/src/vm/Probes-inl.h @@ -54,7 +54,7 @@ probes::EnterScript(JSContext *cx, JSScript *script, JSFunction *maybeFun, JSRuntime *rt = cx->runtime(); if (rt->spsProfiler.enabled()) { - rt->spsProfiler.enter(cx, script, maybeFun); + rt->spsProfiler.enter(script, maybeFun); JS_ASSERT_IF(!fp->isGeneratorFrame(), !fp->hasPushedSPSFrame()); fp->setPushedSPSFrame(); } @@ -76,7 +76,7 @@ probes::ExitScript(JSContext *cx, JSScript *script, JSFunction *maybeFun, bool p #endif if (popSPSFrame) - cx->runtime()->spsProfiler.exit(cx, script, maybeFun); + cx->runtime()->spsProfiler.exit(script, maybeFun); return ok; } diff --git a/js/src/vm/SPSProfiler.cpp b/js/src/vm/SPSProfiler.cpp index 61411664d5d..a09f7d466f2 100644 --- a/js/src/vm/SPSProfiler.cpp +++ b/js/src/vm/SPSProfiler.cpp @@ -9,6 +9,7 @@ #include "mozilla/DebugOnly.h" #include "jsnum.h" +#include "jsprf.h" #include "jsscript.h" #include "jit/BaselineJIT.h" @@ -76,13 +77,13 @@ SPSProfiler::enable(bool enabled) /* Lookup the string for the function/script, creating one if necessary */ const char* -SPSProfiler::profileString(JSContext *cx, JSScript *script, JSFunction *maybeFun) +SPSProfiler::profileString(JSScript *script, JSFunction *maybeFun) { JS_ASSERT(strings.initialized()); ProfileStringMap::AddPtr s = strings.lookupForAdd(script); if (s) return s->value(); - const char *str = allocProfileString(cx, script, maybeFun); + const char *str = allocProfileString(script, maybeFun); if (str == nullptr) return nullptr; if (!strings.add(s, script, str)) { @@ -112,9 +113,9 @@ SPSProfiler::onScriptFinalized(JSScript *script) } bool -SPSProfiler::enter(JSContext *cx, JSScript *script, JSFunction *maybeFun) +SPSProfiler::enter(JSScript *script, JSFunction *maybeFun) { - const char *str = profileString(cx, script, maybeFun); + const char *str = profileString(script, maybeFun); if (str == nullptr) return false; @@ -125,14 +126,14 @@ SPSProfiler::enter(JSContext *cx, JSScript *script, JSFunction *maybeFun) } void -SPSProfiler::exit(JSContext *cx, JSScript *script, JSFunction *maybeFun) +SPSProfiler::exit(JSScript *script, JSFunction *maybeFun) { pop(); #ifdef DEBUG /* Sanity check to make sure push/pop balanced */ if (*size_ < max_) { - const char *str = profileString(cx, script, maybeFun); + const char *str = profileString(script, maybeFun); /* Can't fail lookup because we should already be in the set */ JS_ASSERT(str != nullptr); @@ -207,44 +208,53 @@ SPSProfiler::pop() * some scripts, resize the hash table of profile strings, and invalidate the * AddPtr held while invoking allocProfileString. */ -const char* -SPSProfiler::allocProfileString(JSContext *cx, JSScript *script, JSFunction *maybeFun) +const char * +SPSProfiler::allocProfileString(JSScript *script, JSFunction *maybeFun) { // Note: this profiler string is regexp-matched by // browser/devtools/profiler/cleopatra/js/parserWorker.js. - DebugOnly gcBefore = cx->runtime()->gcNumber; - StringBuffer buf(cx); - bool hasAtom = maybeFun != nullptr && maybeFun->displayAtom() != nullptr; - if (hasAtom) { - if (!buf.append(maybeFun->displayAtom())) - return nullptr; - if (!buf.append(" (")) - return nullptr; - } - if (script->filename()) { - if (!buf.appendInflated(script->filename(), strlen(script->filename()))) - return nullptr; - } else if (!buf.append("")) { - return nullptr; - } - if (!buf.append(":")) - return nullptr; - if (!NumberValueToStringBuffer(cx, NumberValue(script->lineno()), buf)) - return nullptr; - if (hasAtom && !buf.append(")")) - return nullptr; - size_t len = buf.length(); + // Determine if the function (if any) has an explicit or guessed name. + bool hasAtom = maybeFun && maybeFun->displayAtom(); + + // Get the function name, if any, and its length. + const jschar *atom = nullptr; + size_t lenAtom = 0; + if (hasAtom) { + atom = maybeFun->displayAtom()->charsZ(); + lenAtom = maybeFun->displayAtom()->length(); + } + + // Get the script filename, if any, and its length. + const char *filename = script->filename(); + if (filename == nullptr) + filename = ""; + size_t lenFilename = strlen(filename); + + // Get the line number and its length as a string. + uint64_t lineno = script->lineno(); + size_t lenLineno = 1; + for (uint64_t i = lineno; i /= 10; lenLineno++); + + // Determine the required buffer size. + size_t len = lenFilename + lenLineno + 1; // +1 for the ":" separating them. + if (hasAtom) + len += lenAtom + 3; // +3 for the " (" and ")" it adds. + + // Allocate the buffer. char *cstr = js_pod_malloc(len + 1); if (cstr == nullptr) return nullptr; - const jschar *ptr = buf.begin(); - for (size_t i = 0; i < len; i++) - cstr[i] = ptr[i]; - cstr[len] = 0; + // Construct the descriptive string. + size_t ret; + if (hasAtom) + ret = JS_snprintf(cstr, len + 1, "%hs (%s:%llu)", atom, filename, lineno); + else + ret = JS_snprintf(cstr, len + 1, "%s:%llu", filename, lineno); + + MOZ_ASSERT(ret == len, "Computed length should match actual length!"); - JS_ASSERT(gcBefore == cx->runtime()->gcNumber); return cstr; } diff --git a/js/src/vm/SPSProfiler.h b/js/src/vm/SPSProfiler.h index b33af92eab9..e2df55bed4c 100644 --- a/js/src/vm/SPSProfiler.h +++ b/js/src/vm/SPSProfiler.h @@ -124,8 +124,7 @@ class SPSProfiler bool slowAssertions; uint32_t enabled_; - const char *allocProfileString(JSContext *cx, JSScript *script, - JSFunction *function); + const char *allocProfileString(JSScript *script, JSFunction *function); void push(const char *string, void *sp, JSScript *script, jsbytecode *pc); void pop(); @@ -165,8 +164,8 @@ class SPSProfiler * - exit: this function has ceased execution, and no further * entries/exits will be made */ - bool enter(JSContext *cx, JSScript *script, JSFunction *maybeFun); - void exit(JSContext *cx, JSScript *script, JSFunction *maybeFun); + bool enter(JSScript *script, JSFunction *maybeFun); + void exit(JSScript *script, JSFunction *maybeFun); void updatePC(JSScript *script, jsbytecode *pc) { if (enabled() && *size_ - 1 < max_) { JS_ASSERT(*size_ > 0); @@ -182,7 +181,7 @@ class SPSProfiler jsbytecode *ipToPC(JSScript *script, size_t ip) { return nullptr; } void setProfilingStack(ProfileEntry *stack, uint32_t *size, uint32_t max); - const char *profileString(JSContext *cx, JSScript *script, JSFunction *maybeFun); + const char *profileString(JSScript *script, JSFunction *maybeFun); void onScriptFinalized(JSScript *script); /* meant to be used for testing, not recommended to call in normal code */ @@ -320,11 +319,10 @@ class SPSInstrumentation * Flags entry into a JS function for the first time. Before this is called, * no instrumentation is emitted, but after this instrumentation is emitted. */ - bool push(JSContext *cx, JSScript *script, Assembler &masm, Register scratch) { + bool push(JSScript *script, Assembler &masm, Register scratch) { if (!enabled()) return true; - const char *string = profiler_->profileString(cx, script, - script->functionNonDelazifying()); + const char *string = profiler_->profileString(script, script->functionNonDelazifying()); if (string == nullptr) return false; masm.spsPushFrame(profiler_, string, script, scratch); From 5734d88f7faad4d9d7cb930410d5f91ed2236b82 Mon Sep 17 00:00:00 2001 From: Emanuel Hoogeveen Date: Tue, 28 Jan 2014 08:56:05 -0500 Subject: [PATCH 033/296] Bug 841646 - Part 2: Add locks around |strings| table access to avoid races. r=jandem --- js/src/vm/SPSProfiler.cpp | 11 ++++++++++ js/src/vm/SPSProfiler.h | 43 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/js/src/vm/SPSProfiler.cpp b/js/src/vm/SPSProfiler.cpp index a09f7d466f2..762ade86ed9 100644 --- a/js/src/vm/SPSProfiler.cpp +++ b/js/src/vm/SPSProfiler.cpp @@ -28,6 +28,11 @@ SPSProfiler::SPSProfiler(JSRuntime *rt) enabled_(false) { JS_ASSERT(rt != nullptr); +#ifdef JS_THREADSAFE + lock_ = PR_NewLock(); + if (lock_ == nullptr) + MOZ_CRASH("Couldn't allocate lock!"); +#endif } SPSProfiler::~SPSProfiler() @@ -36,11 +41,15 @@ SPSProfiler::~SPSProfiler() for (ProfileStringMap::Enum e(strings); !e.empty(); e.popFront()) js_free(const_cast(e.front().value())); } +#ifdef JS_THREADSAFE + PR_DestroyLock(lock_); +#endif } void SPSProfiler::setProfilingStack(ProfileEntry *stack, uint32_t *size, uint32_t max) { + AutoSPSLock lock(lock_); JS_ASSERT_IF(size_ && *size_ != 0, !enabled()); if (!strings.initialized()) strings.init(); @@ -79,6 +88,7 @@ SPSProfiler::enable(bool enabled) const char* SPSProfiler::profileString(JSScript *script, JSFunction *maybeFun) { + AutoSPSLock lock(lock_); JS_ASSERT(strings.initialized()); ProfileStringMap::AddPtr s = strings.lookupForAdd(script); if (s) @@ -103,6 +113,7 @@ SPSProfiler::onScriptFinalized(JSScript *script) * off, we still want to remove the string, so no check of enabled() is * done. */ + AutoSPSLock lock(lock_); if (!strings.initialized()) return; if (ProfileStringMap::Ptr entry = strings.lookup(script)) { diff --git a/js/src/vm/SPSProfiler.h b/js/src/vm/SPSProfiler.h index e2df55bed4c..e27f3bcfa8a 100644 --- a/js/src/vm/SPSProfiler.h +++ b/js/src/vm/SPSProfiler.h @@ -12,6 +12,7 @@ #include +#include "jslock.h" #include "jsscript.h" #include "js/ProfilingStack.h" @@ -123,6 +124,7 @@ class SPSProfiler uint32_t max_; bool slowAssertions; uint32_t enabled_; + PRLock *lock_; const char *allocProfileString(JSScript *script, JSFunction *function); void push(const char *string, void *sp, JSScript *script, jsbytecode *pc); @@ -185,14 +187,51 @@ class SPSProfiler void onScriptFinalized(JSScript *script); /* meant to be used for testing, not recommended to call in normal code */ - size_t stringsCount() { return strings.count(); } - void stringsReset() { strings.clear(); } + size_t stringsCount(); + void stringsReset(); uint32_t *addressOfEnabled() { return &enabled_; } }; +/* + * This class is used to make sure the strings table + * is only accessed on one thread at a time. + */ +class AutoSPSLock +{ + public: +#ifdef JS_THREADSAFE + AutoSPSLock(PRLock *lock) + { + MOZ_ASSERT(lock, "Parameter should not be null!"); + lock_ = lock; + PR_Lock(lock); + } + ~AutoSPSLock() { PR_Unlock(lock_); } +#else + AutoSPSLock(PRLock *) {} +#endif + + private: + PRLock *lock_; +}; + +inline size_t +SPSProfiler::stringsCount() +{ + AutoSPSLock lock(lock_); + return strings.count(); +} + +inline void +SPSProfiler::stringsReset() +{ + AutoSPSLock lock(lock_); + strings.clear(); +} + /* * This class is used in RunScript() to push the marker onto the sampling stack * that we're about to enter JS function calls. This is the only time in which a From fb646d6e4c5c2bf5ae1762c4d28afe19e7386118 Mon Sep 17 00:00:00 2001 From: Emanuel Hoogeveen Date: Tue, 28 Jan 2014 08:56:27 -0500 Subject: [PATCH 034/296] Bug 841646 - Part 3: Move SPSProfiler::slowAssertionsEnabled checks to JitCompileOptions and remove SPSInstrumentation::slowAssertions. r=jandem --- js/src/jit/CodeGenerator.cpp | 4 ++-- js/src/jit/CompileWrappers.cpp | 5 ++++- js/src/jit/CompileWrappers.h | 5 +++++ js/src/jit/Lowering.cpp | 3 +-- js/src/vm/SPSProfiler.h | 1 - 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index 200538d2c4c..a4f74b979e3 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -7754,7 +7754,7 @@ CodeGenerator::visitFunctionBoundary(LFunctionBoundary *lir) // fallthrough case MFunctionBoundary::Enter: - if (sps_.slowAssertions()) { + if (gen->options.spsSlowAssertionsEnabled()) { saveLive(lir); pushArg(ImmGCPtr(lir->script())); if (!callVM(SPSEnterInfo, lir)) @@ -7775,7 +7775,7 @@ CodeGenerator::visitFunctionBoundary(LFunctionBoundary *lir) return true; case MFunctionBoundary::Exit: - if (sps_.slowAssertions()) { + if (gen->options.spsSlowAssertionsEnabled()) { saveLive(lir); pushArg(ImmGCPtr(lir->script())); // Once we've exited, then we shouldn't emit instrumentation for diff --git a/js/src/jit/CompileWrappers.cpp b/js/src/jit/CompileWrappers.cpp index c2a1c226e29..37cb3efea5c 100644 --- a/js/src/jit/CompileWrappers.cpp +++ b/js/src/jit/CompileWrappers.cpp @@ -254,7 +254,8 @@ AutoLockForCompilation::AutoLockForCompilation(CompileCompartment *compartment #endif JitCompileOptions::JitCompileOptions() - : cloneSingletons_(false) + : cloneSingletons_(false), + spsSlowAssertionsEnabled_(false) { } @@ -262,4 +263,6 @@ JitCompileOptions::JitCompileOptions(JSContext *cx) { JS::CompartmentOptions &options = cx->compartment()->options(); cloneSingletons_ = options.cloneSingletons(cx); + spsSlowAssertionsEnabled_ = cx->runtime()->spsProfiler.enabled() && + cx->runtime()->spsProfiler.slowAssertionsEnabled(); } diff --git a/js/src/jit/CompileWrappers.h b/js/src/jit/CompileWrappers.h index 88f946c9968..2a8bc4f8d30 100644 --- a/js/src/jit/CompileWrappers.h +++ b/js/src/jit/CompileWrappers.h @@ -128,8 +128,13 @@ class JitCompileOptions return cloneSingletons_; } + bool spsSlowAssertionsEnabled() const { + return spsSlowAssertionsEnabled_; + } + private: bool cloneSingletons_; + bool spsSlowAssertionsEnabled_; }; diff --git a/js/src/jit/Lowering.cpp b/js/src/jit/Lowering.cpp index e8ad7e63983..e170d8ca744 100644 --- a/js/src/jit/Lowering.cpp +++ b/js/src/jit/Lowering.cpp @@ -3275,8 +3275,7 @@ LIRGenerator::visitFunctionBoundary(MFunctionBoundary *ins) return false; // If slow assertions are enabled, then this node will result in a callVM // out to a C++ function for the assertions, so we will need a safepoint. - return !GetIonContext()->runtime->spsProfiler().slowAssertionsEnabled() || - assignSafepoint(lir, ins); + return !gen->options.spsSlowAssertionsEnabled() || assignSafepoint(lir, ins); } bool diff --git a/js/src/vm/SPSProfiler.h b/js/src/vm/SPSProfiler.h index e27f3bcfa8a..a4c714cf1b2 100644 --- a/js/src/vm/SPSProfiler.h +++ b/js/src/vm/SPSProfiler.h @@ -292,7 +292,6 @@ class SPSInstrumentation /* Small proxies around SPSProfiler */ bool enabled() { return profiler_ && profiler_->enabled(); } SPSProfiler *profiler() { JS_ASSERT(enabled()); return profiler_; } - bool slowAssertions() { return enabled() && profiler_->slowAssertionsEnabled(); } /* Signals an inline function returned, reverting to the previous state */ void leaveInlineFrame() { From 10619ca926d02613beb36f5b80dd5ecac3d3e37d Mon Sep 17 00:00:00 2001 From: Emanuel Hoogeveen Date: Tue, 28 Jan 2014 08:56:51 -0500 Subject: [PATCH 035/296] Bug 841646 - Part 4: Allow parallel compilation while the SPS Profiler is active. r=jandem --- js/src/jit/Ion.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/js/src/jit/Ion.cpp b/js/src/jit/Ion.cpp index a92d6cd3550..79ed27604ff 100644 --- a/js/src/jit/Ion.cpp +++ b/js/src/jit/Ion.cpp @@ -1571,14 +1571,9 @@ OffThreadCompilationAvailable(JSContext *cx) // Skip off thread compilation if PC count profiling is enabled, as // CodeGenerator::maybeCreateScriptCounts will not attach script profiles // when running off thread. - // - // Also skip off thread compilation if the SPS profiler is enabled, as it - // stores strings in the spsProfiler data structure, which is not protected - // by a lock. return cx->runtime()->canUseParallelIonCompilation() && cx->runtime()->gcIncrementalState == gc::NO_INCREMENTAL - && !cx->runtime()->profilingScripts - && !cx->runtime()->spsProfiler.enabled(); + && !cx->runtime()->profilingScripts; } static void @@ -1735,8 +1730,7 @@ IonCompile(JSContext *cx, JSScript *script, Maybe protect; if (js_JitOptions.checkThreadSafety && cx->runtime()->gcIncrementalState == gc::NO_INCREMENTAL && - !cx->runtime()->profilingScripts && - !cx->runtime()->spsProfiler.enabled()) + !cx->runtime()->profilingScripts) { protect.construct(cx->runtime()); } From 3c6bb5e907be57d8546f4ce0710d78c2d5825ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=83=C2=A9d=C3=83=C2=A9ric=20Wang?= Date: Tue, 28 Jan 2014 08:57:08 -0500 Subject: [PATCH 036/296] Bug 945254 - Take italic correction into account when positioning subscripts. r=karlt --- layout/mathml/nsMathMLmmultiscriptsFrame.cpp | 14 +++-- .../reftests/mathml/multiscripts-1-ref.html | 8 +-- layout/reftests/mathml/multiscripts-1.html | 9 +-- layout/reftests/mathml/reftest.list | 1 + .../subscript-italic-correction-ref.html | 36 +++++++++++ .../mathml/subscript-italic-correction.html | 61 +++++++++++++++++++ 6 files changed, 109 insertions(+), 20 deletions(-) create mode 100644 layout/reftests/mathml/subscript-italic-correction-ref.html create mode 100644 layout/reftests/mathml/subscript-italic-correction.html diff --git a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp index 9869d56051e..bf70d549812 100644 --- a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp +++ b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp @@ -357,8 +357,7 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext, // we update boundingMetrics.{ascent,descent} with that // of the baseFrame only after processing all the sup/sub pairs - // XXX need italic correction only *if* there are postscripts ? - boundingMetrics.width = bmBase.width + italicCorrection; + boundingMetrics.width = bmBase.width; boundingMetrics.rightBearing = bmBase.rightBearing; boundingMetrics.leftBearing = bmBase.leftBearing; // until overwritten } else { @@ -425,9 +424,10 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext, if (bmSupScript.width) width = std::max(width, bmSupScript.width + aScriptSpace); - rightBearing = std::max(rightBearing, bmSupScript.rightBearing); if (!prescriptsFrame) { // we are still looping over base & postscripts + rightBearing = std::max(rightBearing, + italicCorrection + bmSupScript.rightBearing); boundingMetrics.rightBearing = boundingMetrics.width + rightBearing; boundingMetrics.width += width; } else { @@ -570,7 +570,7 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext, baseSize.Width(), dx), dy, 0); - dx += bmBase.width + italicCorrection; + dx += bmBase.width; } else if (prescriptsFrame != childFrame) { // process each sup/sub pair if (0 == count) { @@ -608,8 +608,12 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext, if (supScriptFrame) { nscoord x = dx; - if (isPreScript) + if (isPreScript) { x += width - supScriptSize.Width(); + } else { + // post superscripts are shifted by the italic correction value + x += italicCorrection; + } dy = aDesiredSize.TopAscent() - supScriptSize.TopAscent() - maxSupScriptShift; FinishReflowChild (supScriptFrame, aPresContext, supScriptSize, diff --git a/layout/reftests/mathml/multiscripts-1-ref.html b/layout/reftests/mathml/multiscripts-1-ref.html index 5ba708c759f..05db5cede64 100644 --- a/layout/reftests/mathml/multiscripts-1-ref.html +++ b/layout/reftests/mathml/multiscripts-1-ref.html @@ -58,13 +58,7 @@

- msup / msupsub: - - - AAA - - - + msupsub: AAA diff --git a/layout/reftests/mathml/multiscripts-1.html b/layout/reftests/mathml/multiscripts-1.html index a9b251cf4d8..a0e1f1b285e 100644 --- a/layout/reftests/mathml/multiscripts-1.html +++ b/layout/reftests/mathml/multiscripts-1.html @@ -58,14 +58,7 @@

- msup / msupsub: - - - AAA - - - - + msupsub: AAA diff --git a/layout/reftests/mathml/reftest.list b/layout/reftests/mathml/reftest.list index 62647262863..423550be503 100644 --- a/layout/reftests/mathml/reftest.list +++ b/layout/reftests/mathml/reftest.list @@ -155,6 +155,7 @@ fails == whitespace-trim-4.html whitespace-trim-4-ref.html # Bug 787215 == mathml-mmultiscript-mprescript.html mathml-mmultiscript-mprescript-ref.html != menclose-1.html menclose-1-ref.html == mmultiscript-align.html mmultiscript-align-ref.html +== subscript-italic-correction.html subscript-italic-correction-ref.html == mathvariant-1a.html mathvariant-1a-ref.html == mathvariant-1b.html mathvariant-1b-ref.html == mathvariant-1c.html mathvariant-1c-ref.html diff --git a/layout/reftests/mathml/subscript-italic-correction-ref.html b/layout/reftests/mathml/subscript-italic-correction-ref.html new file mode 100644 index 00000000000..247149bade8 --- /dev/null +++ b/layout/reftests/mathml/subscript-italic-correction-ref.html @@ -0,0 +1,36 @@ + + + + subscript + + + + +
+ + + f + + + + +
+ +
+ +
+ + + f + + + + + + + + +
+ + + diff --git a/layout/reftests/mathml/subscript-italic-correction.html b/layout/reftests/mathml/subscript-italic-correction.html new file mode 100644 index 00000000000..fb571605f83 --- /dev/null +++ b/layout/reftests/mathml/subscript-italic-correction.html @@ -0,0 +1,61 @@ + + + + subscript + + + + + +
+ + + f + + + + +
+ +
+ +
+ + + f + + + + + + + + +
+ + + From aa5444a7119eda60663fbbaee93460b347315e82 Mon Sep 17 00:00:00 2001 From: Milan Sreckovic Date: Fri, 24 Jan 2014 17:19:34 -0500 Subject: [PATCH 037/296] Bug 946860 - Move the preference evaluation to main thread. r=gwright --- gfx/gl/GLLibraryEGL.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/gfx/gl/GLLibraryEGL.cpp b/gfx/gl/GLLibraryEGL.cpp index 0043bfc8105..6cb4b6c2bf4 100644 --- a/gfx/gl/GLLibraryEGL.cpp +++ b/gfx/gl/GLLibraryEGL.cpp @@ -32,16 +32,12 @@ static const char *sEGLExtensionNames[] = { #if defined(ANDROID) +static bool sUseApitraceInitialized = false; +static bool sUseApitrace = false; + static PRLibrary* LoadApitraceLibrary() { - static bool sUseApitraceInitialized = false; - static bool sUseApitrace = false; - - if (!sUseApitraceInitialized) { - sUseApitrace = Preferences::GetBool("gfx.apitrace.enabled", false); - sUseApitraceInitialized = true; - } - + MOZ_ASSERT(sUseApitraceInitialized); if (!sUseApitrace) { return nullptr; } @@ -105,6 +101,13 @@ GLLibraryEGL::EnsureInitialized() return true; } +#if defined(ANDROID) + if (!sUseApitraceInitialized) { + sUseApitrace = Preferences::GetBool("gfx.apitrace.enabled", false); + sUseApitraceInitialized = true; + } +#endif // ANDROID + mozilla::ScopedGfxFeatureReporter reporter("EGL"); #ifdef XP_WIN From c913854ce27dd9299fbc9bbf10b4c7f4bd888c43 Mon Sep 17 00:00:00 2001 From: Dan Glastonbury Date: Fri, 10 Jan 2014 12:23:56 +1000 Subject: [PATCH 038/296] Bug 948002 - Add functions getExtensionWithKnownPrefixes and getSupportedExtensionWithKnownPrefixes to fix tests that fail to parse. r=bjacob, r=jgilbert --- .../conformance/resources/webgl-test-utils.js | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/content/canvas/test/webgl/conformance/resources/webgl-test-utils.js b/content/canvas/test/webgl/conformance/resources/webgl-test-utils.js index 97294cac9e8..e1ab518ce80 100644 --- a/content/canvas/test/webgl/conformance/resources/webgl-test-utils.js +++ b/content/canvas/test/webgl/conformance/resources/webgl-test-utils.js @@ -767,6 +767,50 @@ var loadTextFileAsync = function(url, callback) { } }; +// Add your prefix here. +var browserPrefixes = [ + "", + "MOZ_", + "OP_", + "WEBKIT_" +]; + +/** + * Given an extension name like WEBGL_compressed_texture_s3tc + * returns the name of the supported version extension, like + * WEBKIT_WEBGL_compressed_teture_s3tc + * @param {string} name Name of extension to look for + * @return {string} name of extension found or undefined if not + * found. + */ +var getSupportedExtensionWithKnownPrefixes = function(gl, name) { + var supported = gl.getSupportedExtensions(); + for (var ii = 0; ii < browserPrefixes.length; ++ii) { + var prefixedName = browserPrefixes[ii] + name; + if (supported.indexOf(prefixedName) >= 0) { + return prefixedName; + } + } +}; + +/** + * Given an extension name like WEBGL_compressed_texture_s3tc + * returns the supported version extension, like + * WEBKIT_WEBGL_compressed_teture_s3tc + * @param {string} name Name of extension to look for + * @return {WebGLExtension} The extension or undefined if not + * found. + */ +var getExtensionWithKnownPrefixes = function(gl, name) { + for (var ii = 0; ii < browserPrefixes.length; ++ii) { + var prefixedName = browserPrefixes[ii] + name; + var ext = gl.getExtension(prefixedName); + if (ext) { + return ext; + } + } +}; + /** * Recursively loads a file as a list. Each line is parsed for a relative * path. If the file ends in .txt the contents of that file is inserted in @@ -1277,9 +1321,11 @@ return { createColoredTexture: createColoredTexture, drawQuad: drawQuad, endsWith: endsWith, + getExtensionWithKnownPrefixes: getExtensionWithKnownPrefixes, getFileListAsync: getFileListAsync, getLastError: getLastError, getScript: getScript, + getSupportedExtensionWithKnownPrefixes: getSupportedExtensionWithKnownPrefixes, getUrlArguments: getUrlArguments, glEnumToString: glEnumToString, glErrorShouldBe: glErrorShouldBe, From 78c24fc87187579052cbadcff6be8160a33c15ec Mon Sep 17 00:00:00 2001 From: Dan Glastonbury Date: Fri, 24 Jan 2014 13:52:33 +1000 Subject: [PATCH 039/296] Bug 948002 - Remove trailing whitespace. r=jgilbert --- content/canvas/src/WebGLContextUtils.cpp | 6 +++--- content/canvas/src/WebGLTexelConversions.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/content/canvas/src/WebGLContextUtils.cpp b/content/canvas/src/WebGLContextUtils.cpp index c4e14764eeb..32dcc8abfd3 100644 --- a/content/canvas/src/WebGLContextUtils.cpp +++ b/content/canvas/src/WebGLContextUtils.cpp @@ -67,8 +67,8 @@ WebGLContext::ShouldGenerateWarnings() const } CheckedUint32 -WebGLContext::GetImageSize(GLsizei height, - GLsizei width, +WebGLContext::GetImageSize(GLsizei height, + GLsizei width, uint32_t pixelSize, uint32_t packOrUnpackAlignment) { @@ -91,7 +91,7 @@ WebGLContext::SynthesizeGLError(GLenum err) // but if there isn't, then we need to check for a gl error // that may have occurred before this one and use that code // instead. - + MakeContextCurrent(); UpdateWebGLErrorAndClearGLError(); diff --git a/content/canvas/src/WebGLTexelConversions.cpp b/content/canvas/src/WebGLTexelConversions.cpp index ba6926d4269..792e6810c76 100644 --- a/content/canvas/src/WebGLTexelConversions.cpp +++ b/content/canvas/src/WebGLTexelConversions.cpp @@ -16,7 +16,7 @@ namespace { * This class is just a helper to implement WebGLContext::ConvertImage below. * * Design comments: - * + * * WebGLContext::ConvertImage has to handle hundreds of format conversion paths. * It is important to minimize executable code size here. Instead of passing around * a large number of function parameters hundreds of times, we create a @@ -381,4 +381,4 @@ WebGLContext::ConvertImage(size_t width, size_t height, size_t srcStride, size_t } } -} // end namespace mozilla +} // end namespace mozilla From 9e7275ca4283c165fb100a68011c2d0e0ccd96e6 Mon Sep 17 00:00:00 2001 From: Dan Glastonbury Date: Fri, 24 Jan 2014 13:53:53 +1000 Subject: [PATCH 040/296] Bug 948002 - Fix WebGL framebuffer completeness checks. r=bjacob When changing WebGLTexture::ImageInfo to consistently store GL internal format instead of format, code that checked for depth textures broke because general depth component format type was being checked instead of the sized formats. With :bjacob, we audited the locations of the checks and updated the code to accept the internal formats by utilizing helper functions that check the GLenum. --- content/canvas/src/WebGLContextGL.cpp | 96 ++++++++++------- content/canvas/src/WebGLContextUtils.cpp | 35 ++++--- content/canvas/src/WebGLContextUtils.h | 3 + content/canvas/src/WebGLFramebuffer.cpp | 113 ++++++++++++++------- content/canvas/src/WebGLTexelConversions.h | 27 +++++ content/canvas/src/WebGLTexture.cpp | 3 +- 6 files changed, 191 insertions(+), 86 deletions(-) diff --git a/content/canvas/src/WebGLContextGL.cpp b/content/canvas/src/WebGLContextGL.cpp index 0a5b4108c5b..457902904f5 100644 --- a/content/canvas/src/WebGLContextGL.cpp +++ b/content/canvas/src/WebGLContextGL.cpp @@ -638,10 +638,10 @@ WebGLContext::CopyTexSubImage2D(GLenum target, if (yoffset + height > texHeight || yoffset + height < 0) return ErrorInvalidValue("copyTexSubImage2D: yoffset+height is too large"); - GLenum format = imageInfo.InternalFormat(); - bool texFormatRequiresAlpha = format == LOCAL_GL_RGBA || - format == LOCAL_GL_ALPHA || - format == LOCAL_GL_LUMINANCE_ALPHA; + GLenum internalFormat = imageInfo.InternalFormat(); + bool texFormatRequiresAlpha = (internalFormat == LOCAL_GL_RGBA || + internalFormat == LOCAL_GL_ALPHA || + internalFormat == LOCAL_GL_LUMINANCE_ALPHA); bool fboFormatHasAlpha = mBoundFramebuffer ? mBoundFramebuffer->ColorAttachment(0).HasAlpha() : bool(gl->GetPixelFormat().alpha > 0); @@ -649,9 +649,11 @@ WebGLContext::CopyTexSubImage2D(GLenum target, return ErrorInvalidOperation("copyTexSubImage2D: texture format requires an alpha channel " "but the framebuffer doesn't have one"); - if (format == LOCAL_GL_DEPTH_COMPONENT || - format == LOCAL_GL_DEPTH_STENCIL) + if (IsGLDepthFormat(internalFormat) || + IsGLDepthStencilFormat(internalFormat)) + { return ErrorInvalidOperation("copyTexSubImage2D: a base internal format of DEPTH_COMPONENT or DEPTH_STENCIL isn't supported"); + } if (mBoundFramebuffer) if (!mBoundFramebuffer->CheckAndInitializeAttachments()) @@ -661,7 +663,7 @@ WebGLContext::CopyTexSubImage2D(GLenum target, tex->DoDeferredImageInitialization(target, level); } - return CopyTexSubImage2D_base(target, level, format, xoffset, yoffset, x, y, width, height, true); + return CopyTexSubImage2D_base(target, level, internalFormat, xoffset, yoffset, x, y, width, height, true); } @@ -1182,15 +1184,17 @@ WebGLContext::GenerateMipmap(GLenum target) if (!tex->IsFirstImagePowerOfTwo()) return ErrorInvalidOperation("generateMipmap: Level zero of texture does not have power-of-two width and height."); - GLenum format = tex->ImageInfoAt(imageTarget, 0).InternalFormat(); - if (IsTextureFormatCompressed(format)) + GLenum internalFormat = tex->ImageInfoAt(imageTarget, 0).InternalFormat(); + if (IsTextureFormatCompressed(internalFormat)) return ErrorInvalidOperation("generateMipmap: Texture data at level zero is compressed."); if (IsExtensionEnabled(WEBGL_depth_texture) && - (format == LOCAL_GL_DEPTH_COMPONENT || format == LOCAL_GL_DEPTH_STENCIL)) + (IsGLDepthFormat(internalFormat) || IsGLDepthStencilFormat(internalFormat))) + { return ErrorInvalidOperation("generateMipmap: " "A texture that has a base internal format of " "DEPTH_COMPONENT or DEPTH_STENCIL isn't supported"); + } if (!tex->AreAllLevel0ImageInfosEqual()) return ErrorInvalidOperation("generateMipmap: The six faces of this cube map have different dimensions, format, or type."); @@ -4125,31 +4129,44 @@ BaseTypeAndSizeFromUniformType(GLenum uType, GLenum *baseType, GLint *unitSize) } -WebGLTexelFormat mozilla::GetWebGLTexelFormat(GLenum format, GLenum type) +WebGLTexelFormat mozilla::GetWebGLTexelFormat(GLenum internalformat, GLenum type) { // // WEBGL_depth_texture - if (format == LOCAL_GL_DEPTH_COMPONENT) { + if (internalformat == LOCAL_GL_DEPTH_COMPONENT) { switch (type) { case LOCAL_GL_UNSIGNED_SHORT: return WebGLTexelFormat::D16; case LOCAL_GL_UNSIGNED_INT: return WebGLTexelFormat::D32; - default: - MOZ_CRASH("Invalid WebGL texture format/type?"); } - } else if (format == LOCAL_GL_DEPTH_STENCIL) { + + MOZ_CRASH("Invalid WebGL texture format/type?"); + } + + if (internalformat == LOCAL_GL_DEPTH_STENCIL) { switch (type) { case LOCAL_GL_UNSIGNED_INT_24_8_EXT: return WebGLTexelFormat::D24S8; - default: - MOZ_CRASH("Invalid WebGL texture format/type?"); } + + MOZ_CRASH("Invalid WebGL texture format/type?"); } + if (internalformat == LOCAL_GL_DEPTH_COMPONENT16) { + return WebGLTexelFormat::D16; + } + + if (internalformat == LOCAL_GL_DEPTH_COMPONENT32) { + return WebGLTexelFormat::D32; + } + + if (internalformat == LOCAL_GL_DEPTH24_STENCIL8) { + return WebGLTexelFormat::D24S8; + } if (type == LOCAL_GL_UNSIGNED_BYTE) { - switch (format) { + switch (internalformat) { case LOCAL_GL_RGBA: case LOCAL_GL_SRGB_ALPHA_EXT: return WebGLTexelFormat::RGBA8; @@ -4162,14 +4179,16 @@ WebGLTexelFormat mozilla::GetWebGLTexelFormat(GLenum format, GLenum type) return WebGLTexelFormat::R8; case LOCAL_GL_LUMINANCE_ALPHA: return WebGLTexelFormat::RA8; - default: - MOZ_ASSERT(false, "Coding mistake?! Should never reach this point."); - return WebGLTexelFormat::BadFormat; } - } else if (type == LOCAL_GL_FLOAT) { + + MOZ_CRASH("Invalid WebGL texture format/type?"); + } + + if (type == LOCAL_GL_FLOAT) { // OES_texture_float - switch (format) { + switch (internalformat) { case LOCAL_GL_RGBA: + case LOCAL_GL_RGBA32F: return WebGLTexelFormat::RGBA32F; case LOCAL_GL_RGB: return WebGLTexelFormat::RGB32F; @@ -4179,23 +4198,24 @@ WebGLTexelFormat mozilla::GetWebGLTexelFormat(GLenum format, GLenum type) return WebGLTexelFormat::R32F; case LOCAL_GL_LUMINANCE_ALPHA: return WebGLTexelFormat::RA32F; - default: - MOZ_ASSERT(false, "Coding mistake?! Should never reach this point."); - return WebGLTexelFormat::BadFormat; - } - } else { - switch (type) { - case LOCAL_GL_UNSIGNED_SHORT_4_4_4_4: - return WebGLTexelFormat::RGBA4444; - case LOCAL_GL_UNSIGNED_SHORT_5_5_5_1: - return WebGLTexelFormat::RGBA5551; - case LOCAL_GL_UNSIGNED_SHORT_5_6_5: - return WebGLTexelFormat::RGB565; - default: - MOZ_ASSERT(false, "Coding mistake?! Should never reach this point."); - return WebGLTexelFormat::BadFormat; } + + MOZ_CRASH("Invalid WebGL texture format/type?"); } + + switch (type) { + case LOCAL_GL_UNSIGNED_SHORT_4_4_4_4: + return WebGLTexelFormat::RGBA4444; + case LOCAL_GL_UNSIGNED_SHORT_5_5_5_1: + return WebGLTexelFormat::RGBA5551; + case LOCAL_GL_UNSIGNED_SHORT_5_6_5: + return WebGLTexelFormat::RGB565; + default: + MOZ_ASSERT(false, "Coding mistake?! Should never reach this point."); + return WebGLTexelFormat::BadFormat; + } + + MOZ_CRASH("Invalid WebGL texture format/type?"); } GLenum diff --git a/content/canvas/src/WebGLContextUtils.cpp b/content/canvas/src/WebGLContextUtils.cpp index 32dcc8abfd3..43ad3541fdc 100644 --- a/content/canvas/src/WebGLContextUtils.cpp +++ b/content/canvas/src/WebGLContextUtils.cpp @@ -23,6 +23,25 @@ using namespace mozilla; +namespace mozilla { + +bool +IsGLDepthFormat(GLenum internalFormat) +{ + return (internalFormat == LOCAL_GL_DEPTH_COMPONENT || + internalFormat == LOCAL_GL_DEPTH_COMPONENT16 || + internalFormat == LOCAL_GL_DEPTH_COMPONENT32); +} + +bool +IsGLDepthStencilFormat(GLenum internalFormat) +{ + return (internalFormat == LOCAL_GL_DEPTH_STENCIL || + internalFormat == LOCAL_GL_DEPTH24_STENCIL8); +} + +} // namespace mozilla + void WebGLContext::GenerateWarning(const char *fmt, ...) { @@ -197,16 +216,7 @@ WebGLContext::ErrorName(GLenum error) bool WebGLContext::IsTextureFormatCompressed(GLenum format) { - switch(format) { - case LOCAL_GL_RGB: - case LOCAL_GL_RGBA: - case LOCAL_GL_ALPHA: - case LOCAL_GL_LUMINANCE: - case LOCAL_GL_LUMINANCE_ALPHA: - case LOCAL_GL_DEPTH_COMPONENT: - case LOCAL_GL_DEPTH_STENCIL: - return false; - + switch (format) { case LOCAL_GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: @@ -219,10 +229,9 @@ WebGLContext::IsTextureFormatCompressed(GLenum format) case LOCAL_GL_COMPRESSED_RGBA_PVRTC_4BPPV1: case LOCAL_GL_COMPRESSED_RGBA_PVRTC_2BPPV1: return true; + default: + return false; } - - MOZ_ASSERT(false, "Invalid WebGL texture format?"); - return false; } void diff --git a/content/canvas/src/WebGLContextUtils.h b/content/canvas/src/WebGLContextUtils.h index 26c96a93bd1..0bdf6d65fed 100644 --- a/content/canvas/src/WebGLContextUtils.h +++ b/content/canvas/src/WebGLContextUtils.h @@ -12,6 +12,9 @@ namespace mozilla { +bool IsGLDepthFormat(GLenum internalFormat); +bool IsGLDepthStencilFormat(GLenum internalFormat); + template JS::Value WebGLContext::WebGLObjectAsJSValue(JSContext *cx, const WebGLObjectType *object, ErrorResult& rv) const diff --git a/content/canvas/src/WebGLFramebuffer.cpp b/content/canvas/src/WebGLFramebuffer.cpp index 6f3f9bea257..22343c9ed31 100644 --- a/content/canvas/src/WebGLFramebuffer.cpp +++ b/content/canvas/src/WebGLFramebuffer.cpp @@ -128,24 +128,63 @@ WebGLFramebuffer::Attachment::RectangleObject() const } static inline bool -IsValidAttachedTextureColorFormat(GLenum format) +IsValidFBOTextureColorFormat(GLenum internalFormat) { return ( /* linear 8-bit formats */ - format == LOCAL_GL_ALPHA || - format == LOCAL_GL_LUMINANCE || - format == LOCAL_GL_LUMINANCE_ALPHA || - format == LOCAL_GL_RGB || - format == LOCAL_GL_RGBA || + internalFormat == LOCAL_GL_ALPHA || + internalFormat == LOCAL_GL_LUMINANCE || + internalFormat == LOCAL_GL_LUMINANCE_ALPHA || + internalFormat == LOCAL_GL_RGB || + internalFormat == LOCAL_GL_RGBA || /* sRGB 8-bit formats */ - format == LOCAL_GL_SRGB_EXT || - format == LOCAL_GL_SRGB_ALPHA_EXT || + internalFormat == LOCAL_GL_SRGB_EXT || + internalFormat == LOCAL_GL_SRGB_ALPHA_EXT || /* linear float32 formats */ - format == LOCAL_GL_ALPHA32F_ARB || - format == LOCAL_GL_LUMINANCE32F_ARB || - format == LOCAL_GL_LUMINANCE_ALPHA32F_ARB || - format == LOCAL_GL_RGB32F_ARB || - format == LOCAL_GL_RGBA32F_ARB); + internalFormat == LOCAL_GL_ALPHA32F_ARB || + internalFormat == LOCAL_GL_LUMINANCE32F_ARB || + internalFormat == LOCAL_GL_LUMINANCE_ALPHA32F_ARB || + internalFormat == LOCAL_GL_RGB32F_ARB || + internalFormat == LOCAL_GL_RGBA32F_ARB); +} + +static inline bool +IsValidFBOTextureDepthFormat(GLenum internalFormat) { + return ( + internalFormat == LOCAL_GL_DEPTH_COMPONENT || + internalFormat == LOCAL_GL_DEPTH_COMPONENT16 || + internalFormat == LOCAL_GL_DEPTH_COMPONENT32); +} + +static inline bool +IsValidFBOTextureDepthStencilFormat(GLenum internalFormat) { + return ( + internalFormat == LOCAL_GL_DEPTH_STENCIL || + internalFormat == LOCAL_GL_DEPTH24_STENCIL8); +} + +static inline bool +IsValidFBORenderbufferColorFormat(GLenum internalFormat) { + return ( + internalFormat == LOCAL_GL_RGB565 || + internalFormat == LOCAL_GL_RGB5_A1 || + internalFormat == LOCAL_GL_RGBA4 || + internalFormat == LOCAL_GL_SRGB8_ALPHA8_EXT); +} + +static inline bool +IsValidFBORenderbufferDepthFormat(GLenum internalFormat) { + return internalFormat == LOCAL_GL_DEPTH_COMPONENT16; +} + +static inline bool +IsValidFBORenderbufferDepthStencilFormat(GLenum internalFormat) { + return internalFormat == LOCAL_GL_DEPTH24_STENCIL8; +} + +static inline bool +IsValidFBORenderbufferStencilFormat(GLenum internalFormat) { + return internalFormat == LOCAL_GL_STENCIL_INDEX8; } bool @@ -164,37 +203,43 @@ WebGLFramebuffer::Attachment::IsComplete() const if (mTexturePtr) { MOZ_ASSERT(mTexturePtr->HasImageInfoAt(mTexImageTarget, mTexImageLevel)); - GLenum format = mTexturePtr->ImageInfoAt(mTexImageTarget, mTexImageLevel).InternalFormat(); + const WebGLTexture::ImageInfo& imageInfo = + mTexturePtr->ImageInfoAt(mTexImageTarget, mTexImageLevel); + GLenum internalFormat = imageInfo.InternalFormat(); - if (mAttachmentPoint == LOCAL_GL_DEPTH_ATTACHMENT) { - return format == LOCAL_GL_DEPTH_COMPONENT; - } else if (mAttachmentPoint == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) { - return format == LOCAL_GL_DEPTH_STENCIL; - } else if (mAttachmentPoint >= LOCAL_GL_COLOR_ATTACHMENT0 && - mAttachmentPoint < GLenum(LOCAL_GL_COLOR_ATTACHMENT0 + WebGLContext::sMaxColorAttachments)) + if (mAttachmentPoint == LOCAL_GL_DEPTH_ATTACHMENT) + return IsValidFBOTextureDepthFormat(internalFormat); + + if (mAttachmentPoint == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) + return IsValidFBOTextureDepthStencilFormat(internalFormat); + + if (mAttachmentPoint >= LOCAL_GL_COLOR_ATTACHMENT0 && + mAttachmentPoint < GLenum(LOCAL_GL_COLOR_ATTACHMENT0 + + WebGLContext::sMaxColorAttachments)) { - return IsValidAttachedTextureColorFormat(format); + return IsValidFBOTextureColorFormat(internalFormat); } MOZ_ASSERT(false, "Invalid WebGL attachment point?"); return false; } if (mRenderbufferPtr) { - GLenum format = mRenderbufferPtr->InternalFormat(); + GLenum internalFormat = mRenderbufferPtr->InternalFormat(); - if (mAttachmentPoint == LOCAL_GL_DEPTH_ATTACHMENT) { - return format == LOCAL_GL_DEPTH_COMPONENT16; - } else if (mAttachmentPoint == LOCAL_GL_STENCIL_ATTACHMENT) { - return format == LOCAL_GL_STENCIL_INDEX8; - } else if (mAttachmentPoint == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) { - return format == LOCAL_GL_DEPTH_STENCIL; - } else if (mAttachmentPoint >= LOCAL_GL_COLOR_ATTACHMENT0 && - mAttachmentPoint < GLenum(LOCAL_GL_COLOR_ATTACHMENT0 + WebGLContext::sMaxColorAttachments)) + if (mAttachmentPoint == LOCAL_GL_DEPTH_ATTACHMENT) + return IsValidFBORenderbufferDepthFormat(internalFormat); + + if (mAttachmentPoint == LOCAL_GL_STENCIL_ATTACHMENT) + return IsValidFBORenderbufferStencilFormat(internalFormat); + + if (mAttachmentPoint == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) + return IsValidFBORenderbufferDepthStencilFormat(internalFormat); + + if (mAttachmentPoint >= LOCAL_GL_COLOR_ATTACHMENT0 && + mAttachmentPoint < GLenum(LOCAL_GL_COLOR_ATTACHMENT0 + + WebGLContext::sMaxColorAttachments)) { - return format == LOCAL_GL_RGB565 || - format == LOCAL_GL_RGB5_A1 || - format == LOCAL_GL_RGBA4 || - format == LOCAL_GL_SRGB8_ALPHA8_EXT; + return IsValidFBORenderbufferColorFormat(internalFormat); } MOZ_ASSERT(false, "Invalid WebGL attachment point?"); return false; diff --git a/content/canvas/src/WebGLTexelConversions.h b/content/canvas/src/WebGLTexelConversions.h index 85e49624d06..df8f808bd6d 100644 --- a/content/canvas/src/WebGLTexelConversions.h +++ b/content/canvas/src/WebGLTexelConversions.h @@ -95,6 +95,33 @@ struct IntermediateFormat : WebGLTexelFormat::RGBA8; }; +inline GLenum +GLFormatForTexelFormat(WebGLTexelFormat format) { + switch (format) { + case WebGLTexelFormat::R8: return LOCAL_GL_LUMINANCE; + case WebGLTexelFormat::A8: return LOCAL_GL_ALPHA; + case WebGLTexelFormat::RA8: return LOCAL_GL_LUMINANCE_ALPHA; + case WebGLTexelFormat::RGBA5551: return LOCAL_GL_RGBA; + case WebGLTexelFormat::RGBA4444: return LOCAL_GL_RGBA; + case WebGLTexelFormat::RGB565: return LOCAL_GL_RGB; + case WebGLTexelFormat::D16: return LOCAL_GL_DEPTH_COMPONENT; + case WebGLTexelFormat::RGB8: return LOCAL_GL_RGB; + case WebGLTexelFormat::RGBA8: return LOCAL_GL_RGBA; + case WebGLTexelFormat::BGRA8: return LOCAL_GL_BGRA; + case WebGLTexelFormat::BGRX8: return LOCAL_GL_BGR; + case WebGLTexelFormat::R32F: return LOCAL_GL_LUMINANCE; + case WebGLTexelFormat::A32F: return LOCAL_GL_ALPHA; + case WebGLTexelFormat::D32: return LOCAL_GL_DEPTH_COMPONENT; + case WebGLTexelFormat::D24S8: return LOCAL_GL_DEPTH_STENCIL; + case WebGLTexelFormat::RA32F: return LOCAL_GL_LUMINANCE_ALPHA; + case WebGLTexelFormat::RGB32F: return LOCAL_GL_RGB; + case WebGLTexelFormat::RGBA32F: return LOCAL_GL_RGBA; + default: + MOZ_CRASH("Unknown texel format. Coding mistake?"); + return LOCAL_GL_INVALID_ENUM; + } +} + inline size_t TexelBytesForFormat(WebGLTexelFormat format) { switch (format) { case WebGLTexelFormat::R8: diff --git a/content/canvas/src/WebGLTexture.cpp b/content/canvas/src/WebGLTexture.cpp index 35a592c4ebc..76a784e7674 100644 --- a/content/canvas/src/WebGLTexture.cpp +++ b/content/canvas/src/WebGLTexture.cpp @@ -430,10 +430,11 @@ WebGLTexture::DoDeferredImageInitialization(GLenum imageTarget, GLint level) MOZ_ASSERT(checked_byteLength.isValid()); // should have been checked earlier void *zeros = calloc(1, checked_byteLength.value()); + GLenum format = WebGLTexelConversions::GLFormatForTexelFormat(texelformat); mContext->UpdateWebGLErrorAndClearGLError(); mContext->gl->fTexImage2D(imageTarget, level, imageInfo.mInternalFormat, imageInfo.mWidth, imageInfo.mHeight, - 0, imageInfo.mInternalFormat, imageInfo.mType, + 0, format, imageInfo.mType, zeros); GLenum error = LOCAL_GL_NO_ERROR; mContext->UpdateWebGLErrorAndClearGLError(&error); From 3f1115ce416167451cabf10f591b57bd97148ff2 Mon Sep 17 00:00:00 2001 From: Dan Glastonbury Date: Fri, 24 Jan 2014 16:28:47 +1000 Subject: [PATCH 041/296] Bug 948002 - Add extra comments of meaning of GLenum to IsValidFBOXXX calls. r=jgilbert --- content/canvas/src/WebGLFramebuffer.cpp | 27 ++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/content/canvas/src/WebGLFramebuffer.cpp b/content/canvas/src/WebGLFramebuffer.cpp index 22343c9ed31..e0b4ae2d934 100644 --- a/content/canvas/src/WebGLFramebuffer.cpp +++ b/content/canvas/src/WebGLFramebuffer.cpp @@ -127,6 +127,10 @@ WebGLFramebuffer::Attachment::RectangleObject() const MOZ_CRASH("Should not get here."); } +/* The following IsValidFBOTextureXXX functions check the internal + format that is used by GL or GL ES texture formats. This + corresponds to the state that is stored in + WebGLTexture::ImageInfo::InternalFormat()*/ static inline bool IsValidFBOTextureColorFormat(GLenum internalFormat) { @@ -149,7 +153,8 @@ IsValidFBOTextureColorFormat(GLenum internalFormat) } static inline bool -IsValidFBOTextureDepthFormat(GLenum internalFormat) { +IsValidFBOTextureDepthFormat(GLenum internalFormat) +{ return ( internalFormat == LOCAL_GL_DEPTH_COMPONENT || internalFormat == LOCAL_GL_DEPTH_COMPONENT16 || @@ -157,14 +162,19 @@ IsValidFBOTextureDepthFormat(GLenum internalFormat) { } static inline bool -IsValidFBOTextureDepthStencilFormat(GLenum internalFormat) { +IsValidFBOTextureDepthStencilFormat(GLenum internalFormat) +{ return ( internalFormat == LOCAL_GL_DEPTH_STENCIL || internalFormat == LOCAL_GL_DEPTH24_STENCIL8); } +/* The following IsValidFBORenderbufferXXX functions check the internal + format that is stored by WebGLRenderbuffer::InternalFormat(). Valid + values can be found in WebGLContext::RenderbufferStorage. */ static inline bool -IsValidFBORenderbufferColorFormat(GLenum internalFormat) { +IsValidFBORenderbufferColorFormat(GLenum internalFormat) +{ return ( internalFormat == LOCAL_GL_RGB565 || internalFormat == LOCAL_GL_RGB5_A1 || @@ -173,17 +183,20 @@ IsValidFBORenderbufferColorFormat(GLenum internalFormat) { } static inline bool -IsValidFBORenderbufferDepthFormat(GLenum internalFormat) { +IsValidFBORenderbufferDepthFormat(GLenum internalFormat) +{ return internalFormat == LOCAL_GL_DEPTH_COMPONENT16; } static inline bool -IsValidFBORenderbufferDepthStencilFormat(GLenum internalFormat) { - return internalFormat == LOCAL_GL_DEPTH24_STENCIL8; +IsValidFBORenderbufferDepthStencilFormat(GLenum internalFormat) +{ + return internalFormat == LOCAL_GL_DEPTH_STENCIL; } static inline bool -IsValidFBORenderbufferStencilFormat(GLenum internalFormat) { +IsValidFBORenderbufferStencilFormat(GLenum internalFormat) +{ return internalFormat == LOCAL_GL_STENCIL_INDEX8; } From b1e9ad70758a4bc23701ba4bd510d0364e88fd5a Mon Sep 17 00:00:00 2001 From: Ted Clancy Date: Mon, 27 Jan 2014 19:37:05 -0500 Subject: [PATCH 042/296] Bug 958359 - IndexedDB should log a message to the console when it returns NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR. r=bent --- dom/indexedDB/AsyncConnectionHelper.cpp | 16 +- dom/indexedDB/IDBCursor.cpp | 22 +-- dom/indexedDB/IDBDatabase.cpp | 51 +++--- dom/indexedDB/IDBFactory.cpp | 22 +-- dom/indexedDB/IDBIndex.cpp | 107 +++++------ dom/indexedDB/IDBObjectStore.cpp | 228 ++++++++++++------------ dom/indexedDB/IDBRequest.cpp | 3 +- dom/indexedDB/IDBTransaction.cpp | 11 +- dom/indexedDB/Key.cpp | 10 +- dom/indexedDB/KeyPath.cpp | 18 +- dom/indexedDB/OpenDatabaseHelper.cpp | 90 +++++----- dom/indexedDB/ReportInternalError.cpp | 32 ++++ dom/indexedDB/ReportInternalError.h | 51 ++++++ dom/indexedDB/moz.build | 1 + 14 files changed, 395 insertions(+), 267 deletions(-) create mode 100644 dom/indexedDB/ReportInternalError.cpp create mode 100644 dom/indexedDB/ReportInternalError.h diff --git a/dom/indexedDB/AsyncConnectionHelper.cpp b/dom/indexedDB/AsyncConnectionHelper.cpp index 216913fff21..0896b2ab7b1 100644 --- a/dom/indexedDB/AsyncConnectionHelper.cpp +++ b/dom/indexedDB/AsyncConnectionHelper.cpp @@ -20,6 +20,7 @@ #include "IDBTransaction.h" #include "IndexedDatabaseManager.h" #include "ProfilerHelpers.h" +#include "ReportInternalError.h" #include "TransactionThreadPool.h" #include "ipc/IndexedDBChild.h" @@ -59,13 +60,13 @@ ConvertCloneReadInfosToArrayInternal( { JS::Rooted array(aCx, JS_NewArrayObject(aCx, 0, nullptr)); if (!array) { - NS_WARNING("Failed to make array!"); + IDB_WARNING("Failed to make array!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } if (!aReadInfos.IsEmpty()) { if (!JS_SetArrayLength(aCx, array, uint32_t(aReadInfos.Length()))) { - NS_WARNING("Failed to set array length!"); + IDB_WARNING("Failed to set array length!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -80,7 +81,7 @@ ConvertCloneReadInfosToArrayInternal( } if (!JS_SetElement(aCx, array, index, val)) { - NS_WARNING("Failed to set array element!"); + IDB_WARNING("Failed to set array element!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } } @@ -126,7 +127,7 @@ HelperBase::WrapNative(JSContext* aCx, nsresult rv = nsContentUtils::WrapNative(aCx, global, aNative, aResult); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return NS_OK; } @@ -246,7 +247,7 @@ AsyncConnectionHelper::Run() } case Error: { - NS_WARNING("MaybeSendResultsToChildProcess failed!"); + IDB_WARNING("MaybeSendResultsToChildProcess failed!"); mResultCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; if (mRequest) { mRequest->NotifyHelperSentResultsToChildProcess(mResultCode); @@ -341,6 +342,7 @@ AsyncConnectionHelper::Run() mResultCode = NS_ERROR_DOM_INDEXEDDB_RECOVERABLE_ERR; } else { + IDB_REPORT_INTERNAL_ERR(); mResultCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } } @@ -459,13 +461,13 @@ AsyncConnectionHelper::OnSuccess() nsRefPtr event = CreateSuccessEvent(mRequest); if (!event) { - NS_ERROR("Failed to create event!"); + IDB_WARNING("Failed to create event!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } bool dummy; nsresult rv = mRequest->DispatchEvent(event, &dummy); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); WidgetEvent* internalEvent = event->GetInternalNSEvent(); NS_ASSERTION(internalEvent, "This should never be null!"); diff --git a/dom/indexedDB/IDBCursor.cpp b/dom/indexedDB/IDBCursor.cpp index 304d270e9e0..8f2a395cc5d 100644 --- a/dom/indexedDB/IDBCursor.cpp +++ b/dom/indexedDB/IDBCursor.cpp @@ -20,6 +20,7 @@ #include "IDBObjectStore.h" #include "IDBTransaction.h" #include "ProfilerHelpers.h" +#include "ReportInternalError.h" #include "TransactionThreadPool.h" #include "ipc/IndexedDBChild.h" @@ -497,7 +498,7 @@ IDBCursor::ContinueInternal(const Key& aKey, int32_t aCount, ErrorResult& aRv) nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return; } @@ -998,6 +999,7 @@ CursorHelper::Dispatch(nsIEventTarget* aDatabaseThread) // If we've been invalidated then there's no point sending anything to the // parent process. if (mCursor->Transaction()->Database()->IsInvalidated()) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -1006,11 +1008,11 @@ CursorHelper::Dispatch(nsIEventTarget* aDatabaseThread) CursorRequestParams params; nsresult rv = PackArgumentsForParentProcess(params); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); NoDispatchEventTarget target; rv = AsyncConnectionHelper::Dispatch(&target); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mActor = new IndexedDBCursorRequestChild(this, mCursor, params.type()); cursorActor->SendPIndexedDBRequestConstructor(mActor, params); @@ -1046,19 +1048,19 @@ ContinueHelper::DoDatabaseWork(mozIStorageConnection* aConnection) query.AppendInt(mCount); nsCOMPtr stmt = mTransaction->GetCachedStatement(query); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = BindArgumentsToStatement(stmt); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); NS_ASSERTION(mCount > 0, "Not ok!"); bool hasResult; for (int32_t index = 0; index < mCount; index++) { rv = stmt->ExecuteStep(&hasResult); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (!hasResult) { break; @@ -1067,7 +1069,7 @@ ContinueHelper::DoDatabaseWork(mozIStorageConnection* aConnection) if (hasResult) { rv = GatherResultsFromStatement(stmt); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } else { mKey.Unset(); @@ -1193,7 +1195,7 @@ ContinueHelper::UnpackResponseFromParentProcess( "Inconsistent clone info!"); if (!mCloneReadInfo.SetFromSerialized(cloneInfo)) { - NS_WARNING("Failed to copy clone buffer!"); + IDB_WARNING("Failed to copy clone buffer!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -1212,7 +1214,7 @@ ContinueObjectStoreHelper::BindArgumentsToStatement( // Bind object store id. nsresult rv = aStatement->BindInt64ByName(NS_LITERAL_CSTRING("id"), mCursor->mObjectStore->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); NS_NAMED_LITERAL_CSTRING(currentKeyName, "current_key"); NS_NAMED_LITERAL_CSTRING(rangeKeyName, "range_key"); @@ -1274,7 +1276,7 @@ ContinueIndexHelper::BindArgumentsToStatement(mozIStorageStatement* aStatement) // Bind index id. nsresult rv = aStatement->BindInt64ByName(NS_LITERAL_CSTRING("id"), mCursor->mIndex->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); NS_NAMED_LITERAL_CSTRING(currentKeyName, "current_key"); diff --git a/dom/indexedDB/IDBDatabase.cpp b/dom/indexedDB/IDBDatabase.cpp index 19579b9046f..0a7c98bb396 100644 --- a/dom/indexedDB/IDBDatabase.cpp +++ b/dom/indexedDB/IDBDatabase.cpp @@ -29,6 +29,7 @@ #include "IDBTransaction.h" #include "IDBFactory.h" #include "ProfilerHelpers.h" +#include "ReportInternalError.h" #include "TransactionThreadPool.h" #include "ipc/IndexedDBChild.h" @@ -418,7 +419,7 @@ IDBDatabase::CreateObjectStoreInternal(IDBTransaction* aTransaction, newInfo->comittedAutoIncrementId = newInfo->nextAutoIncrementId; if (!databaseInfo->PutObjectStore(newInfo)) { - NS_WARNING("Put failed!"); + IDB_WARNING("Put failed!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -429,7 +430,7 @@ IDBDatabase::CreateObjectStoreInternal(IDBTransaction* aTransaction, nsRefPtr objectStore = aTransaction->GetOrCreateObjectStore(newInfo->name, newInfo, true); if (!objectStore) { - NS_WARNING("Failed to get objectStore!"); + IDB_WARNING("Failed to get objectStore!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -440,7 +441,7 @@ IDBDatabase::CreateObjectStoreInternal(IDBTransaction* aTransaction, nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -502,7 +503,7 @@ IDBDatabase::GetObjectStoreNames(ErrorResult& aRv) const nsAutoTArray objectStoreNames; if (!info->GetObjectStoreNames(objectStoreNames)) { - NS_WARNING("Couldn't get names!"); + IDB_WARNING("Couldn't get names!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -511,7 +512,7 @@ IDBDatabase::GetObjectStoreNames(ErrorResult& aRv) const uint32_t count = objectStoreNames.Length(); for (uint32_t index = 0; index < count; index++) { if (!list->Add(objectStoreNames[index])) { - NS_WARNING("Failed to add element"); + IDB_WARNING("Failed to add element"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -590,7 +591,7 @@ IDBDatabase::DeleteObjectStore(const nsAString& aName, ErrorResult& aRv) nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return; } @@ -619,6 +620,7 @@ IDBDatabase::Transaction(const Sequence& aStoreNames, NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); if (QuotaManager::IsShuttingDown()) { + IDB_REPORT_INTERNAL_ERR(); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -665,7 +667,7 @@ IDBDatabase::Transaction(const Sequence& aStoreNames, nsRefPtr transaction = IDBTransaction::Create(this, aStoreNames, transactionMode, false); if (!transaction) { - NS_WARNING("Failed to create the transaction!"); + IDB_WARNING("Failed to create the transaction!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -686,12 +688,13 @@ IDBDatabase::MozCreateFileHandle(const nsAString& aName, NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); if (!IndexedDatabaseManager::IsMainProcess()) { - NS_WARNING("Not supported yet!"); + IDB_WARNING("Not supported yet!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } if (QuotaManager::IsShuttingDown()) { + IDB_REPORT_INTERNAL_ERR(); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -712,7 +715,7 @@ IDBDatabase::MozCreateFileHandle(const nsAString& aName, nsresult rv = helper->Dispatch(quotaManager->IOThread()); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -834,20 +837,20 @@ CreateObjectStoreHelper::DoDatabaseWork(mozIStorageConnection* aConnection) "INSERT INTO object_store (id, auto_increment, name, key_path) " "VALUES (:id, :auto_increment, :name, :key_path)" )); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mObjectStore->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("auto_increment"), mObjectStore->IsAutoIncrement() ? 1 : 0); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = stmt->BindStringByName(NS_LITERAL_CSTRING("name"), mObjectStore->Name()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); const KeyPath& keyPath = mObjectStore->GetKeyPath(); if (keyPath.IsValid()) { @@ -855,15 +858,15 @@ CreateObjectStoreHelper::DoDatabaseWork(mozIStorageConnection* aConnection) keyPath.SerializeToString(keyPathSerialization); rv = stmt->BindStringByName(NS_LITERAL_CSTRING("key_path"), keyPathSerialization); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } else { rv = stmt->BindNullByName(NS_LITERAL_CSTRING("key_path")); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } rv = stmt->Execute(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return NS_OK; } @@ -888,15 +891,15 @@ DeleteObjectStoreHelper::DoDatabaseWork(mozIStorageConnection* aConnection) "DELETE FROM object_store " "WHERE id = :id " )); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mObjectStoreId); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = stmt->Execute(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return NS_OK; } @@ -917,7 +920,7 @@ CreateFileHelper::DoDatabaseWork(mozIStorageConnection* aConnection) FileManager* fileManager = mDatabase->Manager(); mFileInfo = fileManager->GetNewFileInfo(); - NS_ENSURE_TRUE(mFileInfo, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(mFileInfo, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); const int64_t& fileId = mFileInfo->Id(); @@ -931,13 +934,13 @@ CreateFileHelper::DoDatabaseWork(mozIStorageConnection* aConnection) NS_ENSURE_SUCCESS(rv, rv); directory = fileManager->GetDirectory(); - NS_ENSURE_TRUE(directory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(directory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); file = fileManager->GetFileForId(directory, fileId); - NS_ENSURE_TRUE(file, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(file, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = file->Create(nsIFile::NORMAL_FILE_TYPE, 0644); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return NS_OK; } @@ -948,7 +951,7 @@ CreateFileHelper::GetSuccessResult(JSContext* aCx, { nsRefPtr fileHandle = IDBFileHandle::Create(mDatabase, mName, mType, mFileInfo.forget()); - NS_ENSURE_TRUE(fileHandle, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(fileHandle, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return WrapNative(aCx, NS_ISUPPORTS_CAST(nsIDOMFileHandle*, fileHandle), aVal); diff --git a/dom/indexedDB/IDBFactory.cpp b/dom/indexedDB/IDBFactory.cpp index 46e784420fc..eb1cb8058a7 100644 --- a/dom/indexedDB/IDBFactory.cpp +++ b/dom/indexedDB/IDBFactory.cpp @@ -44,6 +44,7 @@ #include "IndexedDatabaseManager.h" #include "Key.h" #include "ProfilerHelpers.h" +#include "ReportInternalError.h" #include "nsNetUtil.h" #include "ipc/IndexedDBChild.h" @@ -109,18 +110,18 @@ IDBFactory::Create(nsPIDOMWindow* aWindow, NS_ASSERTION(aASCIIOrigin.IsEmpty() || nsContentUtils::IsCallerChrome(), "Non-chrome may not supply their own origin!"); - NS_ENSURE_TRUE(aWindow, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(aWindow, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (aWindow->IsOuterWindow()) { aWindow = aWindow->GetCurrentInnerWindow(); - NS_ENSURE_TRUE(aWindow, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(aWindow, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } // Make sure that the manager is up before we do anything here since lots of // decisions depend on which process we're running in. indexedDB::IndexedDatabaseManager* mgr = indexedDB::IndexedDatabaseManager::GetOrCreate(); - NS_ENSURE_TRUE(mgr, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(mgr, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsresult rv; @@ -154,7 +155,7 @@ IDBFactory::Create(nsPIDOMWindow* aWindow, if (!IndexedDatabaseManager::IsMainProcess()) { TabChild* tabChild = TabChild::GetFrom(aWindow); - NS_ENSURE_TRUE(tabChild, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(tabChild, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); IndexedDBChild* actor = new IndexedDBChild(origin); @@ -191,7 +192,7 @@ IDBFactory::Create(JSContext* aCx, // Make sure that the manager is up before we do anything here since lots of // decisions depend on which process we're running in. IndexedDatabaseManager* mgr = IndexedDatabaseManager::GetOrCreate(); - NS_ENSURE_TRUE(mgr, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(mgr, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsCString group; nsCString origin; @@ -213,7 +214,7 @@ IDBFactory::Create(JSContext* aCx, if (!IndexedDatabaseManager::IsMainProcess()) { ContentChild* contentChild = ContentChild::GetSingleton(); - NS_ENSURE_TRUE(contentChild, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(contentChild, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); IndexedDBChild* actor = new IndexedDBChild(origin); @@ -372,7 +373,7 @@ IDBFactory::SetDefaultPragmas(mozIStorageConnection* aConnection) "PRAGMA recursive_triggers = ON;"; nsresult rv = aConnection->ExecuteSimpleSQL(NS_LITERAL_CSTRING(query)); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return NS_OK; } @@ -611,7 +612,7 @@ IDBFactory::OpenInternal(const nsAString& aName, nsRefPtr request = IDBOpenDBRequest::Create(this, window, scriptOwner); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsresult rv; @@ -622,7 +623,7 @@ IDBFactory::OpenInternal(const nsAString& aName, aPrivilege); rv = openHelper->Init(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (!Preferences::GetBool(PREF_INDEXEDDB_ENABLED)) { openHelper->SetError(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR); @@ -647,7 +648,7 @@ IDBFactory::OpenInternal(const nsAString& aName, rv = openHelper->WaitForOpenAllowed(); } } - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } else if (aDeleting) { nsCString databaseId; @@ -798,6 +799,7 @@ IDBFactory::Open(nsIPrincipal* aPrincipal, const nsAString& aName, &privilege, &defaultPersistenceType); if (NS_FAILED(rv)) { + IDB_REPORT_INTERNAL_ERR(); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } diff --git a/dom/indexedDB/IDBIndex.cpp b/dom/indexedDB/IDBIndex.cpp index 6cf783982ce..6d3d88f6bd0 100644 --- a/dom/indexedDB/IDBIndex.cpp +++ b/dom/indexedDB/IDBIndex.cpp @@ -25,6 +25,7 @@ #include "IDBObjectStore.h" #include "IDBTransaction.h" #include "ProfilerHelpers.h" +#include "ReportInternalError.h" #include "ipc/IndexedDBChild.h" #include "ipc/IndexedDBParent.h" @@ -438,7 +439,7 @@ IDBIndex::GetInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv) nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -448,7 +449,7 @@ IDBIndex::GetInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv) nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -480,7 +481,7 @@ IDBIndex::GetKeyInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv) nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -490,7 +491,7 @@ IDBIndex::GetKeyInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv) nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -523,7 +524,7 @@ IDBIndex::GetAllInternal(IDBKeyRange* aKeyRange, uint32_t aLimit, nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -533,7 +534,7 @@ IDBIndex::GetAllInternal(IDBKeyRange* aKeyRange, uint32_t aLimit, nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -567,7 +568,7 @@ IDBIndex::GetAllKeysInternal(IDBKeyRange* aKeyRange, uint32_t aLimit, nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -577,7 +578,7 @@ IDBIndex::GetAllKeysInternal(IDBKeyRange* aKeyRange, uint32_t aLimit, nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -610,7 +611,7 @@ IDBIndex::CountInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv) nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -620,7 +621,7 @@ IDBIndex::CountInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv) nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -656,7 +657,7 @@ IDBIndex::OpenKeyCursorInternal(IDBKeyRange* aKeyRange, size_t aDirection, nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -666,7 +667,7 @@ IDBIndex::OpenKeyCursorInternal(IDBKeyRange* aKeyRange, size_t aDirection, nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -702,13 +703,13 @@ IDBIndex::OpenCursorInternal(IDBKeyRange* aKeyRange, static_cast(aDirection); nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsRefPtr helper = new OpenCursorHelper(transaction, request, this, aKeyRange, direction); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); IDB_PROFILER_MARK("IndexedDB Request %llu: " "database(%s).transaction(%s).objectStore(%s).index(%s)." @@ -741,7 +742,7 @@ IDBIndex::OpenCursorFromChildProcess(IDBRequest* aRequest, nsRefPtr cursor = IDBCursor::Create(aRequest, mObjectStore->Transaction(), this, direction, Key(), EmptyCString(), EmptyCString(), aKey, aObjectKey); - NS_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); cursor.forget(_retval); return NS_OK; @@ -768,7 +769,7 @@ IDBIndex::OpenCursorFromChildProcess( StructuredCloneReadInfo cloneInfo; if (!cloneInfo.SetFromSerialized(aCloneInfo)) { - NS_WARNING("Failed to copy clone buffer!"); + IDB_WARNING("Failed to copy clone buffer!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -778,7 +779,7 @@ IDBIndex::OpenCursorFromChildProcess( IDBCursor::Create(aRequest, mObjectStore->Transaction(), this, direction, Key(), EmptyCString(), EmptyCString(), aKey, aObjectKey, cloneInfo); - NS_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); NS_ASSERTION(!cloneInfo.mCloneBuffer.data(), "Should have swapped!"); @@ -969,7 +970,7 @@ IDBIndex::OpenCursor(JSContext* aCx, nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -979,7 +980,7 @@ IDBIndex::OpenCursor(JSContext* aCx, nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -1051,6 +1052,7 @@ IndexHelper::Dispatch(nsIEventTarget* aDatabaseThread) // If we've been invalidated then there's no point sending anything to the // parent process. if (mIndex->ObjectStore()->Transaction()->Database()->IsInvalidated()) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -1059,11 +1061,11 @@ IndexHelper::Dispatch(nsIEventTarget* aDatabaseThread) IndexRequestParams params; nsresult rv = PackArgumentsForParentProcess(params); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); NoDispatchEventTarget target; rv = AsyncConnectionHelper::Dispatch(&target); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mActor = new IndexedDBIndexRequestChild(this, mIndex, params.type()); indexActor->SendPIndexedDBRequestConstructor(mActor, params); @@ -1100,20 +1102,20 @@ GetKeyHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */) NS_LITERAL_CSTRING(" LIMIT 1"); nsCOMPtr stmt = mTransaction->GetCachedStatement(query); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("index_id"), mIndex->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = mKeyRange->BindToStatement(stmt); NS_ENSURE_SUCCESS(rv, rv); bool hasResult; rv = stmt->ExecuteStep(&hasResult); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (hasResult) { rv = mKey.SetFromStatement(stmt, 0); @@ -1226,20 +1228,20 @@ GetHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */) NS_LITERAL_CSTRING(" LIMIT 1"); nsCOMPtr stmt = mTransaction->GetCachedStatement(query); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("index_id"), mIndex->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = mKeyRange->BindToStatement(stmt); NS_ENSURE_SUCCESS(rv, rv); bool hasResult; rv = stmt->ExecuteStep(&hasResult); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (hasResult) { rv = IDBObjectStore::GetStructuredCloneReadInfoFromStatement(stmt, 0, 1, @@ -1355,7 +1357,7 @@ GetHelper::UnpackResponseFromParentProcess(const ResponseValue& aResponseValue) "Inconsistent clone info!"); if (!mCloneReadInfo.SetFromSerialized(cloneInfo)) { - NS_WARNING("Failed to copy clone buffer!"); + IDB_WARNING("Failed to copy clone buffer!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -1398,13 +1400,13 @@ GetAllKeysHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */) keyRangeClause + limitClause; nsCOMPtr stmt = mTransaction->GetCachedStatement(query); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("index_id"), mIndex->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (mKeyRange) { rv = mKeyRange->BindToStatement(stmt); @@ -1425,7 +1427,7 @@ GetAllKeysHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */) rv = key->SetFromStatement(stmt, 0); NS_ENSURE_SUCCESS(rv, rv); } - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return NS_OK; } @@ -1446,13 +1448,13 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx, JS::Rooted array(aCx, JS_NewArrayObject(aCx, 0, nullptr)); if (!array) { - NS_WARNING("Failed to make array!"); + IDB_WARNING("Failed to make array!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } if (!keys.IsEmpty()) { if (!JS_SetArrayLength(aCx, array, uint32_t(keys.Length()))) { - NS_WARNING("Failed to set array length!"); + IDB_WARNING("Failed to set array length!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -1468,7 +1470,7 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx, } if (!JS_SetElement(aCx, array, index, value)) { - NS_WARNING("Failed to set array element!"); + IDB_WARNING("Failed to set array element!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } } @@ -1582,13 +1584,13 @@ GetAllHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */) keyRangeClause + limitClause; nsCOMPtr stmt = mTransaction->GetCachedStatement(query); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("index_id"), mIndex->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (mKeyRange) { rv = mKeyRange->BindToStatement(stmt); @@ -1610,7 +1612,7 @@ GetAllHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */) mDatabase, *readInfo); NS_ENSURE_SUCCESS(rv, rv); } - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return NS_OK; } @@ -1761,7 +1763,7 @@ GetAllHelper::UnpackResponseFromParentProcess( StructuredCloneReadInfo* destInfo = mCloneReadInfos.AppendElement(); if (!destInfo->SetFromSerialized(srcInfo)) { - NS_WARNING("Failed to copy clone buffer!"); + IDB_WARNING("Failed to copy clone buffer!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -1821,13 +1823,13 @@ OpenKeyCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection) nsCOMPtr stmt = mTransaction->GetCachedStatement(firstQuery); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("index_id"), mIndex->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (mKeyRange) { rv = mKeyRange->BindToStatement(stmt); @@ -1836,7 +1838,7 @@ OpenKeyCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection) bool hasResult; rv = stmt->ExecuteStep(&hasResult); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (!hasResult) { mKey.Unset(); @@ -1949,7 +1951,7 @@ OpenKeyCursorHelper::EnsureCursor() nsRefPtr cursor = IDBCursor::Create(mRequest, mTransaction, mIndex, mDirection, mRangeKey, mContinueQuery, mContinueToQuery, mKey, mObjectKey); - NS_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mCursor.swap(cursor); return NS_OK; @@ -1964,7 +1966,7 @@ OpenKeyCursorHelper::GetSuccessResult(JSContext* aCx, if (mCursor) { rv = WrapNative(aCx, mCursor, aVal); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } else { aVal.setUndefined(); @@ -2099,8 +2101,7 @@ OpenKeyCursorHelper::UnpackResponseFromParentProcess( } break; default: - NS_NOTREACHED("Unknown response union type!"); - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; + MOZ_CRASH(); } return NS_OK; @@ -2166,12 +2167,12 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection) nsCOMPtr stmt = mTransaction->GetCachedStatement(firstQuery); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mIndex->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (mKeyRange) { rv = mKeyRange->BindToStatement(stmt); @@ -2180,7 +2181,7 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection) bool hasResult; rv = stmt->ExecuteStep(&hasResult); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (!hasResult) { mKey.Unset(); @@ -2304,7 +2305,7 @@ OpenCursorHelper::EnsureCursor() IDBCursor::Create(mRequest, mTransaction, mIndex, mDirection, mRangeKey, mContinueQuery, mContinueToQuery, mKey, mObjectKey, mCloneReadInfo); - NS_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); NS_ASSERTION(!mCloneReadInfo.mCloneBuffer.data(), "Should have swapped!"); @@ -2477,12 +2478,12 @@ CountHelper::DoDatabaseWork(mozIStorageConnection* aConnection) keyRangeClause; nsCOMPtr stmt = mTransaction->GetCachedStatement(query); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mIndex->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (mKeyRange) { if (!mKeyRange->Lower().IsUnset()) { @@ -2497,8 +2498,8 @@ CountHelper::DoDatabaseWork(mozIStorageConnection* aConnection) bool hasResult; rv = stmt->ExecuteStep(&hasResult); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - NS_ENSURE_TRUE(hasResult, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(hasResult, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mCount = stmt->AsInt64(0); return NS_OK; diff --git a/dom/indexedDB/IDBObjectStore.cpp b/dom/indexedDB/IDBObjectStore.cpp index adaf065b1de..fe013dae456 100644 --- a/dom/indexedDB/IDBObjectStore.cpp +++ b/dom/indexedDB/IDBObjectStore.cpp @@ -42,6 +42,7 @@ #include "DictionaryHelpers.h" #include "KeyPath.h" #include "ProfilerHelpers.h" +#include "ReportInternalError.h" #include "ipc/IndexedDBChild.h" #include "ipc/IndexedDBParent.h" @@ -1047,12 +1048,14 @@ IDBObjectStore::AppendIndexUpdateInfo( JS::Rooted array(aCx, JSVAL_TO_OBJECT(val)); uint32_t arrayLength; if (!JS_GetArrayLength(aCx, array, &arrayLength)) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } for (uint32_t arrayIndex = 0; arrayIndex < arrayLength; arrayIndex++) { JS::Rooted arrayItem(aCx); if (!JS_GetElement(aCx, array, arrayIndex, &arrayItem)) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -1219,7 +1222,7 @@ IDBObjectStore::GetStructuredCloneReadInfoFromStatement( uint32_t blobDataLength; nsresult rv = aStatement->GetSharedBlob(aDataIndex, &blobDataLength, &blobData); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); const char* compressed = reinterpret_cast(blobData); size_t compressedLength = size_t(blobDataLength); @@ -1229,7 +1232,7 @@ IDBObjectStore::GetStructuredCloneReadInfoFromStatement( size_t uncompressedLength; if (!snappy::GetUncompressedLength(compressed, compressedLength, &uncompressedLength)) { - NS_WARNING("Snappy can't determine uncompressed length!"); + IDB_WARNING("Snappy can't determine uncompressed length!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -1238,28 +1241,29 @@ IDBObjectStore::GetStructuredCloneReadInfoFromStatement( if (!snappy::RawUncompress(compressed, compressedLength, uncompressed.get())) { - NS_WARNING("Snappy can't determine uncompressed length!"); + IDB_WARNING("Snappy can't determine uncompressed length!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } JSAutoStructuredCloneBuffer& buffer = aInfo.mCloneBuffer; if (!buffer.copy(reinterpret_cast(uncompressed.get()), uncompressedLength)) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } bool isNull; rv = aStatement->GetIsNull(aFileIdsIndex, &isNull); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (!isNull) { nsString ids; rv = aStatement->GetString(aFileIdsIndex, ids); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsAutoTArray array; rv = ConvertFileIdsToArray(ids, array); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); FileManager* fileManager = aDatabase->Manager(); @@ -1770,7 +1774,7 @@ IDBObjectStore::ConvertBlobsToActors( if (!aFiles.IsEmpty()) { nsCOMPtr directory = aFileManager->GetDirectory(); if (!directory) { - NS_WARNING("Failed to get directory!"); + IDB_WARNING("Failed to get directory!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -1784,7 +1788,7 @@ IDBObjectStore::ConvertBlobsToActors( nsCOMPtr nativeFile = aFileManager->GetFileForId(directory, file.mFileInfo->Id()); if (!nativeFile) { - NS_WARNING("Failed to get file!"); + IDB_WARNING("Failed to get file!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -1794,6 +1798,7 @@ IDBObjectStore::ConvertBlobsToActors( aContentParent->GetOrCreateActorForBlob(blob); if (!actor) { // This can only fail if the child has crashed. + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -1931,7 +1936,7 @@ IDBObjectStore::AddOrPut(JSContext* aCx, JS::Handle aValue, nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -1942,7 +1947,7 @@ IDBObjectStore::AddOrPut(JSContext* aCx, JS::Handle aValue, nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -1994,11 +1999,11 @@ IDBObjectStore::AddOrPutInternal( } nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); StructuredCloneWriteInfo cloneWriteInfo; if (!cloneWriteInfo.SetFromSerialized(aCloneWriteInfo)) { - NS_WARNING("Failed to copy structured clone buffer!"); + IDB_WARNING("Failed to copy structured clone buffer!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -2021,12 +2026,12 @@ IDBObjectStore::AddOrPutInternal( if (!fileInfo) { fileInfo = fileManager->GetNewFileInfo(); if (!fileInfo) { - NS_WARNING("Failed to get new file info!"); + IDB_WARNING("Failed to get new file info!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } if (NS_FAILED(blob->GetInternalStream(getter_AddRefs(inputStream)))) { - NS_WARNING("Failed to get internal steam!"); + IDB_WARNING("Failed to get internal steam!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -2053,7 +2058,7 @@ IDBObjectStore::AddOrPutInternal( updateInfo); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); #ifdef IDB_PROFILER_USE_MARKS if (aOverwrite) { @@ -2095,7 +2100,7 @@ IDBObjectStore::GetInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv) nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2105,7 +2110,7 @@ IDBObjectStore::GetInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv) nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2134,7 +2139,7 @@ IDBObjectStore::GetAllInternal(IDBKeyRange* aKeyRange, nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2144,7 +2149,7 @@ IDBObjectStore::GetAllInternal(IDBKeyRange* aKeyRange, nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2175,7 +2180,7 @@ IDBObjectStore::GetAllKeysInternal(IDBKeyRange* aKeyRange, uint32_t aLimit, nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2185,7 +2190,7 @@ IDBObjectStore::GetAllKeysInternal(IDBKeyRange* aKeyRange, uint32_t aLimit, nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2222,7 +2227,7 @@ IDBObjectStore::DeleteInternal(IDBKeyRange* aKeyRange, nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2232,7 +2237,7 @@ IDBObjectStore::DeleteInternal(IDBKeyRange* aKeyRange, nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2265,7 +2270,7 @@ IDBObjectStore::Clear(ErrorResult& aRv) nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2274,7 +2279,7 @@ IDBObjectStore::Clear(ErrorResult& aRv) nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2302,7 +2307,7 @@ IDBObjectStore::CountInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv) nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2311,7 +2316,7 @@ IDBObjectStore::CountInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv) new CountHelper(mTransaction, request, this, aKeyRange); nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2343,7 +2348,7 @@ IDBObjectStore::OpenCursorInternal(IDBKeyRange* aKeyRange, nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2353,7 +2358,7 @@ IDBObjectStore::OpenCursorInternal(IDBKeyRange* aKeyRange, nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2391,7 +2396,7 @@ IDBObjectStore::OpenCursorFromChildProcess( StructuredCloneReadInfo cloneInfo; if (!cloneInfo.SetFromSerialized(aCloneInfo)) { - NS_WARNING("Failed to copy clone buffer!"); + IDB_WARNING("Failed to copy clone buffer!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -2400,7 +2405,7 @@ IDBObjectStore::OpenCursorFromChildProcess( nsRefPtr cursor = IDBCursor::Create(aRequest, mTransaction, this, direction, Key(), EmptyCString(), EmptyCString(), aKey, cloneInfo); - NS_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); NS_ASSERTION(!cloneInfo.mCloneBuffer.data(), "Should have swapped!"); @@ -2422,7 +2427,7 @@ IDBObjectStore::OpenCursorFromChildProcess(IDBRequest* aRequest, nsRefPtr cursor = IDBCursor::Create(aRequest, mTransaction, this, direction, Key(), EmptyCString(), EmptyCString(), aKey); - NS_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); cursor.forget(_retval); return NS_OK; @@ -2441,7 +2446,7 @@ IDBObjectStore::OpenKeyCursorInternal(IDBKeyRange* aKeyRange, size_t aDirection, nsRefPtr request = GenerateRequest(this); if (!request) { - NS_WARNING("Failed to generate request!"); + IDB_WARNING("Failed to generate request!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2453,7 +2458,7 @@ IDBObjectStore::OpenKeyCursorInternal(IDBKeyRange* aKeyRange, size_t aDirection, nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2506,7 +2511,7 @@ IDBObjectStore::CreateIndexInternal(const IndexInfo& aInfo, ErrorResult& aRv) nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2561,13 +2566,13 @@ IDBObjectStore::Index(const nsAString& aName, ErrorResult &aRv) if (!retval) { retval = IDBIndex::Create(this, indexInfo, false); if (!retval) { - NS_WARNING("Failed to create index!"); + IDB_WARNING("Failed to create index!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } if (!mCreatedIndexes.AppendElement(retval)) { - NS_WARNING("Out of memory!"); + IDB_WARNING("Out of memory!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2659,7 +2664,7 @@ IDBObjectStore::GetIndexNames(ErrorResult& aRv) for (uint32_t index = 0; index < count; index++) { if (!list->Add(names[index])) { - NS_WARNING("Failed to add element!"); + IDB_WARNING("Failed to add element!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -2903,7 +2908,7 @@ IDBObjectStore::DeleteIndex(const nsAString& aName, ErrorResult& aRv) nsresult rv = helper->DispatchToTransactionPool(); if (NS_FAILED(rv)) { - NS_WARNING("Failed to dispatch!"); + IDB_WARNING("Failed to dispatch!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return; } @@ -3016,7 +3021,7 @@ CopyData(nsIInputStream* aInputStream, nsIOutputStream* aOutputStream) uint32_t numRead; rv = aInputStream->Read(copyBuffer, sizeof(copyBuffer), &numRead); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (!numRead) { break; @@ -3024,7 +3029,7 @@ CopyData(nsIInputStream* aInputStream, nsIOutputStream* aOutputStream) uint32_t numWrite; rv = aOutputStream->Write(copyBuffer, numRead, &numWrite); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (numWrite < numRead) { // Must have hit the quota limit. @@ -3033,7 +3038,7 @@ CopyData(nsIInputStream* aInputStream, nsIOutputStream* aOutputStream) } while (true); rv = aOutputStream->Flush(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return NS_OK; } @@ -3059,6 +3064,7 @@ ObjectStoreHelper::Dispatch(nsIEventTarget* aDatabaseThread) // If we've been invalidated then there's no point sending anything to the // parent process. if (mObjectStore->Transaction()->Database()->IsInvalidated()) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -3067,11 +3073,11 @@ ObjectStoreHelper::Dispatch(nsIEventTarget* aDatabaseThread) ObjectStoreRequestParams params; nsresult rv = PackArgumentsForParentProcess(params); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); NoDispatchEventTarget target; rv = AsyncConnectionHelper::Dispatch(&target); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mActor = new IndexedDBObjectStoreRequestChild(this, mObjectStore, params.type()); @@ -3092,8 +3098,7 @@ nsresult NoRequestObjectStoreHelper::UnpackResponseFromParentProcess( const ResponseValue& aResponseValue) { - NS_NOTREACHED("Should never get here!"); - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; + MOZ_CRASH(); } AsyncConnectionHelper::ChildProcessSendResult @@ -3160,12 +3165,12 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection) "INSERT OR REPLACE INTO object_data (object_store_id, key_value, data, " "file_ids) " "VALUES (:osid, :key_value, :data, :file_ids)"); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), osid); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); NS_ASSERTION(!keyUnset || mObjectStore->IsAutoIncrement(), "Should have key unless autoincrement"); @@ -3180,6 +3185,7 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection) "Generated key must always be a positive integer"); if (autoIncrementNum > (1LL << 53)) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -3225,7 +3231,7 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection) rv = stmt->BindBlobByName(NS_LITERAL_CSTRING("data"), dataBuffer, dataBufferLength); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); // Handle blobs uint32_t length = mCloneWriteInfo.mFiles.Length(); @@ -3233,10 +3239,10 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection) nsRefPtr fileManager = mDatabase->Manager(); nsCOMPtr directory = fileManager->GetDirectory(); - NS_ENSURE_TRUE(directory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(directory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsCOMPtr journalDirectory = fileManager->EnsureJournalDirectory(); - NS_ENSURE_TRUE(journalDirectory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(journalDirectory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsAutoString fileIds; @@ -3251,20 +3257,20 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection) // Create a journal file first nsCOMPtr nativeFile = fileManager->GetFileForId(journalDirectory, id); - NS_ENSURE_TRUE(nativeFile, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(nativeFile, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = nativeFile->Create(nsIFile::NORMAL_FILE_TYPE, 0644); - NS_ENSURE_TRUE(nativeFile, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(nativeFile, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); // Now we can copy the blob nativeFile = fileManager->GetFileForId(directory, id); - NS_ENSURE_TRUE(nativeFile, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(nativeFile, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); IDBDatabase* database = mObjectStore->Transaction()->Database(); nsRefPtr outputStream = FileOutputStream::Create(database->Type(), database->Group(), database->Origin(), nativeFile); - NS_ENSURE_TRUE(outputStream, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(outputStream, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = CopyData(inputStream, outputStream); NS_ENSURE_SUCCESS(rv, rv); @@ -3283,18 +3289,18 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection) else { rv = stmt->BindNullByName(NS_LITERAL_CSTRING("file_ids")); } - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = stmt->Execute(); if (rv == NS_ERROR_STORAGE_CONSTRAINT) { NS_ASSERTION(!keyUnset, "Generated key had a collision!?"); return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR; } - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); int64_t objectDataId; rv = aConnection->GetLastInsertRowID(&objectDataId); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); // Update our indexes if needed. if (mOverwrite || !mIndexUpdateInfo.IsEmpty()) { @@ -3303,7 +3309,7 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection) if (rv == NS_ERROR_STORAGE_CONSTRAINT) { return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR; } - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } if (autoIncrementNum) { @@ -3365,6 +3371,7 @@ AddHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams) BlobChild* actor = contentChild->GetOrCreateActorForBlob(file.mFile); if (!actor) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } blobsChild.AppendElement(actor); @@ -3452,20 +3459,20 @@ GetHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */) keyRangeClause + NS_LITERAL_CSTRING(" LIMIT 1"); nsCOMPtr stmt = mTransaction->GetCachedStatement(query); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), mObjectStore->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = mKeyRange->BindToStatement(stmt); NS_ENSURE_SUCCESS(rv, rv); bool hasResult; rv = stmt->ExecuteStep(&hasResult); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (hasResult) { rv = IDBObjectStore::GetStructuredCloneReadInfoFromStatement(stmt, 0, 1, @@ -3582,7 +3589,7 @@ GetHelper::UnpackResponseFromParentProcess(const ResponseValue& aResponseValue) "Inconsistent clone info!"); if (!mCloneReadInfo.SetFromSerialized(cloneInfo)) { - NS_WARNING("Failed to copy clone buffer!"); + IDB_WARNING("Failed to copy clone buffer!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -3610,19 +3617,19 @@ DeleteHelper::DoDatabaseWork(mozIStorageConnection* /*aConnection */) keyRangeClause; nsCOMPtr stmt = mTransaction->GetCachedStatement(query); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), mObjectStore->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = mKeyRange->BindToStatement(stmt); NS_ENSURE_SUCCESS(rv, rv); rv = stmt->Execute(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return NS_OK; } @@ -3703,16 +3710,16 @@ ClearHelper::DoDatabaseWork(mozIStorageConnection* aConnection) mTransaction->GetCachedStatement( NS_LITERAL_CSTRING("DELETE FROM object_data " "WHERE object_store_id = :osid")); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), mObjectStore->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = stmt->Execute(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return NS_OK; } @@ -3807,13 +3814,13 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection) nsCOMPtr stmt = mTransaction->GetCachedStatement(firstQuery); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mObjectStore->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (mKeyRange) { rv = mKeyRange->BindToStatement(stmt); @@ -3822,7 +3829,7 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection) bool hasResult; rv = stmt->ExecuteStep(&hasResult); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (!hasResult) { mKey.Unset(); @@ -3909,7 +3916,7 @@ OpenCursorHelper::EnsureCursor() IDBCursor::Create(mRequest, mTransaction, mObjectStore, mDirection, mRangeKey, mContinueQuery, mContinueToQuery, mKey, mCloneReadInfo); - NS_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); NS_ASSERTION(!mCloneReadInfo.mCloneBuffer.data(), "Should have swapped!"); @@ -3926,7 +3933,7 @@ OpenCursorHelper::GetSuccessResult(JSContext* aCx, if (mCursor) { rv = WrapNative(aCx, mCursor, aVal); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } else { aVal.setUndefined(); @@ -4098,8 +4105,7 @@ OpenCursorHelper::UnpackResponseFromParentProcess( } break; default: - NS_NOTREACHED("Unknown response union type!"); - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; + MOZ_CRASH(); } return NS_OK; @@ -4149,12 +4155,12 @@ OpenKeyCursorHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */) nsCOMPtr stmt = mTransaction->GetCachedStatement(firstQuery); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(id, mObjectStore->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (mKeyRange) { rv = mKeyRange->BindToStatement(stmt); @@ -4163,7 +4169,7 @@ OpenKeyCursorHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */) bool hasResult; rv = stmt->ExecuteStep(&hasResult); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (!hasResult) { mKey.Unset(); @@ -4239,7 +4245,7 @@ OpenKeyCursorHelper::EnsureCursor() mCursor = IDBCursor::Create(mRequest, mTransaction, mObjectStore, mDirection, mRangeKey, mContinueQuery, mContinueToQuery, mKey); - NS_ENSURE_TRUE(mCursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(mCursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return NS_OK; } @@ -4259,7 +4265,7 @@ OpenKeyCursorHelper::GetSuccessResult(JSContext* aCx, if (mCursor) { rv = WrapNative(aCx, mCursor, aVal); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } else { aVal.setUndefined(); @@ -4430,34 +4436,34 @@ CreateIndexHelper::DoDatabaseWork(mozIStorageConnection* aConnection) "multientry, object_store_id) " "VALUES (:id, :name, :key_path, :unique, :multientry, :osid)" ); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mIndex->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = stmt->BindStringByName(NS_LITERAL_CSTRING("name"), mIndex->Name()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsAutoString keyPathSerialization; mIndex->GetKeyPath().SerializeToString(keyPathSerialization); rv = stmt->BindStringByName(NS_LITERAL_CSTRING("key_path"), keyPathSerialization); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("unique"), mIndex->IsUnique() ? 1 : 0); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("multientry"), mIndex->IsMultiEntry() ? 1 : 0); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), mIndex->ObjectStore()->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (NS_FAILED(stmt->Execute())) { return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR; @@ -4494,20 +4500,20 @@ CreateIndexHelper::InsertDataFromObjectStore(mozIStorageConnection* aConnection) mTransaction->GetCachedStatement( NS_LITERAL_CSTRING("SELECT id, data, file_ids, key_value FROM " "object_data WHERE object_store_id = :osid")); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), mIndex->ObjectStore()->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - NS_ENSURE_TRUE(sTLSIndex != BAD_TLS_INDEX, - NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(sTLSIndex != BAD_TLS_INDEX, + NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); bool hasResult; rv = stmt->ExecuteStep(&hasResult); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (!hasResult) { // Bail early if we have no data to avoid creating the below runtime return NS_OK; @@ -4518,7 +4524,7 @@ CreateIndexHelper::InsertDataFromObjectStore(mozIStorageConnection* aConnection) if (!tlsEntry) { tlsEntry = ThreadLocalJSRuntime::Create(); - NS_ENSURE_TRUE(tlsEntry, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(tlsEntry, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); PR_SetThreadPrivate(sTLSIndex, tlsEntry); } @@ -4567,7 +4573,7 @@ CreateIndexHelper::InsertDataFromObjectStore(mozIStorageConnection* aConnection) NS_ENSURE_SUCCESS(rv, rv); } while (NS_SUCCEEDED(rv = stmt->ExecuteStep(&hasResult)) && hasResult); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return NS_OK; } @@ -4591,12 +4597,12 @@ DeleteIndexHelper::DoDatabaseWork(mozIStorageConnection* aConnection) "DELETE FROM object_store_index " "WHERE name = :name " ); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindStringByName(NS_LITERAL_CSTRING("name"), mName); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (NS_FAILED(stmt->Execute())) { return NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR; @@ -4657,13 +4663,13 @@ GetAllHelper::DoDatabaseWork(mozIStorageConnection* aConnection) mCloneReadInfos.SetCapacity(50); nsCOMPtr stmt = mTransaction->GetCachedStatement(query); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), mObjectStore->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (mKeyRange) { if (!mKeyRange->Lower().IsUnset()) { @@ -4689,7 +4695,7 @@ GetAllHelper::DoDatabaseWork(mozIStorageConnection* aConnection) mDatabase, *readInfo); NS_ENSURE_SUCCESS(rv, rv); } - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return NS_OK; } @@ -4837,7 +4843,7 @@ GetAllHelper::UnpackResponseFromParentProcess( StructuredCloneReadInfo* destInfo = mCloneReadInfos.AppendElement(); if (!destInfo->SetFromSerialized(srcInfo)) { - NS_WARNING("Failed to copy clone buffer!"); + IDB_WARNING("Failed to copy clone buffer!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -4879,12 +4885,12 @@ GetAllKeysHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */) limitClause; nsCOMPtr stmt = mTransaction->GetCachedStatement(query); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(osid, mObjectStore->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (mKeyRange) { rv = mKeyRange->BindToStatement(stmt); @@ -4905,7 +4911,7 @@ GetAllKeysHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */) rv = key->SetFromStatement(stmt, 0); NS_ENSURE_SUCCESS(rv, rv); } - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return NS_OK; } @@ -4926,13 +4932,13 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx, JS::Rooted array(aCx, JS_NewArrayObject(aCx, 0, nullptr)); if (!array) { - NS_WARNING("Failed to make array!"); + IDB_WARNING("Failed to make array!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } if (!keys.IsEmpty()) { if (!JS_SetArrayLength(aCx, array, keys.Length())) { - NS_WARNING("Failed to set array length!"); + IDB_WARNING("Failed to set array length!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -4948,7 +4954,7 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx, } if (!JS_SetElement(aCx, array, index, value)) { - NS_WARNING("Failed to set array element!"); + IDB_WARNING("Failed to set array element!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } } @@ -5079,13 +5085,13 @@ CountHelper::DoDatabaseWork(mozIStorageConnection* aConnection) keyRangeClause; nsCOMPtr stmt = mTransaction->GetCachedStatement(query); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), mObjectStore->Id()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (mKeyRange) { if (!mKeyRange->Lower().IsUnset()) { @@ -5100,8 +5106,8 @@ CountHelper::DoDatabaseWork(mozIStorageConnection* aConnection) bool hasResult; rv = stmt->ExecuteStep(&hasResult); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - NS_ENSURE_TRUE(hasResult, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(hasResult, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mCount = stmt->AsInt64(0); return NS_OK; diff --git a/dom/indexedDB/IDBRequest.cpp b/dom/indexedDB/IDBRequest.cpp index ca01e6e770e..e5795757335 100644 --- a/dom/indexedDB/IDBRequest.cpp +++ b/dom/indexedDB/IDBRequest.cpp @@ -30,6 +30,7 @@ #include "IDBIndex.h" #include "IDBObjectStore.h" #include "IDBTransaction.h" +#include "ReportInternalError.h" namespace { @@ -187,7 +188,7 @@ IDBRequest::NotifyHelperCompleted(HelperBase* aHelper) // Otherwise we need to get the result from the helper. AutoPushJSContext cx(GetJSContext()); if (!cx) { - NS_WARNING("Failed to get safe JSContext!"); + IDB_WARNING("Failed to get safe JSContext!"); rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; SetError(rv); return rv; diff --git a/dom/indexedDB/IDBTransaction.cpp b/dom/indexedDB/IDBTransaction.cpp index 94d71e37961..032890d9a47 100644 --- a/dom/indexedDB/IDBTransaction.cpp +++ b/dom/indexedDB/IDBTransaction.cpp @@ -29,6 +29,7 @@ #include "IDBObjectStore.h" #include "IndexedDatabaseManager.h" #include "ProfilerHelpers.h" +#include "ReportInternalError.h" #include "TransactionThreadPool.h" #include "ipc/IndexedDBChild.h" @@ -680,7 +681,7 @@ IDBTransaction::GetObjectStoreNames(ErrorResult& aRv) uint32_t count = arrayOfNames->Length(); for (uint32_t index = 0; index < count; index++) { if (!list->Add(arrayOfNames->ElementAt(index))) { - NS_WARNING("Failed to add element!"); + IDB_WARNING("Failed to add element!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -714,7 +715,7 @@ IDBTransaction::ObjectStore(const nsAString& aName, ErrorResult& aRv) nsRefPtr objectStore = GetOrCreateObjectStore(aName, info, false); if (!objectStore) { - NS_WARNING("Failed to get or create object store!"); + IDB_WARNING("Failed to get or create object store!"); aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); return nullptr; } @@ -829,7 +830,7 @@ CommitHelper::Run() NS_LITERAL_STRING(COMPLETE_EVT_STR), eDoesNotBubble, eNotCancelable); } - NS_ENSURE_TRUE(event, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(event, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (mListener) { mListener->NotifyTransactionPreComplete(mTransaction); @@ -861,6 +862,7 @@ CommitHelper::Run() IDBDatabase* database = mTransaction->Database(); if (database->IsInvalidated()) { + IDB_REPORT_INTERNAL_ERR(); mAbortCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -869,10 +871,12 @@ CommitHelper::Run() if (NS_SUCCEEDED(mAbortCode) && mUpdateFileRefcountFunction && NS_FAILED(mUpdateFileRefcountFunction->WillCommit(mConnection))) { + IDB_REPORT_INTERNAL_ERR(); mAbortCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } if (NS_SUCCEEDED(mAbortCode) && NS_FAILED(WriteAutoIncrementCounts())) { + IDB_REPORT_INTERNAL_ERR(); mAbortCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -891,6 +895,7 @@ CommitHelper::Run() mAbortCode = NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR; } else { + IDB_REPORT_INTERNAL_ERR(); mAbortCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } } diff --git a/dom/indexedDB/Key.cpp b/dom/indexedDB/Key.cpp index da4c2e9a00a..274b9cd97e8 100644 --- a/dom/indexedDB/Key.cpp +++ b/dom/indexedDB/Key.cpp @@ -7,6 +7,8 @@ #include "mozilla/FloatingPoint.h" #include "Key.h" +#include "ReportInternalError.h" + #include "jsfriendapi.h" #include "nsAlgorithm.h" #include "nsJSUtils.h" @@ -112,6 +114,7 @@ Key::EncodeJSValInternal(JSContext* aCx, JS::Handle aVal, if (aVal.isString()) { nsDependentJSString str; if (!str.init(aCx, aVal)) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } EncodeString(str, aTypeOffset); @@ -142,12 +145,14 @@ Key::EncodeJSValInternal(JSContext* aCx, JS::Handle aVal, uint32_t length; if (!JS_GetArrayLength(aCx, obj, &length)) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } for (uint32_t index = 0; index < length; index++) { JS::Rooted val(aCx); if (!JS_GetElement(aCx, obj, index, &val)) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -189,6 +194,7 @@ Key::DecodeJSValInternal(const unsigned char*& aPos, const unsigned char* aEnd, JS::Rooted array(aCx, JS_NewArrayObject(aCx, 0, nullptr)); if (!array) { NS_WARNING("Failed to make array!"); + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -210,6 +216,7 @@ Key::DecodeJSValInternal(const unsigned char*& aPos, const unsigned char* aEnd, if (!JS_SetElement(aCx, array, index++, val)) { NS_WARNING("Failed to set array element!"); + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } } @@ -224,6 +231,7 @@ Key::DecodeJSValInternal(const unsigned char*& aPos, const unsigned char* aEnd, nsString key; DecodeString(aPos, aEnd, key); if (!xpc::StringToJsval(aCx, key, aVal)) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } } @@ -231,7 +239,7 @@ Key::DecodeJSValInternal(const unsigned char*& aPos, const unsigned char* aEnd, double msec = static_cast(DecodeNumber(aPos, aEnd)); JSObject* date = JS_NewDateObjectMsec(aCx, msec); if (!date) { - NS_WARNING("Failed to make date!"); + IDB_WARNING("Failed to make date!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } diff --git a/dom/indexedDB/KeyPath.cpp b/dom/indexedDB/KeyPath.cpp index c1a751cf90b..bf76e044ceb 100644 --- a/dom/indexedDB/KeyPath.cpp +++ b/dom/indexedDB/KeyPath.cpp @@ -7,6 +7,7 @@ #include "KeyPath.h" #include "IDBObjectStore.h" #include "Key.h" +#include "ReportInternalError.h" #include "nsCharSeparatedTokenizer.h" #include "nsJSUtils.h" @@ -114,13 +115,13 @@ GetJSValFromKeyPathString(JSContext* aCx, bool ok = JS_HasUCProperty(aCx, obj, keyPathChars, keyPathLen, &hasProp); - NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (hasProp) { // Get if the property exists... JS::Rooted intermediate(aCx); bool ok = JS_GetUCProperty(aCx, obj, keyPathChars, keyPathLen, &intermediate); - NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); // Treat explicitly undefined as an error. if (intermediate == JSVAL_VOID) { @@ -162,6 +163,7 @@ GetJSValFromKeyPathString(JSContext* aCx, JS::Rooted dummy(aCx, JS_NewObject(aCx, nullptr, JS::NullPtr(), JS::NullPtr())); if (!dummy) { + IDB_REPORT_INTERNAL_ERR(); rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; break; } @@ -170,6 +172,7 @@ GetJSValFromKeyPathString(JSContext* aCx, token.Length(), OBJECT_TO_JSVAL(dummy), nullptr, nullptr, JSPROP_ENUMERATE)) { + IDB_REPORT_INTERNAL_ERR(); rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; break; } @@ -180,6 +183,7 @@ GetJSValFromKeyPathString(JSContext* aCx, JS::Rooted dummy(aCx, JS_NewObject(aCx, &IDBObjectStore::sDummyPropJSClass, JS::NullPtr(), JS::NullPtr())); if (!dummy) { + IDB_REPORT_INTERNAL_ERR(); rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; break; } @@ -187,6 +191,7 @@ GetJSValFromKeyPathString(JSContext* aCx, if (!JS_DefineUCProperty(aCx, obj, token.BeginReading(), token.Length(), OBJECT_TO_JSVAL(dummy), nullptr, nullptr, JSPROP_ENUMERATE)) { + IDB_REPORT_INTERNAL_ERR(); rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; break; } @@ -210,9 +215,10 @@ GetJSValFromKeyPathString(JSContext* aCx, targetObjectPropName.get(), targetObjectPropName.Length(), &succeeded)) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } - NS_ENSURE_TRUE(succeeded, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(succeeded, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } NS_ENSURE_SUCCESS(rv, rv); @@ -400,6 +406,7 @@ KeyPath::ExtractKeyAsJSVal(JSContext* aCx, const JS::Value& aValue, } if (!JS_SetElement(aCx, arrayObj, i, value)) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } } @@ -497,7 +504,7 @@ KeyPath::ToJSVal(JSContext* aCx, JS::MutableHandle aValue) const uint32_t len = mStrings.Length(); JS::Rooted array(aCx, JS_NewArrayObject(aCx, len, nullptr)); if (!array) { - NS_WARNING("Failed to make array!"); + IDB_WARNING("Failed to make array!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -505,10 +512,12 @@ KeyPath::ToJSVal(JSContext* aCx, JS::MutableHandle aValue) const JS::Rooted val(aCx); nsString tmp(mStrings[i]); if (!xpc::StringToJsval(aCx, tmp, &val)) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } if (!JS_SetElement(aCx, array, i, val)) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } } @@ -520,6 +529,7 @@ KeyPath::ToJSVal(JSContext* aCx, JS::MutableHandle aValue) const if (IsString()) { nsString tmp(mStrings[0]); if (!xpc::StringToJsval(aCx, tmp, aValue)) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } return NS_OK; diff --git a/dom/indexedDB/OpenDatabaseHelper.cpp b/dom/indexedDB/OpenDatabaseHelper.cpp index 0912fc138fb..97b4e4b769d 100644 --- a/dom/indexedDB/OpenDatabaseHelper.cpp +++ b/dom/indexedDB/OpenDatabaseHelper.cpp @@ -24,6 +24,7 @@ #include "IDBFactory.h" #include "IndexedDatabaseManager.h" #include "ProfilerHelpers.h" +#include "ReportInternalError.h" using namespace mozilla; using namespace mozilla::dom; @@ -1786,6 +1787,7 @@ OpenDatabaseHelper::DoDatabaseWork() mState = eFiringEvents; // In case we fail somewhere along the line. if (QuotaManager::IsShuttingDown()) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -1805,18 +1807,18 @@ OpenDatabaseHelper::DoDatabaseWork() quotaManager->EnsureOriginIsInitialized(mPersistenceType, mGroup, mASCIIOrigin, mTrackingQuota, getter_AddRefs(dbDirectory)); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = dbDirectory->Append(NS_LITERAL_STRING(IDB_DIRECTORY_NAME)); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); bool exists; rv = dbDirectory->Exists(&exists); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (!exists) { rv = dbDirectory->Create(nsIFile::DIRECTORY_TYPE, 0755); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } #ifdef DEBUG else { @@ -1828,24 +1830,24 @@ OpenDatabaseHelper::DoDatabaseWork() nsAutoString filename; rv = GetDatabaseFilename(mName, filename); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsCOMPtr dbFile; rv = dbDirectory->Clone(getter_AddRefs(dbFile)); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = dbFile->Append(filename + NS_LITERAL_STRING(".sqlite")); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = dbFile->GetPath(mDatabaseFilePath); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsCOMPtr fmDirectory; rv = dbDirectory->Clone(getter_AddRefs(fmDirectory)); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = fmDirectory->Append(filename); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsCOMPtr connection; rv = CreateDatabaseConnection(dbFile, fmDirectory, mName, mPersistenceType, @@ -1853,13 +1855,14 @@ OpenDatabaseHelper::DoDatabaseWork() getter_AddRefs(connection)); if (NS_FAILED(rv) && NS_ERROR_GET_MODULE(rv) != NS_ERROR_MODULE_DOM_INDEXEDDB) { + IDB_REPORT_INTERNAL_ERR(); rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } NS_ENSURE_SUCCESS(rv, rv); rv = IDBFactory::LoadDatabaseInformation(connection, mDatabaseId, &mCurrentVersion, mObjectStores); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (mForDeletion) { mState = eDeletePending; @@ -1908,7 +1911,7 @@ OpenDatabaseHelper::DoDatabaseWork() mPrivilege, mName); rv = fileManager->Init(fmDirectory, connection); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); mgr->AddFileManager(fileManager); } @@ -1976,7 +1979,7 @@ OpenDatabaseHelper::CreateDatabaseConnection( bool isDirectory; rv = aFMDirectory->IsDirectory(&isDirectory); NS_ENSURE_SUCCESS(rv, rv); - NS_ENSURE_TRUE(isDirectory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(isDirectory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = aFMDirectory->Remove(true); NS_ENSURE_SUCCESS(rv, rv); @@ -1999,12 +2002,12 @@ OpenDatabaseHelper::CreateDatabaseConnection( // Unknown schema will fail origin initialization too if (!schemaVersion && aName.IsVoid()) { - NS_WARNING("Unable to open IndexedDB database, schema is not set!"); + IDB_WARNING("Unable to open IndexedDB database, schema is not set!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } if (schemaVersion > kSQLiteSchemaVersion) { - NS_WARNING("Unable to open IndexedDB database, schema is too high!"); + IDB_WARNING("Unable to open IndexedDB database, schema is too high!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -2044,13 +2047,13 @@ OpenDatabaseHelper::CreateDatabaseConnection( "INSERT INTO database (name) " "VALUES (:name)" ), getter_AddRefs(stmt)); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = stmt->BindStringByName(NS_LITERAL_CSTRING("name"), aName); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = stmt->Execute(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } else { // This logic needs to change next time we change the schema! @@ -2092,6 +2095,7 @@ OpenDatabaseHelper::CreateDatabaseConnection( else { NS_WARNING("Unable to open IndexedDB database, no upgrade path is " "available!"); + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } NS_ENSURE_SUCCESS(rv, rv); @@ -2136,7 +2140,7 @@ OpenDatabaseHelper::StartSetVersion() nsRefPtr transaction = IDBTransaction::Create(mDatabase, storesToOpen, IDBTransaction::VERSION_CHANGE, true); - NS_ENSURE_TRUE(transaction, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(transaction, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsRefPtr helper = new SetVersionHelper(transaction, mOpenDBRequest, this, mRequestedVersion, @@ -2149,7 +2153,7 @@ OpenDatabaseHelper::StartSetVersion() mDatabase, mDatabase->Origin(), helper, &VersionChangeEventsRunnable::QueueVersionChange, helper); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); // The SetVersionHelper is responsible for dispatching us back to the // main thread again and changing the state to eSetVersionCompleted. @@ -2179,7 +2183,7 @@ OpenDatabaseHelper::StartDelete() mDatabase, mDatabase->Origin(), helper, &VersionChangeEventsRunnable::QueueVersionChange, helper); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); // The DeleteDatabaseHelper is responsible for dispatching us back to the // main thread again and changing the state to eDeleteCompleted. @@ -2374,7 +2378,6 @@ OpenDatabaseHelper::EnsureSuccessResult() newInfo->filePath = mDatabaseFilePath; if (!DatabaseInfo::Put(newInfo)) { - NS_ERROR("Failed to add to hash!"); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -2382,7 +2385,7 @@ OpenDatabaseHelper::EnsureSuccessResult() nsresult rv = IDBFactory::SetDatabaseMetadata(dbInfo, mCurrentVersion, mObjectStores); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); NS_ASSERTION(mObjectStores.IsEmpty(), "Should have swapped!"); } @@ -2395,6 +2398,7 @@ OpenDatabaseHelper::EnsureSuccessResult() dbInfo.forget(), mASCIIOrigin, mFileManager, mContentParent); if (!database) { + IDB_REPORT_INTERNAL_ERR(); return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } @@ -2538,11 +2542,11 @@ SetVersionHelper::DoDatabaseWork(mozIStorageConnection* aConnection) "UPDATE database " "SET version = :version" ), getter_AddRefs(stmt)); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("version"), mRequestedVersion); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (NS_FAILED(stmt->Execute())) { return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR; @@ -2663,38 +2667,38 @@ DeleteDatabaseHelper::DoDatabaseWork(mozIStorageConnection* aConnection) nsresult rv = quotaManager->GetDirectoryForOrigin(mPersistenceType, mASCIIOrigin, getter_AddRefs(directory)); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); NS_ASSERTION(directory, "What?"); rv = directory->Append(NS_LITERAL_STRING(IDB_DIRECTORY_NAME)); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsAutoString filename; rv = GetDatabaseFilename(mName, filename); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); nsCOMPtr dbFile; rv = directory->Clone(getter_AddRefs(dbFile)); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = dbFile->Append(filename + NS_LITERAL_STRING(".sqlite")); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); bool exists = false; rv = dbFile->Exists(&exists); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (exists) { int64_t fileSize; if (privilege != Chrome) { rv = dbFile->GetFileSize(&fileSize); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } rv = dbFile->Remove(false); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (privilege != Chrome) { QuotaManager* quotaManager = QuotaManager::Get(); @@ -2707,44 +2711,44 @@ DeleteDatabaseHelper::DoDatabaseWork(mozIStorageConnection* aConnection) nsCOMPtr dbJournalFile; rv = directory->Clone(getter_AddRefs(dbJournalFile)); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = dbJournalFile->Append(filename + NS_LITERAL_STRING(".sqlite-journal")); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = dbJournalFile->Exists(&exists); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (exists) { rv = dbJournalFile->Remove(false); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } nsCOMPtr fmDirectory; rv = directory->Clone(getter_AddRefs(fmDirectory)); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = fmDirectory->Append(filename); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = fmDirectory->Exists(&exists); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (exists) { bool isDirectory; rv = fmDirectory->IsDirectory(&isDirectory); NS_ENSURE_SUCCESS(rv, rv); - NS_ENSURE_TRUE(isDirectory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_TRUE(isDirectory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); uint64_t usage = 0; if (privilege != Chrome) { rv = FileManager::GetUsage(fmDirectory, &usage); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); } rv = fmDirectory->Remove(true); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); if (privilege != Chrome) { QuotaManager* quotaManager = QuotaManager::Get(); diff --git a/dom/indexedDB/ReportInternalError.cpp b/dom/indexedDB/ReportInternalError.cpp new file mode 100644 index 00000000000..d02eedc3044 --- /dev/null +++ b/dom/indexedDB/ReportInternalError.cpp @@ -0,0 +1,32 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "ReportInternalError.h" + +#include "mozilla/IntegerPrintfMacros.h" + +#include "nsContentUtils.h" +#include "nsPrintfCString.h" + +BEGIN_INDEXEDDB_NAMESPACE + +void +ReportInternalError(const char* aFile, uint32_t aLine, const char* aStr) +{ + // Get leaf of file path + for (const char* p = aFile; *p; ++p) { + if (*p == '/' && *(p + 1)) { + aFile = p + 1; + } + } + + nsContentUtils::LogSimpleConsoleError( + NS_ConvertUTF8toUTF16(nsPrintfCString( + "IndexedDB %s: %s:%lu", aStr, aFile, aLine)), + "indexedDB"); +} + +END_INDEXEDDB_NAMESPACE diff --git a/dom/indexedDB/ReportInternalError.h b/dom/indexedDB/ReportInternalError.h new file mode 100644 index 00000000000..882c1469fd4 --- /dev/null +++ b/dom/indexedDB/ReportInternalError.h @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_indexeddb_reportinternalerror_h__ +#define mozilla_dom_indexeddb_reportinternalerror_h__ + +#include "nsDebug.h" + +#include "IndexedDatabase.h" + +#define IDB_WARNING(x) \ + mozilla::dom::indexedDB::ReportInternalError(__FILE__, __LINE__, x); \ + NS_WARNING(x) + +#define IDB_REPORT_INTERNAL_ERR() \ + mozilla::dom::indexedDB::ReportInternalError(__FILE__, __LINE__, \ + "UnknownErr") + +// Based on NS_ENSURE_TRUE +#define IDB_ENSURE_TRUE(x, ret) \ + do { \ + if (MOZ_UNLIKELY(!(x))) { \ + IDB_REPORT_INTERNAL_ERR(); \ + NS_WARNING("IDB_ENSURE_TRUE(" #x ") failed"); \ + return ret; \ + } \ + } while(0) + +// Based on NS_ENSURE_SUCCESS +#define IDB_ENSURE_SUCCESS(res, ret) \ + do { \ + nsresult __rv = res; /* Don't evaluate |res| more than once */ \ + if (NS_FAILED(__rv)) { \ + IDB_REPORT_INTERNAL_ERR(); \ + NS_ENSURE_SUCCESS_BODY(res, ret) \ + return ret; \ + } \ + } while(0) + + +BEGIN_INDEXEDDB_NAMESPACE + +void +ReportInternalError(const char* aFile, uint32_t aLine, const char* aStr); + +END_INDEXEDDB_NAMESPACE + +#endif // mozilla_dom_indexeddb_reportinternalerror_h__ diff --git a/dom/indexedDB/moz.build b/dom/indexedDB/moz.build index 4e18e389d9d..a1434c07df3 100644 --- a/dom/indexedDB/moz.build +++ b/dom/indexedDB/moz.build @@ -62,6 +62,7 @@ SOURCES += [ 'IDBCursor.cpp', 'IDBIndex.cpp', 'IDBObjectStore.cpp', + 'ReportInternalError.cpp', ] FAIL_ON_WARNINGS = True From c25cc9fe6933f3bba1659a46e7cae9021ce6c682 Mon Sep 17 00:00:00 2001 From: Ali Akhtarzada Date: Tue, 28 Jan 2014 09:00:10 -0500 Subject: [PATCH 043/296] Bug 961714 - Implement RemoteDXGITextureImage::GetAsSourceSurface. r=nical --- gfx/layers/d3d10/ImageLayerD3D10.cpp | 80 ++++++++++++++++++++++++++++ gfx/layers/d3d10/ImageLayerD3D10.h | 1 + 2 files changed, 81 insertions(+) diff --git a/gfx/layers/d3d10/ImageLayerD3D10.cpp b/gfx/layers/d3d10/ImageLayerD3D10.cpp index e5f72c62de0..56368375b2f 100644 --- a/gfx/layers/d3d10/ImageLayerD3D10.cpp +++ b/gfx/layers/d3d10/ImageLayerD3D10.cpp @@ -494,6 +494,86 @@ RemoteDXGITextureImage::DeprecatedGetAsSurface() return surface.forget(); } +TemporaryRef +RemoteDXGITextureImage::GetAsSourceSurface() +{ + nsRefPtr device = + gfxWindowsPlatform::GetPlatform()->GetD3D10Device(); + if (!device) { + NS_WARNING("Cannot readback from shared texture because no D3D10 device is available."); + return nullptr; + } + + TextureD3D10BackendData* data = GetD3D10TextureBackendData(device); + + if (!data) { + return nullptr; + } + + nsRefPtr keyedMutex; + + if (FAILED(data->mTexture->QueryInterface(IID_IDXGIKeyedMutex, getter_AddRefs(keyedMutex)))) { + NS_WARNING("Failed to QueryInterface for IDXGIKeyedMutex, strange."); + return nullptr; + } + + if (FAILED(keyedMutex->AcquireSync(0, 0))) { + NS_WARNING("Failed to acquire sync for keyedMutex, plugin failed to release?"); + return nullptr; + } + + D3D10_TEXTURE2D_DESC desc; + + data->mTexture->GetDesc(&desc); + + desc.CPUAccessFlags = D3D10_CPU_ACCESS_READ; + desc.BindFlags = 0; + desc.MiscFlags = 0; + desc.Usage = D3D10_USAGE_STAGING; + + nsRefPtr softTexture; + HRESULT hr = device->CreateTexture2D(&desc, nullptr, getter_AddRefs(softTexture)); + + if (FAILED(hr)) { + NS_WARNING("Failed to create 2D staging texture."); + return nullptr; + } + + device->CopyResource(softTexture, data->mTexture); + keyedMutex->ReleaseSync(0); + + RefPtr surface + = gfx::Factory::CreateDataSourceSurface(mSize, + mFormat == RemoteImageData::BGRX32 + ? gfx::SurfaceFormat::B8G8R8X8 + : gfx::SurfaceFormat::B8G8R8A8); + + if (!surface) { + NS_WARNING("Failed to create SourceSurface for DXGI texture."); + return nullptr; + } + + gfx::DataSourceSurface::MappedSurface mappedSurface; + if (!surface->Map(gfx::DataSourceSurface::WRITE, &mappedSurface)) { + NS_WARNING("Failed to map source surface"); + return nullptr; + } + + D3D10_MAPPED_TEXTURE2D mapped; + softTexture->Map(0, D3D10_MAP_READ, 0, &mapped); + + for (int y = 0; y < mSize.height; y++) { + memcpy(mappedSurface.mData + mappedSurface.mStride * y, + (unsigned char*)(mapped.pData) + mapped.RowPitch * y, + mSize.width * 4); + } + + softTexture->Unmap(0); + surface->Unmap(); + + return surface; +} + TextureD3D10BackendData* RemoteDXGITextureImage::GetD3D10TextureBackendData(ID3D10Device *aDevice) { diff --git a/gfx/layers/d3d10/ImageLayerD3D10.h b/gfx/layers/d3d10/ImageLayerD3D10.h index 93fb8cfddcb..6041d9f7d89 100644 --- a/gfx/layers/d3d10/ImageLayerD3D10.h +++ b/gfx/layers/d3d10/ImageLayerD3D10.h @@ -61,6 +61,7 @@ public: RemoteDXGITextureImage() : Image(nullptr, REMOTE_IMAGE_DXGI_TEXTURE) {} already_AddRefed DeprecatedGetAsSurface(); + virtual TemporaryRef GetAsSourceSurface() MOZ_OVERRIDE; IntSize GetSize() { return mSize; } From da3e302179603fc0b026fc42e2587f8c1cdac467 Mon Sep 17 00:00:00 2001 From: Haitao Feng Date: Tue, 28 Jan 2014 09:12:20 -0500 Subject: [PATCH 044/296] Bug 947711 - Introduce MIRType_Float32x4, MIRType_Int32x4 and MIRType_Doublex2. r=nbp --- js/src/jit/IonTypes.h | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/js/src/jit/IonTypes.h b/js/src/jit/IonTypes.h index c2a51426cef..f615f6e3538 100644 --- a/js/src/jit/IonTypes.h +++ b/js/src/jit/IonTypes.h @@ -62,6 +62,13 @@ BailoutKindString(BailoutKind kind) } #endif +static const uint32_t ELEMENT_TYPE_BITS = 4; +static const uint32_t ELEMENT_TYPE_SHIFT = 0; +static const uint32_t ELEMENT_TYPE_MASK = (1 << ELEMENT_TYPE_BITS) - 1; +static const uint32_t VECTOR_SCALE_BITS = 2; +static const uint32_t VECTOR_SCALE_SHIFT = ELEMENT_TYPE_BITS + ELEMENT_TYPE_SHIFT; +static const uint32_t VECTOR_SCALE_MASK = (1 << VECTOR_SCALE_BITS) - 1; + // The ordering of this enumeration is important: Anything < Value is a // specialized type. Furthermore, anything < String has trivial conversion to // a number. @@ -77,14 +84,31 @@ enum MIRType MIRType_Object, MIRType_Magic, MIRType_Value, - MIRType_None, // Invalid, used as a placeholder. - MIRType_Slots, // A slots vector - MIRType_Elements, // An elements vector - MIRType_Pointer, // An opaque pointer that receives no special treatment - MIRType_Shape, // A Shape pointer. - MIRType_ForkJoinSlice // js::ForkJoinSlice* + MIRType_None, // Invalid, used as a placeholder. + MIRType_Slots, // A slots vector + MIRType_Elements, // An elements vector + MIRType_Pointer, // An opaque pointer that receives no special treatment + MIRType_Shape, // A Shape pointer. + MIRType_ForkJoinSlice, // js::ForkJoinSlice* + MIRType_Last = MIRType_ForkJoinSlice, + MIRType_Float32x4 = MIRType_Float32 | (2 << VECTOR_SCALE_SHIFT), + MIRType_Int32x4 = MIRType_Int32 | (2 << VECTOR_SCALE_SHIFT), + MIRType_Doublex2 = MIRType_Double | (1 << VECTOR_SCALE_SHIFT) }; +static inline MIRType +ElementType(MIRType type) +{ + JS_STATIC_ASSERT(MIRType_Last <= ELEMENT_TYPE_MASK); + return static_cast((type >> ELEMENT_TYPE_SHIFT) & ELEMENT_TYPE_MASK); +} + +static inline uint32_t +VectorSize(MIRType type) +{ + return 1 << ((type >> VECTOR_SCALE_SHIFT) & VECTOR_SCALE_MASK); +} + static inline MIRType MIRTypeFromValueType(JSValueType type) { From 4086562d804f4b1003da5791af86651f25099703 Mon Sep 17 00:00:00 2001 From: Dan Glastonbury Date: Fri, 24 Jan 2014 13:59:33 +1000 Subject: [PATCH 045/296] Bug 953221 - Minor erroneous complete check fails. r=bjacob --- content/canvas/src/WebGLContext.cpp | 75 +++++++++++++------------ content/canvas/src/WebGLFramebuffer.cpp | 8 +-- content/canvas/src/WebGLFramebuffer.h | 2 +- 3 files changed, 45 insertions(+), 40 deletions(-) diff --git a/content/canvas/src/WebGLContext.cpp b/content/canvas/src/WebGLContext.cpp index fe83ffb8a36..da356631e09 100644 --- a/content/canvas/src/WebGLContext.cpp +++ b/content/canvas/src/WebGLContext.cpp @@ -1043,50 +1043,55 @@ WebGLContext::ForceClearFramebufferWithDefaultValues(GLbitfield mask, const bool // Dither shouldn't matter when we're clearing to {0,0,0,0}. MOZ_ASSERT(gl->fIsEnabled(LOCAL_GL_SCISSOR_TEST) == mScissorTestEnabled); - realGLboolean colorWriteMask[4] = {2, 2, 2, 2}; - GLfloat colorClearValue[4] = {-1.0f, -1.0f, -1.0f, -1.0f}; + if (initializeColorBuffer) { + realGLboolean colorWriteMask[4] = {2, 2, 2, 2}; + GLfloat colorClearValue[4] = {-1.0f, -1.0f, -1.0f, -1.0f}; - gl->fGetBooleanv(LOCAL_GL_COLOR_WRITEMASK, colorWriteMask); - gl->fGetFloatv(LOCAL_GL_COLOR_CLEAR_VALUE, colorClearValue); + gl->fGetBooleanv(LOCAL_GL_COLOR_WRITEMASK, colorWriteMask); + gl->fGetFloatv(LOCAL_GL_COLOR_CLEAR_VALUE, colorClearValue); - MOZ_ASSERT(colorWriteMask[0] == mColorWriteMask[0] && - colorWriteMask[1] == mColorWriteMask[1] && - colorWriteMask[2] == mColorWriteMask[2] && - colorWriteMask[3] == mColorWriteMask[3]); - MOZ_ASSERT(IsShadowCorrect(mColorClearValue[0], colorClearValue[0]) && - IsShadowCorrect(mColorClearValue[1], colorClearValue[1]) && - IsShadowCorrect(mColorClearValue[2], colorClearValue[2]) && - IsShadowCorrect(mColorClearValue[3], colorClearValue[3])); + MOZ_ASSERT(colorWriteMask[0] == mColorWriteMask[0] && + colorWriteMask[1] == mColorWriteMask[1] && + colorWriteMask[2] == mColorWriteMask[2] && + colorWriteMask[3] == mColorWriteMask[3]); + MOZ_ASSERT(IsShadowCorrect(mColorClearValue[0], colorClearValue[0]) && + IsShadowCorrect(mColorClearValue[1], colorClearValue[1]) && + IsShadowCorrect(mColorClearValue[2], colorClearValue[2]) && + IsShadowCorrect(mColorClearValue[3], colorClearValue[3])); + } + + if (initializeDepthBuffer) { + realGLboolean depthWriteMask = 2; + GLfloat depthClearValue = -1.0f; - realGLboolean depthWriteMask = 2; - GLfloat depthClearValue = -1.0f; + gl->fGetBooleanv(LOCAL_GL_DEPTH_WRITEMASK, &depthWriteMask); + gl->fGetFloatv(LOCAL_GL_DEPTH_CLEAR_VALUE, &depthClearValue); - gl->fGetBooleanv(LOCAL_GL_DEPTH_WRITEMASK, &depthWriteMask); - gl->fGetFloatv(LOCAL_GL_DEPTH_CLEAR_VALUE, &depthClearValue); + MOZ_ASSERT(depthWriteMask == mDepthWriteMask); + MOZ_ASSERT(IsShadowCorrect(mDepthClearValue, depthClearValue)); + } - MOZ_ASSERT(depthWriteMask == mDepthWriteMask); - MOZ_ASSERT(IsShadowCorrect(mDepthClearValue, depthClearValue)); + if (initializeStencilBuffer) { + GLuint stencilWriteMaskFront = 0xdeadbad1; + GLuint stencilWriteMaskBack = 0xdeadbad1; + GLuint stencilClearValue = 0xdeadbad1; + gl->GetUIntegerv(LOCAL_GL_STENCIL_WRITEMASK, &stencilWriteMaskFront); + gl->GetUIntegerv(LOCAL_GL_STENCIL_BACK_WRITEMASK, &stencilWriteMaskBack); + gl->GetUIntegerv(LOCAL_GL_STENCIL_CLEAR_VALUE, &stencilClearValue); - GLuint stencilWriteMaskFront = 0xdeadbad1; - GLuint stencilWriteMaskBack = 0xdeadbad1; - GLuint stencilClearValue = 0xdeadbad1; + GLuint stencilBits = 0; + gl->GetUIntegerv(LOCAL_GL_STENCIL_BITS, &stencilBits); + GLuint stencilMask = (GLuint(1) << stencilBits) - 1; - gl->GetUIntegerv(LOCAL_GL_STENCIL_WRITEMASK, &stencilWriteMaskFront); - gl->GetUIntegerv(LOCAL_GL_STENCIL_BACK_WRITEMASK, &stencilWriteMaskBack); - gl->GetUIntegerv(LOCAL_GL_STENCIL_CLEAR_VALUE, &stencilClearValue); - - GLuint stencilBits = 0; - gl->GetUIntegerv(LOCAL_GL_STENCIL_BITS, &stencilBits); - GLuint stencilMask = (GLuint(1) << stencilBits) - 1; - - MOZ_ASSERT( ( stencilWriteMaskFront & stencilMask) == - (mStencilWriteMaskFront & stencilMask) ); - MOZ_ASSERT( ( stencilWriteMaskBack & stencilMask) == - (mStencilWriteMaskBack & stencilMask) ); - MOZ_ASSERT( ( stencilClearValue & stencilMask) == - (mStencilClearValue & stencilMask) ); + MOZ_ASSERT( ( stencilWriteMaskFront & stencilMask) == + (mStencilWriteMaskFront & stencilMask) ); + MOZ_ASSERT( ( stencilWriteMaskBack & stencilMask) == + (mStencilWriteMaskBack & stencilMask) ); + MOZ_ASSERT( ( stencilClearValue & stencilMask) == + (mStencilClearValue & stencilMask) ); + } } #endif diff --git a/content/canvas/src/WebGLFramebuffer.cpp b/content/canvas/src/WebGLFramebuffer.cpp index e0b4ae2d934..9a257f07372 100644 --- a/content/canvas/src/WebGLFramebuffer.cpp +++ b/content/canvas/src/WebGLFramebuffer.cpp @@ -330,7 +330,7 @@ WebGLFramebuffer::FramebufferRenderbuffer(GLenum target, break; default: // finish checking that the 'attachment' parameter is among the allowed values - if (!CheckColorAttachementNumber(attachment, "framebufferRenderbuffer")){ + if (!CheckColorAttachmentNumber(attachment, "framebufferRenderbuffer")){ return; } @@ -387,7 +387,7 @@ WebGLFramebuffer::FramebufferTexture2D(GLenum target, mDepthStencilAttachment.SetTexImage(wtex, textarget, level); break; default: - if (!CheckColorAttachementNumber(attachment, "framebufferTexture2D")) + if (!CheckColorAttachmentNumber(attachment, "framebufferTexture2D")) return; size_t colorAttachmentId = size_t(attachment - LOCAL_GL_COLOR_ATTACHMENT0); @@ -407,7 +407,7 @@ WebGLFramebuffer::GetAttachment(GLenum attachment) const if (attachment == LOCAL_GL_STENCIL_ATTACHMENT) return mStencilAttachment; - if (!CheckColorAttachementNumber(attachment, "getAttachment")) { + if (!CheckColorAttachmentNumber(attachment, "getAttachment")) { MOZ_ASSERT(false); return mColorAttachments[0]; } @@ -677,7 +677,7 @@ WebGLFramebuffer::CheckAndInitializeAttachments() return true; } -bool WebGLFramebuffer::CheckColorAttachementNumber(GLenum attachment, const char* functionName) const +bool WebGLFramebuffer::CheckColorAttachmentNumber(GLenum attachment, const char* functionName) const { const char* const errorFormating = "%s: attachment: invalid enum value 0x%x"; diff --git a/content/canvas/src/WebGLFramebuffer.h b/content/canvas/src/WebGLFramebuffer.h index ef359ed52e2..282f36ae5a0 100644 --- a/content/canvas/src/WebGLFramebuffer.h +++ b/content/canvas/src/WebGLFramebuffer.h @@ -168,7 +168,7 @@ public: bool CheckAndInitializeAttachments(); - bool CheckColorAttachementNumber(GLenum attachment, const char* functionName) const; + bool CheckColorAttachmentNumber(GLenum attachment, const char* functionName) const; GLuint mGLName; bool mHasEverBeenBound; From ba8d11d8f9403cac4c23c0786bbf8648f17f3fe4 Mon Sep 17 00:00:00 2001 From: Dan Glastonbury Date: Fri, 24 Jan 2014 14:01:10 +1000 Subject: [PATCH 046/296] Bug 953221 - Disable glDrawBuffer/glReadBuffer when no color attachment. r=bjacob This is mainly for OSX where the OGL version requires this so that the framebuffer complete checks pass. --- content/canvas/src/WebGLContextGL.cpp | 12 ++++++++++++ content/canvas/src/WebGLFramebuffer.cpp | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/content/canvas/src/WebGLContextGL.cpp b/content/canvas/src/WebGLContextGL.cpp index 457902904f5..936d3b0ffbd 100644 --- a/content/canvas/src/WebGLContextGL.cpp +++ b/content/canvas/src/WebGLContextGL.cpp @@ -206,6 +206,18 @@ WebGLContext::BindFramebuffer(GLenum target, WebGLFramebuffer *wfb) if (!wfb) { gl->fBindFramebuffer(target, 0); + + // Restore draw/read buffers when switching back to default + // render target. + GLint drawBuffer = LOCAL_GL_COLOR_ATTACHMENT0; + gl->fGetIntegerv(LOCAL_GL_DRAW_BUFFER, &drawBuffer); + if (drawBuffer == LOCAL_GL_NONE) + gl->fDrawBuffer(LOCAL_GL_COLOR_ATTACHMENT0); + + GLint readBuffer = LOCAL_GL_COLOR_ATTACHMENT0; + gl->fGetIntegerv(LOCAL_GL_READ_BUFFER, &readBuffer); + if (readBuffer == LOCAL_GL_NONE) + gl->fReadBuffer(LOCAL_GL_COLOR_ATTACHMENT0); } else { GLuint framebuffername = wfb->GLName(); gl->fBindFramebuffer(target, framebuffername); diff --git a/content/canvas/src/WebGLFramebuffer.cpp b/content/canvas/src/WebGLFramebuffer.cpp index 9a257f07372..51a89515a54 100644 --- a/content/canvas/src/WebGLFramebuffer.cpp +++ b/content/canvas/src/WebGLFramebuffer.cpp @@ -727,6 +727,11 @@ WebGLFramebuffer::FinalizeAttachments() const ColorAttachment(i).FinalizeAttachment(LOCAL_GL_COLOR_ATTACHMENT0 + i); } + GLenum colorBufferSource = + ColorAttachment(0).IsDefined() ? LOCAL_GL_COLOR_ATTACHMENT0 : LOCAL_GL_NONE; + mContext->gl->fDrawBuffer(colorBufferSource); + mContext->gl->fReadBuffer(colorBufferSource); + if (DepthAttachment().IsDefined()) DepthAttachment().FinalizeAttachment(LOCAL_GL_DEPTH_ATTACHMENT); From b098c3e967d1493e0d983f8093470ddb7ac25127 Mon Sep 17 00:00:00 2001 From: Dan Glastonbury Date: Fri, 24 Jan 2014 14:02:07 +1000 Subject: [PATCH 047/296] Bug 953221 - Split out DRAW_BUFFER/READ_BUFFER state setup. r=bjacob --- content/canvas/src/WebGLContextGL.cpp | 12 --------- content/canvas/src/WebGLFramebuffer.cpp | 35 +++++++++++++++++++++---- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/content/canvas/src/WebGLContextGL.cpp b/content/canvas/src/WebGLContextGL.cpp index 936d3b0ffbd..457902904f5 100644 --- a/content/canvas/src/WebGLContextGL.cpp +++ b/content/canvas/src/WebGLContextGL.cpp @@ -206,18 +206,6 @@ WebGLContext::BindFramebuffer(GLenum target, WebGLFramebuffer *wfb) if (!wfb) { gl->fBindFramebuffer(target, 0); - - // Restore draw/read buffers when switching back to default - // render target. - GLint drawBuffer = LOCAL_GL_COLOR_ATTACHMENT0; - gl->fGetIntegerv(LOCAL_GL_DRAW_BUFFER, &drawBuffer); - if (drawBuffer == LOCAL_GL_NONE) - gl->fDrawBuffer(LOCAL_GL_COLOR_ATTACHMENT0); - - GLint readBuffer = LOCAL_GL_COLOR_ATTACHMENT0; - gl->fGetIntegerv(LOCAL_GL_READ_BUFFER, &readBuffer); - if (readBuffer == LOCAL_GL_NONE) - gl->fReadBuffer(LOCAL_GL_COLOR_ATTACHMENT0); } else { GLuint framebuffername = wfb->GLName(); gl->fBindFramebuffer(target, framebuffername); diff --git a/content/canvas/src/WebGLFramebuffer.cpp b/content/canvas/src/WebGLFramebuffer.cpp index 51a89515a54..558dbbb0ce9 100644 --- a/content/canvas/src/WebGLFramebuffer.cpp +++ b/content/canvas/src/WebGLFramebuffer.cpp @@ -719,6 +719,34 @@ void WebGLFramebuffer::EnsureColorAttachments(size_t colorAttachmentId) } } +static void +FinalizeDrawAndReadBuffers(GLContext* aGL, bool aColorBufferDefined) +{ + MOZ_ASSERT(aGL, "Expected a valid GLContext ptr."); + // GLES don't support DrawBuffer()/ReadBuffer. + // According to http://www.opengl.org/wiki/Framebuffer_Object + // + // Each draw buffers must either specify color attachment points that have images + // attached or must be GL_NONE​. (GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER​ when false). + // + // If the read buffer is set, then it must specify an attachment point that has an + // image attached. (GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER​ when false). + // + // Note that this test is not performed if OpenGL 4.2 or ARB_ES2_compatibility is + // available. + if (aGL->IsGLES2() || + aGL->IsSupported(GLFeature::ES2_compatibility) || + aGL->IsAtLeast(ContextProfile::OpenGL, 420)) + { + return; + } + + // TODO(djg): Assert that fDrawBuffer/fReadBuffer is not NULL. + GLenum colorBufferSource = aColorBufferDefined ? LOCAL_GL_COLOR_ATTACHMENT0 : LOCAL_GL_NONE; + aGL->fDrawBuffer(colorBufferSource); + aGL->fReadBuffer(colorBufferSource); +} + void WebGLFramebuffer::FinalizeAttachments() const { @@ -727,11 +755,6 @@ WebGLFramebuffer::FinalizeAttachments() const ColorAttachment(i).FinalizeAttachment(LOCAL_GL_COLOR_ATTACHMENT0 + i); } - GLenum colorBufferSource = - ColorAttachment(0).IsDefined() ? LOCAL_GL_COLOR_ATTACHMENT0 : LOCAL_GL_NONE; - mContext->gl->fDrawBuffer(colorBufferSource); - mContext->gl->fReadBuffer(colorBufferSource); - if (DepthAttachment().IsDefined()) DepthAttachment().FinalizeAttachment(LOCAL_GL_DEPTH_ATTACHMENT); @@ -740,6 +763,8 @@ WebGLFramebuffer::FinalizeAttachments() const if (DepthStencilAttachment().IsDefined()) DepthStencilAttachment().FinalizeAttachment(LOCAL_GL_DEPTH_STENCIL_ATTACHMENT); + + FinalizeDrawAndReadBuffers(mContext->gl, ColorAttachment(0).IsDefined()); } inline void From b38b5e6a7627b64b7dfa0b316f001fb90d27b9c8 Mon Sep 17 00:00:00 2001 From: Dan Glastonbury Date: Wed, 22 Jan 2014 19:21:19 +1000 Subject: [PATCH 048/296] Bug 953221 - GLenum to C string helper. r=bjacob --- gfx/gl/GLDebugUtils.cpp | 59 +++++++++++++++++++++++++++++++++++++++++ gfx/gl/GLDebugUtils.h | 19 +++++++++++++ gfx/gl/moz.build | 1 + 3 files changed, 79 insertions(+) create mode 100644 gfx/gl/GLDebugUtils.cpp create mode 100644 gfx/gl/GLDebugUtils.h diff --git a/gfx/gl/GLDebugUtils.cpp b/gfx/gl/GLDebugUtils.cpp new file mode 100644 index 00000000000..cc8c611d4ca --- /dev/null +++ b/gfx/gl/GLDebugUtils.cpp @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "GLDebugUtils.h" +#include "GLConsts.h" + +namespace mozilla { +namespace gl { + +const char* +GLenumToStr(GLenum e) { + switch (e) { +#define HANDLE_GL_ENUM(x) case LOCAL_##x: return #x + HANDLE_GL_ENUM(GL_TRIANGLES); + HANDLE_GL_ENUM(GL_TRIANGLE_STRIP); + HANDLE_GL_ENUM(GL_TRIANGLE_FAN); + HANDLE_GL_ENUM(GL_FRAMEBUFFER); + HANDLE_GL_ENUM(GL_RENDERBUFFER); + HANDLE_GL_ENUM(GL_DEPTH_ATTACHMENT); + HANDLE_GL_ENUM(GL_STENCIL_ATTACHMENT); + HANDLE_GL_ENUM(GL_DEPTH_STENCIL_ATTACHMENT); + HANDLE_GL_ENUM(GL_TEXTURE_2D); + HANDLE_GL_ENUM(GL_TEXTURE_CUBE_MAP_NEGATIVE_X); + HANDLE_GL_ENUM(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y); + HANDLE_GL_ENUM(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z); + HANDLE_GL_ENUM(GL_TEXTURE_CUBE_MAP_POSITIVE_X); + HANDLE_GL_ENUM(GL_TEXTURE_CUBE_MAP_POSITIVE_Y); + HANDLE_GL_ENUM(GL_TEXTURE_CUBE_MAP_POSITIVE_Z); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT0); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT1); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT2); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT3); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT4); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT5); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT6); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT7); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT8); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT9); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT10); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT11); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT12); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT13); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT14); + HANDLE_GL_ENUM(GL_COLOR_ATTACHMENT15); + HANDLE_GL_ENUM(GL_UNSIGNED_BYTE); + HANDLE_GL_ENUM(GL_UNSIGNED_SHORT); + HANDLE_GL_ENUM(GL_UNSIGNED_INT); + HANDLE_GL_ENUM(GL_RGBA); + HANDLE_GL_ENUM(GL_DEPTH_COMPONENT); +#undef HANDLE_GL_ENUM + } + + return "(unknown)"; +} + +} // namespace gl +} // namespace mozilla diff --git a/gfx/gl/GLDebugUtils.h b/gfx/gl/GLDebugUtils.h new file mode 100644 index 00000000000..d828492526e --- /dev/null +++ b/gfx/gl/GLDebugUtils.h @@ -0,0 +1,19 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef GLDEBUGUTILS_H_ +#define GLDEBUGUTILS_H_ + +#include "GLTypes.h" + +namespace mozilla { +namespace gl { + +const char* GLenumToStr(GLenum e); + +} // namespace gl +} // namespace mozilla + +#endif // !GLDEBUGUTILS_H_ diff --git a/gfx/gl/moz.build b/gfx/gl/moz.build index b3f9ab2847e..64e90c38332 100644 --- a/gfx/gl/moz.build +++ b/gfx/gl/moz.build @@ -121,6 +121,7 @@ UNIFIED_SOURCES += [ 'GLContext.cpp', 'GLContextFeatures.cpp', 'GLContextTypes.cpp', + 'GLDebugUtils.cpp', 'GLLibraryEGL.cpp', 'GLLibraryLoader.cpp', 'GLReadTexImageHelper.cpp', From 7370bd6e93b9e0ba18d889adf2daeac510f8bad4 Mon Sep 17 00:00:00 2001 From: Ali Akhtarzada Date: Tue, 28 Jan 2014 09:13:58 -0500 Subject: [PATCH 049/296] Bug 961713 - Implement GrallocImage::GetAsSourceSurface. r=nical --- gfx/layers/GrallocImages.cpp | 95 ++++++++++++++++++++++++++++++++++++ gfx/layers/GrallocImages.h | 1 + 2 files changed, 96 insertions(+) diff --git a/gfx/layers/GrallocImages.cpp b/gfx/layers/GrallocImages.cpp index 58810151c9b..b5c822e150c 100644 --- a/gfx/layers/GrallocImages.cpp +++ b/gfx/layers/GrallocImages.cpp @@ -284,6 +284,101 @@ GrallocImage::DeprecatedGetAsSurface() return imageSurface.forget(); } +TemporaryRef +GrallocImage::GetAsSourceSurface() +{ + android::sp graphicBuffer = + GrallocBufferActor::GetFrom(GetSurfaceDescriptor()); + + void *buffer; + int32_t rv = + graphicBuffer->lock(android::GraphicBuffer::USAGE_SW_READ_OFTEN, &buffer); + + if (rv) { + NS_WARNING("Couldn't lock graphic buffer"); + return nullptr; + } + + GraphicBufferAutoUnlock unlock(graphicBuffer); + + uint32_t format = graphicBuffer->getPixelFormat(); + uint32_t omxFormat = 0; + + for (int i = 0; sColorIdMap[i]; i += 2) { + if (sColorIdMap[i] == format) { + omxFormat = sColorIdMap[i + 1]; + break; + } + } + + if (!omxFormat) { + NS_WARNING("Unknown color format"); + return nullptr; + } + + RefPtr surface + = gfx::Factory::CreateDataSourceSurface(GetSize(), gfx::SurfaceFormat::R5G6B5); + + uint32_t width = GetSize().width; + uint32_t height = GetSize().height; + + gfx::DataSourceSurface::MappedSurface mappedSurface; + if (!surface->Map(gfx::DataSourceSurface::WRITE, &mappedSurface)) { + NS_WARNING("Could not map DataSourceSurface"); + return nullptr; + } + + if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO) { + // The Adreno hardware decoder aligns image dimensions to a multiple of 32, + // so we have to account for that here + uint32_t alignedWidth = ALIGN(width, 32); + uint32_t alignedHeight = ALIGN(height, 32); + uint32_t uvOffset = ALIGN(alignedHeight * alignedWidth, 4096); + uint32_t uvStride = 2 * ALIGN(width / 2, 32); + uint8_t* buffer_as_bytes = static_cast(buffer); + ConvertYVU420SPToRGB565(buffer, alignedWidth, + buffer_as_bytes + uvOffset, uvStride, + mappedSurface.mData, + width, height); + + surface->Unmap(); + return surface; + } + else if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP) { + uint32_t uvOffset = height * width; + ConvertYVU420SPToRGB565(buffer, width, + buffer + uvOffset, width, + mappedSurface.mData, + width, height); + + surface->Unmap(); + return surface; + } + + android::ColorConverter colorConverter((OMX_COLOR_FORMATTYPE)omxFormat, + OMX_COLOR_Format16bitRGB565); + + if (!colorConverter.isValid()) { + NS_WARNING("Invalid color conversion"); + return nullptr; + } + + rv = colorConverter.convert(buffer, width, height, + 0, 0, width - 1, height - 1 /* source crop */, + mappedSurface.mData, width, height, + 0, 0, width - 1, height - 1 /* dest crop */); + + surface->Unmap(); + + if (rv) { + NS_WARNING("OMX color conversion failed"); + return nullptr; + } + + return surface; +} + + TextureClient* GrallocImage::GetTextureClient() { diff --git a/gfx/layers/GrallocImages.h b/gfx/layers/GrallocImages.h index abece19527f..20cfdf38018 100644 --- a/gfx/layers/GrallocImages.h +++ b/gfx/layers/GrallocImages.h @@ -127,6 +127,7 @@ public: }; virtual already_AddRefed DeprecatedGetAsSurface(); + virtual TemporaryRef GetAsSourceSurface() MOZ_OVERRIDE; void* GetNativeBuffer() { From 1abf911f0391b9d6115bad4832ca2e580c241b7a Mon Sep 17 00:00:00 2001 From: Ali Akhtarzada Date: Tue, 28 Jan 2014 09:14:10 -0500 Subject: [PATCH 050/296] Bug 961715 - Implement D3D9SurfaceImage::GetAsSourceSurface. r=nical --- gfx/layers/D3D9SurfaceImage.cpp | 62 +++++++++++++++++++++++++++++++++ gfx/layers/D3D9SurfaceImage.h | 1 + 2 files changed, 63 insertions(+) diff --git a/gfx/layers/D3D9SurfaceImage.cpp b/gfx/layers/D3D9SurfaceImage.cpp index 61e50876d6a..dec7bd96c5a 100644 --- a/gfx/layers/D3D9SurfaceImage.cpp +++ b/gfx/layers/D3D9SurfaceImage.cpp @@ -172,5 +172,67 @@ D3D9SurfaceImage::DeprecatedGetAsSurface() return surface.forget(); } +TemporaryRef +D3D9SurfaceImage::GetAsSourceSurface() +{ + NS_ENSURE_TRUE(mTexture, nullptr); + + HRESULT hr; + RefPtr surface = gfx::Factory::CreateDataSourceSurface(mSize, gfx::SurfaceFormat::B8G8R8X8); + + if (!surface) { + NS_WARNING("Failed to created SourceSurface for D3D9SurfaceImage."); + return nullptr; + } + + // Ensure that the texture is ready to be used. + EnsureSynchronized(); + + // Readback the texture from GPU memory into system memory, so that + // we can copy it into the Cairo image. This is expensive. + RefPtr textureSurface; + hr = mTexture->GetSurfaceLevel(0, byRef(textureSurface)); + NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr); + + RefPtr device; + hr = mTexture->GetDevice(byRef(device)); + NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr); + + RefPtr systemMemorySurface; + hr = device->CreateOffscreenPlainSurface(mDesc.Width, + mDesc.Height, + D3DFMT_X8R8G8B8, + D3DPOOL_SYSTEMMEM, + byRef(systemMemorySurface), + 0); + NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr); + + hr = device->GetRenderTargetData(textureSurface, systemMemorySurface); + NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr); + + D3DLOCKED_RECT rect; + hr = systemMemorySurface->LockRect(&rect, nullptr, 0); + NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr); + + gfx::DataSourceSurface::MappedSurface mappedSurface; + if (!surface->Map(gfx::DataSourceSurface::WRITE, &mappedSurface)) { + systemMemorySurface->UnlockRect(); + return nullptr; + } + + const unsigned char* src = (const unsigned char*)(rect.pBits); + const unsigned srcPitch = rect.Pitch; + for (int y = 0; y < mSize.height; y++) { + memcpy(mappedSurface.mData + mappedSurface.mStride * y, + (unsigned char*)(src) + srcPitch * y, + mSize.width * 4); + } + + systemMemorySurface->UnlockRect(); + surface->Unmap(); + + return surface; +} + } /* layers */ } /* mozilla */ diff --git a/gfx/layers/D3D9SurfaceImage.h b/gfx/layers/D3D9SurfaceImage.h index 82dc5597dc9..ae7a1cbf31d 100644 --- a/gfx/layers/D3D9SurfaceImage.h +++ b/gfx/layers/D3D9SurfaceImage.h @@ -47,6 +47,7 @@ public: gfx::IntSize GetSize() MOZ_OVERRIDE; already_AddRefed DeprecatedGetAsSurface() MOZ_OVERRIDE; + virtual TemporaryRef GetAsSourceSurface() MOZ_OVERRIDE; private: From 19bc2255089b16e2670da7263fbc839f0e272cf6 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Tue, 28 Jan 2014 09:15:24 -0500 Subject: [PATCH 051/296] Bug 964078. r=roc --- layout/generic/nsBulletFrame.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/layout/generic/nsBulletFrame.cpp b/layout/generic/nsBulletFrame.cpp index 1f46464bd87..ab43066ca1c 100644 --- a/layout/generic/nsBulletFrame.cpp +++ b/layout/generic/nsBulletFrame.cpp @@ -7,6 +7,7 @@ #include "nsBulletFrame.h" +#include "mozilla/MathAlgorithms.h" #include "nsCOMPtr.h" #include "nsGkAtoms.h" #include "nsGenericHTMLElement.h" @@ -897,18 +898,16 @@ static const CJKIdeographicData gDataTradChineseFormal = { false // informal }; -static const bool CJKIdeographicToText(int32_t ordinal, nsString& result, +static const bool CJKIdeographicToText(int32_t aOrdinal, nsString& result, const CJKIdeographicData& data) { char16_t buf[NUM_BUF_SIZE]; int32_t idx = NUM_BUF_SIZE; int32_t pos = 0; - bool isNegative = (ordinal < 0); - bool needZero = (ordinal == 0); + bool isNegative = (aOrdinal < 0); + bool needZero = (aOrdinal == 0); int32_t unitidx = 0, unit10Kidx = 0; - if (isNegative) { - ordinal = -ordinal; - } + uint32_t ordinal = mozilla::Abs(aOrdinal); do { unitidx = pos % 4; if (unitidx == 0) { From 25952d17e40553036f30c9cb3a88cd5a9d13d00c Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Tue, 28 Jan 2014 15:33:53 +0100 Subject: [PATCH 052/296] Bug 959597 part 1 - ARM simulator build changes. r=glandium --- js/src/configure.in | 32 ++++++++++++++++++++++++++++++++ js/src/moz.build | 14 +++++++++----- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/js/src/configure.in b/js/src/configure.in index bf9a5c1d735..10b30f2c318 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -3414,6 +3414,38 @@ if test -n "$MOZ_VALGRIND"; then fi AC_SUBST(MOZ_VALGRIND) +dnl ======================================================== +dnl = Use ARM JIT code simulator. Requires an x86 build. +dnl ======================================================== +dnl Also define JS_CODEGEN_ARM in this case. If the simulator is not used, +dnl JS_CODEGEN_foo is defined if JS_CPU_foo is defined. +MOZ_ARG_ENABLE_BOOL(arm-simulator, +[ --enable-arm-simulator Enable ARM simulator for JIT code], + JS_ARM_SIMULATOR=1, + JS_ARM_SIMULATOR= ) +if test -n "$JS_ARM_SIMULATOR"; then + if test "$CPU_ARCH" != "x86"; then + AC_MSG_ERROR([The ARM simulator only works on x86.]) + fi + AC_DEFINE(JS_ARM_SIMULATOR) + AC_DEFINE(JS_CODEGEN_ARM) + JS_CODEGEN_ARM=1 +elif test "$CPU_ARCH" = "x86"; then + AC_DEFINE(JS_CODEGEN_X86) + JS_CODEGEN_X86=1 +elif test "$CPU_ARCH" = "x86_64"; then + AC_DEFINE(JS_CODEGEN_X64) + JS_CODEGEN_X64=1 +elif test "$CPU_ARCH" = "arm"; then + AC_DEFINE(JS_CODEGEN_ARM) + JS_CODEGEN_ARM=1 +fi + +AC_SUBST(JS_ARM_SIMULATOR) +AC_SUBST(JS_CODEGEN_ARM) +AC_SUBST(JS_CODEGEN_X86) +AC_SUBST(JS_CODEGEN_X64) + dnl ======================================================== dnl jprof dnl ======================================================== diff --git a/js/src/moz.build b/js/src/moz.build index 1265db456b8..d465e81fe07 100644 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -281,7 +281,7 @@ if CONFIG['ENABLE_ION']: 'jit/ValueNumbering.cpp', 'jit/VMFunctions.cpp', ] - if CONFIG['TARGET_CPU'].find('86') != -1: + if CONFIG['JS_CODEGEN_X86'] or CONFIG['JS_CODEGEN_X64']: UNIFIED_SOURCES += [ 'jit/shared/Assembler-x86-shared.cpp', 'jit/shared/BaselineCompiler-x86-shared.cpp', @@ -290,7 +290,7 @@ if CONFIG['ENABLE_ION']: 'jit/shared/Lowering-x86-shared.cpp', 'jit/shared/MoveEmitter-x86-shared.cpp', ] - if CONFIG['TARGET_CPU'] == 'x86_64': + if CONFIG['JS_CODEGEN_X64']: UNIFIED_SOURCES += [ 'jit/x64/Assembler-x64.cpp', 'jit/x64/Bailouts-x64.cpp', @@ -312,7 +312,7 @@ if CONFIG['ENABLE_ION']: 'jit/x86/MacroAssembler-x86.cpp', 'jit/x86/Trampoline-x86.cpp', ] - elif CONFIG['TARGET_CPU'].find('arm') != -1: + elif CONFIG['JS_CODEGEN_ARM']: UNIFIED_SOURCES += [ 'jit/arm/Architecture-arm.cpp', 'jit/arm/Assembler-arm.cpp', @@ -325,6 +325,10 @@ if CONFIG['ENABLE_ION']: 'jit/arm/MoveEmitter-arm.cpp', 'jit/arm/Trampoline-arm.cpp', ] + if CONFIG['JS_ARM_SIMULATOR']: + UNIFIED_SOURCES += [ + 'jit/arm/Simulator-arm.cpp' + ] if CONFIG['OS_ARCH'] == 'WINNT': SOURCES += [ @@ -343,11 +347,11 @@ else: ] if CONFIG['ENABLE_ION'] or CONFIG['ENABLE_YARR_JIT']: - if '86' in CONFIG['TARGET_CPU']: + if CONFIG['JS_CODEGEN_X86'] or CONFIG['JS_CODEGEN_X64']: SOURCES += [ 'assembler/assembler/MacroAssemblerX86Common.cpp', ] - elif CONFIG['CPU_ARCH'] == 'arm': + elif CONFIG['JS_CODEGEN_ARM']: SOURCES += [ 'assembler/assembler/ARMAssembler.cpp', 'assembler/assembler/MacroAssemblerARM.cpp', From 7b93750e86aab772676b047e3918917e51d38f2c Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Tue, 28 Jan 2014 15:33:56 +0100 Subject: [PATCH 053/296] Bug 959597 part 2 - Use JS_CODEGEN_* instead of JS_CPU_* for JIT backend code. r=nbp --- js/src/jit/AsmJS.cpp | 48 +++++++++---------- js/src/jit/AsmJS.h | 2 +- js/src/jit/AsmJSModule.cpp | 14 +++--- js/src/jit/AsmJSSignalHandlers.cpp | 18 +++---- js/src/jit/BaselineBailouts.cpp | 6 +-- js/src/jit/BaselineCompiler.cpp | 2 +- js/src/jit/BaselineCompiler.h | 4 +- js/src/jit/BaselineHelpers.h | 6 +-- js/src/jit/BaselineIC.cpp | 4 +- js/src/jit/BaselineIC.h | 4 +- js/src/jit/BaselineRegisters.h | 4 +- js/src/jit/CodeGenerator.cpp | 2 +- js/src/jit/CodeGenerator.h | 6 +-- js/src/jit/IonCaches.cpp | 4 +- js/src/jit/IonCaches.h | 14 +++--- js/src/jit/IonLinker.h | 2 +- js/src/jit/IonMacroAssembler.cpp | 16 +++---- js/src/jit/IonMacroAssembler.h | 12 ++--- js/src/jit/LIR.h | 8 ++-- js/src/jit/LOpcodes.h | 6 +-- js/src/jit/Lowering.cpp | 2 +- js/src/jit/Lowering.h | 6 +-- js/src/jit/MoveEmitter.h | 4 +- js/src/jit/RegisterAllocator.h | 4 +- js/src/jit/RegisterSets.h | 16 +++---- js/src/jit/Registers.h | 6 +-- js/src/jit/arm/Architecture-arm.h | 2 +- js/src/jit/arm/Assembler-arm.h | 2 +- js/src/jit/arm/CodeGenerator-arm.h | 2 +- js/src/jit/arm/MacroAssembler-arm.cpp | 10 ++-- js/src/jit/arm/MacroAssembler-arm.h | 2 +- js/src/jit/shared/Assembler-shared.h | 4 +- js/src/jit/shared/Assembler-x86-shared.cpp | 6 +-- js/src/jit/shared/Assembler-x86-shared.h | 2 +- js/src/jit/shared/CodeGenerator-shared.cpp | 2 +- .../jit/shared/CodeGenerator-x86-shared.cpp | 8 ++-- js/src/jit/shared/Lowering-shared-inl.h | 2 +- js/src/jit/shared/Lowering-x86-shared.cpp | 2 +- js/src/jit/shared/MacroAssembler-x86-shared.h | 4 +- js/src/jit/shared/MoveEmitter-x86-shared.cpp | 14 +++--- js/src/jit/shared/MoveEmitter-x86-shared.h | 6 +-- js/src/jit/x86/Trampoline-x86.cpp | 2 +- js/src/shell/js.cpp | 4 +- 43 files changed, 147 insertions(+), 147 deletions(-) diff --git a/js/src/jit/AsmJS.cpp b/js/src/jit/AsmJS.cpp index 83993c62251..5ce2979307c 100644 --- a/js/src/jit/AsmJS.cpp +++ b/js/src/jit/AsmJS.cpp @@ -1489,19 +1489,19 @@ class MOZ_STACK_CLASS ModuleCompiler } void setInterpExitOffset(unsigned exitIndex) { -#if defined(JS_CPU_ARM) +#if defined(JS_CODEGEN_ARM) masm_.flush(); #endif module_->exit(exitIndex).initInterpOffset(masm_.size()); } void setIonExitOffset(unsigned exitIndex) { -#if defined(JS_CPU_ARM) +#if defined(JS_CODEGEN_ARM) masm_.flush(); #endif module_->exit(exitIndex).initIonOffset(masm_.size()); } void setEntryOffset(unsigned exportIndex) { -#if defined(JS_CPU_ARM) +#if defined(JS_CODEGEN_ARM) masm_.flush(); #endif module_->exportedFunction(exportIndex).initCodeOffset(masm_.size()); @@ -1543,7 +1543,7 @@ class MOZ_STACK_CLASS ModuleCompiler if (masm_.oom()) return false; -#if defined(JS_CPU_ARM) +#if defined(JS_CODEGEN_ARM) // Now that compilation has finished, we need to update offsets to // reflect actual offsets (an ARM distinction). for (unsigned i = 0; i < module_->numHeapAccesses(); i++) { @@ -1624,7 +1624,7 @@ class MOZ_STACK_CLASS ModuleCompiler } } -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) // Global data accesses in x86 need to be patched with the absolute // address of the global. Globals are allocated sequentially after the // code section so we can just use an RelativeLink. @@ -1638,7 +1638,7 @@ class MOZ_STACK_CLASS ModuleCompiler } #endif -#if defined(JS_CPU_X64) +#if defined(JS_CODEGEN_X64) // Global data accesses on x64 use rip-relative addressing and thus do // not need patching after deserialization. uint8_t *code = module_->codeBase(); @@ -5836,21 +5836,21 @@ GenerateEntry(ModuleCompiler &m, const AsmJSModule::ExportedFunction &exportedFu // ARM has a globally-pinned GlobalReg (x64 uses RIP-relative addressing, // x86 uses immediates in effective addresses) and NaN register (used as // part of the out-of-bounds handling in heap loads/stores). -#if defined(JS_CPU_ARM) +#if defined(JS_CODEGEN_ARM) masm.movePtr(IntArgReg1, GlobalReg); masm.ma_vimm(GenericNaN(), NANReg); #endif // ARM and x64 have a globally-pinned HeapReg (x86 uses immediates in // effective addresses). -#if defined(JS_CPU_X64) || defined(JS_CPU_ARM) +#if defined(JS_CODEGEN_X64) || defined(JS_CODEGEN_ARM) masm.loadPtr(Address(IntArgReg1, m.module().heapOffset()), HeapReg); #endif // Get 'argv' into a non-arg register and save it on the stack. Register argv = ABIArgGenerator::NonArgReturnVolatileReg0; Register scratch = ABIArgGenerator::NonArgReturnVolatileReg1; -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) masm.loadPtr(Address(StackPointer, NativeFrameSize + masm.framePushed()), argv); #else masm.movePtr(IntArgReg0, argv); @@ -6046,7 +6046,7 @@ FillArgumentArray(ModuleCompiler &m, const VarTypeVector &argTypes, case ABIArg::Stack: if (i.mirType() == MIRType_Int32) { Address src(StackPointer, offsetToCallerStackArgs + i->offsetFromArgBase()); -#if defined(JS_CPU_X86) || defined(JS_CPU_X64) +#if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64) masm.load32(src, scratch); masm.storeValue(JSVAL_TYPE_INT32, scratch, dstAddr); #else @@ -6073,7 +6073,7 @@ GenerateFFIInterpreterExit(ModuleCompiler &m, const ModuleCompiler::ExitDescript m.setInterpExitOffset(exitIndex); masm.setFramePushed(0); -#if defined(JS_CPU_X86) || defined(JS_CPU_X64) +#if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64) MIRType typeArray[] = { MIRType_Pointer, // cx MIRType_Pointer, // exitDatum MIRType_Int32, // argc @@ -6291,7 +6291,7 @@ GenerateFFIIonExit(ModuleCompiler &m, const ModuleCompiler::ExitDescriptor &exit RegisterSet restoreSet = RegisterSet::Intersect(RegisterSet::All(), RegisterSet::Not(RegisterSet::Volatile())); -#if defined(JS_CPU_ARM) +#if defined(JS_CODEGEN_ARM) masm.Push(lr); #endif masm.PushRegsInMask(restoreSet); @@ -6303,7 +6303,7 @@ GenerateFFIIonExit(ModuleCompiler &m, const ModuleCompiler::ExitDescriptor &exit MIRTypeVector emptyVector(m.cx()); unsigned argBytes = 3 * sizeof(size_t) + (1 + exit.sig().args().length()) * sizeof(Value); unsigned extraBytes = 0; -#if defined(JS_CPU_ARM) +#if defined(JS_CODEGEN_ARM) extraBytes += sizeof(size_t); #endif unsigned stackDec = StackDecrementForCall(masm, emptyVector, argBytes + extraBytes); @@ -6319,10 +6319,10 @@ GenerateFFIIonExit(ModuleCompiler &m, const ModuleCompiler::ExitDescriptor &exit // 2.1. Get ExitDatum unsigned globalDataOffset = m.module().exitIndexToGlobalDataOffset(exitIndex); -#if defined(JS_CPU_X64) +#if defined(JS_CODEGEN_X64) CodeOffsetLabel label2 = masm.leaRipRelative(callee); m.addGlobalAccess(AsmJSGlobalAccess(label2.offset(), globalDataOffset)); -#elif defined(JS_CPU_X86) +#elif defined(JS_CODEGEN_X86) CodeOffsetLabel label2 = masm.movlWithPatch(Imm32(0), callee); m.addGlobalAccess(AsmJSGlobalAccess(label2.offset(), globalDataOffset)); #else @@ -6345,7 +6345,7 @@ GenerateFFIIonExit(ModuleCompiler &m, const ModuleCompiler::ExitDescriptor &exit // 5. Fill the arguments unsigned offsetToArgs = 3 * sizeof(size_t) + sizeof(Value); unsigned offsetToCallerStackArgs = masm.framePushed(); -#if defined(JS_CPU_X86) || defined(JS_CPU_X64) +#if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64) offsetToCallerStackArgs += NativeFrameSize; #else offsetToCallerStackArgs += ShadowStackSpace; @@ -6373,12 +6373,12 @@ GenerateFFIIonExit(ModuleCompiler &m, const ModuleCompiler::ExitDescriptor &exit masm.pop(scratch); // 2. Call -#if defined(JS_CPU_ARM) && defined(DEBUG) +#if defined(JS_CODEGEN_ARM) && defined(DEBUG) // ARM still needs to push, before stack is aligned masm.Push(scratch); #endif AssertStackAlignment(masm); -#if defined(JS_CPU_ARM) && defined(DEBUG) +#if defined(JS_CODEGEN_ARM) && defined(DEBUG) masm.freeStack(sizeof(size_t)); #endif masm.callIon(scratch); @@ -6457,7 +6457,7 @@ GenerateStackOverflowExit(ModuleCompiler &m, Label *throwLabel) masm.align(CodeAlignment); masm.bind(&m.stackOverflowLabel()); -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) // Ensure that at least one slot is pushed for passing 'cx' below. masm.push(Imm32(0)); #endif @@ -6470,7 +6470,7 @@ GenerateStackOverflowExit(ModuleCompiler &m, Label *throwLabel) masm.subPtr(Imm32(ShadowStackSpace), StackPointer); // Prepare the arguments for the call to js_ReportOverRecursed. -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) LoadAsmJSActivationIntoRegister(masm, eax); LoadJSContextFromActivation(masm, eax, eax); masm.storePtr(eax, Address(StackPointer, 0)); @@ -6499,7 +6499,7 @@ GenerateOperationCallbackExit(ModuleCompiler &m, Label *throwLabel) masm.align(CodeAlignment); masm.bind(&m.operationCallbackLabel()); -#ifndef JS_CPU_ARM +#ifndef JS_CODEGEN_ARM // Be very careful here not to perturb the machine state before saving it // to the stack. In particular, add/sub instructions may set conditions in // the flags register. @@ -6519,7 +6519,7 @@ GenerateOperationCallbackExit(ModuleCompiler &m, Label *throwLabel) // We know that StackPointer is word-aligned, but not necessarily // stack-aligned, so we need to align it dynamically. masm.mov(StackPointer, ABIArgGenerator::NonVolatileReg); -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) // Ensure that at least one slot is pushed for passing 'cx' below. masm.push(Imm32(0)); #endif @@ -6528,10 +6528,10 @@ GenerateOperationCallbackExit(ModuleCompiler &m, Label *throwLabel) masm.subPtr(Imm32(ShadowStackSpace), StackPointer); // argument 0: cx -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) LoadJSContextFromActivation(masm, activation, scratch); masm.storePtr(scratch, Address(StackPointer, 0)); -#elif defined(JS_CPU_X64) +#elif defined(JS_CODEGEN_X64) LoadJSContextFromActivation(masm, activation, IntArgReg0); #endif diff --git a/js/src/jit/AsmJS.h b/js/src/jit/AsmJS.h index 8fa5d8adcb8..38724341c7b 100644 --- a/js/src/jit/AsmJS.h +++ b/js/src/jit/AsmJS.h @@ -86,7 +86,7 @@ RoundUpToNextValidAsmJSHeapLength(uint32_t length); extern bool IsValidAsmJSHeapLength(uint32_t length); -#ifdef JS_CPU_X64 +#ifdef JS_CODEGEN_X64 // On x64, the internal ArrayBuffer data array is inflated to 4GiB (only the // byteLength portion of which is accessible) so that out-of-bounds accesses // (made using a uint32 index) are guaranteed to raise a SIGSEGV. diff --git a/js/src/jit/AsmJSModule.cpp b/js/src/jit/AsmJSModule.cpp index cfb6188d0b7..f7f5108217e 100644 --- a/js/src/jit/AsmJSModule.cpp +++ b/js/src/jit/AsmJSModule.cpp @@ -44,7 +44,7 @@ AsmJSModule::initHeap(Handle heap, JSContext *cx) heapDatum() = heap->dataPointer(); JS_ASSERT(IsValidAsmJSHeapLength(heap->byteLength())); -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) uint8_t *heapOffset = heap->dataPointer(); void *heapLength = (void*)heap->byteLength(); for (unsigned i = 0; i < heapAccesses_.length(); i++) { @@ -56,7 +56,7 @@ AsmJSModule::initHeap(Handle heap, JSContext *cx) JS_ASSERT(disp <= INT32_MAX); JSC::X86Assembler::setPointer(addr, (void *)(heapOffset + disp)); } -#elif defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_ARM) uint32_t heapLength = heap->byteLength(); for (unsigned i = 0; i < heapAccesses_.length(); i++) { jit::Assembler::updateBoundsCheck(heapLength, @@ -180,7 +180,7 @@ InvokeFromAsmJS_ToNumber(JSContext *cx, int32_t exitIndex, int32_t argc, Value * } -#if defined(JS_CPU_ARM) +#if defined(JS_CODEGEN_ARM) extern "C" { extern int @@ -227,7 +227,7 @@ AddressOf(AsmJSImmKind kind, ExclusiveContext *cx) return FuncCast(EnableActivationFromAsmJS); case AsmJSImm_DisableActivationFromAsmJS: return FuncCast(DisableActivationFromAsmJS); -#if defined(JS_CPU_ARM) +#if defined(JS_CODEGEN_ARM) case AsmJSImm_aeabi_idivmod: return FuncCast(__aeabi_idivmod); case AsmJSImm_aeabi_uidivmod: @@ -732,15 +732,15 @@ GetCPUID(uint32_t *cpuId) ARCH_BITS = 2 }; -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) JS_ASSERT(uint32_t(JSC::MacroAssembler::getSSEState()) <= (UINT32_MAX >> ARCH_BITS)); *cpuId = X86 | (JSC::MacroAssembler::getSSEState() << ARCH_BITS); return true; -#elif defined(JS_CPU_X64) +#elif defined(JS_CODEGEN_X64) JS_ASSERT(uint32_t(JSC::MacroAssembler::getSSEState()) <= (UINT32_MAX >> ARCH_BITS)); *cpuId = X64 | (JSC::MacroAssembler::getSSEState() << ARCH_BITS); return true; -#elif defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_ARM) JS_ASSERT(GetARMFlags() <= (UINT32_MAX >> ARCH_BITS)); *cpuId = ARM | (GetARMFlags() << ARCH_BITS); return true; diff --git a/js/src/jit/AsmJSSignalHandlers.cpp b/js/src/jit/AsmJSSignalHandlers.cpp index aac3b3b84ee..eac33ff3b8e 100644 --- a/js/src/jit/AsmJSSignalHandlers.cpp +++ b/js/src/jit/AsmJSSignalHandlers.cpp @@ -187,7 +187,7 @@ class AutoSetHandlingSignal } }; -#if defined(JS_CPU_X64) +#if defined(JS_CODEGEN_X64) template static void SetXMMRegToNaN(bool isFloat32, T *xmm_reg) @@ -250,7 +250,7 @@ LookupHeapAccess(const AsmJSModule &module, uint8_t *pc) # include // for ucontext_t, mcontext_t #endif -#if defined(JS_CPU_X64) +#if defined(JS_CODEGEN_X64) # if defined(__DragonFly__) # include // for union savefpu # elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ @@ -340,7 +340,7 @@ ContextToPC(CONTEXT *context) return reinterpret_cast(&PC_sig(context)); } -# if defined(JS_CPU_X64) +# if defined(JS_CODEGEN_X64) static void SetRegisterToCoercedUndefined(CONTEXT *context, bool isFloat32, AnyRegister reg) { @@ -386,7 +386,7 @@ SetRegisterToCoercedUndefined(CONTEXT *context, bool isFloat32, AnyRegister reg) } } } -# endif // JS_CPU_X64 +# endif // JS_CODEGEN_X64 #endif // !XP_MACOSX #if defined(XP_WIN) @@ -441,7 +441,7 @@ HandleException(PEXCEPTION_POINTERS exception) return true; } -# if defined(JS_CPU_X64) +# if defined(JS_CODEGEN_X64) // These checks aren't necessary, but, since we can, check anyway to make // sure we aren't covering up a real bug. if (!module.maybeHeap() || @@ -490,7 +490,7 @@ AsmJSExceptionHandler(LPEXCEPTION_POINTERS exception) static uint8_t ** ContextToPC(x86_thread_state_t &state) { -# if defined(JS_CPU_X64) +# if defined(JS_CODEGEN_X64) JS_STATIC_ASSERT(sizeof(state.uts.ts64.__rip) == sizeof(void*)); return reinterpret_cast(&state.uts.ts64.__rip); # else @@ -499,7 +499,7 @@ ContextToPC(x86_thread_state_t &state) # endif } -# if defined(JS_CPU_X64) +# if defined(JS_CODEGEN_X64) static bool SetRegisterToCoercedUndefined(mach_port_t rtThread, x86_thread_state64_t &state, const AsmJSHeapAccess &heapAccess) @@ -639,7 +639,7 @@ HandleMachException(JSRuntime *rt, const ExceptionRequest &request) return kret == KERN_SUCCESS; } -# if defined(JS_CPU_X64) +# if defined(JS_CODEGEN_X64) // These checks aren't necessary, but, since we can, check anyway to make // sure we aren't covering up a real bug. if (!module.maybeHeap() || @@ -878,7 +878,7 @@ HandleSignal(int signum, siginfo_t *info, void *ctx) return true; } -# if defined(JS_CPU_X64) +# if defined(JS_CODEGEN_X64) // These checks aren't necessary, but, since we can, check anyway to make // sure we aren't covering up a real bug. if (!module.maybeHeap() || diff --git a/js/src/jit/BaselineBailouts.cpp b/js/src/jit/BaselineBailouts.cpp index 0adf78037ca..c1ff8c4d888 100644 --- a/js/src/jit/BaselineBailouts.cpp +++ b/js/src/jit/BaselineBailouts.cpp @@ -337,12 +337,12 @@ struct BaselineStackBuilder // so we can calculate it directly. For other archs, the previous frame pointer // is stored on the stack in the frame that precedes the rectifier frame. size_t priorOffset = IonJSFrameLayout::Size() + topFrame->prevFrameLocalSize(); -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) // On X86, the FramePointer is pushed as the first value in the Rectifier frame. JS_ASSERT(BaselineFrameReg == FramePointer); priorOffset -= sizeof(void *); return virtualPointerAtStackOffset(priorOffset); -#elif defined(JS_CPU_X64) || defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_X64) || defined(JS_CODEGEN_ARM) // On X64 and ARM, the frame pointer save location depends on the caller of the // the rectifier frame. BufferPointer priorFrame = @@ -1141,7 +1141,7 @@ InitFromBailout(JSContext *cx, HandleScript caller, jsbytecode *callerPC, size_t startOfRectifierFrame = builder.framePushed(); // On x86-only, the frame pointer is saved again in the rectifier frame. -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) if (!builder.writePtr(prevFramePtr, "PrevFramePtr-X86Only")) return false; #endif diff --git a/js/src/jit/BaselineCompiler.cpp b/js/src/jit/BaselineCompiler.cpp index c12315f3622..0f4cbe4a86f 100644 --- a/js/src/jit/BaselineCompiler.cpp +++ b/js/src/jit/BaselineCompiler.cpp @@ -414,7 +414,7 @@ BaselineCompiler::emitOutOfLinePostBarrierSlot() regs.take(objReg); regs.take(BaselineFrameReg); Register scratch = regs.takeAny(); -#if defined(JS_CPU_ARM) +#if defined(JS_CODEGEN_ARM) // On ARM, save the link register before calling. It contains the return // address. The |masm.ret()| later will pop this into |pc| to return. masm.push(lr); diff --git a/js/src/jit/BaselineCompiler.h b/js/src/jit/BaselineCompiler.h index e6c33508267..c8d3e038d9a 100644 --- a/js/src/jit/BaselineCompiler.h +++ b/js/src/jit/BaselineCompiler.h @@ -10,9 +10,9 @@ #ifdef JS_ION #include "jit/FixedList.h" -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) # include "jit/x86/BaselineCompiler-x86.h" -#elif defined(JS_CPU_X64) +#elif defined(JS_CODEGEN_X64) # include "jit/x64/BaselineCompiler-x64.h" #else # include "jit/arm/BaselineCompiler-arm.h" diff --git a/js/src/jit/BaselineHelpers.h b/js/src/jit/BaselineHelpers.h index e4d71e636ba..89550564604 100644 --- a/js/src/jit/BaselineHelpers.h +++ b/js/src/jit/BaselineHelpers.h @@ -9,11 +9,11 @@ #ifdef JS_ION -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) # include "jit/x86/BaselineHelpers-x86.h" -#elif defined(JS_CPU_X64) +#elif defined(JS_CODEGEN_X64) # include "jit/x64/BaselineHelpers-x64.h" -#elif defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_ARM) # include "jit/arm/BaselineHelpers-arm.h" #else # error "Unknown architecture!" diff --git a/js/src/jit/BaselineIC.cpp b/js/src/jit/BaselineIC.cpp index ebde4d44f98..e3519bddeff 100644 --- a/js/src/jit/BaselineIC.cpp +++ b/js/src/jit/BaselineIC.cpp @@ -581,7 +581,7 @@ ICStubCompiler::getStubCode() // Compile new stubcode. MacroAssembler masm; -#ifdef JS_CPU_ARM +#ifdef JS_CODEGEN_ARM masm.setSecondScratchReg(BaselineSecondScratchReg); #endif @@ -712,7 +712,7 @@ ICStubCompiler::emitPostWriteBarrierSlot(MacroAssembler &masm, Register obj, Reg masm.bind(&isTenured); // void PostWriteBarrier(JSRuntime *rt, JSObject *obj); -#ifdef JS_CPU_ARM +#ifdef JS_CODEGEN_ARM saveRegs.add(BaselineTailCallReg); #endif saveRegs = GeneralRegisterSet::Intersect(saveRegs, GeneralRegisterSet::Volatile()); diff --git a/js/src/jit/BaselineIC.h b/js/src/jit/BaselineIC.h index 182a74426af..0f7c8d21071 100644 --- a/js/src/jit/BaselineIC.h +++ b/js/src/jit/BaselineIC.h @@ -1049,13 +1049,13 @@ class ICStubCompiler inline GeneralRegisterSet availableGeneralRegs(size_t numInputs) const { GeneralRegisterSet regs(GeneralRegisterSet::All()); JS_ASSERT(!regs.has(BaselineStackReg)); -#ifdef JS_CPU_ARM +#ifdef JS_CODEGEN_ARM JS_ASSERT(!regs.has(BaselineTailCallReg)); regs.take(BaselineSecondScratchReg); #endif regs.take(BaselineFrameReg); regs.take(BaselineStubReg); -#ifdef JS_CPU_X64 +#ifdef JS_CODEGEN_X64 regs.take(ExtractTemp0); regs.take(ExtractTemp1); #endif diff --git a/js/src/jit/BaselineRegisters.h b/js/src/jit/BaselineRegisters.h index b99e18278fa..b49ab639fe6 100644 --- a/js/src/jit/BaselineRegisters.h +++ b/js/src/jit/BaselineRegisters.h @@ -9,9 +9,9 @@ #ifdef JS_ION -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) # include "jit/x86/BaselineRegisters-x86.h" -#elif defined(JS_CPU_X64) +#elif defined(JS_CODEGEN_X64) # include "jit/x64/BaselineRegisters-x64.h" #else # include "jit/arm/BaselineRegisters-arm.h" diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index a4f74b979e3..d34af9e720e 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -7900,7 +7900,7 @@ CodeGenerator::visitAsmJSCall(LAsmJSCall *ins) { MAsmJSCall *mir = ins->mir(); -#if defined(JS_CPU_ARM) && !defined(JS_CPU_ARM_HARDFP) +#if defined(JS_CODEGEN_ARM) && !defined(JS_CODEGEN_ARM_HARDFP) if (mir->callee().which() == MAsmJSCall::Callee::Builtin) { for (unsigned i = 0, e = ins->numOperands(); i < e; i++) { LAllocation *a = ins->getOperand(i); diff --git a/js/src/jit/CodeGenerator.h b/js/src/jit/CodeGenerator.h index 9a5a9ca70f4..51eefe762b4 100644 --- a/js/src/jit/CodeGenerator.h +++ b/js/src/jit/CodeGenerator.h @@ -12,11 +12,11 @@ # include "jit/PerfSpewer.h" #endif -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) # include "jit/x86/CodeGenerator-x86.h" -#elif defined(JS_CPU_X64) +#elif defined(JS_CODEGEN_X64) # include "jit/x64/CodeGenerator-x64.h" -#elif defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_ARM) # include "jit/arm/CodeGenerator-arm.h" #else #error "CPU Not Supported" diff --git a/js/src/jit/IonCaches.cpp b/js/src/jit/IonCaches.cpp index f6ddfb750b5..245b61f663c 100644 --- a/js/src/jit/IonCaches.cpp +++ b/js/src/jit/IonCaches.cpp @@ -43,7 +43,7 @@ CodeLocationJump::repoint(JitCode *code, MacroAssembler *masm) size_t jumpTableEntryOffset = reinterpret_cast(jumpTableEntry_); #endif if (masm != nullptr) { -#ifdef JS_CPU_X64 +#ifdef JS_CODEGEN_X64 JS_ASSERT((uint64_t)raw_ <= UINT32_MAX); #endif new_off = masm->actualOffset((uintptr_t)raw_); @@ -64,7 +64,7 @@ CodeLocationLabel::repoint(JitCode *code, MacroAssembler *masm) JS_ASSERT(state_ == Relative); size_t new_off = (size_t)raw_; if (masm != nullptr) { -#ifdef JS_CPU_X64 +#ifdef JS_CODEGEN_X64 JS_ASSERT((uint64_t)raw_ <= UINT32_MAX); #endif new_off = masm->actualOffset((uintptr_t)raw_); diff --git a/js/src/jit/IonCaches.h b/js/src/jit/IonCaches.h index 7f800cbc206..28ec236c32d 100644 --- a/js/src/jit/IonCaches.h +++ b/js/src/jit/IonCaches.h @@ -7,7 +7,7 @@ #ifndef jit_IonCaches_h #define jit_IonCaches_h -#ifdef JS_CPU_ARM +#ifdef JS_CODEGEN_ARM # include "jit/arm/Assembler-arm.h" #endif #include "jit/Registers.h" @@ -347,7 +347,7 @@ class RepatchIonCache : public IonCache CodeLocationJump lastJump_; // Offset from the initial jump to the rejoin label. -#ifdef JS_CPU_ARM +#ifdef JS_CODEGEN_ARM static const size_t REJOIN_LABEL_OFFSET = 4; #else static const size_t REJOIN_LABEL_OFFSET = 0; @@ -355,7 +355,7 @@ class RepatchIonCache : public IonCache CodeLocationLabel rejoinLabel() const { uint8_t *ptr = initialJump_.raw(); -#ifdef JS_CPU_ARM +#ifdef JS_CODEGEN_ARM uint32_t i = 0; while (i < REJOIN_LABEL_OFFSET) ptr = Assembler::nextInstruction(ptr, &i); @@ -1042,7 +1042,7 @@ class GetPropertyParIC : public ParallelIonCache CACHE_HEADER(GetPropertyPar) -#ifdef JS_CPU_X86 +#ifdef JS_CODEGEN_X86 // x86 lacks a general purpose scratch register for dispatch caches and // must be given one manually. void initializeAddCacheState(LInstruction *ins, AddCacheState *addState); @@ -1101,7 +1101,7 @@ class GetElementParIC : public ParallelIonCache CACHE_HEADER(GetElementPar) -#ifdef JS_CPU_X86 +#ifdef JS_CODEGEN_X86 // x86 lacks a general purpose scratch register for dispatch caches and // must be given one manually. void initializeAddCacheState(LInstruction *ins, AddCacheState *addState); @@ -1162,7 +1162,7 @@ class SetPropertyParIC : public ParallelIonCache CACHE_HEADER(SetPropertyPar) -#ifdef JS_CPU_X86 +#ifdef JS_CODEGEN_X86 // x86 lacks a general purpose scratch register for dispatch caches and // must be given one manually. void initializeAddCacheState(LInstruction *ins, AddCacheState *addState); @@ -1222,7 +1222,7 @@ class SetElementParIC : public ParallelIonCache CACHE_HEADER(SetElementPar) -#ifdef JS_CPU_X86 +#ifdef JS_CODEGEN_X86 // x86 lacks a general purpose scratch register for dispatch caches and // must be given one manually. void initializeAddCacheState(LInstruction *ins, AddCacheState *addState); diff --git a/js/src/jit/IonLinker.h b/js/src/jit/IonLinker.h index 05923d2bfba..a975715d96c 100644 --- a/js/src/jit/IonLinker.h +++ b/js/src/jit/IonLinker.h @@ -82,7 +82,7 @@ class Linker } JitCode *newCodeForIonScript(JSContext *cx) { -#ifdef JS_CPU_ARM +#ifdef JS_CODEGEN_ARM // ARM does not yet use implicit interrupt checks, see bug 864220. return newCode(cx, JSC::ION_CODE); #else diff --git a/js/src/jit/IonMacroAssembler.cpp b/js/src/jit/IonMacroAssembler.cpp index 4d17767fade..a97d105c481 100644 --- a/js/src/jit/IonMacroAssembler.cpp +++ b/js/src/jit/IonMacroAssembler.cpp @@ -245,14 +245,14 @@ MacroAssembler::PushRegsInMask(RegisterSet set) int32_t diffF = set.fpus().size() * sizeof(double); int32_t diffG = set.gprs().size() * sizeof(intptr_t); -#if defined(JS_CPU_X86) || defined(JS_CPU_X64) +#if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64) // On x86, always use push to push the integer registers, as it's fast // on modern hardware and it's a small instruction. for (GeneralRegisterBackwardIterator iter(set.gprs()); iter.more(); iter++) { diffG -= sizeof(intptr_t); Push(*iter); } -#elif defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_ARM) if (set.gprs().size() > 1) { adjustFrame(diffG); startDataTransferM(IsStore, StackPointer, DB, WriteBack); @@ -277,7 +277,7 @@ MacroAssembler::PushRegsInMask(RegisterSet set) #endif JS_ASSERT(diffG == 0); -#ifdef JS_CPU_ARM +#ifdef JS_CODEGEN_ARM adjustFrame(diffF); diffF += transferMultipleByRuns(set.fpus(), IsStore, StackPointer, DB); #else @@ -298,7 +298,7 @@ MacroAssembler::PopRegsInMaskIgnore(RegisterSet set, RegisterSet ignore) const int32_t reservedG = diffG; const int32_t reservedF = diffF; -#ifdef JS_CPU_ARM +#ifdef JS_CODEGEN_ARM // ARM can load multiple registers at once, but only if we want back all // the registers we previously saved to the stack. if (ignore.empty(true)) { @@ -316,7 +316,7 @@ MacroAssembler::PopRegsInMaskIgnore(RegisterSet set, RegisterSet ignore) } JS_ASSERT(diffF == 0); -#if defined(JS_CPU_X86) || defined(JS_CPU_X64) +#if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64) // On x86, use pop to pop the integer registers, if we're not going to // ignore any slots, as it's fast on modern hardware and it's a small // instruction. @@ -327,7 +327,7 @@ MacroAssembler::PopRegsInMaskIgnore(RegisterSet set, RegisterSet ignore) } } else #endif -#ifdef JS_CPU_ARM +#ifdef JS_CODEGEN_ARM if (set.gprs().size() > 1 && ignore.empty(false)) { startDataTransferM(IsLoad, StackPointer, IA, WriteBack); for (GeneralRegisterBackwardIterator iter(set.gprs()); iter.more(); iter++) { @@ -538,7 +538,7 @@ void MacroAssembler::clampDoubleToUint8(FloatRegister input, Register output) { JS_ASSERT(input != ScratchFloatReg); -#ifdef JS_CPU_ARM +#ifdef JS_CODEGEN_ARM ma_vimm(0.5, ScratchFloatReg); if (hasVFPv3()) { Label notSplit; @@ -993,7 +993,7 @@ MacroAssembler::generateBailoutTail(Register scratch, Register bailoutInfo) // Discard exit frame. addPtr(Imm32(IonExitFrameLayout::SizeWithFooter()), StackPointer); -#if defined(JS_CPU_X86) || defined(JS_CPU_X64) +#if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64) push(BaselineTailCallReg); #endif jump(Address(BaselineStubReg, ICStub::offsetOfStubCode())); diff --git a/js/src/jit/IonMacroAssembler.h b/js/src/jit/IonMacroAssembler.h index 1935d17f376..5de37ea9142 100644 --- a/js/src/jit/IonMacroAssembler.h +++ b/js/src/jit/IonMacroAssembler.h @@ -11,11 +11,11 @@ #include "jscompartment.h" -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) # include "jit/x86/MacroAssembler-x86.h" -#elif defined(JS_CPU_X64) +#elif defined(JS_CODEGEN_X64) # include "jit/x64/MacroAssembler-x64.h" -#elif defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_ARM) # include "jit/arm/MacroAssembler-arm.h" #endif #include "jit/IonInstrumentation.h" @@ -204,7 +204,7 @@ class MacroAssembler : public MacroAssemblerSpecific } moveResolver_.setAllocator(*icx->temp); -#ifdef JS_CPU_ARM +#ifdef JS_CODEGEN_ARM initWithAllocator(); m_buffer.id = icx->getNextAssemblerId(); #endif @@ -221,7 +221,7 @@ class MacroAssembler : public MacroAssemblerSpecific ionContext_.construct(cx, (js::jit::TempAllocator *)nullptr); alloc_.construct(cx); moveResolver_.setAllocator(*ionContext_.ref().temp); -#ifdef JS_CPU_ARM +#ifdef JS_CODEGEN_ARM initWithAllocator(); m_buffer.id = GetIonContext()->getNextAssemblerId(); #endif @@ -236,7 +236,7 @@ class MacroAssembler : public MacroAssemblerSpecific embedsNurseryPointers_(false), sps_(nullptr) { -#ifdef JS_CPU_ARM +#ifdef JS_CODEGEN_ARM initWithAllocator(); m_buffer.id = 0; #endif diff --git a/js/src/jit/LIR.h b/js/src/jit/LIR.h index 55653b87ef9..f417e65ee9a 100644 --- a/js/src/jit/LIR.h +++ b/js/src/jit/LIR.h @@ -1541,14 +1541,14 @@ LAllocation::toRegister() const #endif #include "jit/LIR-Common.h" -#if defined(JS_CPU_X86) || defined(JS_CPU_X64) -# if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64) +# if defined(JS_CODEGEN_X86) # include "jit/x86/LIR-x86.h" -# elif defined(JS_CPU_X64) +# elif defined(JS_CODEGEN_X64) # include "jit/x64/LIR-x64.h" # endif # include "jit/shared/LIR-x86-shared.h" -#elif defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_ARM) # include "jit/arm/LIR-arm.h" #endif diff --git a/js/src/jit/LOpcodes.h b/js/src/jit/LOpcodes.h index c02b4e47b7a..745feb32af1 100644 --- a/js/src/jit/LOpcodes.h +++ b/js/src/jit/LOpcodes.h @@ -290,11 +290,11 @@ _(AssertRangeF) \ _(AssertRangeV) -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) # include "jit/x86/LOpcodes-x86.h" -#elif defined(JS_CPU_X64) +#elif defined(JS_CODEGEN_X64) # include "jit/x64/LOpcodes-x64.h" -#elif defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_ARM) # include "jit/arm/LOpcodes-arm.h" #endif diff --git a/js/src/jit/Lowering.cpp b/js/src/jit/Lowering.cpp index e170d8ca744..5d18a09a223 100644 --- a/js/src/jit/Lowering.cpp +++ b/js/src/jit/Lowering.cpp @@ -2106,7 +2106,7 @@ LIRGenerator::visitInterruptCheck(MInterruptCheck *ins) // Implicit interrupt checks require asm.js signal handlers to be // installed. ARM does not yet use implicit interrupt checks, see // bug 864220. -#ifndef JS_CPU_ARM +#ifndef JS_CODEGEN_ARM if (GetIonContext()->runtime->signalHandlersInstalled()) { LInterruptCheckImplicit *lir = new(alloc()) LInterruptCheckImplicit(); return add(lir, ins) && assignSafepoint(lir, ins); diff --git a/js/src/jit/Lowering.h b/js/src/jit/Lowering.h index 3748afac86e..fffdaf3e3ea 100644 --- a/js/src/jit/Lowering.h +++ b/js/src/jit/Lowering.h @@ -11,11 +11,11 @@ // MIRGraph. #include "jit/LIR.h" -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) # include "jit/x86/Lowering-x86.h" -#elif defined(JS_CPU_X64) +#elif defined(JS_CODEGEN_X64) # include "jit/x64/Lowering-x64.h" -#elif defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_ARM) # include "jit/arm/Lowering-arm.h" #else # error "CPU!" diff --git a/js/src/jit/MoveEmitter.h b/js/src/jit/MoveEmitter.h index b861ac05b7f..9b88c0391e2 100644 --- a/js/src/jit/MoveEmitter.h +++ b/js/src/jit/MoveEmitter.h @@ -7,9 +7,9 @@ #ifndef jit_MoveEmitter_h #define jit_MoveEmitter_h -#if defined(JS_CPU_X86) || defined(JS_CPU_X64) +#if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64) # include "jit/shared/MoveEmitter-x86-shared.h" -#elif defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_ARM) # include "jit/arm/MoveEmitter-arm.h" #else # error "CPU Not Supported" diff --git a/js/src/jit/RegisterAllocator.h b/js/src/jit/RegisterAllocator.h index 879c69ff317..6415262494a 100644 --- a/js/src/jit/RegisterAllocator.h +++ b/js/src/jit/RegisterAllocator.h @@ -308,10 +308,10 @@ class RegisterAllocator { if (FramePointer != InvalidReg && mir->instrumentedProfiling()) allRegisters_.take(AnyRegister(FramePointer)); -#if defined(JS_CPU_X64) +#if defined(JS_CODEGEN_X64) if (mir->compilingAsmJS()) allRegisters_.take(AnyRegister(HeapReg)); -#elif defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_ARM) if (mir->compilingAsmJS()) { allRegisters_.take(AnyRegister(HeapReg)); allRegisters_.take(AnyRegister(GlobalReg)); diff --git a/js/src/jit/RegisterSets.h b/js/src/jit/RegisterSets.h index 1cc5c064e58..178857ace82 100644 --- a/js/src/jit/RegisterSets.h +++ b/js/src/jit/RegisterSets.h @@ -809,10 +809,10 @@ class ABIArg class AsmJSHeapAccess { uint32_t offset_; -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) uint8_t cmpDelta_; // the number of bytes from the cmp to the load/store instruction #endif -#if defined(JS_CPU_X86) || defined(JS_CPU_X64) +#if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64) uint8_t opLength_; // the length of the load/store instruction uint8_t isFloat32Load_; AnyRegister::Code loadedReg_ : 8; @@ -822,13 +822,13 @@ class AsmJSHeapAccess public: AsmJSHeapAccess() {} -#if defined(JS_CPU_X86) || defined(JS_CPU_X64) +#if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64) // If 'cmp' equals 'offset' or if it is not supplied then the // cmpDelta_ is zero indicating that there is no length to patch. AsmJSHeapAccess(uint32_t offset, uint32_t after, ArrayBufferView::ViewType vt, AnyRegister loadedReg, uint32_t cmp = UINT32_MAX) : offset_(offset), -# if defined(JS_CPU_X86) +# if defined(JS_CODEGEN_X86) cmpDelta_(cmp == UINT32_MAX ? 0 : offset - cmp), # endif opLength_(after - offset), @@ -837,14 +837,14 @@ class AsmJSHeapAccess {} AsmJSHeapAccess(uint32_t offset, uint8_t after, uint32_t cmp = UINT32_MAX) : offset_(offset), -# if defined(JS_CPU_X86) +# if defined(JS_CODEGEN_X86) cmpDelta_(cmp == UINT32_MAX ? 0 : offset - cmp), # endif opLength_(after - offset), isFloat32Load_(false), loadedReg_(UINT8_MAX) {} -#elif defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_ARM) explicit AsmJSHeapAccess(uint32_t offset) : offset_(offset) {} @@ -852,12 +852,12 @@ class AsmJSHeapAccess uint32_t offset() const { return offset_; } void setOffset(uint32_t offset) { offset_ = offset; } -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) bool hasLengthCheck() const { return cmpDelta_ > 0; } void *patchLengthAt(uint8_t *code) const { return code + (offset_ - cmpDelta_); } void *patchOffsetAt(uint8_t *code) const { return code + (offset_ + opLength_); } #endif -#if defined(JS_CPU_X86) || defined(JS_CPU_X64) +#if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64) unsigned opLength() const { return opLength_; } bool isLoad() const { return loadedReg_ != UINT8_MAX; } bool isFloat32Load() const { return isFloat32Load_; } diff --git a/js/src/jit/Registers.h b/js/src/jit/Registers.h index 19ede68562a..b5cb822f000 100644 --- a/js/src/jit/Registers.h +++ b/js/src/jit/Registers.h @@ -10,11 +10,11 @@ #include "mozilla/Array.h" #include "jit/IonTypes.h" -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) # include "jit/x86/Architecture-x86.h" -#elif defined(JS_CPU_X64) +#elif defined(JS_CODEGEN_X64) # include "jit/x64/Architecture-x64.h" -#elif defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_ARM) # include "jit/arm/Architecture-arm.h" #endif diff --git a/js/src/jit/arm/Architecture-arm.h b/js/src/jit/arm/Architecture-arm.h index 15d53c60342..c2634a09728 100644 --- a/js/src/jit/arm/Architecture-arm.h +++ b/js/src/jit/arm/Architecture-arm.h @@ -12,7 +12,7 @@ // gcc appears to use __ARM_PCS_VFP to denote that the target is a hard-float target. #ifdef __ARM_PCS_VFP -#define JS_CPU_ARM_HARDFP +#define JS_CODEGEN_ARM_HARDFP #endif namespace js { namespace jit { diff --git a/js/src/jit/arm/Assembler-arm.h b/js/src/jit/arm/Assembler-arm.h index ec94ff5471f..73f25445840 100644 --- a/js/src/jit/arm/Assembler-arm.h +++ b/js/src/jit/arm/Assembler-arm.h @@ -2102,7 +2102,7 @@ class InstructionIterator { static const uint32_t NumIntArgRegs = 4; static const uint32_t NumFloatArgRegs = 8; -#ifdef JS_CPU_ARM_HARDFP +#ifdef JS_CODEGEN_ARM_HARDFP static inline bool GetIntArgReg(uint32_t usedIntArgs, uint32_t usedFloatArgs, Register *out) { diff --git a/js/src/jit/arm/CodeGenerator-arm.h b/js/src/jit/arm/CodeGenerator-arm.h index 08c90dfd892..edecc34613a 100644 --- a/js/src/jit/arm/CodeGenerator-arm.h +++ b/js/src/jit/arm/CodeGenerator-arm.h @@ -176,7 +176,7 @@ class CodeGeneratorARM : public CodeGeneratorShared bool generateInvalidateEpilogue(); protected: void postAsmJSCall(LAsmJSCall *lir) { -#ifndef JS_CPU_ARM_HARDFP +#ifndef JS_CODEGEN_ARM_HARDFP if (lir->mir()->callee().which() == MAsmJSCall::Callee::Builtin) { switch (lir->mir()->type()) { case MIRType_Double: diff --git a/js/src/jit/arm/MacroAssembler-arm.cpp b/js/src/jit/arm/MacroAssembler-arm.cpp index 36be5849d1f..ba57af962ea 100644 --- a/js/src/jit/arm/MacroAssembler-arm.cpp +++ b/js/src/jit/arm/MacroAssembler-arm.cpp @@ -3479,7 +3479,7 @@ MacroAssemblerARMCompat::setupABICall(uint32_t args) inCall_ = true; args_ = args; passedArgs_ = 0; -#ifdef JS_CPU_ARM_HARDFP +#ifdef JS_CODEGEN_ARM_HARDFP usedIntSlots_ = 0; usedFloatSlots_ = 0; padding_ = 0; @@ -3512,7 +3512,7 @@ MacroAssemblerARMCompat::setupUnalignedABICall(uint32_t args, const Register &sc ma_and(Imm32(~(StackAlignment - 1)), sp, sp); ma_push(scratch); } -#ifdef JS_CPU_ARM_HARDFP +#ifdef JS_CODEGEN_ARM_HARDFP void MacroAssemblerARMCompat::passABIArg(const MoveOperand &from, MoveOp::Type type) { @@ -3631,7 +3631,7 @@ void MacroAssemblerARMCompat::callWithABIPre(uint32_t *stackAdjust) { JS_ASSERT(inCall_); -#ifdef JS_CPU_ARM_HARDFP +#ifdef JS_CODEGEN_ARM_HARDFP *stackAdjust = ((usedIntSlots_ > NumIntArgRegs) ? usedIntSlots_ - NumIntArgRegs : 0) * sizeof(intptr_t); *stackAdjust += 2*((usedFloatSlots_ > NumFloatArgRegs) ? usedFloatSlots_ - NumFloatArgRegs : 0) * sizeof(intptr_t); #else @@ -3693,13 +3693,13 @@ MacroAssemblerARMCompat::callWithABIPost(uint32_t stackAdjust, MoveOp::Type resu switch (result) { case MoveOp::DOUBLE: -#ifndef JS_CPU_ARM_HARDFP +#ifndef JS_CODEGEN_ARM_HARDFP // Move double from r0/r1 to ReturnFloatReg. as_vxfer(r0, r1, ReturnFloatReg, CoreToFloat); break; #endif case MoveOp::FLOAT32: -#ifndef JS_CPU_ARM_HARDFP +#ifndef JS_CODEGEN_ARM_HARDFP // Move float32 from r0 to ReturnFloatReg. as_vxfer(r0, InvalidReg, VFPRegister(d0).singleOverlay(), CoreToFloat); break; diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index 523dac5d9ae..deb687b36da 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -444,7 +444,7 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM // the initial number of arguments declared was correct. uint32_t passedArgs_; -#ifdef JS_CPU_ARM_HARDFP +#ifdef JS_CODEGEN_ARM_HARDFP uint32_t usedIntSlots_; uint32_t usedFloatSlots_; uint32_t padding_; diff --git a/js/src/jit/shared/Assembler-shared.h b/js/src/jit/shared/Assembler-shared.h index 9e547198bf7..ae8c1c34b65 100644 --- a/js/src/jit/shared/Assembler-shared.h +++ b/js/src/jit/shared/Assembler-shared.h @@ -17,7 +17,7 @@ #include "jit/Registers.h" #include "jit/RegisterSets.h" -#if defined(JS_CPU_X64) || defined(JS_CPU_ARM) +#if defined(JS_CODEGEN_X64) || defined(JS_CODEGEN_ARM) // JS_SMALL_BRANCH means the range on a branch instruction // is smaller than the whole address space # define JS_SMALL_BRANCH @@ -685,7 +685,7 @@ enum AsmJSImmKind AsmJSImm_ToInt32, AsmJSImm_EnableActivationFromAsmJS, AsmJSImm_DisableActivationFromAsmJS, -#if defined(JS_CPU_ARM) +#if defined(JS_CODEGEN_ARM) AsmJSImm_aeabi_idivmod, AsmJSImm_aeabi_uidivmod, #endif diff --git a/js/src/jit/shared/Assembler-x86-shared.cpp b/js/src/jit/shared/Assembler-x86-shared.cpp index e716f6f2ce3..3223319844b 100644 --- a/js/src/jit/shared/Assembler-x86-shared.cpp +++ b/js/src/jit/shared/Assembler-x86-shared.cpp @@ -6,11 +6,11 @@ #include "gc/Marking.h" #include "jit/JitCompartment.h" -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) # include "jit/x86/MacroAssembler-x86.h" -#elif defined(JS_CPU_X64) +#elif defined(JS_CODEGEN_X64) # include "jit/x64/MacroAssembler-x64.h" -#elif defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_ARM) # include "jit/arm/MacroAssembler-arm.h" #endif diff --git a/js/src/jit/shared/Assembler-x86-shared.h b/js/src/jit/shared/Assembler-x86-shared.h index 4ee6d3d6eb6..2ffb62a018b 100644 --- a/js/src/jit/shared/Assembler-x86-shared.h +++ b/js/src/jit/shared/Assembler-x86-shared.h @@ -1165,7 +1165,7 @@ class AssemblerX86Shared masm.pop_flags(); } -#ifdef JS_CPU_X86 +#ifdef JS_CODEGEN_X86 void pushAllRegs() { masm.pusha(); } diff --git a/js/src/jit/shared/CodeGenerator-shared.cpp b/js/src/jit/shared/CodeGenerator-shared.cpp index 9b384e7779f..96386254887 100644 --- a/js/src/jit/shared/CodeGenerator-shared.cpp +++ b/js/src/jit/shared/CodeGenerator-shared.cpp @@ -64,7 +64,7 @@ CodeGeneratorShared::CodeGeneratorShared(MIRGenerator *gen, LIRGraph *graph, Mac // An MAsmJSCall does not align the stack pointer at calls sites but instead // relies on the a priori stack adjustment (in the prologue) on platforms // (like x64) which require the stack to be aligned. -#ifdef JS_CPU_ARM +#ifdef JS_CODEGEN_ARM bool forceAlign = true; #else bool forceAlign = false; diff --git a/js/src/jit/shared/CodeGenerator-x86-shared.cpp b/js/src/jit/shared/CodeGenerator-x86-shared.cpp index 8704b187d1c..eb610a2198b 100644 --- a/js/src/jit/shared/CodeGenerator-x86-shared.cpp +++ b/js/src/jit/shared/CodeGenerator-x86-shared.cpp @@ -155,7 +155,7 @@ CodeGeneratorX86Shared::visitBitAndAndBranch(LBitAndAndBranch *baab) void CodeGeneratorX86Shared::emitCompare(MCompare::CompareType type, const LAllocation *left, const LAllocation *right) { -#ifdef JS_CPU_X64 +#ifdef JS_CODEGEN_X64 if (type == MCompare::Compare_Object) { masm.cmpq(ToRegister(left), ToOperand(right)); return; @@ -339,7 +339,7 @@ class BailoutJump { public: BailoutJump(Assembler::Condition cond) : cond_(cond) { } -#ifdef JS_CPU_X86 +#ifdef JS_CODEGEN_X86 void operator()(MacroAssembler &masm, uint8_t *code) const { masm.j(cond_, ImmPtr(code), Relocation::HARDCODED); } @@ -355,7 +355,7 @@ class BailoutLabel { public: BailoutLabel(Label *label) : label_(label) { } -#ifdef JS_CPU_X86 +#ifdef JS_CODEGEN_X86 void operator()(MacroAssembler &masm, uint8_t *code) const { masm.retarget(label_, ImmPtr(code), Relocation::HARDCODED); } @@ -393,7 +393,7 @@ CodeGeneratorX86Shared::bailout(const T &binder, LSnapshot *snapshot) JS_ASSERT_IF(frameClass_ != FrameSizeClass::None() && deoptTable_, frameClass_.frameSize() == masm.framePushed()); -#ifdef JS_CPU_X86 +#ifdef JS_CODEGEN_X86 // On x64, bailout tables are pointless, because 16 extra bytes are // reserved per external jump, whereas it takes only 10 bytes to encode a // a non-table based bailout. diff --git a/js/src/jit/shared/Lowering-shared-inl.h b/js/src/jit/shared/Lowering-shared-inl.h index 04410664cd0..6b1d0c927d1 100644 --- a/js/src/jit/shared/Lowering-shared-inl.h +++ b/js/src/jit/shared/Lowering-shared-inl.h @@ -324,7 +324,7 @@ LIRGeneratorShared::useRegisterOrNonDoubleConstant(MDefinition *mir) return useRegister(mir); } -#if defined(JS_CPU_ARM) +#if defined(JS_CODEGEN_ARM) LAllocation LIRGeneratorShared::useAnyOrConstant(MDefinition *mir) { diff --git a/js/src/jit/shared/Lowering-x86-shared.cpp b/js/src/jit/shared/Lowering-x86-shared.cpp index 71d687543df..011d70f22a4 100644 --- a/js/src/jit/shared/Lowering-x86-shared.cpp +++ b/js/src/jit/shared/Lowering-x86-shared.cpp @@ -288,7 +288,7 @@ LIRGeneratorX86Shared::lowerUrshD(MUrsh *mir) JS_ASSERT(rhs->type() == MIRType_Int32); JS_ASSERT(mir->type() == MIRType_Double); -#ifdef JS_CPU_X64 +#ifdef JS_CODEGEN_X64 JS_ASSERT(ecx == rcx); #endif diff --git a/js/src/jit/shared/MacroAssembler-x86-shared.h b/js/src/jit/shared/MacroAssembler-x86-shared.h index b145179f616..aca5bb80548 100644 --- a/js/src/jit/shared/MacroAssembler-x86-shared.h +++ b/js/src/jit/shared/MacroAssembler-x86-shared.h @@ -10,9 +10,9 @@ #include "mozilla/Casting.h" #include "mozilla/DebugOnly.h" -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) # include "jit/x86/Assembler-x86.h" -#elif defined(JS_CPU_X64) +#elif defined(JS_CODEGEN_X64) # include "jit/x64/Assembler-x64.h" #endif diff --git a/js/src/jit/shared/MoveEmitter-x86-shared.cpp b/js/src/jit/shared/MoveEmitter-x86-shared.cpp index d95b453bc3b..9dbaa794b17 100644 --- a/js/src/jit/shared/MoveEmitter-x86-shared.cpp +++ b/js/src/jit/shared/MoveEmitter-x86-shared.cpp @@ -241,7 +241,7 @@ MoveEmitterX86::breakCycle(const MoveOperand &to, MoveOp::Type type) masm.storeDouble(to.floatReg(), cycleSlot()); } break; -#ifdef JS_CPU_X64 +#ifdef JS_CODEGEN_X64 case MoveOp::INT32: // x64 can't pop to a 32-bit destination, so don't push. if (to.isMemory()) { @@ -252,7 +252,7 @@ MoveEmitterX86::breakCycle(const MoveOperand &to, MoveOp::Type type) } break; #endif -#ifndef JS_CPU_X64 +#ifndef JS_CODEGEN_X64 case MoveOp::INT32: #endif case MoveOp::GENERAL: @@ -293,7 +293,7 @@ MoveEmitterX86::completeCycle(const MoveOperand &to, MoveOp::Type type) masm.loadDouble(cycleSlot(), to.floatReg()); } break; -#ifdef JS_CPU_X64 +#ifdef JS_CODEGEN_X64 case MoveOp::INT32: JS_ASSERT(pushedAtCycle_ != -1); JS_ASSERT(pushedAtCycle_ - pushedAtStart_ >= sizeof(int32_t)); @@ -306,7 +306,7 @@ MoveEmitterX86::completeCycle(const MoveOperand &to, MoveOp::Type type) } break; #endif -#ifndef JS_CPU_X64 +#ifndef JS_CODEGEN_X64 case MoveOp::INT32: #endif case MoveOp::GENERAL: @@ -329,7 +329,7 @@ MoveEmitterX86::emitInt32Move(const MoveOperand &from, const MoveOperand &to) } else { // Memory to memory gpr move. JS_ASSERT(from.isMemory()); -#ifdef JS_CPU_X64 +#ifdef JS_CODEGEN_X64 // x64 has a ScratchReg. Use it. masm.load32(toAddress(from), ScratchReg); masm.move32(ScratchReg, toOperand(to)); @@ -354,7 +354,7 @@ MoveEmitterX86::emitGeneralMove(const MoveOperand &from, const MoveOperand &to) masm.lea(toOperand(from), to.reg()); } else if (from.isMemory()) { // Memory to memory gpr move. -#ifdef JS_CPU_X64 +#ifdef JS_CODEGEN_X64 // x64 has a ScratchReg. Use it. masm.loadPtr(toAddress(from), ScratchReg); masm.mov(ScratchReg, toOperand(to)); @@ -366,7 +366,7 @@ MoveEmitterX86::emitGeneralMove(const MoveOperand &from, const MoveOperand &to) } else { // Effective address to memory move. JS_ASSERT(from.isEffectiveAddress()); -#ifdef JS_CPU_X64 +#ifdef JS_CODEGEN_X64 // x64 has a ScratchReg. Use it. masm.lea(toOperand(from), ScratchReg); masm.mov(ScratchReg, toOperand(to)); diff --git a/js/src/jit/shared/MoveEmitter-x86-shared.h b/js/src/jit/shared/MoveEmitter-x86-shared.h index 869752700c3..ccc67311128 100644 --- a/js/src/jit/shared/MoveEmitter-x86-shared.h +++ b/js/src/jit/shared/MoveEmitter-x86-shared.h @@ -7,11 +7,11 @@ #ifndef jit_MoveEmitter_x86_shared_h #define jit_MoveEmitter_x86_shared_h -#if defined(JS_CPU_X86) +#if defined(JS_CODEGEN_X86) # include "jit/x86/MacroAssembler-x86.h" -#elif defined(JS_CPU_X64) +#elif defined(JS_CODEGEN_X64) # include "jit/x64/MacroAssembler-x64.h" -#elif defined(JS_CPU_ARM) +#elif defined(JS_CODEGEN_ARM) # include "jit/arm/MacroAssembler-arm.h" #endif #include "jit/MoveResolver.h" diff --git a/js/src/jit/x86/Trampoline-x86.cpp b/js/src/jit/x86/Trampoline-x86.cpp index 682414b1fd4..8c19c241121 100644 --- a/js/src/jit/x86/Trampoline-x86.cpp +++ b/js/src/jit/x86/Trampoline-x86.cpp @@ -364,7 +364,7 @@ JitRuntime::generateArgumentsRectifier(JSContext *cx, ExecutionMode mode, void * // NOTE: The fact that x86 ArgumentsRectifier saves the FramePointer is relied upon // by the baseline bailout code. If this changes, fix that code! See // BaselineJIT.cpp/BaselineStackBuilder::calculatePrevFramePtr, and - // BaselineJIT.cpp/InitFromBailout. Check for the |#if defined(JS_CPU_X86)| portions. + // BaselineJIT.cpp/InitFromBailout. Check for the |#if defined(JS_CODEGEN_X86)| portions. masm.push(FramePointer); masm.movl(esp, FramePointer); // Save %esp. diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index b8aaccf034a..b9c98f62468 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -5901,12 +5901,12 @@ main(int argc, char **argv, char **envp) if (op.getBoolOption('O')) OOM_printAllocationCount = true; -#if defined(JS_CPU_X86) && defined(JS_ION) +#if defined(JS_CODEGEN_X86) && defined(JS_ION) if (op.getBoolOption("no-fpu")) JSC::MacroAssembler::SetFloatingPointDisabled(); #endif -#if (defined(JS_CPU_X86) || defined(JS_CPU_X64)) && defined(JS_ION) +#if (defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64)) && defined(JS_ION) if (op.getBoolOption("no-sse3")) { JSC::MacroAssembler::SetSSE3Disabled(); PropagateFlagToNestedShells("--no-sse3"); From d1d5ad6377f6e41e613881c5e2f3ae38cde5160f Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Mon, 6 Jan 2014 13:24:31 -0500 Subject: [PATCH 054/296] Bug 957593 - part 1 - eliminate TX_MATCH_CHAR; r=peterv --- dom/xslt/xslt/txXSLTNumber.cpp | 114 ++++++++++++++++----------------- 1 file changed, 56 insertions(+), 58 deletions(-) diff --git a/dom/xslt/xslt/txXSLTNumber.cpp b/dom/xslt/xslt/txXSLTNumber.cpp index 0175720099d..1fd0853956f 100644 --- a/dom/xslt/xslt/txXSLTNumber.cpp +++ b/dom/xslt/xslt/txXSLTNumber.cpp @@ -421,17 +421,15 @@ txXSLTNumber::getPrevInDocumentOrder(txXPathTreeWalker& aWalker) #define TX_CHAR_RANGE(ch, a, b) if (ch < a) return false; \ if (ch <= b) return true -#define TX_MATCH_CHAR(ch, a) if (ch < a) return false; \ - if (ch == a) return true bool txXSLTNumber::isAlphaNumeric(char16_t ch) { TX_CHAR_RANGE(ch, 0x0030, 0x0039); TX_CHAR_RANGE(ch, 0x0041, 0x005A); TX_CHAR_RANGE(ch, 0x0061, 0x007A); - TX_MATCH_CHAR(ch, 0x00AA); + TX_CHAR_RANGE(ch, 0x00AA, 0x00AA); TX_CHAR_RANGE(ch, 0x00B2, 0x00B3); - TX_MATCH_CHAR(ch, 0x00B5); + TX_CHAR_RANGE(ch, 0x00B5, 0x00B5); TX_CHAR_RANGE(ch, 0x00B9, 0x00BA); TX_CHAR_RANGE(ch, 0x00BC, 0x00BE); TX_CHAR_RANGE(ch, 0x00C0, 0x00D6); @@ -443,11 +441,11 @@ bool txXSLTNumber::isAlphaNumeric(char16_t ch) TX_CHAR_RANGE(ch, 0x02BB, 0x02C1); TX_CHAR_RANGE(ch, 0x02D0, 0x02D1); TX_CHAR_RANGE(ch, 0x02E0, 0x02E4); - TX_MATCH_CHAR(ch, 0x02EE); - TX_MATCH_CHAR(ch, 0x037A); - TX_MATCH_CHAR(ch, 0x0386); + TX_CHAR_RANGE(ch, 0x02EE, 0x02EE); + TX_CHAR_RANGE(ch, 0x037A, 0x037A); + TX_CHAR_RANGE(ch, 0x0386, 0x0386); TX_CHAR_RANGE(ch, 0x0388, 0x038A); - TX_MATCH_CHAR(ch, 0x038C); + TX_CHAR_RANGE(ch, 0x038C, 0x038C); TX_CHAR_RANGE(ch, 0x038E, 0x03A1); TX_CHAR_RANGE(ch, 0x03A3, 0x03CE); TX_CHAR_RANGE(ch, 0x03D0, 0x03D7); @@ -459,7 +457,7 @@ bool txXSLTNumber::isAlphaNumeric(char16_t ch) TX_CHAR_RANGE(ch, 0x04D0, 0x04F5); TX_CHAR_RANGE(ch, 0x04F8, 0x04F9); TX_CHAR_RANGE(ch, 0x0531, 0x0556); - TX_MATCH_CHAR(ch, 0x0559); + TX_CHAR_RANGE(ch, 0x0559, 0x0559); TX_CHAR_RANGE(ch, 0x0561, 0x0587); TX_CHAR_RANGE(ch, 0x05D0, 0x05EA); TX_CHAR_RANGE(ch, 0x05F0, 0x05F2); @@ -467,22 +465,22 @@ bool txXSLTNumber::isAlphaNumeric(char16_t ch) TX_CHAR_RANGE(ch, 0x0640, 0x064A); TX_CHAR_RANGE(ch, 0x0660, 0x0669); TX_CHAR_RANGE(ch, 0x0671, 0x06D3); - TX_MATCH_CHAR(ch, 0x06D5); + TX_CHAR_RANGE(ch, 0x06D5, 0x06D5); TX_CHAR_RANGE(ch, 0x06E5, 0x06E6); TX_CHAR_RANGE(ch, 0x06F0, 0x06FC); - TX_MATCH_CHAR(ch, 0x0710); + TX_CHAR_RANGE(ch, 0x0710, 0x0710); TX_CHAR_RANGE(ch, 0x0712, 0x072C); TX_CHAR_RANGE(ch, 0x0780, 0x07A5); TX_CHAR_RANGE(ch, 0x0905, 0x0939); - TX_MATCH_CHAR(ch, 0x093D); - TX_MATCH_CHAR(ch, 0x0950); + TX_CHAR_RANGE(ch, 0x093D, 0x093D); + TX_CHAR_RANGE(ch, 0x0950, 0x0950); TX_CHAR_RANGE(ch, 0x0958, 0x0961); TX_CHAR_RANGE(ch, 0x0966, 0x096F); TX_CHAR_RANGE(ch, 0x0985, 0x098C); TX_CHAR_RANGE(ch, 0x098F, 0x0990); TX_CHAR_RANGE(ch, 0x0993, 0x09A8); TX_CHAR_RANGE(ch, 0x09AA, 0x09B0); - TX_MATCH_CHAR(ch, 0x09B2); + TX_CHAR_RANGE(ch, 0x09B2, 0x09B2); TX_CHAR_RANGE(ch, 0x09B6, 0x09B9); TX_CHAR_RANGE(ch, 0x09DC, 0x09DD); TX_CHAR_RANGE(ch, 0x09DF, 0x09E1); @@ -496,19 +494,19 @@ bool txXSLTNumber::isAlphaNumeric(char16_t ch) TX_CHAR_RANGE(ch, 0x0A35, 0x0A36); TX_CHAR_RANGE(ch, 0x0A38, 0x0A39); TX_CHAR_RANGE(ch, 0x0A59, 0x0A5C); - TX_MATCH_CHAR(ch, 0x0A5E); + TX_CHAR_RANGE(ch, 0x0A5E, 0x0A5E); TX_CHAR_RANGE(ch, 0x0A66, 0x0A6F); TX_CHAR_RANGE(ch, 0x0A72, 0x0A74); TX_CHAR_RANGE(ch, 0x0A85, 0x0A8B); - TX_MATCH_CHAR(ch, 0x0A8D); + TX_CHAR_RANGE(ch, 0x0A8D, 0x0A8D); TX_CHAR_RANGE(ch, 0x0A8F, 0x0A91); TX_CHAR_RANGE(ch, 0x0A93, 0x0AA8); TX_CHAR_RANGE(ch, 0x0AAA, 0x0AB0); TX_CHAR_RANGE(ch, 0x0AB2, 0x0AB3); TX_CHAR_RANGE(ch, 0x0AB5, 0x0AB9); - TX_MATCH_CHAR(ch, 0x0ABD); - TX_MATCH_CHAR(ch, 0x0AD0); - TX_MATCH_CHAR(ch, 0x0AE0); + TX_CHAR_RANGE(ch, 0x0ABD, 0x0ABD); + TX_CHAR_RANGE(ch, 0x0AD0, 0x0AD0); + TX_CHAR_RANGE(ch, 0x0AE0, 0x0AE0); TX_CHAR_RANGE(ch, 0x0AE6, 0x0AEF); TX_CHAR_RANGE(ch, 0x0B05, 0x0B0C); TX_CHAR_RANGE(ch, 0x0B0F, 0x0B10); @@ -516,7 +514,7 @@ bool txXSLTNumber::isAlphaNumeric(char16_t ch) TX_CHAR_RANGE(ch, 0x0B2A, 0x0B30); TX_CHAR_RANGE(ch, 0x0B32, 0x0B33); TX_CHAR_RANGE(ch, 0x0B36, 0x0B39); - TX_MATCH_CHAR(ch, 0x0B3D); + TX_CHAR_RANGE(ch, 0x0B3D, 0x0B3D); TX_CHAR_RANGE(ch, 0x0B5C, 0x0B5D); TX_CHAR_RANGE(ch, 0x0B5F, 0x0B61); TX_CHAR_RANGE(ch, 0x0B66, 0x0B6F); @@ -524,7 +522,7 @@ bool txXSLTNumber::isAlphaNumeric(char16_t ch) TX_CHAR_RANGE(ch, 0x0B8E, 0x0B90); TX_CHAR_RANGE(ch, 0x0B92, 0x0B95); TX_CHAR_RANGE(ch, 0x0B99, 0x0B9A); - TX_MATCH_CHAR(ch, 0x0B9C); + TX_CHAR_RANGE(ch, 0x0B9C, 0x0B9C); TX_CHAR_RANGE(ch, 0x0B9E, 0x0B9F); TX_CHAR_RANGE(ch, 0x0BA3, 0x0BA4); TX_CHAR_RANGE(ch, 0x0BA8, 0x0BAA); @@ -543,7 +541,7 @@ bool txXSLTNumber::isAlphaNumeric(char16_t ch) TX_CHAR_RANGE(ch, 0x0C92, 0x0CA8); TX_CHAR_RANGE(ch, 0x0CAA, 0x0CB3); TX_CHAR_RANGE(ch, 0x0CB5, 0x0CB9); - TX_MATCH_CHAR(ch, 0x0CDE); + TX_CHAR_RANGE(ch, 0x0CDE, 0x0CDE); TX_CHAR_RANGE(ch, 0x0CE0, 0x0CE1); TX_CHAR_RANGE(ch, 0x0CE6, 0x0CEF); TX_CHAR_RANGE(ch, 0x0D05, 0x0D0C); @@ -555,31 +553,31 @@ bool txXSLTNumber::isAlphaNumeric(char16_t ch) TX_CHAR_RANGE(ch, 0x0D85, 0x0D96); TX_CHAR_RANGE(ch, 0x0D9A, 0x0DB1); TX_CHAR_RANGE(ch, 0x0DB3, 0x0DBB); - TX_MATCH_CHAR(ch, 0x0DBD); + TX_CHAR_RANGE(ch, 0x0DBD, 0x0DBD); TX_CHAR_RANGE(ch, 0x0DC0, 0x0DC6); TX_CHAR_RANGE(ch, 0x0E01, 0x0E30); TX_CHAR_RANGE(ch, 0x0E32, 0x0E33); TX_CHAR_RANGE(ch, 0x0E40, 0x0E46); TX_CHAR_RANGE(ch, 0x0E50, 0x0E59); TX_CHAR_RANGE(ch, 0x0E81, 0x0E82); - TX_MATCH_CHAR(ch, 0x0E84); + TX_CHAR_RANGE(ch, 0x0E84, 0x0E84); TX_CHAR_RANGE(ch, 0x0E87, 0x0E88); - TX_MATCH_CHAR(ch, 0x0E8A); - TX_MATCH_CHAR(ch, 0x0E8D); + TX_CHAR_RANGE(ch, 0x0E8A, 0x0E8A); + TX_CHAR_RANGE(ch, 0x0E8D, 0x0E8D); TX_CHAR_RANGE(ch, 0x0E94, 0x0E97); TX_CHAR_RANGE(ch, 0x0E99, 0x0E9F); TX_CHAR_RANGE(ch, 0x0EA1, 0x0EA3); - TX_MATCH_CHAR(ch, 0x0EA5); - TX_MATCH_CHAR(ch, 0x0EA7); + TX_CHAR_RANGE(ch, 0x0EA5, 0x0EA5); + TX_CHAR_RANGE(ch, 0x0EA7, 0x0EA7); TX_CHAR_RANGE(ch, 0x0EAA, 0x0EAB); TX_CHAR_RANGE(ch, 0x0EAD, 0x0EB0); TX_CHAR_RANGE(ch, 0x0EB2, 0x0EB3); - TX_MATCH_CHAR(ch, 0x0EBD); + TX_CHAR_RANGE(ch, 0x0EBD, 0x0EBD); TX_CHAR_RANGE(ch, 0x0EC0, 0x0EC4); - TX_MATCH_CHAR(ch, 0x0EC6); + TX_CHAR_RANGE(ch, 0x0EC6, 0x0EC6); TX_CHAR_RANGE(ch, 0x0ED0, 0x0ED9); TX_CHAR_RANGE(ch, 0x0EDC, 0x0EDD); - TX_MATCH_CHAR(ch, 0x0F00); + TX_CHAR_RANGE(ch, 0x0F00, 0x0F00); TX_CHAR_RANGE(ch, 0x0F20, 0x0F33); TX_CHAR_RANGE(ch, 0x0F40, 0x0F47); TX_CHAR_RANGE(ch, 0x0F49, 0x0F6A); @@ -596,25 +594,25 @@ bool txXSLTNumber::isAlphaNumeric(char16_t ch) TX_CHAR_RANGE(ch, 0x11A8, 0x11F9); TX_CHAR_RANGE(ch, 0x1200, 0x1206); TX_CHAR_RANGE(ch, 0x1208, 0x1246); - TX_MATCH_CHAR(ch, 0x1248); + TX_CHAR_RANGE(ch, 0x1248, 0x1248); TX_CHAR_RANGE(ch, 0x124A, 0x124D); TX_CHAR_RANGE(ch, 0x1250, 0x1256); - TX_MATCH_CHAR(ch, 0x1258); + TX_CHAR_RANGE(ch, 0x1258, 0x1258); TX_CHAR_RANGE(ch, 0x125A, 0x125D); TX_CHAR_RANGE(ch, 0x1260, 0x1286); - TX_MATCH_CHAR(ch, 0x1288); + TX_CHAR_RANGE(ch, 0x1288, 0x1288); TX_CHAR_RANGE(ch, 0x128A, 0x128D); TX_CHAR_RANGE(ch, 0x1290, 0x12AE); - TX_MATCH_CHAR(ch, 0x12B0); + TX_CHAR_RANGE(ch, 0x12B0, 0x12B0); TX_CHAR_RANGE(ch, 0x12B2, 0x12B5); TX_CHAR_RANGE(ch, 0x12B8, 0x12BE); - TX_MATCH_CHAR(ch, 0x12C0); + TX_CHAR_RANGE(ch, 0x12C0, 0x12C0); TX_CHAR_RANGE(ch, 0x12C2, 0x12C5); TX_CHAR_RANGE(ch, 0x12C8, 0x12CE); TX_CHAR_RANGE(ch, 0x12D0, 0x12D6); TX_CHAR_RANGE(ch, 0x12D8, 0x12EE); TX_CHAR_RANGE(ch, 0x12F0, 0x130E); - TX_MATCH_CHAR(ch, 0x1310); + TX_CHAR_RANGE(ch, 0x1310, 0x1310); TX_CHAR_RANGE(ch, 0x1312, 0x1315); TX_CHAR_RANGE(ch, 0x1318, 0x131E); TX_CHAR_RANGE(ch, 0x1320, 0x1346); @@ -638,13 +636,13 @@ bool txXSLTNumber::isAlphaNumeric(char16_t ch) TX_CHAR_RANGE(ch, 0x1F20, 0x1F45); TX_CHAR_RANGE(ch, 0x1F48, 0x1F4D); TX_CHAR_RANGE(ch, 0x1F50, 0x1F57); - TX_MATCH_CHAR(ch, 0x1F59); - TX_MATCH_CHAR(ch, 0x1F5B); - TX_MATCH_CHAR(ch, 0x1F5D); + TX_CHAR_RANGE(ch, 0x1F59, 0x1F59); + TX_CHAR_RANGE(ch, 0x1F5B, 0x1F5B); + TX_CHAR_RANGE(ch, 0x1F5D, 0x1F5D); TX_CHAR_RANGE(ch, 0x1F5F, 0x1F7D); TX_CHAR_RANGE(ch, 0x1F80, 0x1FB4); TX_CHAR_RANGE(ch, 0x1FB6, 0x1FBC); - TX_MATCH_CHAR(ch, 0x1FBE); + TX_CHAR_RANGE(ch, 0x1FBE, 0x1FBE); TX_CHAR_RANGE(ch, 0x1FC2, 0x1FC4); TX_CHAR_RANGE(ch, 0x1FC6, 0x1FCC); TX_CHAR_RANGE(ch, 0x1FD0, 0x1FD3); @@ -652,23 +650,23 @@ bool txXSLTNumber::isAlphaNumeric(char16_t ch) TX_CHAR_RANGE(ch, 0x1FE0, 0x1FEC); TX_CHAR_RANGE(ch, 0x1FF2, 0x1FF4); TX_CHAR_RANGE(ch, 0x1FF6, 0x1FFC); - TX_MATCH_CHAR(ch, 0x2070); + TX_CHAR_RANGE(ch, 0x2070, 0x2070); TX_CHAR_RANGE(ch, 0x2074, 0x2079); TX_CHAR_RANGE(ch, 0x207F, 0x2089); - TX_MATCH_CHAR(ch, 0x2102); - TX_MATCH_CHAR(ch, 0x2107); + TX_CHAR_RANGE(ch, 0x2102, 0x2102); + TX_CHAR_RANGE(ch, 0x2107, 0x2107); TX_CHAR_RANGE(ch, 0x210A, 0x2113); - TX_MATCH_CHAR(ch, 0x2115); + TX_CHAR_RANGE(ch, 0x2115, 0x2115); TX_CHAR_RANGE(ch, 0x2119, 0x211D); - TX_MATCH_CHAR(ch, 0x2124); - TX_MATCH_CHAR(ch, 0x2126); - TX_MATCH_CHAR(ch, 0x2128); + TX_CHAR_RANGE(ch, 0x2124, 0x2124); + TX_CHAR_RANGE(ch, 0x2126, 0x2126); + TX_CHAR_RANGE(ch, 0x2128, 0x2128); TX_CHAR_RANGE(ch, 0x212A, 0x212D); TX_CHAR_RANGE(ch, 0x212F, 0x2131); TX_CHAR_RANGE(ch, 0x2133, 0x2139); TX_CHAR_RANGE(ch, 0x2153, 0x2183); TX_CHAR_RANGE(ch, 0x2460, 0x249B); - TX_MATCH_CHAR(ch, 0x24EA); + TX_CHAR_RANGE(ch, 0x24EA, 0x24EA); TX_CHAR_RANGE(ch, 0x2776, 0x2793); TX_CHAR_RANGE(ch, 0x3005, 0x3007); TX_CHAR_RANGE(ch, 0x3021, 0x3029); @@ -684,21 +682,21 @@ bool txXSLTNumber::isAlphaNumeric(char16_t ch) TX_CHAR_RANGE(ch, 0x31A0, 0x31B7); TX_CHAR_RANGE(ch, 0x3220, 0x3229); TX_CHAR_RANGE(ch, 0x3280, 0x3289); - TX_MATCH_CHAR(ch, 0x3400); - TX_MATCH_CHAR(ch, 0x4DB5); - TX_MATCH_CHAR(ch, 0x4E00); - TX_MATCH_CHAR(ch, 0x9FA5); + TX_CHAR_RANGE(ch, 0x3400, 0x3400); + TX_CHAR_RANGE(ch, 0x4DB5, 0x4DB5); + TX_CHAR_RANGE(ch, 0x4E00, 0x4E00); + TX_CHAR_RANGE(ch, 0x9FA5, 0x9FA5); TX_CHAR_RANGE(ch, 0xA000, 0xA48C); - TX_MATCH_CHAR(ch, 0xAC00); - TX_MATCH_CHAR(ch, 0xD7A3); + TX_CHAR_RANGE(ch, 0xAC00, 0xAC00); + TX_CHAR_RANGE(ch, 0xD7A3, 0xD7A3); TX_CHAR_RANGE(ch, 0xF900, 0xFA2D); TX_CHAR_RANGE(ch, 0xFB00, 0xFB06); TX_CHAR_RANGE(ch, 0xFB13, 0xFB17); - TX_MATCH_CHAR(ch, 0xFB1D); + TX_CHAR_RANGE(ch, 0xFB1D, 0xFB1D); TX_CHAR_RANGE(ch, 0xFB1F, 0xFB28); TX_CHAR_RANGE(ch, 0xFB2A, 0xFB36); TX_CHAR_RANGE(ch, 0xFB38, 0xFB3C); - TX_MATCH_CHAR(ch, 0xFB3E); + TX_CHAR_RANGE(ch, 0xFB3E, 0xFB3E); TX_CHAR_RANGE(ch, 0xFB40, 0xFB41); TX_CHAR_RANGE(ch, 0xFB43, 0xFB44); TX_CHAR_RANGE(ch, 0xFB46, 0xFBB1); @@ -707,7 +705,7 @@ bool txXSLTNumber::isAlphaNumeric(char16_t ch) TX_CHAR_RANGE(ch, 0xFD92, 0xFDC7); TX_CHAR_RANGE(ch, 0xFDF0, 0xFDFB); TX_CHAR_RANGE(ch, 0xFE70, 0xFE72); - TX_MATCH_CHAR(ch, 0xFE74); + TX_CHAR_RANGE(ch, 0xFE74, 0xFE74); TX_CHAR_RANGE(ch, 0xFE76, 0xFEFC); TX_CHAR_RANGE(ch, 0xFF10, 0xFF19); TX_CHAR_RANGE(ch, 0xFF21, 0xFF3A); From bf35a9e411e99fe2e4fdc56f8e401edfdd583fd1 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Mon, 6 Jan 2014 13:38:53 -0500 Subject: [PATCH 055/296] Bug 957593 - part 2 - implement txXSLTNumber::isAlphaNumeric with binary search for a codesize win; r=peterv --- dom/xslt/xslt/txXSLTNumber.cpp | 604 +++++++++++++++++---------------- 1 file changed, 311 insertions(+), 293 deletions(-) diff --git a/dom/xslt/xslt/txXSLTNumber.cpp b/dom/xslt/xslt/txXSLTNumber.cpp index 1fd0853956f..b99985926d4 100644 --- a/dom/xslt/xslt/txXSLTNumber.cpp +++ b/dom/xslt/xslt/txXSLTNumber.cpp @@ -3,6 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "mozilla/ArrayUtils.h" #include "mozilla/FloatingPoint.h" #include "txXSLTNumber.h" @@ -14,6 +15,8 @@ #include "txIXPathContext.h" #include "txXPathTreeWalker.h" +#include + nsresult txXSLTNumber::createNumber(Expr* aValueExpr, txPattern* aCountPattern, txPattern* aFromPattern, LevelType aLevel, Expr* aGroupSize, Expr* aGroupSeparator, @@ -419,300 +422,315 @@ txXSLTNumber::getPrevInDocumentOrder(txXPathTreeWalker& aWalker) return aWalker.moveToParent(); } -#define TX_CHAR_RANGE(ch, a, b) if (ch < a) return false; \ - if (ch <= b) return true +struct CharRange { + char16_t lower; // inclusive + char16_t upper; // inclusive + + bool operator<(const CharRange& other) const { + return upper < other.lower; + } +}; bool txXSLTNumber::isAlphaNumeric(char16_t ch) { - TX_CHAR_RANGE(ch, 0x0030, 0x0039); - TX_CHAR_RANGE(ch, 0x0041, 0x005A); - TX_CHAR_RANGE(ch, 0x0061, 0x007A); - TX_CHAR_RANGE(ch, 0x00AA, 0x00AA); - TX_CHAR_RANGE(ch, 0x00B2, 0x00B3); - TX_CHAR_RANGE(ch, 0x00B5, 0x00B5); - TX_CHAR_RANGE(ch, 0x00B9, 0x00BA); - TX_CHAR_RANGE(ch, 0x00BC, 0x00BE); - TX_CHAR_RANGE(ch, 0x00C0, 0x00D6); - TX_CHAR_RANGE(ch, 0x00D8, 0x00F6); - TX_CHAR_RANGE(ch, 0x00F8, 0x021F); - TX_CHAR_RANGE(ch, 0x0222, 0x0233); - TX_CHAR_RANGE(ch, 0x0250, 0x02AD); - TX_CHAR_RANGE(ch, 0x02B0, 0x02B8); - TX_CHAR_RANGE(ch, 0x02BB, 0x02C1); - TX_CHAR_RANGE(ch, 0x02D0, 0x02D1); - TX_CHAR_RANGE(ch, 0x02E0, 0x02E4); - TX_CHAR_RANGE(ch, 0x02EE, 0x02EE); - TX_CHAR_RANGE(ch, 0x037A, 0x037A); - TX_CHAR_RANGE(ch, 0x0386, 0x0386); - TX_CHAR_RANGE(ch, 0x0388, 0x038A); - TX_CHAR_RANGE(ch, 0x038C, 0x038C); - TX_CHAR_RANGE(ch, 0x038E, 0x03A1); - TX_CHAR_RANGE(ch, 0x03A3, 0x03CE); - TX_CHAR_RANGE(ch, 0x03D0, 0x03D7); - TX_CHAR_RANGE(ch, 0x03DA, 0x03F3); - TX_CHAR_RANGE(ch, 0x0400, 0x0481); - TX_CHAR_RANGE(ch, 0x048C, 0x04C4); - TX_CHAR_RANGE(ch, 0x04C7, 0x04C8); - TX_CHAR_RANGE(ch, 0x04CB, 0x04CC); - TX_CHAR_RANGE(ch, 0x04D0, 0x04F5); - TX_CHAR_RANGE(ch, 0x04F8, 0x04F9); - TX_CHAR_RANGE(ch, 0x0531, 0x0556); - TX_CHAR_RANGE(ch, 0x0559, 0x0559); - TX_CHAR_RANGE(ch, 0x0561, 0x0587); - TX_CHAR_RANGE(ch, 0x05D0, 0x05EA); - TX_CHAR_RANGE(ch, 0x05F0, 0x05F2); - TX_CHAR_RANGE(ch, 0x0621, 0x063A); - TX_CHAR_RANGE(ch, 0x0640, 0x064A); - TX_CHAR_RANGE(ch, 0x0660, 0x0669); - TX_CHAR_RANGE(ch, 0x0671, 0x06D3); - TX_CHAR_RANGE(ch, 0x06D5, 0x06D5); - TX_CHAR_RANGE(ch, 0x06E5, 0x06E6); - TX_CHAR_RANGE(ch, 0x06F0, 0x06FC); - TX_CHAR_RANGE(ch, 0x0710, 0x0710); - TX_CHAR_RANGE(ch, 0x0712, 0x072C); - TX_CHAR_RANGE(ch, 0x0780, 0x07A5); - TX_CHAR_RANGE(ch, 0x0905, 0x0939); - TX_CHAR_RANGE(ch, 0x093D, 0x093D); - TX_CHAR_RANGE(ch, 0x0950, 0x0950); - TX_CHAR_RANGE(ch, 0x0958, 0x0961); - TX_CHAR_RANGE(ch, 0x0966, 0x096F); - TX_CHAR_RANGE(ch, 0x0985, 0x098C); - TX_CHAR_RANGE(ch, 0x098F, 0x0990); - TX_CHAR_RANGE(ch, 0x0993, 0x09A8); - TX_CHAR_RANGE(ch, 0x09AA, 0x09B0); - TX_CHAR_RANGE(ch, 0x09B2, 0x09B2); - TX_CHAR_RANGE(ch, 0x09B6, 0x09B9); - TX_CHAR_RANGE(ch, 0x09DC, 0x09DD); - TX_CHAR_RANGE(ch, 0x09DF, 0x09E1); - TX_CHAR_RANGE(ch, 0x09E6, 0x09F1); - TX_CHAR_RANGE(ch, 0x09F4, 0x09F9); - TX_CHAR_RANGE(ch, 0x0A05, 0x0A0A); - TX_CHAR_RANGE(ch, 0x0A0F, 0x0A10); - TX_CHAR_RANGE(ch, 0x0A13, 0x0A28); - TX_CHAR_RANGE(ch, 0x0A2A, 0x0A30); - TX_CHAR_RANGE(ch, 0x0A32, 0x0A33); - TX_CHAR_RANGE(ch, 0x0A35, 0x0A36); - TX_CHAR_RANGE(ch, 0x0A38, 0x0A39); - TX_CHAR_RANGE(ch, 0x0A59, 0x0A5C); - TX_CHAR_RANGE(ch, 0x0A5E, 0x0A5E); - TX_CHAR_RANGE(ch, 0x0A66, 0x0A6F); - TX_CHAR_RANGE(ch, 0x0A72, 0x0A74); - TX_CHAR_RANGE(ch, 0x0A85, 0x0A8B); - TX_CHAR_RANGE(ch, 0x0A8D, 0x0A8D); - TX_CHAR_RANGE(ch, 0x0A8F, 0x0A91); - TX_CHAR_RANGE(ch, 0x0A93, 0x0AA8); - TX_CHAR_RANGE(ch, 0x0AAA, 0x0AB0); - TX_CHAR_RANGE(ch, 0x0AB2, 0x0AB3); - TX_CHAR_RANGE(ch, 0x0AB5, 0x0AB9); - TX_CHAR_RANGE(ch, 0x0ABD, 0x0ABD); - TX_CHAR_RANGE(ch, 0x0AD0, 0x0AD0); - TX_CHAR_RANGE(ch, 0x0AE0, 0x0AE0); - TX_CHAR_RANGE(ch, 0x0AE6, 0x0AEF); - TX_CHAR_RANGE(ch, 0x0B05, 0x0B0C); - TX_CHAR_RANGE(ch, 0x0B0F, 0x0B10); - TX_CHAR_RANGE(ch, 0x0B13, 0x0B28); - TX_CHAR_RANGE(ch, 0x0B2A, 0x0B30); - TX_CHAR_RANGE(ch, 0x0B32, 0x0B33); - TX_CHAR_RANGE(ch, 0x0B36, 0x0B39); - TX_CHAR_RANGE(ch, 0x0B3D, 0x0B3D); - TX_CHAR_RANGE(ch, 0x0B5C, 0x0B5D); - TX_CHAR_RANGE(ch, 0x0B5F, 0x0B61); - TX_CHAR_RANGE(ch, 0x0B66, 0x0B6F); - TX_CHAR_RANGE(ch, 0x0B85, 0x0B8A); - TX_CHAR_RANGE(ch, 0x0B8E, 0x0B90); - TX_CHAR_RANGE(ch, 0x0B92, 0x0B95); - TX_CHAR_RANGE(ch, 0x0B99, 0x0B9A); - TX_CHAR_RANGE(ch, 0x0B9C, 0x0B9C); - TX_CHAR_RANGE(ch, 0x0B9E, 0x0B9F); - TX_CHAR_RANGE(ch, 0x0BA3, 0x0BA4); - TX_CHAR_RANGE(ch, 0x0BA8, 0x0BAA); - TX_CHAR_RANGE(ch, 0x0BAE, 0x0BB5); - TX_CHAR_RANGE(ch, 0x0BB7, 0x0BB9); - TX_CHAR_RANGE(ch, 0x0BE7, 0x0BF2); - TX_CHAR_RANGE(ch, 0x0C05, 0x0C0C); - TX_CHAR_RANGE(ch, 0x0C0E, 0x0C10); - TX_CHAR_RANGE(ch, 0x0C12, 0x0C28); - TX_CHAR_RANGE(ch, 0x0C2A, 0x0C33); - TX_CHAR_RANGE(ch, 0x0C35, 0x0C39); - TX_CHAR_RANGE(ch, 0x0C60, 0x0C61); - TX_CHAR_RANGE(ch, 0x0C66, 0x0C6F); - TX_CHAR_RANGE(ch, 0x0C85, 0x0C8C); - TX_CHAR_RANGE(ch, 0x0C8E, 0x0C90); - TX_CHAR_RANGE(ch, 0x0C92, 0x0CA8); - TX_CHAR_RANGE(ch, 0x0CAA, 0x0CB3); - TX_CHAR_RANGE(ch, 0x0CB5, 0x0CB9); - TX_CHAR_RANGE(ch, 0x0CDE, 0x0CDE); - TX_CHAR_RANGE(ch, 0x0CE0, 0x0CE1); - TX_CHAR_RANGE(ch, 0x0CE6, 0x0CEF); - TX_CHAR_RANGE(ch, 0x0D05, 0x0D0C); - TX_CHAR_RANGE(ch, 0x0D0E, 0x0D10); - TX_CHAR_RANGE(ch, 0x0D12, 0x0D28); - TX_CHAR_RANGE(ch, 0x0D2A, 0x0D39); - TX_CHAR_RANGE(ch, 0x0D60, 0x0D61); - TX_CHAR_RANGE(ch, 0x0D66, 0x0D6F); - TX_CHAR_RANGE(ch, 0x0D85, 0x0D96); - TX_CHAR_RANGE(ch, 0x0D9A, 0x0DB1); - TX_CHAR_RANGE(ch, 0x0DB3, 0x0DBB); - TX_CHAR_RANGE(ch, 0x0DBD, 0x0DBD); - TX_CHAR_RANGE(ch, 0x0DC0, 0x0DC6); - TX_CHAR_RANGE(ch, 0x0E01, 0x0E30); - TX_CHAR_RANGE(ch, 0x0E32, 0x0E33); - TX_CHAR_RANGE(ch, 0x0E40, 0x0E46); - TX_CHAR_RANGE(ch, 0x0E50, 0x0E59); - TX_CHAR_RANGE(ch, 0x0E81, 0x0E82); - TX_CHAR_RANGE(ch, 0x0E84, 0x0E84); - TX_CHAR_RANGE(ch, 0x0E87, 0x0E88); - TX_CHAR_RANGE(ch, 0x0E8A, 0x0E8A); - TX_CHAR_RANGE(ch, 0x0E8D, 0x0E8D); - TX_CHAR_RANGE(ch, 0x0E94, 0x0E97); - TX_CHAR_RANGE(ch, 0x0E99, 0x0E9F); - TX_CHAR_RANGE(ch, 0x0EA1, 0x0EA3); - TX_CHAR_RANGE(ch, 0x0EA5, 0x0EA5); - TX_CHAR_RANGE(ch, 0x0EA7, 0x0EA7); - TX_CHAR_RANGE(ch, 0x0EAA, 0x0EAB); - TX_CHAR_RANGE(ch, 0x0EAD, 0x0EB0); - TX_CHAR_RANGE(ch, 0x0EB2, 0x0EB3); - TX_CHAR_RANGE(ch, 0x0EBD, 0x0EBD); - TX_CHAR_RANGE(ch, 0x0EC0, 0x0EC4); - TX_CHAR_RANGE(ch, 0x0EC6, 0x0EC6); - TX_CHAR_RANGE(ch, 0x0ED0, 0x0ED9); - TX_CHAR_RANGE(ch, 0x0EDC, 0x0EDD); - TX_CHAR_RANGE(ch, 0x0F00, 0x0F00); - TX_CHAR_RANGE(ch, 0x0F20, 0x0F33); - TX_CHAR_RANGE(ch, 0x0F40, 0x0F47); - TX_CHAR_RANGE(ch, 0x0F49, 0x0F6A); - TX_CHAR_RANGE(ch, 0x0F88, 0x0F8B); - TX_CHAR_RANGE(ch, 0x1000, 0x1021); - TX_CHAR_RANGE(ch, 0x1023, 0x1027); - TX_CHAR_RANGE(ch, 0x1029, 0x102A); - TX_CHAR_RANGE(ch, 0x1040, 0x1049); - TX_CHAR_RANGE(ch, 0x1050, 0x1055); - TX_CHAR_RANGE(ch, 0x10A0, 0x10C5); - TX_CHAR_RANGE(ch, 0x10D0, 0x10F6); - TX_CHAR_RANGE(ch, 0x1100, 0x1159); - TX_CHAR_RANGE(ch, 0x115F, 0x11A2); - TX_CHAR_RANGE(ch, 0x11A8, 0x11F9); - TX_CHAR_RANGE(ch, 0x1200, 0x1206); - TX_CHAR_RANGE(ch, 0x1208, 0x1246); - TX_CHAR_RANGE(ch, 0x1248, 0x1248); - TX_CHAR_RANGE(ch, 0x124A, 0x124D); - TX_CHAR_RANGE(ch, 0x1250, 0x1256); - TX_CHAR_RANGE(ch, 0x1258, 0x1258); - TX_CHAR_RANGE(ch, 0x125A, 0x125D); - TX_CHAR_RANGE(ch, 0x1260, 0x1286); - TX_CHAR_RANGE(ch, 0x1288, 0x1288); - TX_CHAR_RANGE(ch, 0x128A, 0x128D); - TX_CHAR_RANGE(ch, 0x1290, 0x12AE); - TX_CHAR_RANGE(ch, 0x12B0, 0x12B0); - TX_CHAR_RANGE(ch, 0x12B2, 0x12B5); - TX_CHAR_RANGE(ch, 0x12B8, 0x12BE); - TX_CHAR_RANGE(ch, 0x12C0, 0x12C0); - TX_CHAR_RANGE(ch, 0x12C2, 0x12C5); - TX_CHAR_RANGE(ch, 0x12C8, 0x12CE); - TX_CHAR_RANGE(ch, 0x12D0, 0x12D6); - TX_CHAR_RANGE(ch, 0x12D8, 0x12EE); - TX_CHAR_RANGE(ch, 0x12F0, 0x130E); - TX_CHAR_RANGE(ch, 0x1310, 0x1310); - TX_CHAR_RANGE(ch, 0x1312, 0x1315); - TX_CHAR_RANGE(ch, 0x1318, 0x131E); - TX_CHAR_RANGE(ch, 0x1320, 0x1346); - TX_CHAR_RANGE(ch, 0x1348, 0x135A); - TX_CHAR_RANGE(ch, 0x1369, 0x137C); - TX_CHAR_RANGE(ch, 0x13A0, 0x13F4); - TX_CHAR_RANGE(ch, 0x1401, 0x166C); - TX_CHAR_RANGE(ch, 0x166F, 0x1676); - TX_CHAR_RANGE(ch, 0x1681, 0x169A); - TX_CHAR_RANGE(ch, 0x16A0, 0x16EA); - TX_CHAR_RANGE(ch, 0x16EE, 0x16F0); - TX_CHAR_RANGE(ch, 0x1780, 0x17B3); - TX_CHAR_RANGE(ch, 0x17E0, 0x17E9); - TX_CHAR_RANGE(ch, 0x1810, 0x1819); - TX_CHAR_RANGE(ch, 0x1820, 0x1877); - TX_CHAR_RANGE(ch, 0x1880, 0x18A8); - TX_CHAR_RANGE(ch, 0x1E00, 0x1E9B); - TX_CHAR_RANGE(ch, 0x1EA0, 0x1EF9); - TX_CHAR_RANGE(ch, 0x1F00, 0x1F15); - TX_CHAR_RANGE(ch, 0x1F18, 0x1F1D); - TX_CHAR_RANGE(ch, 0x1F20, 0x1F45); - TX_CHAR_RANGE(ch, 0x1F48, 0x1F4D); - TX_CHAR_RANGE(ch, 0x1F50, 0x1F57); - TX_CHAR_RANGE(ch, 0x1F59, 0x1F59); - TX_CHAR_RANGE(ch, 0x1F5B, 0x1F5B); - TX_CHAR_RANGE(ch, 0x1F5D, 0x1F5D); - TX_CHAR_RANGE(ch, 0x1F5F, 0x1F7D); - TX_CHAR_RANGE(ch, 0x1F80, 0x1FB4); - TX_CHAR_RANGE(ch, 0x1FB6, 0x1FBC); - TX_CHAR_RANGE(ch, 0x1FBE, 0x1FBE); - TX_CHAR_RANGE(ch, 0x1FC2, 0x1FC4); - TX_CHAR_RANGE(ch, 0x1FC6, 0x1FCC); - TX_CHAR_RANGE(ch, 0x1FD0, 0x1FD3); - TX_CHAR_RANGE(ch, 0x1FD6, 0x1FDB); - TX_CHAR_RANGE(ch, 0x1FE0, 0x1FEC); - TX_CHAR_RANGE(ch, 0x1FF2, 0x1FF4); - TX_CHAR_RANGE(ch, 0x1FF6, 0x1FFC); - TX_CHAR_RANGE(ch, 0x2070, 0x2070); - TX_CHAR_RANGE(ch, 0x2074, 0x2079); - TX_CHAR_RANGE(ch, 0x207F, 0x2089); - TX_CHAR_RANGE(ch, 0x2102, 0x2102); - TX_CHAR_RANGE(ch, 0x2107, 0x2107); - TX_CHAR_RANGE(ch, 0x210A, 0x2113); - TX_CHAR_RANGE(ch, 0x2115, 0x2115); - TX_CHAR_RANGE(ch, 0x2119, 0x211D); - TX_CHAR_RANGE(ch, 0x2124, 0x2124); - TX_CHAR_RANGE(ch, 0x2126, 0x2126); - TX_CHAR_RANGE(ch, 0x2128, 0x2128); - TX_CHAR_RANGE(ch, 0x212A, 0x212D); - TX_CHAR_RANGE(ch, 0x212F, 0x2131); - TX_CHAR_RANGE(ch, 0x2133, 0x2139); - TX_CHAR_RANGE(ch, 0x2153, 0x2183); - TX_CHAR_RANGE(ch, 0x2460, 0x249B); - TX_CHAR_RANGE(ch, 0x24EA, 0x24EA); - TX_CHAR_RANGE(ch, 0x2776, 0x2793); - TX_CHAR_RANGE(ch, 0x3005, 0x3007); - TX_CHAR_RANGE(ch, 0x3021, 0x3029); - TX_CHAR_RANGE(ch, 0x3031, 0x3035); - TX_CHAR_RANGE(ch, 0x3038, 0x303A); - TX_CHAR_RANGE(ch, 0x3041, 0x3094); - TX_CHAR_RANGE(ch, 0x309D, 0x309E); - TX_CHAR_RANGE(ch, 0x30A1, 0x30FA); - TX_CHAR_RANGE(ch, 0x30FC, 0x30FE); - TX_CHAR_RANGE(ch, 0x3105, 0x312C); - TX_CHAR_RANGE(ch, 0x3131, 0x318E); - TX_CHAR_RANGE(ch, 0x3192, 0x3195); - TX_CHAR_RANGE(ch, 0x31A0, 0x31B7); - TX_CHAR_RANGE(ch, 0x3220, 0x3229); - TX_CHAR_RANGE(ch, 0x3280, 0x3289); - TX_CHAR_RANGE(ch, 0x3400, 0x3400); - TX_CHAR_RANGE(ch, 0x4DB5, 0x4DB5); - TX_CHAR_RANGE(ch, 0x4E00, 0x4E00); - TX_CHAR_RANGE(ch, 0x9FA5, 0x9FA5); - TX_CHAR_RANGE(ch, 0xA000, 0xA48C); - TX_CHAR_RANGE(ch, 0xAC00, 0xAC00); - TX_CHAR_RANGE(ch, 0xD7A3, 0xD7A3); - TX_CHAR_RANGE(ch, 0xF900, 0xFA2D); - TX_CHAR_RANGE(ch, 0xFB00, 0xFB06); - TX_CHAR_RANGE(ch, 0xFB13, 0xFB17); - TX_CHAR_RANGE(ch, 0xFB1D, 0xFB1D); - TX_CHAR_RANGE(ch, 0xFB1F, 0xFB28); - TX_CHAR_RANGE(ch, 0xFB2A, 0xFB36); - TX_CHAR_RANGE(ch, 0xFB38, 0xFB3C); - TX_CHAR_RANGE(ch, 0xFB3E, 0xFB3E); - TX_CHAR_RANGE(ch, 0xFB40, 0xFB41); - TX_CHAR_RANGE(ch, 0xFB43, 0xFB44); - TX_CHAR_RANGE(ch, 0xFB46, 0xFBB1); - TX_CHAR_RANGE(ch, 0xFBD3, 0xFD3D); - TX_CHAR_RANGE(ch, 0xFD50, 0xFD8F); - TX_CHAR_RANGE(ch, 0xFD92, 0xFDC7); - TX_CHAR_RANGE(ch, 0xFDF0, 0xFDFB); - TX_CHAR_RANGE(ch, 0xFE70, 0xFE72); - TX_CHAR_RANGE(ch, 0xFE74, 0xFE74); - TX_CHAR_RANGE(ch, 0xFE76, 0xFEFC); - TX_CHAR_RANGE(ch, 0xFF10, 0xFF19); - TX_CHAR_RANGE(ch, 0xFF21, 0xFF3A); - TX_CHAR_RANGE(ch, 0xFF41, 0xFF5A); - TX_CHAR_RANGE(ch, 0xFF66, 0xFFBE); - TX_CHAR_RANGE(ch, 0xFFC2, 0xFFC7); - TX_CHAR_RANGE(ch, 0xFFCA, 0xFFCF); - TX_CHAR_RANGE(ch, 0xFFD2, 0xFFD7); - return false; + static const CharRange alphanumericRanges[] = { + { 0x0030, 0x0039 }, + { 0x0041, 0x005A }, + { 0x0061, 0x007A }, + { 0x00AA, 0x00AA }, + { 0x00B2, 0x00B3 }, + { 0x00B5, 0x00B5 }, + { 0x00B9, 0x00BA }, + { 0x00BC, 0x00BE }, + { 0x00C0, 0x00D6 }, + { 0x00D8, 0x00F6 }, + { 0x00F8, 0x021F }, + { 0x0222, 0x0233 }, + { 0x0250, 0x02AD }, + { 0x02B0, 0x02B8 }, + { 0x02BB, 0x02C1 }, + { 0x02D0, 0x02D1 }, + { 0x02E0, 0x02E4 }, + { 0x02EE, 0x02EE }, + { 0x037A, 0x037A }, + { 0x0386, 0x0386 }, + { 0x0388, 0x038A }, + { 0x038C, 0x038C }, + { 0x038E, 0x03A1 }, + { 0x03A3, 0x03CE }, + { 0x03D0, 0x03D7 }, + { 0x03DA, 0x03F3 }, + { 0x0400, 0x0481 }, + { 0x048C, 0x04C4 }, + { 0x04C7, 0x04C8 }, + { 0x04CB, 0x04CC }, + { 0x04D0, 0x04F5 }, + { 0x04F8, 0x04F9 }, + { 0x0531, 0x0556 }, + { 0x0559, 0x0559 }, + { 0x0561, 0x0587 }, + { 0x05D0, 0x05EA }, + { 0x05F0, 0x05F2 }, + { 0x0621, 0x063A }, + { 0x0640, 0x064A }, + { 0x0660, 0x0669 }, + { 0x0671, 0x06D3 }, + { 0x06D5, 0x06D5 }, + { 0x06E5, 0x06E6 }, + { 0x06F0, 0x06FC }, + { 0x0710, 0x0710 }, + { 0x0712, 0x072C }, + { 0x0780, 0x07A5 }, + { 0x0905, 0x0939 }, + { 0x093D, 0x093D }, + { 0x0950, 0x0950 }, + { 0x0958, 0x0961 }, + { 0x0966, 0x096F }, + { 0x0985, 0x098C }, + { 0x098F, 0x0990 }, + { 0x0993, 0x09A8 }, + { 0x09AA, 0x09B0 }, + { 0x09B2, 0x09B2 }, + { 0x09B6, 0x09B9 }, + { 0x09DC, 0x09DD }, + { 0x09DF, 0x09E1 }, + { 0x09E6, 0x09F1 }, + { 0x09F4, 0x09F9 }, + { 0x0A05, 0x0A0A }, + { 0x0A0F, 0x0A10 }, + { 0x0A13, 0x0A28 }, + { 0x0A2A, 0x0A30 }, + { 0x0A32, 0x0A33 }, + { 0x0A35, 0x0A36 }, + { 0x0A38, 0x0A39 }, + { 0x0A59, 0x0A5C }, + { 0x0A5E, 0x0A5E }, + { 0x0A66, 0x0A6F }, + { 0x0A72, 0x0A74 }, + { 0x0A85, 0x0A8B }, + { 0x0A8D, 0x0A8D }, + { 0x0A8F, 0x0A91 }, + { 0x0A93, 0x0AA8 }, + { 0x0AAA, 0x0AB0 }, + { 0x0AB2, 0x0AB3 }, + { 0x0AB5, 0x0AB9 }, + { 0x0ABD, 0x0ABD }, + { 0x0AD0, 0x0AD0 }, + { 0x0AE0, 0x0AE0 }, + { 0x0AE6, 0x0AEF }, + { 0x0B05, 0x0B0C }, + { 0x0B0F, 0x0B10 }, + { 0x0B13, 0x0B28 }, + { 0x0B2A, 0x0B30 }, + { 0x0B32, 0x0B33 }, + { 0x0B36, 0x0B39 }, + { 0x0B3D, 0x0B3D }, + { 0x0B5C, 0x0B5D }, + { 0x0B5F, 0x0B61 }, + { 0x0B66, 0x0B6F }, + { 0x0B85, 0x0B8A }, + { 0x0B8E, 0x0B90 }, + { 0x0B92, 0x0B95 }, + { 0x0B99, 0x0B9A }, + { 0x0B9C, 0x0B9C }, + { 0x0B9E, 0x0B9F }, + { 0x0BA3, 0x0BA4 }, + { 0x0BA8, 0x0BAA }, + { 0x0BAE, 0x0BB5 }, + { 0x0BB7, 0x0BB9 }, + { 0x0BE7, 0x0BF2 }, + { 0x0C05, 0x0C0C }, + { 0x0C0E, 0x0C10 }, + { 0x0C12, 0x0C28 }, + { 0x0C2A, 0x0C33 }, + { 0x0C35, 0x0C39 }, + { 0x0C60, 0x0C61 }, + { 0x0C66, 0x0C6F }, + { 0x0C85, 0x0C8C }, + { 0x0C8E, 0x0C90 }, + { 0x0C92, 0x0CA8 }, + { 0x0CAA, 0x0CB3 }, + { 0x0CB5, 0x0CB9 }, + { 0x0CDE, 0x0CDE }, + { 0x0CE0, 0x0CE1 }, + { 0x0CE6, 0x0CEF }, + { 0x0D05, 0x0D0C }, + { 0x0D0E, 0x0D10 }, + { 0x0D12, 0x0D28 }, + { 0x0D2A, 0x0D39 }, + { 0x0D60, 0x0D61 }, + { 0x0D66, 0x0D6F }, + { 0x0D85, 0x0D96 }, + { 0x0D9A, 0x0DB1 }, + { 0x0DB3, 0x0DBB }, + { 0x0DBD, 0x0DBD }, + { 0x0DC0, 0x0DC6 }, + { 0x0E01, 0x0E30 }, + { 0x0E32, 0x0E33 }, + { 0x0E40, 0x0E46 }, + { 0x0E50, 0x0E59 }, + { 0x0E81, 0x0E82 }, + { 0x0E84, 0x0E84 }, + { 0x0E87, 0x0E88 }, + { 0x0E8A, 0x0E8A }, + { 0x0E8D, 0x0E8D }, + { 0x0E94, 0x0E97 }, + { 0x0E99, 0x0E9F }, + { 0x0EA1, 0x0EA3 }, + { 0x0EA5, 0x0EA5 }, + { 0x0EA7, 0x0EA7 }, + { 0x0EAA, 0x0EAB }, + { 0x0EAD, 0x0EB0 }, + { 0x0EB2, 0x0EB3 }, + { 0x0EBD, 0x0EBD }, + { 0x0EC0, 0x0EC4 }, + { 0x0EC6, 0x0EC6 }, + { 0x0ED0, 0x0ED9 }, + { 0x0EDC, 0x0EDD }, + { 0x0F00, 0x0F00 }, + { 0x0F20, 0x0F33 }, + { 0x0F40, 0x0F47 }, + { 0x0F49, 0x0F6A }, + { 0x0F88, 0x0F8B }, + { 0x1000, 0x1021 }, + { 0x1023, 0x1027 }, + { 0x1029, 0x102A }, + { 0x1040, 0x1049 }, + { 0x1050, 0x1055 }, + { 0x10A0, 0x10C5 }, + { 0x10D0, 0x10F6 }, + { 0x1100, 0x1159 }, + { 0x115F, 0x11A2 }, + { 0x11A8, 0x11F9 }, + { 0x1200, 0x1206 }, + { 0x1208, 0x1246 }, + { 0x1248, 0x1248 }, + { 0x124A, 0x124D }, + { 0x1250, 0x1256 }, + { 0x1258, 0x1258 }, + { 0x125A, 0x125D }, + { 0x1260, 0x1286 }, + { 0x1288, 0x1288 }, + { 0x128A, 0x128D }, + { 0x1290, 0x12AE }, + { 0x12B0, 0x12B0 }, + { 0x12B2, 0x12B5 }, + { 0x12B8, 0x12BE }, + { 0x12C0, 0x12C0 }, + { 0x12C2, 0x12C5 }, + { 0x12C8, 0x12CE }, + { 0x12D0, 0x12D6 }, + { 0x12D8, 0x12EE }, + { 0x12F0, 0x130E }, + { 0x1310, 0x1310 }, + { 0x1312, 0x1315 }, + { 0x1318, 0x131E }, + { 0x1320, 0x1346 }, + { 0x1348, 0x135A }, + { 0x1369, 0x137C }, + { 0x13A0, 0x13F4 }, + { 0x1401, 0x166C }, + { 0x166F, 0x1676 }, + { 0x1681, 0x169A }, + { 0x16A0, 0x16EA }, + { 0x16EE, 0x16F0 }, + { 0x1780, 0x17B3 }, + { 0x17E0, 0x17E9 }, + { 0x1810, 0x1819 }, + { 0x1820, 0x1877 }, + { 0x1880, 0x18A8 }, + { 0x1E00, 0x1E9B }, + { 0x1EA0, 0x1EF9 }, + { 0x1F00, 0x1F15 }, + { 0x1F18, 0x1F1D }, + { 0x1F20, 0x1F45 }, + { 0x1F48, 0x1F4D }, + { 0x1F50, 0x1F57 }, + { 0x1F59, 0x1F59 }, + { 0x1F5B, 0x1F5B }, + { 0x1F5D, 0x1F5D }, + { 0x1F5F, 0x1F7D }, + { 0x1F80, 0x1FB4 }, + { 0x1FB6, 0x1FBC }, + { 0x1FBE, 0x1FBE }, + { 0x1FC2, 0x1FC4 }, + { 0x1FC6, 0x1FCC }, + { 0x1FD0, 0x1FD3 }, + { 0x1FD6, 0x1FDB }, + { 0x1FE0, 0x1FEC }, + { 0x1FF2, 0x1FF4 }, + { 0x1FF6, 0x1FFC }, + { 0x2070, 0x2070 }, + { 0x2074, 0x2079 }, + { 0x207F, 0x2089 }, + { 0x2102, 0x2102 }, + { 0x2107, 0x2107 }, + { 0x210A, 0x2113 }, + { 0x2115, 0x2115 }, + { 0x2119, 0x211D }, + { 0x2124, 0x2124 }, + { 0x2126, 0x2126 }, + { 0x2128, 0x2128 }, + { 0x212A, 0x212D }, + { 0x212F, 0x2131 }, + { 0x2133, 0x2139 }, + { 0x2153, 0x2183 }, + { 0x2460, 0x249B }, + { 0x24EA, 0x24EA }, + { 0x2776, 0x2793 }, + { 0x3005, 0x3007 }, + { 0x3021, 0x3029 }, + { 0x3031, 0x3035 }, + { 0x3038, 0x303A }, + { 0x3041, 0x3094 }, + { 0x309D, 0x309E }, + { 0x30A1, 0x30FA }, + { 0x30FC, 0x30FE }, + { 0x3105, 0x312C }, + { 0x3131, 0x318E }, + { 0x3192, 0x3195 }, + { 0x31A0, 0x31B7 }, + { 0x3220, 0x3229 }, + { 0x3280, 0x3289 }, + { 0x3400, 0x3400 }, + { 0x4DB5, 0x4DB5 }, + { 0x4E00, 0x4E00 }, + { 0x9FA5, 0x9FA5 }, + { 0xA000, 0xA48C }, + { 0xAC00, 0xAC00 }, + { 0xD7A3, 0xD7A3 }, + { 0xF900, 0xFA2D }, + { 0xFB00, 0xFB06 }, + { 0xFB13, 0xFB17 }, + { 0xFB1D, 0xFB1D }, + { 0xFB1F, 0xFB28 }, + { 0xFB2A, 0xFB36 }, + { 0xFB38, 0xFB3C }, + { 0xFB3E, 0xFB3E }, + { 0xFB40, 0xFB41 }, + { 0xFB43, 0xFB44 }, + { 0xFB46, 0xFBB1 }, + { 0xFBD3, 0xFD3D }, + { 0xFD50, 0xFD8F }, + { 0xFD92, 0xFDC7 }, + { 0xFDF0, 0xFDFB }, + { 0xFE70, 0xFE72 }, + { 0xFE74, 0xFE74 }, + { 0xFE76, 0xFEFC }, + { 0xFF10, 0xFF19 }, + { 0xFF21, 0xFF3A }, + { 0xFF41, 0xFF5A }, + { 0xFF66, 0xFFBE }, + { 0xFFC2, 0xFFC7 }, + { 0xFFCA, 0xFFCF }, + { 0xFFD2, 0xFFD7 } + }; + + CharRange search = { ch, ch }; + const CharRange* end = mozilla::ArrayEnd(alphanumericRanges); + const CharRange* element = std::lower_bound(&alphanumericRanges[0], end, search); + if (element == end) { + return false; + } + return element->lower <= ch && ch <= element->upper; } From d52820361f833a46315588333481b5c9682fc76b Mon Sep 17 00:00:00 2001 From: Douglas Crosher Date: Sun, 26 Jan 2014 19:42:53 +1100 Subject: [PATCH 056/296] Bug 964005 - Odinmonkey (ARM): Include d15 in the callee saved registers. r=mjrosenb --- js/src/jit/AsmJS.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/src/jit/AsmJS.cpp b/js/src/jit/AsmJS.cpp index 5ce2979307c..92cf9bcac59 100644 --- a/js/src/jit/AsmJS.cpp +++ b/js/src/jit/AsmJS.cpp @@ -5754,9 +5754,16 @@ static const RegisterSet AllRegsExceptSP = RegisterSet(GeneralRegisterSet(Registers::AllMask & ~(uint32_t(1) << Registers::StackPointer)), FloatRegisterSet(FloatRegisters::AllMask)); +#if defined(JS_CPU_ARM) +// The ARM system ABI also includes d15 in the non volatile float registers. +static const RegisterSet NonVolatileRegs = + RegisterSet(GeneralRegisterSet(Registers::NonVolatileMask), + FloatRegisterSet(FloatRegisters::NonVolatileMask | (1 << FloatRegisters::d15))); +#else static const RegisterSet NonVolatileRegs = RegisterSet(GeneralRegisterSet(Registers::NonVolatileMask), FloatRegisterSet(FloatRegisters::NonVolatileMask)); +#endif static void LoadAsmJSActivationIntoRegister(MacroAssembler &masm, Register reg) From a639c857e92b1f3b08c565b5ab08db827be52397 Mon Sep 17 00:00:00 2001 From: David Bolter Date: Tue, 28 Jan 2014 10:27:36 -0500 Subject: [PATCH 057/296] Bug 964546 - Add test for ignored roles. r=surkov --- accessible/tests/mochitest/role/test_aria.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/accessible/tests/mochitest/role/test_aria.html b/accessible/tests/mochitest/role/test_aria.html index 63a36687aa5..11361aa901c 100644 --- a/accessible/tests/mochitest/role/test_aria.html +++ b/accessible/tests/mochitest/role/test_aria.html @@ -129,6 +129,10 @@ // roles transformed by ARIA state attributes testRole("togglebutton", ROLE_TOGGLE_BUTTON); + ////////////////////////////////////////////////////////////////////////// + // ignore unknown roles, take first known + testRole("unknown_roles", ROLE_PUSHBUTTON); + ////////////////////////////////////////////////////////////////////////// // misc roles testRole("note", ROLE_NOTE); @@ -300,6 +304,9 @@