Skip to content

Commit 6956e53

Browse files
committed
Add EmptyViewRendererHost
1 parent 44df8dc commit 6956e53

File tree

2 files changed

+61
-15
lines changed

2 files changed

+61
-15
lines changed

Sources/OpenSwiftUICore/View/Graph/ViewGraph.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,26 +323,26 @@ extension ViewGraph {
323323
self.rawValue = rawValue
324324
}
325325

326-
static var _0: Outputs { .init(rawValue: 1 << 0) }
327-
static var _1: Outputs { .init(rawValue: 1 << 1) }
328-
static var _2: Outputs { .init(rawValue: 1 << 2) }
329-
static var _3: Outputs { .init(rawValue: 1 << 3) }
330-
static var layout: Outputs { .init(rawValue: 1 << 4) }
326+
package static let displayList: ViewGraph.Outputs = .init(rawValue: 1 << 0)
327+
package static let platformItemList: ViewGraph.Outputs = .init(rawValue: 1 << 1)
328+
package static let viewResponders: ViewGraph.Outputs = .init(rawValue: 1 << 2)
329+
package static let layout: ViewGraph.Outputs = .init(rawValue: 1 << 4)
330+
package static let focus: ViewGraph.Outputs = .init(rawValue: 1 << 5)
331+
package static let all: ViewGraph.Outputs = .init(rawValue: 0xFF)
332+
package static let defaults: ViewGraph.Outputs = [.displayList, .viewResponders, .layout, .focus]
331333

334+
// FIXME
332335
fileprivate func addRequestedPreferences(to inputs: inout _ViewInputs) {
333336
inputs.preferences.add(HostPreferencesKey.self)
334-
if contains(._0) {
337+
if contains(.displayList) {
335338
inputs.preferences.add(DisplayList.Key.self)
336339
}
337-
if contains(._2) {
340+
if contains(.viewResponders) {
338341
// inputs.preferences.add(ViewRespondersKey.self)
339342
}
340-
if contains(._1) {
343+
if contains(.platformItemList) {
341344
// inputs.preferences.add(PlatformItemList.Key.self)
342345
}
343-
if contains(._3) {
344-
// inputs.preferences.add(AccessibilityNodesKe.self)
345-
}
346346
}
347347
}
348348
}

Sources/OpenSwiftUICore/View/Graph/ViewRendererHost.swift

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,32 @@ package protocol ViewRendererHost: ViewGraphDelegate {
4343
var viewGraph: ViewGraph { get }
4444
var currentTimestamp: Time { get set }
4545
var propertiesNeedingUpdate: ViewRendererHostProperties { get set }
46-
func addImplicitPropertiesNeedingUpdate(to properties: inout ViewRendererHostProperties)
47-
var isRendering: Bool { get set }
46+
var renderingPhase: ViewRenderingPhase { get set }
47+
var externalUpdateCount: Int { get set }
4848
func updateRootView()
49-
func requestUpdate(after: Double)
49+
func updateEnvironment()
50+
func updateFocusedItem()
51+
func updateFocusedValues()
52+
func updateTransform()
53+
func updateSize()
54+
func updateSafeArea()
55+
func updateScrollableContainerSize()
56+
func updateFocusStore()
57+
func updateAccessibilityFocus()
58+
func updateAccessibilityFocusStore()
59+
func updateAccessibilityEnvironment()
60+
func requestUpdate(after delay: Double)
61+
func renderDisplayList(_ list: DisplayList, asynchronously: Bool, time: Time, nextTime: Time, targetTimestamp: Time?, version: DisplayList.Version, maxVersion: DisplayList.Version) -> Time
62+
func didRender()
5063
}
5164

52-
// MARK: - ViewRendererHost's default implementation for ViewGraphDelegate
65+
extension ViewRendererHost {
66+
package var isRendering: Bool {
67+
fatalError("TODO")
68+
}
69+
}
70+
71+
// TODO: FIXME
5372

5473
extension ViewRendererHost {
5574
package func updateViewGraph<Value>(body: (ViewGraph) -> Value) -> Value {
@@ -134,3 +153,30 @@ extension ViewRendererHost {
134153
// TODO: Signpost.viewHost
135154
}
136155
}
156+
157+
// MARK: - EmptyViewRendererHost
158+
159+
final package class EmptyViewRendererHost: ViewRendererHost {
160+
package let viewGraph: ViewGraph
161+
package var propertiesNeedingUpdate: ViewRendererHostProperties = []
162+
package var renderingPhase: ViewRenderingPhase = .none
163+
package var externalUpdateCount: Int = .zero
164+
package var currentTimestamp: Time = .zero
165+
package init(environment: EnvironmentValues = EnvironmentValues()) {
166+
Update.begin()
167+
viewGraph = ViewGraph(rootViewType: EmptyView.self, requestedOutputs: [])
168+
viewGraph.setEnvironment(environment)
169+
initializeViewGraph()
170+
Update.end()
171+
}
172+
package func requestUpdate(after delay: Double) {}
173+
package func updateRootView() {}
174+
package func updateEnvironment() {}
175+
package func updateSize() {}
176+
package func updateSafeArea() {}
177+
package func updateScrollableContainerSize() {}
178+
package func renderDisplayList(_ list: DisplayList, asynchronously: Bool, time: Time, nextTime: Time, targetTimestamp: Time?, version: DisplayList.Version, maxVersion: DisplayList.Version) -> Time {
179+
.infinity
180+
}
181+
package func forEachIdentifiedView(body: (_IdentifiedViewProxy) -> Void) {}
182+
}

0 commit comments

Comments
 (0)