2021-01-23 17:50:22 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-01-23 17:50:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-03-05 14:04:14 +01:00
|
|
|
#include <AK/FlyString.h>
|
2021-01-23 17:50:22 +00:00
|
|
|
#include <LibWeb/DOM/Event.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::XHR {
|
|
|
|
|
|
|
|
|
|
// FIXME: All the "u32"s should be "u64"s, however LibJS doesn't currently support constructing values with u64,
|
|
|
|
|
// and the IDL parser doesn't properly parse "unsigned long long".
|
|
|
|
|
|
2021-10-01 18:55:24 +03:00
|
|
|
struct ProgressEventInit : public DOM::EventInit {
|
|
|
|
|
bool length_computable { false };
|
|
|
|
|
u32 loaded { 0 };
|
|
|
|
|
u32 total { 0 };
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-08 22:29:40 +02:00
|
|
|
class ProgressEvent final : public DOM::Event {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(ProgressEvent, DOM::Event);
|
2022-08-08 22:29:40 +02:00
|
|
|
|
2021-01-23 17:50:22 +00:00
|
|
|
public:
|
2023-03-05 14:04:14 +01:00
|
|
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ProgressEvent>> create(JS::Realm&, FlyString const& event_name, ProgressEventInit const& event_init);
|
|
|
|
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ProgressEvent>> construct_impl(JS::Realm&, FlyString const& event_name, ProgressEventInit const& event_init);
|
2021-01-23 17:50:22 +00:00
|
|
|
|
2022-08-08 22:29:40 +02:00
|
|
|
virtual ~ProgressEvent() override;
|
2021-01-23 17:50:22 +00:00
|
|
|
|
|
|
|
|
bool length_computable() const { return m_length_computable; }
|
2022-05-10 11:08:02 +02:00
|
|
|
u64 loaded() const { return m_loaded; }
|
|
|
|
|
u64 total() const { return m_total; }
|
2021-01-23 17:50:22 +00:00
|
|
|
|
2022-08-08 22:29:40 +02:00
|
|
|
private:
|
2023-03-05 14:04:14 +01:00
|
|
|
ProgressEvent(JS::Realm&, FlyString const& event_name, ProgressEventInit const& event_init);
|
2022-09-25 18:08:29 -06:00
|
|
|
|
2023-01-28 12:33:35 -05:00
|
|
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
2023-01-10 06:28:20 -05:00
|
|
|
|
2021-01-23 17:50:22 +00:00
|
|
|
bool m_length_computable { false };
|
2022-05-10 11:08:02 +02:00
|
|
|
u64 m_loaded { 0 };
|
|
|
|
|
u64 m_total { 0 };
|
2021-01-23 17:50:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|