mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 05:45:37 +00:00
Bug 1438956 - Remove nsIDOMTimeRanges. r=bz
MozReview-Commit-ID: DAgQ0OkSxkq --HG-- extra : rebase_source : e995b4d76186032fc048bc7b63f4e1e2aee046b4
This commit is contained in:
parent
e3bfce50d6
commit
d729e5e045
@ -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<Promise>
|
||||
@ -2791,9 +2783,8 @@ HTMLMediaElement::Seek(double aTime,
|
||||
}
|
||||
RefPtr<TimeRanges> 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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -11,7 +11,6 @@ XPIDL_SOURCES += [
|
||||
'nsIDOMHTMLFormElement.idl',
|
||||
'nsIDOMHTMLInputElement.idl',
|
||||
'nsIDOMMozBrowserFrame.idl',
|
||||
'nsIDOMTimeRanges.idl',
|
||||
'nsIMozBrowserFrame.idl',
|
||||
]
|
||||
|
||||
|
@ -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);
|
||||
};
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user