mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 05:10:57 +00:00 
			
		
		
		
	 1fe2cca439
			
		
	
	
		1fe2cca439
		
	
	
	
	
		
			
			This way the fragment offsets make a lot more sense, since they assume whitespace has already been collapsed.
		
			
				
	
	
		
			40 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| #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;
 | |
|     const String& text_for_rendering() const { return m_text_for_rendering; }
 | |
| 
 | |
|     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;
 | |
| 
 | |
|     String m_text_for_rendering;
 | |
| };
 | |
| 
 | |
| template<>
 | |
| inline bool is<LayoutText>(const LayoutNode& node)
 | |
| {
 | |
|     return node.is_text();
 | |
| }
 |