2023-06-18 19:43:56 +12:00
|
|
|
/*
|
2023-07-15 22:33:22 +12:00
|
|
|
* Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
|
2023-06-23 08:46:46 +12:00
|
|
|
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
|
2023-06-18 19:43:56 +12:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibWeb/Bindings/CountQueuingStrategyPrototype.h>
|
|
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
2023-06-23 08:46:46 +12:00
|
|
|
#include <LibWeb/HTML/Window.h>
|
2023-06-18 19:43:56 +12:00
|
|
|
#include <LibWeb/Streams/CountQueuingStrategy.h>
|
|
|
|
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::Streams {
|
|
|
|
|
|
2023-11-19 19:47:52 +01:00
|
|
|
JS_DEFINE_ALLOCATOR(CountQueuingStrategy);
|
|
|
|
|
|
2023-06-18 19:43:56 +12:00
|
|
|
// https://streams.spec.whatwg.org/#blqs-constructor
|
|
|
|
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<CountQueuingStrategy>> CountQueuingStrategy::construct_impl(JS::Realm& realm, QueuingStrategyInit const& init)
|
|
|
|
|
{
|
|
|
|
|
// The new CountQueuingStrategy(init) constructor steps are:
|
|
|
|
|
// 1. Set this.[[highWaterMark]] to init["highWaterMark"].
|
2023-08-13 13:05:26 +02:00
|
|
|
return realm.heap().allocate<CountQueuingStrategy>(realm, realm, init.high_water_mark);
|
2023-06-18 19:43:56 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CountQueuingStrategy::CountQueuingStrategy(JS::Realm& realm, double high_water_mark)
|
|
|
|
|
: PlatformObject(realm)
|
|
|
|
|
, m_high_water_mark(high_water_mark)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CountQueuingStrategy::~CountQueuingStrategy() = default;
|
|
|
|
|
|
2023-06-23 08:46:46 +12:00
|
|
|
// https://streams.spec.whatwg.org/#cqs-size
|
|
|
|
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> CountQueuingStrategy::size()
|
|
|
|
|
{
|
|
|
|
|
// 1. Return this's relevant global object's count queuing strategy size function.
|
|
|
|
|
return global_object().count_queuing_strategy_size_function();
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
void CountQueuingStrategy::initialize(JS::Realm& realm)
|
2023-06-18 19:43:56 +12:00
|
|
|
{
|
2023-08-07 08:41:28 +02:00
|
|
|
Base::initialize(realm);
|
2023-11-22 12:55:21 +13:00
|
|
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::CountQueuingStrategyPrototype>(realm, "CountQueuingStrategy"_fly_string));
|
2023-06-18 19:43:56 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|