mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:52:45 +00:00 
			
		
		
		
	LibWeb: Add missing paintable null check in get_bounding_client_rect()
Fixes crashing on https://github.com/
This commit is contained in:
		
							parent
							
								
									f361b8c000
								
							
						
					
					
						commit
						8f8ec37d58
					
				
					 3 changed files with 15 additions and 1 deletions
				
			
		|  | @ -0,0 +1 @@ | |||
|    {"x":0,"y":0,"width":0,"height":0,"top":0,"right":0,"bottom":0,"left":0} | ||||
|  | @ -0,0 +1,12 @@ | |||
| <!DOCTYPE html> | ||||
| <style type="text/css"> | ||||
|     #box { display: none; } | ||||
| </style> | ||||
| <div id="box"></div> | ||||
| <script src="include.js"></script> | ||||
| <script> | ||||
|     test(() => { | ||||
|         const rect = document.getElementById("box").getBoundingClientRect(); | ||||
|         println(JSON.stringify(rect)); | ||||
|     }); | ||||
| </script> | ||||
|  | @ -844,7 +844,8 @@ JS::NonnullGCPtr<Geometry::DOMRect> Element::get_bounding_client_rect() const | |||
|         return Geometry::DOMRect::create(realm(), absolute_rect.to_type<float>()); | ||||
|     } | ||||
| 
 | ||||
|     if (auto const* paintable = this->paintable(); is<Painting::InlinePaintable>(*paintable)) { | ||||
|     auto const* paintable = this->paintable(); | ||||
|     if (paintable && is<Painting::InlinePaintable>(*paintable)) { | ||||
|         auto const& inline_paintable = static_cast<Painting::InlinePaintable const&>(*paintable); | ||||
|         auto absolute_rect = inline_paintable.bounding_rect(); | ||||
|         absolute_rect.translate_by(-viewport_offset.x(), -viewport_offset.y()); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Aliaksandr Kalenik
						Aliaksandr Kalenik