1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:07:45 +00:00

LibWeb: Implement BrowsingContext::selected_text() in terms of Selection

Instead of sifting through the layout tree to extract the selected text,
look at the DOM selection instead.

Note that we can't just stringify the DOM Range, as that would include
non-visible things (like the content of <style> elements, etc.) so we
run it through an ad-hoc variant of the range stringification algorithm.
This can probably be factored better, but it's a start. :^)
This commit is contained in:
Andreas Kling 2023-01-11 19:47:38 +01:00
parent 3cabd17f9b
commit bf69f4370e
2 changed files with 29 additions and 37 deletions

View file

@ -84,6 +84,8 @@ public:
JS::NonnullGCPtr<Geometry::DOMRect> get_bounding_client_rect() const;
bool contains_node(Node const&) const;
private:
explicit Range(Document&);
Range(Node& start_container, u32 start_offset, Node& end_container, u32 end_offset);
@ -105,7 +107,6 @@ private:
WebIDL::ExceptionOr<JS::NonnullGCPtr<DocumentFragment>> clone_the_contents();
WebIDL::ExceptionOr<void> insert(JS::NonnullGCPtr<Node>);
bool contains_node(Node const&) const;
bool partially_contains_node(Node const&) const;
};