Commit bfa78851 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Exclude SemanticNodes that are fully covered by an overlapping sliver (#11826)

* Exclude SemanticNodes that are fully covered by an overlapping sliver

* simplification

* formatting

* nits

* add test for center widget
parent 98c8366b
...@@ -285,6 +285,36 @@ abstract class RenderSliverMultiBoxAdaptor extends RenderSliver ...@@ -285,6 +285,36 @@ abstract class RenderSliverMultiBoxAdaptor extends RenderSliver
visitor(child); visitor(child);
} }
@override
void visitChildrenForSemantics(RenderObjectVisitor visitor) {
switch (constraints.normalizedGrowthDirection) {
case GrowthDirection.forward:
super.visitChildrenForSemantics((RenderObject child) {
// The sliver is overlapped at the leading edge.
final Offset bottomLeftInViewport = MatrixUtils.transformPoint(
child.getTransformTo(parent), child.semanticBounds.bottomLeft
);
final double endOverlap = constraints.overlap;
if ((constraints.axis == Axis.vertical && bottomLeftInViewport.dy > endOverlap) ||
(constraints.axis == Axis.horizontal && bottomLeftInViewport.dx > endOverlap))
visitor(child);
});
break;
case GrowthDirection.reverse:
super.visitChildrenForSemantics((RenderObject child) {
// The sliver is overlapped at the trailing edge.
final Offset topRightInViewport = MatrixUtils.transformPoint(
child.getTransformTo(parent), child.semanticBounds.topRight
);
final double startOverlap = constraints.remainingPaintExtent - constraints.overlap;
if ((constraints.axis == Axis.vertical && topRightInViewport.dy < startOverlap) ||
(constraints.axis == Axis.horizontal && topRightInViewport.dx < startOverlap))
visitor(child);
});
break;
}
}
/// Called during layout to create and add the child with the given index and /// Called during layout to create and add the child with the given index and
/// scroll offset. /// scroll offset.
/// ///
......
...@@ -97,7 +97,8 @@ abstract class RenderViewportBase<ParentDataClass extends ContainerParentDataMix ...@@ -97,7 +97,8 @@ abstract class RenderViewportBase<ParentDataClass extends ContainerParentDataMix
@override @override
void visitChildrenForSemantics(RenderObjectVisitor visitor) { void visitChildrenForSemantics(RenderObjectVisitor visitor) {
for (RenderSliver sliver in childrenInPaintOrder) { for (RenderSliver sliver in childrenInPaintOrder) {
if (sliver.geometry.paintExtent != 0) if (sliver.geometry.paintExtent != 0 &&
sliver.constraints.overlap < sliver.geometry.paintOrigin + sliver.geometry.paintExtent)
visitor(sliver); visitor(sliver);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment