mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 05:57:35 +00:00
LibWeb: Implement size attribute of ByteLengthQueuingStrategy
Co-authored-by: Matthew Olsson <mattco@serenityos.org>
This commit is contained in:
parent
b2a51e86e5
commit
a975fca42e
5 changed files with 42 additions and 1 deletions
|
@ -111,6 +111,7 @@ void Window::visit_edges(JS::Cell::Visitor& visitor)
|
||||||
for (auto& mime_type_object : m_pdf_viewer_mime_type_objects)
|
for (auto& mime_type_object : m_pdf_viewer_mime_type_objects)
|
||||||
visitor.visit(mime_type_object);
|
visitor.visit(mime_type_object);
|
||||||
visitor.visit(m_count_queuing_strategy_size_function);
|
visitor.visit(m_count_queuing_strategy_size_function);
|
||||||
|
visitor.visit(m_byte_length_queuing_strategy_size_function);
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::~Window() = default;
|
Window::~Window() = default;
|
||||||
|
@ -780,6 +781,30 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> Window::count_queuin
|
||||||
return JS::NonnullGCPtr { *m_count_queuing_strategy_size_function };
|
return JS::NonnullGCPtr { *m_count_queuing_strategy_size_function };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://streams.spec.whatwg.org/#byte-length-queuing-strategy-size-function
|
||||||
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> Window::byte_length_queuing_strategy_size_function()
|
||||||
|
{
|
||||||
|
auto& realm = this->realm();
|
||||||
|
|
||||||
|
if (!m_byte_length_queuing_strategy_size_function) {
|
||||||
|
// 1. Let steps be the following steps, given chunk:
|
||||||
|
auto steps = [](JS::VM& vm) {
|
||||||
|
auto chunk = vm.argument(0);
|
||||||
|
|
||||||
|
// 1. Return ? GetV(chunk, "byteLength").
|
||||||
|
return chunk.get(vm, vm.names.byteLength);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 2. Let F be ! CreateBuiltinFunction(steps, 1, "size", « », globalObject’s relevant Realm).
|
||||||
|
auto function = JS::NativeFunction::create(realm, move(steps), 1, "size", &realm);
|
||||||
|
|
||||||
|
// 3. Set globalObject’s byte length queuing strategy size function to a Function that represents a reference to F, with callback context equal to globalObject’s relevant settings object.
|
||||||
|
m_byte_length_queuing_strategy_size_function = MUST_OR_THROW_OOM(heap().allocate<WebIDL::CallbackType>(realm, *function, relevant_settings_object(*this)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return JS::NonnullGCPtr { *m_byte_length_queuing_strategy_size_function };
|
||||||
|
}
|
||||||
|
|
||||||
WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironmentSettingsObject>)
|
WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironmentSettingsObject>)
|
||||||
{
|
{
|
||||||
auto& realm = this->realm();
|
auto& realm = this->realm();
|
||||||
|
|
|
@ -123,6 +123,7 @@ public:
|
||||||
CrossOriginPropertyDescriptorMap& cross_origin_property_descriptor_map() { return m_cross_origin_property_descriptor_map; }
|
CrossOriginPropertyDescriptorMap& cross_origin_property_descriptor_map() { return m_cross_origin_property_descriptor_map; }
|
||||||
|
|
||||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> count_queuing_strategy_size_function();
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> count_queuing_strategy_size_function();
|
||||||
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> byte_length_queuing_strategy_size_function();
|
||||||
|
|
||||||
// JS API functions
|
// JS API functions
|
||||||
JS::NonnullGCPtr<WindowProxy> window() const;
|
JS::NonnullGCPtr<WindowProxy> window() const;
|
||||||
|
@ -246,6 +247,9 @@ private:
|
||||||
|
|
||||||
// https://streams.spec.whatwg.org/#count-queuing-strategy-size-function
|
// https://streams.spec.whatwg.org/#count-queuing-strategy-size-function
|
||||||
JS::GCPtr<WebIDL::CallbackType> m_count_queuing_strategy_size_function;
|
JS::GCPtr<WebIDL::CallbackType> m_count_queuing_strategy_size_function;
|
||||||
|
|
||||||
|
// https://streams.spec.whatwg.org/#byte-length-queuing-strategy-size-function
|
||||||
|
JS::GCPtr<WebIDL::CallbackType> m_byte_length_queuing_strategy_size_function;
|
||||||
};
|
};
|
||||||
|
|
||||||
void run_animation_frame_callbacks(DOM::Document&, double now);
|
void run_animation_frame_callbacks(DOM::Document&, double now);
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2023, Shannon Booth <shannon.ml.booth@gmail.com>
|
* Copyright (c) 2023, Shannon Booth <shannon.ml.booth@gmail.com>
|
||||||
|
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibWeb/Bindings/ByteLengthQueuingStrategyPrototype.h>
|
#include <LibWeb/Bindings/ByteLengthQueuingStrategyPrototype.h>
|
||||||
#include <LibWeb/Bindings/Intrinsics.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
|
#include <LibWeb/HTML/Window.h>
|
||||||
#include <LibWeb/Streams/ByteLengthQueuingStrategy.h>
|
#include <LibWeb/Streams/ByteLengthQueuingStrategy.h>
|
||||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||||
|
|
||||||
|
@ -27,6 +29,13 @@ ByteLengthQueuingStrategy::ByteLengthQueuingStrategy(JS::Realm& realm, double hi
|
||||||
|
|
||||||
ByteLengthQueuingStrategy::~ByteLengthQueuingStrategy() = default;
|
ByteLengthQueuingStrategy::~ByteLengthQueuingStrategy() = default;
|
||||||
|
|
||||||
|
// https://streams.spec.whatwg.org/#blqs-size
|
||||||
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> ByteLengthQueuingStrategy::size()
|
||||||
|
{
|
||||||
|
// 1. Return this's relevant global object's byte length queuing strategy size function.
|
||||||
|
return global_object().byte_length_queuing_strategy_size_function();
|
||||||
|
}
|
||||||
|
|
||||||
JS::ThrowCompletionOr<void> ByteLengthQueuingStrategy::initialize(JS::Realm& realm)
|
JS::ThrowCompletionOr<void> ByteLengthQueuingStrategy::initialize(JS::Realm& realm)
|
||||||
{
|
{
|
||||||
MUST_OR_THROW_OOM(Base::initialize(realm));
|
MUST_OR_THROW_OOM(Base::initialize(realm));
|
||||||
|
|
|
@ -31,6 +31,8 @@ public:
|
||||||
return m_high_water_mark;
|
return m_high_water_mark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::CallbackType>> size();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ByteLengthQueuingStrategy(JS::Realm&, double high_water_mark);
|
explicit ByteLengthQueuingStrategy(JS::Realm&, double high_water_mark);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#import <WebIDL/Function.idl>
|
||||||
#import <Streams/QueuingStrategyInit.idl>
|
#import <Streams/QueuingStrategyInit.idl>
|
||||||
|
|
||||||
// https://streams.spec.whatwg.org/#blqs-class-definition
|
// https://streams.spec.whatwg.org/#blqs-class-definition
|
||||||
|
@ -7,5 +8,5 @@ interface ByteLengthQueuingStrategy {
|
||||||
|
|
||||||
readonly attribute unrestricted double highWaterMark;
|
readonly attribute unrestricted double highWaterMark;
|
||||||
|
|
||||||
// FIXME: readonly attribute Function size;
|
readonly attribute Function size;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue