From fa525e1cee65bf505b8ecb11508f20ce7153609a Mon Sep 17 00:00:00 2001 From: David Richardson Date: Tue, 1 Sep 2026 08:34:36 -0600 Subject: [PATCH] AppKit: final PLATFORM body-block sweep (8 files) - CPVisualEffectView, CPWebView, _CPBorderlessBridgeWindowView, CPViewAnimator, CPFontManager, _CPMenuBarWindow, CPRuleEditor, CPScrollView: 8 PLATFORM blocks resolved to runtime CPDOMAvailable guards (5 wrapped, 2 guard-returns, 1 if/else) - this completes the method-body sweep: remaining PLATFORM directives are a method-definition, class-scope, or import gate, reserved for the structural-design phase - work-in-progress towards complete removal of CPP directives --- AppKit/CPFontManager.j | 44 ++++++++++--------- AppKit/CPMenu/_CPMenuBarWindow.j | 20 +++++---- AppKit/CPRuleEditor/CPRuleEditor.j | 10 +++-- AppKit/CPScrollView.j | 7 ++- AppKit/CPVisualEffectView.j | 8 ++-- AppKit/CPWebView.j | 8 ++-- .../CPWindow/_CPBorderlessBridgeWindowView.j | 10 +++-- AppKit/CoreAnimation/CPViewAnimator.j | 7 ++- 8 files changed, 63 insertions(+), 51 deletions(-) diff --git a/AppKit/CPFontManager.j b/AppKit/CPFontManager.j index d10a27e44..6429590ac 100644 --- a/AppKit/CPFontManager.j +++ b/AppKit/CPFontManager.j @@ -25,6 +25,7 @@ @import "CPControl.j" @import "CPFont.j" @import "CPFontDescriptor.j" +@import "CPCompatibility.j" @global CPApp @class CPFontPanel @@ -132,28 +133,31 @@ CPRemoveTraitFontAction = 7; { _availableFonts = []; -#if PLATFORM(DOM) - _CPFontDetectSpan = document.createElement("span"); - _CPFontDetectSpan.fontSize = "24px"; - _CPFontDetectSpan.appendChild(document.createTextNode("mmmmmmmmmml")); - var div = document.createElement("div"); - div.style.position = "absolute"; - div.style.top = "-1000px"; - div.appendChild(_CPFontDetectSpan); - document.getElementsByTagName("body")[0].appendChild(div); - - _CPFontDetectReferenceFonts = _CPFontDetectPickTwoDifferentFonts(["monospace", "serif", "sans-serif", "cursive"]); - - for (var i = 0; i < _CPFontDetectAllFonts.length; i++) + if (CPDOMAvailable) { - var available = _CPFontDetectFontAvailable(_CPFontDetectAllFonts[i]); - if (available) - _availableFonts.push(_CPFontDetectAllFonts[i]); + _CPFontDetectSpan = document.createElement("span"); + _CPFontDetectSpan.fontSize = "24px"; + _CPFontDetectSpan.appendChild(document.createTextNode("mmmmmmmmmml")); + var div = document.createElement("div"); + div.style.position = "absolute"; + div.style.top = "-1000px"; + div.appendChild(_CPFontDetectSpan); + document.getElementsByTagName("body")[0].appendChild(div); + + _CPFontDetectReferenceFonts = _CPFontDetectPickTwoDifferentFonts(["monospace", "serif", "sans-serif", "cursive"]); + + for (var i = 0; i < _CPFontDetectAllFonts.length; i++) + { + var available = _CPFontDetectFontAvailable(_CPFontDetectAllFonts[i]); + if (available) + _availableFonts.push(_CPFontDetectAllFonts[i]); + } + } + else + { + // If there's no font detection, just assume all fonts are available. + _availableFonts = _CPFontDetectAllFonts; } -#else - // If there's no font detection, just assume all fonts are available. - _availableFonts = _CPFontDetectAllFonts; -#endif } return _availableFonts; } diff --git a/AppKit/CPMenu/_CPMenuBarWindow.j b/AppKit/CPMenu/_CPMenuBarWindow.j index c39596622..7b0b0d0bb 100644 --- a/AppKit/CPMenu/_CPMenuBarWindow.j +++ b/AppKit/CPMenu/_CPMenuBarWindow.j @@ -22,6 +22,7 @@ @import "CPPanel.j" @import "_CPMenuManager.j" +@import "CPCompatibility.j" @class _CPMenuView @class CPMenu @@ -100,16 +101,17 @@ - (void)setTitle:(CPString)aTitle { -#if PLATFORM(DOM) - var bundleName = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"CPBundleName"]; + if (CPDOMAvailable) + { + var bundleName = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"CPBundleName"]; - if (![bundleName length]) - document.title = aTitle; - else if ([aTitle length]) - document.title = aTitle + @" - " + bundleName; - else - document.title = bundleName; -#endif + if (![bundleName length]) + document.title = aTitle; + else if ([aTitle length]) + document.title = aTitle + @" - " + bundleName; + else + document.title = bundleName; + } [_titleField setStringValue:aTitle]; [_titleField sizeToFit]; diff --git a/AppKit/CPRuleEditor/CPRuleEditor.j b/AppKit/CPRuleEditor/CPRuleEditor.j index e934424c5..87d13548b 100644 --- a/AppKit/CPRuleEditor/CPRuleEditor.j +++ b/AppKit/CPRuleEditor/CPRuleEditor.j @@ -33,6 +33,7 @@ @import "_CPRuleEditorViewSliceRow.j" @import "_CPRuleEditorLocalizer.j" +@import "CPCompatibility.j" @class CPCompoundPredicate @class CPComparisonPredicate @@ -2248,10 +2249,11 @@ TODO: implement firstSlice = [_slices objectAtIndex:firstIndex], dragview = [[CPView alloc] initWithFrame:[firstSlice frame]]; -#if PLATFORM(DOM) - var html = firstSlice._DOMElement.innerHTML; - dragview._DOMElement.innerHTML = [html copy]; -#endif + if (CPDOMAvailable) + { + var html = firstSlice._DOMElement.innerHTML; + dragview._DOMElement.innerHTML = [html copy]; + } [dragview setBackgroundColor:[firstSlice backgroundColor]]; [dragview setAlphaValue:0.7]; diff --git a/AppKit/CPScrollView.j b/AppKit/CPScrollView.j index 73533032a..c5ba08182 100644 --- a/AppKit/CPScrollView.j +++ b/AppKit/CPScrollView.j @@ -30,6 +30,7 @@ @import "CPScroller.j" @import "CPView.j" @import "CPRulerView.j" +@import "CPCompatibility.j" @class CPTableView @class CPRulerView @@ -49,7 +50,8 @@ /*! @ignore */ var _isBrowserUsingOverlayScrollers = function() { -#if PLATFORM(DOM) + if (!CPDOMAvailable) return NO; + /* Even if the system supports overlay (Lion) scrollers, the browser (e.g. FireFox *cough*) may not. @@ -85,9 +87,6 @@ var _isBrowserUsingOverlayScrollers = function() document.body.removeChild(outer); return usingOverlayScrollers; -#else - return NO; -#endif }; var TIMER_INTERVAL = 0.2, diff --git a/AppKit/CPVisualEffectView.j b/AppKit/CPVisualEffectView.j index 45c9e7a92..b5eb5e05f 100644 --- a/AppKit/CPVisualEffectView.j +++ b/AppKit/CPVisualEffectView.j @@ -23,6 +23,7 @@ @import @import "CPAppearance.j" @import "CPView.j" +@import "CPCompatibility.j" @typedef CPVisualEffectMaterial CPVisualEffectMaterialAppearanceBased = 0; @@ -126,9 +127,10 @@ CPVisualEffectStateInactive = 2; [self setBackgroundColor:finalColor]; -#if PLATFORM(DOM) - self._DOMElement.style[prop] = shouldEnable ? "blur(30px)" : nil; -#endif + if (CPDOMAvailable) + { + self._DOMElement.style[prop] = shouldEnable ? "blur(30px)" : nil; + } } diff --git a/AppKit/CPWebView.j b/AppKit/CPWebView.j index 35a65860e..d3a22f13c 100644 --- a/AppKit/CPWebView.j +++ b/AppKit/CPWebView.j @@ -22,6 +22,7 @@ @import "CPView.j" @import "CPScrollView.j" +@import "CPCompatibility.j" @class CPWebScriptObject @@ -1031,9 +1032,10 @@ CPWebViewAppKitScrollMaxPollCount = 3; _forwardStack = []; _scrollMode = CPWebViewScrollAuto; -#if PLATFORM(DOM) - [self _initDOMWithFrame:[self frame]]; -#endif + if (CPDOMAvailable) + { + [self _initDOMWithFrame:[self frame]]; + } if (![self backgroundColor]) [self setBackgroundColor:[CPColor whiteColor]]; diff --git a/AppKit/CPWindow/_CPBorderlessBridgeWindowView.j b/AppKit/CPWindow/_CPBorderlessBridgeWindowView.j index de208b924..a75756e0b 100644 --- a/AppKit/CPWindow/_CPBorderlessBridgeWindowView.j +++ b/AppKit/CPWindow/_CPBorderlessBridgeWindowView.j @@ -21,6 +21,7 @@ */ @import "_CPWindowView.j" +@import "CPCompatibility.j" @implementation _CPBorderlessBridgeWindowView : _CPWindowView { @@ -90,10 +91,11 @@ if (_frame.size.width < theWindow._minSize.width || _frame.size.height < theWindow._minSize.height) [theWindow._contentView setFrameSize:CGSizeMake(MAX(_frame.size.width, theWindow._minSize.width), MAX(_frame.size.height, theWindow._minSize.height))]; -#if PLATFORM(DOM) - _DOMElement.style.overflowX = (_frame.size.width < theWindow._minSize.width)? "scroll":"hidden"; - _DOMElement.style.overflowY = (_frame.size.height < theWindow._minSize.height)? "scroll":"hidden"; -#endif + if (CPDOMAvailable) + { + _DOMElement.style.overflowX = (_frame.size.width < theWindow._minSize.width)? "scroll":"hidden"; + _DOMElement.style.overflowY = (_frame.size.height < theWindow._minSize.height)? "scroll":"hidden"; + } } @end diff --git a/AppKit/CoreAnimation/CPViewAnimator.j b/AppKit/CoreAnimation/CPViewAnimator.j index 5fb289ce2..96602d737 100644 --- a/AppKit/CoreAnimation/CPViewAnimator.j +++ b/AppKit/CoreAnimation/CPViewAnimator.j @@ -394,11 +394,10 @@ var frameToCSSTranslationTransformMatrix = function(start, current) - (Object)_DOMElement { -#if PLATFORM(DOM) - return _DOMElement; -#else + if (CPDOMAvailable) + return _DOMElement; + return nil; -#endif } - (CPString)debug_description