From d729e5e04549ae6c0ae12209daee9bc999a6a406 Mon Sep 17 00:00:00 2001 From: Adrian Wielgosik Date: Fri, 16 Feb 2018 19:34:28 +0100 Subject: [PATCH] Bug 1438956 - Remove nsIDOMTimeRanges. r=bz MozReview-Commit-ID: DAgQ0OkSxkq --HG-- extra : rebase_source : e995b4d76186032fc048bc7b63f4e1e2aee046b4 --- dom/html/HTMLMediaElement.cpp | 69 +++++++-------------- dom/html/HTMLVideoElement.cpp | 9 +-- dom/html/TimeRanges.cpp | 24 ------- dom/html/TimeRanges.h | 4 +- dom/interfaces/html/moz.build | 1 - dom/interfaces/html/nsIDOMTimeRanges.idl | 21 ------- xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp | 3 - 7 files changed, 26 insertions(+), 105 deletions(-) delete mode 100644 dom/interfaces/html/nsIDOMTimeRanges.idl diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index cb7546ef8fb3..f4fa7e0ca02e 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -2693,41 +2693,33 @@ HTMLMediaElement::SetCurrentTime(double aCurrentTime, ErrorResult& aRv) } /** - * Check if aValue is inside a range of aRanges, and if so sets aIsInRanges - * to true and put the range index in aIntervalIndex. If aValue is not - * inside a range, aIsInRanges is set to false, and aIntervalIndex + * Check if aValue is inside a range of aRanges, and if so returns true + * and puts the range index in aIntervalIndex. If aValue is not + * inside a range, returns false, and aIntervalIndex * is set to the index of the range which ends immediately before aValue - * (and can be -1 if aValue is before aRanges.Start(0)). Returns NS_OK - * on success, and NS_ERROR_FAILURE on failure. + * (and can be -1 if aValue is before aRanges.Start(0)). */ -static nsresult +static bool IsInRanges(TimeRanges& aRanges, double aValue, - bool& aIsInRanges, int32_t& aIntervalIndex) { - aIsInRanges = false; - uint32_t length; - nsresult rv = aRanges.GetLength(&length); - NS_ENSURE_SUCCESS(rv, rv); + uint32_t length = aRanges.Length(); + for (uint32_t i = 0; i < length; i++) { - double start, end; - rv = aRanges.Start(i, &start); - NS_ENSURE_SUCCESS(rv, rv); + double start = aRanges.Start(i, IgnoreErrors()); if (start > aValue) { aIntervalIndex = i - 1; - return NS_OK; + return false; } - rv = aRanges.End(i, &end); - NS_ENSURE_SUCCESS(rv, rv); + double end = aRanges.End(i, IgnoreErrors()); if (aValue <= end) { aIntervalIndex = i; - aIsInRanges = true; - return NS_OK; + return true; } } aIntervalIndex = length - 1; - return NS_OK; + return false; } already_AddRefed @@ -2791,9 +2783,8 @@ HTMLMediaElement::Seek(double aTime, } RefPtr seekable = new TimeRanges(ToSupports(OwnerDoc()), seekableIntervals); - uint32_t length = 0; - seekable->GetLength(&length); - if (!length) { + uint32_t length = seekable->Length(); + if (length == 0) { promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR); return promise.forget(); } @@ -2804,25 +2795,14 @@ HTMLMediaElement::Seek(double aTime, // See seeking spec, point 7 : // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#seeking int32_t range = 0; - bool isInRange = false; - if (NS_FAILED(IsInRanges(*seekable, aTime, isInRange, range))) { - aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); // This will reject the promise. - return promise.forget(); - } + bool isInRange = IsInRanges(*seekable, aTime, range); if (!isInRange) { if (range != -1) { // |range + 1| can't be negative, because the only possible negative value // for |range| is -1. if (uint32_t(range + 1) < length) { - double leftBound, rightBound; - if (NS_FAILED(seekable->End(range, &leftBound))) { - aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); - return promise.forget(); - } - if (NS_FAILED(seekable->Start(range + 1, &rightBound))) { - aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); - return promise.forget(); - } + double leftBound = seekable->End(range, IgnoreErrors()); + double rightBound = seekable->Start(range + 1, IgnoreErrors()); double distanceLeft = Abs(leftBound - aTime); double distanceRight = Abs(rightBound - aTime); if (distanceLeft == distanceRight) { @@ -2834,15 +2814,12 @@ HTMLMediaElement::Seek(double aTime, } else { // Seek target is after the end last range in seekable data. // Clamp the seek target to the end of the last seekable range. - if (NS_FAILED(seekable->End(length - 1, &aTime))) { - aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); - return promise.forget(); - } + aTime = seekable->GetEndTime(); } } else { // aTime is before the first range in |seekable|, the closest point we can // seek to is the start of the first range. - seekable->Start(0, &aTime); + aTime = seekable->GetStartTime(); } } @@ -2903,13 +2880,11 @@ HTMLMediaElement::Played() uint32_t timeRangeCount = 0; if (mPlayed) { - mPlayed->GetLength(&timeRangeCount); + timeRangeCount = mPlayed->Length(); } for (uint32_t i = 0; i < timeRangeCount; i++) { - double begin; - double end; - mPlayed->Start(i, &begin); - mPlayed->End(i, &end); + double begin = mPlayed->Start(i, IgnoreErrors()); + double end = mPlayed->End(i, IgnoreErrors()); ranges->Add(begin, end); } diff --git a/dom/html/HTMLVideoElement.cpp b/dom/html/HTMLVideoElement.cpp index eea620f3b081..4953672eca8d 100644 --- a/dom/html/HTMLVideoElement.cpp +++ b/dom/html/HTMLVideoElement.cpp @@ -352,14 +352,11 @@ HTMLVideoElement::TotalPlayTime() const double total = 0.0; if (mPlayed) { - uint32_t timeRangeCount = 0; - mPlayed->GetLength(&timeRangeCount); + uint32_t timeRangeCount = mPlayed->Length(); for (uint32_t i = 0; i < timeRangeCount; i++) { - double begin; - double end; - mPlayed->Start(i, &begin); - mPlayed->End(i, &end); + double begin = mPlayed->Start(i, IgnoreErrors()); + double end = mPlayed->End(i, IgnoreErrors()); total += end - begin; } diff --git a/dom/html/TimeRanges.cpp b/dom/html/TimeRanges.cpp index dceca985d784..5b9a22b983b0 100644 --- a/dom/html/TimeRanges.cpp +++ b/dom/html/TimeRanges.cpp @@ -18,7 +18,6 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(TimeRanges) NS_IMPL_CYCLE_COLLECTING_RELEASE(TimeRanges) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TimeRanges) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY - NS_INTERFACE_MAP_ENTRY(nsIDOMTimeRanges) NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_END @@ -65,13 +64,6 @@ TimeRanges::~TimeRanges() { } -NS_IMETHODIMP -TimeRanges::GetLength(uint32_t* aLength) -{ - *aLength = Length(); - return NS_OK; -} - double TimeRanges::Start(uint32_t aIndex, ErrorResult& aRv) const { @@ -83,14 +75,6 @@ TimeRanges::Start(uint32_t aIndex, ErrorResult& aRv) const return mRanges[aIndex].mStart; } -NS_IMETHODIMP -TimeRanges::Start(uint32_t aIndex, double* aTime) -{ - ErrorResult rv; - *aTime = Start(aIndex, rv); - return rv.StealNSResult(); -} - double TimeRanges::End(uint32_t aIndex, ErrorResult& aRv) const { @@ -102,14 +86,6 @@ TimeRanges::End(uint32_t aIndex, ErrorResult& aRv) const return mRanges[aIndex].mEnd; } -NS_IMETHODIMP -TimeRanges::End(uint32_t aIndex, double* aTime) -{ - ErrorResult rv; - *aTime = End(aIndex, rv); - return rv.StealNSResult(); -} - void TimeRanges::Add(double aStart, double aEnd) { diff --git a/dom/html/TimeRanges.h b/dom/html/TimeRanges.h index 7d12cecdc1dc..b2d4e35da373 100644 --- a/dom/html/TimeRanges.h +++ b/dom/html/TimeRanges.h @@ -8,7 +8,6 @@ #define mozilla_dom_TimeRanges_h_ #include "nsCOMPtr.h" -#include "nsIDOMTimeRanges.h" #include "nsISupports.h" #include "nsTArray.h" #include "nsWrapperCache.h" @@ -25,13 +24,12 @@ namespace dom { // Implements media TimeRanges: // http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#timeranges -class TimeRanges final : public nsIDOMTimeRanges, +class TimeRanges final : public nsISupports, public nsWrapperCache { public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TimeRanges) - NS_DECL_NSIDOMTIMERANGES TimeRanges(); explicit TimeRanges(nsISupports* aParent); diff --git a/dom/interfaces/html/moz.build b/dom/interfaces/html/moz.build index 4db2b576c156..845b1bc38d08 100644 --- a/dom/interfaces/html/moz.build +++ b/dom/interfaces/html/moz.build @@ -11,7 +11,6 @@ XPIDL_SOURCES += [ 'nsIDOMHTMLFormElement.idl', 'nsIDOMHTMLInputElement.idl', 'nsIDOMMozBrowserFrame.idl', - 'nsIDOMTimeRanges.idl', 'nsIMozBrowserFrame.idl', ] diff --git a/dom/interfaces/html/nsIDOMTimeRanges.idl b/dom/interfaces/html/nsIDOMTimeRanges.idl deleted file mode 100644 index 7e738fa8b7cc..000000000000 --- a/dom/interfaces/html/nsIDOMTimeRanges.idl +++ /dev/null @@ -1,21 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et cindent: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "domstubs.idl" - -[uuid(c43448db-0bab-461d-b648-1ca14a967f7e)] -interface nsIDOMTimeRanges : nsISupports -{ - /* The number of ranges represented by the time range object */ - readonly attribute unsigned long length; - - /* The position of the start of the index'd range, in seconds measured - from the start of the timeline that this object represents */ - double start(in unsigned long index); - - /* The position of the end of the index'd range, in seconds measured - from the start of the timeline that this object represents */ - double end(in unsigned long index); -}; diff --git a/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp b/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp index c29715372981..4aa7b1f4eed3 100644 --- a/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp +++ b/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp @@ -48,7 +48,6 @@ #include "nsIDOMScrollAreaEvent.h" #include "nsIDOMSerializer.h" #include "nsIDOMText.h" -#include "nsIDOMTimeRanges.h" #include "nsIDOMUIEvent.h" #include "nsIDOMWheelEvent.h" #include "nsIDOMXMLDocument.h" @@ -121,7 +120,6 @@ #include "mozilla/dom/SVGElementBinding.h" #include "mozilla/dom/TextBinding.h" #include "mozilla/dom/TimeEventBinding.h" -#include "mozilla/dom/TimeRangesBinding.h" #include "mozilla/dom/TreeBoxObjectBinding.h" #include "mozilla/dom/UIEventBinding.h" #include "mozilla/dom/WheelEventBinding.h" @@ -229,7 +227,6 @@ const ComponentsInterfaceShimEntry kComponentsInterfaceShimMap[] = DEFINE_SHIM(ScrollAreaEvent), DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMSerializer, XMLSerializer), DEFINE_SHIM(Text), - DEFINE_SHIM(TimeRanges), DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsITreeBoxObject, TreeBoxObject), DEFINE_SHIM(UIEvent), DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIWebBrowserPersistable, FrameLoader),