mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 05:10:57 +00:00 
			
		
		
		
	 44979ad7a5
			
		
	
	
		44979ad7a5
		
	
	
	
	
		
			
			Replaced elements will now properly create line breaks when they use up the available horizontal space. This fixes an issue with <img>'s lining up instead of breaking.
		
			
				
	
	
		
			24 lines
		
	
	
	
		
			675 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
	
		
			675 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #include <LibHTML/DOM/Element.h>
 | |
| #include <LibHTML/Layout/LayoutBlock.h>
 | |
| #include <LibHTML/Layout/LayoutReplaced.h>
 | |
| 
 | |
| LayoutReplaced::LayoutReplaced(const Element& element, NonnullRefPtr<StyleProperties> style)
 | |
|     : LayoutNodeWithStyle(&element, move(style))
 | |
| {
 | |
|     // FIXME: Allow non-inline replaced elements.
 | |
|     set_inline(true);
 | |
| }
 | |
| 
 | |
| LayoutReplaced::~LayoutReplaced()
 | |
| {
 | |
| }
 | |
| 
 | |
| void LayoutReplaced::split_into_lines(LayoutBlock& container)
 | |
| {
 | |
|     layout();
 | |
| 
 | |
|     auto* line_box = &container.ensure_last_line_box();
 | |
|     if (line_box->width() + width() > container.width())
 | |
|         line_box = &container.add_line_box();
 | |
|     line_box->add_fragment(*this, 0, 0, width(), height());
 | |
| }
 |