[scroll] replace ScrollViewType with UIKit's scroll view names on ScrollView - #105
Conversation
…ollView `ScrollViewType` reused names `NSScrollView` already has (`bounds`, `contentSize`, `contentView`) as same-named methods, which gave each name two meanings on AppKit. For `contentView()` it was a trap: Swift imports a `contentView() -> NSView?` onto every `NSScrollView` from `NSTextFinderBarContainer`, so in an optional or inferred context a call resolved to AppKit's clip view instead of the document view (#27). The protocol added nothing either: `ScrollView` is its superclass constraint and conforms itself, so no other type can conform. `ScrollView` now has UIKit's names and meanings on both platforms. On AppKit it implements `contentOffset`, `contentInset`, `adjustedContentInset`, `visibleSize` and `isScrollEnabled` on top of the clip view, and keeps its `contentSize` override, which AppKit itself never reads. The scroll range helpers move to `ScrollView+Scrolling.swift`, and the renderable container becomes the internal `contentContainerView`, which also replaces the public `documentView()`. Removed: `ScrollViewType`, `bounds()`, `setBounds(_:)`, `contentSize()`, `setContentSize(_:)`, `contentInsets()`, `setContentInsets(_:)`, `contentOffset()`, `setContentOffset(_:)`, `contentView()`, the macOS `documentView()`, and `BaseScrollView.isScrollable`. Fixes #27.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (42)
💤 Files with no reviewable changes (2)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe pull request replaces ChangesCross-platform ScrollView API
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to This change moves ScrollView to a cross-platform property API and updates ComposeView and its tests to use it. No concrete defect was identified, and the author reports passing macOS and iOS test runs. tvOS and visionOS rely on CI. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to This is a documented breaking API change within one UI package. The inspected paths retain existing content ownership, rendering order, and event routing. No material security regression was established, but downstream compatibility and complete security coverage remain unverified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 11.28% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 133 functions across 39 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #105 +/- ##
==========================================
+ Coverage 95.44% 95.99% +0.54%
==========================================
Files 114 114
Lines 7006 6985 -21
==========================================
+ Hits 6687 6705 +18
+ Misses 319 280 -39
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e15f3f5608
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
On UIKit, `setBounds(_:)` assigned `bounds`, which resizes the view around its center, while setting `frame.size` keeps its origin, so the note's replacement changed where a resized view sits. It now says to assign `bounds` on iOS, tvOS and visionOS, to set `frame.size`, then `contentOffset` on macOS, and that setting `frame.size`, then `contentOffset` resizes from the view's origin on every platform.
Summary
ScrollViewis now a UIKit-named class adapter: one scroll view API on both platforms, with UIKit's names and meanings, and no name that means two things on macOS.ScrollViewTypeand its method-style accessors, which reusedNSScrollView's own names (bounds,contentSize,contentView) with different meanings. ForcontentView(), that let Swift silently pick AppKit's clip view in an optional or inferred context (AppKit:contentView()resolves toNSScrollView.contentView(the clip view) in optional or inferred contexts #27).isScrollableto UIKit'sisScrollEnabled.What changed
ScrollViewgainscontentOffset,contentInset,adjustedContentInset,visibleSizeandisScrollEnabled, implemented on the clip view. On iOS these areUIScrollView's own.contentSizekeeps its existing override, which AppKit itself never reads (probed in tiling, layout, display, scrolling, resizing, scroller changes and magnification).minOffsetX/Y,maxOffsetX/Y,canScrollTo*,stopDecelerating()) move toScrollView+Scrolling.swift, rewritten on the new names.contentContainerView, the document view on macOS and the scroll view itself on iOS, replacescontentView()and the publicdocumentView().ComposeViewand the slide transition use the new members. The render pass assignsself.contentSize, since a local variable shadows the property there.ScrollViewTypeTestsis split intoScrollViewTests, now cross-platform contract tests, andScrollView+ScrollingTests.setBounds(_:)'s behavior on each platform.Platform differences kept on purpose
Each is pinned by a test, with a follow-up issue:
contentOffsetclamps it into the scrollable range on macOS, but not on iOS #100).contentInsetiscontentInsets, which includes the automatic adjustment while it's on ([scroll] LockComposeView's automatic insets, magnification, border, and document view #103 locks it off forComposeView).visibleSizeis the clip view's size, which legacy scroll bars and pixel rounding affect ([render] Make visibleSize and the render size exact on macOS, instead of rounded to pixels #102).Test plan
visibleSizeequalsbounds.size, with a content inset and zoom, passes on iOS, tvOS and visionOS. On visionOS,AnimationClockTests.test_now_firstReadDuringTheCommit_theTurnEndsWhenTheLoopWakesfailed once and passed on CI's retry. It's timing-sensitive and unrelated to this change.make formatandmake lint.Follow-ups
#99, #100, #101, #102, #103, #104
Fixes #27