Skip to content

feat: implement color and shape leaf hit testing - #1066

Merged
Kyle-Ye merged 3 commits into
mainfrom
feature/colorview_gesture
Sep 10, 2026
Merged

feat: implement color and shape leaf hit testing#1066
Kyle-Ye merged 3 commits into
mainfrom
feature/colorview_gesture

Conversation

@Kyle-Ye

@Kyle-Ye Kyle-Ye commented Sep 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Implement ColorView hit testing and description attributes.
  • Add ShapeStyledLeafView hit testing, content paths, and responder updates with clear-style handling and background selection.
  • Use PlatformPoint buffers across content responders and forward the Path point-array overload to its buffer overload.

Validation

Focused, isolated behavior checks passed for color containment and shape responder forwarding.

@github-actions github-actions Bot added area: event-gesture Events, gestures, tracing, or interaction plumbing. area: graphics Color, shape, gradient, image, symbols, and graphics primitives. type: feature New API, behavior, platform support, or user-facing capability. labels Sep 9, 2026
@augmentcode

augmentcode Bot commented Sep 9, 2026

Copy link
Copy Markdown

PR Risk Analyzer Agent 🛡️

👀 Human review needed

Justification

This PR implements new functional hit-testing and geometry logic in the core event/render path — it is not a docs, formatting, or otherwise mechanical change, so it falls outside automatic low-risk approval.

Key factors:

  • Package API surface change. The package protocol ContentResponder.contains(points:size:) signature and its default implementations change from UnsafeBufferPointer<CGPoint> to UnsafeBufferPointer<PlatformPoint>. PlatformPoint is a typealias for CGPoint, so this is type-compatible, but it touches every conformer (ColorView, RendererLeafView default, ShapeStyledLeafView, ShapeStyledResponderData) and warrants a maintainer's confirmation.
  • New responder wiring. ShapeStyledResponderFilter (a StatefulRule) now feeds outputs.preferences.viewResponders and drives interactive hit testing via LeafViewResponder/ContentResponderHelper. Behavioral logic in the attribute graph has correctness implications that benefit from human review.
  • Incomplete path branch may trap at runtime. ShapeStyledLeafView.contains(...) routes the .path case to path.contains(points: UnsafeBufferPointer<PlatformPoint>, eoFill:origin:), but that buffer overload in Path.swift is still _openSwiftUIUnimplementedFailure(). The newly added array overload only forwards to it, so real path-shape hit testing will trap if exercised; only the non-path (frame-rectangle) branch is functional.
  • Inline containment divergence. ColorView.contains reimplements containment inline (min($0.x, $0.y) >= 0 && $0.x < size.width && $0.y < size.height) instead of reusing the existing CGSize.contains(point:) helper. It is functionally equivalent, but the divergence is worth a reviewer's eye.

Static analysis only; build and tests are owned by CI.

Reviewed commit e7536da

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep Code Review Agent🐛

Review completed with 1 suggestions.

Reviewed commit: e7536da

guard points.contains(where: { framedShape.frame.contains($0) }) else {
return BitVector64()
}
return path.contains(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep Code Review Agent🐛

This new shape hit-test path calls Path.contains(points:eoFill:origin:), but that overload still ends in _openSwiftUIUnimplementedFailure(). Any hit test whose point is inside a path-backed shape's frame will now trigger a precondition failure instead of returning a containment mask.

Severity: high


🤖 Was this useful? React with 👍 or 👎

@tuist

tuist Bot commented Sep 9, 2026

Copy link
Copy Markdown

🛠️ Tuist Run Report 🛠️

Tests 🧪

Scheme Status Cache hit rate Tests Skipped Ran Commit
OpenSwiftUI 0 % 1197 0 1197 1b457f3a4

Builds 🔨

Scheme Status Duration Commit
OpenSwiftUI 1m 1s 1b457f3a4

@augmentcode

augmentcode Bot commented Sep 9, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR implements hit testing for color and shape-backed leaf views.

Changes:

  • Adds opaque-color containment and non-clear color description attributes to ColorView.
  • Moves content-responder point buffers to PlatformPoint.
  • Adds a buffer-based Path.contains overload, with the array overload forwarding to it.
  • Implements shape leaf containment, including fill-rule and frame-origin handling.
  • Provides shape content paths and suppresses responder paths/hits when resolved styles are clear.
  • Registers a stateful shape responder filter when view responders are requested.
  • Keeps responder data synchronized with animated size, position, transform, view, and styles.
  • Selects a nonempty background shape for hit testing when a shape leaf supplies one.
  • Refactors display-list construction while preserving its conditional creation and identity behavior.

Technical Notes: The changes make hit-testing masks operate on transformed local point buffers and use the existing responder-helper invalidation flow.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 3.22581% with 90 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.90%. Comparing base (217da04) to head (7d3326e).

Files with missing lines Patch % Lines
...tUICore/Shape/ShapeStyle/ShapeStyledLeafView.swift 0.00% 80 Missing ⚠️
...rces/OpenSwiftUICore/Graphic/Color/ColorView.swift 25.00% 6 Missing ⚠️
Sources/OpenSwiftUICore/Shape/Path.swift 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1066      +/-   ##
==========================================
- Coverage   29.92%   29.90%   -0.03%     
==========================================
  Files         790      790              
  Lines       62423    62483      +60     
==========================================
+ Hits        18682    18685       +3     
- Misses      43741    43798      +57     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Kyle-Ye
Kyle-Ye force-pushed the feature/colorview_gesture branch from e7536da to 7d3326e Compare September 10, 2026 16:12
@Kyle-Ye
Kyle-Ye merged commit be5749e into main Sep 10, 2026
6 checks passed
@Kyle-Ye
Kyle-Ye deleted the feature/colorview_gesture branch September 10, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: event-gesture Events, gestures, tracing, or interaction plumbing. area: graphics Color, shape, gradient, image, symbols, and graphics primitives. type: feature New API, behavior, platform support, or user-facing capability.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant