2023-04-18 16:19:37 -04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibJS/Forward.h>
|
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2025-02-14 11:22:12 +01:00
|
|
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
2023-04-18 16:19:37 -04:00
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
2025-02-14 11:22:12 +01:00
|
|
|
// https://html.spec.whatwg.org/multipage/media.html#time-ranges
|
2023-04-18 16:19:37 -04:00
|
|
|
class TimeRanges final : public Bindings::PlatformObject {
|
|
|
|
WEB_PLATFORM_OBJECT(TimeRanges, Bindings::PlatformObject);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(TimeRanges);
|
2023-04-18 16:19:37 -04:00
|
|
|
|
|
|
|
public:
|
2025-02-14 11:22:12 +01:00
|
|
|
// https://html.spec.whatwg.org/multipage/media.html#dom-timeranges-length
|
2023-04-18 16:19:37 -04:00
|
|
|
size_t length() const;
|
2025-02-14 11:22:12 +01:00
|
|
|
|
|
|
|
// 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);
|
2023-04-18 16:19:37 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
explicit TimeRanges(JS::Realm&);
|
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2025-02-14 11:22:12 +01:00
|
|
|
|
|
|
|
struct Range {
|
|
|
|
double start;
|
|
|
|
double end;
|
|
|
|
};
|
|
|
|
|
|
|
|
Vector<Range> m_ranges;
|
2023-04-18 16:19:37 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|