CPScrollView: Show full border on bordered scroll views in Aristo3

Previously, Aristo3's 1px CSS border on scroll views was occluded on
the top and left edges by zero insets, switching to CPNoBorder left
stale border styling because CPNoBorder did not set a background, and
-setBorderType: requested only a redraw rather than a layout pass for
CSS-themed rendering.

Line and bezel insets are now 1px on all sides, every border type sets
its background (with Aristo3 returning no background for CPNoBorder),
and -setBorderType: now triggers a layout update.
This commit is contained in:
David Richardson committed 2026-11-25 10:14:55 -06:00
1 parent f29788e4e6
commit 1d0944c2bc
3 files changed
+110 -7

No files matched your search

+13 -3
View File
@@ -573,7 +573,13 @@ Notifies the delegate when the scroll view has finished scrolling.
_borderType = borderType;
[self reflectScrolledClipView:_contentView];
[self setNeedsDisplay:YES];
/*
2026-11-25: A CSS theme applies the border background in -layoutSubviews, so a change
of border type must lay the scroll view out again. Only a redraw was requested, which
a CSS theme does not use, so the old background stayed until some other layout.
*/
[self refreshDisplay];
}
@@ -1906,8 +1912,12 @@ Notifies the delegate when the scroll view has finished scrolling.
if (![self isCSSBased])
return;
if (_borderType !== CPNoBorder)
[self setBackgroundColor:[self currentValueForThemeAttribute:@"background-color-"+CPScrollViewBorderSuffixes[_borderType]]];
/*
2026-11-25: The background is set for every border type. It was not set for
CPNoBorder, so a scroll view whose border type changed to CPNoBorder kept the
background, and with it the border, of its previous border type.
*/
[self setBackgroundColor:[self currentValueForThemeAttribute:@"background-color-"+CPScrollViewBorderSuffixes[_borderType]]];
if (_scrollerStyle === CPScrollerStyleLegacy)
[[self bottomCornerView] setBackgroundColor:[self currentValueForThemeAttribute:@"bottom-corner-color"]];
+12 -4
View File
@@ -2282,8 +2282,11 @@ function A3MaskIconOfSize(aMaskImage, aColor, aSize)
themedScrollViewValues =
[
// --- Standard States ---
[@"background-color-no-border", bezelCssColor],
[@"background-color-no-border", bezelFocusedCssColor, [CPThemeStateFirstResponder, CPThemeStateKeyWindow]],
/*
2026-11-25: No background for a scroll view without a border. The values were the
bordered bezel, so a scroll view whose border type changed to CPNoBorder kept a
border. The cause: the bezel was copied to every border type.
*/
[@"background-color-line-border", bezelCssColor],
[@"background-color-line-border", bezelFocusedCssColor, [CPThemeStateFirstResponder, CPThemeStateKeyWindow]],
[@"background-color-bezel-border", bezelCssColor],
@@ -2292,8 +2295,13 @@ function A3MaskIconOfSize(aMaskImage, aColor, aSize)
[@"background-color-groove-border", bezelFocusedCssColor, [CPThemeStateFirstResponder, CPThemeStateKeyWindow]],
[@"content-inset-no-border", CGInsetMakeZero()],
[@"content-inset-line-border", CGInsetMake(0,2,2,0)],
[@"content-inset-bezel-border", CGInsetMake(0,2,2,0)],
/*
2026-11-25: The content of a bordered scroll view is inset by the 1px CSS border on
every side. The insets were 0 at the top and left, so the content covered the top and
left border lines, and a white text view on a light pane had no visible edge there.
*/
[@"content-inset-line-border", CGInsetMake(1,1,1,1)],
[@"content-inset-bezel-border", CGInsetMake(1,1,1,1)],
[@"content-inset-groove-border", CGInsetMake(0,2,2,0)],
[@"bottom-corner-color", bottomCornerColor],
+85
View File
@@ -1,11 +1,13 @@
@import <AppKit/AppKit.j>
@import "CPNotificationCenterHelper.j"
@import "BuiltThemes.j"
@implementation CPScrollViewTest : OJTestCase
{
CPScrollerStyle globalScrollerStyle;
CPTheme previousTheme;
}
- (void)setUp
@@ -14,6 +16,7 @@
[[CPApplication alloc] init];
globalScrollerStyle = [CPScrollView globalScrollerStyle];
previousTheme = [CPTheme defaultTheme];
}
/*
@@ -23,6 +26,7 @@
- (void)tearDown
{
[CPScrollView setGlobalScrollerStyle:globalScrollerStyle];
[CPTheme setDefaultTheme:previousTheme];
}
/*!
@@ -488,6 +492,87 @@
[self assertSize:CGSizeMake(95.0, 95.0) equals:contentSize message:@"both scroller widths come from scrollerWidthInStyle:"];
}
// MARK: - Borders in a CSS theme
/*
Makes the built Aristo3 theme, a CSS theme, the default theme, so that scroll views made
after it take it. The tests need the themes built first, as `npx jake build` does.
*/
- (void)useAristo3
{
var theme = BuiltThemeNamed(@"Aristo3");
[self assertNotNull:theme message:@"The built blends hold no Aristo3 theme. Build the themes first."];
[self assertTrue:[theme isCSSBased] message:@"Aristo3 is a CSS theme"];
[CPTheme setDefaultTheme:theme];
}
- (CPScrollView)scrollViewWithBorderType:(CPBorderType)aBorderType
{
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[scrollView setScrollerStyle:CPScrollerStyleOverlay];
[scrollView setHasHorizontalScroller:NO];
[scrollView setHasVerticalScroller:NO];
[scrollView setBorderType:aBorderType];
[scrollView setDocumentView:[[CPView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]];
[scrollView layoutIfNeeded];
return scrollView;
}
/*
Aristo3 draws the border as a 1px CSS border, so the content must leave 1px free on every
side, or it covers the border lines there.
*/
- (void)testTheContentOfABezeledScrollViewLeavesItsBorderFreeOnEverySide
{
[self useAristo3];
var scrollView = [self scrollViewWithBorderType:CPBezelBorder];
[self assertTrue:CGRectEqualToRect([[scrollView contentView] frame], CGRectMake(1, 1, 98, 98))
message:@"content frame " + CPStringFromRect([[scrollView contentView] frame]) + " should be {{1, 1}, {98, 98}}"];
}
- (void)testTheContentOfALineBorderedScrollViewLeavesItsBorderFreeOnEverySide
{
[self useAristo3];
var scrollView = [self scrollViewWithBorderType:CPLineBorder];
[self assertTrue:CGRectEqualToRect([[scrollView contentView] frame], CGRectMake(1, 1, 98, 98))
message:@"content frame " + CPStringFromRect([[scrollView contentView] frame]) + " should be {{1, 1}, {98, 98}}"];
}
- (void)testAScrollViewWithoutABorderHasNoBackground
{
[self useAristo3];
var scrollView = [self scrollViewWithBorderType:CPNoBorder];
[self assertNull:[scrollView backgroundColor] message:@"a scroll view without a border has no background"];
}
/*
In a CSS theme the border is the background, so a scroll view whose border is removed must
lose the background too.
*/
- (void)testAScrollViewLosesItsBorderWhenTheBorderTypeChangesToNoBorder
{
[self useAristo3];
var scrollView = [self scrollViewWithBorderType:CPBezelBorder];
[self assertNotNull:[scrollView backgroundColor] message:@"precondition: a bezeled scroll view has a background"];
[scrollView setBorderType:CPNoBorder];
[scrollView layoutIfNeeded];
[self assertNull:[scrollView backgroundColor] message:@"the background of the bezel stays after the border is removed"];
}
@end