ProgressEvent.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #include <LibWeb/WebIDL/Types.h>
  10. namespace Web::XHR {
  11. struct ProgressEventInit : public DOM::EventInit {
  12. bool length_computable { false };
  13. WebIDL::UnsignedLongLong loaded { 0 };
  14. WebIDL::UnsignedLongLong total { 0 };
  15. };
  16. class ProgressEvent final : public DOM::Event {
  17. WEB_PLATFORM_OBJECT(ProgressEvent, DOM::Event);
  18. JS_DECLARE_ALLOCATOR(ProgressEvent);
  19. public:
  20. [[nodiscard]] static 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. WebIDL::UnsignedLongLong loaded() const { return m_loaded; }
  25. WebIDL::UnsignedLongLong total() const { return m_total; }
  26. private:
  27. ProgressEvent(JS::Realm&, FlyString const& event_name, ProgressEventInit const& event_init);
  28. virtual void initialize(JS::Realm&) override;
  29. bool m_length_computable { false };
  30. WebIDL::UnsignedLongLong m_loaded { 0 };
  31. WebIDL::UnsignedLongLong m_total { 0 };
  32. };
  33. }