mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
LibWeb: Implement CountQueuingStrategy highWaterMark property
This commit is contained in:
parent
0d714ad165
commit
c9941ba95b
6 changed files with 95 additions and 0 deletions
|
@ -493,6 +493,7 @@ set(SOURCES
|
|||
SecureContexts/AbstractOperations.cpp
|
||||
SRI/SRI.cpp
|
||||
Streams/AbstractOperations.cpp
|
||||
Streams/CountQueuingStrategy.cpp
|
||||
Streams/ReadableByteStreamController.cpp
|
||||
Streams/ReadableStream.cpp
|
||||
Streams/ReadableStreamBYOBReader.cpp
|
||||
|
|
|
@ -535,6 +535,7 @@ class Selection;
|
|||
}
|
||||
|
||||
namespace Web::Streams {
|
||||
class CountQueuingStrategy;
|
||||
class ReadableByteStreamController;
|
||||
class ReadableStream;
|
||||
class ReadableStreamBYOBReader;
|
||||
|
|
38
Userland/Libraries/LibWeb/Streams/CountQueuingStrategy.cpp
Normal file
38
Userland/Libraries/LibWeb/Streams/CountQueuingStrategy.cpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Shannon Booth <shannon.ml.booth@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/CountQueuingStrategyPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Streams/CountQueuingStrategy.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::Streams {
|
||||
|
||||
// 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"].
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<CountQueuingStrategy>(realm, realm, init.high_water_mark));
|
||||
}
|
||||
|
||||
CountQueuingStrategy::CountQueuingStrategy(JS::Realm& realm, double high_water_mark)
|
||||
: PlatformObject(realm)
|
||||
, m_high_water_mark(high_water_mark)
|
||||
{
|
||||
}
|
||||
|
||||
CountQueuingStrategy::~CountQueuingStrategy() = default;
|
||||
|
||||
JS::ThrowCompletionOr<void> CountQueuingStrategy::initialize(JS::Realm& realm)
|
||||
{
|
||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CountQueuingStrategyPrototype>(realm, "CountQueuingStrategy"));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
43
Userland/Libraries/LibWeb/Streams/CountQueuingStrategy.h
Normal file
43
Userland/Libraries/LibWeb/Streams/CountQueuingStrategy.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Shannon Booth <shannon.ml.booth@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Forward.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/Streams/QueuingStrategyInit.h>
|
||||
|
||||
namespace Web::Streams {
|
||||
|
||||
// https://streams.spec.whatwg.org/#countqueuingstrategy
|
||||
class CountQueuingStrategy final : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(CountQueuingStrategy, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CountQueuingStrategy>> construct_impl(JS::Realm&, QueuingStrategyInit const&);
|
||||
|
||||
virtual ~CountQueuingStrategy() override;
|
||||
|
||||
// https://streams.spec.whatwg.org/#cqs-high-water-mark
|
||||
double high_water_mark() const
|
||||
{
|
||||
// The highWaterMark getter steps are:
|
||||
// 1. Return this.[[highWaterMark]].
|
||||
return m_high_water_mark;
|
||||
}
|
||||
|
||||
private:
|
||||
explicit CountQueuingStrategy(JS::Realm&, double high_water_mark);
|
||||
|
||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
|
||||
// https://streams.spec.whatwg.org/#countqueuingstrategy-highwatermark
|
||||
double m_high_water_mark { 0 };
|
||||
};
|
||||
|
||||
}
|
11
Userland/Libraries/LibWeb/Streams/CountQueuingStrategy.idl
Normal file
11
Userland/Libraries/LibWeb/Streams/CountQueuingStrategy.idl
Normal file
|
@ -0,0 +1,11 @@
|
|||
#import <Streams/QueuingStrategyInit.idl>
|
||||
|
||||
// https://streams.spec.whatwg.org/#cqs-class-definition
|
||||
[Exposed=*]
|
||||
interface CountQueuingStrategy {
|
||||
constructor(QueuingStrategyInit init);
|
||||
|
||||
readonly attribute unrestricted double highWaterMark;
|
||||
|
||||
// FIXME: readonly attribute Function size;
|
||||
};
|
|
@ -186,6 +186,7 @@ libweb_js_bindings(NavigationTiming/PerformanceTiming)
|
|||
libweb_js_bindings(PerformanceTimeline/PerformanceEntry)
|
||||
libweb_js_bindings(RequestIdleCallback/IdleDeadline)
|
||||
libweb_js_bindings(ResizeObserver/ResizeObserver)
|
||||
libweb_js_bindings(Streams/CountQueuingStrategy)
|
||||
libweb_js_bindings(Streams/ReadableByteStreamController)
|
||||
libweb_js_bindings(Streams/ReadableStream)
|
||||
libweb_js_bindings(Streams/ReadableStreamBYOBReader)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue