DOMPointReadOnly.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <LibGfx/Point.h>
  9. #include <LibWeb/Bindings/PlatformObject.h>
  10. #include <LibWeb/Forward.h>
  11. namespace Web::Geometry {
  12. struct DOMPointInit {
  13. double x { 0 };
  14. double y { 0 };
  15. double z { 0 };
  16. double w { 1 };
  17. };
  18. // https://drafts.fxtf.org/geometry/#dompointreadonly
  19. class DOMPointReadOnly : public Bindings::PlatformObject {
  20. WEB_PLATFORM_OBJECT(DOMPointReadOnly, Bindings::PlatformObject);
  21. public:
  22. static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMPointReadOnly>> construct_impl(JS::Realm&, double x = 0, double y = 0, double z = 0, double w = 1);
  23. static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMPointReadOnly>> from_point(JS::VM&, DOMPointInit const&);
  24. virtual ~DOMPointReadOnly() override;
  25. double x() const { return m_x; }
  26. double y() const { return m_y; }
  27. double z() const { return m_z; }
  28. double w() const { return m_w; }
  29. protected:
  30. DOMPointReadOnly(JS::Realm&, double x, double y, double z, double w);
  31. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  32. double m_x;
  33. double m_y;
  34. double m_z;
  35. double m_w;
  36. };
  37. }