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