mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 19:22:45 +00:00 
			
		
		
		
	LibWeb: Don't invalidate style when adding/removing empty style sheet
For whatever reason, web pages sometimes add and/or remove a completely empty style sheet. When this happens, we don't need to invalidate the document's style, since the outcome will be the same as before.
This commit is contained in:
		
							parent
							
								
									ba6a9318c3
								
							
						
					
					
						commit
						14d4f227f2
					
				
					 1 changed files with 10 additions and 0 deletions
				
			
		|  | @ -19,6 +19,11 @@ void StyleSheetList::add_sheet(CSSStyleSheet& sheet) | |||
| 
 | ||||
|     sort_sheets(); | ||||
| 
 | ||||
|     if (sheet.rules().length() == 0) { | ||||
|         // NOTE: If the added sheet has no rules, we don't have to invalidate anything.
 | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     m_document.style_computer().invalidate_rule_cache(); | ||||
|     m_document.style_computer().load_fonts_from_sheet(sheet); | ||||
|     m_document.invalidate_style(); | ||||
|  | @ -29,6 +34,11 @@ void StyleSheetList::remove_sheet(CSSStyleSheet& sheet) | |||
|     sheet.set_style_sheet_list({}, nullptr); | ||||
|     m_sheets.remove_first_matching([&](auto& entry) { return entry.ptr() == &sheet; }); | ||||
| 
 | ||||
|     if (sheet.rules().length() == 0) { | ||||
|         // NOTE: If the removed sheet had no rules, we don't have to invalidate anything.
 | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     sort_sheets(); | ||||
| 
 | ||||
|     m_document.style_computer().invalidate_rule_cache(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling