| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 22:07:45 +02:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-18 15:01:28 +01:00
										 |  |  | #include <LibWeb/HTML/BrowsingContext.h>
 | 
					
						
							| 
									
										
										
										
											2020-07-26 15:08:16 +02:00
										 |  |  | #include <LibWeb/HTML/HTMLImageElement.h>
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  | #include <LibWeb/Layout/ReplacedBox.h>
 | 
					
						
							| 
									
										
										
										
											2019-10-05 22:07:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  | namespace Web::Layout { | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-20 18:38:25 +02:00
										 |  |  | class ImageBox final | 
					
						
							| 
									
										
										
										
											2021-01-30 12:25:33 +01:00
										 |  |  |     : public ReplacedBox | 
					
						
							| 
									
										
										
										
											2021-11-18 15:01:28 +01:00
										 |  |  |     , public HTML::BrowsingContext::ViewportClient { | 
					
						
							| 
									
										
										
										
											2022-10-17 14:41:50 +02:00
										 |  |  |     JS_CELL(ImageBox, ReplacedBox); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 22:07:45 +02:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     ImageBox(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>, ImageLoader const&); | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     virtual ~ImageBox() override; | 
					
						
							| 
									
										
										
										
											2019-10-05 22:07:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 13:38:18 +01:00
										 |  |  |     virtual void prepare_for_replaced_layout() override; | 
					
						
							| 
									
										
										
										
											2019-10-05 22:07:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     const DOM::Element& dom_node() const { return static_cast<const DOM::Element&>(ReplacedBox::dom_node()); } | 
					
						
							| 
									
										
										
										
											2019-10-05 23:20:35 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     bool renders_as_alt_text() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-11 12:51:49 +01:00
										 |  |  |     virtual JS::GCPtr<Painting::Paintable> create_paintable() const override; | 
					
						
							| 
									
										
										
										
											2022-03-10 14:02:25 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto const& image_loader() const { return m_image_loader; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-07 16:46:05 +02:00
										 |  |  |     void dom_node_did_update_alt_text(Badge<HTML::HTMLImageElement>); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 22:07:45 +02:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2021-09-08 11:12:22 +02:00
										 |  |  |     // ^BrowsingContext::ViewportClient
 | 
					
						
							| 
									
										
										
										
											2022-11-03 12:49:54 +00:00
										 |  |  |     virtual void browsing_context_did_set_viewport_rect(CSSPixelRect const&) final; | 
					
						
							| 
									
										
										
										
											2021-01-30 12:25:33 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-20 18:38:25 +02:00
										 |  |  |     // ^JS::Cell
 | 
					
						
							|  |  |  |     virtual void finalize() override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-13 22:22:54 +02:00
										 |  |  |     int preferred_width() const; | 
					
						
							|  |  |  |     int preferred_height() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     ImageLoader const& m_image_loader; | 
					
						
							| 
									
										
										
										
											2022-09-07 16:46:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-04 20:54:05 +00:00
										 |  |  |     Optional<CSSPixels> m_cached_alt_text_width; | 
					
						
							| 
									
										
										
										
											2019-10-05 22:07:45 +02:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2019-12-18 20:52:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |