summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Selection/Selection.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-10-10 19:12:32 +0200
committerAndreas Kling <kling@serenityos.org>2021-10-11 00:32:19 +0200
commit5c9ca5c2dccbb8800ac78bf3ab74e372bb3b8895 (patch)
tree79fe0c4c09edc0e9aa010a5b8c455d6924053f6d /Userland/Libraries/LibWeb/Selection/Selection.h
parent6782cf519370c09781b14559c83f156e82792f72 (diff)
downloadserenity-5c9ca5c2dccbb8800ac78bf3ab74e372bb3b8895.zip
LibWeb: Stub out a basic Selection interface
This patch establishes scaffolding for the Selection API.
Diffstat (limited to 'Userland/Libraries/LibWeb/Selection/Selection.h')
-rw-r--r--Userland/Libraries/LibWeb/Selection/Selection.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Selection/Selection.h b/Userland/Libraries/LibWeb/Selection/Selection.h
new file mode 100644
index 0000000000..56731c9aab
--- /dev/null
+++ b/Userland/Libraries/LibWeb/Selection/Selection.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/NonnullRefPtr.h>
+#include <AK/RefCounted.h>
+#include <LibWeb/Bindings/Wrappable.h>
+
+namespace Web::Selection {
+
+class Selection
+ : public RefCounted<Selection>
+ , public Bindings::Wrappable {
+public:
+ using WrapperType = Bindings::SelectionWrapper;
+
+ static NonnullRefPtr<Selection> create();
+
+ DOM::Node* anchor_node();
+ unsigned anchor_offset();
+ DOM::Node* focus_node();
+ unsigned focus_offset() const;
+ bool is_collapsed() const;
+ unsigned range_count() const;
+ String type() const;
+ NonnullRefPtr<DOM::Range> get_range_at(unsigned index);
+ void add_range(DOM::Range&);
+ void remove_range(DOM::Range&);
+ void remove_all_ranges();
+ void empty();
+ void collapse(DOM::Node*, unsigned offset);
+ void set_position(DOM::Node*, unsigned offset);
+ void collapse_to_start();
+ void collapse_to_end();
+ void extend(DOM::Node&, unsigned offset);
+ void set_base_and_extent(DOM::Node& anchor_node, unsigned anchor_offset, DOM::Node& focus_node, unsigned focus_offset);
+ void select_all_children(DOM::Node&);
+ void delete_from_document();
+ bool contains_node(DOM::Node&, bool allow_partial_containment) const;
+
+ String to_string() const;
+};
+
+}