From 0ccb78c213460e4f2331adace034473205d6ed4b Mon Sep 17 00:00:00 2001 From: roytam1 Date: Wed, 8 Nov 2023 16:50:37 +0800 Subject: [PATCH] import changes from `dev' branch of rmottola/Arctic-Fox: - Bug 1212720 - Part 1: Implement Document.getAnimations(). r=heycam, r=smaug (8c3951b318) - Bug 1212720 - Part 2: Tests for document.getAnimations. r=heycam (8e6660abe1) - Bug 1212720 - Part 3: Remove AnimationTimeline.getAnimations. r=heycam, r=smaug (a663e7e79b) - Bug 1212720 - Part 4: Remove all cancelAllAnimationsOnEnd. It is not needed any more. r=bbirtles (8c9b92f2d4) - Bug 1218258 - Fix -Wimplicit-fallthrough warnings in toolkit/components/downloads. r=paolo (1962eee4fc) - Bug 1218258 - Fix -Wshadow warnings in toolkit/components/downloads. r=paolo (6cf1d464bb) - Bug 1212323: P1. Use a 640x360 SPS to test for HW decoding support. r=cpearce (ed67910d9c) - Bug 1212323: P2. Have IsVideoAccelerated return a Promise. r=cpearce (824e543945) - Bug 1240365 - FileReader should use the global scope correctly in ChromeWorkers, r=smaug, r=khuey (bf40380947) - Bug 1239210 - Don't process WebIDL files when not compiling; r=glandium (5a55f23b2e) --- dom/animation/AnimationTimeline.cpp | 42 -------- dom/animation/AnimationTimeline.h | 3 - ...html => file_document-get-animations.html} | 50 +++++----- ...html => test_document-get-animations.html} | 2 +- ...html => file_document-get-animations.html} | 8 +- ...html => test_document-get-animations.html} | 2 +- dom/animation/test/mochitest.ini | 16 +-- dom/animation/test/testcommon.js | 12 --- dom/base/Element.cpp | 9 +- dom/base/Element.h | 2 + dom/base/FileReader.cpp | 32 ++---- dom/base/FileReader.h | 2 +- dom/base/nsDOMWindowUtils.cpp | 35 ++++--- dom/base/nsDocument.cpp | 28 ++++++ dom/base/nsDocument.h | 2 + dom/base/nsIDocument.h | 4 + dom/bindings/Makefile.in | 4 + dom/interfaces/base/nsIDOMWindowUtils.idl | 9 +- dom/media/fmp4/MP4Decoder.cpp | 99 +++++++++++++++---- dom/media/fmp4/MP4Decoder.h | 4 +- dom/webidl/AnimationTimeline.webidl | 1 - dom/webidl/Document.webidl | 2 + .../test/xpcshell/data/worker_fileReader.js | 8 ++ dom/workers/test/xpcshell/test_fileReader.js | 40 ++++++++ dom/workers/test/xpcshell/xpcshell.ini | 2 + .../downloads/ApplicationReputation.cpp | 30 +++--- .../downloads/nsDownloadManager.cpp | 23 +++-- 27 files changed, 280 insertions(+), 191 deletions(-) rename dom/animation/test/css-animations/{file_timeline-get-animations.html => file_document-get-animations.html} (86%) rename dom/animation/test/css-animations/{test_timeline-get-animations.html => test_document-get-animations.html} (86%) rename dom/animation/test/css-transitions/{file_timeline-get-animations.html => file_document-get-animations.html} (83%) rename dom/animation/test/css-transitions/{test_timeline-get-animations.html => test_document-get-animations.html} (86%) create mode 100644 dom/workers/test/xpcshell/data/worker_fileReader.js create mode 100644 dom/workers/test/xpcshell/test_fileReader.js diff --git a/dom/animation/AnimationTimeline.cpp b/dom/animation/AnimationTimeline.cpp index 1628c043f1..643106807c 100644 --- a/dom/animation/AnimationTimeline.cpp +++ b/dom/animation/AnimationTimeline.cpp @@ -34,48 +34,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AnimationTimeline) NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_END -void -AnimationTimeline::GetAnimations(AnimationSequence& aAnimations) -{ - nsCOMPtr window = do_QueryInterface(mWindow); - if (mWindow) { - nsIDocument* doc = window->GetDoc(); - if (doc) { - doc->FlushPendingNotifications(Flush_Style); - } - } - - aAnimations.SetCapacity(mAnimations.Count()); - - for (Animation* animation = mAnimationOrder.getFirst(); animation; - animation = animation->getNext()) { - - // Skip animations which are no longer relevant or which have been - // associated with another timeline. These animations will be removed - // on the next tick. - if (!animation->IsRelevant() || animation->GetTimeline() != this) { - continue; - } - - // Bug 1174575: Until we implement a suitable PseudoElement interface we - // don't have anything to return for the |target| attribute of - // KeyframeEffect(ReadOnly) objects that refer to pseudo-elements. - // Rather than return some half-baked version of these objects (e.g. - // we a null effect attribute) we simply don't provide access to animations - // whose effect refers to a pseudo-element until we can support them - // properly. - Element* target; - nsCSSPseudoElements::Type pseudoType; - animation->GetEffect()->GetTarget(target, pseudoType); - if (pseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) { - aAnimations.AppendElement(animation); - } - } - - // Sort animations by priority - aAnimations.Sort(AnimationPtrComparator>()); -} - void AnimationTimeline::NotifyAnimationUpdated(Animation& aAnimation) { diff --git a/dom/animation/AnimationTimeline.h b/dom/animation/AnimationTimeline.h index 7163d43502..47250ec19a 100644 --- a/dom/animation/AnimationTimeline.h +++ b/dom/animation/AnimationTimeline.h @@ -51,11 +51,8 @@ public: nsIGlobalObject* GetParentObject() const { return mWindow; } - typedef nsTArray> AnimationSequence; - // AnimationTimeline methods virtual Nullable GetCurrentTime() const = 0; - void GetAnimations(AnimationSequence& aAnimations); // Wrapper functions for AnimationTimeline DOM methods when called from // script. diff --git a/dom/animation/test/css-animations/file_timeline-get-animations.html b/dom/animation/test/css-animations/file_document-get-animations.html similarity index 86% rename from dom/animation/test/css-animations/file_timeline-get-animations.html rename to dom/animation/test/css-animations/file_document-get-animations.html index a0357d0e0d..f57c3cb5b2 100644 --- a/dom/animation/test/css-animations/file_timeline-get-animations.html +++ b/dom/animation/test/css-animations/file_document-get-animations.html @@ -24,7 +24,7 @@ 'use strict'; test(function(t) { - assert_equals(document.timeline.getAnimations().length, 0, + assert_equals(document.getAnimations().length, 0, 'getAnimations returns an empty sequence for a document' + ' with no animations'); }, 'getAnimations for non-animated content'); @@ -34,17 +34,17 @@ test(function(t) { // Add an animation div.style.animation = 'animLeft 100s'; - assert_equals(document.timeline.getAnimations().length, 1, + assert_equals(document.getAnimations().length, 1, 'getAnimations returns a running CSS Animation'); // Add another animation div.style.animation = 'animLeft 100s, animTop 100s'; - assert_equals(document.timeline.getAnimations().length, 2, + assert_equals(document.getAnimations().length, 2, 'getAnimations returns two running CSS Animations'); // Remove both div.style.animation = ''; - assert_equals(document.timeline.getAnimations().length, 0, + assert_equals(document.getAnimations().length, 0, 'getAnimations returns no running CSS Animations'); }, 'getAnimations for CSS Animations'); @@ -53,7 +53,7 @@ test(function(t) { div.style.animation = 'animLeft 100s, animTop 100s, animRight 100s, ' + 'animBottom 100s'; - var animations = document.timeline.getAnimations(); + var animations = document.getAnimations(); assert_equals(animations.length, 4, 'getAnimations returns all running CSS Animations'); assert_equals(animations[0].animationName, 'animLeft', @@ -72,7 +72,7 @@ test(function(t) { var div3 = addDiv(t, { style: 'animation: animLeft 100s' }); var div4 = addDiv(t, { style: 'animation: animLeft 100s' }); - var animations = document.timeline.getAnimations(); + var animations = document.getAnimations(); assert_equals(animations.length, 4, 'getAnimations returns all running CSS Animations'); assert_equals(animations[0].effect.target, div1, @@ -95,7 +95,7 @@ test(function(t) { // Which should give: 2, 1, 4, 3 div2.appendChild(div1); div2.appendChild(div4); - animations = document.timeline.getAnimations(); + animations = document.getAnimations(); assert_equals(animations[0].effect.target, div2, 'Order of first animation returned after tree surgery'); assert_equals(animations[1].effect.target, div1, @@ -114,7 +114,7 @@ test(function(t) { var expectedResults = [ [ div1, 'animLeft' ], [ div1, 'animTop' ], [ div2, 'animBottom' ] ]; - var animations = document.timeline.getAnimations(); + var animations = document.getAnimations(); assert_equals(animations.length, expectedResults.length, 'getAnimations returns all running CSS Animations'); animations.forEach(function(anim, i) { @@ -132,7 +132,7 @@ test(function(t) { [ div1, 'animLeft' ], [ div1, 'animRight' ], [ div1, 'animTop' ] ]; - animations = document.timeline.getAnimations(); + animations = document.getAnimations(); assert_equals(animations.length, expectedResults.length, 'getAnimations returns all running CSS Animations after ' + 'making changes'); @@ -145,10 +145,8 @@ test(function(t) { }, 'Order of CSS Animations - across and within elements'); test(function(t) { - cancelAllAnimationsOnEnd(t); - var div = addDiv(t, { style: 'animation: animLeft 100s, animTop 100s' }); - var animLeft = document.timeline.getAnimations()[0]; + var animLeft = document.getAnimations()[0]; assert_equals(animLeft.animationName, 'animLeft', 'Originally, animLeft animation comes first'); @@ -156,7 +154,7 @@ test(function(t) { div.style.animation = 'animTop 100s'; animLeft.play(); - var animations = document.timeline.getAnimations(); + var animations = document.getAnimations(); assert_equals(animations.length, 2, 'getAnimations returns markup-bound and free animations'); assert_equals(animations[0].animationName, 'animTop', @@ -165,18 +163,16 @@ test(function(t) { }, 'Order of CSS Animations - markup-bound vs free animations'); test(function(t) { - cancelAllAnimationsOnEnd(t); - var div = addDiv(t, { style: 'animation: animLeft 100s, animTop 100s' }); - var animLeft = document.timeline.getAnimations()[0]; - var animTop = document.timeline.getAnimations()[1]; + var animLeft = document.getAnimations()[0]; + var animTop = document.getAnimations()[1]; // Disassociate both animations from markup and restart in opposite order div.style.animation = ''; animTop.play(); animLeft.play(); - var animations = document.timeline.getAnimations(); + var animations = document.getAnimations(); assert_equals(animations.length, 2, 'getAnimations returns free animations'); assert_equals(animations[0], animTop, @@ -187,7 +183,7 @@ test(function(t) { // Restarting an animation should have no effect animTop.cancel(); animTop.play(); - assert_equals(document.timeline.getAnimations()[0], animTop, + assert_equals(document.getAnimations()[0], animTop, 'After restarting, the ordering of free animations' + ' does not change'); }, 'Order of CSS Animations - free animations'); @@ -204,7 +200,7 @@ test(function(t) { flushComputedStyle(div); // Although the transition was added later, it should come first in the list - var animations = document.timeline.getAnimations(); + var animations = document.getAnimations(); assert_equals(animations.length, 2, 'Both CSS animations and transitions are returned'); assert_class_string(animations[0], 'CSSTransition', 'Transition comes first'); @@ -214,38 +210,36 @@ test(function(t) { test(function(t) { var div = addDiv(t, { style: 'animation: animLeft 100s forwards' }); div.getAnimations()[0].finish(); - assert_equals(document.timeline.getAnimations().length, 1, + assert_equals(document.getAnimations().length, 1, 'Forwards-filling CSS animations are returned'); }, 'Finished but filling CSS Animations are returned'); test(function(t) { var div = addDiv(t, { style: 'animation: animLeft 100s' }); div.getAnimations()[0].finish(); - assert_equals(document.timeline.getAnimations().length, 0, + assert_equals(document.getAnimations().length, 0, 'Non-filling finished CSS animations are not returned'); }, 'Finished but not filling CSS Animations are not returned'); test(function(t) { var div = addDiv(t, { style: 'animation: animLeft 100s 100s' }); - assert_equals(document.timeline.getAnimations().length, 1, + assert_equals(document.getAnimations().length, 1, 'Yet-to-start CSS animations are returned'); }, 'Yet-to-start CSS Animations are returned'); test(function(t) { var div = addDiv(t, { style: 'animation: animLeft 100s' }); div.getAnimations()[0].cancel(); - assert_equals(document.timeline.getAnimations().length, 0, + assert_equals(document.getAnimations().length, 0, 'CSS animations cancelled by the API are not returned'); }, 'CSS Animations cancelled via the API are not returned'); test(function(t) { - cancelAllAnimationsOnEnd(t); - var div = addDiv(t, { style: 'animation: animLeft 100s' }); var anim = div.getAnimations()[0]; anim.cancel(); anim.play(); - assert_equals(document.timeline.getAnimations().length, 1, + assert_equals(document.getAnimations().length, 1, 'CSS animations cancelled and restarted by the API are ' + 'returned'); }, 'CSS Animations cancelled and restarted via the API are returned'); @@ -256,7 +250,7 @@ test(function(t) { // but we haven't implemented a PseudoElement interface to use as // animation's target (bug 1174575) so we simply don't return these animations // until we can support them properly. - assert_equals(document.timeline.getAnimations().length, 0, + assert_equals(document.getAnimations().length, 0, 'CSS animations on pseudo elements are not returned'); }, 'CSS Animations targetting pseudo-elements are not returned'); diff --git a/dom/animation/test/css-animations/test_timeline-get-animations.html b/dom/animation/test/css-animations/test_document-get-animations.html similarity index 86% rename from dom/animation/test/css-animations/test_timeline-get-animations.html rename to dom/animation/test/css-animations/test_document-get-animations.html index 70c15494ec..dc964e62c8 100644 --- a/dom/animation/test/css-animations/test_timeline-get-animations.html +++ b/dom/animation/test/css-animations/test_document-get-animations.html @@ -9,7 +9,7 @@ setup({explicit_done: true}); SpecialPowers.pushPrefEnv( { "set": [["dom.animations-api.core.enabled", true]]}, function() { - window.open("file_timeline-get-animations.html"); + window.open("file_document-get-animations.html"); }); diff --git a/dom/animation/test/css-transitions/file_timeline-get-animations.html b/dom/animation/test/css-transitions/file_document-get-animations.html similarity index 83% rename from dom/animation/test/css-transitions/file_timeline-get-animations.html rename to dom/animation/test/css-transitions/file_document-get-animations.html index d4489a630f..d49b2dd5d5 100644 --- a/dom/animation/test/css-transitions/file_timeline-get-animations.html +++ b/dom/animation/test/css-transitions/file_document-get-animations.html @@ -6,7 +6,7 @@ 'use strict'; test(function(t) { - assert_equals(document.timeline.getAnimations().length, 0, + assert_equals(document.getAnimations().length, 0, 'getAnimations returns an empty sequence for a document' + ' with no animations'); }, 'getAnimations for non-animated content'); @@ -22,12 +22,12 @@ test(function(t) { div.style.transition = 'all 100s'; div.style.left = '100px'; div.style.top = '100px'; - assert_equals(document.timeline.getAnimations().length, 2, + assert_equals(document.getAnimations().length, 2, 'getAnimations returns two running CSS Transitions'); // Remove both div.style.transitionProperty = 'none'; - assert_equals(document.timeline.getAnimations().length, 0, + assert_equals(document.getAnimations().length, 0, 'getAnimations returns no running CSS Transitions'); }, 'getAnimations for CSS Transitions'); @@ -39,7 +39,7 @@ async_test(function(t) { var animations = div.getAnimations(); assert_equals(animations.length, 1, 'Got transition'); animations[0].finished.then(t.step_func(function() { - assert_equals(document.timeline.getAnimations().length, 0, + assert_equals(document.getAnimations().length, 0, 'No animations returned'); t.done(); })); diff --git a/dom/animation/test/css-transitions/test_timeline-get-animations.html b/dom/animation/test/css-transitions/test_document-get-animations.html similarity index 86% rename from dom/animation/test/css-transitions/test_timeline-get-animations.html rename to dom/animation/test/css-transitions/test_document-get-animations.html index 70c15494ec..dc964e62c8 100644 --- a/dom/animation/test/css-transitions/test_timeline-get-animations.html +++ b/dom/animation/test/css-transitions/test_document-get-animations.html @@ -9,7 +9,7 @@ setup({explicit_done: true}); SpecialPowers.pushPrefEnv( { "set": [["dom.animations-api.core.enabled", true]]}, function() { - window.open("file_timeline-get-animations.html"); + window.open("file_document-get-animations.html"); }); diff --git a/dom/animation/test/mochitest.ini b/dom/animation/test/mochitest.ini index a447ff855e..dd64f9321c 100644 --- a/dom/animation/test/mochitest.ini +++ b/dom/animation/test/mochitest.ini @@ -32,15 +32,15 @@ support-files = css-animations/file_animation-reverse.html support-files = css-animations/file_animation-starttime.html [css-animations/test_cssanimation-animationname.html] support-files = css-animations/file_cssanimation-animationname.html -[css-animations/test_keyframeeffect-getframes.html] -support-files = css-animations/file_keyframeeffect-getframes.html +[css-animations/test_document-get-animations.html] +support-files = css-animations/file_document-get-animations.html [css-animations/test_effect-target.html] support-files = css-animations/file_effect-target.html [css-animations/test_element-get-animations.html] skip-if = buildapp == 'mulet' support-files = css-animations/file_element-get-animations.html -[css-animations/test_timeline-get-animations.html] -support-files = css-animations/file_timeline-get-animations.html +[css-animations/test_keyframeeffect-getframes.html] +support-files = css-animations/file_keyframeeffect-getframes.html [css-transitions/test_animation-cancel.html] support-files = css-transitions/file_animation-cancel.html [css-transitions/test_animation-computed-timing.html] @@ -57,15 +57,15 @@ support-files = css-transitions/file_animation-ready.html support-files = css-transitions/file_animation-starttime.html [css-transitions/test_csstransition-transitionproperty.html] support-files = css-transitions/file_csstransition-transitionproperty.html -[css-transitions/test_keyframeeffect-getframes.html] -support-files = css-transitions/file_keyframeeffect-getframes.html +[css-transitions/test_document-get-animations.html] +support-files = css-transitions/file_document-get-animations.html [css-transitions/test_effect-target.html] support-files = css-transitions/file_effect-target.html [css-transitions/test_element-get-animations.html] skip-if = buildapp == 'mulet' support-files = css-transitions/file_element-get-animations.html -[css-transitions/test_timeline-get-animations.html] -support-files = css-transitions/file_timeline-get-animations.html +[css-transitions/test_keyframeeffect-getframes.html] +support-files = css-transitions/file_keyframeeffect-getframes.html [document-timeline/test_document-timeline.html] support-files = document-timeline/file_document-timeline.html [document-timeline/test_request_animation_frame.html] diff --git a/dom/animation/test/testcommon.js b/dom/animation/test/testcommon.js index 54add06692..af537a441f 100644 --- a/dom/animation/test/testcommon.js +++ b/dom/animation/test/testcommon.js @@ -17,18 +17,6 @@ function addDiv(t) { return div; } -/** - * Some tests cause animations to continue to exist even after their target - * element has been removed from the document tree. To ensure that these - * animations do not impact other tests we should cancel them when the test - * is complete. - */ -function cancelAllAnimationsOnEnd(t) { - t.add_cleanup(function() { - document.timeline.getAnimations().forEach(animation => animation.cancel()); - }); -} - /** * Promise wrapper for requestAnimationFrame. */ diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 0ac957ead0..8cca2d5294 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -3378,6 +3378,13 @@ Element::GetAnimations(nsTArray>& aAnimations) doc->FlushPendingNotifications(Flush_Style); } + GetAnimationsUnsorted(aAnimations); + aAnimations.Sort(AnimationPtrComparator>()); +} + +void +Element::GetAnimationsUnsorted(nsTArray>& aAnimations) +{ EffectSet* effects = EffectSet::GetEffectSet(this, nsCSSPseudoElements::ePseudo_NotPseudoElement); if (!effects) { @@ -3395,8 +3402,6 @@ Element::GetAnimations(nsTArray>& aAnimations) "effect set"); aAnimations.AppendElement(animation); } - - aAnimations.Sort(AnimationPtrComparator>()); } NS_IMETHODIMP diff --git a/dom/base/Element.h b/dom/base/Element.h index 084fc6076b..ca056b8da9 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -852,7 +852,9 @@ public: { } + // Note: GetAnimations will flush style while GetAnimationsUnsorted won't. void GetAnimations(nsTArray>& aAnimations); + void GetAnimationsUnsorted(nsTArray>& aAnimations); NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML); virtual void SetInnerHTML(const nsAString& aInnerHTML, ErrorResult& aError); diff --git a/dom/base/FileReader.cpp b/dom/base/FileReader.cpp index 629b14f8e7..e6c255ee49 100644 --- a/dom/base/FileReader.cpp +++ b/dom/base/FileReader.cpp @@ -98,9 +98,9 @@ FileReader::RootResultArrayBuffer() //FileReader constructors/initializers -FileReader::FileReader(nsPIDOMWindow* aWindow, +FileReader::FileReader(nsIGlobalObject* aGlobal, WorkerPrivate* aWorkerPrivate) - : DOMEventTargetHelper(aWindow) + : DOMEventTargetHelper(aGlobal) , mFileData(nullptr) , mDataLen(0) , mDataFormat(FILE_AS_BINARY) @@ -114,8 +114,8 @@ FileReader::FileReader(nsPIDOMWindow* aWindow, , mBusyCount(0) , mWorkerPrivate(aWorkerPrivate) { - MOZ_ASSERT_IF(!NS_IsMainThread(), mWorkerPrivate && !aWindow); - MOZ_ASSERT_IF(NS_IsMainThread(), !mWorkerPrivate); + MOZ_ASSERT(aGlobal); + MOZ_ASSERT(NS_IsMainThread() == !mWorkerPrivate); SetDOMStringToNull(mResult); } @@ -128,8 +128,7 @@ FileReader::~FileReader() /* static */ already_AddRefed FileReader::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) { - // The owner can be null when this object is used by chrome code. - nsCOMPtr owner = do_QueryInterface(aGlobal.GetAsSupports()); + nsCOMPtr global = do_QueryInterface(aGlobal.GetAsSupports()); WorkerPrivate* workerPrivate = nullptr; if (!NS_IsMainThread()) { @@ -138,14 +137,7 @@ FileReader::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) MOZ_ASSERT(workerPrivate); } - RefPtr fileReader = new FileReader(owner, workerPrivate); - - if (!owner && nsContentUtils::ThreadsafeIsCallerChrome()) { - // Instead of grabbing some random global from the context stack, - // let's use the default one (junk scope) for now. - // We should move away from this Init... - fileReader->BindToOwner(xpc::NativeGlobal(xpc::PrivilegedJunkScope())); - } + RefPtr fileReader = new FileReader(global, workerPrivate); return fileReader.forget(); } @@ -242,17 +234,7 @@ FileReader::DoOnLoadEnd(nsresult aStatus, switch (mDataFormat) { case FILE_AS_ARRAYBUFFER: { AutoJSAPI jsapi; - nsCOMPtr globalObject; - - if (NS_IsMainThread()) { - globalObject = do_QueryInterface(GetParentObject()); - } else { - MOZ_ASSERT(mWorkerPrivate); - MOZ_ASSERT(mBusyCount); - globalObject = mWorkerPrivate->GlobalScope(); - } - - if (!globalObject || !jsapi.Init(globalObject)) { + if (!jsapi.Init(GetParentObject())) { FreeFileData(); return NS_ERROR_FAILURE; } diff --git a/dom/base/FileReader.h b/dom/base/FileReader.h index 797dac67b8..af187dddb5 100644 --- a/dom/base/FileReader.h +++ b/dom/base/FileReader.h @@ -46,7 +46,7 @@ class FileReader final : public DOMEventTargetHelper, friend class FileReaderDecreaseBusyCounter; public: - FileReader(nsPIDOMWindow* aWindow, + FileReader(nsIGlobalObject* aGlobal, workers::WorkerPrivate* aWorkerPrivate); NS_DECL_ISUPPORTS_INHERITED diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index f7059ce97f..83da1c102c 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -107,6 +107,7 @@ #include "HTMLImageElement.h" #include "mozilla/css/ImageLoader.h" #include "mozilla/layers/APZCTreeManager.h" // for layers::ZoomToRectBehavior +#include "mozilla/dom/Promise.h" #ifdef XP_WIN #undef GetClassName @@ -2269,28 +2270,30 @@ nsDOMWindowUtils::GetLayerManagerRemote(bool* retval) } NS_IMETHODIMP -nsDOMWindowUtils::GetSupportsHardwareH264Decoding(nsAString& aRetval) +nsDOMWindowUtils::GetSupportsHardwareH264Decoding(JS::MutableHandle aPromise) { - MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome()); + nsCOMPtr window = do_QueryReferent(mWindow); + NS_ENSURE_STATE(window); + nsCOMPtr parentObject = do_QueryInterface(window); + NS_ENSURE_STATE(parentObject); #ifdef MOZ_FMP4 nsCOMPtr widget = GetWidget(); - if (!widget) - return NS_ERROR_FAILURE; - + NS_ENSURE_STATE(widget); LayerManager *mgr = widget->GetLayerManager(); - if (!mgr) - return NS_ERROR_FAILURE; - - nsCString failureReason; - if (MP4Decoder::IsVideoAccelerated(mgr->GetCompositorBackendType(), failureReason)) { - aRetval.AssignLiteral("Yes"); - } else { - aRetval.AssignLiteral("No; "); - AppendUTF8toUTF16(failureReason, aRetval); - } + NS_ENSURE_STATE(mgr); + RefPtr promise = + MP4Decoder::IsVideoAccelerated(mgr->GetCompositorBackendType(), parentObject); + NS_ENSURE_STATE(promise); + aPromise.setObject(*promise->GetWrapper()); #else - aRetval.AssignLiteral("No; Compiled without MP4 support."); + ErrorResult rv; + RefPtr promise = Promise::Create(parentObject, rv); + if (rv.Failed()) { + return rv.StealNSResult(); + } + promise.MaybeResolve(NS_LITERAL_STRING("No; Compiled without MP4 support.")); + aPromise.setObject(*promise->GetWrapper()); #endif return NS_OK; } diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 52777001c3..f8baf1c067 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -10,10 +10,12 @@ #include "nsDocument.h" #include "nsIDocumentInlines.h" +#include "mozilla/AnimationComparator.h" #include "mozilla/ArrayUtils.h" #include "mozilla/AutoRestore.h" #include "mozilla/BinarySearch.h" #include "mozilla/DebugOnly.h" +#include "mozilla/EffectSet.h" #include "mozilla/IntegerRange.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Likely.h" @@ -3156,6 +3158,32 @@ nsDocument::Timeline() return mDocumentTimeline; } +void +nsDocument::GetAnimations(nsTArray>& aAnimations) +{ + FlushPendingNotifications(Flush_Style); + + // Bug 1174575: Until we implement a suitable PseudoElement interface we + // don't have anything to return for the |target| attribute of + // KeyframeEffect(ReadOnly) objects that refer to pseudo-elements. + // Rather than return some half-baked version of these objects (e.g. + // we a null effect attribute) we simply don't provide access to animations + // whose effect refers to a pseudo-element until we can support them + // properly. + for (nsIContent* node = nsINode::GetFirstChild(); + node; + node = node->GetNextNode(this)) { + if (!node->IsElement()) { + continue; + } + + node->AsElement()->GetAnimationsUnsorted(aAnimations); + } + + // Sort animations by priority + aAnimations.Sort(AnimationPtrComparator>()); +} + /* Return true if the document is in the focused top-level window, and is an * ancestor of the focused DOMWindow. */ NS_IMETHODIMP diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h index 6339e07602..1ddf12757e 100644 --- a/dom/base/nsDocument.h +++ b/dom/base/nsDocument.h @@ -759,6 +759,8 @@ public: static bool IsWebAnimationsEnabled(JSContext* aCx, JSObject* aObject); virtual mozilla::dom::DocumentTimeline* Timeline() override; + virtual void GetAnimations( + nsTArray>& aAnimations) override; virtual nsresult SetSubDocumentFor(Element* aContent, nsIDocument* aSubDoc) override; diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h index f3fc673b09..db824a1ee7 100644 --- a/dom/base/nsIDocument.h +++ b/dom/base/nsIDocument.h @@ -104,6 +104,7 @@ class Rule; } // namespace css namespace dom { +class Animation; class AnonymousContent; class Attr; class BoxObject; @@ -2201,6 +2202,9 @@ public: virtual mozilla::dom::DocumentTimeline* Timeline() = 0; + virtual void GetAnimations( + nsTArray>& aAnimations) = 0; + nsresult ScheduleFrameRequestCallback(mozilla::dom::FrameRequestCallback& aCallback, int32_t *aHandle); void CancelFrameRequestCallback(int32_t aHandle); diff --git a/dom/bindings/Makefile.in b/dom/bindings/Makefile.in index 28e1d39f3e..dc114e3041 100644 --- a/dom/bindings/Makefile.in +++ b/dom/bindings/Makefile.in @@ -4,6 +4,8 @@ webidl_base := $(topsrcdir)/dom/webidl +ifdef COMPILE_ENVIRONMENT + # Generated by moz.build include webidlsrcs.mk @@ -55,6 +57,8 @@ codegen.pp: $(codegen_dependencies) compiletests: $(call SUBMAKE,libs,test) +endif + GARBAGE += \ codegen.pp \ codegen.json \ diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl index 05ec8eb429..2a5858cab1 100644 --- a/dom/interfaces/base/nsIDOMWindowUtils.idl +++ b/dom/interfaces/base/nsIDOMWindowUtils.idl @@ -49,7 +49,7 @@ interface nsIJSRAIIHelper; interface nsIContentPermissionRequest; interface nsIObserver; -[scriptable, uuid(ca6a458c-82e7-4979-886e-6d214eac6f0b)] +[scriptable, uuid(46b44e33-13c2-4eb3-bf80-76a4e0857ccc)] interface nsIDOMWindowUtils : nsISupports { /** @@ -1327,11 +1327,12 @@ interface nsIDOMWindowUtils : nsISupports { readonly attribute boolean layerManagerRemote; /** - * True if we can initialize a hardware-backed h264 decoder for a simple - * test video, does not mean that all h264 video decoding will be done + * Returns a Promise that will be resolved with a string once the capabilities + * of the h264 decoder have been determined. + * Success does not mean that all h264 video decoding will be done * in hardware. */ - readonly attribute AString supportsHardwareH264Decoding; + readonly attribute jsval supportsHardwareH264Decoding; /** * Record (and return) frame-intervals for frames which were presented diff --git a/dom/media/fmp4/MP4Decoder.cpp b/dom/media/fmp4/MP4Decoder.cpp index 0b414afc29..c89c47dff3 100644 --- a/dom/media/fmp4/MP4Decoder.cpp +++ b/dom/media/fmp4/MP4Decoder.cpp @@ -188,23 +188,46 @@ MP4Decoder::IsEnabled() return Preferences::GetBool("media.mp4.enabled"); } +// sTestH264ExtraData represents the content of the avcC atom found in +// an AVC1 h264 video. It contains the H264 SPS and PPS NAL. +// the structure of the avcC atom is as follow: +// write(0x1); // version, always 1 +// write(sps[0].data[1]); // profile +// write(sps[0].data[2]); // compatibility +// write(sps[0].data[3]); // level +// write(0xFC | 3); // reserved (6 bits), NULA length size - 1 (2 bits) +// write(0xE0 | 1); // reserved (3 bits), num of SPS (5 bits) +// write_word(sps[0].size); // 2 bytes for length of SPS +// for(size_t i=0 ; i < sps[0].size ; ++i) +// write(sps[0].data[i]); // data of SPS +// write(&b, pps.size()); // num of PPS +// for(size_t i=0 ; i < pps.size() ; ++i) { +// write_word(pps[i].size); // 2 bytes for length of PPS +// for(size_t j=0 ; j < pps[i].size ; ++j) +// write(pps[i].data[j]); // data of PPS +// } +// } +// here we have a h264 Baseline, 640x360 +// We use a 640x360 extradata, as some video framework (Apple VT) will never +// attempt to use hardware decoding for small videos. static const uint8_t sTestH264ExtraData[] = { - 0x01, 0x64, 0x00, 0x0a, 0xff, 0xe1, 0x00, 0x17, 0x67, 0x64, - 0x00, 0x0a, 0xac, 0xd9, 0x44, 0x26, 0x84, 0x00, 0x00, 0x03, - 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xc8, 0x3c, 0x48, 0x96, - 0x58, 0x01, 0x00, 0x06, 0x68, 0xeb, 0xe3, 0xcb, 0x22, 0xc0 + 0x01, 0x42, 0xc0, 0x1e, 0xff, 0xe1, 0x00, 0x17, 0x67, 0x42, + 0xc0, 0x1e, 0xbb, 0x40, 0x50, 0x17, 0xfc, 0xb8, 0x08, 0x80, + 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b, 0xb5, 0x07, 0x8b, 0x17, + 0x50, 0x01, 0x00, 0x04, 0x68, 0xce, 0x32, 0xc8 }; static already_AddRefed CreateTestH264Decoder(layers::LayersBackend aBackend, - VideoInfo& aConfig) + VideoInfo& aConfig, + FlushableTaskQueue* aTaskQueue) { aConfig.mMimeType = "video/avc"; aConfig.mId = 1; aConfig.mDuration = 40000; aConfig.mMediaTime = 0; - aConfig.mDisplay = nsIntSize(64, 64); - aConfig.mImage = nsIntRect(0, 0, 64, 64); + aConfig.mDisplay = nsIntSize(640, 360); + aConfig.mImage = nsIntRect(0, 0, 640, 360); aConfig.mExtraData = new MediaByteBuffer(); aConfig.mExtraData->AppendElements(sTestH264ExtraData, MOZ_ARRAY_LENGTH(sTestH264ExtraData)); @@ -213,23 +236,63 @@ CreateTestH264Decoder(layers::LayersBackend aBackend, RefPtr platform = new PDMFactory(); RefPtr decoder( - platform->CreateDecoder(aConfig, nullptr, nullptr, aBackend, nullptr)); + platform->CreateDecoder(aConfig, aTaskQueue, nullptr, aBackend, nullptr)); return decoder.forget(); } -/* static */ bool -MP4Decoder::IsVideoAccelerated(layers::LayersBackend aBackend, nsACString& aFailureReason) +/* static */ already_AddRefed +MP4Decoder::IsVideoAccelerated(layers::LayersBackend aBackend, nsIGlobalObject* aParent) { - VideoInfo config; - RefPtr decoder(CreateTestH264Decoder(aBackend, config)); - if (!decoder) { - aFailureReason.AssignLiteral("Failed to create H264 decoder"); - return false; + MOZ_ASSERT(NS_IsMainThread()); + + ErrorResult rv; + RefPtr promise; + promise = dom::Promise::Create(aParent, rv); + if (rv.Failed()) { + rv.SuppressException(); + return nullptr; } - bool result = decoder->IsHardwareAccelerated(aFailureReason); - decoder->Shutdown(); - return result; + + RefPtr taskQueue = + new FlushableTaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER)); + VideoInfo config; + RefPtr decoder(CreateTestH264Decoder(aBackend, config, taskQueue)); + if (!decoder) { + taskQueue->BeginShutdown(); + taskQueue->AwaitShutdownAndIdle(); + promise->MaybeResolve(NS_LITERAL_STRING("No; Failed to create H264 decoder")); + return promise.forget(); + } + + decoder->Init() + ->Then(AbstractThread::MainThread(), __func__, + [promise, decoder, taskQueue] (TrackInfo::TrackType aTrack) { + nsCString failureReason; + bool ok = decoder->IsHardwareAccelerated(failureReason); + nsAutoString result; + if (ok) { + result.AssignLiteral("Yes"); + } else { + result.AssignLiteral("No"); + if (failureReason.Length()) { + result.AppendLiteral("; "); + AppendUTF8toUTF16(failureReason, result); + } + } + decoder->Shutdown(); + taskQueue->BeginShutdown(); + taskQueue->AwaitShutdownAndIdle(); + promise->MaybeResolve(result); + }, + [promise, decoder, taskQueue] (MediaDataDecoder::DecoderFailureReason aResult) { + decoder->Shutdown(); + taskQueue->BeginShutdown(); + taskQueue->AwaitShutdownAndIdle(); + promise->MaybeResolve(NS_LITERAL_STRING("No; Failed to initialize H264 decoder")); + }); + + return promise.forget(); } void diff --git a/dom/media/fmp4/MP4Decoder.h b/dom/media/fmp4/MP4Decoder.h index 62578ed234..d99eb8e976 100644 --- a/dom/media/fmp4/MP4Decoder.h +++ b/dom/media/fmp4/MP4Decoder.h @@ -8,6 +8,7 @@ #include "MediaDecoder.h" #include "MediaFormatReader.h" +#include "mozilla/dom/Promise.h" namespace mozilla { @@ -38,7 +39,8 @@ public: // Returns true if the MP4 backend is preffed on. static bool IsEnabled(); - static bool IsVideoAccelerated(layers::LayersBackend aBackend, nsACString& aReason); + static already_AddRefed + IsVideoAccelerated(layers::LayersBackend aBackend, nsIGlobalObject* aParent); void GetMozDebugReaderData(nsAString& aString) override; diff --git a/dom/webidl/AnimationTimeline.webidl b/dom/webidl/AnimationTimeline.webidl index 97b4767f9d..fe3d0fb49a 100644 --- a/dom/webidl/AnimationTimeline.webidl +++ b/dom/webidl/AnimationTimeline.webidl @@ -14,5 +14,4 @@ interface AnimationTimeline { [BinaryName="currentTimeAsDouble"] readonly attribute double? currentTime; - sequence getAnimations (); }; diff --git a/dom/webidl/Document.webidl b/dom/webidl/Document.webidl index 4a22e072ea..43a4f7fc26 100644 --- a/dom/webidl/Document.webidl +++ b/dom/webidl/Document.webidl @@ -310,6 +310,8 @@ partial interface Document { partial interface Document { [Func="nsDocument::IsWebAnimationsEnabled"] readonly attribute DocumentTimeline timeline; + [Func="nsDocument::IsWebAnimationsEnabled"] + sequence getAnimations(); }; // Mozilla extensions of various sorts diff --git a/dom/workers/test/xpcshell/data/worker_fileReader.js b/dom/workers/test/xpcshell/data/worker_fileReader.js new file mode 100644 index 0000000000..b27366d17b --- /dev/null +++ b/dom/workers/test/xpcshell/data/worker_fileReader.js @@ -0,0 +1,8 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + + +self.onmessage = function(msg) { + var fr = new FileReader(); + self.postMessage("OK"); +}; diff --git a/dom/workers/test/xpcshell/test_fileReader.js b/dom/workers/test/xpcshell/test_fileReader.js new file mode 100644 index 0000000000..0e283fbe01 --- /dev/null +++ b/dom/workers/test/xpcshell/test_fileReader.js @@ -0,0 +1,40 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +Components.utils.import("resource://gre/modules/Promise.jsm"); + +// Worker must be loaded from a chrome:// uri, not a file:// +// uri, so we first need to load it. +var WORKER_SOURCE_URI = "chrome://workers/content/worker_fileReader.js"; +do_load_manifest("data/chrome.manifest"); + +function run_test() { + run_next_test(); +} + +function talk_with_worker(worker) { + let deferred = Promise.defer(); + worker.onmessage = function(event) { + let success = true; + if (event.data == "OK") { + deferred.resolve(); + } else { + success = false; + deferred.reject(event); + } + do_check_true(success); + worker.terminate(); + }; + worker.onerror = function(event) { + let error = new Error(event.message, event.filename, event.lineno); + worker.terminate(); + deferred.reject(error); + }; + worker.postMessage("START"); + return deferred.promise; +} + + +add_task(function test_chrome_worker() { + return talk_with_worker(new ChromeWorker(WORKER_SOURCE_URI)); +}); diff --git a/dom/workers/test/xpcshell/xpcshell.ini b/dom/workers/test/xpcshell/xpcshell.ini index f1437f9ac7..698fca76ee 100644 --- a/dom/workers/test/xpcshell/xpcshell.ini +++ b/dom/workers/test/xpcshell/xpcshell.ini @@ -4,6 +4,8 @@ tail = skip-if = toolkit == 'android' || toolkit == 'gonk' support-files = data/worker.js + data/worker_fileReader.js data/chrome.manifest [test_workers.js] +[test_fileReader.js] diff --git a/toolkit/components/downloads/ApplicationReputation.cpp b/toolkit/components/downloads/ApplicationReputation.cpp index 8f12ed594c..f03eb8a35c 100644 --- a/toolkit/components/downloads/ApplicationReputation.cpp +++ b/toolkit/components/downloads/ApplicationReputation.cpp @@ -593,7 +593,7 @@ PendingLookup::GenerateWhitelistStringsForChain( aChain.element(i).certificate().size(), getter_AddRefs(issuer)); NS_ENSURE_SUCCESS(rv, rv); - nsresult rv = GenerateWhitelistStringsForPair(signer, issuer); + rv = GenerateWhitelistStringsForPair(signer, issuer); NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; @@ -703,24 +703,24 @@ PendingLookup::DoLookupInternal() nsresult rv = mQuery->GetSourceURI(getter_AddRefs(uri)); NS_ENSURE_SUCCESS(rv, rv); - nsCString spec; - rv = GetStrippedSpec(uri, spec); + nsCString sourceSpec; + rv = GetStrippedSpec(uri, sourceSpec); NS_ENSURE_SUCCESS(rv, rv); - mAnylistSpecs.AppendElement(spec); + mAnylistSpecs.AppendElement(sourceSpec); ClientDownloadRequest_Resource* resource = mRequest.add_resources(); - resource->set_url(spec.get()); + resource->set_url(sourceSpec.get()); resource->set_type(ClientDownloadRequest::DOWNLOAD_URL); nsCOMPtr referrer = nullptr; rv = mQuery->GetReferrerURI(getter_AddRefs(referrer)); if (referrer) { - nsCString spec; - rv = GetStrippedSpec(referrer, spec); + nsCString referrerSpec; + rv = GetStrippedSpec(referrer, referrerSpec); NS_ENSURE_SUCCESS(rv, rv); - mAnylistSpecs.AppendElement(spec); - resource->set_referrer(spec.get()); + mAnylistSpecs.AppendElement(referrerSpec); + resource->set_referrer(referrerSpec.get()); } nsCOMPtr redirects; rv = mQuery->GetRedirects(getter_AddRefs(redirects)); @@ -787,11 +787,11 @@ PendingLookup::ParseCertificates(nsIArray* aSigArray) NS_ENSURE_SUCCESS(rv, rv); while (hasMoreChains) { - nsCOMPtr supports; - rv = chains->GetNext(getter_AddRefs(supports)); + nsCOMPtr chainSupports; + rv = chains->GetNext(getter_AddRefs(chainSupports)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr certList = do_QueryInterface(supports, &rv); + nsCOMPtr certList = do_QueryInterface(chainSupports, &rv); NS_ENSURE_SUCCESS(rv, rv); safe_browsing::ClientDownloadRequest_CertificateChain* certChain = @@ -804,11 +804,11 @@ PendingLookup::ParseCertificates(nsIArray* aSigArray) bool hasMoreCerts = false; rv = chainElt->HasMoreElements(&hasMoreCerts); while (hasMoreCerts) { - nsCOMPtr supports; - rv = chainElt->GetNext(getter_AddRefs(supports)); + nsCOMPtr certSupports; + rv = chainElt->GetNext(getter_AddRefs(certSupports)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr cert = do_QueryInterface(supports, &rv); + nsCOMPtr cert = do_QueryInterface(certSupports, &rv); NS_ENSURE_SUCCESS(rv, rv); uint8_t* data = nullptr; diff --git a/toolkit/components/downloads/nsDownloadManager.cpp b/toolkit/components/downloads/nsDownloadManager.cpp index 605eaea99c..de62c84cf4 100644 --- a/toolkit/components/downloads/nsDownloadManager.cpp +++ b/toolkit/components/downloads/nsDownloadManager.cpp @@ -494,6 +494,7 @@ nsDownloadManager::InitFileDB() NS_ENSURE_SUCCESS(rv, rv); } // Fallthrough to the next upgrade + MOZ_FALLTHROUGH; case 2: // Add referrer column to the database { @@ -508,6 +509,7 @@ nsDownloadManager::InitFileDB() NS_ENSURE_SUCCESS(rv, rv); } // Fallthrough to the next upgrade + MOZ_FALLTHROUGH; case 3: // This version adds a column to the database (entityID) { @@ -522,6 +524,7 @@ nsDownloadManager::InitFileDB() NS_ENSURE_SUCCESS(rv, rv); } // Fallthrough to the next upgrade + MOZ_FALLTHROUGH; case 4: // This version adds a column to the database (tempPath) { @@ -536,6 +539,7 @@ nsDownloadManager::InitFileDB() NS_ENSURE_SUCCESS(rv, rv); } // Fallthrough to the next upgrade + MOZ_FALLTHROUGH; case 5: // This version adds two columns for tracking transfer progress { @@ -555,6 +559,7 @@ nsDownloadManager::InitFileDB() NS_ENSURE_SUCCESS(rv, rv); } // Fallthrough to the next upgrade + MOZ_FALLTHROUGH; case 6: // This version adds three columns to DB (MIME type related info) { @@ -579,6 +584,7 @@ nsDownloadManager::InitFileDB() NS_ENSURE_SUCCESS(rv, rv); } // Fallthrough to next upgrade + MOZ_FALLTHROUGH; case 7: // This version adds a column to remember to auto-resume downloads { @@ -593,6 +599,7 @@ nsDownloadManager::InitFileDB() NS_ENSURE_SUCCESS(rv, rv); } // Fallthrough to the next upgrade + MOZ_FALLTHROUGH; // Warning: schema versions >=8 must take into account that they can // be operating on schemas from unknown, future versions that have @@ -627,6 +634,7 @@ nsDownloadManager::InitFileDB() // Extra sanity checking for developers #ifndef DEBUG + MOZ_FALLTHROUGH; case DM_SCHEMA_VERSION: #endif break; @@ -643,6 +651,7 @@ nsDownloadManager::InitFileDB() NS_ENSURE_SUCCESS(rv, rv); } // Fallthrough to downgrade check + MOZ_FALLTHROUGH; // Downgrading // If columns have been added to the table, we can still use the ones we @@ -1265,17 +1274,17 @@ nsDownloadManager::GetDownloadFromDB(mozIStorageConnection* aDBConn, if (dl->mGUID.IsEmpty()) { rv = GenerateGUID(dl->mGUID); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr stmt; + nsCOMPtr updateStmt; rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING( "UPDATE moz_downloads SET guid = :guid " "WHERE id = :id"), - getter_AddRefs(stmt)); + getter_AddRefs(updateStmt)); NS_ENSURE_SUCCESS(rv, rv); - rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("guid"), dl->mGUID); + rv = updateStmt->BindUTF8StringByName(NS_LITERAL_CSTRING("guid"), dl->mGUID); NS_ENSURE_SUCCESS(rv, rv); - rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), dl->mID); + rv = updateStmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), dl->mID); NS_ENSURE_SUCCESS(rv, rv); - rv = stmt->Execute(); + rv = updateStmt->Execute(); NS_ENSURE_SUCCESS(rv, rv); } @@ -1480,9 +1489,6 @@ nsDownloadManager::GetUserDownloadsDirectory(nsIFile **aResult) case 0: // Desktop { nsCOMPtr downloadDir; - nsCOMPtr dirService = - do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); rv = dirService->Get(NS_OS_DESKTOP_DIR, NS_GET_IID(nsIFile), getter_AddRefs(downloadDir)); @@ -1804,7 +1810,6 @@ nsDownloadManager::RetryDownload(const nsACString& aGUID) return RetryDownload(dl); } - NS_IMETHODIMP nsDownloadManager::RetryDownload(uint32_t aID) {