AppKit: CPApplication, CPImage, CPColorPicker PLATFORM conditional removal

- 10 PLATFORM blocks resolved across three files: runtime
  CPDOMAvailable guards (6 wrapped, 3 early returns, 1 sequential
  guard-return preserving the CommonJS result)
- CPApplication: @global CPWindowObjectList declared; its definition
  resides in the DOM-only CPPlatformWindow+DOM category
- zero preprocessor directives remain in these files
- work-in-progress towards complete removal of CPP directives
This commit is contained in:
David Richardson committed 2026-08-29 12:25:14 -06:00
1 parent 06ebbfb300
commit c2be4f87c5
3 files changed
+64 -58

No files matched your search

+25 -22
View File
@@ -37,6 +37,8 @@
@import "CPWindowController.j"
@import "_CPPopoverWindow.j"
@global CPWindowObjectList
@typedef CPModalSession
var CPMainCibFile = @"CPMainCibFile",
@@ -241,9 +243,10 @@ var CPApplicationDelegate_applicationShouldTerminate_ = 1 << 0,
// At this point we clear the window.status to eliminate Safari's "Cancelled" error message
// The message shouldn't be displayed, because only an XHR is cancelled, but it is a usability issue.
// We do it here so that applications can change it in willFinish or didFinishLaunching
#if PLATFORM(DOM)
window.status = " ";
#endif
if (CPDOMAvailable)
{
window.status = " ";
}
// We also want to set the default cursor on the body, so that buttons and things don't have an iBeam
[[CPCursor arrowCursor] set];
@@ -273,9 +276,10 @@ var CPApplicationDelegate_applicationShouldTerminate_ = 1 << 0,
var needsUntitled = !!_documentController,
URLStrings = nil;
#if PLATFORM(DOM)
URLStrings = window.cpOpeningURLStrings && window.cpOpeningURLStrings();
#endif
if (CPDOMAvailable)
{
URLStrings = window.cpOpeningURLStrings && window.cpOpeningURLStrings();
}
var index = 0,
count = [URLStrings count];
@@ -727,11 +731,10 @@ var CPApplicationDelegate_applicationShouldTerminate_ = 1 << 0,
*/
- (CPArray)orderedWindows
{
#if PLATFORM(DOM)
return CPWindowObjectList();
#else
if (CPDOMAvailable)
return CPWindowObjectList();
return [];
#endif
}
- (void)hide:(id)aSender
@@ -1304,22 +1307,22 @@ _CPRunModalLoop = function(anEvent)
function CPApplicationMain(args, namedArgs)
{
#if PLATFORM(DOM)
// hook to allow recorder, etc to manipulate things before starting AppKit
if (window.parent !== window && typeof window.parent._childAppIsStarting === "function")
if (CPDOMAvailable)
{
try
// hook to allow recorder, etc to manipulate things before starting AppKit
if (window.parent !== window && typeof window.parent._childAppIsStarting === "function")
{
window.parent._childAppIsStarting(window);
}
catch(err)
{
// This could happen if we're in an iframe without access to the parent frame.
CPLog.warn("Failed to call parent frame's _childAppIsStarting().");
try
{
window.parent._childAppIsStarting(window);
}
catch(err)
{
// This could happen if we're in an iframe without access to the parent frame.
CPLog.warn("Failed to call parent frame's _childAppIsStarting().");
}
}
}
#endif
var mainBundle = [CPBundle mainBundle],
principalClass = [mainBundle principalClass];
+33 -30
View File
@@ -23,6 +23,7 @@
@import <Foundation/CPObject.j>
@import "CPView.j"
@import "CPCompatibility.j"
@class CPSlider
@class CPColorPanel
@@ -235,24 +236,25 @@
{
if (self = [super initWithFrame:aFrame])
{
#if PLATFORM(DOM)
var path = [[CPBundle bundleForClass:CPColorPicker] pathForResource:@"wheel.png"];
if (CPDOMAvailable)
{
var path = [[CPBundle bundleForClass:CPColorPicker] pathForResource:@"wheel.png"];
_wheelImage = new Image();
_wheelImage.src = path;
_wheelImage.style.position = "absolute";
_wheelImage = new Image();
_wheelImage.src = path;
_wheelImage.style.position = "absolute";
path = [[CPBundle bundleForClass:CPColorPicker] pathForResource:@"wheel_black.png"];
path = [[CPBundle bundleForClass:CPColorPicker] pathForResource:@"wheel_black.png"];
_blackWheelImage = new Image();
_blackWheelImage.src = path;
_blackWheelImage.style.opacity = "0";
_blackWheelImage.style.filter = "alpha(opacity=0)";
_blackWheelImage.style.position = "absolute";
_blackWheelImage = new Image();
_blackWheelImage.src = path;
_blackWheelImage.style.opacity = "0";
_blackWheelImage.style.filter = "alpha(opacity=0)";
_blackWheelImage.style.position = "absolute";
_DOMElement.appendChild(_wheelImage);
_DOMElement.appendChild(_blackWheelImage);
#endif
_DOMElement.appendChild(_wheelImage);
_DOMElement.appendChild(_blackWheelImage);
}
[self setWheelSize:aFrame.size];
@@ -272,10 +274,10 @@
- (void)setWheelBrightness:(float)brightness
{
#if PLATFORM(DOM)
if (!CPDOMAvailable) return;
_blackWheelImage.style.opacity = 1.0 - brightness;
_blackWheelImage.style.filter = "alpha(opacity=" + (1.0 - brightness) * 100 + ")"
#endif
}
- (void)setFrameSize:(CGSize)aSize
@@ -288,21 +290,22 @@
{
var min = MIN(aSize.width, aSize.height);
#if PLATFORM(DOM)
_blackWheelImage.style.width = min;
_blackWheelImage.style.height = min;
_blackWheelImage.width = min;
_blackWheelImage.height = min;
_blackWheelImage.style.top = (aSize.height - min) / 2.0 + "px";
_blackWheelImage.style.left = (aSize.width - min) / 2.0 + "px";
if (CPDOMAvailable)
{
_blackWheelImage.style.width = min;
_blackWheelImage.style.height = min;
_blackWheelImage.width = min;
_blackWheelImage.height = min;
_blackWheelImage.style.top = (aSize.height - min) / 2.0 + "px";
_blackWheelImage.style.left = (aSize.width - min) / 2.0 + "px";
_wheelImage.style.width = min;
_wheelImage.style.height = min;
_wheelImage.width = min;
_wheelImage.height = min;
_wheelImage.style.top = (aSize.height - min) / 2.0 + "px";
_wheelImage.style.left = (aSize.width - min) / 2.0 + "px";
#endif
_wheelImage.style.width = min;
_wheelImage.style.height = min;
_wheelImage.width = min;
_wheelImage.height = min;
_wheelImage.style.top = (aSize.height - min) / 2.0 + "px";
_wheelImage.style.left = (aSize.width - min) / 2.0 + "px";
}
_radius = min / 2.0;
+6 -6
View File
@@ -239,7 +239,8 @@ function CPAppKitImage(aFilename, aSize)
*/
- (CPData)data
{
#if PLATFORM(DOM)
if (!CPDOMAvailable) return;
var dataURL;
if ([_filename hasPrefix:@"data:image"])
@@ -261,7 +262,6 @@ function CPAppKitImage(aFilename, aSize)
var base64 = dataURL.replace(/^data:image\/png;base64,/, "");
return [CPData dataWithBase64:base64];
#endif
}
/*!
@@ -384,7 +384,8 @@ function CPAppKitImage(aFilename, aSize)
_loadStatus = CPImageLoadStatusLoading;
#if PLATFORM(DOM)
if (!CPDOMAvailable) return;
_image = new Image();
var isSynchronous = YES;
@@ -431,7 +432,6 @@ function CPAppKitImage(aFilename, aSize)
// onload and friends may fire after this point but BEFORE the end of the run loop,
// crazy, I know. So don't set isSynchronous here, rather wait a bit longer.
window.setTimeout(function() { isSynchronous = NO; }, 0);
#endif
}
- (BOOL)isSingleImage
@@ -641,7 +641,8 @@ function CPAppKitImage(aFilename, aSize)
- (DOMElement)applyCSSImageForView:(CPView)aView onDOMElement:(DOMElement)aDOMElement styleNode:(DOMElement)aStyleNode previousState:(CPArrayRef)aPreviousStateRef
{
#if PLATFORM(DOM)
if (!CPDOMAvailable) return;
// First, restore previous CSS styling before applying the new one
var aPreviousState = @deref(aPreviousStateRef);
@@ -724,7 +725,6 @@ function CPAppKitImage(aFilename, aSize)
@deref(aPreviousStateRef) = aPreviousState;
return aStyleNode;
#endif
}
- (BOOL)_shouldBeResized