Skip to content

Commit df629d7

Browse files
committed
fix(display-list): make moveContents nonoptional
1 parent a5b6045 commit df629d7

4 files changed

Lines changed: 18 additions & 7 deletions

File tree

‎Package.resolved‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Sources/OpenRenderBox/Render/ORBDisplayList.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public final class ORBDisplayList: NSObject, ORBDisplayListContents {
154154

155155
// MARK: - Contents
156156

157-
public func moveContents() -> (any ORBDisplayListContents)? {
157+
public func moveContents() -> any ORBDisplayListContents {
158158
_openRenderBoxUnimplementedFailure()
159159
}
160160

‎Sources/OpenRenderBoxCxx/include/OpenRenderBoxObjC/Render/ORBDisplayList.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ORB_ASSUME_NONNULL_BEGIN
5656
- (void)drawDisplayList:(id<ORBDisplayListContents>)list alpha:(float)alpha;
5757
- (void)drawInRect:(CGRect)rect alpha:(float)alpha blendMode:(int)mode flags:(unsigned int)flags operation:(id /* block */)operation;
5858
- (void)renderInContext:(CGContextRef)context options:(nullable id)options;
59-
- (nullable id<ORBDisplayListContents>)moveContents;
59+
- (id<ORBDisplayListContents>)moveContents;
6060
- (void)setIdentifier:(unsigned int)identifier namespace:(nullable NSUUID *)ns;
6161
- (void)beginRecordingXML;
6262
- (void)addAffineTransformStyle:(CGAffineTransform)style;

‎Tests/OpenRenderBoxCompatibilityTests/DisplayListTests.swift‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,20 @@ struct DisplayListTests {
6363
context.fill([CGRect(x: 0, y: 0, width: 10, height: 10)])
6464
displayList.endCGContext()
6565

66-
let contents = displayList.moveContents()
67-
#expect(contents != nil)
66+
let contents: any ORBDisplayListContents = displayList.moveContents()
67+
#expect(!contents.isEmpty())
68+
#expect(displayList.isEmpty())
69+
70+
let emptyContents: any ORBDisplayListContents = displayList.moveContents()
71+
#expect(emptyContents.isEmpty())
72+
#expect(displayList.isEmpty())
73+
}
74+
75+
@Test
76+
func testMoveEmptyContents() {
77+
let displayList = ORBDisplayList()
78+
let contents: any ORBDisplayListContents = displayList.moveContents()
79+
#expect(contents.isEmpty())
6880
#expect(displayList.isEmpty())
6981
}
7082

@@ -94,8 +106,7 @@ struct DisplayListTests {
94106
displayList.endCGContext()
95107

96108
let contents = displayList.moveContents()
97-
#expect(contents != nil)
98-
#expect(contents!.isEmpty() == false)
109+
#expect(!contents.isEmpty())
99110
}
100111
#endif
101112
}

0 commit comments

Comments
 (0)