2
0
Эх сурвалжийг харах

Make elements with 'filter' and 'backdrop-filter' properties create a local stacking context

Michael Ragazzon 2 жил өмнө
parent
commit
f6230b2d2f
1 өөрчлөгдсөн 25 нэмэгдсэн , 39 устгасан
  1. 25 39
      Source/Core/Element.cpp

+ 25 - 39
Source/Core/Element.cpp

@@ -1720,57 +1720,43 @@ void Element::OnPropertyChange(const PropertyIdSet& changed_properties)
 		}
 	}
 
-	// Update the z-index.
-	if (changed_properties.Contains(PropertyId::ZIndex))
-	{
-		Style::ZIndex z_index_property = meta->computed_values.z_index();
+	const bool border_radius_changed = (                                    //
+		changed_properties.Contains(PropertyId::BorderTopLeftRadius) ||     //
+		changed_properties.Contains(PropertyId::BorderTopRightRadius) ||    //
+		changed_properties.Contains(PropertyId::BorderBottomRightRadius) || //
+		changed_properties.Contains(PropertyId::BorderBottomLeftRadius)     //
+	);
+	const bool filter_changed = (changed_properties.Contains(PropertyId::Filter) || changed_properties.Contains(PropertyId::BackdropFilter));
 
-		if (z_index_property.type == Style::ZIndex::Auto)
-		{
-			if (local_stacking_context && !local_stacking_context_forced)
-			{
-				// We're no longer acting as a stacking context.
-				local_stacking_context = false;
+	// Update the z-index and stacking context.
+	if (changed_properties.Contains(PropertyId::ZIndex) || filter_changed)
+	{
+		const Style::ZIndex z_index_property = meta->computed_values.z_index();
 
-				stacking_context_dirty = false;
-				stacking_context.clear();
-			}
+		const float new_z_index = (z_index_property.type == Style::ZIndex::Auto ? 0.f : z_index_property.value);
+		const bool enable_local_stacking_context = (z_index_property.type != Style::ZIndex::Auto || local_stacking_context_forced ||
+			meta->computed_values.has_filter() || meta->computed_values.has_backdrop_filter());
 
-			// If our old z-index was not zero, then we must dirty our stacking context so we'll be re-indexed.
-			if (z_index != 0)
-			{
-				z_index = 0;
-				DirtyStackingContext();
-			}
-		}
-		else
+		if (z_index != new_z_index || local_stacking_context != enable_local_stacking_context)
 		{
-			float new_z_index = z_index_property.value;
+			z_index = new_z_index;
 
-			if (new_z_index != z_index)
+			if (local_stacking_context != enable_local_stacking_context)
 			{
-				z_index = new_z_index;
+				local_stacking_context = enable_local_stacking_context;
 
-				if (parent != nullptr)
-					parent->DirtyStackingContext();
+				// If we are no longer acting as a local stacking context, then we clear the list and are all set. Otherwise, we need to rebuild our
+				// local stacking context.
+				stacking_context.clear();
+				stacking_context_dirty = local_stacking_context;
 			}
 
-			if (!local_stacking_context)
-			{
-				local_stacking_context = true;
-				stacking_context_dirty = true;
-			}
+			// When our z-index or local stacking context changes, then we must dirty our parent stacking context so we are re-indexed.
+			if (parent)
+				parent->DirtyStackingContext();
 		}
 	}
 
-	const bool border_radius_changed = (                                    //
-		changed_properties.Contains(PropertyId::BorderTopLeftRadius) ||     //
-		changed_properties.Contains(PropertyId::BorderTopRightRadius) ||    //
-		changed_properties.Contains(PropertyId::BorderBottomRightRadius) || //
-		changed_properties.Contains(PropertyId::BorderBottomLeftRadius)     //
-	);
-	const bool filter_changed = (changed_properties.Contains(PropertyId::Filter) || changed_properties.Contains(PropertyId::BackdropFilter));
-
 	// Dirty the background if it's changed.
 	if (border_radius_changed ||                                    //
 		changed_properties.Contains(PropertyId::BackgroundColor) || //