mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 12:12:45 +00:00 
			
		
		
		
	 ac6b3c989d
			
		
	
	
		ac6b3c989d
		
	
	
	
	
		
			
			With this change, instead of applying scroll offsets during the recording of the painting command list, we do the following: 1. Collect all boxes with scrollable overflow into a PaintContext, each with an id and the total amount of scrolling offset accumulated from ancestor scrollable boxes. 2. During the recording phase assign a corresponding scroll_frame_id to each command that paints content within a scrollable box. 3. Before executing the recorded commands, translate each command that has a scroll_frame_id by the accumulated scroll offset. This approach has following advantages: - Implementing nested scrollables becomes much simpler, as the recording phase only requires the correct assignment of the nearest scrollable's scroll_frame_id, while the accumulated offset from ancestors is applied subsequently. - The recording of painting commands is not tied to a specific offset within scrollable boxes, which means in the future, it will be possible to update the scrolling offset and repaint without the need to re-record painting commands.
		
			
				
	
	
		
			31 lines
		
	
	
	
		
			701 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
	
		
			701 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibWeb/Painting/PaintableBox.h>
 | |
| 
 | |
| namespace Web::Painting {
 | |
| 
 | |
| class ViewportPaintable final : public PaintableWithLines {
 | |
|     JS_CELL(ViewportPaintable, PaintableWithLines);
 | |
| 
 | |
| public:
 | |
|     static JS::NonnullGCPtr<ViewportPaintable> create(Layout::Viewport const&);
 | |
|     virtual ~ViewportPaintable() override;
 | |
| 
 | |
|     void paint_all_phases(PaintContext&);
 | |
|     void build_stacking_context_tree_if_needed();
 | |
| 
 | |
|     void collect_scroll_frames(PaintContext&) const;
 | |
| 
 | |
| private:
 | |
|     void build_stacking_context_tree();
 | |
| 
 | |
|     explicit ViewportPaintable(Layout::Viewport const&);
 | |
| };
 | |
| 
 | |
| }
 |