ProgressEvent.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2021, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/FlyString.h>
  8. #include <LibWeb/DOM/Event.h>
  9. namespace Web::XHR {
  10. // FIXME: All the "u32"s should be "u64"s, however LibJS doesn't currently support constructing values with u64,
  11. // and the IDL parser doesn't properly parse "unsigned long long".
  12. struct ProgressEventInit : public DOM::EventInit {
  13. bool length_computable { false };
  14. u32 loaded { 0 };
  15. u32 total { 0 };
  16. };
  17. class ProgressEvent final : public DOM::Event {
  18. WEB_PLATFORM_OBJECT(ProgressEvent, DOM::Event);
  19. public:
  20. static WebIDL::ExceptionOr<JS::NonnullGCPtr<ProgressEvent>> create(JS::Realm&, FlyString const& event_name, ProgressEventInit const& event_init);
  21. static WebIDL::ExceptionOr<JS::NonnullGCPtr<ProgressEvent>> construct_impl(JS::Realm&, FlyString const& event_name, ProgressEventInit const& event_init);
  22. virtual ~ProgressEvent() override;
  23. bool length_computable() const { return m_length_computable; }
  24. u64 loaded() const { return m_loaded; }
  25. u64 total() const { return m_total; }
  26. private:
  27. ProgressEvent(JS::Realm&, FlyString const& event_name, ProgressEventInit const& event_init);
  28. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  29. bool m_length_computable { false };
  30. u64 m_loaded { 0 };
  31. u64 m_total { 0 };
  32. };
  33. }