mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 00:22:43 +00:00 
			
		
		
		
	 f3f0b08d43
			
		
	
	
		f3f0b08d43
		
	
	
	
	
		
			
			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.
		
			
				
	
	
		
			39 lines
		
	
	
	
		
			938 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
	
		
			938 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #pragma once
 | |
| 
 | |
| #include <LibDraw/FloatRect.h>
 | |
| 
 | |
| class LayoutNode;
 | |
| class RenderingContext;
 | |
| 
 | |
| class LineBoxFragment {
 | |
|     friend class LineBox;
 | |
| public:
 | |
|     LineBoxFragment(const LayoutNode& layout_node, int start, int length, const FloatRect& rect)
 | |
|         : m_layout_node(layout_node)
 | |
|         , m_start(start)
 | |
|         , m_length(length)
 | |
|         , m_rect(rect)
 | |
|     {
 | |
|     }
 | |
| 
 | |
|     const LayoutNode& layout_node() const { return m_layout_node; }
 | |
|     int start() const { return m_start; }
 | |
|     int length() const { return m_length; }
 | |
|     const FloatRect& rect() const { return m_rect; }
 | |
|     FloatRect& rect() { return m_rect; }
 | |
| 
 | |
|     float width() const { return m_rect.width(); }
 | |
| 
 | |
|     void render(RenderingContext&);
 | |
| 
 | |
|     bool is_justifiable_whitespace() const;
 | |
|     StringView text() const;
 | |
| 
 | |
|     int text_index_at(float x) const;
 | |
| 
 | |
| private:
 | |
|     const LayoutNode& m_layout_node;
 | |
|     int m_start { 0 };
 | |
|     int m_length { 0 };
 | |
|     FloatRect m_rect;
 | |
| };
 |