
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.
20 lines
639 B
C++
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;
|
|
};
|