Skip to content

Add initial rendering support for NSHostingView #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 18, 2025

Conversation

Mx-Iris
Copy link
Member

@Mx-Iris Mx-Iris commented May 17, 2025

No description provided.

@Mx-Iris Mx-Iris requested review from Kyle-Ye and Copilot May 17, 2025 16:32
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces initial support for rendering in NSHostingView by adding temporary layout values, new environment parameters, and updated view creation logic across the rendering and hosting integration layers.

  • Added temporary hard-coded frame assignments for macOS and iOS in RendererLeafView.
  • Introduced macOS-specific opaqueBackground handling and a new initializer in the DisplayList view renderer.
  • Enhanced NSHostingView rendering logic and integrated new AppKit view implementations including NSProjectionView, NSInheritedView, and NSGraphicsView.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Sources/OpenSwiftUICore/Render/RendererLeafView.swift Temporary hard-coded frame values added for macOS and iOS.
Sources/OpenSwiftUICore/Render/DisplayList/DisplayListViewRenderer.swift Added opaqueBackground property and new initializer for macOS.
Sources/OpenSwiftUI/Integration/Render/AppKit/NSViewPlatformViewDefinition.swift Updated view creation logic with switch cases.
Sources/OpenSwiftUI/Integration/Hosting/AppKit/View/NSProjectionView.swift New NSProjectionView implementation.
Sources/OpenSwiftUI/Integration/Hosting/AppKit/View/NSInheritedView.swift New NSInheritedView implementation.
Sources/OpenSwiftUI/Integration/Hosting/AppKit/View/NSHostingView.swift Enhanced rendering flow and display list update logic.
Sources/OpenSwiftUI/Integration/Hosting/AppKit/View/NSGraphicsView.swift Added new NSGraphicsView implementation.
Sources/COpenSwiftUI/QuartzCore/CAChameleonLayer.m & CAChameleonLayer.h Added CAChameleonLayer implementation.
Sources/COpenSwiftUI/AppKit/OpenSwiftUI+NSView.m & OpenSwiftUI+NSView.h Added NSView category with a setFlipped declaration.
Comments suppressed due to low confidence (1)

Sources/COpenSwiftUI/AppKit/OpenSwiftUI+NSView.h:23

  • [nitpick] The method name 'setFlipped:' may be confused with NSView's built-in computed property 'isFlipped'. Consider renaming it to more clearly indicate its intended behavior.
- (void)setFlipped:(BOOL)flipped;

Comment on lines +145 to 147
item.frame = CGRect(x: 0, y: 0, width: 500, height: 300)
#elseif os(iOS)
item.frame = CGRect(x: 0, y: 100.333, width: 402, height: 739)
Copy link
Preview

Copilot AI May 17, 2025

Choose a reason for hiding this comment

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

The temporary hard-coded frame values may hinder adaptability across different screen sizes. Consider deferring to the layout system or using configurable parameters once implemented.

Suggested change
item.frame = CGRect(x: 0, y: 0, width: 500, height: 300)
#elseif os(iOS)
item.frame = CGRect(x: 0, y: 100.333, width: 402, height: 739)
let defaultSize = CGSize(width: 500, height: 300)
item.frame = CGRect(origin: .zero, size: proposedSize.or(defaultSize))
#elseif os(iOS)
let defaultSize = CGSize(width: 402, height: 739)
item.frame = CGRect(origin: CGPoint(x: 0, y: 100.333), size: proposedSize.or(defaultSize))

Copilot uses AI. Check for mistakes.

version: DisplayList.Version,
maxVersion: DisplayList.Version
) -> Time {
func render() -> Time {
Copy link
Preview

Copilot AI May 17, 2025

Choose a reason for hiding this comment

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

[nitpick] The nested render() function increases the complexity of renderDisplayList. Consider extracting it into a separate method to improve readability and maintainability.

Suggested change
func render() -> Time {
private func renderDisplayListSynchronously(
list: DisplayList,
time: Time,
nextTime: Time,
version: DisplayList.Version,
maxVersion: DisplayList.Version
) -> Time {

Copilot uses AI. Check for mistakes.

Copy link

codecov bot commented May 17, 2025

Codecov Report

Attention: Patch coverage is 0% with 93 lines in your changes missing coverage. Please review.

Project coverage is 22.28%. Comparing base (8eb03b6) to head (6967387).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...ntegration/Hosting/AppKit/View/NSHostingView.swift 0.00% 38 Missing ⚠️
...n/Render/AppKit/NSViewPlatformViewDefinition.swift 0.00% 33 Missing ⚠️
...tegration/Hosting/AppKit/View/NSGraphicsView.swift 0.00% 5 Missing ⚠️
...egration/Hosting/AppKit/View/NSInheritedView.swift 0.00% 5 Missing ⚠️
...gration/Hosting/AppKit/View/NSProjectionView.swift 0.00% 5 Missing ⚠️
...e/Render/DisplayList/DisplayListViewRenderer.swift 0.00% 4 Missing ⚠️
...rces/OpenSwiftUICore/Render/RendererLeafView.swift 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #291      +/-   ##
==========================================
- Coverage   22.38%   22.28%   -0.10%     
==========================================
  Files         343      346       +3     
  Lines       16246    16333      +87     
==========================================
+ Hits         3636     3640       +4     
- Misses      12610    12693      +83     

☔ View full report in Codecov by Sentry.
📢 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.

@Mx-Iris Mx-Iris requested a review from Kyle-Ye May 17, 2025 17:05
@Kyle-Ye Kyle-Ye merged commit 73e1eb0 into main May 18, 2025
6 checks passed
@Kyle-Ye Kyle-Ye deleted the feature/appkit_view_render branch May 18, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants