StaticRange.h 935 B

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