Truly independent web browser
/*
* Copyright (c) 2023, Tim Flynn <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Vector.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/media.html#time-ranges
class TimeRanges final : public Bindings::GCAllocatedWrappable {
WEB_WRAPPABLE(TimeRanges, Bindings::GCAllocatedWrappable);
GC_DECLARE_ALLOCATOR(TimeRanges);
public:
[[nodiscard]] static GC::Ref<TimeRanges> create();
// https://html.spec.whatwg.org/multipage/media.html#dom-timeranges-length
size_t length() const;
// https://html.spec.whatwg.org/multipage/media.html#dom-timeranges-start
WebIDL::ExceptionOr<double> start(u32 index) const;
// https://html.spec.whatwg.org/multipage/media.html#dom-timeranges-end
WebIDL::ExceptionOr<double> end(u32 index) const;
void add_range(double start, double end);
bool in_range(double);
private:
explicit TimeRanges();
struct Range {
double start;
double end;
};
Vector<Range> m_ranges;
};
}