From 3a12bbdccbfebb999b76aeaa4fc51e7c900c4bd4 Mon Sep 17 00:00:00 2001 From: Randell Jesup Date: Sat, 14 Jul 2012 00:01:09 -0400 Subject: [PATCH 01/70] Bug 773151: provide back-compatibility for external API code using nsCAutoString CLOSED TREE r=bsmedberg --- xpcom/glue/nsStringAPI.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xpcom/glue/nsStringAPI.h b/xpcom/glue/nsStringAPI.h index ca2b308540a2..94b4f6be0d30 100644 --- a/xpcom/glue/nsStringAPI.h +++ b/xpcom/glue/nsStringAPI.h @@ -1435,4 +1435,7 @@ typedef nsString nsAutoString; NS_HIDDEN_(bool) ParseString(const nsACString& aAstring, char aDelimiter, nsTArray& aArray); +/* for back compatibility for pre-name-change code */ +typedef nsAutoCString nsCAutoString; + #endif // nsStringAPI_h__ From fcf82e3f1d3650e4737833eb7372d07f36917ea9 Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Sun, 2 Sep 2012 04:42:39 -0400 Subject: [PATCH 02/70] Bug 766038 - increase system NSPR requirement to 4.9.2. r=glandium --- configure.in | 2 +- js/src/configure.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 6769c10bef53..5ed347579778 100644 --- a/configure.in +++ b/configure.in @@ -3818,7 +3818,7 @@ MOZ_ARG_WITH_BOOL(system-nspr, _USE_SYSTEM_NSPR=1 ) if test -n "$_USE_SYSTEM_NSPR"; then - AM_PATH_NSPR(4.9.0, [MOZ_NATIVE_NSPR=1], [AC_MSG_ERROR([your don't have NSPR installed or your version is too old])]) + AM_PATH_NSPR(4.9.2, [MOZ_NATIVE_NSPR=1], [AC_MSG_ERROR([your don't have NSPR installed or your version is too old])]) fi if test -n "$MOZ_NATIVE_NSPR"; then diff --git a/js/src/configure.in b/js/src/configure.in index cdb87684e6bf..ebaa0eb5e242 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -3219,7 +3219,7 @@ fi dnl Top-level Mozilla switched to requiring NSPR 4.8.6 (bug 560582), but we don't need it in JS. if test -n "$_USE_SYSTEM_NSPR"; then MOZ_NATIVE_NSPR= - AM_PATH_NSPR(4.7.0, [MOZ_NATIVE_NSPR=1], [AC_MSG_ERROR([your don't have NSPR installed or your version is too old])]) + AM_PATH_NSPR(4.9.2, [MOZ_NATIVE_NSPR=1], [AC_MSG_ERROR([your don't have NSPR installed or your version is too old])]) fi if test -n "$MOZ_NATIVE_NSPR"; then From 33fe5589ca1e058f7d42915917d68fc809094b0d Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 7 Aug 2012 17:58:47 +0300 Subject: [PATCH 03/70] Bug 782594 - Use NS_FAILED instead of boolean test (content/, js/xpconnect/, layout/); r=bz --- content/base/src/nsContentUtils.cpp | 12 ++++++------ content/html/content/src/nsHTMLFrameSetElement.cpp | 2 +- content/xul/templates/src/nsXULContentBuilder.cpp | 2 +- js/xpconnect/src/XPCWrappedNative.cpp | 4 ++-- layout/forms/nsListControlFrame.cpp | 2 +- layout/generic/nsSelection.cpp | 4 ++-- layout/style/nsFontFaceLoader.cpp | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 3584d5f94ec5..ac8a43331349 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -5136,7 +5136,7 @@ nsContentUtils::GetViewportInfo(nsIDocument *aDocument) nsresult errorCode; float scaleMinFloat = minScaleStr.ToFloat(&errorCode); - if (errorCode) { + if (NS_FAILED(errorCode)) { scaleMinFloat = kViewportMinScale; } @@ -5151,7 +5151,7 @@ nsContentUtils::GetViewportInfo(nsIDocument *aDocument) nsresult scaleMaxErrorCode; float scaleMaxFloat = maxScaleStr.ToFloat(&scaleMaxErrorCode); - if (scaleMaxErrorCode) { + if (NS_FAILED(scaleMaxErrorCode)) { scaleMaxFloat = kViewportMaxScale; } @@ -5210,7 +5210,7 @@ nsContentUtils::GetViewportInfo(nsIDocument *aDocument) screen->GetRect(&screenLeft, &screenTop, &screenWidth, &screenHeight); uint32_t width = widthStr.ToInteger(&errorCode); - if (errorCode) { + if (NS_FAILED(errorCode)) { if (autoSize) { width = screenWidth; } else { @@ -5229,7 +5229,7 @@ nsContentUtils::GetViewportInfo(nsIDocument *aDocument) uint32_t height = heightStr.ToInteger(&errorCode); - if (errorCode) { + if (NS_FAILED(errorCode)) { height = width * ((float)screenHeight / screenWidth); } @@ -5244,10 +5244,10 @@ nsContentUtils::GetViewportInfo(nsIDocument *aDocument) // We need to perform a conversion, but only if the initial or maximum // scale were set explicitly by the user. - if (!scaleStr.IsEmpty() && !scaleErrorCode) { + if (!scaleStr.IsEmpty() && NS_SUCCEEDED(scaleErrorCode)) { width = NS_MAX(width, (uint32_t)(screenWidth / scaleFloat)); height = NS_MAX(height, (uint32_t)(screenHeight / scaleFloat)); - } else if (!maxScaleStr.IsEmpty() && !scaleMaxErrorCode) { + } else if (!maxScaleStr.IsEmpty() && NS_SUCCEEDED(scaleMaxErrorCode)) { width = NS_MAX(width, (uint32_t)(screenWidth / scaleMaxFloat)); height = NS_MAX(height, (uint32_t)(screenHeight / scaleMaxFloat)); } diff --git a/content/html/content/src/nsHTMLFrameSetElement.cpp b/content/html/content/src/nsHTMLFrameSetElement.cpp index 12a04ee8bd35..8435502e6730 100644 --- a/content/html/content/src/nsHTMLFrameSetElement.cpp +++ b/content/html/content/src/nsHTMLFrameSetElement.cpp @@ -277,7 +277,7 @@ nsHTMLFrameSetElement::ParseRowCol(const nsAString & aValue, // Otherwise just convert to integer. nsresult err; specs[i].mValue = token.ToInteger(&err); - if (err) { + if (NS_FAILED(err)) { specs[i].mValue = 0; } } diff --git a/content/xul/templates/src/nsXULContentBuilder.cpp b/content/xul/templates/src/nsXULContentBuilder.cpp index 3597d8ccb0de..59154ecf8fe6 100644 --- a/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/content/xul/templates/src/nsXULContentBuilder.cpp @@ -1891,7 +1891,7 @@ nsXULContentBuilder::InsertSortedNode(nsIContent* aContainer, // found "static" XUL element count hint nsresult strErr = NS_OK; staticCount = staticValue.ToInteger(&strErr); - if (strErr) + if (NS_FAILED(strErr)) staticCount = 0; } else { // compute the "static" XUL element count diff --git a/js/xpconnect/src/XPCWrappedNative.cpp b/js/xpconnect/src/XPCWrappedNative.cpp index 27ef5d96c7f7..7d226726ede5 100644 --- a/js/xpconnect/src/XPCWrappedNative.cpp +++ b/js/xpconnect/src/XPCWrappedNative.cpp @@ -551,8 +551,8 @@ XPCWrappedNative::GetNewOrUsed(XPCCallContext& ccx, JSObject *cached = cache->GetWrapper(); if (cached) { if (IS_SLIM_WRAPPER_OBJECT(cached)) { - if (!XPCWrappedNative::Morph(ccx, cached, Interface, cache, - getter_AddRefs(wrapper))) + if (NS_FAILED(XPCWrappedNative::Morph(ccx, cached, + Interface, cache, getter_AddRefs(wrapper)))) return NS_ERROR_FAILURE; } else { wrapper = static_cast(xpc_GetJSPrivate(cached)); diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 197a9bfc36c7..2749435206fc 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -1575,7 +1575,7 @@ nsListControlFrame::GetFormProperty(nsIAtom* aName, nsAString& aValue) const nsresult error = NS_OK; bool selected = false; int32_t indx = val.ToInteger(&error, 10); // Get index from aValue - if (error == 0) + if (NS_SUCCEEDED(error)) selected = IsContentSelectedByIndex(indx); aValue.Assign(selected ? NS_LITERAL_STRING("1") : NS_LITERAL_STRING("0")); diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index b92350931e44..3e3c2c7cfc24 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -935,7 +935,7 @@ nsFrameSelection::MoveCaret(uint32_t aKeycode, aVisualMovement); if (NS_FAILED(result) || !frame) - return result?result:NS_ERROR_FAILURE; + return NS_FAILED(result) ? result : NS_ERROR_FAILURE; //set data using mLimiter to stop on scroll views. If we have a limiter then we stop peeking //when we hit scrollable views. If no limiter then just let it go ahead @@ -5567,7 +5567,7 @@ Selection::SelectionLanguageChange(bool aLangRTL) uint8_t levelBefore, levelAfter; result = GetPresContext(getter_AddRefs(context)); if (NS_FAILED(result) || !context) - return result?result:NS_ERROR_FAILURE; + return NS_FAILED(result) ? result : NS_ERROR_FAILURE; uint8_t level = NS_GET_EMBEDDING_LEVEL(focusFrame); int32_t focusOffset = GetFocusOffset(); diff --git a/layout/style/nsFontFaceLoader.cpp b/layout/style/nsFontFaceLoader.cpp index 2c399b432e56..beddffbd8fd4 100644 --- a/layout/style/nsFontFaceLoader.cpp +++ b/layout/style/nsFontFaceLoader.cpp @@ -734,7 +734,7 @@ nsUserFontSet::LogMessage(gfxProxyFontEntry *aProxy, nsCSSProps::kFontStretchKTable).get(), aProxy->mSrcIndex); - if (aStatus != 0) { + if (NS_FAILED(aStatus)) { msg.Append(": "); switch (aStatus) { case NS_ERROR_DOM_BAD_URI: From e3ad397b4c8da0ac5c959863abb10a0df7cde2d9 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Thu, 9 Aug 2012 11:36:41 +0300 Subject: [PATCH 04/70] Bug 782594 - Return 0 from nsXULTreeBuilder::CompareResults on error; r=bz --- content/xul/templates/src/nsXULTreeBuilder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/xul/templates/src/nsXULTreeBuilder.cpp b/content/xul/templates/src/nsXULTreeBuilder.cpp index 4e051be2e6bd..c2db2527f1ef 100644 --- a/content/xul/templates/src/nsXULTreeBuilder.cpp +++ b/content/xul/templates/src/nsXULTreeBuilder.cpp @@ -1850,7 +1850,7 @@ nsXULTreeBuilder::CompareResults(nsIXULTemplateResult* aLeft, nsIXULTemplateResu nsCOMPtr ref; nsresult rv = aLeft->GetBindingObjectFor(mRefVariable, getter_AddRefs(ref)); if (NS_FAILED(rv)) - return rv; + return 0; nsCOMPtr container = do_QueryInterface(ref); if (container) { From e6ccfeb159e4689df158632ef317f47d706fa41f Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 14 Aug 2012 12:10:42 +0300 Subject: [PATCH 05/70] Bug 782594 - NS_ERROR_INVALID_ARG is not an accesskey; r=bz --- content/events/src/nsEventStateManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index c8681a2b2bf0..da6213602c6f 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -4874,7 +4874,8 @@ nsEventStateManager::UnregisterAccessKey(nsIContent* aContent, uint32_t aKey) uint32_t nsEventStateManager::GetRegisteredAccessKey(nsIContent* aContent) { - NS_ENSURE_ARG(aContent); + NS_ASSERTION(aContent, "Null pointer passed to GetRegisteredAccessKey"); + NS_ENSURE_TRUE(aContent, 0); if (mAccessKeys.IndexOf(aContent) == -1) return 0; From d3d8037f962e214f7fd91592a98fae15b224e66a Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 14 Aug 2012 12:10:42 +0300 Subject: [PATCH 06/70] Bug 782594 - Don't try returning nsresult in place of bool (content/); r=bz --- content/html/content/src/nsHTMLFormElement.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp index 304fff91cae4..227becbfb033 100644 --- a/content/html/content/src/nsHTMLFormElement.cpp +++ b/content/html/content/src/nsHTMLFormElement.cpp @@ -1688,7 +1688,8 @@ nsHTMLFormElement::CheckValidFormSubmission() nsCOMPtr theEnum; nsresult rv = service->EnumerateObservers(NS_INVALIDFORMSUBMIT_SUBJECT, getter_AddRefs(theEnum)); - NS_ENSURE_SUCCESS(rv, rv); + // Return true on error here because that's what we always did + NS_ENSURE_SUCCESS(rv, true); bool hasObserver = false; rv = theEnum->HasMoreElements(&hasObserver); @@ -1698,7 +1699,8 @@ nsHTMLFormElement::CheckValidFormSubmission() if (NS_SUCCEEDED(rv) && hasObserver) { nsCOMPtr invalidElements = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); + // Return true on error here because that's what we always did + NS_ENSURE_SUCCESS(rv, true); if (!CheckFormValidity(invalidElements.get())) { // For the first invalid submission, we should update element states. From 5d6d9b8deaa1171f309065474c4a197b1b739fe1 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 14 Aug 2012 12:10:42 +0300 Subject: [PATCH 07/70] Bug 782594 - Don't try returning nsresult in place of uint32_t; r=bz --- .../windowwatcher/src/nsWindowWatcher.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp index 2bd5c3538d24..c7af49860aee 100644 --- a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp +++ b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp @@ -1470,12 +1470,14 @@ uint32_t nsWindowWatcher::CalculateChromeFlags(nsIDOMWindow *aParent, nsCOMPtr securityManager(do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID)); - NS_ENSURE_TRUE(securityManager, NS_ERROR_FAILURE); bool isChrome = false; - nsresult rv = securityManager->SubjectPrincipalIsSystem(&isChrome); - if (NS_FAILED(rv)) { - isChrome = false; + nsresult rv; + if (securityManager) { + rv = securityManager->SubjectPrincipalIsSystem(&isChrome); + if (NS_FAILED(rv)) { + isChrome = false; + } } nsCOMPtr prefBranch; @@ -1578,11 +1580,13 @@ uint32_t nsWindowWatcher::CalculateChromeFlags(nsIDOMWindow *aParent, */ // Check security state for use in determing window dimensions - bool enabled; - nsresult res = - securityManager->IsCapabilityEnabled("UniversalXPConnect", &enabled); + bool enabled = false; + if (securityManager) { + rv = securityManager->IsCapabilityEnabled("UniversalXPConnect", + &enabled); + } - if (NS_FAILED(res) || !enabled || (isChrome && !aHasChromeParent)) { + if (NS_FAILED(rv) || !enabled || (isChrome && !aHasChromeParent)) { // If priv check fails (or if we're called from chrome, but the // parent is not a chrome window), set all elements to minimum // reqs., else leave them alone. From 6976d782c336017afc440cce2b1caebea1a4cf99 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 14 Aug 2012 12:10:42 +0300 Subject: [PATCH 08/70] Bug 782594 - Make some methods in uriloader/ infallible; r=bz --- .../prefetch/OfflineCacheUpdateChild.cpp | 10 ++----- uriloader/prefetch/OfflineCacheUpdateChild.h | 2 +- uriloader/prefetch/nsOfflineCacheUpdate.cpp | 28 +++++++------------ uriloader/prefetch/nsOfflineCacheUpdate.h | 6 ++-- 4 files changed, 17 insertions(+), 29 deletions(-) diff --git a/uriloader/prefetch/OfflineCacheUpdateChild.cpp b/uriloader/prefetch/OfflineCacheUpdateChild.cpp index afcc9b52757a..9119e99c7baa 100644 --- a/uriloader/prefetch/OfflineCacheUpdateChild.cpp +++ b/uriloader/prefetch/OfflineCacheUpdateChild.cpp @@ -90,7 +90,7 @@ OfflineCacheUpdateChild::~OfflineCacheUpdateChild() LOG(("OfflineCacheUpdateChild::~OfflineCacheUpdateChild [%p]", this)); } -nsresult +void OfflineCacheUpdateChild::GatherObservers(nsCOMArray &aObservers) { for (int32_t i = 0; i < mWeakObservers.Count(); i++) { @@ -105,8 +105,6 @@ OfflineCacheUpdateChild::GatherObservers(nsCOMArray observers; - rv = GatherObservers(observers); - NS_ENSURE_SUCCESS(rv, rv); + GatherObservers(observers); for (int32_t i = 0; i < observers.Count(); i++) observers[i]->ApplicationCacheAvailable(cache); @@ -477,8 +474,7 @@ OfflineCacheUpdateChild::RecvNotifyStateEvent(const uint32_t &event, } nsCOMArray observers; - nsresult rv = GatherObservers(observers); - NS_ENSURE_SUCCESS(rv, rv); + GatherObservers(observers); for (int32_t i = 0; i < observers.Count(); i++) observers[i]->UpdateStateChanged(this, event); diff --git a/uriloader/prefetch/OfflineCacheUpdateChild.h b/uriloader/prefetch/OfflineCacheUpdateChild.h index 7936cf61c3ba..59c62c68d674 100644 --- a/uriloader/prefetch/OfflineCacheUpdateChild.h +++ b/uriloader/prefetch/OfflineCacheUpdateChild.h @@ -50,7 +50,7 @@ public: private: nsresult AssociateDocument(nsIDOMDocument *aDocument, nsIApplicationCache *aApplicationCache); - nsresult GatherObservers(nsCOMArray &aObservers); + void GatherObservers(nsCOMArray &aObservers); nsresult Finish(); void RefcountHitZero(); diff --git a/uriloader/prefetch/nsOfflineCacheUpdate.cpp b/uriloader/prefetch/nsOfflineCacheUpdate.cpp index 1d9c9ee0011f..78cb48b5f211 100644 --- a/uriloader/prefetch/nsOfflineCacheUpdate.cpp +++ b/uriloader/prefetch/nsOfflineCacheUpdate.cpp @@ -1528,8 +1528,7 @@ nsOfflineCacheUpdate::LoadCompleted(nsOfflineCacheUpdateItem *aItem) return; } - rv = NotifyState(nsIOfflineCacheUpdateObserver::STATE_ITEMCOMPLETED); - if (NS_FAILED(rv)) return; + NotifyState(nsIOfflineCacheUpdateObserver::STATE_ITEMCOMPLETED); ProcessNextURI(); } @@ -1774,7 +1773,7 @@ nsOfflineCacheUpdate::ProcessNextURI() return NS_DispatchToCurrentThread(this); } -nsresult +void nsOfflineCacheUpdate::GatherObservers(nsCOMArray &aObservers) { for (int32_t i = 0; i < mWeakObservers.Count(); i++) { @@ -1789,38 +1788,30 @@ nsOfflineCacheUpdate::GatherObservers(nsCOMArray for (int32_t i = 0; i < mObservers.Count(); i++) { aObservers.AppendObject(mObservers[i]); } - - return NS_OK; } -nsresult +void nsOfflineCacheUpdate::NotifyState(uint32_t state) { LOG(("nsOfflineCacheUpdate::NotifyState [%p, %d]", this, state)); nsCOMArray observers; - nsresult rv = GatherObservers(observers); - NS_ENSURE_SUCCESS(rv, rv); + GatherObservers(observers); for (int32_t i = 0; i < observers.Count(); i++) { observers[i]->UpdateStateChanged(this, state); } - - return NS_OK; } -nsresult +void nsOfflineCacheUpdate::AssociateDocuments(nsIApplicationCache* cache) { nsCOMArray observers; - nsresult rv = GatherObservers(observers); - NS_ENSURE_SUCCESS(rv, rv); + GatherObservers(observers); for (int32_t i = 0; i < observers.Count(); i++) { observers[i]->ApplicationCacheAvailable(cache); } - - return NS_OK; } void @@ -2235,17 +2226,18 @@ nsOfflineCacheUpdate::UpdateStateChanged(nsIOfflineCacheUpdate *aUpdate, mSucceeded = succeeded; } - nsresult rv = NotifyState(aState); + NotifyState(aState); if (aState == nsIOfflineCacheUpdateObserver::STATE_FINISHED) aUpdate->RemoveObserver(this); - return rv; + return NS_OK; } NS_IMETHODIMP nsOfflineCacheUpdate::ApplicationCacheAvailable(nsIApplicationCache *applicationCache) { - return AssociateDocuments(applicationCache); + AssociateDocuments(applicationCache); + return NS_OK; } //----------------------------------------------------------------------------- diff --git a/uriloader/prefetch/nsOfflineCacheUpdate.h b/uriloader/prefetch/nsOfflineCacheUpdate.h index 87c8a06bcaf5..c38a5d963c78 100644 --- a/uriloader/prefetch/nsOfflineCacheUpdate.h +++ b/uriloader/prefetch/nsOfflineCacheUpdate.h @@ -227,10 +227,10 @@ private: nsresult AddExistingItems(uint32_t aType, nsTArray* namespaceFilter = nullptr); nsresult ScheduleImplicit(); - nsresult AssociateDocuments(nsIApplicationCache* cache); + void AssociateDocuments(nsIApplicationCache* cache); - nsresult GatherObservers(nsCOMArray &aObservers); - nsresult NotifyState(uint32_t state); + void GatherObservers(nsCOMArray &aObservers); + void NotifyState(uint32_t state); nsresult Finish(); nsresult FinishNoNotify(); From 08e86fdc863bd00043e5065aea6be690ecf00192 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 14 Aug 2012 12:10:42 +0300 Subject: [PATCH 09/70] Bug 782594 - Don't use nsresult as boolean; r=bz --- uriloader/base/nsDocLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp index 695c3e36a73d..a64185de8143 100644 --- a/uriloader/base/nsDocLoader.cpp +++ b/uriloader/base/nsDocLoader.cpp @@ -1138,7 +1138,7 @@ NS_IMETHODIMP nsDocLoader::OnStatus(nsIRequest* aRequest, nsISupports* ctxt, // // Fire progress notifications out to any registered nsIWebProgressListeners // - if (aStatus) { + if (aStatus != NS_OK) { // Remember the current status for this request nsRequestInfo *info; info = GetRequestInfo(aRequest); From ae8c41742c8826ab655fd3933d4505abf7a92906 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 7 Aug 2012 20:17:27 +0300 Subject: [PATCH 10/70] Bug 782594 - Don't return nsresult from main() (netwerk/); r=bz --- netwerk/streamconv/test/TestStreamConv.cpp | 22 +++++++++---------- netwerk/test/PropertiesTest.cpp | 6 +++--- netwerk/test/TestBlockingSocket.cpp | 4 ++-- netwerk/test/TestCallbacks.cpp | 6 +++--- netwerk/test/TestOpen.cpp | 2 +- netwerk/test/TestPageLoad.cpp | 14 ++++++------ netwerk/test/TestProtocols.cpp | 4 ++-- netwerk/test/TestSTSParser.cpp | 4 ++-- netwerk/test/TestServ.cpp | 4 ++-- netwerk/test/TestStreamLoader.cpp | 2 +- netwerk/test/TestUpload.cpp | 6 +++--- netwerk/test/urltest.cpp | 25 ++++++++++++---------- 12 files changed, 51 insertions(+), 48 deletions(-) diff --git a/netwerk/streamconv/test/TestStreamConv.cpp b/netwerk/streamconv/test/TestStreamConv.cpp index e2d8ec2b6add..d634c528d00e 100644 --- a/netwerk/streamconv/test/TestStreamConv.cpp +++ b/netwerk/streamconv/test/TestStreamConv.cpp @@ -178,12 +178,12 @@ main(int argc, char* argv[]) nsCOMPtr catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; nsCString previous; nsCOMPtr StreamConvService = do_GetService(kStreamConverterServiceCID, &rv); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; // Define the *from* content type and *to* content-type for conversion. static const char fromStr[] = "a/foo"; @@ -201,14 +201,14 @@ main(int argc, char* argv[]) nsCOMPtr channel; nsCOMPtr dummyURI; rv = NS_NewURI(getter_AddRefs(dummyURI), "http://meaningless"); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; rv = NS_NewInputStreamChannel(getter_AddRefs(channel), dummyURI, nullptr, // inStr "text/plain", // content-type -1); // XXX fix contentLength - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; nsCOMPtr request(do_QueryInterface(channel)); #endif @@ -227,7 +227,7 @@ main(int argc, char* argv[]) nsIStreamListener *converterListener = nullptr; rv = StreamConvService->AsyncConvertData(fromStr, toStr, dataReceiver, nullptr, &converterListener); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; NS_RELEASE(dataReceiver); // at this point we have a stream listener to push data to, and the one @@ -235,17 +235,17 @@ main(int argc, char* argv[]) // going. Typically these On*() calls would be made inside their respective wrappers On*() // methods. rv = converterListener->OnStartRequest(request, nullptr); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; rv = SEND_DATA("aaa"); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; rv = SEND_DATA("aaa"); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; // Finish the request. rv = converterListener->OnStopRequest(request, nullptr, rv); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; NS_RELEASE(converterListener); #else @@ -253,7 +253,7 @@ main(int argc, char* argv[]) nsCOMPtr convertedData; rv = StreamConvService->Convert(inputData, fromStr, toStr, nullptr, getter_AddRefs(convertedData)); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; #endif // Enter the message pump to allow the URL load to proceed. @@ -264,5 +264,5 @@ main(int argc, char* argv[]) } // this scopes the nsCOMPtrs // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM NS_ShutdownXPCOM(nullptr); - return rv; + return 0; } diff --git a/netwerk/test/PropertiesTest.cpp b/netwerk/test/PropertiesTest.cpp index 5695b5f8a0c6..90a9c29aa5c3 100644 --- a/netwerk/test/PropertiesTest.cpp +++ b/netwerk/test/PropertiesTest.cpp @@ -40,14 +40,14 @@ main(int argc, char* argv[]) nsIInputStream* in = nullptr; nsCOMPtr service(do_GetService(kIOServiceCID, &ret)); - if (NS_FAILED(ret)) return ret; + if (NS_FAILED(ret)) return 1; nsIChannel *channel = nullptr; ret = service->NewChannel(NS_LITERAL_CSTRING(TEST_URL), nullptr, nullptr, &channel); - if (NS_FAILED(ret)) return ret; + if (NS_FAILED(ret)) return 1; ret = channel->Open(&in); - if (NS_FAILED(ret)) return ret; + if (NS_FAILED(ret)) return 1; nsIPersistentProperties* props; ret = CallCreateInstance(kPersistentPropertiesCID, &props); diff --git a/netwerk/test/TestBlockingSocket.cpp b/netwerk/test/TestBlockingSocket.cpp index 755298ecbc40..e4812faf61f0 100644 --- a/netwerk/test/TestBlockingSocket.cpp +++ b/netwerk/test/TestBlockingSocket.cpp @@ -110,7 +110,7 @@ main(int argc, char* argv[]) nsCOMPtr file; rv = NS_NewNativeLocalFile(nsDependentCString(fileName), false, getter_AddRefs(file)); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; rv = RunBlockingTest(nsDependentCString(hostName), port, file); #if defined(PR_LOGGING) @@ -126,5 +126,5 @@ main(int argc, char* argv[]) // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM rv = NS_ShutdownXPCOM(nullptr); NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed"); - return NS_OK; + return 0; } diff --git a/netwerk/test/TestCallbacks.cpp b/netwerk/test/TestCallbacks.cpp index cde2228d0fd8..922a48d7e33e 100644 --- a/netwerk/test/TestCallbacks.cpp +++ b/netwerk/test/TestCallbacks.cpp @@ -221,14 +221,14 @@ int main(int argc, char *argv[]) { } rv = NS_InitXPCOM2(nullptr, nullptr, nullptr); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; if (cmdLineURL) { rv = StartLoad(argv[1]); } else { rv = StartLoad("http://badhostnamexyz/test.txt"); } - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; // Enter the message pump to allow the URL load to proceed. PumpEvents(); @@ -237,7 +237,7 @@ int main(int argc, char *argv[]) { if (gError) { fprintf(stderr, "\n\n-------ERROR-------\n\n"); } - return rv; + return 0; } nsresult StartLoad(const char *aURISpec) { diff --git a/netwerk/test/TestOpen.cpp b/netwerk/test/TestOpen.cpp index 9bb77e490dae..8d97a3264fde 100644 --- a/netwerk/test/TestOpen.cpp +++ b/netwerk/test/TestOpen.cpp @@ -33,7 +33,7 @@ main(int argc, char **argv) return -1; nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; char buf[256]; diff --git a/netwerk/test/TestPageLoad.cpp b/netwerk/test/TestPageLoad.cpp index 0397bf733ba3..938559464888 100644 --- a/netwerk/test/TestPageLoad.cpp +++ b/netwerk/test/TestPageLoad.cpp @@ -25,11 +25,11 @@ nsresult auxLoad(char *uriBuf); //---------------------------------------------------------------------- -#define RETURN_IF_FAILED(rv, step) \ +#define RETURN_IF_FAILED(rv, ret, step) \ PR_BEGIN_MACRO \ if (NS_FAILED(rv)) { \ printf(">>> %s failed: rv=%x\n", step, rv); \ - return rv;\ + return ret;\ } \ PR_END_MACRO @@ -296,11 +296,11 @@ nsresult auxLoad(char *uriBuf) printf("\n"); uriList.AppendObject(uri); rv = NS_NewChannel(getter_AddRefs(chan), uri, nullptr, nullptr, callbacks); - RETURN_IF_FAILED(rv, "NS_NewChannel"); + RETURN_IF_FAILED(rv, rv, "NS_NewChannel"); gKeepRunning++; rv = chan->AsyncOpen(listener, myBool); - RETURN_IF_FAILED(rv, "AsyncOpen"); + RETURN_IF_FAILED(rv, rv, "AsyncOpen"); return NS_OK; @@ -337,17 +337,17 @@ int main(int argc, char **argv) nsCOMPtr callbacks = new MyNotifications(); rv = NS_NewURI(getter_AddRefs(baseURI), argv[1]); - RETURN_IF_FAILED(rv, "NS_NewURI"); + RETURN_IF_FAILED(rv, -1, "NS_NewURI"); rv = NS_NewChannel(getter_AddRefs(chan), baseURI, nullptr, nullptr, callbacks); - RETURN_IF_FAILED(rv, "NS_OpenURI"); + RETURN_IF_FAILED(rv, -1, "NS_OpenURI"); gKeepRunning++; //TIMER STARTED----------------------- printf("Starting clock ... \n"); start = PR_Now(); rv = chan->AsyncOpen(listener, nullptr); - RETURN_IF_FAILED(rv, "AsyncOpen"); + RETURN_IF_FAILED(rv, -1, "AsyncOpen"); PumpEvents(); diff --git a/netwerk/test/TestProtocols.cpp b/netwerk/test/TestProtocols.cpp index 8042c49f6609..d31309058323 100644 --- a/netwerk/test/TestProtocols.cpp +++ b/netwerk/test/TestProtocols.cpp @@ -835,7 +835,7 @@ main(int argc, char* argv[]) */ rv = NS_InitXPCOM2(nullptr, nullptr, nullptr); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; { int i; @@ -887,5 +887,5 @@ main(int argc, char* argv[]) } // this scopes the nsCOMPtrs // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM NS_ShutdownXPCOM(nullptr); - return rv; + return NS_FAILED(rv) ? -1 : 0; } diff --git a/netwerk/test/TestSTSParser.cpp b/netwerk/test/TestSTSParser.cpp index a8c15797ed7c..7dc525ecdac3 100644 --- a/netwerk/test/TestSTSParser.cpp +++ b/netwerk/test/TestSTSParser.cpp @@ -92,11 +92,11 @@ main(int32_t argc, char *argv[]) // grab handle to the service nsCOMPtr stss; stss = do_GetService("@mozilla.org/stsservice;1", &rv); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, -1); nsCOMPtr pm; pm = do_GetService("@mozilla.org/permissionmanager;1", &rv); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, -1); int rv0, rv1; diff --git a/netwerk/test/TestServ.cpp b/netwerk/test/TestServ.cpp index 0adfbeca018b..c9a586c1e38f 100644 --- a/netwerk/test/TestServ.cpp +++ b/netwerk/test/TestServ.cpp @@ -127,7 +127,7 @@ main(int argc, char* argv[]) */ rv = NS_InitXPCOM2(nullptr, nullptr, nullptr); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; { rv = MakeServer(atoi(argv[1])); @@ -141,5 +141,5 @@ main(int argc, char* argv[]) } // this scopes the nsCOMPtrs // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM NS_ShutdownXPCOM(nullptr); - return rv; + return 0; } diff --git a/netwerk/test/TestStreamLoader.cpp b/netwerk/test/TestStreamLoader.cpp index 65b2dbf5a178..db6a3997fec9 100644 --- a/netwerk/test/TestStreamLoader.cpp +++ b/netwerk/test/TestStreamLoader.cpp @@ -85,5 +85,5 @@ int main(int argc, char **argv) } // this scopes the nsCOMPtrs // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM NS_ShutdownXPCOM(nullptr); - return rv; + return 0; } diff --git a/netwerk/test/TestUpload.cpp b/netwerk/test/TestUpload.cpp index 4c252ca6da54..5f61bcc1a9ac 100644 --- a/netwerk/test/TestUpload.cpp +++ b/netwerk/test/TestUpload.cpp @@ -127,16 +127,16 @@ main(int argc, char* argv[]) true, nsDependentCString(fileName), // XXX UTF-8 0, ioService); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; // create our url. nsCOMPtr uri; rv = NS_NewURI(getter_AddRefs(uri), uriSpec); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; nsCOMPtr channel; rv = ioService->NewChannelFromURI(uri, getter_AddRefs(channel)); - if (NS_FAILED(rv)) return rv; + if (NS_FAILED(rv)) return -1; // QI and set the upload stream nsCOMPtr uploadChannel(do_QueryInterface(channel)); diff --git a/netwerk/test/urltest.cpp b/netwerk/test/urltest.cpp index d495b5d51877..e796659394dd 100644 --- a/netwerk/test/urltest.cpp +++ b/netwerk/test/urltest.cpp @@ -380,11 +380,9 @@ int main(int argc, char **argv) if (test_common_init(&argc, &argv) != 0) return -1; - int rv = -1; - if (argc < 2) { printusage(); - return NS_OK; + return 0; } { nsCOMPtr servMan; @@ -404,7 +402,7 @@ int main(int argc, char **argv) if (i+1 >= argc) { printusage(); - return NS_OK; + return 0; } } else if (PL_strcasecmp(argv[i], "-abs") == 0) @@ -421,7 +419,7 @@ int main(int argc, char **argv) if (i+1 >= argc) { printusage(); - return NS_OK; + return 0; } gFileIO = argv[i+1]; i++; @@ -434,13 +432,19 @@ int main(int argc, char **argv) PRTime startTime = PR_Now(); if (bMakeAbs) { - rv = (url && relativePath) - ? doMakeAbsTest(url, relativePath) - : doMakeAbsTest(); + if (url && relativePath) { + doMakeAbsTest(url, relativePath); + } else { + doMakeAbsTest(); + } } else { - rv = gFileIO ? testURL(0, urlFactory) : testURL(url, urlFactory); + if (gFileIO) { + testURL(0, urlFactory); + } else { + testURL(url, urlFactory); + } } if (gFileIO) { @@ -450,6 +454,5 @@ int main(int argc, char **argv) } } // this scopes the nsCOMPtrs // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM - rv = NS_ShutdownXPCOM(nullptr); - return rv; + return NS_FAILED(NS_ShutdownXPCOM(nullptr)) ? 1 : 0; } From aaa114b25661cbaccf31f9fc72d3e5792d17959d Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 2 Sep 2012 21:01:59 -0400 Subject: [PATCH 11/70] Bug 787760 - Use strong enum class for StrictMode. r=njn --- js/src/frontend/Parser.cpp | 10 +++++----- js/src/frontend/Parser.h | 2 +- js/src/frontend/SharedContext-inl.h | 2 +- js/src/frontend/SharedContext.h | 10 +++++----- js/src/frontend/TokenStream.h | 14 ++++++-------- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index e077dba26a1c..065bd59a3475 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -79,7 +79,7 @@ using namespace js::frontend; JS_END_MACRO #define MUST_MATCH_TOKEN(tt, errno) MUST_MATCH_TOKEN_WITH_FLAGS(tt, errno, 0) -StrictMode::StrictModeState +StrictMode StrictModeGetter::get() const { return parser->pc->sc->strictModeState; @@ -388,7 +388,7 @@ Parser::newObjectBox(JSObject *obj) } FunctionBox::FunctionBox(ObjectBox* traceListHead, JSObject *obj, ParseContext *outerpc, - StrictMode::StrictModeState sms) + StrictMode sms) : ObjectBox(traceListHead, obj), siblings(outerpc->functionList), kids(NULL), @@ -444,7 +444,7 @@ FunctionBox::FunctionBox(ObjectBox* traceListHead, JSObject *obj, ParseContext * } FunctionBox * -Parser::newFunctionBox(JSObject *obj, ParseContext *outerpc, StrictMode::StrictModeState sms) +Parser::newFunctionBox(JSObject *obj, ParseContext *outerpc, StrictMode sms) { JS_ASSERT(obj && !IsPoisonedPtr(obj)); JS_ASSERT(obj->isFunction()); @@ -1612,7 +1612,7 @@ Parser::functionDef(HandlePropertyName funName, FunctionType type, FunctionSynta return NULL; // Inherit strictness if neeeded. - StrictMode::StrictModeState sms = (outerpc->sc->strictModeState == StrictMode::STRICT) ? + StrictMode sms = (outerpc->sc->strictModeState == StrictMode::STRICT) ? StrictMode::STRICT : StrictMode::UNKNOWN; // Create box for fun->object early to protect against last-ditch GC. @@ -1779,7 +1779,7 @@ Parser::functionExpr() } void -FunctionBox::recursivelySetStrictMode(StrictMode::StrictModeState strictness) +FunctionBox::recursivelySetStrictMode(StrictMode strictness) { if (strictModeState == StrictMode::UNKNOWN) { strictModeState = strictness; diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index 17c409aa6703..c0886b07e426 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -303,7 +303,7 @@ struct Parser : private AutoGCRooter */ ObjectBox *newObjectBox(JSObject *obj); - FunctionBox *newFunctionBox(JSObject *obj, ParseContext *pc, StrictMode::StrictModeState sms); + FunctionBox *newFunctionBox(JSObject *obj, ParseContext *pc, StrictMode sms); /* * Create a new function object given parse context (pc) and a name (which diff --git a/js/src/frontend/SharedContext-inl.h b/js/src/frontend/SharedContext-inl.h index e5a8f4a648b3..c0c953de17cb 100644 --- a/js/src/frontend/SharedContext-inl.h +++ b/js/src/frontend/SharedContext-inl.h @@ -16,7 +16,7 @@ namespace frontend { inline SharedContext::SharedContext(JSContext *cx, JSObject *scopeChain, JSFunction *fun, - FunctionBox *funbox, StrictMode::StrictModeState sms) + FunctionBox *funbox, StrictMode sms) : context(cx), fun_(cx, fun), funbox_(funbox), diff --git a/js/src/frontend/SharedContext.h b/js/src/frontend/SharedContext.h index ff43c0c622bb..3ec58ca0c34e 100644 --- a/js/src/frontend/SharedContext.h +++ b/js/src/frontend/SharedContext.h @@ -156,12 +156,12 @@ struct SharedContext { // can have any kind of children. // // When parsing is done, no context may be in the UNKNOWN strictness state. - StrictMode::StrictModeState strictModeState; + StrictMode strictModeState; // If it's function code, fun must be non-NULL and scopeChain must be NULL. // If it's global code, fun and funbox must be NULL. inline SharedContext(JSContext *cx, JSObject *scopeChain, JSFunction *fun, FunctionBox *funbox, - StrictMode::StrictModeState sms); + StrictMode sms); // In theory, |fun*| flags are only relevant if |inFunction()| is true. // However, we get and set in some cases where |inFunction()| is false, @@ -297,7 +297,7 @@ struct FunctionBox : public ObjectBox size_t bufStart; size_t bufEnd; uint16_t ndefaults; - StrictMode::StrictModeState strictModeState; + StrictMode strictModeState; bool inWith:1; /* some enclosing scope is a with-statement or E4X filter-expression */ bool inGenexpLambda:1; /* lambda from generator expression */ @@ -305,13 +305,13 @@ struct FunctionBox : public ObjectBox ContextFlags cxFlags; FunctionBox(ObjectBox* traceListHead, JSObject *obj, ParseContext *pc, - StrictMode::StrictModeState sms); + StrictMode sms); bool funIsGenerator() const { return cxFlags.funIsGenerator; } JSFunction *function() const { return (JSFunction *) object; } - void recursivelySetStrictMode(StrictMode::StrictModeState strictness); + void recursivelySetStrictMode(StrictMode strictness); }; // Push the C-stack-allocated struct at stmt onto the StmtInfoPC stack. diff --git a/js/src/frontend/TokenStream.h b/js/src/frontend/TokenStream.h index b00dacde6d01..b515091a04c5 100644 --- a/js/src/frontend/TokenStream.h +++ b/js/src/frontend/TokenStream.h @@ -433,16 +433,14 @@ struct CompileError { void throwError(); }; -namespace StrictMode { /* For an explanation of how these are used, see the comment in the FunctionBox definition. */ -enum StrictModeState { +MOZ_BEGIN_ENUM_CLASS(StrictMode, uint8_t) NOTSTRICT, UNKNOWN, STRICT -}; -} +MOZ_END_ENUM_CLASS(StrictMode) -inline StrictMode::StrictModeState +inline StrictMode StrictModeFromContext(JSContext *cx) { return cx->hasRunOption(JSOPTION_STRICT_MODE) ? StrictMode::STRICT : StrictMode::UNKNOWN; @@ -463,7 +461,7 @@ class StrictModeGetter { public: StrictModeGetter(Parser *p) : parser(p) { } - StrictMode::StrictModeState get() const; + StrictMode get() const; CompileError *queuedStrictModeError() const; void setQueuedStrictModeError(CompileError *e); }; @@ -536,9 +534,9 @@ class TokenStream void setXMLOnlyMode(bool enabled = true) { setFlag(enabled, TSF_XMLONLYMODE); } void setUnexpectedEOF(bool enabled = true) { setFlag(enabled, TSF_UNEXPECTED_EOF); } - StrictMode::StrictModeState strictModeState() const + StrictMode strictModeState() const { - return strictModeGetter ? strictModeGetter->get() : StrictMode::NOTSTRICT; + return strictModeGetter ? strictModeGetter->get() : StrictMode(StrictMode::NOTSTRICT); } bool isXMLTagMode() const { return !!(flags & TSF_XMLTAGMODE); } bool isXMLOnlyMode() const { return !!(flags & TSF_XMLONLYMODE); } From 6e84e4fd579eeaa5df3775519b67e55f977a3925 Mon Sep 17 00:00:00 2001 From: Matthew Gregan Date: Mon, 3 Sep 2012 13:18:42 +1200 Subject: [PATCH 12/70] Bug 778675 - Add some more logging to debug a cubeb_audiounit test failure. --- media/libcubeb/src/cubeb_audiounit.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/media/libcubeb/src/cubeb_audiounit.c b/media/libcubeb/src/cubeb_audiounit.c index 9369b8345a7e..b058ce325bd3 100644 --- a/media/libcubeb/src/cubeb_audiounit.c +++ b/media/libcubeb/src/cubeb_audiounit.c @@ -191,10 +191,16 @@ cubeb_stream_init(cubeb * context, cubeb_stream ** stream, char const * stream_n input.inputProcRefCon = stm; r = AudioUnitSetProperty(stm->unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Global, 0, &input, sizeof(input)); + if (r != 0) { + fprintf(stderr, "cubeb_audiounit: FATAL: AudioUnitSetProperty(SetRenderCallback) returned %ld\n", (long) r); + } assert(r == 0); r = AudioUnitSetProperty(stm->unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &ss, sizeof(ss)); + if (r != 0) { + fprintf(stderr, "cubeb_audiounit: FATAL: AudioUnitSetProperty(StreamFormat) returned %ld\n", (long) r); + } assert(r == 0); buffer_size = ss.mSampleRate / 1000.0 * latency * ss.mBytesPerFrame / NBUFS; @@ -204,6 +210,9 @@ cubeb_stream_init(cubeb * context, cubeb_stream ** stream, char const * stream_n assert(buffer_size % ss.mBytesPerFrame == 0); r = AudioUnitInitialize(stm->unit); + if (r != 0) { + fprintf(stderr, "cubeb_audiounit: FATAL: AudioUnitInitialize returned %ld\n", (long) r); + } assert(r == 0); *stream = stm; From 013a4e4c315ca823186d70f7d3974ad15e5a126f Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Mon, 3 Sep 2012 16:12:23 +1200 Subject: [PATCH 13/70] Bug 787805 - Null check mInput in FileMediaResource::EnsureLengthInitialized(). r=roc --- content/media/MediaResource.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/media/MediaResource.cpp b/content/media/MediaResource.cpp index 8a4b8779319f..c860c5f40720 100644 --- a/content/media/MediaResource.cpp +++ b/content/media/MediaResource.cpp @@ -1031,7 +1031,7 @@ private: void FileMediaResource::EnsureLengthInitialized() { mLock.AssertCurrentThreadOwns(); - if (mSizeInitialized) { + if (mSizeInitialized || !mInput) { return; } mSizeInitialized = true; From bf62bdbc2a51e6a43fee058fe7161f0fc089ee57 Mon Sep 17 00:00:00 2001 From: Gina Yeh Date: Mon, 3 Sep 2012 14:38:44 +0800 Subject: [PATCH 14/70] Bug 764559 - Final version: add eventlistener for adapteradded in BluetoothManager, r=qdot, sr=jst --- content/base/src/nsGkAtomList.h | 1 + dom/bluetooth/BluetoothManager.cpp | 51 ++++++++++++++++---- dom/bluetooth/BluetoothService.h | 1 + dom/bluetooth/gonk/BluetoothGonkService.cpp | 10 ++++ dom/bluetooth/gonk/BluetoothGonkService.h | 5 ++ dom/bluetooth/linux/BluetoothDBusService.cpp | 19 +++++++- dom/bluetooth/linux/BluetoothDBusService.h | 2 + dom/bluetooth/nsIDOMBluetoothManager.idl | 3 +- 8 files changed, 80 insertions(+), 12 deletions(-) diff --git a/content/base/src/nsGkAtomList.h b/content/base/src/nsGkAtomList.h index 392037f64d97..5fcc795ac98b 100644 --- a/content/base/src/nsGkAtomList.h +++ b/content/base/src/nsGkAtomList.h @@ -614,6 +614,7 @@ GK_ATOM(OFF, "OFF") GK_ATOM(ol, "ol") GK_ATOM(omitXmlDeclaration, "omit-xml-declaration") GK_ATOM(onabort, "onabort") +GK_ATOM(onadapteradded, "onadapteradded") GK_ATOM(onafterprint, "onafterprint") GK_ATOM(onafterscriptexecute, "onafterscriptexecute") GK_ATOM(onalerting, "onalerting") diff --git a/dom/bluetooth/BluetoothManager.cpp b/dom/bluetooth/BluetoothManager.cpp index 5d22e45e3eef..703af6e01fd7 100644 --- a/dom/bluetooth/BluetoothManager.cpp +++ b/dom/bluetooth/BluetoothManager.cpp @@ -83,7 +83,7 @@ public: sc->GetNativeGlobal(), adapter, aValue); - bool result = NS_SUCCEEDED(rv) ? true : false; + bool result = NS_SUCCEEDED(rv); if (!result) { NS_WARNING("Cannot create native object!"); SetError(NS_LITERAL_STRING("BluetoothNativeObjectError")); @@ -247,6 +247,20 @@ BluetoothManager::HandleMozsettingChanged(const PRUnichar* aData) } bool enabled = value.toBoolean(); + bool isEnabled = (bs->IsEnabledInternal() > 0); + if (!isEnabled && enabled) { + if (NS_FAILED(bs->RegisterBluetoothSignalHandler(NS_LITERAL_STRING("/"), this))) { + NS_ERROR("Failed to register object with observer!"); + return NS_ERROR_FAILURE; + } + } else if (isEnabled && !enabled){ + if (NS_FAILED(bs->UnregisterBluetoothSignalHandler(NS_LITERAL_STRING("/"), this))) { + NS_WARNING("Failed to unregister object with observer!"); + } + } else { + return NS_OK; + } + nsCOMPtr resultTask = new ToggleBtResultTask(this, enabled); if (enabled) { @@ -330,17 +344,19 @@ BluetoothManager::GetDefaultAdapter(nsIDOMDOMRequest** aAdapter) // static already_AddRefed BluetoothManager::Create(nsPIDOMWindow* aWindow) { - nsRefPtr manager = new BluetoothManager(aWindow); BluetoothService* bs = BluetoothService::Get(); if (!bs) { NS_WARNING("BluetoothService not available!"); return nullptr; } - - if (NS_FAILED(bs->RegisterBluetoothSignalHandler(NS_LITERAL_STRING("/"), manager))) { - NS_ERROR("Failed to register object with observer!"); - return nullptr; + + bool isEnabled = (bs->IsEnabledInternal() > 0); + if (isEnabled) { + if (NS_FAILED(bs->RegisterBluetoothSignalHandler(NS_LITERAL_STRING("/"), manager))) { + NS_ERROR("Failed to register object with observer!"); + return nullptr; + } } return manager.forget(); @@ -390,13 +406,28 @@ NS_NewBluetoothManager(nsPIDOMWindow* aWindow, void BluetoothManager::Notify(const BluetoothSignal& aData) { + if (aData.name().EqualsLiteral("AdapterAdded")) { + nsRefPtr event = new nsDOMEvent(nullptr, nullptr); + nsresult rv = event->InitEvent(NS_LITERAL_STRING("adapteradded"), false, false); + + if (NS_FAILED(rv)) { + NS_WARNING("Failed to init the adapteradded event!!!"); + return; + } + + event->SetTrusted(true); + bool dummy; + DispatchEvent(event, &dummy); + } else { #ifdef DEBUG - nsCString warningMsg; - warningMsg.AssignLiteral("Not handling manager signal: "); - warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name())); - NS_WARNING(warningMsg.get()); + nsCString warningMsg; + warningMsg.AssignLiteral("Not handling manager signal: "); + warningMsg.Append(NS_ConvertUTF16toUTF8(aData.name())); + NS_WARNING(warningMsg.get()); #endif + } } NS_IMPL_EVENT_HANDLER(BluetoothManager, enabled) NS_IMPL_EVENT_HANDLER(BluetoothManager, disabled) +NS_IMPL_EVENT_HANDLER(BluetoothManager, adapteradded) diff --git a/dom/bluetooth/BluetoothService.h b/dom/bluetooth/BluetoothService.h index 43aed9e94291..f84d44c92b8c 100644 --- a/dom/bluetooth/BluetoothService.h +++ b/dom/bluetooth/BluetoothService.h @@ -225,6 +225,7 @@ public: virtual bool SetPasskeyInternal(const nsAString& aDeviceAddress, uint32_t aPasskey) = 0; virtual bool SetPairingConfirmationInternal(const nsAString& aDeviceAddress, bool aConfirm) = 0; virtual bool SetAuthorizationInternal(const nsAString& aDeviceAddress, bool aAllow) = 0; + virtual int IsEnabledInternal() = 0; /** * Due to the fact that some operations require multiple calls, a diff --git a/dom/bluetooth/gonk/BluetoothGonkService.cpp b/dom/bluetooth/gonk/BluetoothGonkService.cpp index 1e9ca5768e77..634c5e39e4a3 100644 --- a/dom/bluetooth/gonk/BluetoothGonkService.cpp +++ b/dom/bluetooth/gonk/BluetoothGonkService.cpp @@ -128,6 +128,16 @@ StartStopGonkBluetooth(bool aShouldEnable) return NS_OK; } +int +BluetoothGonkService::IsEnabledInternal() +{ + if (!EnsureBluetoothInit()) { + NS_ERROR("Failed to load bluedroid library.\n"); + return false; + } + return IsBluetoothEnabled(); +} + nsresult BluetoothGonkService::StartInternal() { diff --git a/dom/bluetooth/gonk/BluetoothGonkService.h b/dom/bluetooth/gonk/BluetoothGonkService.h index afeb53d45290..308d9b8608d5 100644 --- a/dom/bluetooth/gonk/BluetoothGonkService.h +++ b/dom/bluetooth/gonk/BluetoothGonkService.h @@ -52,6 +52,11 @@ public: * otherwise */ virtual nsresult StopInternal(); + + /** + * @return true if bluetooth daemon is enabled, false otherwise + */ + virtual int IsEnabledInternal(); }; END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/linux/BluetoothDBusService.cpp b/dom/bluetooth/linux/BluetoothDBusService.cpp index 951068030967..8ab2ab2bb00c 100644 --- a/dom/bluetooth/linux/BluetoothDBusService.cpp +++ b/dom/bluetooth/linux/BluetoothDBusService.cpp @@ -831,7 +831,6 @@ EventFilter(DBusConnection* aConn, DBusMessage* aMsg, void* aData) BluetoothValue v; if (dbus_message_is_signal(aMsg, DBUS_ADAPTER_IFACE, "DeviceFound")) { - DBusMessageIter iter; if (!dbus_message_iter_init(aMsg, &iter)) { @@ -892,6 +891,16 @@ EventFilter(DBusConnection* aConn, DBusMessage* aMsg, void* aData) errorStr, sDeviceProperties, ArrayLength(sDeviceProperties)); + } else if (dbus_message_is_signal(aMsg, DBUS_MANAGER_IFACE, "AdapterAdded")) { + const char* str; + if (!dbus_message_get_args(aMsg, &err, + DBUS_TYPE_OBJECT_PATH, &str, + DBUS_TYPE_INVALID)) { + LOG_AND_FREE_DBUS_ERROR_WITH_MSG(&err, aMsg); + errorStr.AssignLiteral("Cannot parse manager path!"); + } else { + v = NS_ConvertUTF8toUTF16(str); + } } else if (dbus_message_is_signal(aMsg, DBUS_MANAGER_IFACE, "PropertyChanged")) { ParsePropertyChange(aMsg, v, @@ -1028,6 +1037,14 @@ BluetoothDBusService::StopInternal() return NS_OK; } + +int +BluetoothDBusService::IsEnabledInternal() +{ + // assume bluetooth is always enabled on desktop + return true; +} + class DefaultAdapterPropertiesRunnable : public nsRunnable { public: diff --git a/dom/bluetooth/linux/BluetoothDBusService.h b/dom/bluetooth/linux/BluetoothDBusService.h index 470c06d170b8..391e6e9e4c7c 100644 --- a/dom/bluetooth/linux/BluetoothDBusService.h +++ b/dom/bluetooth/linux/BluetoothDBusService.h @@ -82,6 +82,8 @@ public: virtual bool SetAuthorizationInternal(const nsAString& aDeviceAddress, bool aAllow); + virtual int IsEnabledInternal(); + private: nsresult SendGetPropertyMessage(const nsAString& aPath, const char* aInterface, diff --git a/dom/bluetooth/nsIDOMBluetoothManager.idl b/dom/bluetooth/nsIDOMBluetoothManager.idl index 82ca02ac1294..50b53ad4f2c0 100644 --- a/dom/bluetooth/nsIDOMBluetoothManager.idl +++ b/dom/bluetooth/nsIDOMBluetoothManager.idl @@ -9,7 +9,7 @@ interface nsIDOMDOMRequest; interface nsIDOMBluetoothAdapter; -[scriptable, builtinclass, uuid(b9e0a4a2-fa84-402d-8830-d0f3625f120a)] +[scriptable, builtinclass, uuid(d27ec867-949f-4585-b718-d2352e420ec6)] interface nsIDOMBluetoothManager : nsIDOMEventTarget { readonly attribute bool enabled; @@ -18,4 +18,5 @@ interface nsIDOMBluetoothManager : nsIDOMEventTarget [implicit_jscontext] attribute jsval onenabled; [implicit_jscontext] attribute jsval ondisabled; + [implicit_jscontext] attribute jsval onadapteradded; }; From 219d6ac1041d5f600b94a055f3754b5173f46431 Mon Sep 17 00:00:00 2001 From: Nicholas Cameron Date: Mon, 3 Sep 2012 18:58:07 +1200 Subject: [PATCH 15/70] Bug 786817; Check multiple masks properly and invalidate after removing a mask layer. r=roc --- layout/base/FrameLayerBuilder.cpp | 41 ++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 10170f5023f1..91d9bae67d60 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -497,11 +497,19 @@ public: mXScale(1.f), mYScale(1.f), mActiveScrolledRootPosition(0, 0) {} + /** + * Record the number of clips in the Thebes layer's mask layer. + * Should not be reset when the layer is recycled since it is used to track + * changes in the use of mask layers. + */ + uint32_t mMaskClipCount; + /** * A color that should be painted over the bounds of the layer's visible * region before any other content is painted. */ nscolor mForcedBackgroundColor; + /** * The resolution scale used. */ @@ -1675,6 +1683,10 @@ ContainerState::FindThebesLayerFor(nsDisplayItem* aItem, layer = thebesLayerData->mLayer; } + // check to see if the new item has rounded rect clips in common with + // other items in the layer + thebesLayerData->UpdateCommonClipCount(aClip); + thebesLayerData->Accumulate(this, aItem, aVisibleRect, aDrawRect, aClip); return thebesLayerData; @@ -3202,7 +3214,7 @@ FrameLayerBuilder::Clip::RemoveRoundedCorners() } gfxRect -CalculateBounds(nsTArray aRects, int32_t A2D) +CalculateBounds(const nsTArray& aRects, int32_t A2D) { nsRect bounds = aRects[0].mRect; for (uint32_t i = 1; i < aRects.Length(); ++i) { @@ -3211,16 +3223,36 @@ CalculateBounds(nsTArray aRects, int32_t A return nsLayoutUtils::RectToGfxRect(bounds, A2D); } - + +static void +SetClipCount(ThebesDisplayItemLayerUserData* aThebesData, + uint32_t aClipCount) +{ + if (aThebesData) { + aThebesData->mMaskClipCount = aClipCount; + } +} + void ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aClip, uint32_t aRoundedRectClipCount) { + // if the number of clips we are going to mask has decreased, then aLayer might have + // cached graphics which assume the existence of a soon-to-be non-existent mask layer + // in that case, invalidate the whole layer. + ThebesDisplayItemLayerUserData* thebesData = GetThebesDisplayItemLayerUserData(aLayer); + if (thebesData && + aRoundedRectClipCount < thebesData->mMaskClipCount) { + ThebesLayer* thebes = aLayer->AsThebesLayer(); + thebes->InvalidateRegion(thebes->GetValidRegion().GetBounds()); + } + // don't build an unnecessary mask nsIntRect layerBounds = aLayer->GetVisibleRegion().GetBounds(); if (aClip.mRoundedClipRects.IsEmpty() || - aRoundedRectClipCount <= 0 || + aRoundedRectClipCount == 0 || layerBounds.IsEmpty()) { + SetClipCount(thebesData, 0); return; } @@ -3238,6 +3270,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl if (*userData == newData) { aLayer->SetMaskLayer(maskLayer); + SetClipCount(thebesData, aRoundedRectClipCount); return; } @@ -3292,6 +3325,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl // fail if we can't get the right surface if (!surface || surface->CairoStatus()) { NS_WARNING("Could not create surface for mask layer."); + SetClipCount(thebesData, 0); return; } @@ -3327,6 +3361,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl userData->mImageKey = key; aLayer->SetMaskLayer(maskLayer); + SetClipCount(thebesData, aRoundedRectClipCount); return; } From b56388c6aa7bed85bbc5cc7075bb6d105aa70a7e Mon Sep 17 00:00:00 2001 From: Nicholas Cameron Date: Mon, 3 Sep 2012 18:58:07 +1200 Subject: [PATCH 16/70] Bug 769021; fix a memory leak with mask sharing. r=khuey --- layout/base/FrameLayerBuilder.cpp | 24 ++++++-------- layout/base/MaskLayerImageCache.cpp | 5 ++- layout/base/MaskLayerImageCache.h | 51 ++++++++++++++++++++++++----- 3 files changed, 56 insertions(+), 24 deletions(-) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 91d9bae67d60..18e9f6406efa 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -3296,28 +3296,24 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl gfxMatrix imageTransform = maskTransform; imageTransform.Scale(mParameters.mXScale, mParameters.mYScale); + nsAutoPtr newKey( + new MaskLayerImageCache::MaskLayerImageKey(aLayer->Manager()->GetBackendType())); + // copy and transform the rounded rects - nsTArray roundedRects; for (uint32_t i = 0; i < newData.mRoundedClipRects.Length(); ++i) { - roundedRects.AppendElement( + newKey->mRoundedClipRects.AppendElement( MaskLayerImageCache::PixelRoundedRect(newData.mRoundedClipRects[i], mContainerFrame->PresContext())); - roundedRects[i].ScaleAndTranslate(imageTransform); + newKey->mRoundedClipRects[i].ScaleAndTranslate(imageTransform); } - // check to see if we can reuse a mask image - const MaskLayerImageCache::MaskLayerImageKey* key = - new MaskLayerImageCache::MaskLayerImageKey(roundedRects, aLayer->Manager()->GetBackendType()); - const MaskLayerImageCache::MaskLayerImageKey* lookupKey = key; + const MaskLayerImageCache::MaskLayerImageKey* lookupKey = newKey; + // check to see if we can reuse a mask image nsRefPtr container = GetMaskLayerImageCache()->FindImageFor(&lookupKey); - if (container) { - // track the returned key for the mask image - delete key; - key = lookupKey; - } else { + if (!container) { // no existing mask image, so build a new one nsRefPtr surface = aLayer->Manager()->CreateOptimalMaskSurface(surfaceSize); @@ -3348,7 +3344,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl static_cast(image.get())->SetData(data); container->SetCurrentImageInTransaction(image); - GetMaskLayerImageCache()->PutImage(key, container); + GetMaskLayerImageCache()->PutImage(newKey.forget(), container); } maskLayer->SetContainer(container); @@ -3358,7 +3354,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl userData->mScaleX = newData.mScaleX; userData->mScaleY = newData.mScaleY; userData->mRoundedClipRects.SwapElements(newData.mRoundedClipRects); - userData->mImageKey = key; + userData->mImageKey = lookupKey; aLayer->SetMaskLayer(maskLayer); SetClipCount(thebesData, aRoundedRectClipCount); diff --git a/layout/base/MaskLayerImageCache.cpp b/layout/base/MaskLayerImageCache.cpp index 8c67029be615..af21c4b83262 100644 --- a/layout/base/MaskLayerImageCache.cpp +++ b/layout/base/MaskLayerImageCache.cpp @@ -12,10 +12,13 @@ namespace mozilla { MaskLayerImageCache::MaskLayerImageCache() { + MOZ_COUNT_CTOR(MaskLayerImageCache); mMaskImageContainers.Init(); } MaskLayerImageCache::~MaskLayerImageCache() -{} +{ + MOZ_COUNT_DTOR(MaskLayerImageCache); +} /* static */ PLDHashOperator diff --git a/layout/base/MaskLayerImageCache.h b/layout/base/MaskLayerImageCache.h index ab27f4f7016f..5598c5f54163 100644 --- a/layout/base/MaskLayerImageCache.h +++ b/layout/base/MaskLayerImageCache.h @@ -50,10 +50,24 @@ public: aPresContext->AppUnitsToGfxUnits(aRRect.mRect.width), aPresContext->AppUnitsToGfxUnits(aRRect.mRect.height)) { + MOZ_COUNT_CTOR(PixelRoundedRect); NS_FOR_CSS_HALF_CORNERS(corner) { mRadii[corner] = aPresContext->AppUnitsToGfxUnits(aRRect.mRadii[corner]); } } + PixelRoundedRect(const PixelRoundedRect& aPRR) + : mRect(aPRR.mRect) + { + MOZ_COUNT_CTOR(PixelRoundedRect); + NS_FOR_CSS_HALF_CORNERS(corner) { + mRadii[corner] = aPRR.mRadii[corner]; + } + } + + ~PixelRoundedRect() + { + MOZ_COUNT_DTOR(PixelRoundedRect); + } // Applies the scale and translate components of aTransform. // It is an error to pass a matrix which does more than just scale @@ -99,6 +113,9 @@ public: gfxRect mRect; // Indices into mRadii are the NS_CORNER_* constants in nsStyleConsts.h gfxFloat mRadii[8]; + + private: + PixelRoundedRect() MOZ_DELETE; }; /** @@ -111,14 +128,27 @@ public: * pointers to a key object (the +1 being from the hashtable entry), but this * invariant may be temporarily broken. */ - class MaskLayerImageKey + struct MaskLayerImageKey { - public: - MaskLayerImageKey(const nsTArray& aRoundedClipRects, layers::LayersBackend aBackend) + MaskLayerImageKey(layers::LayersBackend aBackend) : mBackend(aBackend) , mLayerCount(0) - , mRoundedClipRects(aRoundedClipRects) - {} + , mRoundedClipRects() + { + MOZ_COUNT_CTOR(MaskLayerImageKey); + } + MaskLayerImageKey(const MaskLayerImageKey& aKey) + : mBackend(aKey.mBackend) + , mLayerCount(aKey.mLayerCount) + , mRoundedClipRects(aKey.mRoundedClipRects) + { + MOZ_COUNT_CTOR(MaskLayerImageKey); + } + + ~MaskLayerImageKey() + { + MOZ_COUNT_DTOR(MaskLayerImageKey); + } void AddRef() const { ++mLayerCount; } void Release() const @@ -172,11 +202,14 @@ protected: typedef const MaskLayerImageKey& KeyType; typedef const MaskLayerImageKey* KeyTypePointer; - MaskLayerImageEntry(KeyTypePointer aKey) : mKey(aKey) {} - MaskLayerImageEntry(const MaskLayerImageEntry& aOther) - : mKey(aOther.mKey.get()) + MaskLayerImageEntry(KeyTypePointer aKey) : mKey(aKey) { - NS_ERROR("ALLOW_MEMMOVE == true, should never be called"); + MOZ_COUNT_CTOR(MaskLayerImageEntry); + } + MaskLayerImageEntry(const MaskLayerImageEntry& aOther) MOZ_DELETE; + ~MaskLayerImageEntry() + { + MOZ_COUNT_DTOR(MaskLayerImageEntry); } // KeyEquals(): does this entry match this key? From ac89c3d82799c1e051660a0bb7ed3325bb8785c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A3o=20Gottwald?= Date: Mon, 3 Sep 2012 09:24:15 +0200 Subject: [PATCH 17/70] Bug 786495 - Dragging a tab to bookmark it or cancelling the drag-and-drop operation (pressing ESC) unexpectedly reorders tabs. r=jaws --- browser/base/content/tabbrowser.xml | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index ff7ec2d7035e..3c25c58bac06 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -3228,25 +3228,16 @@ - draggedTab._tPos) - newIndex--; - this.tabbrowser.moveTabTo(draggedTab, newIndex); - } - } - for (let tab of this.tabbrowser.visibleTabs) tab.style.transform = ""; this.removeAttribute("movingtab"); + + this._handleTabSelect(); ]]> @@ -3623,7 +3614,7 @@ return; } - this._finishAnimateTabMove(event); + this._finishAnimateTabMove(); if (effects == "link") { let tab = this._getDragTargetTab(event); @@ -3700,7 +3691,14 @@ if (draggedTab.parentNode != this || event.shiftKey) this.selectedItem = newTab; } else if (draggedTab && draggedTab.parentNode == this) { - this._finishAnimateTabMove(event); + // actually move the dragged tab + if ("animDropIndex" in draggedTab._dragData) { + let newIndex = draggedTab._dragData.animDropIndex; + if (newIndex > draggedTab._tPos) + newIndex--; + this.tabbrowser.moveTabTo(draggedTab, newIndex); + } + this._finishAnimateTabMove(); } else if (draggedTab) { // swap the dropped tab with a new one we create and then close // it in the other window (making it seem to have moved between @@ -3769,7 +3767,7 @@ // isn't dispatched when the tab is moved within the tabstrip, // see bug 460801. - this._finishAnimateTabMove(event); + this._finishAnimateTabMove(); var dt = event.dataTransfer; var draggedTab = dt.mozGetDataAt(TAB_DROP_TYPE, 0); From da002e7c2da5e08db48915a399121833686edccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kan-Ru=20Chen=20=28=E9=99=B3=E4=BE=83=E5=A6=82=29?= Date: Mon, 3 Sep 2012 15:36:04 +0800 Subject: [PATCH 18/70] Bug 785339 - Restore BasicPlanarYCbCrImage::SetDelayedConversion. r=roc --- content/media/nsBuiltinDecoderReader.cpp | 1 + gfx/layers/basic/BasicImages.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/content/media/nsBuiltinDecoderReader.cpp b/content/media/nsBuiltinDecoderReader.cpp index c60d076b2c02..8e7bcce1080b 100644 --- a/content/media/nsBuiltinDecoderReader.cpp +++ b/content/media/nsBuiltinDecoderReader.cpp @@ -233,6 +233,7 @@ VideoData* VideoData::Create(nsVideoInfo& aInfo, data.mPicSize = gfxIntSize(aPicture.width, aPicture.height); data.mStereoMode = aInfo.mStereoMode; + videoImage->SetDelayedConversion(true); videoImage->SetData(data); return v.forget(); } diff --git a/gfx/layers/basic/BasicImages.cpp b/gfx/layers/basic/BasicImages.cpp index 6b73bb76cfb0..c3c234ef4e64 100644 --- a/gfx/layers/basic/BasicImages.cpp +++ b/gfx/layers/basic/BasicImages.cpp @@ -30,6 +30,7 @@ public: BasicPlanarYCbCrImage(const gfxIntSize& aScaleHint, gfxImageFormat aOffscreenFormat, BufferRecycleBin *aRecycleBin) : PlanarYCbCrImage(aRecycleBin) , mScaleHint(aScaleHint) + , mDelayedConversion(false) { SetOffscreenFormat(aOffscreenFormat); } @@ -44,12 +45,15 @@ public: } virtual void SetData(const Data& aData); + virtual void SetDelayedConversion(bool aDelayed) { mDelayedConversion = aDelayed; } + already_AddRefed GetAsSurface(); private: + nsAutoArrayPtr mDecodedBuffer; gfxIntSize mScaleHint; int mStride; - nsAutoArrayPtr mDecodedBuffer; + bool mDelayedConversion; }; class BasicImageFactory : public ImageFactory @@ -81,6 +85,10 @@ BasicPlanarYCbCrImage::SetData(const Data& aData) { PlanarYCbCrImage::SetData(aData); + if (mDelayedConversion) { + return; + } + // Do some sanity checks to prevent integer overflow if (aData.mYSize.width > PlanarYCbCrImage::MAX_DIMENSION || aData.mYSize.height > PlanarYCbCrImage::MAX_DIMENSION) { From eaff9ae281cd8d6f28dbaa110b85604d8d378cec Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Mon, 3 Sep 2012 09:20:05 +0100 Subject: [PATCH 19/70] Backout 03cb77f8d75d (bug 769021), 04fd792509d6 (bug 786817) for burning the tree --- layout/base/FrameLayerBuilder.cpp | 65 ++++++++--------------------- layout/base/MaskLayerImageCache.cpp | 5 +-- layout/base/MaskLayerImageCache.h | 51 ++++------------------ 3 files changed, 27 insertions(+), 94 deletions(-) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 18e9f6406efa..10170f5023f1 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -497,19 +497,11 @@ public: mXScale(1.f), mYScale(1.f), mActiveScrolledRootPosition(0, 0) {} - /** - * Record the number of clips in the Thebes layer's mask layer. - * Should not be reset when the layer is recycled since it is used to track - * changes in the use of mask layers. - */ - uint32_t mMaskClipCount; - /** * A color that should be painted over the bounds of the layer's visible * region before any other content is painted. */ nscolor mForcedBackgroundColor; - /** * The resolution scale used. */ @@ -1683,10 +1675,6 @@ ContainerState::FindThebesLayerFor(nsDisplayItem* aItem, layer = thebesLayerData->mLayer; } - // check to see if the new item has rounded rect clips in common with - // other items in the layer - thebesLayerData->UpdateCommonClipCount(aClip); - thebesLayerData->Accumulate(this, aItem, aVisibleRect, aDrawRect, aClip); return thebesLayerData; @@ -3214,7 +3202,7 @@ FrameLayerBuilder::Clip::RemoveRoundedCorners() } gfxRect -CalculateBounds(const nsTArray& aRects, int32_t A2D) +CalculateBounds(nsTArray aRects, int32_t A2D) { nsRect bounds = aRects[0].mRect; for (uint32_t i = 1; i < aRects.Length(); ++i) { @@ -3223,36 +3211,16 @@ CalculateBounds(const nsTArray& aRects, in return nsLayoutUtils::RectToGfxRect(bounds, A2D); } - -static void -SetClipCount(ThebesDisplayItemLayerUserData* aThebesData, - uint32_t aClipCount) -{ - if (aThebesData) { - aThebesData->mMaskClipCount = aClipCount; - } -} - + void ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aClip, uint32_t aRoundedRectClipCount) { - // if the number of clips we are going to mask has decreased, then aLayer might have - // cached graphics which assume the existence of a soon-to-be non-existent mask layer - // in that case, invalidate the whole layer. - ThebesDisplayItemLayerUserData* thebesData = GetThebesDisplayItemLayerUserData(aLayer); - if (thebesData && - aRoundedRectClipCount < thebesData->mMaskClipCount) { - ThebesLayer* thebes = aLayer->AsThebesLayer(); - thebes->InvalidateRegion(thebes->GetValidRegion().GetBounds()); - } - // don't build an unnecessary mask nsIntRect layerBounds = aLayer->GetVisibleRegion().GetBounds(); if (aClip.mRoundedClipRects.IsEmpty() || - aRoundedRectClipCount == 0 || + aRoundedRectClipCount <= 0 || layerBounds.IsEmpty()) { - SetClipCount(thebesData, 0); return; } @@ -3270,7 +3238,6 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl if (*userData == newData) { aLayer->SetMaskLayer(maskLayer); - SetClipCount(thebesData, aRoundedRectClipCount); return; } @@ -3296,24 +3263,28 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl gfxMatrix imageTransform = maskTransform; imageTransform.Scale(mParameters.mXScale, mParameters.mYScale); - nsAutoPtr newKey( - new MaskLayerImageCache::MaskLayerImageKey(aLayer->Manager()->GetBackendType())); - // copy and transform the rounded rects + nsTArray roundedRects; for (uint32_t i = 0; i < newData.mRoundedClipRects.Length(); ++i) { - newKey->mRoundedClipRects.AppendElement( + roundedRects.AppendElement( MaskLayerImageCache::PixelRoundedRect(newData.mRoundedClipRects[i], mContainerFrame->PresContext())); - newKey->mRoundedClipRects[i].ScaleAndTranslate(imageTransform); + roundedRects[i].ScaleAndTranslate(imageTransform); } - const MaskLayerImageCache::MaskLayerImageKey* lookupKey = newKey; - // check to see if we can reuse a mask image + const MaskLayerImageCache::MaskLayerImageKey* key = + new MaskLayerImageCache::MaskLayerImageKey(roundedRects, aLayer->Manager()->GetBackendType()); + const MaskLayerImageCache::MaskLayerImageKey* lookupKey = key; + nsRefPtr container = GetMaskLayerImageCache()->FindImageFor(&lookupKey); - if (!container) { + if (container) { + // track the returned key for the mask image + delete key; + key = lookupKey; + } else { // no existing mask image, so build a new one nsRefPtr surface = aLayer->Manager()->CreateOptimalMaskSurface(surfaceSize); @@ -3321,7 +3292,6 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl // fail if we can't get the right surface if (!surface || surface->CairoStatus()) { NS_WARNING("Could not create surface for mask layer."); - SetClipCount(thebesData, 0); return; } @@ -3344,7 +3314,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl static_cast(image.get())->SetData(data); container->SetCurrentImageInTransaction(image); - GetMaskLayerImageCache()->PutImage(newKey.forget(), container); + GetMaskLayerImageCache()->PutImage(key, container); } maskLayer->SetContainer(container); @@ -3354,10 +3324,9 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl userData->mScaleX = newData.mScaleX; userData->mScaleY = newData.mScaleY; userData->mRoundedClipRects.SwapElements(newData.mRoundedClipRects); - userData->mImageKey = lookupKey; + userData->mImageKey = key; aLayer->SetMaskLayer(maskLayer); - SetClipCount(thebesData, aRoundedRectClipCount); return; } diff --git a/layout/base/MaskLayerImageCache.cpp b/layout/base/MaskLayerImageCache.cpp index af21c4b83262..8c67029be615 100644 --- a/layout/base/MaskLayerImageCache.cpp +++ b/layout/base/MaskLayerImageCache.cpp @@ -12,13 +12,10 @@ namespace mozilla { MaskLayerImageCache::MaskLayerImageCache() { - MOZ_COUNT_CTOR(MaskLayerImageCache); mMaskImageContainers.Init(); } MaskLayerImageCache::~MaskLayerImageCache() -{ - MOZ_COUNT_DTOR(MaskLayerImageCache); -} +{} /* static */ PLDHashOperator diff --git a/layout/base/MaskLayerImageCache.h b/layout/base/MaskLayerImageCache.h index 5598c5f54163..ab27f4f7016f 100644 --- a/layout/base/MaskLayerImageCache.h +++ b/layout/base/MaskLayerImageCache.h @@ -50,24 +50,10 @@ public: aPresContext->AppUnitsToGfxUnits(aRRect.mRect.width), aPresContext->AppUnitsToGfxUnits(aRRect.mRect.height)) { - MOZ_COUNT_CTOR(PixelRoundedRect); NS_FOR_CSS_HALF_CORNERS(corner) { mRadii[corner] = aPresContext->AppUnitsToGfxUnits(aRRect.mRadii[corner]); } } - PixelRoundedRect(const PixelRoundedRect& aPRR) - : mRect(aPRR.mRect) - { - MOZ_COUNT_CTOR(PixelRoundedRect); - NS_FOR_CSS_HALF_CORNERS(corner) { - mRadii[corner] = aPRR.mRadii[corner]; - } - } - - ~PixelRoundedRect() - { - MOZ_COUNT_DTOR(PixelRoundedRect); - } // Applies the scale and translate components of aTransform. // It is an error to pass a matrix which does more than just scale @@ -113,9 +99,6 @@ public: gfxRect mRect; // Indices into mRadii are the NS_CORNER_* constants in nsStyleConsts.h gfxFloat mRadii[8]; - - private: - PixelRoundedRect() MOZ_DELETE; }; /** @@ -128,27 +111,14 @@ public: * pointers to a key object (the +1 being from the hashtable entry), but this * invariant may be temporarily broken. */ - struct MaskLayerImageKey + class MaskLayerImageKey { - MaskLayerImageKey(layers::LayersBackend aBackend) + public: + MaskLayerImageKey(const nsTArray& aRoundedClipRects, layers::LayersBackend aBackend) : mBackend(aBackend) , mLayerCount(0) - , mRoundedClipRects() - { - MOZ_COUNT_CTOR(MaskLayerImageKey); - } - MaskLayerImageKey(const MaskLayerImageKey& aKey) - : mBackend(aKey.mBackend) - , mLayerCount(aKey.mLayerCount) - , mRoundedClipRects(aKey.mRoundedClipRects) - { - MOZ_COUNT_CTOR(MaskLayerImageKey); - } - - ~MaskLayerImageKey() - { - MOZ_COUNT_DTOR(MaskLayerImageKey); - } + , mRoundedClipRects(aRoundedClipRects) + {} void AddRef() const { ++mLayerCount; } void Release() const @@ -202,14 +172,11 @@ protected: typedef const MaskLayerImageKey& KeyType; typedef const MaskLayerImageKey* KeyTypePointer; - MaskLayerImageEntry(KeyTypePointer aKey) : mKey(aKey) + MaskLayerImageEntry(KeyTypePointer aKey) : mKey(aKey) {} + MaskLayerImageEntry(const MaskLayerImageEntry& aOther) + : mKey(aOther.mKey.get()) { - MOZ_COUNT_CTOR(MaskLayerImageEntry); - } - MaskLayerImageEntry(const MaskLayerImageEntry& aOther) MOZ_DELETE; - ~MaskLayerImageEntry() - { - MOZ_COUNT_DTOR(MaskLayerImageEntry); + NS_ERROR("ALLOW_MEMMOVE == true, should never be called"); } // KeyEquals(): does this entry match this key? From 756cd13dfd31ac33b4f146f0a9aa27395e7819c8 Mon Sep 17 00:00:00 2001 From: "Timothy B. Terriberry" Date: Mon, 3 Sep 2012 01:41:17 -0700 Subject: [PATCH 20/70] Bug 787788 - Fix downmixing weights for 6.1 Opus files, r=rillian --- content/media/ogg/nsOggReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/media/ogg/nsOggReader.cpp b/content/media/ogg/nsOggReader.cpp index 53dd49271d5c..0e9b4df84047 100644 --- a/content/media/ogg/nsOggReader.cpp +++ b/content/media/ogg/nsOggReader.cpp @@ -538,7 +538,7 @@ nsresult nsOggReader::DecodeOpus(ogg_packet* aPacket) { /*4*/{ {0.4226f,0}, {0,0.4226f}, {0.366f,0.2114f}, {0.2114f,0.366f}}, /*5*/{ {0.651f,0}, {0.46f,0.46f}, {0,0.651f}, {0.5636f,0.3254f}, {0.3254f,0.5636f}}, /*6*/{ {0.529f,0}, {0.3741f,0.3741f}, {0,0.529f}, {0.4582f,0.2645f}, {0.2645f,0.4582f}, {0.3741f,0.3741f}}, - /*7*/{ {0.4553f,0}, {0.322f,0.322f}, {0,4553}, {0.3943f,0.2277f}, {0.2277f,0.3943f}, {0.2788f,0.2788f}, {0.322f,0.322f}}, + /*7*/{ {0.4553f,0}, {0.322f,0.322f}, {0,0.4553f}, {0.3943f,0.2277f}, {0.2277f,0.3943f}, {0.2788f,0.2788f}, {0.322f,0.322f}}, /*8*/{ {0.3886f,0}, {0.2748f,0.2748f}, {0,0.3886f}, {0.3366f,0.1943f}, {0.1943f,0.3366f}, {0.3366f,0.1943f}, {0.1943f,0.3366f}, {0.2748f,0.2748f}}, }; for (int32_t i = 0; i < frames; i++) { From b42466cd6ba10d41d20bf31818f53658736769b1 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Mon, 3 Sep 2012 10:04:49 +0100 Subject: [PATCH 21/70] Backout 1d89bc229215 (bug 784142) for bug 787744 --- browser/base/content/test/Makefile.in | 1 - .../base/content/test/browser_bug784142.js | 61 ------------------- dom/base/nsGlobalWindow.cpp | 10 ++- 3 files changed, 4 insertions(+), 68 deletions(-) delete mode 100644 browser/base/content/test/browser_bug784142.js diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in index 9394dbbc0a35..4fe61ae88aee 100644 --- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -274,7 +274,6 @@ _BROWSER_FILES = \ social_flyout.html \ social_window.html \ social_worker.js \ - browser_bug784142.js \ $(NULL) ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT)) diff --git a/browser/base/content/test/browser_bug784142.js b/browser/base/content/test/browser_bug784142.js deleted file mode 100644 index e028879d7f93..000000000000 --- a/browser/base/content/test/browser_bug784142.js +++ /dev/null @@ -1,61 +0,0 @@ -const windowMediator = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); - -function test() -{ - waitForExplicitFinish(); - - // Need to enable modal dialogs for this test. - Services.prefs.setBoolPref("prompts.tab_modal.enabled", false); - - windowMediator.addListener(promptListener); - - // Open a new tab and have that tab open a new window. This is done to - // ensure that the new window is a normal browser window. - var script = "window.open('data:text/html,', null, 'width=200,height=200');"; - gBrowser.selectedTab = - gBrowser.addTab("data:text/html,"); -} - -function windowOpened(win) -{ - // Wait for the page in the window to load. - waitForFocus(clickButton, win.content); -} - -function clickButton(win) -{ - // Set the window in the prompt listener to indicate that the alert window - // is now expected to open. - promptListener.window = win; - - // Click the Close button in the window. - EventUtils.synthesizeMouseAtCenter(win.content.document.getElementById("button"), { }, win); - - windowMediator.removeListener(promptListener); - gBrowser.removeTab(gBrowser.selectedTab); - - is(promptListener.message, "window appeared", "modal prompt closer didn't crash"); - Services.prefs.clearUserPref("prompts.tab_modal.enabled", false); - finish(); -} - -var promptListener = { - onWindowTitleChange: function () {}, - onOpenWindow: function (win) { - let domWin = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow); - if (!promptListener.window) { - // The first window that is open is the one opened by the new tab. - waitForFocus(windowOpened, domWin); - } - else { - // The second window is the alert opened when clicking the Close button in the window - ok(promptListener.window.closed, "window has closed"); - - // Assign a message so that it can be checked just before the test - // finishes to ensure that the alert opened properly. - promptListener.message = "window appeared"; - executeSoon(function () { domWin.close() }); - } - }, - onCloseWindow: function () {} -}; diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 1ee17c870cbf..73f4b5d3146f 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -2518,7 +2518,7 @@ nsGlobalWindow::DialogsAreBlocked(bool *aBeingAbused) nsGlobalWindow *topWindow = GetScriptableTop(); if (!topWindow) { - NS_ASSERTION(!mDocShell, "DialogsAreBlocked() called without a top window?"); + NS_ERROR("DialogsAreBlocked() called without a top window?"); return true; } @@ -7652,11 +7652,9 @@ nsGlobalWindow::ActivateOrDeactivate(bool aActivate) // widgetListener should be a nsXULWindow nsIWidgetListener* listener = topLevelWidget->GetWidgetListener(); - if (listener) { - nsCOMPtr window = listener->GetXULWindow(); - nsCOMPtr req(do_QueryInterface(window)); - topLevelWindow = do_GetInterface(req); - } + nsCOMPtr window = listener->GetXULWindow(); + nsCOMPtr req(do_QueryInterface(window)); + topLevelWindow = do_GetInterface(req); } if (topLevelWindow) { nsCOMPtr piWin(do_QueryInterface(topLevelWindow)); From 90e033f0ae4ef4ef0a7ac8948315015250ec012d Mon Sep 17 00:00:00 2001 From: Nicholas Cameron Date: Mon, 3 Sep 2012 22:35:33 +1200 Subject: [PATCH 22/70] Bug 786817; Check multiple masks properly and invalidate after removing a mask layer. r=roc --- layout/base/FrameLayerBuilder.cpp | 41 ++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 10170f5023f1..91d9bae67d60 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -497,11 +497,19 @@ public: mXScale(1.f), mYScale(1.f), mActiveScrolledRootPosition(0, 0) {} + /** + * Record the number of clips in the Thebes layer's mask layer. + * Should not be reset when the layer is recycled since it is used to track + * changes in the use of mask layers. + */ + uint32_t mMaskClipCount; + /** * A color that should be painted over the bounds of the layer's visible * region before any other content is painted. */ nscolor mForcedBackgroundColor; + /** * The resolution scale used. */ @@ -1675,6 +1683,10 @@ ContainerState::FindThebesLayerFor(nsDisplayItem* aItem, layer = thebesLayerData->mLayer; } + // check to see if the new item has rounded rect clips in common with + // other items in the layer + thebesLayerData->UpdateCommonClipCount(aClip); + thebesLayerData->Accumulate(this, aItem, aVisibleRect, aDrawRect, aClip); return thebesLayerData; @@ -3202,7 +3214,7 @@ FrameLayerBuilder::Clip::RemoveRoundedCorners() } gfxRect -CalculateBounds(nsTArray aRects, int32_t A2D) +CalculateBounds(const nsTArray& aRects, int32_t A2D) { nsRect bounds = aRects[0].mRect; for (uint32_t i = 1; i < aRects.Length(); ++i) { @@ -3211,16 +3223,36 @@ CalculateBounds(nsTArray aRects, int32_t A return nsLayoutUtils::RectToGfxRect(bounds, A2D); } - + +static void +SetClipCount(ThebesDisplayItemLayerUserData* aThebesData, + uint32_t aClipCount) +{ + if (aThebesData) { + aThebesData->mMaskClipCount = aClipCount; + } +} + void ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aClip, uint32_t aRoundedRectClipCount) { + // if the number of clips we are going to mask has decreased, then aLayer might have + // cached graphics which assume the existence of a soon-to-be non-existent mask layer + // in that case, invalidate the whole layer. + ThebesDisplayItemLayerUserData* thebesData = GetThebesDisplayItemLayerUserData(aLayer); + if (thebesData && + aRoundedRectClipCount < thebesData->mMaskClipCount) { + ThebesLayer* thebes = aLayer->AsThebesLayer(); + thebes->InvalidateRegion(thebes->GetValidRegion().GetBounds()); + } + // don't build an unnecessary mask nsIntRect layerBounds = aLayer->GetVisibleRegion().GetBounds(); if (aClip.mRoundedClipRects.IsEmpty() || - aRoundedRectClipCount <= 0 || + aRoundedRectClipCount == 0 || layerBounds.IsEmpty()) { + SetClipCount(thebesData, 0); return; } @@ -3238,6 +3270,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl if (*userData == newData) { aLayer->SetMaskLayer(maskLayer); + SetClipCount(thebesData, aRoundedRectClipCount); return; } @@ -3292,6 +3325,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl // fail if we can't get the right surface if (!surface || surface->CairoStatus()) { NS_WARNING("Could not create surface for mask layer."); + SetClipCount(thebesData, 0); return; } @@ -3327,6 +3361,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl userData->mImageKey = key; aLayer->SetMaskLayer(maskLayer); + SetClipCount(thebesData, aRoundedRectClipCount); return; } From 0d44d4a95dced8c54c90af25b05a4396a8a756b8 Mon Sep 17 00:00:00 2001 From: Nicholas Cameron Date: Mon, 3 Sep 2012 22:35:33 +1200 Subject: [PATCH 23/70] Bug 769021; fix a memory leak with mask sharing. r=khuey --- layout/base/FrameLayerBuilder.cpp | 24 ++++++-------- layout/base/MaskLayerImageCache.cpp | 5 ++- layout/base/MaskLayerImageCache.h | 51 ++++++++++++++++++++++++----- 3 files changed, 56 insertions(+), 24 deletions(-) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 91d9bae67d60..18e9f6406efa 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -3296,28 +3296,24 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl gfxMatrix imageTransform = maskTransform; imageTransform.Scale(mParameters.mXScale, mParameters.mYScale); + nsAutoPtr newKey( + new MaskLayerImageCache::MaskLayerImageKey(aLayer->Manager()->GetBackendType())); + // copy and transform the rounded rects - nsTArray roundedRects; for (uint32_t i = 0; i < newData.mRoundedClipRects.Length(); ++i) { - roundedRects.AppendElement( + newKey->mRoundedClipRects.AppendElement( MaskLayerImageCache::PixelRoundedRect(newData.mRoundedClipRects[i], mContainerFrame->PresContext())); - roundedRects[i].ScaleAndTranslate(imageTransform); + newKey->mRoundedClipRects[i].ScaleAndTranslate(imageTransform); } - // check to see if we can reuse a mask image - const MaskLayerImageCache::MaskLayerImageKey* key = - new MaskLayerImageCache::MaskLayerImageKey(roundedRects, aLayer->Manager()->GetBackendType()); - const MaskLayerImageCache::MaskLayerImageKey* lookupKey = key; + const MaskLayerImageCache::MaskLayerImageKey* lookupKey = newKey; + // check to see if we can reuse a mask image nsRefPtr container = GetMaskLayerImageCache()->FindImageFor(&lookupKey); - if (container) { - // track the returned key for the mask image - delete key; - key = lookupKey; - } else { + if (!container) { // no existing mask image, so build a new one nsRefPtr surface = aLayer->Manager()->CreateOptimalMaskSurface(surfaceSize); @@ -3348,7 +3344,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl static_cast(image.get())->SetData(data); container->SetCurrentImageInTransaction(image); - GetMaskLayerImageCache()->PutImage(key, container); + GetMaskLayerImageCache()->PutImage(newKey.forget(), container); } maskLayer->SetContainer(container); @@ -3358,7 +3354,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl userData->mScaleX = newData.mScaleX; userData->mScaleY = newData.mScaleY; userData->mRoundedClipRects.SwapElements(newData.mRoundedClipRects); - userData->mImageKey = key; + userData->mImageKey = lookupKey; aLayer->SetMaskLayer(maskLayer); SetClipCount(thebesData, aRoundedRectClipCount); diff --git a/layout/base/MaskLayerImageCache.cpp b/layout/base/MaskLayerImageCache.cpp index 8c67029be615..af21c4b83262 100644 --- a/layout/base/MaskLayerImageCache.cpp +++ b/layout/base/MaskLayerImageCache.cpp @@ -12,10 +12,13 @@ namespace mozilla { MaskLayerImageCache::MaskLayerImageCache() { + MOZ_COUNT_CTOR(MaskLayerImageCache); mMaskImageContainers.Init(); } MaskLayerImageCache::~MaskLayerImageCache() -{} +{ + MOZ_COUNT_DTOR(MaskLayerImageCache); +} /* static */ PLDHashOperator diff --git a/layout/base/MaskLayerImageCache.h b/layout/base/MaskLayerImageCache.h index ab27f4f7016f..5598c5f54163 100644 --- a/layout/base/MaskLayerImageCache.h +++ b/layout/base/MaskLayerImageCache.h @@ -50,10 +50,24 @@ public: aPresContext->AppUnitsToGfxUnits(aRRect.mRect.width), aPresContext->AppUnitsToGfxUnits(aRRect.mRect.height)) { + MOZ_COUNT_CTOR(PixelRoundedRect); NS_FOR_CSS_HALF_CORNERS(corner) { mRadii[corner] = aPresContext->AppUnitsToGfxUnits(aRRect.mRadii[corner]); } } + PixelRoundedRect(const PixelRoundedRect& aPRR) + : mRect(aPRR.mRect) + { + MOZ_COUNT_CTOR(PixelRoundedRect); + NS_FOR_CSS_HALF_CORNERS(corner) { + mRadii[corner] = aPRR.mRadii[corner]; + } + } + + ~PixelRoundedRect() + { + MOZ_COUNT_DTOR(PixelRoundedRect); + } // Applies the scale and translate components of aTransform. // It is an error to pass a matrix which does more than just scale @@ -99,6 +113,9 @@ public: gfxRect mRect; // Indices into mRadii are the NS_CORNER_* constants in nsStyleConsts.h gfxFloat mRadii[8]; + + private: + PixelRoundedRect() MOZ_DELETE; }; /** @@ -111,14 +128,27 @@ public: * pointers to a key object (the +1 being from the hashtable entry), but this * invariant may be temporarily broken. */ - class MaskLayerImageKey + struct MaskLayerImageKey { - public: - MaskLayerImageKey(const nsTArray& aRoundedClipRects, layers::LayersBackend aBackend) + MaskLayerImageKey(layers::LayersBackend aBackend) : mBackend(aBackend) , mLayerCount(0) - , mRoundedClipRects(aRoundedClipRects) - {} + , mRoundedClipRects() + { + MOZ_COUNT_CTOR(MaskLayerImageKey); + } + MaskLayerImageKey(const MaskLayerImageKey& aKey) + : mBackend(aKey.mBackend) + , mLayerCount(aKey.mLayerCount) + , mRoundedClipRects(aKey.mRoundedClipRects) + { + MOZ_COUNT_CTOR(MaskLayerImageKey); + } + + ~MaskLayerImageKey() + { + MOZ_COUNT_DTOR(MaskLayerImageKey); + } void AddRef() const { ++mLayerCount; } void Release() const @@ -172,11 +202,14 @@ protected: typedef const MaskLayerImageKey& KeyType; typedef const MaskLayerImageKey* KeyTypePointer; - MaskLayerImageEntry(KeyTypePointer aKey) : mKey(aKey) {} - MaskLayerImageEntry(const MaskLayerImageEntry& aOther) - : mKey(aOther.mKey.get()) + MaskLayerImageEntry(KeyTypePointer aKey) : mKey(aKey) { - NS_ERROR("ALLOW_MEMMOVE == true, should never be called"); + MOZ_COUNT_CTOR(MaskLayerImageEntry); + } + MaskLayerImageEntry(const MaskLayerImageEntry& aOther) MOZ_DELETE; + ~MaskLayerImageEntry() + { + MOZ_COUNT_DTOR(MaskLayerImageEntry); } // KeyEquals(): does this entry match this key? From e78f249443b8d67cfd15488d56a961bad2e27636 Mon Sep 17 00:00:00 2001 From: Nicholas Cameron Date: Mon, 3 Sep 2012 22:47:51 +1200 Subject: [PATCH 24/70] Back out bug 769021, bug 786817 --- layout/base/FrameLayerBuilder.cpp | 65 ++++++++--------------------- layout/base/MaskLayerImageCache.cpp | 5 +-- layout/base/MaskLayerImageCache.h | 51 ++++------------------ 3 files changed, 27 insertions(+), 94 deletions(-) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 18e9f6406efa..10170f5023f1 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -497,19 +497,11 @@ public: mXScale(1.f), mYScale(1.f), mActiveScrolledRootPosition(0, 0) {} - /** - * Record the number of clips in the Thebes layer's mask layer. - * Should not be reset when the layer is recycled since it is used to track - * changes in the use of mask layers. - */ - uint32_t mMaskClipCount; - /** * A color that should be painted over the bounds of the layer's visible * region before any other content is painted. */ nscolor mForcedBackgroundColor; - /** * The resolution scale used. */ @@ -1683,10 +1675,6 @@ ContainerState::FindThebesLayerFor(nsDisplayItem* aItem, layer = thebesLayerData->mLayer; } - // check to see if the new item has rounded rect clips in common with - // other items in the layer - thebesLayerData->UpdateCommonClipCount(aClip); - thebesLayerData->Accumulate(this, aItem, aVisibleRect, aDrawRect, aClip); return thebesLayerData; @@ -3214,7 +3202,7 @@ FrameLayerBuilder::Clip::RemoveRoundedCorners() } gfxRect -CalculateBounds(const nsTArray& aRects, int32_t A2D) +CalculateBounds(nsTArray aRects, int32_t A2D) { nsRect bounds = aRects[0].mRect; for (uint32_t i = 1; i < aRects.Length(); ++i) { @@ -3223,36 +3211,16 @@ CalculateBounds(const nsTArray& aRects, in return nsLayoutUtils::RectToGfxRect(bounds, A2D); } - -static void -SetClipCount(ThebesDisplayItemLayerUserData* aThebesData, - uint32_t aClipCount) -{ - if (aThebesData) { - aThebesData->mMaskClipCount = aClipCount; - } -} - + void ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aClip, uint32_t aRoundedRectClipCount) { - // if the number of clips we are going to mask has decreased, then aLayer might have - // cached graphics which assume the existence of a soon-to-be non-existent mask layer - // in that case, invalidate the whole layer. - ThebesDisplayItemLayerUserData* thebesData = GetThebesDisplayItemLayerUserData(aLayer); - if (thebesData && - aRoundedRectClipCount < thebesData->mMaskClipCount) { - ThebesLayer* thebes = aLayer->AsThebesLayer(); - thebes->InvalidateRegion(thebes->GetValidRegion().GetBounds()); - } - // don't build an unnecessary mask nsIntRect layerBounds = aLayer->GetVisibleRegion().GetBounds(); if (aClip.mRoundedClipRects.IsEmpty() || - aRoundedRectClipCount == 0 || + aRoundedRectClipCount <= 0 || layerBounds.IsEmpty()) { - SetClipCount(thebesData, 0); return; } @@ -3270,7 +3238,6 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl if (*userData == newData) { aLayer->SetMaskLayer(maskLayer); - SetClipCount(thebesData, aRoundedRectClipCount); return; } @@ -3296,24 +3263,28 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl gfxMatrix imageTransform = maskTransform; imageTransform.Scale(mParameters.mXScale, mParameters.mYScale); - nsAutoPtr newKey( - new MaskLayerImageCache::MaskLayerImageKey(aLayer->Manager()->GetBackendType())); - // copy and transform the rounded rects + nsTArray roundedRects; for (uint32_t i = 0; i < newData.mRoundedClipRects.Length(); ++i) { - newKey->mRoundedClipRects.AppendElement( + roundedRects.AppendElement( MaskLayerImageCache::PixelRoundedRect(newData.mRoundedClipRects[i], mContainerFrame->PresContext())); - newKey->mRoundedClipRects[i].ScaleAndTranslate(imageTransform); + roundedRects[i].ScaleAndTranslate(imageTransform); } - const MaskLayerImageCache::MaskLayerImageKey* lookupKey = newKey; - // check to see if we can reuse a mask image + const MaskLayerImageCache::MaskLayerImageKey* key = + new MaskLayerImageCache::MaskLayerImageKey(roundedRects, aLayer->Manager()->GetBackendType()); + const MaskLayerImageCache::MaskLayerImageKey* lookupKey = key; + nsRefPtr container = GetMaskLayerImageCache()->FindImageFor(&lookupKey); - if (!container) { + if (container) { + // track the returned key for the mask image + delete key; + key = lookupKey; + } else { // no existing mask image, so build a new one nsRefPtr surface = aLayer->Manager()->CreateOptimalMaskSurface(surfaceSize); @@ -3321,7 +3292,6 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl // fail if we can't get the right surface if (!surface || surface->CairoStatus()) { NS_WARNING("Could not create surface for mask layer."); - SetClipCount(thebesData, 0); return; } @@ -3344,7 +3314,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl static_cast(image.get())->SetData(data); container->SetCurrentImageInTransaction(image); - GetMaskLayerImageCache()->PutImage(newKey.forget(), container); + GetMaskLayerImageCache()->PutImage(key, container); } maskLayer->SetContainer(container); @@ -3354,10 +3324,9 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl userData->mScaleX = newData.mScaleX; userData->mScaleY = newData.mScaleY; userData->mRoundedClipRects.SwapElements(newData.mRoundedClipRects); - userData->mImageKey = lookupKey; + userData->mImageKey = key; aLayer->SetMaskLayer(maskLayer); - SetClipCount(thebesData, aRoundedRectClipCount); return; } diff --git a/layout/base/MaskLayerImageCache.cpp b/layout/base/MaskLayerImageCache.cpp index af21c4b83262..8c67029be615 100644 --- a/layout/base/MaskLayerImageCache.cpp +++ b/layout/base/MaskLayerImageCache.cpp @@ -12,13 +12,10 @@ namespace mozilla { MaskLayerImageCache::MaskLayerImageCache() { - MOZ_COUNT_CTOR(MaskLayerImageCache); mMaskImageContainers.Init(); } MaskLayerImageCache::~MaskLayerImageCache() -{ - MOZ_COUNT_DTOR(MaskLayerImageCache); -} +{} /* static */ PLDHashOperator diff --git a/layout/base/MaskLayerImageCache.h b/layout/base/MaskLayerImageCache.h index 5598c5f54163..ab27f4f7016f 100644 --- a/layout/base/MaskLayerImageCache.h +++ b/layout/base/MaskLayerImageCache.h @@ -50,24 +50,10 @@ public: aPresContext->AppUnitsToGfxUnits(aRRect.mRect.width), aPresContext->AppUnitsToGfxUnits(aRRect.mRect.height)) { - MOZ_COUNT_CTOR(PixelRoundedRect); NS_FOR_CSS_HALF_CORNERS(corner) { mRadii[corner] = aPresContext->AppUnitsToGfxUnits(aRRect.mRadii[corner]); } } - PixelRoundedRect(const PixelRoundedRect& aPRR) - : mRect(aPRR.mRect) - { - MOZ_COUNT_CTOR(PixelRoundedRect); - NS_FOR_CSS_HALF_CORNERS(corner) { - mRadii[corner] = aPRR.mRadii[corner]; - } - } - - ~PixelRoundedRect() - { - MOZ_COUNT_DTOR(PixelRoundedRect); - } // Applies the scale and translate components of aTransform. // It is an error to pass a matrix which does more than just scale @@ -113,9 +99,6 @@ public: gfxRect mRect; // Indices into mRadii are the NS_CORNER_* constants in nsStyleConsts.h gfxFloat mRadii[8]; - - private: - PixelRoundedRect() MOZ_DELETE; }; /** @@ -128,27 +111,14 @@ public: * pointers to a key object (the +1 being from the hashtable entry), but this * invariant may be temporarily broken. */ - struct MaskLayerImageKey + class MaskLayerImageKey { - MaskLayerImageKey(layers::LayersBackend aBackend) + public: + MaskLayerImageKey(const nsTArray& aRoundedClipRects, layers::LayersBackend aBackend) : mBackend(aBackend) , mLayerCount(0) - , mRoundedClipRects() - { - MOZ_COUNT_CTOR(MaskLayerImageKey); - } - MaskLayerImageKey(const MaskLayerImageKey& aKey) - : mBackend(aKey.mBackend) - , mLayerCount(aKey.mLayerCount) - , mRoundedClipRects(aKey.mRoundedClipRects) - { - MOZ_COUNT_CTOR(MaskLayerImageKey); - } - - ~MaskLayerImageKey() - { - MOZ_COUNT_DTOR(MaskLayerImageKey); - } + , mRoundedClipRects(aRoundedClipRects) + {} void AddRef() const { ++mLayerCount; } void Release() const @@ -202,14 +172,11 @@ protected: typedef const MaskLayerImageKey& KeyType; typedef const MaskLayerImageKey* KeyTypePointer; - MaskLayerImageEntry(KeyTypePointer aKey) : mKey(aKey) + MaskLayerImageEntry(KeyTypePointer aKey) : mKey(aKey) {} + MaskLayerImageEntry(const MaskLayerImageEntry& aOther) + : mKey(aOther.mKey.get()) { - MOZ_COUNT_CTOR(MaskLayerImageEntry); - } - MaskLayerImageEntry(const MaskLayerImageEntry& aOther) MOZ_DELETE; - ~MaskLayerImageEntry() - { - MOZ_COUNT_DTOR(MaskLayerImageEntry); + NS_ERROR("ALLOW_MEMMOVE == true, should never be called"); } // KeyEquals(): does this entry match this key? From 1a39148dea89f199e69e729fabbcc92d398cb298 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 7 Aug 2012 20:17:27 +0300 Subject: [PATCH 25/70] Bug 782616 - Don't return nsresult from main() (storage/); r=mak --- storage/test/test_deadlock_detector.cpp | 27 +++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/storage/test/test_deadlock_detector.cpp b/storage/test/test_deadlock_detector.cpp index 31295b0de569..aaa200730d37 100644 --- a/storage/test/test_deadlock_detector.cpp +++ b/storage/test/test_deadlock_detector.cpp @@ -293,13 +293,13 @@ CheckForDeadlock(const char* test, const char* const* findTokens) // Single-threaded sanity tests // Stupidest possible deadlock. -nsresult +int Sanity_Child() { TestMutex m1("dd.sanity.m1"); m1.Lock(); m1.Lock(); - return NS_OK; // not reached + return 0; // not reached } nsresult @@ -321,7 +321,7 @@ Sanity() } // Slightly less stupid deadlock. -nsresult +int Sanity2_Child() { TestMutex m1("dd.sanity2.m1"); @@ -329,7 +329,7 @@ Sanity2_Child() m1.Lock(); m2.Lock(); m1.Lock(); - return NS_OK; // not reached + return 0; // not reached } nsresult @@ -352,7 +352,7 @@ Sanity2() } -nsresult +int Sanity3_Child() { TestMutex m1("dd.sanity3.m1"); @@ -371,7 +371,7 @@ Sanity3_Child() m4.Lock(); m1.Lock(); - return NS_OK; + return 0; } nsresult @@ -395,7 +395,7 @@ Sanity3() } -nsresult +int Sanity4_Child() { mozilla::ReentrantMonitor m1("dd.sanity4.m1"); @@ -403,7 +403,7 @@ Sanity4_Child() m1.Enter(); m2.Lock(); m1.Enter(); - return NS_OK; + return 0; } nsresult @@ -449,7 +449,7 @@ TwoThreads_thread(void* arg) } } -nsresult +int TwoThreads_Child() { ttM1 = new TestMutex("dd.twothreads.m1"); @@ -463,7 +463,7 @@ TwoThreads_Child() PRThread* t2 = spawn(TwoThreads_thread, (void*) 1); PR_JoinThread(t2); - return NS_OK; + return 0; } nsresult @@ -505,7 +505,7 @@ ContentionNoDeadlock_thread(void* arg) } } -nsresult +int ContentionNoDeadlock_Child() { PRThread* threads[3]; @@ -522,7 +522,7 @@ ContentionNoDeadlock_Child() for (uint32_t i = 0; i < ArrayLength(cndMs); ++i) delete cndMs[i]; - return NS_OK; + return 0; } nsresult @@ -574,7 +574,8 @@ main(int argc, char** argv) if (!strcmp("ContentionNoDeadlock", test)) return ContentionNoDeadlock_Child(); - FAIL("unknown child test"); + fail("%s | %s - unknown child test", __FILE__, __FUNCTION__); + return 1; } ScopedXPCOM xpcom("Storage deadlock detector correctness (" __FILE__ ")"); From afd8cc68eb416a1462bc55ec1ab0c36e90c7e533 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 14 Aug 2012 12:10:42 +0300 Subject: [PATCH 26/70] Bug 782594 - No, storing a 32-bit error code in a 16-bit variable is not "somewhat sensible"; r=bz --- uriloader/prefetch/nsPrefetchService.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/uriloader/prefetch/nsPrefetchService.cpp b/uriloader/prefetch/nsPrefetchService.cpp index e704bdd5b29a..0d56ddedc795 100644 --- a/uriloader/prefetch/nsPrefetchService.cpp +++ b/uriloader/prefetch/nsPrefetchService.cpp @@ -835,15 +835,6 @@ nsPrefetchNode::GetStatus(uint16_t *aStatus) uint32_t httpStatus; rv = httpChannel->GetResponseStatus(&httpStatus); if (rv == NS_ERROR_NOT_AVAILABLE) { - // Someone's calling this before we got a response... Check our - // ReadyState. If we're at RECEIVING or LOADED, then this means the - // connection errored before we got any data; return a somewhat - // sensible error code in that case. - if (mState >= nsIDOMLoadStatus::RECEIVING) { - *aStatus = NS_ERROR_NOT_AVAILABLE; - return NS_OK; - } - *aStatus = 0; return NS_OK; } From 91ce311a848aad2bafc7d7e2c9b6122018fa26bc Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 14 Aug 2012 12:10:42 +0300 Subject: [PATCH 27/70] Bug 782616 - Don't treat SetJournalMode's return type as nsresult; r=mak --- toolkit/components/places/Database.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/components/places/Database.cpp b/toolkit/components/places/Database.cpp index 50ee007e687d..208b25811955 100644 --- a/toolkit/components/places/Database.cpp +++ b/toolkit/components/places/Database.cpp @@ -560,7 +560,7 @@ Database::InitSchema(bool* aDatabaseMigrated) // Be sure to set journal mode after page_size. WAL would prevent the change // otherwise. - if (NS_SUCCEEDED(SetJournalMode(mMainConn, JOURNAL_WAL))) { + if (JOURNAL_WAL == SetJournalMode(mMainConn, JOURNAL_WAL)) { // Set the WAL journal size limit. We want it to be small, since in // synchronous = NORMAL mode a crash could cause loss of all the // transactions in the journal. For added safety we will also force From a3af1937ff57d0fb76b78770dec538b4e7376b3c Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 14 Aug 2012 12:10:42 +0300 Subject: [PATCH 28/70] Bug 782594 - Don't use the same variable for nsresult and uint32_t; r=bz --- netwerk/base/public/nsNetUtil.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/netwerk/base/public/nsNetUtil.h b/netwerk/base/public/nsNetUtil.h index cc1599aa5080..bf665cb31a49 100644 --- a/netwerk/base/public/nsNetUtil.h +++ b/netwerk/base/public/nsNetUtil.h @@ -1678,9 +1678,12 @@ NS_SecurityHashURI(nsIURI* aURI) scheme.EqualsLiteral("news")) { nsAutoCString spec; - uint32_t specHash = baseURI->GetSpec(spec); - if (NS_SUCCEEDED(specHash)) + uint32_t specHash; + nsresult res = baseURI->GetSpec(spec); + if (NS_SUCCEEDED(res)) specHash = mozilla::HashString(spec); + else + specHash = static_cast(res); return specHash; } From 869e32586e9179e5a134166fab889c15ed105c68 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 14 Aug 2012 12:10:42 +0300 Subject: [PATCH 29/70] Bug 782616 - Use more appropriate return types than nsresult; r=mak --- toolkit/components/places/History.cpp | 2 +- toolkit/components/places/nsNavHistory.cpp | 2 +- toolkit/components/places/tests/unit/test_async_history_api.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/toolkit/components/places/History.cpp b/toolkit/components/places/History.cpp index b06006e78273..fd9731561d27 100644 --- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -907,7 +907,7 @@ private: mozStorageStatementScoper scoper(stmt); nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("visit_date"), _place.visitTime); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, false); scoper.Abandon(); } diff --git a/toolkit/components/places/nsNavHistory.cpp b/toolkit/components/places/nsNavHistory.cpp index 7e51163f426e..58396e9967dc 100644 --- a/toolkit/components/places/nsNavHistory.cpp +++ b/toolkit/components/places/nsNavHistory.cpp @@ -714,7 +714,7 @@ nsNavHistory::GetNewSessionID() "SELECT session FROM moz_historyvisits " "ORDER BY visit_date DESC " ), getter_AddRefs(selectSession)); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, 0); bool hasSession; if (NS_SUCCEEDED(selectSession->ExecuteStep(&hasSession)) && hasSession) { mLastSessionID = selectSession->AsInt64(0) + 1; diff --git a/toolkit/components/places/tests/unit/test_async_history_api.js b/toolkit/components/places/tests/unit/test_async_history_api.js index 8d4ece027a6d..5a2f2dfd214d 100644 --- a/toolkit/components/places/tests/unit/test_async_history_api.js +++ b/toolkit/components/places/tests/unit/test_async_history_api.js @@ -550,7 +550,7 @@ function test_invalid_sessionId_ignored() new VisitInfo(), ], }; - place.visits[0].sessionId = -1; + place.visits[0].sessionId = 0; do_check_false(gGlobalHistory.isVisited(place.uri)); gHistory.updatePlaces(place, expectHandleResult(function(aPlaceInfo) { From 24e24f56263db8a9f3ee17fbeafc3c7822e72de6 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Fri, 31 Aug 2012 23:05:50 +1200 Subject: [PATCH 30/70] Bug 786620. Fix --enable-profiling build bustage. r=mfinkle --HG-- extra : rebase_source : 427f9f4beb9dd4e1441607f4b967ed0cfb09a6bc --- mobile/android/base/App.java.in | 1 + mobile/android/base/WebApp.java.in | 1 + 2 files changed, 2 insertions(+) diff --git a/mobile/android/base/App.java.in b/mobile/android/base/App.java.in index c2d60dc32aaa..4a82d35a0887 100644 --- a/mobile/android/base/App.java.in +++ b/mobile/android/base/App.java.in @@ -10,6 +10,7 @@ import android.view.MenuItem; import org.mozilla.gecko.BrowserApp; import org.mozilla.gecko.GeckoAppShell; +import org.mozilla.gecko.GeckoEvent; import org.mozilla.gecko.R; public class App extends BrowserApp { diff --git a/mobile/android/base/WebApp.java.in b/mobile/android/base/WebApp.java.in index e4b6a716abbc..72050f64dbe1 100644 --- a/mobile/android/base/WebApp.java.in +++ b/mobile/android/base/WebApp.java.in @@ -20,6 +20,7 @@ import java.net.URL; import org.mozilla.gecko.GeckoApp; import org.mozilla.gecko.GeckoAppShell; +import org.mozilla.gecko.GeckoEvent; import org.mozilla.gecko.WebAppAllocator; import org.mozilla.gecko.Tab; import org.mozilla.gecko.Tabs; From 93553ee043da91d68f04d76b9b036c8d95f285fa Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Mon, 20 Aug 2012 10:25:49 +1200 Subject: [PATCH 31/70] Bug 780847. Fix nsLayoutUtils::IsProperAncestorFrame(CrossDoc) to handle case where aAncestorFrame == aCommonAncestor == aFrame->GetParent(). r=mats --HG-- extra : rebase_source : 9f8d01c7049a701ac5bcf633ee605443b81aec35 --- layout/base/nsLayoutUtils.cpp | 39 +++++++++++------------------------ 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index a665539ad862..61d05f2315f3 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -615,19 +615,9 @@ bool nsLayoutUtils::IsProperAncestorFrameCrossDoc(nsIFrame* aAncestorFrame, nsIFrame* aFrame, nsIFrame* aCommonAncestor) { - if (aFrame == aCommonAncestor) + if (aFrame == aAncestorFrame) return false; - - nsIFrame* parentFrame = GetCrossDocParentFrame(aFrame); - - while (parentFrame != aCommonAncestor) { - if (parentFrame == aAncestorFrame) - return true; - - parentFrame = GetCrossDocParentFrame(parentFrame); - } - - return false; + return IsAncestorFrameCrossDoc(aAncestorFrame, aFrame, aCommonAncestor); } // static @@ -635,9 +625,12 @@ bool nsLayoutUtils::IsAncestorFrameCrossDoc(nsIFrame* aAncestorFrame, nsIFrame* aFrame, nsIFrame* aCommonAncestor) { - if (aFrame == aAncestorFrame) - return true; - return IsProperAncestorFrameCrossDoc(aAncestorFrame, aFrame, aCommonAncestor); + for (nsIFrame* f = aFrame; f != aCommonAncestor; + f = GetCrossDocParentFrame(f)) { + if (f == aAncestorFrame) + return true; + } + return aCommonAncestor == aAncestorFrame; } // static @@ -645,21 +638,13 @@ bool nsLayoutUtils::IsProperAncestorFrame(nsIFrame* aAncestorFrame, nsIFrame* aFrame, nsIFrame* aCommonAncestor) { - if (aFrame == aCommonAncestor) { + if (aFrame == aAncestorFrame) return false; - } - - nsIFrame* parentFrame = aFrame->GetParent(); - - while (parentFrame != aCommonAncestor) { - if (parentFrame == aAncestorFrame) { + for (nsIFrame* f = aFrame; f != aCommonAncestor; f = f->GetParent()) { + if (f == aAncestorFrame) return true; - } - - parentFrame = parentFrame->GetParent(); } - - return false; + return aCommonAncestor == aAncestorFrame; } // static From 99e948a368a7f0b5f739ed923a290af9ee0b8e7d Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 18 Aug 2012 02:12:58 +1200 Subject: [PATCH 32/70] Bug 780847. Add support for checking for event listeners with an nsIAtom* event name. r=smaug --HG-- extra : rebase_source : 4efce91d9a41c39b5431c561474165ab66254e49 --- content/events/src/nsEventListenerManager.cpp | 13 ++++++++++++- content/events/src/nsEventListenerManager.h | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index ea848c8df768..7b7fc0cd1350 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -1005,11 +1005,22 @@ bool nsEventListenerManager::HasListenersFor(const nsAString& aEventName) { nsCOMPtr atom = do_GetAtom(NS_LITERAL_STRING("on") + aEventName); + return HasListenersFor(atom); +} +bool +nsEventListenerManager::HasListenersFor(nsIAtom* aEventNameWithOn) +{ +#ifdef DEBUG + nsAutoString name; + aEventNameWithOn->ToString(name); +#endif + NS_ASSERTION(StringBeginsWith(name, NS_LITERAL_STRING("on")), + "Event name does not start with 'on'"); uint32_t count = mListeners.Length(); for (uint32_t i = 0; i < count; ++i) { nsListenerStruct* ls = &mListeners.ElementAt(i); - if (ls->mTypeAtom == atom) { + if (ls->mTypeAtom == aEventNameWithOn) { return true; } } diff --git a/content/events/src/nsEventListenerManager.h b/content/events/src/nsEventListenerManager.h index f351125196af..e9e56d76f6c4 100644 --- a/content/events/src/nsEventListenerManager.h +++ b/content/events/src/nsEventListenerManager.h @@ -183,6 +183,12 @@ public: */ bool HasListenersFor(const nsAString& aEventName); + /** + * Returns true if there is at least one event listener for aEventNameWithOn. + * Note that aEventNameWithOn must start with "on"! + */ + bool HasListenersFor(nsIAtom* aEventNameWithOn); + /** * Returns true if there is at least one event listener. */ From 1b7000f1041a570d812b9bb4ed55cad100d539c7 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Mon, 20 Aug 2012 12:02:42 +1200 Subject: [PATCH 33/70] Bug 780847. Built-in support for mouse/touch events targeting nodes within a certain radius via heuristics. r=mats,smaug --HG-- extra : rebase_source : 13a350bb6c993e5a23e54657cbe9f22c287036ad --- layout/base/Makefile.in | 1 + layout/base/PositionedEventTargeting.cpp | 274 ++++++++++++++++++ layout/base/PositionedEventTargeting.h | 31 ++ layout/base/nsPresShell.cpp | 20 +- layout/base/tests/Makefile.in | 1 + .../base/tests/test_event_target_radius.html | 177 +++++++++++ modules/libpref/src/init/all.js | 23 ++ 7 files changed, 517 insertions(+), 10 deletions(-) create mode 100644 layout/base/PositionedEventTargeting.cpp create mode 100644 layout/base/PositionedEventTargeting.h create mode 100644 layout/base/tests/test_event_target_radius.html diff --git a/layout/base/Makefile.in b/layout/base/Makefile.in index 734e8a969239..ce6f881e399f 100644 --- a/layout/base/Makefile.in +++ b/layout/base/Makefile.in @@ -88,6 +88,7 @@ CPPSRCS = \ nsStyleChangeList.cpp \ nsStyleSheetService.cpp \ PaintTracker.cpp \ + PositionedEventTargeting.cpp \ StackArena.cpp \ $(NULL) diff --git a/layout/base/PositionedEventTargeting.cpp b/layout/base/PositionedEventTargeting.cpp new file mode 100644 index 000000000000..99cb13fd3d0f --- /dev/null +++ b/layout/base/PositionedEventTargeting.cpp @@ -0,0 +1,274 @@ +/* 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 "PositionedEventTargeting.h" + +#include "mozilla/Preferences.h" +#include "nsGUIEvent.h" +#include "nsLayoutUtils.h" +#include "nsGkAtoms.h" +#include "nsEventListenerManager.h" +#include "nsPrintfCString.h" +#include "mozilla/dom/Element.h" + +namespace mozilla { + +/* + * The basic goal of FindFrameTargetedByInputEvent() is to find a good + * target element that can respond to mouse events. Both mouse events and touch + * events are targeted at this element. Note that even for touch events, we + * check responsiveness to mouse events. We assume Web authors + * designing for touch events will take their own steps to account for + * inaccurate touch events. + * + * IsElementClickable() encapsulates the heuristic that determines whether an + * element is expected to respond to mouse events. An element is deemed + * "clickable" if it has registered listeners for "click", "mousedown" or + * "mouseup", or is on a whitelist of element tags (,