mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:52:45 +00:00 
			
		
		
		
	LibWeb: Add compute_combined_css_transform() for PaintableBox
				
					
				
			This prepares for upcoming changes where the code that finds combined CSS transform will be reused in `clear_clip_overflow_rect()`.
This commit is contained in:
		
							parent
							
								
									080d9ec246
								
							
						
					
					
						commit
						1ae416fa94
					
				
					 2 changed files with 16 additions and 9 deletions
				
			
		|  | @ -142,6 +142,16 @@ CSSPixelRect PaintableBox::compute_absolute_padding_rect_with_css_transform_appl | |||
|     return padding_rect; | ||||
| } | ||||
| 
 | ||||
| Gfx::AffineTransform PaintableBox::compute_combined_css_transform() const | ||||
| { | ||||
|     Gfx::AffineTransform combined_transform; | ||||
|     for (auto const* ancestor = &this->layout_box(); ancestor; ancestor = ancestor->containing_block()) { | ||||
|         auto affine_transform = Gfx::extract_2d_affine_transform(ancestor->paintable_box()->transform()); | ||||
|         combined_transform = combined_transform.multiply(affine_transform); | ||||
|     } | ||||
|     return combined_transform; | ||||
| } | ||||
| 
 | ||||
| CSSPixelRect PaintableBox::absolute_rect() const | ||||
| { | ||||
|     if (!m_absolute_rect.has_value()) | ||||
|  | @ -425,15 +435,11 @@ void PaintableBox::apply_clip_overflow_rect(PaintContext& context, PaintPhase ph | |||
| 
 | ||||
|     if (clip_rect().has_value()) { | ||||
|         auto overflow_clip_rect = clip_rect().value(); | ||||
|         for (auto const* ancestor = &this->layout_box(); ancestor; ancestor = ancestor->containing_block()) { | ||||
|             auto affine_transform = Gfx::extract_2d_affine_transform(ancestor->paintable_box()->transform()); | ||||
|             if (!affine_transform.is_identity()) { | ||||
|                 // NOTE: Since the painting command executor applies a CSS transform and the clip rect is calculated
 | ||||
|                 //       with this transform in account, we need to remove the transform from the clip rect.
 | ||||
|                 //       Otherwise, the transform will be applied twice to the clip rect.
 | ||||
|                 overflow_clip_rect.translate_by(-affine_transform.translation().to_type<CSSPixels>()); | ||||
|             } | ||||
|         } | ||||
|         // NOTE: Since the painting command executor applies a CSS transform and the clip rect is calculated
 | ||||
|         //       with this transform in account, we need to remove the transform from the clip rect.
 | ||||
|         //       Otherwise, the transform will be applied twice to the clip rect.
 | ||||
|         auto combined_transform = compute_combined_css_transform(); | ||||
|         overflow_clip_rect.translate_by(-combined_transform.translation().to_type<CSSPixels>()); | ||||
| 
 | ||||
|         m_clipping_overflow = true; | ||||
|         context.recording_painter().save(); | ||||
|  |  | |||
|  | @ -200,6 +200,7 @@ public: | |||
|     CSSPixelPoint const& transform_origin() const { return m_transform_origin; } | ||||
| 
 | ||||
|     CSSPixelRect compute_absolute_padding_rect_with_css_transform_applied() const; | ||||
|     Gfx::AffineTransform compute_combined_css_transform() const; | ||||
| 
 | ||||
|     Optional<CSSPixelRect> get_clip_rect() const; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Aliaksandr Kalenik
						Aliaksandr Kalenik