Repository navigation
Implement describeApproximatePaintClip in clipping render objects - #196888
Open
YannVanneth wants to merge 5 commits into
Open
YannVanneth wants to merge 5 commits into
YannVanneth wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements the describeApproximatePaintClip method across several render objects, including RenderAnimatedSize, RenderFlow, RenderParagraph, RenderFittedBox, RenderWrap, and RenderTwoDimensionalViewport, to correctly describe their paint clips. It also adds corresponding tests to verify that the semantics rects of overflowing children are clipped. Feedback on the changes suggests performing a safe type check (child is! RenderBox) instead of a direct cast (child as RenderBox) in RenderFittedBox.describeApproximatePaintClip to avoid potential runtime type errors.
chunhtai
reviewed
Nov 25, 2026
Keep cached TwoDimensionalViewport children in the semantics tree, fix its overflow detection, and update semantics when RenderFittedBox or RenderFlow repaint without relayout.
chunhtai
approved these changes
Nov 25, 2026
Contributor
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #196646
Description
Implements
describeApproximatePaintClipon render objects that clip their children duringpaintso that clipped child semantics rects are clipped accordingly:RenderWrap(packages/flutter/lib/src/rendering/wrap.dart): returnsOffset.zero & sizewhenclipBehavior != Clip.noneand_hasVisualOverflowis true.RenderFittedBox(packages/flutter/lib/src/rendering/proxy_box.dart): whenclipBehavior != Clip.noneandpaintsChild(child), updates paint data if needed and returns_hasVisualOverflow! ? Offset.zero & size : null.RenderFlow(packages/flutter/lib/src/rendering/flow.dart): returnsOffset.zero & sizewhenclipBehavior != Clip.none.RenderParagraph(packages/flutter/lib/src/rendering/paragraph.dart): returns_needsClipping ? Offset.zero & size : null.RenderAnimatedSize(packages/flutter/lib/src/rendering/animated_size.dart): initializes_hasVisualOverflow = falseand returnsOffset.zero & sizewhenclipBehavior != Clip.noneand_hasVisualOverflowis true.RenderTwoDimensionalViewport(packages/flutter/lib/src/widgets/two_dimensional_viewport.dart): returnsOffset.zero & viewportDimensionwhenclipBehavior != Clip.noneand_hasVisualOverflowis true.Tests
Added widget tests verifying that each widget clips the semantics rect of an overflowing child when clipping is enabled and preserves the full rect when clipping is disabled:
packages/flutter/test/widgets/wrap_test.dartpackages/flutter/test/widgets/fitted_box_test.dartpackages/flutter/test/widgets/flow_test.dartpackages/flutter/test/widgets/text_test.dartpackages/flutter/test/widgets/animated_size_test.dartpackages/flutter/test/widgets/two_dimensional_viewport_test.dartPre-launch Checklist
///).