forked from mirrors/gecko-dev
		
	Bug 1484571 - Replace NormalDeclarationIterator return type with impl Trait. r=xidorn
				
					
				
			Differential Revision: https://phabricator.services.mozilla.com/D3747 --HG-- extra : moz-landing-system : lando
This commit is contained in:
		
							parent
							
								
									d70e55af73
								
							
						
					
					
						commit
						2ccae542f5
					
				
					 1 changed files with 13 additions and 52 deletions
				
			
		|  | @ -138,56 +138,9 @@ impl<'a> DoubleEndedIterator for DeclarationImportanceIterator<'a> { | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /// Iterator over `PropertyDeclaration` for Importance::Normal.
 |  | ||||||
| ///
 |  | ||||||
| /// TODO(emilio): This should be replaced by `impl Trait`, returning a
 |  | ||||||
| /// filter()ed iterator when available instead, and all the boilerplate below
 |  | ||||||
| /// should go.
 |  | ||||||
| pub struct NormalDeclarationIterator<'a>(DeclarationImportanceIterator<'a>); |  | ||||||
| 
 |  | ||||||
| impl<'a> NormalDeclarationIterator<'a> { |  | ||||||
|     #[inline] |  | ||||||
|     fn new(declarations: &'a [PropertyDeclaration], important: &'a SmallBitVec) -> Self { |  | ||||||
|         NormalDeclarationIterator( |  | ||||||
|             DeclarationImportanceIterator::new(declarations, important) |  | ||||||
|         ) |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| impl<'a> Iterator for NormalDeclarationIterator<'a> { |  | ||||||
|     type Item = &'a PropertyDeclaration; |  | ||||||
| 
 |  | ||||||
|     #[inline] |  | ||||||
|     fn next(&mut self) -> Option<Self::Item> { |  | ||||||
|         loop { |  | ||||||
|             let (decl, importance) = self.0.iter.next()?; |  | ||||||
|             if !importance { |  | ||||||
|                 return Some(decl); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     #[inline] |  | ||||||
|     fn size_hint(&self) -> (usize, Option<usize>) { |  | ||||||
|         self.0.iter.size_hint() |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| impl<'a> DoubleEndedIterator for NormalDeclarationIterator<'a> { |  | ||||||
|     #[inline] |  | ||||||
|     fn next_back(&mut self) -> Option<Self::Item> { |  | ||||||
|         loop { |  | ||||||
|             let (decl, importance) = self.0.iter.next_back()?; |  | ||||||
|             if !importance { |  | ||||||
|                 return Some(decl); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /// Iterator for AnimationValue to be generated from PropertyDeclarationBlock.
 | /// Iterator for AnimationValue to be generated from PropertyDeclarationBlock.
 | ||||||
| pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> { | pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> { | ||||||
|     iter: NormalDeclarationIterator<'a>, |     iter: DeclarationImportanceIterator<'a>, | ||||||
|     context: &'cx mut Context<'cx_a>, |     context: &'cx mut Context<'cx_a>, | ||||||
|     default_values: &'a ComputedValues, |     default_values: &'a ComputedValues, | ||||||
|     /// Custom properties in a keyframe if exists.
 |     /// Custom properties in a keyframe if exists.
 | ||||||
|  | @ -202,7 +155,7 @@ impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> { | ||||||
|         extra_custom_properties: Option<&'a Arc<::custom_properties::CustomPropertiesMap>>, |         extra_custom_properties: Option<&'a Arc<::custom_properties::CustomPropertiesMap>>, | ||||||
|     ) -> AnimationValueIterator<'a, 'cx, 'cx_a> { |     ) -> AnimationValueIterator<'a, 'cx, 'cx_a> { | ||||||
|         AnimationValueIterator { |         AnimationValueIterator { | ||||||
|             iter: declarations.normal_declaration_iter(), |             iter: declarations.declaration_importance_iter(), | ||||||
|             context, |             context, | ||||||
|             default_values, |             default_values, | ||||||
|             extra_custom_properties, |             extra_custom_properties, | ||||||
|  | @ -215,7 +168,11 @@ impl<'a, 'cx, 'cx_a:'cx> Iterator for AnimationValueIterator<'a, 'cx, 'cx_a> { | ||||||
|     #[inline] |     #[inline] | ||||||
|     fn next(&mut self) -> Option<Self::Item> { |     fn next(&mut self) -> Option<Self::Item> { | ||||||
|         loop { |         loop { | ||||||
|             let decl = self.iter.next()?; |             let (decl, importance) = self.iter.next()?; | ||||||
|  | 
 | ||||||
|  |             if importance.important() { | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
| 
 | 
 | ||||||
|             let animation = AnimationValue::from_declaration( |             let animation = AnimationValue::from_declaration( | ||||||
|                 decl, |                 decl, | ||||||
|  | @ -287,8 +244,12 @@ impl PropertyDeclarationBlock { | ||||||
| 
 | 
 | ||||||
|     /// Iterate over `PropertyDeclaration` for Importance::Normal
 |     /// Iterate over `PropertyDeclaration` for Importance::Normal
 | ||||||
|     #[inline] |     #[inline] | ||||||
|     pub fn normal_declaration_iter(&self) -> NormalDeclarationIterator { |     pub fn normal_declaration_iter<'a>( | ||||||
|         NormalDeclarationIterator::new(&self.declarations, &self.declarations_importance) |         &'a self, | ||||||
|  |     ) -> impl DoubleEndedIterator<Item = &'a PropertyDeclaration> { | ||||||
|  |         self.declaration_importance_iter() | ||||||
|  |             .filter(|(_, importance)| !importance.important()) | ||||||
|  |             .map(|(declaration, _)| declaration) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /// Return an iterator of (AnimatableLonghand, AnimationValue).
 |     /// Return an iterator of (AnimatableLonghand, AnimationValue).
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Cameron McCormack
						Cameron McCormack