Skip to content

Commit 7e5f33b

Browse files
committed
Remove bad merge.
1 parent 094dbcd commit 7e5f33b

17 files changed

+157
-465
lines changed

BlueprintUI/Sources/BlueprintView/BlueprintView.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ public final class BlueprintView: UIView {
4040

4141
private var sizesThatFit: [SizeConstraint: CGSize] = [:]
4242

43-
private var cacheStorage = Environment.CacheStorageEnvironmentKey.defaultValue
44-
4543
/// A base environment used when laying out and rendering the element tree.
4644
///
4745
/// Some keys will be overridden with the traits from the view itself. Eg, `windowSize`, `safeAreaInsets`, etc.
@@ -54,13 +52,6 @@ public final class BlueprintView: UIView {
5452
didSet {
5553
// Shortcut: If both environments were empty, nothing changed.
5654
if oldValue.isEmpty && environment.isEmpty { return }
57-
// Shortcut: If there are no changes to the environment, then, well, nothing changed.
58-
if let layoutMode, layoutMode.options.skipUnneededSetNeedsViewHierarchyUpdates && oldValue.isEquivalent(
59-
to: environment,
60-
in: .all
61-
) {
62-
return
63-
}
6455

6556
setNeedsViewHierarchyUpdate()
6657
}
@@ -95,13 +86,6 @@ public final class BlueprintView: UIView {
9586
if oldValue == nil && element == nil {
9687
return
9788
}
98-
if let layoutMode, layoutMode.options.skipUnneededSetNeedsViewHierarchyUpdates, let contextuallyEquivalent = element as? ContextuallyEquivalent, contextuallyEquivalent.isEquivalent(
99-
to: oldValue as? ContextuallyEquivalent,
100-
in: .all
101-
) {
102-
return
103-
}
104-
cacheStorage = Environment.CacheStorageEnvironmentKey.defaultValue
10589

10690
Logger.logElementAssigned(view: self)
10791

@@ -164,7 +148,6 @@ public final class BlueprintView: UIView {
164148

165149
self.element = element
166150
self.environment = environment
167-
self.environment.cacheStorage = cacheStorage
168151

169152
rootController = NativeViewController(
170153
node: NativeViewNode(
@@ -559,13 +542,9 @@ public final class BlueprintView: UIView {
559542
environment.layoutMode = layoutMode
560543
}
561544

562-
environment.cacheStorage = cacheStorage
563-
564545
return environment
565546
}
566547

567-
568-
569548
private func handleAppeared() {
570549
rootController.traverse { node in
571550
node.onAppear?()

BlueprintUI/Sources/Element/Accessibility.swift

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -205,49 +205,3 @@ extension AXCustomContent {
205205
}
206206
}
207207

208-
extension Accessibility {
209-
public static func frameSort(
210-
direction: Environment.LayoutDirection,
211-
root: UIView,
212-
userInterfaceIdiom: UIUserInterfaceIdiom = UIDevice.current.userInterfaceIdiom
213-
) -> (NSObject, NSObject) -> Bool {
214-
{
215-
let first = root.convert($0.accessibilityFrame, from: nil)
216-
let second = root.convert($1.accessibilityFrame, from: nil)
217-
218-
// Horizontal sorting logic - reusable for both center-aligned and fallback cases
219-
let sortHorizontally = {
220-
switch direction {
221-
case .leftToRight:
222-
return first.minX < second.minX
223-
case .rightToLeft:
224-
return first.maxX > second.maxX
225-
}
226-
}
227-
228-
// Check if elements are vertically aligned along their central axis first.
229-
// While this check deviates from VoiceOver's behavior for UIKit, it covers one frequent
230-
// use case of Blueprint Row where it contains a number of elements with their
231-
// verticalAlignment set to .center. Since there's no view representation for Row,
232-
// checking for midY alignment is a reasonable heuristic in its absence.
233-
let centerYTolerance: CGFloat = 1.0
234-
let centerYDelta = abs(first.midY - second.midY)
235-
236-
if centerYDelta <= centerYTolerance {
237-
// Elements are center-aligned, sort horizontally.
238-
return sortHorizontally()
239-
}
240-
241-
// Derived through experimentation, this mimics the default sorting for UIKit.
242-
// If frames differ by more than 8 points the top most element is preferred.
243-
let minYTolerance = userInterfaceIdiom == .phone ? 8.0 : 13.0
244-
let minYDelta = abs(first.minY - second.minY)
245-
if minYDelta <= minYTolerance {
246-
// Elements are within vertical tolerance, sort horizontally.
247-
return sortHorizontally()
248-
}
249-
250-
return first.minY < second.minY
251-
}
252-
}
253-
}

BlueprintUI/Sources/Element/ElementContent.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,6 @@ extension ElementContent {
249249
storage = MeasurableStorage(measurer: measureFunction)
250250
}
251251

252-
/// Initializes a new `ElementContent` with no children that delegates to the provided measure function.
253-
///
254-
/// - parameter validationKey: If present, measureFunction will attempt to cache sizing based on the path of the node. validationKey will be evaluated to ensure that the result is valid.
255-
/// - parameter measureFunction: How to measure the `ElementContent` in the given `SizeConstraint` and `Environment`.
256-
public init(
257-
validationKey: some ContextuallyEquivalent,
258-
measureFunction: @escaping (SizeConstraint, Environment) -> CGSize
259-
) {
260-
storage = MeasurableStorage(validationKey: validationKey, measurer: measureFunction)
261-
}
262-
263252
/// Initializes a new `ElementContent` with no children that uses the provided intrinsic size for measuring.
264253
public init(intrinsicSize: CGSize) {
265254
self = ElementContent(measureFunction: { _ in intrinsicSize })

BlueprintUI/Sources/Element/MeasurableStorage.swift

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,7 @@ struct MeasurableStorage: ContentStorage {
77

88
let childCount = 0
99

10-
let validationKey: AnyContextuallyEquivalent?
1110
let measurer: (SizeConstraint, Environment) -> CGSize
12-
13-
init(validationKey: some ContextuallyEquivalent, measurer: @escaping (SizeConstraint, Environment) -> CGSize) {
14-
self.validationKey = AnyContextuallyEquivalent(validationKey)
15-
self.measurer = measurer
16-
}
17-
18-
init(measurer: @escaping (SizeConstraint, Environment) -> CGSize) {
19-
validationKey = nil
20-
self.measurer = measurer
21-
}
2211
}
2312

2413
extension MeasurableStorage: CaffeinatedContentStorage {
@@ -28,19 +17,7 @@ extension MeasurableStorage: CaffeinatedContentStorage {
2817
environment: Environment,
2918
node: LayoutTreeNode
3019
) -> CGSize {
31-
guard environment.layoutMode.options.measureableStorageCache, let validationKey else {
32-
return measurer(proposal, environment)
33-
}
34-
35-
let key = MeasurableSizeKey(path: node.path, max: proposal.maximum)
36-
return environment.cacheStorage.measurableStorageCache.retrieveOrCreate(
37-
key: key,
38-
environment: environment,
39-
validationValue: validationKey,
40-
context: .elementSizing,
41-
) { environment in
42-
measurer(proposal, environment)
43-
}
20+
measurer(proposal, environment)
4421
}
4522

4623
func performCaffeinatedLayout(
@@ -51,40 +28,3 @@ extension MeasurableStorage: CaffeinatedContentStorage {
5128
[]
5229
}
5330
}
54-
55-
extension MeasurableStorage {
56-
57-
fileprivate struct MeasurableSizeKey: Hashable {
58-
59-
let path: String
60-
let max: CGSize
61-
62-
func hash(into hasher: inout Hasher) {
63-
path.hash(into: &hasher)
64-
max.hash(into: &hasher)
65-
}
66-
67-
}
68-
69-
}
70-
71-
extension CacheStorage {
72-
73-
private struct MeasurableStorageCacheKey: CacheKey {
74-
static var emptyValue = EnvironmentAndValueValidatingCache<
75-
MeasurableStorage.MeasurableSizeKey,
76-
CGSize,
77-
AnyContextuallyEquivalent
78-
>()
79-
}
80-
81-
fileprivate var measurableStorageCache: EnvironmentAndValueValidatingCache<
82-
MeasurableStorage.MeasurableSizeKey,
83-
CGSize,
84-
AnyContextuallyEquivalent
85-
> {
86-
get { self[MeasurableStorageCacheKey.self] }
87-
set { self[MeasurableStorageCacheKey.self] = newValue }
88-
}
89-
90-
}

BlueprintUI/Sources/Layout/LayoutMode.swift

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111
/// Changing the default will cause all instances of ``BlueprintView`` to be invalidated, and re-
1212
/// render their contents.
1313
///
14-
public struct LayoutMode: Hashable {
14+
public struct LayoutMode: Equatable {
1515
public static var `default`: Self = .caffeinated {
1616
didSet {
1717
guard oldValue != .default else { return }
@@ -41,29 +41,15 @@ public struct LayoutMode: Hashable {
4141

4242
extension LayoutMode: CustomStringConvertible {
4343
public var description: String {
44-
var optionsDescription: [String] = []
45-
if options.hintRangeBoundaries {
46-
optionsDescription.append("hint")
47-
}
48-
if options.searchUnconstrainedKeys {
49-
optionsDescription.append("search")
50-
}
51-
if options.measureableStorageCache {
52-
optionsDescription.append("measureableStorageCache")
53-
}
54-
if options.stringNormalizationCache {
55-
optionsDescription.append("stringNormalizationCache")
56-
}
57-
if options.skipUnneededSetNeedsViewHierarchyUpdates {
58-
optionsDescription.append("needsViewHierarchyUpdates")
59-
}
60-
if options.labelAttributedStringCache {
61-
optionsDescription.append("labelAttributedStringCache")
62-
}
63-
if optionsDescription.isEmpty {
44+
switch (options.hintRangeBoundaries, options.searchUnconstrainedKeys) {
45+
case (true, true):
46+
return "Caffeinated (hint+search)"
47+
case (true, false):
48+
return "Caffeinated (hint)"
49+
case (false, true):
50+
return "Caffeinated (search)"
51+
case (false, false):
6452
return "Caffeinated"
65-
} else {
66-
return "Caffeinated \(optionsDescription.joined(separator: "+"))"
6753
}
6854
}
6955
}

BlueprintUI/Sources/Layout/LayoutOptions.swift

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ import Foundation
44
///
55
/// Generally these are only useful for experimenting with the performance profile of different
66
/// element compositions, and you should stick with ``default``.
7-
public struct LayoutOptions: Hashable {
7+
public struct LayoutOptions: Equatable {
88

99
/// The default configuration.
1010
public static let `default` = LayoutOptions(
1111
hintRangeBoundaries: true,
12-
searchUnconstrainedKeys: true,
13-
measureableStorageCache: true,
14-
stringNormalizationCache: true,
15-
skipUnneededSetNeedsViewHierarchyUpdates: true,
16-
labelAttributedStringCache: true
12+
searchUnconstrainedKeys: true
1713
)
1814

1915
/// Enables aggressive cache hinting along the boundaries of the range between constraints and
@@ -26,32 +22,8 @@ public struct LayoutOptions: Hashable {
2622
/// Layout contract for correct behavior.
2723
public var searchUnconstrainedKeys: Bool
2824

29-
/// Allows caching the results of `MeasurableStorage` `sizeThatFits`.
30-
public var measureableStorageCache: Bool
31-
32-
/// Caches results of AttributedLabel normalization process.
33-
public var stringNormalizationCache: Bool
34-
35-
/// Allows skipping calls to setNeedsViewHierarchyUpdates when updating Environment, if the environment is
36-
/// equilvalent to the prior value.
37-
public var skipUnneededSetNeedsViewHierarchyUpdates: Bool
38-
39-
/// Caches MarketLabel attributed string generation
40-
public var labelAttributedStringCache: Bool
41-
42-
public init(
43-
hintRangeBoundaries: Bool,
44-
searchUnconstrainedKeys: Bool,
45-
measureableStorageCache: Bool,
46-
stringNormalizationCache: Bool,
47-
skipUnneededSetNeedsViewHierarchyUpdates: Bool,
48-
labelAttributedStringCache: Bool
49-
) {
25+
public init(hintRangeBoundaries: Bool, searchUnconstrainedKeys: Bool) {
5026
self.hintRangeBoundaries = hintRangeBoundaries
5127
self.searchUnconstrainedKeys = searchUnconstrainedKeys
52-
self.measureableStorageCache = measureableStorageCache
53-
self.stringNormalizationCache = stringNormalizationCache
54-
self.skipUnneededSetNeedsViewHierarchyUpdates = skipUnneededSetNeedsViewHierarchyUpdates
55-
self.labelAttributedStringCache = labelAttributedStringCache
5628
}
5729
}

BlueprintUI/Tests/EnvironmentEntangledCacheTests.swift

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)