| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2022-03-09 23:53:41 +01:00
										 |  |  |  * Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org> | 
					
						
							| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-06 20:02:41 +02:00
										 |  |  | #include <LibWeb/Layout/BlockContainer.h>
 | 
					
						
							| 
									
										
										
										
											2022-03-10 23:13:37 +01:00
										 |  |  | #include <LibWeb/Painting/PaintableBox.h>
 | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  | namespace Web::Layout { | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-06 20:02:41 +02:00
										 |  |  | BlockContainer::BlockContainer(DOM::Document& document, DOM::Node* node, NonnullRefPtr<CSS::StyleProperties> style) | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     : Box(document, node, move(style)) | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-06 20:02:41 +02:00
										 |  |  | BlockContainer::BlockContainer(DOM::Document& document, DOM::Node* node, CSS::ComputedValues computed_values) | 
					
						
							| 
									
										
										
										
											2021-01-06 14:10:53 +01:00
										 |  |  |     : Box(document, node, move(computed_values)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-14 13:21:51 -06:00
										 |  |  | BlockContainer::~BlockContainer() = default; | 
					
						
							| 
									
										
										
										
											2019-06-20 23:00:26 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-06 20:02:41 +02:00
										 |  |  | bool BlockContainer::is_scrollable() const | 
					
						
							| 
									
										
										
										
											2021-02-22 23:44:51 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     // FIXME: Support horizontal scroll as well (overflow-x)
 | 
					
						
							|  |  |  |     return computed_values().overflow_y() == CSS::Overflow::Scroll; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  | void BlockContainer::set_scroll_offset(Gfx::FloatPoint const& offset) | 
					
						
							| 
									
										
										
										
											2021-02-22 19:48:24 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-03-02 17:05:17 +01:00
										 |  |  |     // FIXME: If there is horizontal and vertical scroll ignore only part of the new offset
 | 
					
						
							|  |  |  |     if (offset.y() < 0 || m_scroll_offset == offset) | 
					
						
							| 
									
										
										
										
											2021-02-22 19:48:24 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  |     m_scroll_offset = offset; | 
					
						
							|  |  |  |     set_needs_display(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-10 11:26:01 +01:00
										 |  |  | Painting::PaintableWithLines const* BlockContainer::paint_box() const | 
					
						
							| 
									
										
										
										
											2022-03-10 11:12:06 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-03-10 11:26:01 +01:00
										 |  |  |     return static_cast<Painting::PaintableWithLines const*>(Box::paint_box()); | 
					
						
							| 
									
										
										
										
											2022-03-10 11:12:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-10 22:38:08 +01:00
										 |  |  | RefPtr<Painting::Paintable> BlockContainer::create_paintable() const | 
					
						
							| 
									
										
										
										
											2022-03-10 14:02:25 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return Painting::PaintableWithLines::create(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  | } |