ScreenOrientation.h 988 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/Bindings/PlatformObject.h>
  8. #include <LibWeb/Bindings/ScreenOrientationPrototype.h>
  9. #include <LibWeb/DOM/EventTarget.h>
  10. #include <LibWeb/WebIDL/Types.h>
  11. namespace Web::CSS {
  12. class ScreenOrientation final : public DOM::EventTarget {
  13. WEB_PLATFORM_OBJECT(ScreenOrientation, DOM::EventTarget);
  14. JS_DECLARE_ALLOCATOR(ScreenOrientation);
  15. public:
  16. [[nodiscard]] static JS::NonnullGCPtr<ScreenOrientation> create(JS::Realm&);
  17. WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> lock(Bindings::OrientationLockType);
  18. void unlock();
  19. Bindings::OrientationType type() const;
  20. WebIDL::UnsignedShort angle() const;
  21. void set_onchange(JS::GCPtr<WebIDL::CallbackType>);
  22. JS::GCPtr<WebIDL::CallbackType> onchange();
  23. private:
  24. explicit ScreenOrientation(JS::Realm&);
  25. virtual void initialize(JS::Realm&) override;
  26. };
  27. }