Browse Source

Elements with 'filter' and 'backdrop-filter' properties now act as containing block for absolutely positioned elements

Michael Ragazzon 2 years ago
parent
commit
a5ddc1a069

+ 2 - 2
Source/Core/Layout/ContainerBox.cpp

@@ -131,8 +131,8 @@ ContainerBox::ContainerBox(Type type, Element* element, ContainerBox* parent_con
 		const auto& computed = element->GetComputedValues();
 		overflow_x = computed.overflow_x();
 		overflow_y = computed.overflow_y();
-		position_property = computed.position();
-		has_local_transform_or_perspective = (computed.has_local_transform() || computed.has_local_perspective());
+		is_absolute_positioning_containing_block = (computed.position() != Style::Position::Static || computed.has_local_transform() ||
+			computed.has_local_perspective() || computed.has_filter() || computed.has_backdrop_filter());
 	}
 }
 

+ 4 - 4
Source/Core/Layout/ContainerBox.h

@@ -55,8 +55,9 @@ public:
 
 	ContainerBox* GetParent() { return parent_container; }
 	Element* GetElement() { return element; }
-	Style::Position GetPositionProperty() const { return position_property; }
-	bool HasLocalTransformOrPerspective() const { return has_local_transform_or_perspective; }
+
+	// Returns true if this box acts as a containing block for absolutely positioned descendants.
+	bool IsAbsolutePositioningContainingBlock() const { return is_absolute_positioning_containing_block; }
 
 protected:
 	ContainerBox(Type type, Element* element, ContainerBox* parent_container);
@@ -99,8 +100,7 @@ private:
 
 	Style::Overflow overflow_x = Style::Overflow::Visible;
 	Style::Overflow overflow_y = Style::Overflow::Visible;
-	Style::Position position_property = Style::Position::Static;
-	bool has_local_transform_or_perspective = false;
+	bool is_absolute_positioning_containing_block = false;
 
 	ContainerBox* parent_container = nullptr;
 };

+ 1 - 4
Source/Core/Layout/LayoutDetails.cpp

@@ -186,10 +186,7 @@ ContainingBlock LayoutDetails::GetContainingBlock(ContainerBox* parent_container
 	{
 		area = BoxArea::Padding;
 
-		auto EstablishesAbsoluteContainingBlock = [](ContainerBox* container) -> bool {
-			return container->GetPositionProperty() != Position::Static || container->HasLocalTransformOrPerspective();
-		};
-		while (container && container->GetParent() && !EstablishesAbsoluteContainingBlock(container))
+		while (container && container->GetParent() && !container->IsAbsolutePositioningContainingBlock())
 			container = container->GetParent();
 	}
 

+ 1 - 1
Source/Core/Layout/LayoutDetails.h

@@ -89,7 +89,7 @@ public:
 
 	/// Returns the containing block for a box.
 	/// @param[in] parent_container The parent container of the current box.
-	/// @param[in] child_position The position property of the current box.
+	/// @param[in] position The position property of the current box.
 	/// @return The containing block box and size, possibly indefinite along one or both axes.
 	static ContainingBlock GetContainingBlock(ContainerBox* parent_container, Style::Position position);