mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 20:22:45 +00:00 
			
		
		
		
	LibGUI: Defer line reflow during text insertion
Add a deferral counter and defer reflowing the visual lines until the counter is at zero. Use this to defer reflow when inserting text. This fixes glacial slowdown while paste large amounts of text.
This commit is contained in:
		
							parent
							
								
									30edd198ec
								
							
						
					
					
						commit
						a8f0e4d56e
					
				
					 2 changed files with 42 additions and 0 deletions
				
			
		|  | @ -172,6 +172,24 @@ private: | |||
|     void did_change(); | ||||
|     int fixed_glyph_width() const; | ||||
| 
 | ||||
|     void defer_reflow(); | ||||
|     void undefer_reflow(); | ||||
| 
 | ||||
|     class ReflowDeferrer { | ||||
|     public: | ||||
|         ReflowDeferrer(TextEditor& editor) | ||||
|             : m_editor(editor) | ||||
|         { | ||||
|             m_editor.defer_reflow(); | ||||
|         } | ||||
|         ~ReflowDeferrer() | ||||
|         { | ||||
|             m_editor.undefer_reflow(); | ||||
|         } | ||||
|     private: | ||||
|         TextEditor& m_editor; | ||||
|     }; | ||||
| 
 | ||||
|     Gfx::Rect line_content_rect(size_t item_index) const; | ||||
|     Gfx::Rect line_widget_rect(size_t line_index) const; | ||||
|     Gfx::Rect cursor_content_rect() const; | ||||
|  | @ -238,6 +256,9 @@ private: | |||
|     Core::ElapsedTimer m_triple_click_timer; | ||||
|     NonnullRefPtrVector<Action> m_custom_context_menu_actions; | ||||
| 
 | ||||
|     size_t m_reflow_deferred { 0 }; | ||||
|     size_t m_reflow_requested { 0 }; | ||||
| 
 | ||||
|     RefPtr<TextDocument> m_document; | ||||
| 
 | ||||
|     template<typename Callback> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling