summaryrefslogtreecommitdiff
path: root/Libraries/LibHTML/Layout/LayoutText.h
blob: 9b70ecdc4cd25c13e4550d86aba519681fa25280 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once

#include <LibHTML/DOM/Text.h>
#include <LibHTML/Layout/LayoutNode.h>

class LineBoxFragment;

class LayoutText : public LayoutNode {
public:
    explicit LayoutText(const Text&);
    virtual ~LayoutText() override;

    const Text& node() const { return static_cast<const Text&>(*LayoutNode::node()); }

    const String& text_for_style(const StyleProperties&) const;

    virtual const char* class_name() const override { return "LayoutText"; }
    virtual bool is_text() const final { return true; }

    void render_fragment(RenderingContext&, const LineBoxFragment&) const;

    virtual void split_into_lines(LayoutBlock& container) override;

    const StyleProperties& style() const { return parent()->style(); }

private:
    template<typename Callback>
    void for_each_word(Callback) const;
    template<typename Callback>
    void for_each_source_line(Callback) const;
};