mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:12:44 +00:00 
			
		
		
		
	LibWeb: Add support for range deletion.
This commit is contained in:
		
							parent
							
								
									bbcc5a9332
								
							
						
					
					
						commit
						43dc47a494
					
				
					 8 changed files with 107 additions and 6 deletions
				
			
		|  | @ -345,16 +345,33 @@ bool EventHandler::handle_keydown(KeyCode key, unsigned modifiers, u32 code_poin | |||
|             return focus_next_element(); | ||||
|     } | ||||
| 
 | ||||
|     if (layout_root()->selection().is_valid()) { | ||||
|         auto range = layout_root()->selection().to_dom_range(); | ||||
| 
 | ||||
|         if (key == KeyCode::Key_Backspace) { | ||||
|             if (range.start().node()->is_editable()) { | ||||
|                 m_edit_event_handler->handle_delete(range); | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // FIXME: Check if this code point is in the printable character range.
 | ||||
| 
 | ||||
|         m_edit_event_handler->handle_delete(range); | ||||
|         m_edit_event_handler->handle_insert(m_frame.cursor_position(), code_point); | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     if (m_frame.cursor_position().is_valid() && m_frame.cursor_position().node()->is_editable()) { | ||||
|         if (key == KeyCode::Key_Backspace) { | ||||
|             m_edit_event_handler->handle_delete(m_frame.cursor_position()); | ||||
|             return true; | ||||
|         } | ||||
| 
 | ||||
|         if (code_point) { | ||||
|             m_edit_event_handler->handle_insert(m_frame.cursor_position(), code_point); | ||||
|             return true; | ||||
|         } | ||||
|         // FIXME: Check if this code point is in the printable character range.
 | ||||
| 
 | ||||
|         m_edit_event_handler->handle_insert(m_frame.cursor_position(), code_point); | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     return false; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 asynts
						asynts