StaticRange.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
  3. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <LibWeb/DOM/AbstractRange.h>
  9. namespace Web::DOM {
  10. // NOTE: We must use GCP instead of NNGCP here, otherwise the generated code cannot default initialize this struct.
  11. // They will never be null, as they are marked as required and non-null in the dictionary.
  12. struct StaticRangeInit {
  13. JS::GCPtr<Node> start_container;
  14. u32 start_offset { 0 };
  15. JS::GCPtr<Node> end_container;
  16. u32 end_offset { 0 };
  17. };
  18. class StaticRange final : public AbstractRange {
  19. WEB_PLATFORM_OBJECT(StaticRange, AbstractRange);
  20. public:
  21. static WebIDL::ExceptionOr<JS::NonnullGCPtr<StaticRange>> construct_impl(JS::Realm&, StaticRangeInit& init);
  22. StaticRange(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset);
  23. virtual ~StaticRange() override;
  24. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  25. };
  26. }