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

Improve readability of _SemanticsGeometry (#12038)

parent 26751434
...@@ -547,45 +547,52 @@ typedef void RenderObjectVisitor(RenderObject child); ...@@ -547,45 +547,52 @@ typedef void RenderObjectVisitor(RenderObject child);
typedef void LayoutCallback<T extends Constraints>(T constraints); typedef void LayoutCallback<T extends Constraints>(T constraints);
class _SemanticsGeometry { class _SemanticsGeometry {
_SemanticsGeometry() : transform = new Matrix4.identity(); _SemanticsGeometry() : _transform = new Matrix4.identity();
_SemanticsGeometry.withClipFrom(_SemanticsGeometry other) { _SemanticsGeometry.withClipFrom(_SemanticsGeometry other) {
clipRect = other?.clipRect; _clipRect = other?._clipRect;
transform = new Matrix4.identity(); _transform = new Matrix4.identity();
} }
_SemanticsGeometry.copy(_SemanticsGeometry other) { _SemanticsGeometry.copy(_SemanticsGeometry other) {
if (other != null) { if (other != null) {
clipRect = other.clipRect; _clipRect = other._clipRect;
transform = new Matrix4.copy(other.transform); _transform = new Matrix4.copy(other._transform);
} else { } else {
transform = new Matrix4.identity(); _transform = new Matrix4.identity();
} }
} }
Rect clipRect;
Rect _clipRect;
Rect _intersectClipRect(Rect other) { Rect _intersectClipRect(Rect other) {
if (clipRect == null) if (_clipRect == null)
return other; return other;
if (other == null) if (other == null)
return clipRect; return _clipRect;
return clipRect.intersect(other); return _clipRect.intersect(other);
} }
Matrix4 transform;
Matrix4 _transform;
void applyAncestorChain(List<RenderObject> ancestorChain) { void applyAncestorChain(List<RenderObject> ancestorChain) {
for (int index = ancestorChain.length-1; index > 0; index -= 1) { for (int index = ancestorChain.length-1; index > 0; index -= 1) {
final RenderObject parent = ancestorChain[index]; final RenderObject parent = ancestorChain[index];
final RenderObject child = ancestorChain[index-1]; final RenderObject child = ancestorChain[index-1];
clipRect = _intersectClipRect(parent.describeApproximatePaintClip(child)); _clipRect = _intersectClipRect(parent.describeApproximatePaintClip(child));
if (clipRect != null) { if (_clipRect != null) {
if (clipRect.isEmpty) { if (_clipRect.isEmpty) {
clipRect = Rect.zero; _clipRect = Rect.zero;
} else { } else {
final Matrix4 clipTransform = new Matrix4.identity(); final Matrix4 clipTransform = new Matrix4.identity();
parent.applyPaintTransform(child, clipTransform); parent.applyPaintTransform(child, clipTransform);
clipRect = MatrixUtils.inverseTransformRect(clipTransform, clipRect); _clipRect = MatrixUtils.inverseTransformRect(clipTransform, _clipRect);
} }
} }
parent.applyPaintTransform(child, transform); parent.applyPaintTransform(child, _transform);
} }
} }
void updateSemanticsNode({ void updateSemanticsNode({
@required RenderObject rendering, @required RenderObject rendering,
@required SemanticsNode semantics, @required SemanticsNode semantics,
...@@ -595,9 +602,9 @@ class _SemanticsGeometry { ...@@ -595,9 +602,9 @@ class _SemanticsGeometry {
assert(semantics != null); assert(semantics != null);
assert(parentSemantics != null); assert(parentSemantics != null);
assert(parentSemantics.wasAffectedByClip != null); assert(parentSemantics.wasAffectedByClip != null);
semantics.transform = transform; semantics.transform = _transform;
if (clipRect != null) { if (_clipRect != null) {
semantics.rect = clipRect.intersect(rendering.semanticBounds); semantics.rect = _clipRect.intersect(rendering.semanticBounds);
semantics.wasAffectedByClip = true; semantics.wasAffectedByClip = true;
} else { } else {
semantics.rect = rendering.semanticBounds; semantics.rect = rendering.semanticBounds;
......
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