Selection.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/NonnullRefPtr.h>
  8. #include <AK/RefCounted.h>
  9. #include <LibWeb/Bindings/Wrappable.h>
  10. namespace Web::Selection {
  11. class Selection
  12. : public RefCounted<Selection>
  13. , public Bindings::Wrappable {
  14. public:
  15. using WrapperType = Bindings::SelectionWrapper;
  16. static NonnullRefPtr<Selection> create();
  17. DOM::Node* anchor_node();
  18. unsigned anchor_offset();
  19. DOM::Node* focus_node();
  20. unsigned focus_offset() const;
  21. bool is_collapsed() const;
  22. unsigned range_count() const;
  23. String type() const;
  24. NonnullRefPtr<DOM::Range> get_range_at(unsigned index);
  25. void add_range(DOM::Range&);
  26. void remove_range(DOM::Range&);
  27. void remove_all_ranges();
  28. void empty();
  29. void collapse(DOM::Node*, unsigned offset);
  30. void set_position(DOM::Node*, unsigned offset);
  31. void collapse_to_start();
  32. void collapse_to_end();
  33. void extend(DOM::Node&, unsigned offset);
  34. void set_base_and_extent(DOM::Node& anchor_node, unsigned anchor_offset, DOM::Node& focus_node, unsigned focus_offset);
  35. void select_all_children(DOM::Node&);
  36. void delete_from_document();
  37. bool contains_node(DOM::Node&, bool allow_partial_containment) const;
  38. String to_string() const;
  39. };
  40. }