Skip to content

Commit

Permalink
Update ViewGraph init (#175)
Browse files Browse the repository at this point in the history
* Add RenderUtil.c

* Update ViewGraph init method

* Update PreferenceBridge

* Update ViewGraph init and deint lifecycle

* Add RootDisplayList

* Fix Linux build warning

* Update codecov file
  • Loading branch information
Kyle-Ye authored Dec 15, 2024
1 parent 23542c4 commit fb084bb
Show file tree
Hide file tree
Showing 13 changed files with 512 additions and 261 deletions.
8 changes: 4 additions & 4 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ coverage:
default:
target: auto
threshold: 5
patch:
default:
target: auto
threshold: 5
patch: off
# default:
# target: auto
# threshold: 5
ignore:
- Tests
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "3ec5ceae50a3ce95edc97ef8b27b3a65cb61320642aa5cc535bb5d4690cb4230",
"originHash" : "1cf308da26a892a1962d7acfd0aeae3c95ac506674d47f80a07474eb8476d770",
"pins" : [
{
"identity" : "darwinprivateframeworks",
Expand Down
12 changes: 10 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,23 @@ if useLocalDeps {
package.dependencies += [
.package(path: "../OpenGraph"),
.package(path: "../OpenBox"),
.package(path: "../DarwinPrivateFrameworks"),
]
if attributeGraphCondition || renderBoxCondition {
package.dependencies.append(
.package(path: "../DarwinPrivateFrameworks")
)
}
} else {
package.dependencies += [
// FIXME: on Linux platform: OG contains unsafe build flags which prevents us using version dependency
.package(url: "https://github.com/OpenSwiftUIProject/OpenGraph", branch: "main"),
.package(url: "https://github.com/OpenSwiftUIProject/OpenBox", branch: "main"),
.package(url: "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git", branch: "main"),
]
if attributeGraphCondition || renderBoxCondition {
package.dependencies.append(
.package(url: "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git", branch: "main")
)
}
}

#if os(macOS)
Expand Down
23 changes: 12 additions & 11 deletions Sources/OpenSwiftUICore/Data/Preference/PreferenceBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// OpenSwiftUICore
//
// Audited for iOS 18.0
// Status: Blocked by ViewGraph
// Status: Complete
// ID: A9FAE381E99529D5274BA37A9BC9B074 (SwiftUI)
// ID: DF57A19C61B44C613EB77C1D47FC679A (SwiftUICore)

Expand Down Expand Up @@ -31,12 +31,12 @@ package final class PreferenceBridge {
package func invalidate() {
requestedPreferences = PreferenceKeys()
bridgedViewInputs = PropertyList()
// TODO: Blocked by ViewGraph
// for child in children {
// let viewGraph = child.takeRetainedValue()
// viewGraph.setPreferenceBridge(to: nil, isInvalidating: true)
// child.release()
// }
for child in children {
let viewGraph = child.takeRetainedValue()
viewGraph.invalidatePreferenceBridge()
child.release()
}
viewGraph = nil
isValid = false
}

Expand Down Expand Up @@ -109,10 +109,11 @@ package final class PreferenceBridge {
}

package func removedStateDidChange() {
// TODO: Blocked by ViewGraph
// for child in children {
// let viewGraph = child.takeUnretainedValue()
// }
for child in children {
let viewGraph = child.takeUnretainedValue()
viewGraph.updateRemovedState()
child.release()
}
}

#if canImport(Darwin)
Expand Down
39 changes: 35 additions & 4 deletions Sources/OpenSwiftUICore/Graph/GraphHost.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//
// Audited for iOS 18.0
// Status: Blocked by transactions
// ID: 30C09FF16BC95EC5173809B57186CAC3 (RELEASE_2021)
// ID: F9F204BD2F8DB167A76F17F3FB1B3335 (RELEASE_2024)
// ID: 30C09FF16BC95EC5173809B57186CAC3 (SwiftUI)
// ID: F9F204BD2F8DB167A76F17F3FB1B3335 (SwiftUICore)

import OpenSwiftUI_SPI
package import OpenGraphShims
Expand Down Expand Up @@ -329,7 +329,38 @@ extension GraphHost {
}

package final func updateRemovedState() {
preconditionFailure("TODO")
let isRemoved: Bool
let removedState: RemovedState

if self.removedState.isEmpty {
if let parentHost {
let state = parentHost.removedState
isRemoved = state.contains(.unattached)
removedState = state
} else {
isRemoved = false
removedState = []
}
} else {
isRemoved = true
removedState = self.removedState
}
let isHiddenForReuse = removedState.contains(.hiddenForReuse)

if isRemoved != data.isRemoved {
if isRemoved {
rootSubgraph.willRemove()
// TODO: OGSubgraphRemoveChild
} else {
// TODO: OGSubgraphAddChild
rootSubgraph.didReinsert()
}
data.isRemoved = isRemoved
}
if isHiddenForReuse != data.isHiddenForReuse {
data.isHiddenForReuse = isHiddenForReuse
isHiddenForReuseDidChange()
}
}

// MARK: - GraphHost + Transaction
Expand Down Expand Up @@ -582,7 +613,7 @@ private final class GlobalTransaction {
}
}

// MARK: - Graph + Extension
// MARK: - Graph + GraphHost

extension Graph {
package func graphHost() -> GraphHost {
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenSwiftUICore/Layout/Edge/EdgeInsets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public struct EdgeInsets: Equatable {
public var trailing: CGFloat

@inlinable
@inline(__always)
public init(top: CGFloat, leading: CGFloat, bottom: CGFloat, trailing: CGFloat) {
self.top = top
self.leading = leading
Expand All @@ -25,11 +24,12 @@ public struct EdgeInsets: Equatable {
}

@inlinable
@inline(__always)
public init() {
self.init(top: 0, leading: 0, bottom: 0, trailing: 0)
}

package static var zero: EdgeInsets { EdgeInsets() }

@inline(__always)
init(_ value: CGFloat, edges: Edge.Set) {
self.init(
Expand Down
10 changes: 9 additions & 1 deletion Sources/OpenSwiftUICore/View/Debug/ViewDebug.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,15 @@ extension View {
}
}

extension ViewModifier {
extension ViewModifier {
package static func makeDebuggableView(
modifier: _GraphValue<Self>,
inputs: _ViewInputs,
body: @escaping (_Graph, _ViewInputs) -> _ViewOutputs
) -> _ViewOutputs {
preconditionFailure("TODO")
}

static func makeDebuggableViewList(
modifier: _GraphValue<Self>,
inputs: _ViewListInputs,
Expand Down
Loading

0 comments on commit fb084bb

Please sign in to comment.