2023-06-18 04:43:56 -03:00
|
|
|
/*
|
2023-07-15 07:33:22 -03:00
|
|
|
* Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
|
2023-06-22 17:46:46 -03:00
|
|
|
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
|
2023-06-18 04:43:56 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
2026-04-18 05:54:06 -03:00
|
|
|
#include <LibWeb/Bindings/CountQueuingStrategy.h>
|
2023-06-18 04:43:56 -03:00
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
2024-11-18 06:49:00 -03:00
|
|
|
#include <LibWeb/HTML/UniversalGlobalScope.h>
|
2023-06-18 04:43:56 -03:00
|
|
|
#include <LibWeb/Streams/CountQueuingStrategy.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::Streams {
|
|
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC_DEFINE_ALLOCATOR(CountQueuingStrategy);
|
2023-11-19 15:47:52 -03:00
|
|
|
|
2023-06-18 04:43:56 -03:00
|
|
|
// https://streams.spec.whatwg.org/#blqs-constructor
|
2026-05-01 14:01:23 -03:00
|
|
|
GC::Ref<CountQueuingStrategy> CountQueuingStrategy::construct_impl(JS::Realm& realm, Bindings::QueuingStrategyInit const& init)
|
2023-06-18 04:43:56 -03:00
|
|
|
{
|
|
|
|
|
// The new CountQueuingStrategy(init) constructor steps are:
|
|
|
|
|
// 1. Set this.[[highWaterMark]] to init["highWaterMark"].
|
2024-11-13 13:50:17 -03:00
|
|
|
return realm.create<CountQueuingStrategy>(realm, init.high_water_mark);
|
2023-06-18 04:43:56 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CountQueuingStrategy::CountQueuingStrategy(JS::Realm& realm, double high_water_mark)
|
|
|
|
|
: PlatformObject(realm)
|
|
|
|
|
, m_high_water_mark(high_water_mark)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CountQueuingStrategy::~CountQueuingStrategy() = default;
|
|
|
|
|
|
2023-06-22 17:46:46 -03:00
|
|
|
// https://streams.spec.whatwg.org/#cqs-size
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ref<WebIDL::CallbackType> CountQueuingStrategy::size()
|
2023-06-22 17:46:46 -03:00
|
|
|
{
|
|
|
|
|
// 1. Return this's relevant global object's count queuing strategy size function.
|
2025-08-22 07:59:47 -03:00
|
|
|
auto& global = as<HTML::UniversalGlobalScopeMixin>(HTML::relevant_global_object(*this));
|
|
|
|
|
return global.count_queuing_strategy_size_function();
|
2023-06-22 17:46:46 -03:00
|
|
|
}
|
|
|
|
|
|
2023-08-07 03:41:28 -03:00
|
|
|
void CountQueuingStrategy::initialize(JS::Realm& realm)
|
2023-06-18 04:43:56 -03:00
|
|
|
{
|
2024-03-16 09:13:08 -03:00
|
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(CountQueuingStrategy);
|
2025-04-20 11:22:57 -03:00
|
|
|
Base::initialize(realm);
|
2023-06-18 04:43:56 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|