| 
									
										
										
										
											2019-06-15 23:41:15 +02:00
										 |  |  | #include <LibHTML/DOM/Element.h>
 | 
					
						
							| 
									
										
										
										
											2019-10-03 15:20:13 +02:00
										 |  |  | #include <LibHTML/Layout/LayoutBlock.h>
 | 
					
						
							| 
									
										
										
										
											2019-06-15 23:41:15 +02:00
										 |  |  | #include <LibHTML/Layout/LayoutInline.h>
 | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-21 15:32:17 +03:00
										 |  |  | LayoutInline::LayoutInline(const Node& node, StyleProperties&& style_properties) | 
					
						
							|  |  |  |     : LayoutNode(&node, move(style_properties)) | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | LayoutInline::~LayoutInline() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-09-25 12:30:13 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | void LayoutInline::layout() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Point origin; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (previous_sibling() != nullptr) { | 
					
						
							|  |  |  |         auto& previous_sibling_rect = previous_sibling()->rect(); | 
					
						
							|  |  |  |         auto& previous_sibling_style = previous_sibling()->style(); | 
					
						
							|  |  |  |         origin = previous_sibling_rect.location(); | 
					
						
							|  |  |  |         // FIXME: Implement proper inline positioning when
 | 
					
						
							|  |  |  |         // there are nodes with different heights. And don't
 | 
					
						
							|  |  |  |         // hardcode font size like we do here.
 | 
					
						
							|  |  |  |         origin.move_by(previous_sibling_rect.width(), previous_sibling_rect.height()); | 
					
						
							|  |  |  |         origin.move_by(previous_sibling_style.full_margin().right, -11); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         origin = parent()->rect().location(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     rect().set_location(origin); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for_each_child([&](auto& child) { | 
					
						
							|  |  |  |         child.layout(); | 
					
						
							|  |  |  |         rect().set_right(child.rect().right() + child.style().full_margin().right); | 
					
						
							|  |  |  |         rect().set_bottom(child.rect().bottom() + child.style().full_margin().bottom); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-10-03 15:20:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void LayoutInline::split_into_lines(LayoutBlock& container) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     for_each_child([&](auto& child) { | 
					
						
							|  |  |  |         if (child.is_inline()) { | 
					
						
							|  |  |  |             static_cast<LayoutInline&>(child).split_into_lines(container); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             // FIXME: Support block children of inlines.
 | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | } |