UniversalGlobalScope.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2023, Linus Groh <linusg@serenityos.org>
  3. * Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
  4. * Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
  5. *
  6. * SPDX-License-Identifier: BSD-2-Clause
  7. */
  8. #pragma once
  9. #include <AK/Forward.h>
  10. #include <AK/String.h>
  11. #include <LibJS/Runtime/Value.h>
  12. #include <LibWeb/Forward.h>
  13. #include <LibWeb/WebIDL/ExceptionOr.h>
  14. namespace Web::HTML {
  15. // https://whatpr.org/html/9893/webappapis.html#universalglobalscope-mixin
  16. class UniversalGlobalScopeMixin {
  17. public:
  18. virtual ~UniversalGlobalScopeMixin();
  19. virtual Bindings::PlatformObject& this_impl() = 0;
  20. virtual Bindings::PlatformObject const& this_impl() const = 0;
  21. WebIDL::ExceptionOr<String> btoa(String const& data) const;
  22. WebIDL::ExceptionOr<String> atob(String const& data) const;
  23. void queue_microtask(WebIDL::CallbackType&);
  24. WebIDL::ExceptionOr<JS::Value> structured_clone(JS::Value, StructuredSerializeOptions const&) const;
  25. GC::Ref<WebIDL::CallbackType> count_queuing_strategy_size_function();
  26. GC::Ref<WebIDL::CallbackType> byte_length_queuing_strategy_size_function();
  27. protected:
  28. void visit_edges(GC::Cell::Visitor&);
  29. private:
  30. // https://streams.spec.whatwg.org/#count-queuing-strategy-size-function
  31. GC::Ptr<WebIDL::CallbackType> m_count_queuing_strategy_size_function;
  32. // https://streams.spec.whatwg.org/#byte-length-queuing-strategy-size-function
  33. GC::Ptr<WebIDL::CallbackType> m_byte_length_queuing_strategy_size_function;
  34. };
  35. }