| 
									
										
										
										
											2019-10-15 16:48:38 +02:00
										 |  |  | #include <LibHTML/Dump.h>
 | 
					
						
							| 
									
										
										
										
											2019-12-18 20:57:18 +01:00
										 |  |  | #include <LibHTML/Frame.h>
 | 
					
						
							| 
									
										
										
										
											2019-06-15 23:41:15 +02:00
										 |  |  | #include <LibHTML/Layout/LayoutDocument.h>
 | 
					
						
							| 
									
										
										
										
											2019-12-18 20:57:18 +01:00
										 |  |  | #include <LibHTML/Layout/LayoutImage.h>
 | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-07 09:23:53 +02:00
										 |  |  | LayoutDocument::LayoutDocument(const Document& document, NonnullRefPtr<StyleProperties> style) | 
					
						
							|  |  |  |     : LayoutBlock(&document, move(style)) | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | LayoutDocument::~LayoutDocument() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-06-16 21:35:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void LayoutDocument::layout() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-10-04 15:50:04 +02:00
										 |  |  |     ASSERT(document().frame()); | 
					
						
							|  |  |  |     rect().set_width(document().frame()->size().width()); | 
					
						
							| 
									
										
										
										
											2019-09-25 12:29:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-16 21:35:03 +02:00
										 |  |  |     LayoutNode::layout(); | 
					
						
							| 
									
										
										
										
											2019-09-25 12:29:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-15 16:48:38 +02:00
										 |  |  |     ASSERT(!children_are_inline()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-25 12:29:25 +03:00
										 |  |  |     int lowest_bottom = 0; | 
					
						
							|  |  |  |     for_each_child([&](auto& child) { | 
					
						
							| 
									
										
										
										
											2019-10-15 16:48:38 +02:00
										 |  |  |         ASSERT(is<LayoutBlock>(child)); | 
					
						
							|  |  |  |         auto& child_block = to<LayoutBlock>(child); | 
					
						
							|  |  |  |         if (child_block.rect().bottom() > lowest_bottom) | 
					
						
							|  |  |  |             lowest_bottom = child_block.rect().bottom(); | 
					
						
							| 
									
										
										
										
											2019-09-25 12:29:25 +03:00
										 |  |  |     }); | 
					
						
							|  |  |  |     rect().set_bottom(lowest_bottom); | 
					
						
							| 
									
										
										
										
											2019-06-16 21:35:03 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-12-18 20:57:18 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void LayoutDocument::did_set_viewport_rect(Badge<Frame>, const Rect& a_viewport_rect) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     FloatRect viewport_rect(a_viewport_rect.x(), a_viewport_rect.y(), a_viewport_rect.width(), a_viewport_rect.height()); | 
					
						
							| 
									
										
										
										
											2019-12-18 21:34:03 +01:00
										 |  |  |     for_each_in_subtree_of_type<LayoutImage>([&](auto& layout_image) { | 
					
						
							|  |  |  |         const_cast<HTMLImageElement&>(layout_image.node()).set_volatile({}, !viewport_rect.intersects(layout_image.rect())); | 
					
						
							| 
									
										
										
										
											2019-12-18 20:57:18 +01:00
										 |  |  |         return IterationDecision::Continue; | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | } |