Files
ladybird/Libraries/LibWeb/Streams/ByteLengthQueuingStrategy.cpp
Shannon Booth 5adfd1c43a LibWeb/Bindings: Generate struct definitions from IDL dictionaries
Previously we were inconsistent by generating code for enum definitions
but not generating code for dictionaries. With future changes to the
IDL generator to expose helpers to convert to and from IDL values
this produced circular depdendencies. To solve this problem, also
generate the dictionary definitions in bindings headers.
2026-05-09 10:49:49 +02:00

48 lines
1.6 KiB
C++

/*
* Copyright (c) 2023, Shannon Booth <shannon@serenityos.org>
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/ByteLengthQueuingStrategy.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/HTML/UniversalGlobalScope.h>
#include <LibWeb/Streams/ByteLengthQueuingStrategy.h>
namespace Web::Streams {
GC_DEFINE_ALLOCATOR(ByteLengthQueuingStrategy);
// https://streams.spec.whatwg.org/#blqs-constructor
GC::Ref<ByteLengthQueuingStrategy> ByteLengthQueuingStrategy::construct_impl(JS::Realm& realm, Bindings::QueuingStrategyInit const& init)
{
// The new ByteLengthQueuingStrategy(init) constructor steps are:
// 1. Set this.[[highWaterMark]] to init["highWaterMark"].
return realm.create<ByteLengthQueuingStrategy>(realm, init.high_water_mark);
}
ByteLengthQueuingStrategy::ByteLengthQueuingStrategy(JS::Realm& realm, double high_water_mark)
: PlatformObject(realm)
, m_high_water_mark(high_water_mark)
{
}
ByteLengthQueuingStrategy::~ByteLengthQueuingStrategy() = default;
// https://streams.spec.whatwg.org/#blqs-size
GC::Ref<WebIDL::CallbackType> ByteLengthQueuingStrategy::size()
{
// 1. Return this's relevant global object's byte length queuing strategy size function.
auto& global = as<HTML::UniversalGlobalScopeMixin>(HTML::relevant_global_object(*this));
return global.byte_length_queuing_strategy_size_function();
}
void ByteLengthQueuingStrategy::initialize(JS::Realm& realm)
{
WEB_SET_PROTOTYPE_FOR_INTERFACE(ByteLengthQueuingStrategy);
Base::initialize(realm);
}
}