ladybird/Libraries/LibHTML/Layout/LayoutDocument.h
Andreas Kling f3f0b08d43 LibHTML: Build some foundation for text selection
Add LayoutPosition and LayoutRange classes. The layout tree root node
now has a selection() LayoutRange. It's essentially a start and end
LayoutPosition.

A LayoutPosition is a LayoutNode, and an optional index into that node.
The index is only relevant for text nodes, where it's the character
index into the rendered text.

HtmlView now updates the selection start/end of the LayoutDocument when
clicking and dragging with the left mouse button.

We don't paint the selection yet, and there's no way to copy what's
selected. It only exists as a LayoutRange.
2019-11-05 22:13:26 +01:00

20 lines
639 B
C++

#pragma once
#include <LibHTML/DOM/Document.h>
#include <LibHTML/Layout/LayoutBlock.h>
class LayoutDocument final : public LayoutBlock {
public:
explicit LayoutDocument(const Document&, NonnullRefPtr<StyleProperties>);
virtual ~LayoutDocument() override;
const Document& node() const { return static_cast<const Document&>(*LayoutNode::node()); }
virtual const char* class_name() const override { return "LayoutDocument"; }
virtual void layout() override;
const LayoutRange& selection() const { return m_selection; }
LayoutRange& selection() { return m_selection; }
private:
LayoutRange m_selection;
};