diff options
author | Moonchild <mcwerewolf@wolfbeast.com> | 2019-03-13 07:49:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-13 07:49:07 +0100 |
commit | bf0413359245579e9509146d42cd5547e35da695 (patch) | |
tree | 8218d4f60d9eccacbf42df8cb88094a082d401b4 /dom | |
parent | 51b821b3fdc5a7eab2369cb6a6680598a6264b08 (diff) | |
parent | 709bc24e9110eba12f94cfcb8db00a8338ac4098 (diff) | |
download | UXP-bf0413359245579e9509146d42cd5547e35da695.tar UXP-bf0413359245579e9509146d42cd5547e35da695.tar.gz UXP-bf0413359245579e9509146d42cd5547e35da695.tar.lz UXP-bf0413359245579e9509146d42cd5547e35da695.tar.xz UXP-bf0413359245579e9509146d42cd5547e35da695.zip |
Merge pull request #998 from MoonchildProductions/master
Merge master into Sync-weave
Diffstat (limited to 'dom')
147 files changed, 552 insertions, 1602 deletions
diff --git a/dom/animation/AnimationEffectReadOnly.cpp b/dom/animation/AnimationEffectReadOnly.cpp index bf2e2197d..63d633c2f 100644 --- a/dom/animation/AnimationEffectReadOnly.cpp +++ b/dom/animation/AnimationEffectReadOnly.cpp @@ -23,7 +23,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(AnimationEffectReadOnly) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument, mTiming, mAnimation) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(AnimationEffectReadOnly) diff --git a/dom/animation/AnimationTimeline.cpp b/dom/animation/AnimationTimeline.cpp index 643106807..f4a1ecc9a 100644 --- a/dom/animation/AnimationTimeline.cpp +++ b/dom/animation/AnimationTimeline.cpp @@ -21,7 +21,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(AnimationTimeline) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow, mAnimations) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(AnimationTimeline) diff --git a/dom/base/Attr.cpp b/dom/base/Attr.cpp index 6eb3b49fd..71b559392 100644 --- a/dom/base/Attr.cpp +++ b/dom/base/Attr.cpp @@ -59,8 +59,6 @@ Attr::Attr(nsDOMAttributeMap *aAttrMap, NS_IMPL_CYCLE_COLLECTION_CLASS(Attr) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Attr) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS - if (!nsINode::Traverse(tmp, cb)) { return NS_SUCCESS_INTERRUPTED_TRAVERSE; } diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index 00ee3d42f..3f202d33b 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -138,7 +138,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CustomElementRegistry) } NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWhenDefinedPromiseMap) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(CustomElementRegistry) diff --git a/dom/base/DOMException.cpp b/dom/base/DOMException.cpp index dfda47316..9fbb2f242 100644 --- a/dom/base/DOMException.cpp +++ b/dom/base/DOMException.cpp @@ -165,7 +165,6 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(Exception) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Exception) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLocation) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mData) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(Exception) diff --git a/dom/base/DOMIntersectionObserver.cpp b/dom/base/DOMIntersectionObserver.cpp index e39abf1a6..389b93071 100644 --- a/dom/base/DOMIntersectionObserver.cpp +++ b/dom/base/DOMIntersectionObserver.cpp @@ -43,16 +43,17 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMIntersectionObserver) NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER + tmp->Disconnect(); NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner) + NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument) NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallback) NS_IMPL_CYCLE_COLLECTION_UNLINK(mRoot) NS_IMPL_CYCLE_COLLECTION_UNLINK(mQueuedEntries) - tmp->Disconnect(); NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMIntersectionObserver) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRoot) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mQueuedEntries) @@ -153,30 +154,34 @@ DOMIntersectionObserver::Observe(Element& aTarget) return; } aTarget.RegisterIntersectionObserver(this); - mObservationTargets.PutEntry(&aTarget); + mObservationTargets.AppendElement(&aTarget); Connect(); } void DOMIntersectionObserver::Unobserve(Element& aTarget) { - if (UnlinkTarget(aTarget)) { - aTarget.UnregisterIntersectionObserver(this); + if (!mObservationTargets.Contains(&aTarget)) { + // You're not on the list, buddy! + return; } + + if (mObservationTargets.Length() == 1) { + Disconnect(); + return; + } + + mObservationTargets.RemoveElement(&aTarget); + aTarget.UnregisterIntersectionObserver(this); } -bool +void DOMIntersectionObserver::UnlinkTarget(Element& aTarget) { - if (!mObservationTargets.Contains(&aTarget)) { - return false; - } - if (mObservationTargets.Count() == 1) { - Disconnect(); - return false; - } - mObservationTargets.RemoveEntry(&aTarget); - return true; + mObservationTargets.RemoveElement(&aTarget); + if (mObservationTargets.Length() == 0) { + Disconnect(); + } } void @@ -185,10 +190,11 @@ DOMIntersectionObserver::Connect() if (mConnected) { return; } + mConnected = true; - - nsIDocument* document = mOwner->GetExtantDoc(); - document->AddIntersectionObserver(this); + if (mDocument) { + mDocument->AddIntersectionObserver(this); + } } void @@ -197,18 +203,17 @@ DOMIntersectionObserver::Disconnect() if (!mConnected) { return; } - for (auto iter = mObservationTargets.Iter(); !iter.Done(); iter.Next()) { - Element* target = iter.Get()->GetKey(); + + mConnected = false; + + for (size_t i = 0; i < mObservationTargets.Length(); ++i) { + Element* target = mObservationTargets.ElementAt(i); target->UnregisterIntersectionObserver(this); } mObservationTargets.Clear(); - if (mOwner) { - nsIDocument* document = mOwner->GetExtantDoc(); - if (document) { - document->RemoveIntersectionObserver(this); - } + if (mDocument) { + mDocument->RemoveIntersectionObserver(this); } - mConnected = false; } void @@ -269,17 +274,21 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time root = mRoot; rootFrame = root->GetPrimaryFrame(); if (rootFrame) { + nsRect rootRectRelativeToRootFrame; if (rootFrame->GetType() == nsGkAtoms::scrollFrame) { + // rootRectRelativeToRootFrame should be the content rect of rootFrame, not including the scrollbars. nsIScrollableFrame* scrollFrame = do_QueryFrame(rootFrame); - rootRect = nsLayoutUtils::TransformFrameRectToAncestor( - rootFrame, - rootFrame->GetContentRectRelativeToSelf(), - scrollFrame->GetScrolledFrame()); + rootRectRelativeToRootFrame = scrollFrame->GetScrollPortRect(); } else { - rootRect = nsLayoutUtils::GetAllInFlowRectsUnion(rootFrame, - nsLayoutUtils::GetContainingBlockForClientRect(rootFrame), - nsLayoutUtils::RECTS_ACCOUNT_FOR_TRANSFORMS); + // rootRectRelativeToRootFrame should be the border rect of rootFrame. + rootRectRelativeToRootFrame = rootFrame->GetRectRelativeToSelf(); } + nsIFrame* containingBlock = + nsLayoutUtils::GetContainingBlockForClientRect(rootFrame); + rootRect = + nsLayoutUtils::TransformFrameRectToAncestor(rootFrame, + rootRectRelativeToRootFrame, + containingBlock); } } else { nsCOMPtr<nsIPresShell> presShell = aDocument->GetShell(); @@ -288,12 +297,25 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time if (rootFrame) { nsPresContext* presContext = rootFrame->PresContext(); while (!presContext->IsRootContentDocument()) { - presContext = rootFrame->PresContext()->GetParentPresContext(); - rootFrame = presContext->PresShell()->GetRootScrollFrame(); + // Walk up the tree + presContext = presContext->GetParentPresContext(); + if (!presContext) { + break; + } + nsIFrame* rootScrollFrame = presContext->PresShell()->GetRootScrollFrame(); + if (rootScrollFrame) { + rootFrame = rootScrollFrame; + } else { + break; + } } root = rootFrame->GetContent()->AsElement(); nsIScrollableFrame* scrollFrame = do_QueryFrame(rootFrame); - rootRect = scrollFrame->GetScrollPortRect(); + // If we end up with a null root frame for some reason, we'll proceed + // with an empty root intersection rect. + if (scrollFrame) { + rootRect = scrollFrame->GetScrollPortRect(); + } } } } @@ -314,11 +336,12 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time rootMargin.Side(side) = nsLayoutUtils::ComputeCBDependentValue(basis, coord); } - for (auto iter = mObservationTargets.Iter(); !iter.Done(); iter.Next()) { - Element* target = iter.Get()->GetKey(); + for (size_t i = 0; i < mObservationTargets.Length(); ++i) { + Element* target = mObservationTargets.ElementAt(i); nsIFrame* targetFrame = target->GetPrimaryFrame(); nsRect targetRect; Maybe<nsRect> intersectionRect; + bool isSameDoc = root && root->GetComposedDoc() == target->GetComposedDoc(); if (rootFrame && targetFrame) { // If mRoot is set we are testing intersection with a container element @@ -327,7 +350,7 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time // Skip further processing of this target if it is not in the same // Document as the intersection root, e.g. if root is an element of // the main document and target an element from an embedded iframe. - if (target->GetComposedDoc() != root->GetComposedDoc()) { + if (!isSameDoc) { continue; } // Skip further processing of this target if is not a descendant of the @@ -344,7 +367,7 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time nsLayoutUtils::GetContainingBlockForClientRect(targetFrame), nsLayoutUtils::RECTS_ACCOUNT_FOR_TRANSFORMS ); - intersectionRect = Some(targetFrame->GetVisualOverflowRect()); + intersectionRect = Some(targetFrame->GetRectRelativeToSelf()); nsIFrame* containerFrame = nsLayoutUtils::GetCrossDocParentFrame(targetFrame); while (containerFrame && containerFrame != rootFrame) { @@ -399,29 +422,37 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time intersectionRectRelativeToRoot, rootIntersectionRect ); - if (intersectionRect.isSome()) { - intersectionRect = Some(nsLayoutUtils::TransformFrameRectToAncestor( - nsLayoutUtils::GetContainingBlockForClientRect(rootFrame), - intersectionRect.value(), - targetFrame->PresContext()->PresShell()->GetRootScrollFrame() - )); + if (intersectionRect.isSome() && !isSameDoc) { + nsRect rect = intersectionRect.value(); + nsPresContext* presContext = targetFrame->PresContext(); + nsLayoutUtils::TransformRect(rootFrame, + presContext->PresShell()->GetRootScrollFrame(), rect); + intersectionRect = Some(rect); } } - double targetArea = targetRect.width * targetRect.height; - double intersectionArea = !intersectionRect ? - 0 : intersectionRect->width * intersectionRect->height; - double intersectionRatio = targetArea > 0.0 ? intersectionArea / targetArea : 0.0; + int64_t targetArea = + (int64_t) targetRect.Width() * (int64_t) targetRect.Height(); + int64_t intersectionArea = !intersectionRect ? 0 : + (int64_t) intersectionRect->Width() * + (int64_t) intersectionRect->Height(); + + double intersectionRatio; + if (targetArea > 0.0) { + intersectionRatio = (double) intersectionArea / (double) targetArea; + } else { + intersectionRatio = intersectionRect.isSome() ? 1.0 : 0.0; + } - size_t threshold = -1; + int32_t threshold = -1; if (intersectionRatio > 0.0) { if (intersectionRatio >= 1.0) { intersectionRatio = 1.0; - threshold = mThresholds.Length(); + threshold = (int32_t)mThresholds.Length(); } else { for (size_t k = 0; k < mThresholds.Length(); ++k) { if (mThresholds[k] <= intersectionRatio) { - threshold = k + 1; + threshold = (int32_t)k + 1; } else { break; } @@ -468,6 +499,7 @@ DOMIntersectionObserver::QueueIntersectionObserverEntry(Element* aTarget, rootBounds.forget(), boundingClientRect.forget(), intersectionRect.forget(), + aIntersectionRect.isSome(), aTarget, aIntersectionRatio); mQueuedEntries.AppendElement(entry.forget()); } @@ -480,7 +512,7 @@ DOMIntersectionObserver::Notify() } mozilla::dom::Sequence<mozilla::OwningNonNull<DOMIntersectionObserverEntry>> entries; if (entries.SetCapacity(mQueuedEntries.Length(), mozilla::fallible)) { - for (uint32_t i = 0; i < mQueuedEntries.Length(); ++i) { + for (size_t i = 0; i < mQueuedEntries.Length(); ++i) { RefPtr<DOMIntersectionObserverEntry> next = mQueuedEntries[i]; *entries.AppendElement(mozilla::fallible) = next; } diff --git a/dom/base/DOMIntersectionObserver.h b/dom/base/DOMIntersectionObserver.h index 8144fc5c5..8674fe25d 100644 --- a/dom/base/DOMIntersectionObserver.h +++ b/dom/base/DOMIntersectionObserver.h @@ -30,6 +30,7 @@ public: RefPtr<DOMRect> aRootBounds, RefPtr<DOMRect> aBoundingClientRect, RefPtr<DOMRect> aIntersectionRect, + bool aIsIntersecting, Element* aTarget, double aIntersectionRatio) : mOwner(aOwner), @@ -37,6 +38,7 @@ public: mRootBounds(aRootBounds), mBoundingClientRect(aBoundingClientRect), mIntersectionRect(aIntersectionRect), + mIsIntersecting(aIsIntersecting), mTarget(aTarget), mIntersectionRatio(aIntersectionRatio) { @@ -74,6 +76,11 @@ public: return mIntersectionRect; } + bool IsIntersecting() + { + return mIsIntersecting; + } + double IntersectionRatio() { return mIntersectionRatio; @@ -90,6 +97,7 @@ protected: RefPtr<DOMRect> mRootBounds; RefPtr<DOMRect> mBoundingClientRect; RefPtr<DOMRect> mIntersectionRect; + bool mIsIntersecting; RefPtr<Element> mTarget; double mIntersectionRatio; }; @@ -101,12 +109,17 @@ protected: class DOMIntersectionObserver final : public nsISupports, public nsWrapperCache { - virtual ~DOMIntersectionObserver() { } + virtual ~DOMIntersectionObserver() { + Disconnect(); + } public: DOMIntersectionObserver(already_AddRefed<nsPIDOMWindowInner>&& aOwner, mozilla::dom::IntersectionCallback& aCb) - : mOwner(aOwner), mCallback(&aCb), mConnected(false) + : mOwner(aOwner) + , mDocument(mOwner->GetExtantDoc()) + , mCallback(&aCb) + , mConnected(false) { } NS_DECL_CYCLE_COLLECTING_ISUPPORTS @@ -142,7 +155,7 @@ public: void Observe(Element& aTarget); void Unobserve(Element& aTarget); - bool UnlinkTarget(Element& aTarget); + void UnlinkTarget(Element& aTarget); void Disconnect(); void TakeRecords(nsTArray<RefPtr<DOMIntersectionObserverEntry>>& aRetVal); @@ -164,11 +177,15 @@ protected: double aIntersectionRatio); nsCOMPtr<nsPIDOMWindowInner> mOwner; + RefPtr<nsIDocument> mDocument; RefPtr<mozilla::dom::IntersectionCallback> mCallback; RefPtr<Element> mRoot; nsCSSRect mRootMargin; nsTArray<double> mThresholds; - nsTHashtable<nsPtrHashKey<Element>> mObservationTargets; + + // Holds raw pointers which are explicitly cleared by UnlinkTarget(). + nsTArray<Element*> mObservationTargets; + nsTArray<RefPtr<DOMIntersectionObserverEntry>> mQueuedEntries; bool mConnected; }; diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 3760dc43f..5c3277e84 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -687,19 +687,23 @@ Element::GetScrollFrame(nsIFrame **aStyledFrame, bool aFlushLayout) } void -Element::ScrollIntoView() +Element::ScrollIntoView(const BooleanOrScrollIntoViewOptions& aObject) { - ScrollIntoView(ScrollIntoViewOptions()); -} + if (aObject.IsScrollIntoViewOptions()) { + return ScrollIntoView(aObject.GetAsScrollIntoViewOptions()); + } + + MOZ_DIAGNOSTIC_ASSERT(aObject.IsBoolean()); -void -Element::ScrollIntoView(bool aTop) -{ ScrollIntoViewOptions options; - if (!aTop) { + if (aObject.GetAsBoolean()) { + options.mBlock = ScrollLogicalPosition::Start; + options.mInline = ScrollLogicalPosition::Nearest; + } else { options.mBlock = ScrollLogicalPosition::End; + options.mInline = ScrollLogicalPosition::Nearest; } - ScrollIntoView(options); + return ScrollIntoView(options); } void @@ -716,9 +720,41 @@ Element::ScrollIntoView(const ScrollIntoViewOptions &aOptions) return; } - int16_t vpercent = (aOptions.mBlock == ScrollLogicalPosition::Start) - ? nsIPresShell::SCROLL_TOP - : nsIPresShell::SCROLL_BOTTOM; + int16_t vpercent = nsIPresShell::SCROLL_CENTER; + switch (aOptions.mBlock) { + case ScrollLogicalPosition::Start: + vpercent = nsIPresShell::SCROLL_TOP; + break; + case ScrollLogicalPosition::Center: + vpercent = nsIPresShell::SCROLL_CENTER; + break; + case ScrollLogicalPosition::End: + vpercent = nsIPresShell::SCROLL_BOTTOM; + break; + case ScrollLogicalPosition::Nearest: + vpercent = nsIPresShell::SCROLL_MINIMUM; + break; + default: + MOZ_ASSERT_UNREACHABLE("Unexpected ScrollLogicalPosition value"); + } + + int16_t hpercent = nsIPresShell::SCROLL_CENTER; + switch (aOptions.mInline) { + case ScrollLogicalPosition::Start: + hpercent = nsIPresShell::SCROLL_LEFT; + break; + case ScrollLogicalPosition::Center: + hpercent = nsIPresShell::SCROLL_CENTER; + break; + case ScrollLogicalPosition::End: + hpercent = nsIPresShell::SCROLL_RIGHT; + break; + case ScrollLogicalPosition::Nearest: + hpercent = nsIPresShell::SCROLL_MINIMUM; + break; + default: + MOZ_ASSERT_UNREACHABLE("Unexpected ScrollLogicalPosition value"); + } uint32_t flags = nsIPresShell::SCROLL_OVERFLOW_HIDDEN; if (aOptions.mBehavior == ScrollBehavior::Smooth) { @@ -731,7 +767,9 @@ Element::ScrollIntoView(const ScrollIntoViewOptions &aOptions) nsIPresShell::ScrollAxis( vpercent, nsIPresShell::SCROLL_ALWAYS), - nsIPresShell::ScrollAxis(), + nsIPresShell::ScrollAxis( + hpercent, + nsIPresShell::SCROLL_ALWAYS), flags); } @@ -3947,7 +3985,7 @@ Element::ClearDataset() slots->mDataset = nullptr; } -nsDataHashtable<nsPtrHashKey<DOMIntersectionObserver>, int32_t>* +nsDataHashtable<nsRefPtrHashKey<DOMIntersectionObserver>, int32_t>* Element::RegisteredIntersectionObservers() { nsDOMSlots* slots = DOMSlots(); @@ -3962,7 +4000,7 @@ enum nsPreviousIntersectionThreshold { void Element::RegisterIntersectionObserver(DOMIntersectionObserver* aObserver) { - nsDataHashtable<nsPtrHashKey<DOMIntersectionObserver>, int32_t>* observers = + nsDataHashtable<nsRefPtrHashKey<DOMIntersectionObserver>, int32_t>* observers = RegisteredIntersectionObservers(); if (observers->Contains(aObserver)) { return; @@ -3979,7 +4017,7 @@ Element::RegisterIntersectionObserver(DOMIntersectionObserver* aObserver) void Element::UnregisterIntersectionObserver(DOMIntersectionObserver* aObserver) { - nsDataHashtable<nsPtrHashKey<DOMIntersectionObserver>, int32_t>* observers = + nsDataHashtable<nsRefPtrHashKey<DOMIntersectionObserver>, int32_t>* observers = RegisteredIntersectionObservers(); observers->Remove(aObserver); } @@ -3987,7 +4025,7 @@ Element::UnregisterIntersectionObserver(DOMIntersectionObserver* aObserver) bool Element::UpdateIntersectionObservation(DOMIntersectionObserver* aObserver, int32_t aThreshold) { - nsDataHashtable<nsPtrHashKey<DOMIntersectionObserver>, int32_t>* observers = + nsDataHashtable<nsRefPtrHashKey<DOMIntersectionObserver>, int32_t>* observers = RegisteredIntersectionObservers(); if (!observers->Contains(aObserver)) { return false; diff --git a/dom/base/Element.h b/dom/base/Element.h index c269ab14a..ce84b74fb 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -818,9 +818,10 @@ public: return slots ? slots->mShadowRoot.get() : nullptr; } - void ScrollIntoView(); - void ScrollIntoView(bool aTop); +private: void ScrollIntoView(const ScrollIntoViewOptions &aOptions); +public: + void ScrollIntoView(const BooleanOrScrollIntoViewOptions& aObject); void Scroll(double aXScroll, double aYScroll); void Scroll(const ScrollToOptions& aOptions); void ScrollTo(double aXScroll, double aYScroll); @@ -1382,7 +1383,8 @@ protected: nsDOMTokenList* GetTokenList(nsIAtom* aAtom, const DOMTokenListSupportedTokenArray aSupportedTokens = nullptr); - nsDataHashtable<nsPtrHashKey<DOMIntersectionObserver>, int32_t>* RegisteredIntersectionObservers(); + nsDataHashtable<nsRefPtrHashKey<DOMIntersectionObserver>, int32_t>* + RegisteredIntersectionObservers(); private: /** diff --git a/dom/base/File.cpp b/dom/base/File.cpp index 7d86dfe8a..1d5ab73e7 100755 --- a/dom/base/File.cpp +++ b/dom/base/File.cpp @@ -138,7 +138,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Blob) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(Blob) diff --git a/dom/base/FormData.cpp b/dom/base/FormData.cpp index 6095286be..52bdd9210 100644 --- a/dom/base/FormData.cpp +++ b/dom/base/FormData.cpp @@ -84,7 +84,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(FormData) "mFormData[i].GetAsBlob()", 0); } - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(FormData) diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index fde983e7c..9106778df 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -585,6 +585,12 @@ FragmentOrElement::nsDOMSlots::Traverse(nsCycleCollectionTraversalCallback &cb, mCustomElementData->mCallbackQueue[i]->Traverse(cb); } } + + for (auto iter = mRegisteredIntersectionObservers.Iter(); !iter.Done(); iter.Next()) { + DOMIntersectionObserver* observer = iter.Key(); + NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mRegisteredIntersectionObservers[i]"); + cb.NoteXPCOMChild(observer); + } } void @@ -1872,10 +1878,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(FragmentOrElement) NS_IMPL_CYCLE_COLLECTION_DESCRIBE(FragmentOrElement, tmp->mRefCnt.get()) } - // Always need to traverse script objects, so do that before we check - // if we're uncollectable. - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS - if (!nsINode::Traverse(tmp, cb)) { return NS_SUCCESS_INTERRUPTED_TRAVERSE; } diff --git a/dom/base/FragmentOrElement.h b/dom/base/FragmentOrElement.h index 7c74e9cd4..f0cc29f22 100644 --- a/dom/base/FragmentOrElement.h +++ b/dom/base/FragmentOrElement.h @@ -354,7 +354,8 @@ public: /** * Registered Intersection Observers on the element. */ - nsDataHashtable<nsPtrHashKey<DOMIntersectionObserver>, int32_t> mRegisteredIntersectionObservers; + nsDataHashtable<nsRefPtrHashKey<DOMIntersectionObserver>, int32_t> + mRegisteredIntersectionObservers; }; protected: diff --git a/dom/base/Location.cpp b/dom/base/Location.cpp index e312cffe0..1483c32f9 100644 --- a/dom/base/Location.cpp +++ b/dom/base/Location.cpp @@ -80,7 +80,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Location) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInnerWindow) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(Location) @@ -790,10 +789,6 @@ Location::GetSearch(nsAString& aSearch) NS_IMETHODIMP Location::SetSearch(const nsAString& aSearch) { - if (aSearch.IsEmpty()) { - return NS_OK; // Ignore empty string - } - nsresult rv = SetSearchInternal(aSearch); if (NS_FAILED(rv)) { return rv; diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 286cd0e79..fdf151b6c 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -223,7 +223,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGamepadServiceTest) #endif NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVRGetDisplaysPromises) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(Navigator) diff --git a/dom/base/Pose.cpp b/dom/base/Pose.cpp index 1eab4c173..5bc4ca6de 100644 --- a/dom/base/Pose.cpp +++ b/dom/base/Pose.cpp @@ -26,7 +26,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Pose) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(Pose) diff --git a/dom/base/ProcessGlobal.cpp b/dom/base/ProcessGlobal.cpp index 641f49f98..6cd29ab7c 100644 --- a/dom/base/ProcessGlobal.cpp +++ b/dom/base/ProcessGlobal.cpp @@ -52,7 +52,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ProcessGlobal) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMessageManager) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal) tmp->TraverseHostObjectURIs(cb); - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(ProcessGlobal) diff --git a/dom/base/nsContentList.cpp b/dom/base/nsContentList.cpp index 43e65777d..c98859ee3 100644 --- a/dom/base/nsContentList.cpp +++ b/dom/base/nsContentList.cpp @@ -54,7 +54,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsBaseContentList) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsBaseContentList) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mElements) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(nsBaseContentList) diff --git a/dom/base/nsDOMAttributeMap.cpp b/dom/base/nsDOMAttributeMap.cpp index 381f267cd..2a90df7e4 100644 --- a/dom/base/nsDOMAttributeMap.cpp +++ b/dom/base/nsDOMAttributeMap.cpp @@ -65,7 +65,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMAttributeMap) for (auto iter = tmp->mAttributeCache.Iter(); !iter.Done(); iter.Next()) { cb.NoteXPCOMChild(static_cast<nsINode*>(iter.Data().get())); } - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContent) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END diff --git a/dom/base/nsDOMMutationObserver.cpp b/dom/base/nsDOMMutationObserver.cpp index 024ce5e2e..858a30ce5 100644 --- a/dom/base/nsDOMMutationObserver.cpp +++ b/dom/base/nsDOMMutationObserver.cpp @@ -506,7 +506,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMMutationObserver) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMMutationObserver) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mReceivers) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFirstPendingMutation) diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 291df5f27..2ab5937ac 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -4033,8 +4033,6 @@ nsDOMWindowUtils::ForceUseCounterFlush(nsIDOMNode *aNode) if (nsCOMPtr<nsIDocument> doc = do_QueryInterface(aNode)) { mozilla::css::ImageLoader* loader = doc->StyleImageLoader(); loader->FlushUseCounters(); - - static_cast<nsDocument*>(doc.get())->ReportUseCounters(); return NS_OK; } diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index ac9601caf..a6ed419df 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -1395,63 +1395,6 @@ nsDocument::~nsDocument() NS_ASSERTION(!mIsShowing, "Destroying a currently-showing document"); - if (IsTopLevelContentDocument()) { - //don't report for about: pages - if (!IsAboutPage()) { - // Record the page load - uint32_t pageLoaded = 1; - Accumulate(Telemetry::MIXED_CONTENT_UNBLOCK_COUNTER, pageLoaded); - // Record the mixed content status of the docshell in Telemetry - enum { - NO_MIXED_CONTENT = 0, // There is no Mixed Content on the page - MIXED_DISPLAY_CONTENT = 1, // The page attempted to load Mixed Display Content - MIXED_ACTIVE_CONTENT = 2, // The page attempted to load Mixed Active Content - MIXED_DISPLAY_AND_ACTIVE_CONTENT = 3 // The page attempted to load Mixed Display & Mixed Active Content - }; - - bool mixedActiveLoaded = GetHasMixedActiveContentLoaded(); - bool mixedActiveBlocked = GetHasMixedActiveContentBlocked(); - - bool mixedDisplayLoaded = GetHasMixedDisplayContentLoaded(); - bool mixedDisplayBlocked = GetHasMixedDisplayContentBlocked(); - - bool hasMixedDisplay = (mixedDisplayBlocked || mixedDisplayLoaded); - bool hasMixedActive = (mixedActiveBlocked || mixedActiveLoaded); - - uint32_t mixedContentLevel = NO_MIXED_CONTENT; - if (hasMixedDisplay && hasMixedActive) { - mixedContentLevel = MIXED_DISPLAY_AND_ACTIVE_CONTENT; - } else if (hasMixedActive){ - mixedContentLevel = MIXED_ACTIVE_CONTENT; - } else if (hasMixedDisplay) { - mixedContentLevel = MIXED_DISPLAY_CONTENT; - } - Accumulate(Telemetry::MIXED_CONTENT_PAGE_LOAD, mixedContentLevel); - - // record mixed object subrequest telemetry - if (mHasMixedContentObjectSubrequest) { - /* mixed object subrequest loaded on page*/ - Accumulate(Telemetry::MIXED_CONTENT_OBJECT_SUBREQUEST, 1); - } else { - /* no mixed object subrequests loaded on page*/ - Accumulate(Telemetry::MIXED_CONTENT_OBJECT_SUBREQUEST, 0); - } - - // record CSP telemetry on this document - if (mHasCSP) { - Accumulate(Telemetry::CSP_DOCUMENTS_COUNT, 1); - } - if (mHasUnsafeInlineCSP) { - Accumulate(Telemetry::CSP_UNSAFE_INLINE_DOCUMENTS_COUNT, 1); - } - if (mHasUnsafeEvalCSP) { - Accumulate(Telemetry::CSP_UNSAFE_EVAL_DOCUMENTS_COUNT, 1); - } - } - } - - ReportUseCounters(); - mInDestructor = true; mInUnlinkOrDeletion = true; @@ -1647,10 +1590,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument) NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsDocument, tmp->mRefCnt.get()) } - // Always need to traverse script objects, so do that before we check - // if we're uncollectable. - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS - if (!nsINode::Traverse(tmp, cb)) { return NS_SUCCESS_INTERRUPTED_TRAVERSE; } @@ -1736,8 +1675,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOnDemandBuiltInUASheets) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPreloadingImages) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIntersectionObservers) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSubImportLinks) for (uint32_t i = 0; i < tmp->mFrameRequestCallbacks.Length(); ++i) { @@ -12355,40 +12292,27 @@ nsIDocument::InlineScriptAllowedByCSP() return allowsInlineScript; } -static bool -MightBeAboutOrChromeScheme(nsIURI* aURI) -{ - MOZ_ASSERT(aURI); - bool isAbout = true; - bool isChrome = true; - aURI->SchemeIs("about", &isAbout); - aURI->SchemeIs("chrome", &isChrome); - return isAbout || isChrome; -} - -void -nsDocument::ReportUseCounters() -{ -/* STUB */ -} - void nsDocument::AddIntersectionObserver(DOMIntersectionObserver* aObserver) { - NS_ASSERTION(mIntersectionObservers.IndexOf(aObserver) == nsTArray<int>::NoIndex, - "Intersection observer already in the list"); - mIntersectionObservers.AppendElement(aObserver); + MOZ_ASSERT(!mIntersectionObservers.Contains(aObserver), + "Intersection observer already in the list"); + mIntersectionObservers.PutEntry(aObserver); } void nsDocument::RemoveIntersectionObserver(DOMIntersectionObserver* aObserver) { - mIntersectionObservers.RemoveElement(aObserver); + mIntersectionObservers.RemoveEntry(aObserver); } void nsDocument::UpdateIntersectionObservations() { + if (mIntersectionObservers.IsEmpty()) { + return; + } + DOMHighResTimeStamp time = 0; if (nsPIDOMWindowInner* window = GetInnerWindow()) { Performance* perf = window->GetPerformance(); @@ -12396,25 +12320,42 @@ nsDocument::UpdateIntersectionObservations() time = perf->Now(); } } - for (const auto& observer : mIntersectionObservers) { - observer->Update(this, time); + nsTArray<RefPtr<DOMIntersectionObserver>> observers(mIntersectionObservers.Count()); + for (auto iter = mIntersectionObservers.Iter(); !iter.Done(); iter.Next()) { + DOMIntersectionObserver* observer = iter.Get()->GetKey(); + observers.AppendElement(observer); + } + for (const auto& observer : observers) { + if (observer) { + observer->Update(this, time); + } } } void nsDocument::ScheduleIntersectionObserverNotification() { + if (mIntersectionObservers.IsEmpty()) { + return; + } + nsCOMPtr<nsIRunnable> notification = NewRunnableMethod(this, &nsDocument::NotifyIntersectionObservers); - NS_DispatchToCurrentThread(notification); + NS_DispatchToCurrentThread(notification.forget()); } void nsDocument::NotifyIntersectionObservers() { - nsTArray<RefPtr<DOMIntersectionObserver>> observers(mIntersectionObservers); + nsTArray<RefPtr<DOMIntersectionObserver>> observers(mIntersectionObservers.Count()); + for (auto iter = mIntersectionObservers.Iter(); !iter.Done(); iter.Next()) { + DOMIntersectionObserver* observer = iter.Get()->GetKey(); + observers.AppendElement(observer); + } for (const auto& observer : observers) { - observer->Notify(); + if (observer) { + observer->Notify(); + } } } diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h index 3725b3c18..95fd57545 100644 --- a/dom/base/nsDocument.h +++ b/dom/base/nsDocument.h @@ -774,8 +774,6 @@ public: virtual nsViewportInfo GetViewportInfo(const mozilla::ScreenIntSize& aDisplaySize) override; - void ReportUseCounters(); - virtual void AddIntersectionObserver( mozilla::dom::DOMIntersectionObserver* aObserver) override; virtual void RemoveIntersectionObserver( @@ -1341,8 +1339,9 @@ protected: // Array of observers nsTObserverArray<nsIDocumentObserver*> mObservers; - // Array of intersection observers - nsTArray<RefPtr<mozilla::dom::DOMIntersectionObserver>> mIntersectionObservers; + // Hashtable of intersection observers + nsTHashtable<nsPtrHashKey<mozilla::dom::DOMIntersectionObserver>> + mIntersectionObservers; // Tracker for animations that are waiting to start. // nullptr until GetOrCreatePendingAnimationTracker is called. @@ -1448,14 +1447,6 @@ public: // 'style-sheet-applicable-state-changed' notification. bool mSSApplicableStateNotificationPending:1; - // Whether we have reported use counters for this document with Telemetry yet. - // Normally this is only done at document destruction time, but for image - // documents (SVG documents) that are not guaranteed to be destroyed, we - // report use counters when the image cache no longer has any imgRequestProxys - // pointing to them. We track whether we ever reported use counters so - // that we only report them once for the document. - bool mReportedUseCounters:1; - // Whether we have filled our pres shell's style set with the document's // additional sheets and sheets from the nsStyleSheetService. bool mStyleSetFilled:1; diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp index f173678b7..bba4232aa 100644 --- a/dom/base/nsFrameMessageManager.cpp +++ b/dom/base/nsFrameMessageManager.cpp @@ -132,7 +132,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsFrameMessageManager) } NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChildManagers) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParentManager) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsFrameMessageManager) @@ -706,12 +705,6 @@ nsFrameMessageManager::SendRpcMessage(const nsAString& aMessageName, static bool AllowMessage(size_t aDataLength, const nsAString& aMessageName) { - static const size_t kMinTelemetryMessageSize = 8192; - - if (aDataLength < kMinTelemetryMessageSize) { - return true; - } - NS_ConvertUTF16toUTF8 messageName(aMessageName); messageName.StripChars("0123456789"); diff --git a/dom/base/nsGenericDOMDataNode.cpp b/dom/base/nsGenericDOMDataNode.cpp index 9688588e0..0ae15e09e 100644 --- a/dom/base/nsGenericDOMDataNode.cpp +++ b/dom/base/nsGenericDOMDataNode.cpp @@ -98,10 +98,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGenericDOMDataNode) NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsGenericDOMDataNode, tmp->mRefCnt.get()) } - // Always need to traverse script objects, so do that before we check - // if we're uncollectable. - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS - if (!nsINode::Traverse(tmp, cb)) { return NS_SUCCESS_INTERRUPTED_TRAVERSE; } diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 677e1a0ea..ac85e34c0 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -288,7 +288,6 @@ static bool gMouseDown = false; static bool gDragServiceDisabled = false; static FILE *gDumpFile = nullptr; static uint32_t gSerialCounter = 0; -static TimeStamp gLastRecordedRecentTimeouts; #define STATISTICS_INTERVAL (30 * PR_MSEC_PER_SEC) #ifdef DEBUG_jst @@ -1518,7 +1517,6 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow) mIsPopupSpam(false), mBlockScriptedClosingFlag(false), mWasOffline(false), - mHasHadSlowScript(false), mNotifyIdleObserversIdleOnThaw(false), mNotifyIdleObserversActiveOnThaw(false), mCreatingInnerWindow(false), @@ -2286,7 +2284,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindow) tmp->TraverseHostObjectURIs(cb); - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow) @@ -11542,8 +11539,6 @@ nsGlobalWindow::ShowSlowScriptDialog() unsigned lineno; bool hasFrame = JS::DescribeScriptedCaller(cx, &filename, &lineno); - mHasHadSlowScript = true; - if (XRE_IsContentProcess() && ProcessHangMonitor::Get()) { ProcessHangMonitor::SlowScriptAction action; @@ -13399,13 +13394,6 @@ nsGlobalWindow::RunTimeout(Timeout* aTimeout) return; } - // Record telemetry information about timers set recently. - TimeDuration recordingInterval = TimeDuration::FromMilliseconds(STATISTICS_INTERVAL); - if (gLastRecordedRecentTimeouts.IsNull() || - now - gLastRecordedRecentTimeouts > recordingInterval) { - gLastRecordedRecentTimeouts = now; - } - // Insert a dummy timeout into the list of timeouts between the // portion of the list that we are about to process now and those // timeouts that will be processed in a future call to diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 1cb825a77..1f420895c 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -1780,11 +1780,6 @@ protected: // Window offline status. Checked to see if we need to fire offline event bool mWasOffline : 1; - // Represents whether the inner window's page has had a slow script notice. - // Only used by inner windows; will always be false for outer windows. - // This is used to implement Telemetry measures such as SLOW_SCRIPT_PAGE_COUNT. - bool mHasHadSlowScript : 1; - // Track what sorts of events we need to fire when thawed bool mNotifyIdleObserversIdleOnThaw : 1; bool mNotifyIdleObserversActiveOnThaw : 1; diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 4a984d294..dfd380fc2 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -625,7 +625,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSContext) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsJSContext) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobalObjectRef) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsJSContext) @@ -1356,9 +1355,20 @@ nsJSContext::RunCycleCollectorSlice() TimeStamp now = TimeStamp::Now(); // Only run a limited slice if we're within the max running time. - if (TimeBetween(gCCStats.mBeginTime, now) < kMaxICCDuration) { - float sliceMultiplier = std::max(TimeBetween(gCCStats.mEndSliceTime, now) / (float)kICCIntersliceDelay, 1.0f); - budget = js::SliceBudget(js::TimeBudget(kICCSliceBudget * sliceMultiplier)); + uint32_t runningTime = TimeBetween(gCCStats.mBeginTime, now); + if (runningTime < kMaxICCDuration) { + // Try to make up for a delay in running this slice. + float sliceDelayMultiplier = TimeBetween(gCCStats.mEndSliceTime, now) / (float)kICCIntersliceDelay; + float delaySliceBudget = kICCSliceBudget * sliceDelayMultiplier; + + // Increase slice budgets up to |maxLaterSlice| as we approach + // half way through the ICC, to avoid large sync CCs. + float percentToHalfDone = std::min(2.0f * runningTime / kMaxICCDuration, 1.0f); + const float maxLaterSlice = 40.0f; + float laterSliceBudget = maxLaterSlice * percentToHalfDone; + + budget = js::SliceBudget(js::TimeBudget(std::max({delaySliceBudget, + laterSliceBudget, (float)kICCSliceBudget}))); } } } @@ -2618,7 +2628,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSArgArray) tmp->ReleaseJSObjects(); NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsJSArgArray) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsJSArgArray) diff --git a/dom/base/nsJSTimeoutHandler.cpp b/dom/base/nsJSTimeoutHandler.cpp index 8736cd1dd..ce5d58385 100644 --- a/dom/base/nsJSTimeoutHandler.cpp +++ b/dom/base/nsJSTimeoutHandler.cpp @@ -151,7 +151,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsJSScriptTimeoutHandler) if (tmp->mFunction) { NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFunction) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS } NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END diff --git a/dom/base/nsNodeUtils.cpp b/dom/base/nsNodeUtils.cpp index ecea95dc1..75d408151 100644 --- a/dom/base/nsNodeUtils.cpp +++ b/dom/base/nsNodeUtils.cpp @@ -297,6 +297,16 @@ nsNodeUtils::LastRelease(nsINode* aNode) NodeWillBeDestroyed, (aNode)); } + if (aNode->IsElement()) { + Element* elem = aNode->AsElement(); + FragmentOrElement::nsDOMSlots* domSlots = + static_cast<FragmentOrElement::nsDOMSlots*>(slots); + for (auto iter = domSlots->mRegisteredIntersectionObservers.Iter(); !iter.Done(); iter.Next()) { + DOMIntersectionObserver* observer = iter.Key(); + observer->UnlinkTarget(*elem); + } + } + delete slots; aNode->mSlots = nullptr; } diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index 709c7aa56..c1b732258 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -1582,7 +1582,6 @@ nsObjectLoadingContent::MaybeRewriteYoutubeEmbed(nsIURI* aURI, nsIURI* aBaseURI, } } - // If we're pref'd off, return after telemetry has been logged. if (!Preferences::GetBool(kPrefYoutubeRewrite)) { return; } diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp index 4b4ce7885..d45a2c975 100644 --- a/dom/base/nsRange.cpp +++ b/dom/base/nsRange.cpp @@ -351,7 +351,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsRange) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mEndParent) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRoot) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSelection) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsRange) diff --git a/dom/base/nsScriptLoader.cpp b/dom/base/nsScriptLoader.cpp index 0eb5bbf31..1e23d6c5f 100644 --- a/dom/base/nsScriptLoader.cpp +++ b/dom/base/nsScriptLoader.cpp @@ -353,7 +353,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsModuleScript) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLoader) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsModuleScript) diff --git a/dom/base/nsWrapperCache.cpp b/dom/base/nsWrapperCache.cpp index b91d86598..c5993fe7b 100644 --- a/dom/base/nsWrapperCache.cpp +++ b/dom/base/nsWrapperCache.cpp @@ -133,7 +133,7 @@ nsWrapperCache::CheckCCWrapperTraversal(void* aScriptObjectHolder, // see through the COM layer, so we use a suppression to help it. JS::AutoSuppressGCAnalysis suppress; - aTracer->Traverse(aScriptObjectHolder, callback); + aTracer->TraverseNativeAndJS(aScriptObjectHolder, callback); MOZ_ASSERT(callback.mFound, "Cycle collection participant didn't traverse to preserved " "wrapper! This will probably crash."); diff --git a/dom/base/nsWrapperCache.h b/dom/base/nsWrapperCache.h index 3c69a7ec4..56cae89ed 100644 --- a/dom/base/nsWrapperCache.h +++ b/dom/base/nsWrapperCache.h @@ -331,8 +331,7 @@ private: * causes between the native object and the JS object, so it is important that * any native object that supports preserving of its wrapper * traces/traverses/unlinks the cached JS object (see - * NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER, - * NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS and + * NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER and * NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER). */ enum { WRAPPER_BIT_PRESERVED = 1 << 0 }; @@ -383,7 +382,6 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsWrapperCache, NS_WRAPPERCACHE_IID) NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER \ NS_IMPL_CYCLE_COLLECTION_UNLINK_END \ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \ - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS \ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END \ NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(_class) @@ -395,7 +393,6 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsWrapperCache, NS_WRAPPERCACHE_IID) NS_IMPL_CYCLE_COLLECTION_UNLINK_END \ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \ NS_IMPL_CYCLE_COLLECTION_TRAVERSE(__VA_ARGS__) \ - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS \ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END \ NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(_class) diff --git a/dom/bindings/CallbackObject.cpp b/dom/bindings/CallbackObject.cpp index 7c7d2c6b4..bb01c804c 100644 --- a/dom/bindings/CallbackObject.cpp +++ b/dom/bindings/CallbackObject.cpp @@ -37,7 +37,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CallbackObject) NS_IMPL_CYCLE_COLLECTION_UNLINK(mIncumbentGlobal) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CallbackObject) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIncumbentGlobal) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(CallbackObject) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 7a6668687..cb93e4897 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -14994,7 +14994,6 @@ class CGJSImplClass(CGBindingImplClass): NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(${ifaceName}) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mImpl) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(${ifaceName}) NS_IMPL_CYCLE_COLLECTING_ADDREF(${ifaceName}) diff --git a/dom/bindings/Exceptions.cpp b/dom/bindings/Exceptions.cpp index a3f807688..8ace37051 100644 --- a/dom/bindings/Exceptions.cpp +++ b/dom/bindings/Exceptions.cpp @@ -305,7 +305,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(JSStackFrame) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCaller) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAsyncCaller) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(JSStackFrame) NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mStack) diff --git a/dom/bindings/SimpleGlobalObject.cpp b/dom/bindings/SimpleGlobalObject.cpp index 6ac397019..88710f7d9 100644 --- a/dom/bindings/SimpleGlobalObject.cpp +++ b/dom/bindings/SimpleGlobalObject.cpp @@ -29,8 +29,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(SimpleGlobalObject) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(SimpleGlobalObject) - - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS tmp->TraverseHostObjectURIs(cb); NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index e3406fc02..a750c69b0 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -1047,7 +1047,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CanvasRenderingContext2D) ImplCycleCollectionTraverse(cb, info.mElement, "Hit region fallback element"); } } - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(CanvasRenderingContext2D) @@ -1106,6 +1105,7 @@ CanvasRenderingContext2D::CanvasRenderingContext2D(layers::LayersBackend aCompos , mIsCapturedFrameInvalid(false) , mPathTransformWillUpdate(false) , mInvalidateCount(0) + , mWriteOnly(false) // == !origin-clean { sNumLivingContexts++; @@ -2563,7 +2563,8 @@ CanvasRenderingContext2D::CreatePattern(const CanvasImageSource& aSource, // nullptr and set CORSUsed to true for passing the security check in // CanvasUtils::DoDrawImageSecurityCheck(). RefPtr<CanvasPattern> pat = - new CanvasPattern(this, srcSurf, repeatMode, nullptr, false, true); + new CanvasPattern(this, srcSurf, repeatMode, nullptr, + imgBitmap.IsWriteOnly(), true); return pat.forget(); } @@ -4953,6 +4954,10 @@ CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage, aError.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } + + if (canvas->IsWriteOnly()) { + SetWriteOnly(); + } } else if (aImage.IsImageBitmap()) { ImageBitmap& imageBitmap = aImage.GetAsImageBitmap(); srcSurf = imageBitmap.PrepareForDrawTarget(mTarget); @@ -4961,6 +4966,10 @@ CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage, return; } + if (imageBitmap.IsWriteOnly()) { + SetWriteOnly(); + } + imgSize = gfx::IntSize(imageBitmap.Width(), imageBitmap.Height()); } else { @@ -5675,9 +5684,8 @@ CanvasRenderingContext2D::GetImageData(JSContext* aCx, double aSx, // Check only if we have a canvas element; if we were created with a docshell, // then it's special internal use. - if (mCanvasElement && mCanvasElement->IsWriteOnly() && - !nsContentUtils::IsCallerChrome()) - { + if (IsWriteOnly() || + (mCanvasElement && mCanvasElement->IsWriteOnly() && !nsContentUtils::IsCallerChrome())) { // XXX ERRMSG we need to report an error to developers here! (bug 329026) aError.Throw(NS_ERROR_DOM_SECURITY_ERR); return nullptr; diff --git a/dom/canvas/CanvasRenderingContext2D.h b/dom/canvas/CanvasRenderingContext2D.h index 848b3ee08..46758ec88 100644 --- a/dom/canvas/CanvasRenderingContext2D.h +++ b/dom/canvas/CanvasRenderingContext2D.h @@ -40,6 +40,7 @@ class SourceSurface; namespace dom { class HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap; typedef HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap CanvasImageSource; +class ImageBitmap; class ImageData; class StringOrCanvasGradientOrCanvasPattern; class OwningStringOrCanvasGradientOrCanvasPattern; @@ -1151,6 +1152,19 @@ protected: friend struct CanvasBidiProcessor; friend class CanvasDrawObserver; + friend class ImageBitmap; + + // For the origin-clean algorithm (mWriteOnly == !origin-clean) + // See https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html + void SetWriteOnly() { + mWriteOnly = true; + } + + bool IsWriteOnly() const { + return mWriteOnly; + } + + bool mWriteOnly; }; } // namespace dom diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp index e45cdfc6f..6efe1b318 100644 --- a/dom/canvas/ImageBitmap.cpp +++ b/dom/canvas/ImageBitmap.cpp @@ -351,29 +351,27 @@ CheckSecurityForHTMLElements(const nsLayoutUtils::SurfaceFromElementResult& aRes */ template<class HTMLElementType> static already_AddRefed<SourceSurface> -GetSurfaceFromElement(nsIGlobalObject* aGlobal, HTMLElementType& aElement, ErrorResult& aRv) +GetSurfaceFromElement(nsIGlobalObject* aGlobal, HTMLElementType& aElement, + bool* aWriteOnly, ErrorResult& aRv) { nsLayoutUtils::SurfaceFromElementResult res = nsLayoutUtils::SurfaceFromElement(&aElement, nsLayoutUtils::SFE_WANT_FIRST_FRAME); - // check origin-clean - if (!CheckSecurityForHTMLElements(res)) { - aRv.Throw(NS_ERROR_DOM_SECURITY_ERR); - return nullptr; - } - RefPtr<SourceSurface> surface = res.GetSourceSurface(); if (NS_WARN_IF(!surface)) { - aRv.Throw(NS_ERROR_NOT_AVAILABLE); + aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return nullptr; } + + // Check origin-clean and pass back + *aWriteOnly = !CheckSecurityForHTMLElements(res); return surface.forget(); } /* - * The specification doesn't allow to create an ImegeBitmap from a vector image. + * The specification doesn't allow to create an ImageBitmap from a vector image. * This function is used to check if the given HTMLImageElement contains a * raster image. */ @@ -398,7 +396,7 @@ HasRasterImage(HTMLImageElement& aImageEl) } ImageBitmap::ImageBitmap(nsIGlobalObject* aGlobal, layers::Image* aData, - bool aIsPremultipliedAlpha /* = true */) + bool aWriteOnly, bool aIsPremultipliedAlpha /* = true */) : mParent(aGlobal) , mData(aData) , mSurface(nullptr) @@ -406,6 +404,7 @@ ImageBitmap::ImageBitmap(nsIGlobalObject* aGlobal, layers::Image* aData, , mPictureRect(0, 0, aData->GetSize().width, aData->GetSize().height) , mIsPremultipliedAlpha(aIsPremultipliedAlpha) , mIsCroppingAreaOutSideOfSourceImage(false) + , mWriteOnly(aWriteOnly) { MOZ_ASSERT(aData, "aData is null in ImageBitmap constructor."); } @@ -698,6 +697,7 @@ ImageBitmap::ToCloneData() const RefPtr<SourceSurface> surface = mData->GetAsSourceSurface(); result->mSurface = surface->GetDataSurface(); MOZ_ASSERT(result->mSurface); + result->mWriteOnly = mWriteOnly; return Move(result); } @@ -708,7 +708,7 @@ ImageBitmap::CreateFromCloneData(nsIGlobalObject* aGlobal, { RefPtr<layers::Image> data = CreateImageFromSurface(aData->mSurface); - RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data, + RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data, aData->mWriteOnly, aData->mIsPremultipliedAlpha); ret->mIsCroppingAreaOutSideOfSourceImage = @@ -724,11 +724,8 @@ ImageBitmap::CreateFromOffscreenCanvas(nsIGlobalObject* aGlobal, OffscreenCanvas& aOffscreenCanvas, ErrorResult& aRv) { - // Check origin-clean. - if (aOffscreenCanvas.IsWriteOnly()) { - aRv.Throw(NS_ERROR_DOM_SECURITY_ERR); - return nullptr; - } + // Check origin-clean + bool writeOnly = aOffscreenCanvas.IsWriteOnly(); nsLayoutUtils::SurfaceFromElementResult res = nsLayoutUtils::SurfaceFromOffscreenCanvas(&aOffscreenCanvas, @@ -744,7 +741,7 @@ ImageBitmap::CreateFromOffscreenCanvas(nsIGlobalObject* aGlobal, RefPtr<layers::Image> data = CreateImageFromSurface(surface); - RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data); + RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data, writeOnly); return ret.forget(); } @@ -757,16 +754,19 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, HTMLImageElement& aImageEl aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return nullptr; } - + // Check if the image element is a bitmap (e.g. it's a vector graphic) or not. if (!HasRasterImage(aImageEl)) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return nullptr; } + bool writeOnly = true; + // Get the SourceSurface out from the image element and then do security // checking. - RefPtr<SourceSurface> surface = GetSurfaceFromElement(aGlobal, aImageEl, aRv); + RefPtr<SourceSurface> surface = GetSurfaceFromElement(aGlobal, aImageEl, + &writeOnly, aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr; @@ -780,7 +780,7 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, HTMLImageElement& aImageEl return nullptr; } - RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data); + RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data, writeOnly); // Set the picture rectangle. if (ret && aCropRect.isSome()) { @@ -812,13 +812,13 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, HTMLVideoElement& aVideoEl return nullptr; } + bool writeOnly = true; + // Check security. nsCOMPtr<nsIPrincipal> principal = aVideoEl.GetCurrentVideoPrincipal(); bool CORSUsed = aVideoEl.GetCORSMode() != CORS_NONE; - if (!CheckSecurityForHTMLElements(false, CORSUsed, principal)) { - aRv.Throw(NS_ERROR_DOM_SECURITY_ERR); - return nullptr; - } + + writeOnly = !CheckSecurityForHTMLElements(false, CORSUsed, principal); // Create ImageBitmap. ImageContainer *container = aVideoEl.GetImageContainer(); @@ -834,7 +834,7 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, HTMLVideoElement& aVideoEl aRv.Throw(NS_ERROR_NOT_AVAILABLE); return nullptr; } - RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data); + RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data, writeOnly); // Set the picture rectangle. if (ret && aCropRect.isSome()) { @@ -856,12 +856,18 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, HTMLCanvasElement& aCanvas return nullptr; } - RefPtr<SourceSurface> surface = GetSurfaceFromElement(aGlobal, aCanvasEl, aRv); + bool writeOnly = true; + + RefPtr<SourceSurface> surface = GetSurfaceFromElement(aGlobal, aCanvasEl, &writeOnly, aRv); if (NS_WARN_IF(aRv.Failed())) { return nullptr; } + if (!writeOnly) { + writeOnly = aCanvasEl.IsWriteOnly(); + } + // Crop the source surface if needed. RefPtr<SourceSurface> croppedSurface; IntRect cropRect = aCropRect.valueOr(IntRect()); @@ -874,8 +880,7 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, HTMLCanvasElement& aCanvas aCropRect.isSome()) { // The _surface_ must be a DataSourceSurface. MOZ_ASSERT(surface->GetType() == SurfaceType::DATA, - "The snapshot SourceSurface from WebGL rendering contest is not \ - DataSourceSurface."); + "The snapshot SourceSurface from WebGL rendering contest is not DataSourceSurface."); RefPtr<DataSourceSurface> dataSurface = surface->GetDataSurface(); croppedSurface = CropAndCopyDataSourceSurface(dataSurface, cropRect); cropRect.MoveTo(0, 0); @@ -897,7 +902,7 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, HTMLCanvasElement& aCanvas return nullptr; } - RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data); + RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data, writeOnly); // Set the picture rectangle. if (ret && aCropRect.isSome()) { @@ -958,9 +963,12 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, ImageData& aImageData, return nullptr; } - // Create an ImageBimtap. + // Create an ImageBitmap. // ImageData's underlying data is not alpha-premultiplied. - RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data, false); + RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, + data, + false /* write-only */, + false /* alpha-premult */); // The cropping information has been handled in the CreateImageFromRawData() // function. @@ -975,11 +983,8 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, ImageData& aImageData, ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, CanvasRenderingContext2D& aCanvasCtx, const Maybe<IntRect>& aCropRect, ErrorResult& aRv) { - // Check origin-clean. - if (aCanvasCtx.GetCanvas()->IsWriteOnly()) { - aRv.Throw(NS_ERROR_DOM_SECURITY_ERR); - return nullptr; - } + // Check origin-clean + bool writeOnly = aCanvasCtx.GetCanvas()->IsWriteOnly() || aCanvasCtx.IsWriteOnly(); RefPtr<SourceSurface> surface = aCanvasCtx.GetSurfaceSnapshot(); @@ -1001,7 +1006,7 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, CanvasRenderingContext2D& return nullptr; } - RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data); + RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data, writeOnly); // Set the picture rectangle. if (ret && aCropRect.isSome()) { @@ -1024,7 +1029,10 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, ImageBitmap& aImageBitmap, } RefPtr<layers::Image> data = aImageBitmap.mData; - RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, data, aImageBitmap.mIsPremultipliedAlpha); + RefPtr<ImageBitmap> ret = new ImageBitmap(aGlobal, + data, + aImageBitmap.mWriteOnly, + aImageBitmap.mIsPremultipliedAlpha); // Set the picture rectangle. if (ret && aCropRect.isSome()) { @@ -1295,7 +1303,7 @@ private: } // Create ImageBitmap object. - RefPtr<ImageBitmap> imageBitmap = new ImageBitmap(mGlobalObject, data); + RefPtr<ImageBitmap> imageBitmap = new ImageBitmap(mGlobalObject, data, false /* write-only */); // Set mIsCroppingAreaOutSideOfSourceImage. imageBitmap->SetIsCroppingAreaOutSideOfSourceImage(sourceSize, originalCropRect); @@ -1391,7 +1399,7 @@ private: } // Create ImageBitmap object. - RefPtr<ImageBitmap> imageBitmap = new ImageBitmap(mGlobalObject, data); + RefPtr<ImageBitmap> imageBitmap = new ImageBitmap(mGlobalObject, data, false /* write-only */); // Set mIsCroppingAreaOutSideOfSourceImage. imageBitmap->SetIsCroppingAreaOutSideOfSourceImage(sourceSize, originalCropRect); @@ -1486,14 +1494,19 @@ ImageBitmap::ReadStructuredClone(JSContext* aCx, uint32_t picRectHeight_; uint32_t isPremultipliedAlpha_; uint32_t isCroppingAreaOutSideOfSourceImage_; + uint32_t writeOnly; + uint32_t dummy; if (!JS_ReadUint32Pair(aReader, &picRectX_, &picRectY_) || !JS_ReadUint32Pair(aReader, &picRectWidth_, &picRectHeight_) || !JS_ReadUint32Pair(aReader, &isPremultipliedAlpha_, - &isCroppingAreaOutSideOfSourceImage_)) { + &isCroppingAreaOutSideOfSourceImage_) || + !JS_ReadUint32Pair(aReader, &writeOnly, &dummy)) { return nullptr; } + MOZ_ASSERT(dummy == 0); + int32_t picRectX = BitwiseCast<int32_t>(picRectX_); int32_t picRectY = BitwiseCast<int32_t>(picRectY_); int32_t picRectWidth = BitwiseCast<int32_t>(picRectWidth_); @@ -1512,7 +1525,7 @@ ImageBitmap::ReadStructuredClone(JSContext* aCx, { RefPtr<layers::Image> img = CreateImageFromSurface(aClonedSurfaces[aIndex]); RefPtr<ImageBitmap> imageBitmap = - new ImageBitmap(aParent, img, isPremultipliedAlpha_); + new ImageBitmap(aParent, img, !!writeOnly, isPremultipliedAlpha_); imageBitmap->mIsCroppingAreaOutSideOfSourceImage = isCroppingAreaOutSideOfSourceImage_; @@ -1547,6 +1560,7 @@ ImageBitmap::WriteStructuredClone(JSStructuredCloneWriter* aWriter, const uint32_t picRectHeight = BitwiseCast<uint32_t>(aImageBitmap->mPictureRect.height); const uint32_t isPremultipliedAlpha = aImageBitmap->mIsPremultipliedAlpha ? 1 : 0; const uint32_t isCroppingAreaOutSideOfSourceImage = aImageBitmap->mIsCroppingAreaOutSideOfSourceImage ? 1 : 0; + const uint32_t isWriteOnly = aImageBitmap->mWriteOnly ? 1 : 0; // Indexing the cloned surfaces and send the index to the receiver. uint32_t index = aClonedSurfaces.Length(); @@ -1555,7 +1569,8 @@ ImageBitmap::WriteStructuredClone(JSStructuredCloneWriter* aWriter, NS_WARN_IF(!JS_WriteUint32Pair(aWriter, picRectX, picRectY)) || NS_WARN_IF(!JS_WriteUint32Pair(aWriter, picRectWidth, picRectHeight)) || NS_WARN_IF(!JS_WriteUint32Pair(aWriter, isPremultipliedAlpha, - isCroppingAreaOutSideOfSourceImage))) { + isCroppingAreaOutSideOfSourceImage)) || + NS_WARN_IF(!JS_WriteUint32Pair(aWriter, isWriteOnly, 0))) { return false; } diff --git a/dom/canvas/ImageBitmap.h b/dom/canvas/ImageBitmap.h index 2119c6bda..25084b6ac 100644 --- a/dom/canvas/ImageBitmap.h +++ b/dom/canvas/ImageBitmap.h @@ -65,6 +65,7 @@ struct ImageBitmapCloneData final gfx::IntRect mPictureRect; bool mIsPremultipliedAlpha; bool mIsCroppingAreaOutSideOfSourceImage; + bool mWriteOnly; }; /* @@ -161,6 +162,10 @@ public: template<typename T> friend class MapDataIntoBufferSource; + bool IsWriteOnly() const { + return mWriteOnly; + } + // Mozilla Extensions ImageBitmapFormat FindOptimalFormat(const Optional<Sequence<ImageBitmapFormat>>& aPossibleFormats, @@ -197,6 +202,7 @@ protected: * CreateInternal(from ImageData) method. */ ImageBitmap(nsIGlobalObject* aGlobal, layers::Image* aData, + bool aWriteOnly, bool aIsPremultipliedAlpha = true); virtual ~ImageBitmap(); @@ -280,6 +286,12 @@ protected: */ bool mIsCroppingAreaOutSideOfSourceImage; + /* + * Write-Only flag is set to true if this image has been generated from a + * cross-origin source. This is the opposite of what is called 'origin-clean' + * in the spec. + */ + bool mWriteOnly; }; } // namespace dom diff --git a/dom/canvas/ImageBitmapRenderingContext.cpp b/dom/canvas/ImageBitmapRenderingContext.cpp index 8f5074554..ad313906a 100644 --- a/dom/canvas/ImageBitmapRenderingContext.cpp +++ b/dom/canvas/ImageBitmapRenderingContext.cpp @@ -63,6 +63,11 @@ ImageBitmapRenderingContext::TransferFromImageBitmap(ImageBitmap& aImageBitmap) if (!mImage) { return; } + + // Check if ImageBitmap is tainted, and if so flag the canvas tainted too. + if (aImageBitmap.IsWriteOnly() && mCanvasElement) { + mCanvasElement->SetWriteOnly(); + } Redraw(gfxRect(0, 0, mWidth, mHeight)); } diff --git a/dom/canvas/ImageData.cpp b/dom/canvas/ImageData.cpp index b201fa279..d24fbca95 100644 --- a/dom/canvas/ImageData.cpp +++ b/dom/canvas/ImageData.cpp @@ -29,7 +29,6 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(ImageData) NS_IMPL_CYCLE_COLLECTION_TRACE_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(ImageData) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ImageData) diff --git a/dom/canvas/WebGLContext.h b/dom/canvas/WebGLContext.h index 3ec307b00..8a20237ff 100644 --- a/dom/canvas/WebGLContext.h +++ b/dom/canvas/WebGLContext.h @@ -275,8 +275,9 @@ struct TexImageSourceAdapter final : public TexImageSource mPboOffset = pboOffset; } - TexImageSourceAdapter(const dom::ImageBitmap* imageBitmap, ErrorResult*) { + TexImageSourceAdapter(const dom::ImageBitmap* imageBitmap, ErrorResult* out_error) { mImageBitmap = imageBitmap; + mOut_error = out_error; } TexImageSourceAdapter(const dom::ImageData* imageData, ErrorResult*) { diff --git a/dom/canvas/WebGLTextureUpload.cpp b/dom/canvas/WebGLTextureUpload.cpp index 612d5889d..3839b5d5e 100644 --- a/dom/canvas/WebGLTextureUpload.cpp +++ b/dom/canvas/WebGLTextureUpload.cpp @@ -12,6 +12,7 @@ #include "GLBlitHelper.h" #include "GLContext.h" #include "mozilla/gfx/2D.h" +#include "mozilla/dom/HTMLCanvasElement.h" #include "mozilla/dom/HTMLVideoElement.h" #include "mozilla/dom/ImageBitmap.h" #include "mozilla/dom/ImageData.h" @@ -214,9 +215,18 @@ FromPboOffset(WebGLContext* webgl, const char* funcName, TexImageTarget target, static UniquePtr<webgl::TexUnpackBlob> FromImageBitmap(WebGLContext* webgl, const char* funcName, TexImageTarget target, uint32_t width, uint32_t height, uint32_t depth, - const dom::ImageBitmap& imageBitmap) + const dom::ImageBitmap& imageBitmap, ErrorResult* aRv) { + if (imageBitmap.IsWriteOnly()) { + aRv->Throw(NS_ERROR_DOM_SECURITY_ERR); + return nullptr; + } + UniquePtr<dom::ImageBitmapCloneData> cloneData = Move(imageBitmap.ToCloneData()); + if (!cloneData) { + return nullptr; + } + const RefPtr<gfx::DataSourceSurface> surf = cloneData->mSurface; //// @@ -293,6 +303,14 @@ WebGLContext::FromDomElem(const char* funcName, TexImageTarget target, uint32_t uint32_t height, uint32_t depth, const dom::Element& elem, ErrorResult* const out_error) { + if (elem.IsHTMLElement(nsGkAtoms::canvas)) {
+ const dom::HTMLCanvasElement* canvas = static_cast<const dom::HTMLCanvasElement*>(&elem);
+ if (canvas->IsWriteOnly()) {
+ out_error->Throw(NS_ERROR_DOM_SECURITY_ERR);
+ return nullptr;
+ }
+ }
+ uint32_t flags = nsLayoutUtils::SFE_WANT_IMAGE_SURFACE | nsLayoutUtils::SFE_USE_ELEMENT_SIZE_IF_VECTOR; @@ -412,7 +430,7 @@ WebGLContext::From(const char* funcName, TexImageTarget target, GLsizei rawWidth if (src.mImageBitmap) { return FromImageBitmap(this, funcName, target, width, height, depth, - *(src.mImageBitmap)); + *(src.mImageBitmap), src.mOut_error); } if (src.mImageData) { diff --git a/dom/canvas/test/test_imagebitmap.html b/dom/canvas/test/test_imagebitmap.html index b3d3c08ad..3b74970ac 100644 --- a/dom/canvas/test/test_imagebitmap.html +++ b/dom/canvas/test/test_imagebitmap.html @@ -270,13 +270,22 @@ function testSecurityErrors() { } function checkPromiseFailedWithSecurityError(p) { - return p.then( function(reason) { ok(false, "Did not get SecurityError with unclean source. ImageBitmap was created successfully."); }, - function(reason) { if (reason == "SecurityError: The operation is insecure.") { - ok(true, reason); - } - else { - ok(false, "Did not get SecurityError with unclean source. Error Message: " + reason); - }}); + return p.then(imageBitmap => { + ok(!!imageBitmap, "ImageBitmaps are always created"); + const context = document.createElement("canvas").getContext("2d"); + context.drawImage(imageBitmap, 0, 0); + try { + context.getImageData(0, 0, 1, 1); + ok(false, "Did not get SecurityError with unclean source. ImageBitmap was created successfully."); + } catch (ex) { + if (ex == "SecurityError: The operation is insecure.") { + ok(true, ex); + } + else { + ok(false, "Did not get SecurityError with unclean source. Error Message: " + ex); + } + } + }); } return Promise.all([ diff --git a/dom/console/Console.cpp b/dom/console/Console.cpp index ff5a92167..b174172e0 100755 --- a/dom/console/Console.cpp +++ b/dom/console/Console.cpp @@ -797,7 +797,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Console) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConsoleEventNotifier) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(Console) diff --git a/dom/events/DOMEventTargetHelper.cpp b/dom/events/DOMEventTargetHelper.cpp index f8a5227d6..dd9a01d8d 100644 --- a/dom/events/DOMEventTargetHelper.cpp +++ b/dom/events/DOMEventTargetHelper.cpp @@ -43,7 +43,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(DOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_DESCRIBE(DOMEventTargetHelper, tmp->mRefCnt.get()) } - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mListenerManager) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END diff --git a/dom/events/DataTransfer.cpp b/dom/events/DataTransfer.cpp index 45c72e662..40a0f42e6 100644 --- a/dom/events/DataTransfer.cpp +++ b/dom/events/DataTransfer.cpp @@ -57,7 +57,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DataTransfer) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mItems) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDragTarget) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDragImage) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(DataTransfer) diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp index f33bfa5a8..280e40ad5 100755 --- a/dom/events/Event.cpp +++ b/dom/events/Event.cpp @@ -231,7 +231,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Event) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPresContext) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mExplicitOriginalTarget) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END diff --git a/dom/events/JSEventHandler.cpp b/dom/events/JSEventHandler.cpp index 4b1b33313..b9e7c4d84 100644 --- a/dom/events/JSEventHandler.cpp +++ b/dom/events/JSEventHandler.cpp @@ -63,7 +63,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(JSEventHandler) NS_IMPL_CYCLE_COLLECTION_DESCRIBE(JSEventHandler, tmp->mRefCnt.get()) } NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mTypedHandler.Ptr()) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(JSEventHandler) diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp index 1791399b7..6294b0dc5 100644 --- a/dom/fetch/FetchDriver.cpp +++ b/dom/fetch/FetchDriver.cpp @@ -903,11 +903,7 @@ FetchDriver::SetRequestHeaders(nsIHttpChannel* aChannel) const AutoTArray<InternalHeaders::Entry, 5> headers; mRequest->Headers()->GetEntries(headers); - bool hasAccept = false; for (uint32_t i = 0; i < headers.Length(); ++i) { - if (!hasAccept && headers[i].mName.EqualsLiteral("accept")) { - hasAccept = true; - } if (headers[i].mValue.IsEmpty()) { aChannel->SetEmptyRequestHeader(headers[i].mName); } else { @@ -915,12 +911,6 @@ FetchDriver::SetRequestHeaders(nsIHttpChannel* aChannel) const } } - if (!hasAccept) { - aChannel->SetRequestHeader(NS_LITERAL_CSTRING("accept"), - NS_LITERAL_CSTRING("*/*"), - false /* merge */); - } - if (mRequest->ForceOriginHeader()) { nsAutoString origin; if (NS_SUCCEEDED(nsContentUtils::GetUTFOrigin(mPrincipal, origin))) { diff --git a/dom/filesystem/Directory.cpp b/dom/filesystem/Directory.cpp index 59c78fb2c..5e8a4a745 100644 --- a/dom/filesystem/Directory.cpp +++ b/dom/filesystem/Directory.cpp @@ -36,7 +36,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Directory) tmp->mFileSystem->Traverse(cb); } NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(Directory) diff --git a/dom/gamepad/GamepadServiceTest.cpp b/dom/gamepad/GamepadServiceTest.cpp index a6fde58f0..89429b52a 100644 --- a/dom/gamepad/GamepadServiceTest.cpp +++ b/dom/gamepad/GamepadServiceTest.cpp @@ -35,7 +35,6 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(GamepadServiceTest) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(GamepadServiceTest, DOMEventTargetHelper) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END diff --git a/dom/geolocation/nsGeolocation.cpp b/dom/geolocation/nsGeolocation.cpp index 244018ee8..846e7fff4 100644 --- a/dom/geolocation/nsGeolocation.cpp +++ b/dom/geolocation/nsGeolocation.cpp @@ -7,7 +7,6 @@ #include "nsXULAppAPI.h" #include "mozilla/dom/ContentChild.h" -#include "mozilla/Telemetry.h" #include "mozilla/UniquePtr.h" #include "nsGeolocation.h" @@ -70,7 +69,6 @@ class nsGeolocationRequest final GeoPositionCallback aCallback, GeoPositionErrorCallback aErrorCallback, UniquePtr<PositionOptions>&& aOptions, - uint8_t aProtocolType, bool aWatchPositionRequest = false, int32_t aWatchId = 0); @@ -119,7 +117,6 @@ class nsGeolocationRequest final int32_t mWatchId; bool mShutdown; nsCOMPtr<nsIContentPermissionRequester> mRequester; - uint8_t mProtocolType; }; static UniquePtr<PositionOptions> @@ -287,7 +284,6 @@ nsGeolocationRequest::nsGeolocationRequest(Geolocation* aLocator, GeoPositionCallback aCallback, GeoPositionErrorCallback aErrorCallback, UniquePtr<PositionOptions>&& aOptions, - uint8_t aProtocolType, bool aWatchPositionRequest, int32_t aWatchId) : mIsWatchPositionRequest(aWatchPositionRequest), @@ -296,8 +292,7 @@ nsGeolocationRequest::nsGeolocationRequest(Geolocation* aLocator, mOptions(Move(aOptions)), mLocator(aLocator), mWatchId(aWatchId), - mShutdown(false), - mProtocolType(aProtocolType) + mShutdown(false) { if (nsCOMPtr<nsPIDOMWindowInner> win = do_QueryReferent(mLocator->GetOwner())) { @@ -949,8 +944,7 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Geolocation, mPendingRequests) Geolocation::Geolocation() -: mProtocolType(ProtocolType::OTHER) -, mLastWatchId(0) +: mLastWatchId(0) { } @@ -982,23 +976,6 @@ Geolocation::Init(nsPIDOMWindowInner* aContentDom) nsCOMPtr<nsIURI> uri; nsresult rv = mPrincipal->GetURI(getter_AddRefs(uri)); NS_ENSURE_SUCCESS(rv, rv); - - if (uri) { - bool isHttp; - rv = uri->SchemeIs("http", &isHttp); - NS_ENSURE_SUCCESS(rv, rv); - - bool isHttps; - rv = uri->SchemeIs("https", &isHttps); - NS_ENSURE_SUCCESS(rv, rv); - - // Store the protocol to send via telemetry later. - if (isHttp) { - mProtocolType = ProtocolType::HTTP; - } else if (isHttps) { - mProtocolType = ProtocolType::HTTPS; - } - } } // If no aContentDom was passed into us, we are being used @@ -1185,7 +1162,7 @@ Geolocation::GetCurrentPosition(GeoPositionCallback callback, RefPtr<nsGeolocationRequest> request = new nsGeolocationRequest(this, Move(callback), Move(errorCallback), - Move(options), static_cast<uint8_t>(mProtocolType), + Move(options), false); if (!sGeoEnabled) { @@ -1263,7 +1240,7 @@ Geolocation::WatchPosition(GeoPositionCallback aCallback, RefPtr<nsGeolocationRequest> request = new nsGeolocationRequest(this, Move(aCallback), Move(aErrorCallback), Move(aOptions), - static_cast<uint8_t>(mProtocolType), true, *aRv); + true, *aRv); if (!sGeoEnabled) { nsCOMPtr<nsIRunnable> ev = new RequestAllowEvent(false, request); diff --git a/dom/geolocation/nsGeolocation.h b/dom/geolocation/nsGeolocation.h index 0bc527e34..0bcc587e4 100644 --- a/dom/geolocation/nsGeolocation.h +++ b/dom/geolocation/nsGeolocation.h @@ -202,12 +202,6 @@ private: // where the content was loaded from nsCOMPtr<nsIPrincipal> mPrincipal; - // the protocols we want to measure - enum class ProtocolType: uint8_t { OTHER, HTTP, HTTPS }; - - // the protocol used to load the content - ProtocolType mProtocolType; - // owning back pointer. RefPtr<nsGeolocationService> mService; diff --git a/dom/html/HTMLCanvasElement.cpp b/dom/html/HTMLCanvasElement.cpp index 527135a80..a01795d9e 100644 --- a/dom/html/HTMLCanvasElement.cpp +++ b/dom/html/HTMLCanvasElement.cpp @@ -1000,7 +1000,7 @@ HTMLCanvasElement::GetSize() } bool -HTMLCanvasElement::IsWriteOnly() +HTMLCanvasElement::IsWriteOnly() const { return mWriteOnly; } diff --git a/dom/html/HTMLCanvasElement.h b/dom/html/HTMLCanvasElement.h index 746fab198..e77db6ff1 100644 --- a/dom/html/HTMLCanvasElement.h +++ b/dom/html/HTMLCanvasElement.h @@ -224,9 +224,9 @@ public: nsIntSize GetSize(); /** - * Determine whether the canvas is write-only. + * Determine whether the canvas is write-only (tainted). */ - bool IsWriteOnly(); + bool IsWriteOnly() const; /** * Force the canvas to be write-only. diff --git a/dom/html/HTMLFormControlsCollection.cpp b/dom/html/HTMLFormControlsCollection.cpp index d91a6b5de..77fafae99 100644 --- a/dom/html/HTMLFormControlsCollection.cpp +++ b/dom/html/HTMLFormControlsCollection.cpp @@ -134,7 +134,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(HTMLFormControlsCollection) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(HTMLFormControlsCollection) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNameLookupTable) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(HTMLFormControlsCollection) NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER diff --git a/dom/html/HTMLFormElement.cpp b/dom/html/HTMLFormElement.cpp index 0393ed3e0..6bea19a2b 100644 --- a/dom/html/HTMLFormElement.cpp +++ b/dom/html/HTMLFormElement.cpp @@ -51,7 +51,6 @@ #include "nsIWebProgress.h" #include "nsIDocShell.h" #include "nsIPrompt.h" -#include "nsISecurityUITelemetry.h" #include "nsIStringBundle.h" // radio buttons @@ -954,8 +953,6 @@ HTMLFormElement::DoSecureToInsecureSubmitCheck(nsIURI* aActionURL, return rv; } *aCancelSubmit = (buttonPressed == 1); - uint32_t telemetryBucket = - nsISecurityUITelemetry::WARNING_CONFIRM_POST_TO_INSECURE_FROM_SECURE; return NS_OK; } diff --git a/dom/html/HTMLImageElement.cpp b/dom/html/HTMLImageElement.cpp index 4b2e7a07b..fab1cdef4 100644 --- a/dom/html/HTMLImageElement.cpp +++ b/dom/html/HTMLImageElement.cpp @@ -1345,8 +1345,6 @@ HTMLImageElement::FlushUseCounters() nsCOMPtr<imgIContainer> container; request->GetImage(getter_AddRefs(container)); - - static_cast<image::Image*>(container.get())->ReportUseCounters(); } } // namespace dom diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 6171e1766..050d1ac69 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -1037,14 +1037,6 @@ void HTMLMediaElement::ShutdownDecoder() void HTMLMediaElement::AbortExistingLoads() { -#ifdef MOZ_EME - // If there is no existing decoder then we don't have anything to - // report. This prevents reporting the initial load from an - // empty video element as a failed EME load. - if (mDecoder) { - ReportEMETelemetry(); - } -#endif // Abort any already-running instance of the resource selection algorithm. mLoadWaitStatus = NOT_WAITING; @@ -1900,7 +1892,6 @@ NS_IMETHODIMP HTMLMediaElement::GetCurrentTime(double* aCurrentTime) void HTMLMediaElement::FastSeek(double aTime, ErrorResult& aRv) { - LOG(LogLevel::Debug, ("Reporting telemetry VIDEO_FASTSEEK_USED")); RefPtr<Promise> tobeDropped = Seek(aTime, SeekTarget::PrevSyncPoint, aRv); } @@ -3154,10 +3145,6 @@ HTMLMediaElement::~HTMLMediaElement() if (mProgressTimer) { StopProgress(); } - if (mVideoDecodeSuspendTimer) { - mVideoDecodeSuspendTimer->Cancel(); - mVideoDecodeSuspendTimer = nullptr; - } if (mSrcStream) { EndSrcMediaStreamPlayback(); } @@ -3648,191 +3635,6 @@ nsresult HTMLMediaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParen return rv; } -/* static */ -void HTMLMediaElement::VideoDecodeSuspendTimerCallback(nsITimer* aTimer, void* aClosure) -{ - MOZ_ASSERT(NS_IsMainThread()); - auto element = static_cast<HTMLMediaElement*>(aClosure); - element->mVideoDecodeSuspendTime.Start(); - element->mVideoDecodeSuspendTimer = nullptr; -} - -void HTMLMediaElement::HiddenVideoStart() -{ - MOZ_ASSERT(NS_IsMainThread()); - mHiddenPlayTime.Start(); - if (mVideoDecodeSuspendTimer) { - // Already started, just keep it running. - return; - } - mVideoDecodeSuspendTimer = do_CreateInstance("@mozilla.org/timer;1"); - mVideoDecodeSuspendTimer->InitWithNamedFuncCallback( - VideoDecodeSuspendTimerCallback, this, - MediaPrefs::MDSMSuspendBackgroundVideoDelay(), nsITimer::TYPE_ONE_SHOT, - "HTMLMediaElement::VideoDecodeSuspendTimerCallback"); -} - -void HTMLMediaElement::HiddenVideoStop() -{ - MOZ_ASSERT(NS_IsMainThread()); - mHiddenPlayTime.Pause(); - mVideoDecodeSuspendTime.Pause(); - if (!mVideoDecodeSuspendTimer) { - return; - } - mVideoDecodeSuspendTimer->Cancel(); - mVideoDecodeSuspendTimer = nullptr; -} - -#ifdef MOZ_EME -void -HTMLMediaElement::ReportEMETelemetry() -{ - // Report telemetry for EME videos when a page is unloaded. - NS_ASSERTION(NS_IsMainThread(), "Should be on main thread."); - if (mIsEncrypted && Preferences::GetBool("media.eme.enabled")) { - LOG(LogLevel::Debug, ("%p VIDEO_EME_PLAY_SUCCESS = %s", - this, mLoadedDataFired ? "true" : "false")); - } -} -#endif - -void -HTMLMediaElement::ReportTelemetry() -{ - // Report telemetry for videos when a page is unloaded. We - // want to know data on what state the video is at when - // the user has exited. - enum UnloadedState { - ENDED = 0, - PAUSED = 1, - STALLED = 2, - SEEKING = 3, - OTHER = 4 - }; - - UnloadedState state = OTHER; - if (Seeking()) { - state = SEEKING; - } - else if (Ended()) { - state = ENDED; - } - else if (Paused()) { - state = PAUSED; - } - else { - // For buffering we check if the current playback position is at the end - // of a buffered range, within a margin of error. We also consider to be - // buffering if the last frame status was buffering and the ready state is - // HAVE_CURRENT_DATA to account for times where we are in a buffering state - // regardless of what actual data we have buffered. - bool stalled = false; - RefPtr<TimeRanges> ranges = Buffered(); - const double errorMargin = 0.05; - double t = CurrentTime(); - TimeRanges::index_type index = ranges->Find(t, errorMargin); - ErrorResult ignore; - stalled = index != TimeRanges::NoIndex && - (ranges->End(index, ignore) - t) < errorMargin; - stalled |= mDecoder && NextFrameStatus() == MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_BUFFERING && - mReadyState == HTMLMediaElement::HAVE_CURRENT_DATA; - if (stalled) { - state = STALLED; - } - } - - LOG(LogLevel::Debug, ("%p VIDEO_UNLOAD_STATE = %d", this, state)); - - FrameStatisticsData data; - - if (HTMLVideoElement* vid = HTMLVideoElement::FromContentOrNull(this)) { - FrameStatistics* stats = vid->GetFrameStatistics(); - if (stats) { - data = stats->GetFrameStatisticsData(); - if (data.mParsedFrames) { - MOZ_ASSERT(data.mDroppedFrames <= data.mParsedFrames); - // Dropped frames <= total frames, so 'percentage' cannot be higher than - // 100 and therefore can fit in a uint32_t (that Telemetry takes). - uint32_t percentage = 100 * data.mDroppedFrames / data.mParsedFrames; - LOG(LogLevel::Debug, - ("Reporting telemetry DROPPED_FRAMES_IN_VIDEO_PLAYBACK")); - } - } - } - - if (mMediaInfo.HasVideo() && - mMediaInfo.mVideo.mImage.height > 0) { - // We have a valid video. - double playTime = mPlayTime.Total(); - double hiddenPlayTime = mHiddenPlayTime.Total(); - double videoDecodeSuspendTime = mVideoDecodeSuspendTime.Total(); - - LOG(LogLevel::Debug, ("%p VIDEO_PLAY_TIME_MS = %f", this, playTime)); - - LOG(LogLevel::Debug, ("%p VIDEO_HIDDEN_PLAY_TIME_MS = %f", this, hiddenPlayTime)); - - if (playTime > 0.0) { - // We have actually played something -> Report some valid-video telemetry. - - // Keyed by audio+video or video alone, and by a resolution range. - nsCString key(mMediaInfo.HasAudio() ? "AV," : "V,"); - static const struct { int32_t mH; const char* mRes; } sResolutions[] = { - { 240, "0<h<=240" }, - { 480, "240<h<=480" }, - { 576, "480<h<=576" }, - { 720, "576<h<=720" }, - { 1080, "720<h<=1080" }, - { 2160, "1080<h<=2160" } - }; - const char* resolution = "h>2160"; - int32_t height = mMediaInfo.mVideo.mImage.height; - for (const auto& res : sResolutions) { - if (height <= res.mH) { - resolution = res.mRes; - break; - } - } - key.AppendASCII(resolution); - - uint32_t hiddenPercentage = uint32_t(hiddenPlayTime / playTime * 100.0 + 0.5); - LOG(LogLevel::Debug, ("%p VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE = %u, keys: '%s' and 'All'", - this, hiddenPercentage, key.get())); - - uint32_t videoDecodeSuspendPercentage = - uint32_t(videoDecodeSuspendTime / playTime * 100.0 + 0.5); - LOG(LogLevel::Debug, ("%p VIDEO_INFERRED_DECODE_SUSPEND_PERCENTAGE = %u, keys: '%s' and 'All'", - this, videoDecodeSuspendPercentage, key.get())); - - if (data.mInterKeyframeCount != 0) { - uint32_t average_ms = - uint32_t(std::min<uint64_t>(double(data.mInterKeyframeSum_us) - / double(data.mInterKeyframeCount) - / 1000.0 - + 0.5, - UINT32_MAX)); - LOG(LogLevel::Debug, ("%p VIDEO_INTER_KEYFRAME_AVERAGE_MS = %u, keys: '%s' and 'All'", - this, average_ms, key.get())); - - uint32_t max_ms = - uint32_t(std::min<uint64_t>((data.mInterKeyFrameMax_us + 500) / 1000, - UINT32_MAX)); - LOG(LogLevel::Debug, ("%p VIDEO_INTER_KEYFRAME_MAX_MS = %u, keys: '%s' and 'All'", - this, max_ms, key.get())); - } else { - // Here, we have played *some* of the video, but didn't get more than 1 - // keyframe. Report '0' if we have played for longer than the video- - // decode-suspend delay (showing recovery would be difficult). - uint32_t suspendDelay_ms = MediaPrefs::MDSMSuspendBackgroundVideoDelay(); - if (uint32_t(playTime * 1000.0) > suspendDelay_ms) { - LOG(LogLevel::Debug, ("%p VIDEO_INTER_KEYFRAME_MAX_MS = 0 (only 1 keyframe), keys: '%s' and 'All'", - this, key.get())); - } - } - } - } -} - void HTMLMediaElement::UnbindFromTree(bool aDeep, bool aNullParent) { @@ -5312,19 +5114,6 @@ nsresult HTMLMediaElement::DispatchAsyncEvent(const nsAString& aName) nsCOMPtr<nsIRunnable> event = new nsAsyncEventRunner(aName, this); NS_DispatchToMainThread(event); - if ((aName.EqualsLiteral("play") || aName.EqualsLiteral("playing"))) { - mPlayTime.Start(); - if (IsHidden()) { - HiddenVideoStart(); - } - } else if (aName.EqualsLiteral("waiting")) { - mPlayTime.Pause(); - HiddenVideoStop(); - } else if (aName.EqualsLiteral("pause")) { - mPlayTime.Pause(); - HiddenVideoStop(); - } - return NS_OK; } @@ -5450,11 +5239,6 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendE UpdateSrcMediaStreamPlaying(); UpdateAudioChannelPlayingState(); if (aPauseElement) { - ReportTelemetry(); -#ifdef MOZ_EME - ReportEMETelemetry(); -#endif - #ifdef MOZ_EME // For EME content, we may force destruction of the CDM client (and CDM // instance if this is the last client for that CDM instance) and @@ -5506,13 +5290,6 @@ bool HTMLMediaElement::IsBeingDestroyed() void HTMLMediaElement::NotifyOwnerDocumentActivityChanged() { bool visible = !IsHidden(); - if (visible) { - // Visible -> Just pause hidden play time (no-op if already paused). - HiddenVideoStop(); - } else if (mPlayTime.IsStarted()) { - // Not visible, play time is running -> Start hidden play time if needed. - HiddenVideoStart(); - } if (mDecoder && !IsBeingDestroyed()) { mDecoder->NotifyOwnerActivityChanged(visible); @@ -6288,18 +6065,10 @@ HTMLMediaElement::OnVisibilityChange(Visibility aNewVisibility) break; } case Visibility::APPROXIMATELY_NONVISIBLE: { - if (mPlayTime.IsStarted()) { - // Not visible, play time is running -> Start hidden play time if needed. - HiddenVideoStart(); - } - mDecoder->NotifyOwnerActivityChanged(false); break; } case Visibility::APPROXIMATELY_VISIBLE: { - // Visible -> Just pause hidden play time (no-op if already paused). - HiddenVideoStop(); - mDecoder->NotifyOwnerActivityChanged(true); break; } diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h index af944a318..899e8449a 100644 --- a/dom/html/HTMLMediaElement.h +++ b/dom/html/HTMLMediaElement.h @@ -1195,29 +1195,6 @@ protected: return isPaused; } - /** - * Video has been playing while hidden and, if feature was enabled, would - * trigger suspending decoder. - * Used to track hidden-video-decode-suspend telemetry. - */ - static void VideoDecodeSuspendTimerCallback(nsITimer* aTimer, void* aClosure); - /** - * Video is now both: playing and hidden. - * Used to track hidden-video telemetry. - */ - void HiddenVideoStart(); - /** - * Video is not playing anymore and/or has become visible. - * Used to track hidden-video telemetry. - */ - void HiddenVideoStop(); - -#ifdef MOZ_EME - void ReportEMETelemetry(); -#endif - - void ReportTelemetry(); - // Check the permissions for audiochannel. bool CheckAudioChannelPermissions(const nsAString& aType); @@ -1484,9 +1461,6 @@ protected: // Timer used for updating progress events. nsCOMPtr<nsITimer> mProgressTimer; - // Timer used to simulate video-suspend. - nsCOMPtr<nsITimer> mVideoDecodeSuspendTimer; - #ifdef MOZ_EME // Encrypted Media Extension media keys. RefPtr<MediaKeys> mMediaKeys; @@ -1688,65 +1662,7 @@ protected: // before attaching to the DOM tree. bool mUnboundFromTree = false; -public: - // Helper class to measure times for MSE telemetry stats - class TimeDurationAccumulator - { - public: - TimeDurationAccumulator() - : mCount(0) - {} - void Start() - { - if (IsStarted()) { - return; - } - mStartTime = TimeStamp::Now(); - } - void Pause() - { - if (!IsStarted()) { - return; - } - mSum += (TimeStamp::Now() - mStartTime); - mCount++; - mStartTime = TimeStamp(); - } - bool IsStarted() const - { - return !mStartTime.IsNull(); - } - double Total() const - { - if (!IsStarted()) { - return mSum.ToSeconds(); - } - // Add current running time until now, but keep it running. - return (mSum + (TimeStamp::Now() - mStartTime)).ToSeconds(); - } - uint32_t Count() const - { - if (!IsStarted()) { - return mCount; - } - // Count current run in this report, without increasing the stored count. - return mCount + 1; - } - private: - TimeStamp mStartTime; - TimeDuration mSum; - uint32_t mCount; - }; private: - // Total time a video has spent playing. - TimeDurationAccumulator mPlayTime; - - // Total time a video has spent playing while hidden. - TimeDurationAccumulator mHiddenPlayTime; - - // Total time a video has (or would have) spent in video-decode-suspend mode. - TimeDurationAccumulator mVideoDecodeSuspendTime; - // Indicates if user has interacted with the element. // Used to block autoplay when disabled. bool mHasUserInteraction; diff --git a/dom/html/TextTrackManager.cpp b/dom/html/TextTrackManager.cpp index cc14858b6..7f9d32794 100644 --- a/dom/html/TextTrackManager.cpp +++ b/dom/html/TextTrackManager.cpp @@ -118,7 +118,6 @@ TextTrackManager::TextTrackManager(HTMLMediaElement *aMediaElement) , mTimeMarchesOnDispatched(false) , mUpdateCueDisplayDispatched(false) , performedTrackSelection(false) - , mCueTelemetryReported(false) , mShutdown(false) { nsISupports* parentObject = @@ -170,7 +169,6 @@ TextTrackManager::AddTextTrack(TextTrackKind aKind, const nsAString& aLabel, mTextTracks->AddTextTrack(aKind, aLabel, aLanguage, aMode, aReadyState, aTextTrackSource, CompareTextTracks(mMediaElement)); AddCues(track); - ReportTelemetryForTrack(track); if (aTextTrackSource == TextTrackSource::Track) { RefPtr<nsIRunnable> task = @@ -190,7 +188,6 @@ TextTrackManager::AddTextTrack(TextTrack* aTextTrack) WEBVTT_LOG("%p AddTextTrack TextTrack %p",this, aTextTrack); mTextTracks->AddTextTrack(aTextTrack, CompareTextTracks(mMediaElement)); AddCues(aTextTrack); - ReportTelemetryForTrack(aTextTrack); if (aTextTrack->GetTextTrackSource() == TextTrackSource::Track) { RefPtr<nsIRunnable> task = @@ -309,7 +306,6 @@ TextTrackManager::NotifyCueAdded(TextTrackCue& aCue) mNewCues->AddCue(aCue); } DispatchTimeMarchesOn(); - ReportTelemetryForCue(); } void @@ -827,17 +823,5 @@ TextTrackManager::NotifyReset() mLastTimeMarchesOnCalled = 0.0; } -void -TextTrackManager::ReportTelemetryForTrack(TextTrack* aTextTrack) const -{ -/* STUB */ -} - -void -TextTrackManager::ReportTelemetryForCue() -{ -/* STUB */ -} - } // namespace dom } // namespace mozilla diff --git a/dom/html/TextTrackManager.h b/dom/html/TextTrackManager.h index 4ad1a57a7..2375aa4bb 100644 --- a/dom/html/TextTrackManager.h +++ b/dom/html/TextTrackManager.h @@ -148,13 +148,6 @@ private: nsTArray<TextTrack*>& aTextTracks); bool TrackIsDefault(TextTrack* aTextTrack); - void ReportTelemetryForTrack(TextTrack* aTextTrack) const; - void ReportTelemetryForCue(); - - // If there is at least one cue has been added to the cue list once, we would - // report the usage of cue to Telemetry. - bool mCueTelemetryReported; - class ShutdownObserverProxy final : public nsIObserver { NS_DECL_ISUPPORTS diff --git a/dom/html/nsDOMStringMap.cpp b/dom/html/nsDOMStringMap.cpp index 42725bc6f..6d2bc424d 100644 --- a/dom/html/nsDOMStringMap.cpp +++ b/dom/html/nsDOMStringMap.cpp @@ -19,7 +19,6 @@ using namespace mozilla::dom; NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMStringMap) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMStringMap) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mElement) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END diff --git a/dom/html/nsGenericHTMLElement.h b/dom/html/nsGenericHTMLElement.h index 0635c27e1..24a7a3652 100644 --- a/dom/html/nsGenericHTMLElement.h +++ b/dom/html/nsGenericHTMLElement.h @@ -396,13 +396,6 @@ public: } NS_IMETHOD InsertAdjacentHTML(const nsAString& position, const nsAString& text) final override; - NS_IMETHOD ScrollIntoView(bool top, uint8_t _argc) final override { - if (!_argc) { - top = true; - } - mozilla::dom::Element::ScrollIntoView(top); - return NS_OK; - } NS_IMETHOD GetOffsetParent(nsIDOMElement** aOffsetParent) final override { mozilla::dom::Element* offsetParent = GetOffsetParent(); diff --git a/dom/html/nsTextEditorState.cpp b/dom/html/nsTextEditorState.cpp index 0b4cb1920..25be6016c 100644 --- a/dom/html/nsTextEditorState.cpp +++ b/dom/html/nsTextEditorState.cpp @@ -2255,7 +2255,11 @@ nsTextEditorState::UpdatePlaceholderText(bool aNotify) nsCOMPtr<nsIContent> content = do_QueryInterface(mTextCtrlElement); content->GetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, placeholderValue); - nsContentUtils::RemoveNewlines(placeholderValue); + if (mTextCtrlElement->IsTextArea()) { // <textarea>s preserve newlines... + nsContentUtils::PlatformToDOMLineBreaks(placeholderValue); + } else { // ...<input>s don't + nsContentUtils::RemoveNewlines(placeholderValue); + } NS_ASSERTION(mPlaceholderDiv->GetFirstChild(), "placeholder div has no child"); mPlaceholderDiv->GetFirstChild()->SetText(placeholderValue, aNotify); } diff --git a/dom/indexedDB/ActorsChild.cpp b/dom/indexedDB/ActorsChild.cpp index 3e8f97348..c4fcceb90 100644 --- a/dom/indexedDB/ActorsChild.cpp +++ b/dom/indexedDB/ActorsChild.cpp @@ -3456,6 +3456,8 @@ BackgroundCursorChild::RecvResponse(const CursorResponse& aResponse) RefPtr<IDBCursor> cursor; mStrongCursor.swap(cursor); + + RefPtr<IDBTransaction> transaction = mTransaction; switch (aResponse.type()) { case CursorResponse::Tnsresult: @@ -3486,7 +3488,7 @@ BackgroundCursorChild::RecvResponse(const CursorResponse& aResponse) MOZ_CRASH("Should never get here!"); } - mTransaction->OnRequestFinished(/* aActorDestroyedNormally */ true); + transaction->OnRequestFinished(/* aActorDestroyedNormally */ true); return true; } diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index 58c113058..38621cee3 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -4129,7 +4129,6 @@ GetDatabaseFileURL(nsIFile* aDatabaseFile, PersistenceType aPersistenceType, const nsACString& aGroup, const nsACString& aOrigin, - uint32_t aTelemetryId, nsIFileURL** aResult) { MOZ_ASSERT(aDatabaseFile); @@ -4161,18 +4160,10 @@ GetDatabaseFileURL(nsIFile* aDatabaseFile, nsAutoCString type; PersistenceTypeToText(aPersistenceType, type); - nsAutoCString telemetryFilenameClause; - if (aTelemetryId) { - telemetryFilenameClause.AssignLiteral("&telemetryFilename=indexedDB-"); - telemetryFilenameClause.AppendInt(aTelemetryId); - telemetryFilenameClause.AppendLiteral(".sqlite"); - } - rv = fileUrl->SetQuery(NS_LITERAL_CSTRING("persistenceType=") + type + NS_LITERAL_CSTRING("&group=") + aGroup + NS_LITERAL_CSTRING("&origin=") + aOrigin + - NS_LITERAL_CSTRING("&cache=private") + - telemetryFilenameClause); + NS_LITERAL_CSTRING("&cache=private")); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -4422,7 +4413,6 @@ CreateStorageConnection(nsIFile* aDBFile, PersistenceType aPersistenceType, const nsACString& aGroup, const nsACString& aOrigin, - uint32_t aTelemetryId, mozIStorageConnection** aConnection) { AssertIsOnIOThread(); @@ -4454,7 +4444,6 @@ CreateStorageConnection(nsIFile* aDBFile, aPersistenceType, aGroup, aOrigin, - aTelemetryId, getter_AddRefs(dbFileUrl)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -4890,7 +4879,6 @@ GetStorageConnection(nsIFile* aDatabaseFile, PersistenceType aPersistenceType, const nsACString& aGroup, const nsACString& aOrigin, - uint32_t aTelemetryId, mozIStorageConnection** aConnection) { MOZ_ASSERT(!NS_IsMainThread()); @@ -4918,7 +4906,6 @@ GetStorageConnection(nsIFile* aDatabaseFile, aPersistenceType, aGroup, aOrigin, - aTelemetryId, getter_AddRefs(dbFileUrl)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -4955,7 +4942,6 @@ GetStorageConnection(const nsAString& aDatabaseFilePath, PersistenceType aPersistenceType, const nsACString& aGroup, const nsACString& aOrigin, - uint32_t aTelemetryId, mozIStorageConnection** aConnection) { MOZ_ASSERT(!NS_IsMainThread()); @@ -4974,7 +4960,6 @@ GetStorageConnection(const nsAString& aDatabaseFilePath, aPersistenceType, aGroup, aOrigin, - aTelemetryId, aConnection); } @@ -6296,7 +6281,6 @@ private: const nsCString mId; const nsString mFilePath; uint32_t mActiveMutableFileCount; - const uint32_t mTelemetryId; const PersistenceType mPersistenceType; const bool mFileHandleDisabled; const bool mChromeWriteAccessAllowed; @@ -6313,7 +6297,6 @@ public: const Maybe<ContentParentId>& aOptionalContentParentId, const nsACString& aGroup, const nsACString& aOrigin, - uint32_t aTelemetryId, FullDatabaseMetadata* aMetadata, FileManager* aFileManager, already_AddRefed<DirectoryLock> aDirectoryLock, @@ -6372,12 +6355,6 @@ public: return mId; } - uint32_t - TelemetryId() const - { - return mTelemetryId; - } - PersistenceType Type() const { @@ -7673,8 +7650,6 @@ class OpenDatabaseOp final // cycles. VersionChangeOp* mVersionChangeOp; - uint32_t mTelemetryId; - public: OpenDatabaseOp(Factory* aFactory, already_AddRefed<ContentParent> aContentParent, @@ -10302,13 +10277,6 @@ typedef nsDataHashtable<nsIDHashKey, DatabaseLoggingInfo*> StaticAutoPtr<DatabaseLoggingInfoHashtable> gLoggingInfoHashtable; -typedef nsDataHashtable<nsUint32HashKey, uint32_t> TelemetryIdHashtable; - -StaticAutoPtr<TelemetryIdHashtable> gTelemetryIdHashtable; - -// Protects all reads and writes to gTelemetryIdHashtable. -StaticAutoPtr<Mutex> gTelemetryIdMutex; - #ifdef DEBUG StaticRefPtr<DEBUGThreadSlower> gDEBUGThreadSlower; @@ -10404,88 +10372,6 @@ DecreaseBusyCount() } } -uint32_t -TelemetryIdForFile(nsIFile* aFile) -{ - // May be called on any thread! - - MOZ_ASSERT(aFile); - MOZ_ASSERT(gTelemetryIdMutex); - - // The storage directory is structured like this: - // - // <profile>/storage/<persistence>/<origin>/idb/<filename>.sqlite - // - // For the purposes of this function we're only concerned with the - // <persistence>, <origin>, and <filename> pieces. - - nsString filename; - MOZ_ALWAYS_SUCCEEDS(aFile->GetLeafName(filename)); - - // Make sure we were given a database file. - NS_NAMED_LITERAL_STRING(sqliteExtension, ".sqlite"); - - MOZ_ASSERT(StringEndsWith(filename, sqliteExtension)); - - filename.Truncate(filename.Length() - sqliteExtension.Length()); - - // Get the "idb" directory. - nsCOMPtr<nsIFile> idbDirectory; - MOZ_ALWAYS_SUCCEEDS(aFile->GetParent(getter_AddRefs(idbDirectory))); - - DebugOnly<nsString> idbLeafName; - MOZ_ASSERT(NS_SUCCEEDED(idbDirectory->GetLeafName(idbLeafName))); - MOZ_ASSERT(static_cast<nsString&>(idbLeafName).EqualsLiteral("idb")); - - // Get the <origin> directory. - nsCOMPtr<nsIFile> originDirectory; - MOZ_ALWAYS_SUCCEEDS( - idbDirectory->GetParent(getter_AddRefs(originDirectory))); - - nsString origin; - MOZ_ALWAYS_SUCCEEDS(originDirectory->GetLeafName(origin)); - - // Any databases in these directories are owned by the application and should - // not have their filenames masked. Hopefully they also appear in the - // Telemetry.cpp whitelist. - if (origin.EqualsLiteral("chrome") || - origin.EqualsLiteral("moz-safe-about+home")) { - return 0; - } - - // Get the <persistence> directory. - nsCOMPtr<nsIFile> persistenceDirectory; - MOZ_ALWAYS_SUCCEEDS( - originDirectory->GetParent(getter_AddRefs(persistenceDirectory))); - - nsString persistence; - MOZ_ALWAYS_SUCCEEDS(persistenceDirectory->GetLeafName(persistence)); - - NS_NAMED_LITERAL_STRING(separator, "*"); - - uint32_t hashValue = HashString(persistence + separator + - origin + separator + - filename); - - MutexAutoLock lock(*gTelemetryIdMutex); - - if (!gTelemetryIdHashtable) { - gTelemetryIdHashtable = new TelemetryIdHashtable(); - } - - uint32_t id; - if (!gTelemetryIdHashtable->Get(hashValue, &id)) { - static uint32_t sNextId = 1; - - // We're locked, no need for atomics. - id = sNextId++; - - gTelemetryIdHashtable->Put(hashValue, id); - } - - return id; -} - } // namespace /******************************************************************************* @@ -12265,7 +12151,6 @@ ConnectionPool::GetOrCreateConnection(const Database* aDatabase, aDatabase->Type(), aDatabase->Group(), aDatabase->Origin(), - aDatabase->TelemetryId(), getter_AddRefs(storageConnection)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -14134,7 +14019,6 @@ Database::Database(Factory* aFactory, const Maybe<ContentParentId>& aOptionalContentParentId, const nsACString& aGroup, const nsACString& aOrigin, - uint32_t aTelemetryId, FullDatabaseMetadata* aMetadata, FileManager* aFileManager, already_AddRefed<DirectoryLock> aDirectoryLock, @@ -14151,7 +14035,6 @@ Database::Database(Factory* aFactory, , mId(aMetadata->mDatabaseId) , mFilePath(aMetadata->mFilePath) , mActiveMutableFileCount(0) - , mTelemetryId(aTelemetryId) , mPersistenceType(aMetadata->mCommonMetadata.persistenceType()) , mFileHandleDisabled(aFileHandleDisabled) , mChromeWriteAccessAllowed(aChromeWriteAccessAllowed) @@ -17391,8 +17274,7 @@ FileManager::InitDirectory(nsIFile* aDirectory, nsIFile* aDatabaseFile, PersistenceType aPersistenceType, const nsACString& aGroup, - const nsACString& aOrigin, - uint32_t aTelemetryId) + const nsACString& aOrigin) { AssertIsOnIOThread(); MOZ_ASSERT(aDirectory); @@ -17464,7 +17346,6 @@ FileManager::InitDirectory(nsIFile* aDirectory, aPersistenceType, aGroup, aOrigin, - aTelemetryId, getter_AddRefs(connection)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -17648,11 +17529,6 @@ QuotaClient::QuotaClient() { AssertIsOnBackgroundThread(); MOZ_ASSERT(!sInstance, "We expect this to be a singleton!"); - MOZ_ASSERT(!gTelemetryIdMutex); - - // Always create this so that later access to gTelemetryIdHashtable can be - // properly synchronized. - gTelemetryIdMutex = new Mutex("IndexedDB gTelemetryIdMutex"); sInstance = this; } @@ -17661,14 +17537,8 @@ QuotaClient::~QuotaClient() { AssertIsOnBackgroundThread(); MOZ_ASSERT(sInstance == this, "We expect this to be a singleton!"); - MOZ_ASSERT(gTelemetryIdMutex); MOZ_ASSERT(!mMaintenanceThreadPool); - // No one else should be able to touch gTelemetryIdHashtable now that the - // QuotaClient has gone away. - gTelemetryIdHashtable = nullptr; - gTelemetryIdMutex = nullptr; - sInstance = nullptr; } @@ -17942,8 +17812,7 @@ QuotaClient::InitOrigin(PersistenceType aPersistenceType, initInfo.mDatabaseFile, aPersistenceType, aGroup, - aOrigin, - TelemetryIdForFile(initInfo.mDatabaseFile)); + aOrigin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -19036,7 +18905,6 @@ DatabaseMaintenance::PerformMaintenanceOnDatabase() mPersistenceType, mGroup, mOrigin, - TelemetryIdForFile(databaseFile), getter_AddRefs(connection)); if (NS_WARN_IF(NS_FAILED(rv))) { return; @@ -21653,7 +21521,6 @@ OpenDatabaseOp::OpenDatabaseOp(Factory* aFactory, , mMetadata(new FullDatabaseMetadata(aParams.metadata())) , mRequestedVersion(aParams.metadata().version()) , mVersionChangeOp(nullptr) - , mTelemetryId(0) { if (mContentParent) { // This is a little scary but it looks safe to call this off the main thread @@ -21762,8 +21629,6 @@ OpenDatabaseOp::DoDatabaseWork() return rv; } - mTelemetryId = TelemetryIdForFile(dbFile); - #ifdef DEBUG nsString databaseFilePath; rv = dbFile->GetPath(databaseFilePath); @@ -21794,7 +21659,6 @@ OpenDatabaseOp::DoDatabaseWork() persistenceType, mGroup, mOrigin, - mTelemetryId, getter_AddRefs(connection)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; @@ -22677,7 +22541,6 @@ OpenDatabaseOp::EnsureDatabaseActor() mOptionalContentParentId, mGroup, mOrigin, - mTelemetryId, mMetadata, mFileManager, mDirectoryLock.forget(), diff --git a/dom/indexedDB/FileManager.h b/dom/indexedDB/FileManager.h index da917f431..0fba46ec0 100644 --- a/dom/indexedDB/FileManager.h +++ b/dom/indexedDB/FileManager.h @@ -58,8 +58,7 @@ public: nsIFile* aDatabaseFile, PersistenceType aPersistenceType, const nsACString& aGroup, - const nsACString& aOrigin, - uint32_t aTelemetryId); + const nsACString& aOrigin); static nsresult GetUsage(nsIFile* aDirectory, uint64_t* aUsage); diff --git a/dom/indexedDB/IDBCursor.cpp b/dom/indexedDB/IDBCursor.cpp index 7ae35e981..af88742f0 100644 --- a/dom/indexedDB/IDBCursor.cpp +++ b/dom/indexedDB/IDBCursor.cpp @@ -948,7 +948,6 @@ NS_INTERFACE_MAP_END NS_IMPL_CYCLE_COLLECTION_CLASS(IDBCursor) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBCursor) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRequest) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceObjectStore) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceIndex) diff --git a/dom/indexedDB/IDBFactory.cpp b/dom/indexedDB/IDBFactory.cpp index 825d2ac36..c1ef6353d 100644 --- a/dom/indexedDB/IDBFactory.cpp +++ b/dom/indexedDB/IDBFactory.cpp @@ -865,7 +865,6 @@ NS_INTERFACE_MAP_END NS_IMPL_CYCLE_COLLECTION_CLASS(IDBFactory) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBFactory) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END diff --git a/dom/indexedDB/IDBIndex.cpp b/dom/indexedDB/IDBIndex.cpp index 657e744c9..af50926e6 100644 --- a/dom/indexedDB/IDBIndex.cpp +++ b/dom/indexedDB/IDBIndex.cpp @@ -652,7 +652,6 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBIndex) NS_IMPL_CYCLE_COLLECTION_TRACE_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBIndex) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mObjectStore) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END diff --git a/dom/indexedDB/IDBKeyRange.cpp b/dom/indexedDB/IDBKeyRange.cpp index 2de48a70c..e61c80617 100644 --- a/dom/indexedDB/IDBKeyRange.cpp +++ b/dom/indexedDB/IDBKeyRange.cpp @@ -239,7 +239,6 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(IDBKeyRange) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBKeyRange) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBKeyRange) diff --git a/dom/indexedDB/IDBObjectStore.cpp b/dom/indexedDB/IDBObjectStore.cpp index 8a0b292ad..756792741 100644 --- a/dom/indexedDB/IDBObjectStore.cpp +++ b/dom/indexedDB/IDBObjectStore.cpp @@ -1758,7 +1758,6 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBObjectStore) NS_IMPL_CYCLE_COLLECTION_TRACE_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBObjectStore) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTransaction) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIndexes) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDeletedIndexes) diff --git a/dom/indexedDB/IDBRequest.cpp b/dom/indexedDB/IDBRequest.cpp index 919d3adc7..e0e318059 100644 --- a/dom/indexedDB/IDBRequest.cpp +++ b/dom/indexedDB/IDBRequest.cpp @@ -417,8 +417,6 @@ IDBRequest::GetError(ErrorResult& aRv) NS_IMPL_CYCLE_COLLECTION_CLASS(IDBRequest) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBRequest, IDBWrapperCache) - // Don't need NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS because - // DOMEventTargetHelper does it for us. NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceAsObjectStore) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceAsIndex) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSourceAsCursor) diff --git a/dom/indexedDB/IDBWrapperCache.cpp b/dom/indexedDB/IDBWrapperCache.cpp index df62514c8..ccc2bb43e 100644 --- a/dom/indexedDB/IDBWrapperCache.cpp +++ b/dom/indexedDB/IDBWrapperCache.cpp @@ -18,8 +18,6 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(IDBWrapperCache) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBWrapperCache, DOMEventTargetHelper) - // Don't need NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS because - // DOMEventTargetHelper does it for us. NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBWrapperCache, diff --git a/dom/interfaces/html/nsIDOMHTMLElement.idl b/dom/interfaces/html/nsIDOMHTMLElement.idl index 63a1f9572..686475f04 100644 --- a/dom/interfaces/html/nsIDOMHTMLElement.idl +++ b/dom/interfaces/html/nsIDOMHTMLElement.idl @@ -58,7 +58,6 @@ interface nsIDOMHTMLElement : nsIDOMElement // CSSOM View - [optional_argc] void scrollIntoView([optional] in boolean top); readonly attribute nsIDOMElement offsetParent; readonly attribute long offsetTop; readonly attribute long offsetLeft; diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 417420ecb..79446151c 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -84,7 +84,6 @@ #include "mozilla/ScopeExit.h" #include "mozilla/Services.h" #include "mozilla/StaticPtr.h" -#include "mozilla/Telemetry.h" #include "mozilla/WebBrowserPersistDocumentParent.h" #include "mozilla/Unused.h" #include "nsAnonymousTemporaryFile.h" @@ -3364,17 +3363,6 @@ ContentParent::RecvIsSecureURI(const uint32_t& type, } bool -ContentParent::RecvAccumulateMixedContentHSTS(const URIParams& aURI, const bool& aActive) -{ - nsCOMPtr<nsIURI> ourURI = DeserializeURI(aURI); - if (!ourURI) { - return false; - } - nsMixedContentBlocker::AccumulateMixedContentHSTS(ourURI, aActive); - return true; -} - -bool ContentParent::RecvLoadURIExternal(const URIParams& uri, PBrowserParent* windowContext) { @@ -4764,19 +4752,3 @@ ContentParent::ForceTabPaint(TabParent* aTabParent, uint64_t aLayerObserverEpoch } ProcessHangMonitor::ForcePaint(mHangMonitorActor, aTabParent, aLayerObserverEpoch); } - -bool -ContentParent::RecvAccumulateChildHistogram( - InfallibleTArray<Accumulation>&& aAccumulations) -{ - /* STUB */ - return true; -} - -bool -ContentParent::RecvAccumulateChildKeyedHistogram( - InfallibleTArray<KeyedAccumulation>&& aAccumulations) -{ - /* STUB */ - return true; -} diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index abcea0b65..26b5c44ac 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -741,9 +741,6 @@ private: virtual bool RecvIsSecureURI(const uint32_t& aType, const URIParams& aURI, const uint32_t& aFlags, bool* aIsSecureURI) override; - virtual bool RecvAccumulateMixedContentHSTS(const URIParams& aURI, - const bool& aActive) override; - virtual bool DeallocPHalParent(PHalParent*) override; virtual bool @@ -1044,10 +1041,6 @@ private: virtual bool RecvDeleteGetFilesRequest(const nsID& aID) override; - virtual bool RecvAccumulateChildHistogram( - InfallibleTArray<Accumulation>&& aAccumulations) override; - virtual bool RecvAccumulateChildKeyedHistogram( - InfallibleTArray<KeyedAccumulation>&& aAccumulations) override; public: void SendGetFilesResponseAndForget(const nsID& aID, const GetFilesResponseResult& aResult); diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 9298f9d02..e8fb25aec 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -89,8 +89,6 @@ using mozilla::DataStorageType from "ipc/DataStorageIPCUtils.h"; using mozilla::DocShellOriginAttributes from "mozilla/ipc/BackgroundUtils.h"; using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h"; using struct mozilla::dom::FlyWebPublishOptions from "mozilla/dom/FlyWebPublishOptionsIPCSerializer.h"; -using mozilla::Telemetry::Accumulation from "mozilla/TelemetryComms.h"; -using mozilla::Telemetry::KeyedAccumulation from "mozilla/TelemetryComms.h"; union ChromeRegistryItem { @@ -658,8 +656,6 @@ parent: sync IsSecureURI(uint32_t type, URIParams uri, uint32_t flags) returns (bool isSecureURI); - async AccumulateMixedContentHSTS(URIParams uri, bool active); - sync GetLookAndFeelCache() returns (LookAndFeelInt[] lookAndFeelIntCache); @@ -1022,12 +1018,6 @@ parent: async UnstoreAndBroadcastBlobURLUnregistration(nsCString url); - /** - * Messages for communicating child Telemetry to the parent process - */ - async AccumulateChildHistogram(Accumulation[] accumulations); - async AccumulateChildKeyedHistogram(KeyedAccumulation[] accumulations); - sync GetA11yContentId() returns (uint32_t aContentId); both: diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 3fe94001e..e1355adee 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -176,7 +176,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(TabChildBase) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTabChildGlobal) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWebBrowserChrome) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END diff --git a/dom/locales/en-US/chrome/security/security.properties b/dom/locales/en-US/chrome/security/security.properties index 8efdb0a6d..2be56fb9d 100644 --- a/dom/locales/en-US/chrome/security/security.properties +++ b/dom/locales/en-US/chrome/security/security.properties @@ -85,3 +85,5 @@ BlockScriptWithWrongMimeType=Script from “%1$S” was blocked because of a dis # LOCALIZATION NOTE: Do not translate "data: URI". BlockTopLevelDataURINavigation=Navigation to toplevel data: URI not allowed (Blocked loading of: “%1$S”) + +BlockSubresourceFTP=Loading FTP subresource within http(s) page not allowed (Blocked loading of: “%1$S”) diff --git a/dom/media/DecoderTraits.cpp b/dom/media/DecoderTraits.cpp index f8cb4fd0e..6aa44f3e5 100644 --- a/dom/media/DecoderTraits.cpp +++ b/dom/media/DecoderTraits.cpp @@ -10,7 +10,6 @@ #include "nsCharSeparatedTokenizer.h" #include "nsMimeTypes.h" #include "mozilla/Preferences.h" -#include "mozilla/Telemetry.h" #include "OggDecoder.h" #include "OggDemuxer.h" @@ -85,22 +84,6 @@ DecoderTraits::IsWebMAudioType(const nsACString& aType) return aType.EqualsASCII("audio/webm"); } -static char const *const gHttpLiveStreamingTypes[] = { - // For m3u8. - // https://tools.ietf.org/html/draft-pantos-http-live-streaming-19#section-10 - "application/vnd.apple.mpegurl", - // Some sites serve these as the informal m3u type. - "application/x-mpegurl", - "audio/x-mpegurl", - nullptr -}; - -static bool -IsHttpLiveStreamingType(const nsACString& aType) -{ - return CodecListContains(gHttpLiveStreamingTypes, aType); -} - #ifdef MOZ_FMP4 static bool IsMP4SupportedType(const MediaContentType& aParsedType, @@ -247,10 +230,6 @@ CanHandleMediaType(const MediaContentType& aType, { MOZ_ASSERT(NS_IsMainThread()); - if (IsHttpLiveStreamingType(aType.GetMIMEType())) { - /* Telemetry STUB */ - } - if (aType.HaveCodecs()) { CanPlayStatus result = CanHandleCodecsType(aType, aDiagnostics); if (result == CANPLAY_NO || result == CANPLAY_YES) { diff --git a/dom/media/GraphDriver.cpp b/dom/media/GraphDriver.cpp index b60dfee9d..37c692a4b 100644 --- a/dom/media/GraphDriver.cpp +++ b/dom/media/GraphDriver.cpp @@ -629,7 +629,6 @@ AudioCallbackDriver::Init() cubeb_stream_params output; cubeb_stream_params input; uint32_t latency_frames; - bool firstStream = CubebUtils::GetFirstStream(); MOZ_ASSERT(!NS_IsMainThread(), "This is blocking and should never run on the main thread."); diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp index cf2266bf6..223c59c3b 100644 --- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -30,7 +30,6 @@ #include "mozilla/dom/VideoTrack.h" #include "mozilla/dom/VideoTrackList.h" #include "nsPrintfCString.h" -#include "mozilla/Telemetry.h" #include "GMPService.h" #include "Layers.h" #include "mozilla/layers/ShadowLayers.h" @@ -421,7 +420,6 @@ MediaDecoder::MediaDecoder(MediaDecoderOwner* aOwner) , INIT_CANONICAL(mPlaybackRateReliable, true) , INIT_CANONICAL(mDecoderPosition, 0) , INIT_CANONICAL(mIsVisible, !aOwner->IsHidden()) - , mTelemetryReported(false) { MOZ_COUNT_CTOR(MediaDecoder); MOZ_ASSERT(NS_IsMainThread()); @@ -841,41 +839,6 @@ MediaDecoder::MetadataLoaded(nsAutoPtr<MediaInfo> aInfo, // So we call Invalidate() after calling mOwner->MetadataLoaded to ensure // the media element has the latest dimensions. Invalidate(); - - EnsureTelemetryReported(); -} - -void -MediaDecoder::EnsureTelemetryReported() -{ - MOZ_ASSERT(NS_IsMainThread()); - - if (mTelemetryReported || !mInfo) { - // Note: sometimes we get multiple MetadataLoaded calls (for example - // for chained ogg). So we ensure we don't report duplicate results for - // these resources. - return; - } - - nsTArray<nsCString> codecs; - if (mInfo->HasAudio() && !mInfo->mAudio.GetAsAudioInfo()->mMimeType.IsEmpty()) { - codecs.AppendElement(mInfo->mAudio.GetAsAudioInfo()->mMimeType); - } - if (mInfo->HasVideo() && !mInfo->mVideo.GetAsVideoInfo()->mMimeType.IsEmpty()) { - codecs.AppendElement(mInfo->mVideo.GetAsVideoInfo()->mMimeType); - } - if (codecs.IsEmpty()) { - if (mResource->GetContentType().IsEmpty()) { - NS_WARNING("Somehow the resource's content type is empty"); - return; - } - codecs.AppendElement(nsPrintfCString("resource; %s", mResource->GetContentType().get())); - } - for (const nsCString& codec : codecs) { - DECODER_LOG("Telemetry MEDIA_CODEC_USED= '%s'", codec.get()); - } - - mTelemetryReported = true; } const char* diff --git a/dom/media/MediaDecoder.h b/dom/media/MediaDecoder.h index 7e93de044..05e88db8b 100644 --- a/dom/media/MediaDecoder.h +++ b/dom/media/MediaDecoder.h @@ -440,8 +440,6 @@ private: void SetCDMProxy(CDMProxy* aProxy); - void EnsureTelemetryReported(); - static bool IsOggEnabled(); static bool IsOpusEnabled(); static bool IsWaveEnabled(); @@ -852,8 +850,6 @@ private: // download has ended. Called on the main thread only. aStatus is // the result from OnStopRequest. void NotifyDownloadEnded(nsresult aStatus); - - bool mTelemetryReported; }; } // namespace mozilla diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 5bc1d95ef..2ed1956c9 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -1173,27 +1173,12 @@ StateObject::HandleShutdown() return SetState<ShutdownState>(); } -static void -ReportRecoveryTelemetry(const TimeStamp& aRecoveryStart, - const MediaInfo& aMediaInfo, - bool aIsHardwareAccelerated) -{ -/* STUB */ -} - void MediaDecoderStateMachine:: StateObject::HandleResumeVideoDecoding() { MOZ_ASSERT(mMaster->mVideoDecodeSuspended); - // Start counting recovery time from right now. - TimeStamp start = TimeStamp::Now(); - - // Local reference to mInfo, so that it will be copied in the lambda below. - auto& info = Info(); - bool hw = Reader()->VideoIsHardwareAccelerated(); - // Start video-only seek to the current time. SeekJob seekJob; @@ -1205,10 +1190,7 @@ StateObject::HandleResumeVideoDecoding() type, true /* aVideoOnly */); - SetState<SeekingState>(Move(seekJob), EventVisibility::Suppressed)->Then( - AbstractThread::MainThread(), __func__, - [start, info, hw](){ ReportRecoveryTelemetry(start, info, hw); }, - [](){}); + SetState<SeekingState>(Move(seekJob), EventVisibility::Suppressed); } void diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index 06e8b963b..773434710 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -32,6 +32,10 @@ using mozilla::layers::Image; using mozilla::layers::LayerManager; using mozilla::layers::LayersBackend; +// avoid redefined macro warning in unified builds +#undef LOG +#undef LOGV + static mozilla::LazyLogModule sFormatDecoderLog("MediaFormatReader"); mozilla::LazyLogModule gMediaDemuxerLog("MediaDemuxer"); diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index baaf45416..288f2e74d 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -2033,7 +2033,6 @@ MediaManager::GetUserMedia(nsPIDOMWindowInner* aWindow, } // Determine permissions early (while we still have a stack). - nsIURI* docURI = aWindow->GetDocumentURI(); if (!docURI) { return NS_ERROR_UNEXPECTED; @@ -2043,22 +2042,9 @@ MediaManager::GetUserMedia(nsPIDOMWindowInner* aWindow, Preferences::GetBool("media.navigator.permission.disabled", false); bool isHTTPS = false; docURI->SchemeIs("https", &isHTTPS); - nsCString host; - nsresult rv = docURI->GetHost(host); - // Test for some other schemes that ServiceWorker recognizes - bool isFile; - docURI->SchemeIs("file", &isFile); - bool isApp; - docURI->SchemeIs("app", &isApp); - // Same localhost check as ServiceWorkers uses - // (see IsOriginPotentiallyTrustworthy()) - bool isLocalhost = NS_SUCCEEDED(rv) && - (host.LowerCaseEqualsLiteral("localhost") || - host.LowerCaseEqualsLiteral("127.0.0.1") || - host.LowerCaseEqualsLiteral("::1")); nsCString origin; - rv = nsPrincipal::GetOriginForURI(docURI, origin); + nsresult rv = nsPrincipal::GetOriginForURI(docURI, origin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } diff --git a/dom/media/fmp4/MP4Demuxer.cpp b/dom/media/fmp4/MP4Demuxer.cpp index 5a637b003..ef68d5dca 100644 --- a/dom/media/fmp4/MP4Demuxer.cpp +++ b/dom/media/fmp4/MP4Demuxer.cpp @@ -16,9 +16,6 @@ #include "mp4_demuxer/Index.h" #include "nsPrintfCString.h" -// Used for telemetry -#include "mozilla/Telemetry.h" -#include "mp4_demuxer/AnnexB.h" #include "mp4_demuxer/H264.h" #include "nsAutoPtr.h" @@ -72,23 +69,10 @@ private: // Queued samples extracted by the demuxer, but not yet returned. RefPtr<MediaRawData> mQueuedSample; bool mNeedReIndex; - bool mNeedSPSForTelemetry; bool mIsH264 = false; }; -// Returns true if no SPS was found and search for it should continue. -bool -AccumulateSPSTelemetry(const MediaByteBuffer* aExtradata) -{ - // XXX: Do we still need this without telemetry? - mp4_demuxer::SPSData spsdata; - if (mp4_demuxer::H264::DecodeSPSFromExtraData(aExtradata, spsdata)) { - return false; - } - return true; -} - MP4Demuxer::MP4Demuxer(MediaResource* aResource) : mResource(aResource) , mStream(new mp4_demuxer::ResourceStream(aResource)) @@ -219,25 +203,10 @@ MP4TrackDemuxer::MP4TrackDemuxer(MP4Demuxer* aParent, EnsureUpToDateIndex(); // Force update of index VideoInfo* videoInfo = mInfo->GetAsVideoInfo(); - // Collect telemetry from h264 AVCC SPS. if (videoInfo && (mInfo->mMimeType.EqualsLiteral("video/mp4") || mInfo->mMimeType.EqualsLiteral("video/avc"))) { mIsH264 = true; - RefPtr<MediaByteBuffer> extraData = videoInfo->mExtraData; - mNeedSPSForTelemetry = AccumulateSPSTelemetry(extraData); - mp4_demuxer::SPSData spsdata; - if (mp4_demuxer::H264::DecodeSPSFromExtraData(extraData, spsdata) && - spsdata.pic_width > 0 && spsdata.pic_height > 0 && - mp4_demuxer::H264::EnsureSPSIsSane(spsdata)) { - videoInfo->mImage.width = spsdata.pic_width; - videoInfo->mImage.height = spsdata.pic_height; - videoInfo->mDisplay.width = spsdata.display_width; - videoInfo->mDisplay.height = spsdata.display_height; - } - } else { - // No SPS to be found. - mNeedSPSForTelemetry = false; } } @@ -364,15 +333,6 @@ MP4TrackDemuxer::GetSamples(int32_t aNumSamples) if (samples->mSamples.IsEmpty()) { return SamplesPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_END_OF_STREAM, __func__); } else { - for (const auto& sample : samples->mSamples) { - // Collect telemetry from h264 Annex B SPS. - if (mNeedSPSForTelemetry && mp4_demuxer::AnnexB::HasSPS(sample)) { - RefPtr<MediaByteBuffer> extradata = - mp4_demuxer::AnnexB::ExtractExtraData(sample); - mNeedSPSForTelemetry = AccumulateSPSTelemetry(extradata); - } - } - if (mNextKeyframeTime.isNothing() || samples->mSamples.LastElement()->mTime >= mNextKeyframeTime.value().ToMicroseconds()) { SetNextKeyFrameTime(); diff --git a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp index e1c326818..426e9f74b 100644 --- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp @@ -145,6 +145,8 @@ FFmpegLibWrapper::Link() AV_FUNC(avcodec_alloc_frame, (AV_FUNC_53 | AV_FUNC_54)) AV_FUNC(avcodec_get_frame_defaults, (AV_FUNC_53 | AV_FUNC_54)) AV_FUNC(avcodec_free_frame, AV_FUNC_54) + AV_FUNC(avcodec_send_packet, AV_FUNC_58) + AV_FUNC(avcodec_receive_frame, AV_FUNC_58) AV_FUNC(av_log_set_level, AV_FUNC_AVUTIL_ALL) AV_FUNC(av_malloc, AV_FUNC_AVUTIL_ALL) AV_FUNC(av_freep, AV_FUNC_AVUTIL_ALL) diff --git a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h index c6c43a4ae..b968edd32 100644 --- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h +++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h @@ -71,6 +71,10 @@ struct FFmpegLibWrapper // libavcodec v54 only void (*avcodec_free_frame)(AVFrame** frame); + // libavcodec v58 and later only + int (*avcodec_send_packet)(AVCodecContext* avctx, const AVPacket* avpkt); + int (*avcodec_receive_frame)(AVCodecContext* avctx, AVFrame* frame); + // libavutil void (*av_log_set_level)(int level); void* (*av_malloc)(size_t size); diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp index aec1e9136..f3101e44c 100644 --- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp @@ -174,12 +174,15 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecode(MediaRawData* aSample, bool* aGotFrame) uint8_t* inputData = const_cast<uint8_t*>(aSample->Data()); size_t inputSize = aSample->Size(); -#if LIBAVCODEC_VERSION_MAJOR >= 54 +#if LIBAVCODEC_VERSION_MAJOR >= 54 && LIBAVCODEC_VERSION_MAJOR < 58 if (inputSize && mCodecParser && (mCodecID == AV_CODEC_ID_VP8 -#if LIBAVCODEC_VERSION_MAJOR >= 55 +#if LIBAVCODEC_VERSION_MAJOR >= 55 && LIBAVCODEC_VERSION_MAJOR < 58 || mCodecID == AV_CODEC_ID_VP9 #endif - )) { + )) +#endif +#if LIBAVCODEC_VERSION_MAJOR >= 54 + { while (inputSize) { uint8_t* data = inputData; int size = inputSize; @@ -224,6 +227,48 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecode(MediaRawData* aSample, packet.flags = aSample->mKeyframe ? AV_PKT_FLAG_KEY : 0; packet.pos = aSample->mOffset; +#if LIBAVCODEC_VERSION_MAJOR >= 58 + packet.duration = aSample->mDuration; + int res = mLib->avcodec_send_packet(mCodecContext, &packet); + if (res < 0) { + // In theory, avcodec_send_packet could sent -EAGAIN should its internal + // buffers be full. In practice this can't happen as we only feed one frame + // at a time, and we immediately call avcodec_receive_frame right after. + FFMPEG_LOG("avcodec_send_packet error: %d", res); + return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR, + RESULT_DETAIL("avcodec_send_packet error: %d", res)); + } + + if (aGotFrame) { + *aGotFrame = false; + } + do { + if (!PrepareFrame()) { + NS_WARNING("FFmpeg h264 decoder failed to allocate frame."); + return MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__); + } + res = mLib->avcodec_receive_frame(mCodecContext, mFrame); + if (res == int(AVERROR_EOF)) { + return NS_ERROR_DOM_MEDIA_END_OF_STREAM; + } + if (res == AVERROR(EAGAIN)) { + return NS_OK; + } + if (res < 0) { + FFMPEG_LOG("avcodec_receive_frame error: %d", res); + return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR, + RESULT_DETAIL("avcodec_receive_frame error: %d", res)); + } + MediaResult rv = CreateImage(mFrame->pkt_pos, mFrame->pkt_pts, + mFrame->pkt_duration); + if (NS_FAILED(rv)) { + return rv; + } + if (aGotFrame) { + *aGotFrame = true; + } + } while (true); +#else // LibAV provides no API to retrieve the decoded sample's duration. // (FFmpeg >= 1.0 provides av_frame_get_pkt_duration) // As such we instead use a map using the dts as key that we will retrieve @@ -276,8 +321,21 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecode(MediaRawData* aSample, // against the map becoming extremely big. mDurationMap.Clear(); } + + MediaResult rv = CreateImage(aSample->mOffset, pts, duration); + if (NS_SUCCEEDED(rv) && aGotFrame) { + *aGotFrame = true; + } + return rv; +#endif +} + +MediaResult +FFmpegVideoDecoder<LIBAV_VER>::CreateImage(int64_t aOffset, int64_t aPts, + int64_t aDuration) +{ FFMPEG_LOG("Got one frame output with pts=%lld dts=%lld duration=%lld opaque=%lld", - pts, mFrame->pkt_dts, duration, mCodecContext->reordered_opaque); + aPts, mFrame->pkt_dts, aDuration, mCodecContext->reordered_opaque); VideoData::YCbCrBuffer b; b.mPlanes[0].mData = mFrame->data[0]; @@ -317,9 +375,9 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecode(MediaRawData* aSample, RefPtr<VideoData> v = VideoData::CreateAndCopyData(mInfo, mImageContainer, - aSample->mOffset, - pts, - duration, + aOffset, + aPts, + aDuration, b, !!mFrame->key_frame, -1, @@ -331,9 +389,6 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecode(MediaRawData* aSample, RESULT_DETAIL("image allocation error")); } mCallback->Output(v); - if (aGotFrame) { - *aGotFrame = true; - } return NS_OK; } diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h index 786df0da1..49a55e8a6 100644 --- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h +++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h @@ -49,6 +49,7 @@ private: MediaResult DoDecode(MediaRawData* aSample) override; MediaResult DoDecode(MediaRawData* aSample, bool* aGotFrame); MediaResult DoDecode(MediaRawData* aSample, uint8_t* aData, int aSize, bool* aGotFrame); + MediaResult CreateImage(int64_t aOffset, int64_t aPts, int64_t aDuration); void ProcessDrain() override; void ProcessFlush() override; void OutputDelayedFrames(); diff --git a/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp b/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp index 15e2e1097..e6dd29c6d 100644 --- a/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp +++ b/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp @@ -38,39 +38,6 @@ WMFMediaDataDecoder::Init() return InitPromise::CreateAndResolve(mMFTManager->GetType(), __func__); } -// A single telemetry sample is reported for each MediaDataDecoder object -// that has detected error or produced output successfully. -static void -SendTelemetry(unsigned long hr) -{ - // Collapse the error codes into a range of 0-0xff that can be viewed in - // telemetry histograms. For most MF_E_* errors, unique samples are used, - // retaining the least significant 7 or 8 bits. Other error codes are - // bucketed. - uint32_t sample; - if (SUCCEEDED(hr)) { - sample = 0; - } else if (hr < 0xc00d36b0) { - sample = 1; // low bucket - } else if (hr < 0xc00d3700) { - sample = hr & 0xffU; // MF_E_* - } else if (hr <= 0xc00d3705) { - sample = 0x80 + (hr & 0xfU); // more MF_E_* - } else if (hr < 0xc00d6d60) { - sample = 2; // mid bucket - } else if (hr <= 0xc00d6d78) { - sample = hr & 0xffU; // MF_E_TRANSFORM_* - } else { - sample = 3; // high bucket - } - - nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction( - [sample] { - /* Telemetry STUB */ - }); - NS_DispatchToMainThread(runnable); -} - void WMFMediaDataDecoder::Shutdown() { @@ -90,9 +57,6 @@ WMFMediaDataDecoder::ProcessShutdown() if (mMFTManager) { mMFTManager->Shutdown(); mMFTManager = nullptr; - if (!mRecordedError && mHasSuccessfulOutput) { - SendTelemetry(S_OK); - } } } @@ -124,10 +88,6 @@ WMFMediaDataDecoder::ProcessDecode(MediaRawData* aSample) NS_WARNING("MFTManager rejected sample"); mCallback->Error(MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR, RESULT_DETAIL("MFTManager::Input:%x", hr))); - if (!mRecordedError) { - SendTelemetry(hr); - mRecordedError = true; - } return; } @@ -143,7 +103,6 @@ WMFMediaDataDecoder::ProcessOutput() HRESULT hr = S_OK; while (SUCCEEDED(hr = mMFTManager->Output(mLastStreamOffset, output)) && output) { - mHasSuccessfulOutput = true; mCallback->Output(output); } if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) { @@ -152,10 +111,6 @@ WMFMediaDataDecoder::ProcessOutput() NS_WARNING("WMFMediaDataDecoder failed to output data"); mCallback->Error(MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR, RESULT_DETAIL("MFTManager::Output:%x", hr))); - if (!mRecordedError) { - SendTelemetry(hr); - mRecordedError = true; - } } } diff --git a/dom/media/platforms/wmf/WMFMediaDataDecoder.h b/dom/media/platforms/wmf/WMFMediaDataDecoder.h index 75571d61e..f869012e7 100644 --- a/dom/media/platforms/wmf/WMFMediaDataDecoder.h +++ b/dom/media/platforms/wmf/WMFMediaDataDecoder.h @@ -136,10 +136,6 @@ private: Atomic<bool> mIsFlushing; bool mIsShutDown; - - // For telemetry - bool mHasSuccessfulOutput = false; - bool mRecordedError = false; }; } // namespace mozilla diff --git a/dom/media/test/crashtests/1228484.html b/dom/media/test/crashtests/1228484.html deleted file mode 100644 index 2b2e9b0f9..000000000 --- a/dom/media/test/crashtests/1228484.html +++ /dev/null @@ -1,13 +0,0 @@ -<!DOCTYPE html> -<html> -<head> -<script> - -var htmlAudio = new Audio(URL.createObjectURL(new window.MediaSource())); - -(new window.AudioContext("ringer")).createMediaElementSource(htmlAudio); -(new window.AudioContext("alarm")).createMediaElementSource(htmlAudio); - -</script> -</head> -</html> diff --git a/dom/media/test/crashtests/crashtests.list b/dom/media/test/crashtests/crashtests.list index 496fe5ee5..e4f25ca8d 100644 --- a/dom/media/test/crashtests/crashtests.list +++ b/dom/media/test/crashtests/crashtests.list @@ -81,8 +81,6 @@ load 1157994.html load 1158427.html load 1185176.html load 1185192.html -load 1223670.html -load 1228484.html load 1304948.html load 1319486.html load 1291702.html diff --git a/dom/media/webaudio/AudioBuffer.cpp b/dom/media/webaudio/AudioBuffer.cpp index cb834f6a5..e7eba2d48 100644 --- a/dom/media/webaudio/AudioBuffer.cpp +++ b/dom/media/webaudio/AudioBuffer.cpp @@ -27,7 +27,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(AudioBuffer) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(AudioBuffer) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(AudioBuffer) diff --git a/dom/media/webaudio/AudioContext.cpp b/dom/media/webaudio/AudioContext.cpp index 85842c811..d58441309 100755 --- a/dom/media/webaudio/AudioContext.cpp +++ b/dom/media/webaudio/AudioContext.cpp @@ -179,23 +179,13 @@ AudioContext::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) AudioContext::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) { - return AudioContext::Constructor(aGlobal, - AudioChannelService::GetDefaultAudioChannel(), - aRv); -} - -/* static */ already_AddRefed<AudioContext> -AudioContext::Constructor(const GlobalObject& aGlobal, - AudioChannel aChannel, - ErrorResult& aRv) -{ nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports()); if (!window) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; } - RefPtr<AudioContext> object = new AudioContext(window, false, aChannel); + RefPtr<AudioContext> object = new AudioContext(window, false, AudioChannelService::GetDefaultAudioChannel()); aRv = object->Init(); if (NS_WARN_IF(aRv.Failed())) { return nullptr; diff --git a/dom/media/webaudio/AudioContext.h b/dom/media/webaudio/AudioContext.h index 069efa986..599debef8 100644 --- a/dom/media/webaudio/AudioContext.h +++ b/dom/media/webaudio/AudioContext.h @@ -151,12 +151,6 @@ public: static already_AddRefed<AudioContext> Constructor(const GlobalObject& aGlobal, ErrorResult& aRv); - // Constructor for regular AudioContext. A default audio channel is needed. - static already_AddRefed<AudioContext> - Constructor(const GlobalObject& aGlobal, - AudioChannel aChannel, - ErrorResult& aRv); - // Constructor for offline AudioContext static already_AddRefed<AudioContext> Constructor(const GlobalObject& aGlobal, diff --git a/dom/media/webaudio/AudioParam.cpp b/dom/media/webaudio/AudioParam.cpp index 6f5574993..c1a874264 100644 --- a/dom/media/webaudio/AudioParam.cpp +++ b/dom/media/webaudio/AudioParam.cpp @@ -22,7 +22,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(AudioParam) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(AudioParam) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNode) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(AudioParam) diff --git a/dom/media/webaudio/MediaBufferDecoder.cpp b/dom/media/webaudio/MediaBufferDecoder.cpp index 2ee11eacd..f3b75ca1a 100644 --- a/dom/media/webaudio/MediaBufferDecoder.cpp +++ b/dom/media/webaudio/MediaBufferDecoder.cpp @@ -44,7 +44,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(WebAudioDecodeJob) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOutput) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSuccessCallback) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFailureCallback) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(WebAudioDecodeJob) diff --git a/dom/media/webaudio/WaveShaperNode.cpp b/dom/media/webaudio/WaveShaperNode.cpp index d5c617dcd..4c50f2f1d 100644 --- a/dom/media/webaudio/WaveShaperNode.cpp +++ b/dom/media/webaudio/WaveShaperNode.cpp @@ -23,7 +23,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(WaveShaperNode, AudioNode) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(WaveShaperNode, AudioNode) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(WaveShaperNode) diff --git a/dom/network/TCPSocketChild.cpp b/dom/network/TCPSocketChild.cpp index 8eb19a1db..72581ca9d 100644 --- a/dom/network/TCPSocketChild.cpp +++ b/dom/network/TCPSocketChild.cpp @@ -50,7 +50,6 @@ namespace dom { NS_IMPL_CYCLE_COLLECTION_CLASS(TCPSocketChildBase) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(TCPSocketChildBase) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSocket) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp index 71c4916b9..a5aa48b00 100644 --- a/dom/notification/Notification.cpp +++ b/dom/notification/Notification.cpp @@ -11,7 +11,6 @@ #include "mozilla/OwningNonNull.h" #include "mozilla/Preferences.h" #include "mozilla/Services.h" -#include "mozilla/Telemetry.h" #include "mozilla/Unused.h" #include "mozilla/dom/AppNotificationServiceOptionsBinding.h" @@ -656,172 +655,6 @@ NotificationPermissionRequest::GetTypes(nsIArray** aTypes) aTypes); } -NS_IMPL_ISUPPORTS(NotificationTelemetryService, nsIObserver) - -NotificationTelemetryService::NotificationTelemetryService() - : mDNDRecorded(false) -{} - -NotificationTelemetryService::~NotificationTelemetryService() -{ - Unused << NS_WARN_IF(NS_FAILED(RemovePermissionChangeObserver())); -} - -/* static */ already_AddRefed<NotificationTelemetryService> -NotificationTelemetryService::GetInstance() -{ - nsCOMPtr<nsISupports> telemetrySupports = - do_GetService(NOTIFICATIONTELEMETRYSERVICE_CONTRACTID); - if (!telemetrySupports) { - return nullptr; - } - RefPtr<NotificationTelemetryService> telemetry = - static_cast<NotificationTelemetryService*>(telemetrySupports.get()); - return telemetry.forget(); -} - -nsresult -NotificationTelemetryService::Init() -{ - nsresult rv = AddPermissionChangeObserver(); - NS_ENSURE_SUCCESS(rv, rv); - - RecordPermissions(); - - return NS_OK; -} - -nsresult -NotificationTelemetryService::RemovePermissionChangeObserver() -{ - nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); - if (!obs) { - return NS_ERROR_OUT_OF_MEMORY; - } - return obs->RemoveObserver(this, "perm-changed"); -} - -nsresult -NotificationTelemetryService::AddPermissionChangeObserver() -{ - nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); - if (!obs) { - return NS_ERROR_OUT_OF_MEMORY; - } - return obs->AddObserver(this, "perm-changed", false); -} - -void -NotificationTelemetryService::RecordPermissions() -{ - if (!Telemetry::CanRecordBase() || !Telemetry::CanRecordExtended()) { - return; - } - - nsCOMPtr<nsIPermissionManager> permissionManager = - services::GetPermissionManager(); - if (!permissionManager) { - return; - } - - nsCOMPtr<nsISimpleEnumerator> enumerator; - nsresult rv = permissionManager->GetEnumerator(getter_AddRefs(enumerator)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - - for (;;) { - bool hasMoreElements; - nsresult rv = enumerator->HasMoreElements(&hasMoreElements); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - if (!hasMoreElements) { - break; - } - nsCOMPtr<nsISupports> supportsPermission; - rv = enumerator->GetNext(getter_AddRefs(supportsPermission)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - uint32_t capability; - if (!GetNotificationPermission(supportsPermission, &capability)) { - continue; - } - } -} - -bool -NotificationTelemetryService::GetNotificationPermission(nsISupports* aSupports, - uint32_t* aCapability) -{ - nsCOMPtr<nsIPermission> permission = do_QueryInterface(aSupports); - if (!permission) { - return false; - } - nsAutoCString type; - permission->GetType(type); - if (!type.Equals("desktop-notification")) { - return false; - } - permission->GetCapability(aCapability); - return true; -} - -void -NotificationTelemetryService::RecordDNDSupported() -{ - if (mDNDRecorded) { - return; - } - - nsCOMPtr<nsIAlertsService> alertService = - do_GetService(NS_ALERTSERVICE_CONTRACTID); - if (!alertService) { - return; - } - - nsCOMPtr<nsIAlertsDoNotDisturb> alertServiceDND = - do_QueryInterface(alertService); - if (!alertServiceDND) { - return; - } - - mDNDRecorded = true; - bool isEnabled; - nsresult rv = alertServiceDND->GetManualDoNotDisturb(&isEnabled); - if (NS_FAILED(rv)) { - return; - } -} - -nsresult -NotificationTelemetryService::RecordSender(nsIPrincipal* aPrincipal) -{ - if (!Telemetry::CanRecordBase() || !Telemetry::CanRecordExtended() || - !nsAlertsUtils::IsActionablePrincipal(aPrincipal)) { - return NS_OK; - } - nsAutoString origin; - nsresult rv = Notification::GetOrigin(aPrincipal, origin); - if (NS_FAILED(rv)) { - return rv; - } - if (!mOrigins.Contains(origin)) { - mOrigins.PutEntry(origin); - } - return NS_OK; -} - -NS_IMETHODIMP -NotificationTelemetryService::Observe(nsISupports* aSubject, - const char* aTopic, - const char16_t* aData) -{ - /* STUB */ - return NS_OK; -} - // Observer that the alert service calls to do common tasks and/or dispatch to the // specific observer for the context e.g. main thread, worker, or service worker. class NotificationObserver final : public nsIObserver @@ -1402,8 +1235,6 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } else if (!strcmp("alertshow", aTopic) || !strcmp("alertfinished", aTopic)) { - RefPtr<NotificationTelemetryService> telemetry = - NotificationTelemetryService::GetInstance(); Unused << NS_WARN_IF(NS_FAILED(AdjustPushQuota(aTopic))); } diff --git a/dom/notification/Notification.h b/dom/notification/Notification.h index a2c4b5c68..11958f6ad 100644 --- a/dom/notification/Notification.h +++ b/dom/notification/Notification.h @@ -18,9 +18,6 @@ #include "nsTHashtable.h" #include "nsWeakReference.h" -#define NOTIFICATIONTELEMETRYSERVICE_CONTRACTID \ - "@mozilla.org/notificationTelemetryService;1" - class nsIPrincipal; class nsIVariant; @@ -49,36 +46,6 @@ public: Notify(workers::Status aStatus) override; }; -// Records telemetry probes at application startup, when a notification is -// shown, and when the notification permission is revoked for a site. -class NotificationTelemetryService final : public nsIObserver -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIOBSERVER - - NotificationTelemetryService(); - - static already_AddRefed<NotificationTelemetryService> GetInstance(); - - nsresult Init(); - void RecordDNDSupported(); - void RecordPermissions(); - nsresult RecordSender(nsIPrincipal* aPrincipal); - -private: - virtual ~NotificationTelemetryService(); - - nsresult AddPermissionChangeObserver(); - nsresult RemovePermissionChangeObserver(); - - bool GetNotificationPermission(nsISupports* aSupports, - uint32_t* aCapability); - - bool mDNDRecorded; - nsTHashtable<nsStringHashKey> mOrigins; -}; - /* * Notifications on workers introduce some lifetime issues. The property we * are trying to satisfy is: @@ -143,7 +110,6 @@ class Notification : public DOMEventTargetHelper friend class ServiceWorkerNotificationObserver; friend class WorkerGetRunnable; friend class WorkerNotificationObserver; - friend class NotificationTelemetryService; public: IMPL_EVENT_HANDLER(click) diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp index 64c06d3ea..5a84f5fb1 100644 --- a/dom/performance/PerformanceMainThread.cpp +++ b/dom/performance/PerformanceMainThread.cpp @@ -27,7 +27,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(PerformanceMainThread, NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTiming, mNavigation, mDocEntry) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(PerformanceMainThread, diff --git a/dom/performance/PerformanceObserver.cpp b/dom/performance/PerformanceObserver.cpp index d02acfb09..7bf194bb7 100644 --- a/dom/performance/PerformanceObserver.cpp +++ b/dom/performance/PerformanceObserver.cpp @@ -34,7 +34,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(PerformanceObserver) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPerformance) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(PerformanceObserver) diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index 300c4f621..4a509676d 100755 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -92,11 +92,6 @@ mozilla::plugins::SetupBridge(uint32_t aPluginId, return true; } PluginModuleChromeParent* chromeParent = static_cast<PluginModuleChromeParent*>(plugin->GetLibrary()); - /* - * We can't accumulate BLOCKED_ON_PLUGIN_MODULE_INIT_MS until here because - * its histogram key is not available until *after* NP_Initialize. - */ - chromeParent->AccumulateModuleInitBlockedTime(); *rv = chromeParent->GetRunID(runID); if (NS_FAILED(*rv)) { return true; @@ -335,16 +330,13 @@ PluginModuleContentParent::LoadModule(uint32_t aPluginId, dom::ContentChild* cp = dom::ContentChild::GetSingleton(); nsresult rv; uint32_t runID; - TimeStamp sendLoadPluginStart = TimeStamp::Now(); if (!cp->SendLoadPlugin(aPluginId, &rv, &runID) || NS_FAILED(rv)) { return nullptr; } - TimeStamp sendLoadPluginEnd = TimeStamp::Now(); PluginModuleContentParent* parent = mapping->GetModule(); MOZ_ASSERT(parent); - parent->mTimeBlocked += (sendLoadPluginEnd - sendLoadPluginStart); if (!mapping->IsChannelOpened()) { // mapping is linked into PluginModuleMapping::sModuleListHead and is @@ -440,7 +432,6 @@ PluginModuleChromeParent::LoadModule(const char* aFilePath, uint32_t aPluginId, aPluginTag->mSupportsAsyncInit)); UniquePtr<LaunchCompleteTask> onLaunchedRunnable(new LaunchedTask(parent)); parent->mSubprocess->SetCallRunnableImmediately(!parent->mIsStartingAsync); - TimeStamp launchStart = TimeStamp::Now(); bool launched = parent->mSubprocess->Launch(Move(onLaunchedRunnable), aPluginTag->mSandboxLevel); if (!launched) { @@ -459,8 +450,6 @@ PluginModuleChromeParent::LoadModule(const char* aFilePath, uint32_t aPluginId, return nullptr; } } - TimeStamp launchEnd = TimeStamp::Now(); - parent->mTimeBlocked = (launchEnd - launchStart); return parent.forget(); } @@ -1758,15 +1747,12 @@ PluginModuleChromeParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* PluginSettings settings; GetSettings(&settings); - TimeStamp callNpInitStart = TimeStamp::Now(); // Asynchronous case if (mIsStartingAsync) { if (!SendAsyncNP_Initialize(settings)) { Close(); return NS_ERROR_FAILURE; } - TimeStamp callNpInitEnd = TimeStamp::Now(); - mTimeBlocked += (callNpInitEnd - callNpInitStart); return NS_OK; } @@ -1779,8 +1765,6 @@ PluginModuleChromeParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* Close(); return NS_ERROR_FAILURE; } - TimeStamp callNpInitEnd = TimeStamp::Now(); - mTimeBlocked += (callNpInitEnd - callNpInitStart); RecvNP_InitializeResult(*error); @@ -1882,13 +1866,10 @@ PluginModuleChromeParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) PluginSettings settings; GetSettings(&settings); - TimeStamp callNpInitStart = TimeStamp::Now(); if (mIsStartingAsync) { if (!SendAsyncNP_Initialize(settings)) { return NS_ERROR_FAILURE; } - TimeStamp callNpInitEnd = TimeStamp::Now(); - mTimeBlocked += (callNpInitEnd - callNpInitStart); return NS_OK; } @@ -1896,8 +1877,6 @@ PluginModuleChromeParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) Close(); return NS_ERROR_FAILURE; } - TimeStamp callNpInitEnd = TimeStamp::Now(); - mTimeBlocked += (callNpInitEnd - callNpInitStart); RecvNP_InitializeResult(*error); return NS_OK; } @@ -2194,14 +2173,6 @@ public: } }; -void -PluginModuleParent::AccumulateModuleInitBlockedTime() -{ - // XXX: mTimeBlocked can probably go if not used for anything besides - // telemetry. - mTimeBlocked = TimeDuration(); -} - nsresult PluginModuleParent::NPP_NewInternal(NPMIMEType pluginType, NPP instance, uint16_t mode, @@ -2213,13 +2184,6 @@ PluginModuleParent::NPP_NewInternal(NPMIMEType pluginType, NPP instance, if (mPluginName.IsEmpty()) { GetPluginDetails(); InitQuirksModes(nsDependentCString(pluginType)); - /** mTimeBlocked measures the time that the main thread has been blocked - * on plugin module initialization. As implemented, this is the sum of - * plugin-container launch + toolhelp32 snapshot + NP_Initialize. - * We don't accumulate its value until here because the plugin info - * for its histogram key is not available until *after* NP_Initialize. - */ - AccumulateModuleInitBlockedTime(); } nsCaseInsensitiveUTF8StringArrayComparator comparator; diff --git a/dom/plugins/ipc/PluginModuleParent.h b/dom/plugins/ipc/PluginModuleParent.h index 0ceed6efd..909e8fe35 100644 --- a/dom/plugins/ipc/PluginModuleParent.h +++ b/dom/plugins/ipc/PluginModuleParent.h @@ -115,8 +115,6 @@ public: return mPluginName + mPluginVersion; } - void AccumulateModuleInitBlockedTime(); - virtual nsresult GetRunID(uint32_t* aRunID) override; virtual void SetHasLocalInstance() override { mHadLocalInstance = true; @@ -315,7 +313,6 @@ protected: nsString mBrowserDumpID; nsString mHangID; RefPtr<nsIObserver> mProfilerObserver; - TimeDuration mTimeBlocked; nsCString mPluginName; nsCString mPluginVersion; int32_t mSandboxLevel; diff --git a/dom/promise/Promise.cpp b/dom/promise/Promise.cpp index 557f3a1f9..f636a9101 100644 --- a/dom/promise/Promise.cpp +++ b/dom/promise/Promise.cpp @@ -413,7 +413,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Promise) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mResolveCallbacks) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRejectCallbacks) #endif // SPIDERMONKEY_PROMISE - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(Promise) @@ -1995,7 +1994,6 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(CountdownHolder) NS_IMPL_CYCLE_COLLECTION_TRACE_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CountdownHolder) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPromise) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END diff --git a/dom/promise/PromiseCallback.cpp b/dom/promise/PromiseCallback.cpp index 3f4a689ae..6ecf983b7 100644 --- a/dom/promise/PromiseCallback.cpp +++ b/dom/promise/PromiseCallback.cpp @@ -47,7 +47,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ResolvePromiseCallback, PromiseCallback) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPromise) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(ResolvePromiseCallback) @@ -107,7 +106,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(RejectPromiseCallback, PromiseCallback) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPromise) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(RejectPromiseCallback) @@ -170,7 +168,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(InvokePromiseFuncCallback, PromiseCallback) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPromiseFunc) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(InvokePromiseFuncCallback) @@ -256,7 +253,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(WrapperPromiseCallback, NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mResolveFunc) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRejectFunc) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(WrapperPromiseCallback) diff --git a/dom/push/PushSubscriptionOptions.cpp b/dom/push/PushSubscriptionOptions.cpp index bc4fead1e..39252e9e8 100644 --- a/dom/push/PushSubscriptionOptions.cpp +++ b/dom/push/PushSubscriptionOptions.cpp @@ -36,7 +36,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(PushSubscriptionOptions) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(PushSubscriptionOptions) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(PushSubscriptionOptions) NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER diff --git a/dom/security/nsContentSecurityManager.cpp b/dom/security/nsContentSecurityManager.cpp index 570730312..f2cbc8fcf 100644 --- a/dom/security/nsContentSecurityManager.cpp +++ b/dom/security/nsContentSecurityManager.cpp @@ -92,6 +92,55 @@ nsContentSecurityManager::AllowTopLevelNavigationToDataURI(nsIChannel* aChannel) return false; } +/* static */ nsresult +nsContentSecurityManager::CheckFTPSubresourceLoad(nsIChannel* aChannel) +{ + // We dissallow using FTP resources as a subresource everywhere. + // The only valid way to use FTP resources is loading it as + // a top level document. + + nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo(); + if (!loadInfo) { + return NS_OK; + } + + nsContentPolicyType type = loadInfo->GetExternalContentPolicyType(); + if (type == nsIContentPolicy::TYPE_DOCUMENT) { + return NS_OK; + } + + nsCOMPtr<nsIURI> uri; + nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri)); + NS_ENSURE_SUCCESS(rv, rv); + if (!uri) { + return NS_OK; + } + + bool isFtpURI = (NS_SUCCEEDED(uri->SchemeIs("ftp", &isFtpURI)) && isFtpURI); + if (!isFtpURI) { + return NS_OK; + } + + nsCOMPtr<nsIDocument> doc; + if (nsINode* node = loadInfo->LoadingNode()) { + doc = node->OwnerDoc(); + } + + nsAutoCString spec; + uri->GetSpec(spec); + NS_ConvertUTF8toUTF16 specUTF16(NS_UnescapeURL(spec)); + const char16_t* params[] = { specUTF16.get() }; + + nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, + NS_LITERAL_CSTRING("FTP_URI_BLOCKED"), + doc, + nsContentUtils::eSECURITY_PROPERTIES, + "BlockSubresourceFTP", + params, ArrayLength(params)); + + return NS_ERROR_CONTENT_BLOCKED; +} + static nsresult ValidateSecurityFlags(nsILoadInfo* aLoadInfo) { @@ -574,6 +623,10 @@ nsContentSecurityManager::doContentSecurityCheck(nsIChannel* aChannel, rv = DoContentSecurityChecks(aChannel, loadInfo); NS_ENSURE_SUCCESS(rv, rv); + // Apply this after CSP checks to allow CSP reporting. + rv = CheckFTPSubresourceLoad(aChannel); + NS_ENSURE_SUCCESS(rv, rv); + // now lets set the initalSecurityFlag for subsequent calls loadInfo->SetInitialSecurityCheckDone(true); @@ -591,6 +644,9 @@ nsContentSecurityManager::AsyncOnChannelRedirect(nsIChannel* aOldChannel, // Are we enforcing security using LoadInfo? if (loadInfo && loadInfo->GetEnforceSecurity()) { nsresult rv = CheckChannel(aNewChannel); + if (NS_SUCCEEDED(rv)) { + rv = CheckFTPSubresourceLoad(aNewChannel); + } if (NS_FAILED(rv)) { aOldChannel->Cancel(rv); return rv; diff --git a/dom/security/nsContentSecurityManager.h b/dom/security/nsContentSecurityManager.h index bab847743..750dd8803 100644 --- a/dom/security/nsContentSecurityManager.h +++ b/dom/security/nsContentSecurityManager.h @@ -36,6 +36,7 @@ public: private: static nsresult CheckChannel(nsIChannel* aChannel); + static nsresult CheckFTPSubresourceLoad(nsIChannel* aChannel); virtual ~nsContentSecurityManager() {} diff --git a/dom/security/nsMixedContentBlocker.cpp b/dom/security/nsMixedContentBlocker.cpp index 5f41f414d..543429aff 100644 --- a/dom/security/nsMixedContentBlocker.cpp +++ b/dom/security/nsMixedContentBlocker.cpp @@ -35,7 +35,6 @@ #include "nsISiteSecurityService.h" #include "mozilla/Logging.h" -#include "mozilla/Telemetry.h" #include "mozilla/dom/ContentChild.h" #include "mozilla/ipc/URIUtils.h" @@ -814,17 +813,13 @@ nsMixedContentBlocker::ShouldLoad(bool aHadInsecureImageRedirect, // // We do not count requests aHadInsecureImageRedirect=true, since these are // just an artifact of the image caching system. - bool active = (classification == eMixedScript); if (!aHadInsecureImageRedirect) { - if (XRE_IsParentProcess()) { - AccumulateMixedContentHSTS(innerContentLocation, active); - } else { + if (!XRE_IsParentProcess()) { // Ask the parent process to do the same call mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton(); if (cc) { mozilla::ipc::URIParams uri; SerializeURI(innerContentLocation, uri); - cc->SendAccumulateMixedContentHSTS(uri, active); } } } @@ -977,11 +972,3 @@ enum MixedContentHSTSState { MCB_HSTS_ACTIVE_NO_HSTS = 2, MCB_HSTS_ACTIVE_WITH_HSTS = 3 }; - -// Record information on when HSTS would have made mixed content not mixed -// content (regardless of whether it was actually blocked) -void -nsMixedContentBlocker::AccumulateMixedContentHSTS(nsIURI* aURI, bool aActive) -{ -/* STUB */ -}
\ No newline at end of file diff --git a/dom/security/nsMixedContentBlocker.h b/dom/security/nsMixedContentBlocker.h index 56ab9621f..068068b25 100644 --- a/dom/security/nsMixedContentBlocker.h +++ b/dom/security/nsMixedContentBlocker.h @@ -61,9 +61,6 @@ public: nsISupports* aExtra, nsIPrincipal* aRequestPrincipal, int16_t* aDecision); - static void AccumulateMixedContentHSTS(nsIURI* aURI, - bool aActive); - static bool sBlockMixedScript; static bool sBlockMixedDisplay; diff --git a/dom/storage/DOMStorageCache.cpp b/dom/storage/DOMStorageCache.cpp index a6aa17424..a2b5a6f73 100644 --- a/dom/storage/DOMStorageCache.cpp +++ b/dom/storage/DOMStorageCache.cpp @@ -85,7 +85,6 @@ DOMStorageCache::DOMStorageCache(const nsACString* aOriginNoSuffix) , mInitialized(false) , mPersistent(false) , mSessionOnlyDataSetActive(false) -, mPreloadTelemetryRecorded(false) { MOZ_COUNT_CTOR(DOMStorageCache); } @@ -178,7 +177,7 @@ DOMStorageCache::DataSet(const DOMStorage* aStorage) // Session only data set is demanded but not filled with // current data set, copy to session only set now. - WaitForPreload(Telemetry::LOCALDOMSTORAGE_SESSIONONLY_PRELOAD_BLOCKING_MS); + WaitForPreload(); Data& defaultSet = mData[kDefaultSet]; Data& sessionSet = mData[kSessionSet]; @@ -298,46 +297,18 @@ DOMStorageCache::KeepAlive() mKeepAliveTimer.swap(timer); } -namespace { - -// The AutoTimer provided by telemetry headers is only using static, -// i.e. compile time known ID, but here we know the ID only at run time. -// Hence a new class. -class TelemetryAutoTimer -{ -public: - explicit TelemetryAutoTimer(Telemetry::ID aId) - : id(aId), start(TimeStamp::Now()) {} - ~TelemetryAutoTimer() - { /* STUB */ } -private: - Telemetry::ID id; - const TimeStamp start; -}; - -} // namespace - void -DOMStorageCache::WaitForPreload(Telemetry::ID aTelemetryID) +DOMStorageCache::WaitForPreload() { if (!mPersistent) { return; } bool loaded = mLoaded; - - // Telemetry of rates of pending preloads - if (!mPreloadTelemetryRecorded) { - mPreloadTelemetryRecorded = true; - } - if (loaded) { return; } - // Measure which operation blocks and for how long - TelemetryAutoTimer timer(aTelemetryID); - // If preload already started (i.e. we got some first data, but not all) // SyncPreload will just wait for it to finish rather then synchronously // read from the database. It seems to me more optimal. @@ -354,7 +325,7 @@ nsresult DOMStorageCache::GetLength(const DOMStorage* aStorage, uint32_t* aRetval) { if (Persist(aStorage)) { - WaitForPreload(Telemetry::LOCALDOMSTORAGE_GETLENGTH_BLOCKING_MS); + WaitForPreload(); if (NS_FAILED(mLoadResult)) { return mLoadResult; } @@ -372,7 +343,7 @@ DOMStorageCache::GetKey(const DOMStorage* aStorage, uint32_t aIndex, nsAString& // maybe we need to have a lazily populated key array here or // something? if (Persist(aStorage)) { - WaitForPreload(Telemetry::LOCALDOMSTORAGE_GETKEY_BLOCKING_MS); + WaitForPreload(); if (NS_FAILED(mLoadResult)) { return mLoadResult; } @@ -394,7 +365,7 @@ void DOMStorageCache::GetKeys(const DOMStorage* aStorage, nsTArray<nsString>& aKeys) { if (Persist(aStorage)) { - WaitForPreload(Telemetry::LOCALDOMSTORAGE_GETALLKEYS_BLOCKING_MS); + WaitForPreload(); } if (NS_FAILED(mLoadResult)) { @@ -411,7 +382,7 @@ DOMStorageCache::GetItem(const DOMStorage* aStorage, const nsAString& aKey, nsAString& aRetval) { if (Persist(aStorage)) { - WaitForPreload(Telemetry::LOCALDOMSTORAGE_GETVALUE_BLOCKING_MS); + WaitForPreload(); if (NS_FAILED(mLoadResult)) { return mLoadResult; } @@ -436,7 +407,7 @@ DOMStorageCache::SetItem(const DOMStorage* aStorage, const nsAString& aKey, int64_t delta = 0; if (Persist(aStorage)) { - WaitForPreload(Telemetry::LOCALDOMSTORAGE_SETVALUE_BLOCKING_MS); + WaitForPreload(); if (NS_FAILED(mLoadResult)) { return mLoadResult; } @@ -485,7 +456,7 @@ DOMStorageCache::RemoveItem(const DOMStorage* aStorage, const nsAString& aKey, nsString& aOld) { if (Persist(aStorage)) { - WaitForPreload(Telemetry::LOCALDOMSTORAGE_REMOVEKEY_BLOCKING_MS); + WaitForPreload(); if (NS_FAILED(mLoadResult)) { return mLoadResult; } @@ -524,9 +495,8 @@ DOMStorageCache::Clear(const DOMStorage* aStorage) // We need to preload all data (know the size) before we can proceeed // to correctly decrease cached usage number. // XXX as in case of unload, this is not technically needed now, but - // after super-scope quota introduction we have to do this. Get telemetry - // right now. - WaitForPreload(Telemetry::LOCALDOMSTORAGE_CLEAR_BLOCKING_MS); + // after super-scope quota introduction we have to do this. + WaitForPreload(); if (NS_FAILED(mLoadResult)) { // When we failed to load data from the database, force delete of the // scope data and make use of the storage possible again. @@ -596,9 +566,8 @@ DOMStorageCache::UnloadItems(uint32_t aUnloadFlags) // Must wait for preload to pass correct usage to ProcessUsageDelta // XXX this is not technically needed right now since there is just // per-origin isolated quota handling, but when we introduce super- - // -scope quotas, we have to do this. Better to start getting - // telemetry right now. - WaitForPreload(Telemetry::LOCALDOMSTORAGE_UNLOAD_BLOCKING_MS); + // -scope quotas, we have to do this. + WaitForPreload(); mData[kDefaultSet].mKeys.Clear(); ProcessUsageDelta(kDefaultSet, -mData[kDefaultSet].mOriginQuotaUsage); @@ -617,7 +586,7 @@ DOMStorageCache::UnloadItems(uint32_t aUnloadFlags) #ifdef DOM_STORAGE_TESTS if (aUnloadFlags & kTestReload) { - WaitForPreload(Telemetry::LOCALDOMSTORAGE_UNLOAD_BLOCKING_MS); + WaitForPreload(); mData[kDefaultSet].mKeys.Clear(); mLoaded = false; // This is only used in testing code diff --git a/dom/storage/DOMStorageCache.h b/dom/storage/DOMStorageCache.h index 01cf6b3ea..4469152a2 100644 --- a/dom/storage/DOMStorageCache.h +++ b/dom/storage/DOMStorageCache.h @@ -14,7 +14,6 @@ #include "nsDataHashtable.h" #include "nsHashKeys.h" #include "mozilla/Monitor.h" -#include "mozilla/Telemetry.h" #include "mozilla/Atomics.h" namespace mozilla { @@ -168,7 +167,7 @@ private: private: // Synchronously blocks until the cache is fully loaded from the database - void WaitForPreload(mozilla::Telemetry::ID aTelemetryID); + void WaitForPreload(); // Helper to get one of the 3 data sets (regular, private, session) Data& DataSet(const DOMStorage* aStorage); @@ -241,9 +240,6 @@ private: // Drops back to false when session-only data are cleared from chrome. bool mSessionOnlyDataSetActive : 1; - // Whether we have already captured state of the cache preload on our first access. - bool mPreloadTelemetryRecorded : 1; - // DOMStorageDBThread on the parent or single process, // DOMStorageDBChild on the child process. static DOMStorageDBBridge* sDatabase; diff --git a/dom/svg/DOMSVGLength.cpp b/dom/svg/DOMSVGLength.cpp index 574617045..c72c3e383 100644 --- a/dom/svg/DOMSVGLength.cpp +++ b/dom/svg/DOMSVGLength.cpp @@ -43,7 +43,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMSVGLength) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mList) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSVGElement) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(DOMSVGLength) diff --git a/dom/svg/DOMSVGLengthList.cpp b/dom/svg/DOMSVGLengthList.cpp index 9d93546d9..88ecd6007 100644 --- a/dom/svg/DOMSVGLengthList.cpp +++ b/dom/svg/DOMSVGLengthList.cpp @@ -55,7 +55,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMSVGLengthList) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMSVGLengthList) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAList) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(DOMSVGLengthList) NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER diff --git a/dom/svg/DOMSVGNumber.cpp b/dom/svg/DOMSVGNumber.cpp index 97d80d4d0..6b9528606 100644 --- a/dom/svg/DOMSVGNumber.cpp +++ b/dom/svg/DOMSVGNumber.cpp @@ -35,7 +35,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMSVGNumber) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mList) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(DOMSVGNumber) NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER diff --git a/dom/svg/DOMSVGNumberList.cpp b/dom/svg/DOMSVGNumberList.cpp index 00fb7ba4d..85322688f 100644 --- a/dom/svg/DOMSVGNumberList.cpp +++ b/dom/svg/DOMSVGNumberList.cpp @@ -55,7 +55,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMSVGNumberList) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMSVGNumberList) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAList) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(DOMSVGNumberList) NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER diff --git a/dom/svg/DOMSVGPathSeg.cpp b/dom/svg/DOMSVGPathSeg.cpp index 95be3521e..a15bf42e9 100644 --- a/dom/svg/DOMSVGPathSeg.cpp +++ b/dom/svg/DOMSVGPathSeg.cpp @@ -31,7 +31,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMSVGPathSeg) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mList) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(DOMSVGPathSeg) diff --git a/dom/svg/DOMSVGPathSegList.cpp b/dom/svg/DOMSVGPathSegList.cpp index 0b811cdb1..36768ea34 100644 --- a/dom/svg/DOMSVGPathSegList.cpp +++ b/dom/svg/DOMSVGPathSegList.cpp @@ -36,7 +36,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMSVGPathSegList) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMSVGPathSegList) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mElement) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(DOMSVGPathSegList) NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER diff --git a/dom/svg/DOMSVGPointList.cpp b/dom/svg/DOMSVGPointList.cpp index 966ef476e..ca06bd270 100644 --- a/dom/svg/DOMSVGPointList.cpp +++ b/dom/svg/DOMSVGPointList.cpp @@ -55,7 +55,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMSVGPointList) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMSVGPointList) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mElement) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(DOMSVGPointList) NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER diff --git a/dom/svg/DOMSVGTransformList.cpp b/dom/svg/DOMSVGTransformList.cpp index 30760bc6d..e4bde9aeb 100644 --- a/dom/svg/DOMSVGTransformList.cpp +++ b/dom/svg/DOMSVGTransformList.cpp @@ -54,7 +54,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMSVGTransformList) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMSVGTransformList) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAList) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(DOMSVGTransformList) NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER diff --git a/dom/svg/SVGTransform.cpp b/dom/svg/SVGTransform.cpp index b73018d1c..1cba997eb 100644 --- a/dom/svg/SVGTransform.cpp +++ b/dom/svg/SVGTransform.cpp @@ -51,7 +51,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mList) SVGMatrix* matrix = SVGMatrixTearoffTable().GetTearoff(tmp); CycleCollectionNoteChild(cb, matrix, "matrix"); -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(SVGTransform) diff --git a/dom/svg/nsISVGPoint.cpp b/dom/svg/nsISVGPoint.cpp index 1c1971004..f4fdb9dd0 100644 --- a/dom/svg/nsISVGPoint.cpp +++ b/dom/svg/nsISVGPoint.cpp @@ -32,7 +32,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsISVGPoint) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mList) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsISVGPoint) diff --git a/dom/svg/nsSVGElement.h b/dom/svg/nsSVGElement.h index 42bc05746..257ed7a2e 100644 --- a/dom/svg/nsSVGElement.h +++ b/dom/svg/nsSVGElement.h @@ -715,7 +715,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER \ NS_IMPL_CYCLE_COLLECTION_UNLINK_END \ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_val) \ NS_IMPL_CYCLE_COLLECTION_TRAVERSE(_element) \ - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS \ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END \ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(_val) \ NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER \ diff --git a/dom/webidl/AddonEvent.webidl b/dom/webidl/AddonEvent.webidl deleted file mode 100644 index 235f81ec2..000000000 --- a/dom/webidl/AddonEvent.webidl +++ /dev/null @@ -1,12 +0,0 @@ -[ Func="mozilla::AddonManagerWebAPI::IsAPIEnabled", - Constructor(DOMString type, AddonEventInit eventInitDict)] -interface AddonEvent : Event { - readonly attribute DOMString id; - readonly attribute boolean needsRestart; -}; - -dictionary AddonEventInit : EventInit { - required DOMString id; - required boolean needsRestart; -}; - diff --git a/dom/webidl/AddonManager.webidl b/dom/webidl/AddonManager.webidl deleted file mode 100644 index 02c7953e6..000000000 --- a/dom/webidl/AddonManager.webidl +++ /dev/null @@ -1,91 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -/* We need a JSImplementation but cannot get one without a contract ID. - Since Addon and AddonInstall are only ever created from JS they don't need - real contract IDs. */ -[ChromeOnly, JSImplementation="dummy"] -interface Addon { - // The add-on's ID. - readonly attribute DOMString id; - // The add-on's version. - readonly attribute DOMString version; - // The add-on's type (extension, theme, etc.). - readonly attribute DOMString type; - // The add-on's name in the current locale. - readonly attribute DOMString name; - // The add-on's description in the current locale. - readonly attribute DOMString description; - // If the user has enabled this add-on, note that it still may not be running - // depending on whether enabling requires a restart or if the add-on is - // incompatible in some way. - readonly attribute boolean isEnabled; - // If the add-on is currently active in the browser. - readonly attribute boolean isActive; - // If the add-on may be uninstalled - readonly attribute boolean canUninstall; - - Promise<boolean> uninstall(); - Promise<void> setEnabled(boolean value); -}; - -[ChromeOnly, JSImplementation="dummy"] -interface AddonInstall : EventTarget { - // One of the STATE_* symbols from AddonManager.jsm - readonly attribute DOMString state; - // One of the ERROR_* symbols from AddonManager.jsm, or null - readonly attribute DOMString? error; - // How many bytes have been downloaded - readonly attribute long long progress; - // How many total bytes will need to be downloaded or -1 if unknown - readonly attribute long long maxProgress; - - Promise<void> install(); - Promise<void> cancel(); -}; - -dictionary addonInstallOptions { - required DOMString url; - // If a non-empty string is passed for "hash", it is used to verify the - // checksum of the downloaded XPI before installing. If is omitted or if - // it is null or empty string, no checksum verification is performed. - DOMString? hash = null; -}; - -[HeaderFile="mozilla/AddonManagerWebAPI.h", - Func="mozilla::AddonManagerWebAPI::IsAPIEnabled", - NavigatorProperty="mozAddonManager", - JSImplementation="@mozilla.org/addon-web-api/manager;1"] -interface AddonManager : EventTarget { - /** - * Gets information about an add-on - * - * @param id - * The ID of the add-on to test for. - * @return A promise. It will resolve to an Addon if the add-on is installed. - */ - Promise<Addon> getAddonByID(DOMString id); - - /** - * Creates an AddonInstall object for a given URL. - * - * @param options - * Only one supported option: 'url', the URL of the addon to install. - * @return A promise that resolves to an instance of AddonInstall. - */ - Promise<AddonInstall> createInstall(optional addonInstallOptions options); - - /* Hooks for managing event listeners */ - [ChromeOnly] - void eventListenerWasAdded(DOMString type); - [ChromeOnly] - void eventListenerWasRemoved(DOMString type); -}; - -[ChromeOnly,Exposed=System,HeaderFile="mozilla/AddonManagerWebAPI.h"] -interface AddonManagerPermissions { - static boolean isHostPermitted(DOMString host); -}; - diff --git a/dom/webidl/AudioContext.webidl b/dom/webidl/AudioContext.webidl index c2f65abaf..9aa3d5567 100644 --- a/dom/webidl/AudioContext.webidl +++ b/dom/webidl/AudioContext.webidl @@ -24,7 +24,6 @@ dictionary PeriodicWaveConstraints { }; [Constructor, - Constructor(AudioChannel audioChannelType), Pref="dom.webaudio.enabled"] interface AudioContext : EventTarget { diff --git a/dom/webidl/Element.webidl b/dom/webidl/Element.webidl index 97eb4ffe0..cf17523a5 100644 --- a/dom/webidl/Element.webidl +++ b/dom/webidl/Element.webidl @@ -164,9 +164,10 @@ interface Element : Node { }; // http://dev.w3.org/csswg/cssom-view/ -enum ScrollLogicalPosition { "start", "end" }; +enum ScrollLogicalPosition { "start", "center", "end", "nearest" }; dictionary ScrollIntoViewOptions : ScrollOptions { ScrollLogicalPosition block = "start"; + ScrollLogicalPosition inline = "nearest"; }; // http://dev.w3.org/csswg/cssom-view/#extensions-to-the-element-interface @@ -175,8 +176,7 @@ partial interface Element { DOMRect getBoundingClientRect(); // scrolling - void scrollIntoView(boolean top); - void scrollIntoView(optional ScrollIntoViewOptions options); + void scrollIntoView(optional (boolean or ScrollIntoViewOptions) arg); // None of the CSSOM attributes are [Pure], because they flush attribute long scrollTop; // scroll on setting attribute long scrollLeft; // scroll on setting diff --git a/dom/webidl/IntersectionObserver.webidl b/dom/webidl/IntersectionObserver.webidl index dbe8f428d..83200d950 100644 --- a/dom/webidl/IntersectionObserver.webidl +++ b/dom/webidl/IntersectionObserver.webidl @@ -7,7 +7,7 @@ * https://wicg.github.io/IntersectionObserver/ */ -[ProbablyShortLivingObject, Pref="dom.IntersectionObserver.enabled"] +[ProbablyShortLivingObject, Pref="dom.intersectionObserver.enabled"] interface IntersectionObserverEntry { [Constant] readonly attribute DOMHighResTimeStamp time; @@ -18,6 +18,8 @@ interface IntersectionObserverEntry { [Constant] readonly attribute DOMRectReadOnly intersectionRect; [Constant] + readonly attribute boolean isIntersecting; + [Constant] readonly attribute double intersectionRatio; [Constant] readonly attribute Element target; @@ -25,7 +27,7 @@ interface IntersectionObserverEntry { [Constructor(IntersectionCallback intersectionCallback, optional IntersectionObserverInit options), - Pref="dom.IntersectionObserver.enabled"] + Pref="dom.intersectionObserver.enabled"] interface IntersectionObserver { [Constant] readonly attribute Element? root; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 06fea2f20..aae7e479c 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -591,9 +591,6 @@ WEBIDL_FILES = [ 'XULElement.webidl', ] -if CONFIG['MOZ_WEBEXTENSIONS']: - WEBIDL_FILES += ['AddonManager.webidl'] - if CONFIG['MOZ_AUDIO_CHANNEL_MANAGER']: WEBIDL_FILES += [ 'AudioChannelManager.webidl', @@ -722,9 +719,6 @@ GENERATED_EVENTS_WEBIDL_FILES = [ 'WebGLContextEvent.webidl', ] -if CONFIG['MOZ_WEBEXTENSIONS']: - GENERATED_EVENTS_WEBIDL_FILES += ['AddonEvent.webidl'] - if CONFIG['MOZ_WEBRTC']: GENERATED_EVENTS_WEBIDL_FILES += [ 'RTCDataChannelEvent.webidl', diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index 1f49e16dd..21f6d8ddf 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -1530,7 +1530,6 @@ RuntimeService::RegisterWorker(WorkerPrivate* aWorkerPrivate) const bool isServiceWorker = aWorkerPrivate->IsServiceWorker(); const bool isSharedWorker = aWorkerPrivate->IsSharedWorker(); - const bool isDedicatedWorker = aWorkerPrivate->IsDedicatedWorker(); if (isServiceWorker) { AssertIsOnMainThread(); } diff --git a/dom/worklet/WorkletGlobalScope.cpp b/dom/worklet/WorkletGlobalScope.cpp index 4caeae81a..8c05a0abe 100644 --- a/dom/worklet/WorkletGlobalScope.cpp +++ b/dom/worklet/WorkletGlobalScope.cpp @@ -22,8 +22,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WorkletGlobalScope) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(WorkletGlobalScope) - - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConsole) tmp->TraverseHostObjectURIs(cb); diff --git a/dom/xbl/nsXBLDocumentInfo.cpp b/dom/xbl/nsXBLDocumentInfo.cpp index 283775dc6..73b08d7e1 100644 --- a/dom/xbl/nsXBLDocumentInfo.cpp +++ b/dom/xbl/nsXBLDocumentInfo.cpp @@ -52,7 +52,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXBLDocumentInfo) if (tmp->mDocument && nsCCUncollectableMarker::InGeneration(cb, tmp->mDocument->GetMarkedCCGeneration())) { - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS return NS_SUCCESS_INTERRUPTED_TRAVERSE; } NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument) @@ -62,7 +61,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXBLDocumentInfo) iter.UserData()->Traverse(cb); } } - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsXBLDocumentInfo) if (tmp->mBindingTable) { diff --git a/dom/xslt/xpath/XPathResult.cpp b/dom/xslt/xpath/XPathResult.cpp index 33315c942..07121347e 100644 --- a/dom/xslt/xpath/XPathResult.cpp +++ b/dom/xslt/xpath/XPathResult.cpp @@ -63,7 +63,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(XPathResult) NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(XPathResult) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mResultNodes) diff --git a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp index 726441757..c9bcc31ff 100644 --- a/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp +++ b/dom/xslt/xslt/txMozillaStylesheetCompiler.cpp @@ -462,10 +462,6 @@ txCompileObserver::startLoad(nsIURI* aUri, txStylesheetCompiler* aCompiler, nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel)); if (httpChannel) { - httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"), - NS_LITERAL_CSTRING("*/*"), - false); - nsCOMPtr<nsIURI> referrerURI; aReferrerPrincipal->GetURI(getter_AddRefs(referrerURI)); if (referrerURI) { diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp index 14fa898ab..e351a46eb 100644 --- a/dom/xul/nsXULElement.cpp +++ b/dom/xul/nsXULElement.cpp @@ -2173,7 +2173,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULPrototypeNode) } ImplCycleCollectionTraverse(cb, elem->mChildren, "mChildren"); } - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsXULPrototypeNode) if (tmp->mType == nsXULPrototypeNode::eType_Script) { |