mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-27 03:14:15 +00:00 
			
		
		
		
	 762f20944c
			
		
	
	
		762f20944c
		
	
	
	
	
		
			
			If the current line box already has zero width, there's no point in inserting a line break to make space, since we'll just be at x=0 after breaking as well. This removes an ugly unnecessary line break before images wider than their containing block. :^)
		
			
				
	
	
		
			24 lines
		
	
	
	
		
			690 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
	
		
			690 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)
 | |
|     : LayoutBox(&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() > 0 && line_box->width() + width() > container.width())
 | |
|         line_box = &container.add_line_box();
 | |
|     line_box->add_fragment(*this, 0, 0, width(), height());
 | |
| }
 |