Merge branch 'main' into CPTimezone-modernize

This commit is contained in:
David Richardson committed 2026-09-29 20:28:49 -06:00
commit ed66323b7f
6 files changed
+187 -72

No files matched your search

+66 -2
View File
@@ -108,6 +108,26 @@ function CPTextFieldHandleBlur(anEvent, ownerRef)
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
function _CPTextFieldDetachInputElement(anElement)
{
if (!anElement || !anElement.parentNode)
return;
var wasResigning = CPTextFieldInputResigning;
CPTextFieldInputResigning = YES;
try
{
anElement.parentNode.removeChild(anElement);
}
catch (e)
{
// Bereits durch einen Blur-Handler entfernt – nichts zu tun.
}
CPTextFieldInputResigning = wasResigning;
CPTextFieldInputDidBlur = NO;
}
@implementation CPString (CPTextFieldAdditions)
@@ -661,7 +681,42 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
var element = [self _inputElement];
element.value = _stringValue;
_DOMElement.appendChild(element);
if (element.parentNode !== _DOMElement)
{
var previousOwner = CPTextFieldInputOwner;
// Otherwise Chrome will fire the blur during appendChild (NotFoundError).
_CPTextFieldDetachInputElement(element);
try
{
_DOMElement.appendChild(element);
}
catch (e)
{
// Race with the Blur-Handler: retry once and yield silently.
_CPTextFieldDetachInputElement(element);
try
{
_DOMElement.appendChild(element);
}
catch (e2)
{
[self unsetThemeState:CPThemeStateEditing];
[self _updatePlaceholderState];
[self setNeedsLayout];
return NO;
}
}
if (previousOwner && previousOwner !== self)
{
[previousOwner unsetThemeState:CPThemeStateEditing];
[previousOwner setNeedsLayout];
}
}
CPTextFieldInputIsActive = YES;
@@ -913,7 +968,16 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
CPTextFieldBlurHandler();
if (element.parentNode == _DOMElement)
element.parentNode.removeChild(element);
{
try
{
element.parentNode.removeChild(element);
}
catch (e)
{
// Bereits durch den Blur-Handler entfernt.
}
}
// Previosly, we unflagged CPTextFieldInputDidBlur and CPTextFieldInputResigning before
// the call to removeChild. This resulted in DOM exceptions in Chrome under certain conditions.
+1 -1
View File
@@ -3294,7 +3294,7 @@ var _CPCopyPlaceholder = '-';
var currentFirstResponder = [[CPApp keyWindow] firstResponder];
// Can we accept richtext? Then this is our preference (fixme: shift key to force plain text paste)
if ([currentFirstResponder isRichText])
if ([currentFirstResponder respondsToSelector:@selector(isRichText)] && [currentFirstResponder isRichText])
{
var richtext = nativeClipboard.getData('text/rtf');
+15 -1
View File
@@ -57,11 +57,25 @@ var screenNeedsInitialization = NO,
return [CPApp _sendDelegateApplicationShouldTerminateMessage];
};
window.onunload = function()
var terminateApplication = function()
{
[self closeAllPlatformWindows];
[CPApp terminate:nil];
};
// "unload" is blocked by the permissions policy in current Chrome and prevents the
// back/forward cache. "pagehide" fires reliably instead. If event.persisted is true the
// page goes into the bfcache and may be restored, so the application must not terminate.
if ("onpagehide" in window)
{
window.addEventListener("pagehide", function(anEvent)
{
if (!anEvent.persisted)
terminateApplication();
}, NO);
}
else
window.onunload = terminateApplication;
}
}
+37 -25
View File
@@ -79,6 +79,8 @@ var hasEditableTarget = function(aDOMEvent)
BOOL _ignoreNativeCopyOrCutEvent;
BOOL _ignoreNativePastePreparation;
JSObject _clipboardListeners;
}
- (id)init
@@ -134,37 +136,34 @@ var hasEditableTarget = function(aDOMEvent)
{
if (supportsNativeCopyAndPaste)
{
_DOMWindow.addEventListener("beforecopy", nativeBeforeClipboardEventCallback, NO);
_DOMWindow.addEventListener("beforecut", nativeBeforeClipboardEventCallback, NO);
_DOMWindow.addEventListener("beforepaste", nativeBeforeClipboardEventCallback, NO);
_DOMWindow.addEventListener("copy", nativeCopyOrCutEventCallback, NO);
_DOMWindow.addEventListener("cut", nativeCopyOrCutEventCallback, NO);
_DOMWindow.addEventListener("paste", nativePasteEventCallback, NO);
_clipboardListeners = [
[_DOMWindow, "beforecopy", nativeBeforeClipboardEventCallback],
[_DOMWindow, "beforecut", nativeBeforeClipboardEventCallback],
[_DOMWindow, "beforepaste", nativeBeforeClipboardEventCallback],
[_DOMWindow, "copy", nativeCopyOrCutEventCallback],
[_DOMWindow, "cut", nativeCopyOrCutEventCallback],
[_DOMWindow, "paste", nativePasteEventCallback]
];
}
else
{
theDocument.addEventListener("beforepaste", pasteEventCallback, NO);
theDocument.addEventListener("beforecopy", copyEventCallback, NO);
theDocument.addEventListener("beforecut", copyEventCallback, NO);
_clipboardListeners = [
[theDocument, "beforepaste", pasteEventCallback],
[theDocument, "beforecopy", copyEventCallback],
[theDocument, "beforecut", copyEventCallback]
];
}
_DOMWindow.addEventListener("unload", function()
for (var i = 0; i < _clipboardListeners.length; i++)
_clipboardListeners[i][0].addEventListener(_clipboardListeners[i][1], _clipboardListeners[i][2], NO);
// "unload" is blocked by the permissions policy in current Chrome and prevents the
// back/forward cache. "pagehide" fires reliably instead. If event.persisted is true the
// page goes into the bfcache and may be restored, so the listeners must stay.
_DOMWindow.addEventListener("pagehide", function(anEvent)
{
if (supportsNativeCopyAndPaste)
{
_DOMWindow.removeEventListener("beforecopy", nativeBeforeClipboardEventCallback, NO);
_DOMWindow.removeEventListener("beforecut", nativeBeforeClipboardEventCallback, NO);
_DOMWindow.removeEventListener("beforepaste", nativeBeforeClipboardEventCallback, NO);
_DOMWindow.removeEventListener("copy", nativeCopyOrCutEventCallback, NO);
_DOMWindow.removeEventListener("cut", nativeCopyOrCutEventCallback, NO);
_DOMWindow.removeEventListener("paste", nativePasteEventCallback, NO);
}
else
{
theDocument.removeEventListener("beforepaste", pasteEventCallback, NO);
theDocument.removeEventListener("beforecopy", copyEventCallback, NO);
theDocument.removeEventListener("beforecut", copyEventCallback, NO);
}
if (!anEvent.persisted)
[self _removeClipboardListeners];
}, NO);
}
else
@@ -175,6 +174,8 @@ var hasEditableTarget = function(aDOMEvent)
- (void)destroyDOMElements
{
[self _removeClipboardListeners];
var theDocument = _DOMWindow.document,
_DOMBodyElement = theDocument.getElementById("cappuccino-body") || theDocument.body;
@@ -182,6 +183,17 @@ var hasEditableTarget = function(aDOMEvent)
_DOMPasteboardElement = nil;
}
- (void)_removeClipboardListeners
{
if (!_clipboardListeners)
return;
for (var i = 0; i < _clipboardListeners.length; i++)
_clipboardListeners[i][0].removeEventListener(_clipboardListeners[i][1], _clipboardListeners[i][2], NO);
_clipboardListeners = nil;
}
- (void)windowMaySendKeyEvent:(CPEvent)anEvent
{
// Reset our opinions.
+52 -28
View File
@@ -10,16 +10,39 @@ const utilsFile = ObjectiveJ.utils.file;
var subprojects = ["Objective-J", "CommonJS", "Foundation", "AppKit", "Tools"];
// -----------------------------------------------------------------------------
// Build Orchestration
// -----------------------------------------------------------------------------
var isMasterBuild = process.env.CAPP_INNER_BUILD !== "1";
task ("build", function() {
childProcess.execSync(["mkdir", "-p", $BUILD_DIR].map(utilsFile.enquote).join(" "), {stdio: 'inherit'});
childProcess.execSync(['ln', '-sf', '"$PWD"/node_modules', utilsFile.enquote($BUILD_DIR)].join(" "), {stdio: 'inherit'});
});
["build", "clean", "clobber"].forEach(function(aTaskName)
task ("build", function() {
if (isMasterBuild) {
// Intercept top-level 'jake build' execution.
// Spawn the complete pipeline to avoid circular dependency resolution
// with common.jake's internal targets.
process.env.CAPP_INNER_BUILD = "1";
childProcess.execSync("jake CommonJS build-manual-tests-symlinks", {stdio: 'inherit'});
} else {
// Execute the baseline compilation step when invoked as a prerequisite
subjake(subprojects, "build");
}
});
["clean", "clobber"].forEach(function(aTaskName)
{
task (aTaskName, function()
{
// Traverse standard framework/tool targets
subjake(subprojects, aTaskName);
// Explicitly target the manual tests for wipe operations
subjake(["Tests/Manual"], aTaskName);
});
});
@@ -43,10 +66,32 @@ filedir ($BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, ["debug", "release"], function(
utilsFile.cp_r(path.join($BUILD_DIR, "Debug", "BlendKit"), path.join($BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, "BlendKit"));
});
task ("CommonJS", [$BUILD_CJS_OBJECTIVE_J_DEBUG_FRAMEWORKS, $BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, "debug", "release"], function() {
task ("CommonJS", [$BUILD_CJS_OBJECTIVE_J_DEBUG_FRAMEWORKS,$BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, "debug", "release"], function() {
});
// Install everything in the dist directory
task ("build-manual-tests-symlinks", function()
{
var fwDir = path.join("Tests", "Manual", ".Frameworks");
fs.mkdirSync(fwDir, { recursive: true });
var frameworks = [
{ src: path.join($BUILD_CJS_OBJECTIVE_J_DEBUG_FRAMEWORKS, "Objective-J"), name: "Objective-J" },
{ src: path.join($BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, "Foundation"), name: "Foundation" },
{ src: path.join($BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, "AppKit"), name: "AppKit" },
{ src: path.join($BUILD_CJS_CAPPUCCINO_DEBUG_FRAMEWORKS, "BlendKit"), name: "BlendKit" }
];
frameworks.forEach(function(fw) {
var dest = path.join(fwDir, fw.name);
utilsFile.rm_rf(dest);
fs.symlinkSync(path.resolve(fw.src), dest, 'dir');
});
});
// -----------------------------------------------------------------------------
// NPM Distribution & Legacy Artifacts
// -----------------------------------------------------------------------------
task ("dist", ["CommonJS"], function()
{
installCopy($BUILD_CJS_OBJECTIVE_J, false);
@@ -59,8 +104,6 @@ task ("sudo-dist", ["CommonJS"], function()
installCopy($BUILD_CJS_CAPPUCCINO, true);
});
// Install everything in the dist directory (task dist) and
// create symlinks to the 'dist' binaries in the global 'npm prefix' path
task ("install", ["dist"], function()
{
installGlobal($BUILD_CJS_OBJECTIVE_J, false);
@@ -133,7 +176,6 @@ task ("documentation-no-frame", function()
task ("docset", function()
{
// First, check if docsetutil is available. This is only required for this task.
if (!executableExists("docsetutil")) {
console.error("\nError: 'docsetutil' is not installed, but it's required to build the docset.".red);
console.log("This tool is no longer bundled with Xcode, but can be installed with Homebrew:");
@@ -141,7 +183,6 @@ task ("docset", function()
process.exit(1);
}
// If the tool exists, proceed with the build.
generateDocs(true, true);
});
@@ -167,7 +208,6 @@ function generateDocs(/* boolean */ noFrame, /* boolean */ buildDocset = false)
return;
}
// --- Temporary Directory Setup ---
const projectRoot = process.cwd();
const tempDir = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'capp-docs-')));
console.log(`Using temporary directory for build: ${tempDir}`);
@@ -175,7 +215,6 @@ function generateDocs(/* boolean */ noFrame, /* boolean */ buildDocset = false)
try {
var documentationDir = path.join(projectRoot, "Tools", "Documentation");
// --- Pre-processing ---
console.log("Pre-processing source files...");
const preProcessorsDir = path.join(documentationDir, "preprocess");
var processors = fs.readdirSync(preProcessorsDir).sort();
@@ -185,7 +224,6 @@ function generateDocs(/* boolean */ noFrame, /* boolean */ buildDocset = false)
childProcess.execSync(`"${processorPath}" "${projectRoot}"`, { stdio: 'inherit', cwd: tempDir });
}
// --- Doxygen Execution ---
const doxygenConfigFile = path.join(documentationDir, "Cappuccino.doxygen");
const doxygenTempConfig = path.join(tempDir, "Cappuccino.doxygen");
fs.copyFileSync(doxygenConfigFile, doxygenTempConfig);
@@ -202,8 +240,6 @@ function generateDocs(/* boolean */ noFrame, /* boolean */ buildDocset = false)
const htmlOutputDir = path.join(generatedDocsRoot, "html");
const makefilePath = path.join(htmlOutputDir, "Makefile");
// --- Makefile Execution (ONLY for docset) ---
// For a standard 'jake docs', we do NOT run make.
if (buildDocset && fs.existsSync(makefilePath)) {
console.log("Patching Makefile to use 'docsetutil' from PATH...");
childProcess.execSync(`sed -i.bak 's|"\\$(XCODE_INSTALL_DIR)"/usr/bin/docsetutil|docsetutil|' "${makefilePath}"`);
@@ -212,7 +248,6 @@ function generateDocs(/* boolean */ noFrame, /* boolean */ buildDocset = false)
childProcess.execSync('make', { stdio: 'inherit', cwd: htmlOutputDir });
}
// --- Post-processing ---
console.log("Post-processing generated documentation...");
const postProcessorsDir = path.join(documentationDir, "postprocess");
processors = fs.readdirSync(postProcessorsDir).sort();
@@ -222,14 +257,12 @@ function generateDocs(/* boolean */ noFrame, /* boolean */ buildDocset = false)
childProcess.execSync(`"${processorPath}" "${projectRoot}" "${htmlOutputDir}"`, { stdio: 'inherit', cwd: tempDir });
}
// --- Final Installation ---
if (fs.existsSync(generatedDocsRoot)) {
if (fs.existsSync($DOCUMENTATION_BUILD)) {
fs.rmSync($DOCUMENTATION_BUILD, { recursive: true, force: true });
}
fs.renameSync(generatedDocsRoot, $DOCUMENTATION_BUILD);
// Manually copy the custom CSS file
const finalHtmlPath = path.join($DOCUMENTATION_BUILD, "html");
const customCSS = path.join(documentationDir, "doxygen.css");
if (fs.existsSync(customCSS)) {
@@ -245,7 +278,6 @@ function generateDocs(/* boolean */ noFrame, /* boolean */ buildDocset = false)
console.error("An error occurred during documentation generation:", e.message);
process.exit(1);
} finally {
// --- Cleanup ---
console.log(`Cleaning up temporary directory: ${tempDir}`);
fs.rmSync(tempDir, { recursive: true, force: true });
}
@@ -255,14 +287,13 @@ function generateDocs(/* boolean */ noFrame, /* boolean */ buildDocset = false)
task ("downloads", ["starter_download"]);
$STARTER_README = path.join('Tools', 'READMEs', 'STARTER-README');
$STARTER_BOOTSTRAP = 'bootstrap.sh';
$STARTER_README = path.join('Tools', 'READMEs', 'STARTER-README');$STARTER_BOOTSTRAP = 'bootstrap.sh';
$STARTER_DOWNLOAD = path.join($BUILD_DIR, 'Cappuccino', 'Starter');
$STARTER_DOWNLOAD_APPLICATION = path.join($STARTER_DOWNLOAD, 'NewApplication');
$STARTER_DOWNLOAD_README = path.join($STARTER_DOWNLOAD, 'README');
$STARTER_DOWNLOAD_BOOTSTRAP = path.join($STARTER_DOWNLOAD, 'bootstrap.sh');
task ("starter_download", [$STARTER_DOWNLOAD_APPLICATION, $STARTER_DOWNLOAD_README, $STARTER_DOWNLOAD_BOOTSTRAP, "documentation"], function()
task ("starter_download", [$STARTER_DOWNLOAD_APPLICATION, $STARTER_DOWNLOAD_README,$STARTER_DOWNLOAD_BOOTSTRAP, "documentation"], function()
{
if (FILE.exists($DOCUMENTATION_BUILD))
{
@@ -277,16 +308,12 @@ filedir ($STARTER_DOWNLOAD_APPLICATION, ["CommonJS"], function()
FILE.mkdirs($STARTER_DOWNLOAD);
if (OS.system(["capp", "gen", $STARTER_DOWNLOAD_APPLICATION, "-t", "Application", "--noconfig"]))
// FIXME: uncomment this: we get conversion errors
OS.exit(1); // rake abort if ($? != 0)
//{}
// No tools means no objective-j gem
// FILE.rm(FILE.join($STARTER_DOWNLOAD_APPLICATION, 'Rakefile'))
OS.exit(1);
});
filedir ($STARTER_DOWNLOAD_README, [$STARTER_README], function()
{
utilsFile.cp($STARTER_README, $STARTER_DOWNLOAD_README);
utilsFile.cp($STARTER_README,$STARTER_DOWNLOAD_README);
});
filedir ($STARTER_DOWNLOAD_BOOTSTRAP, [$STARTER_BOOTSTRAP], function()
@@ -302,7 +329,6 @@ task ("deploy", ["downloads", "demos"], function()
{
var cappuccino_output_path = path.join($BUILD_DIR, 'Cappuccino');
// zip the starter pack
var starter_zip_output = path.join($BUILD_DIR, 'Cappuccino', 'Starter.zip');
utilsFile.rm_rf(starter_zip_output);
@@ -363,14 +389,12 @@ task ("demos", function()
return !demo.excluded();
}).forEach(function(demo)
{
// copy frameworks into the demos
utilsFile.cp_r(path.join($STARTER_DOWNLOAD_APPLICATION, "Frameworks"), path.join(demo.path(), "Frameworks"));
utilsFile.rm_rf(path.join(demo.path(), "Frameworks", "Debug"));
var outputPath = demo.name().replace(/\s/g, "-") + ".zip";
OS.system("cd " + OS.enquote(FILE.dirname(demo.path()))+" && zip -ry -8 " + OS.enquote(outputPath) + " " + OS.enquote(FILE.basename(demo.path())));
// remove the frameworks
utilsFile.rm_rf(path.join(demo.path(), "Frameworks"));
});
});
+16 -15
View File
@@ -21,15 +21,15 @@
*/
var ENV = process.env,
task = JAKE.task,
cp = require("child_process"),
path = require("path");
task = JAKE.task,
cp = require("child_process"),
path = require("path");
// Neutered standard targets to protect CI from exhaustive traversals
task ("default", function()
{
console.log("Global traversal disabled to prevent CI timeouts.");
console.log("Use 'npx jake batch-compile' or 'npx jake batch-compile-all' to deliberately build the suite.");
console.log("Global traversal disabled to prevent CI timeouts.");
console.log("Use 'npx jake batch-compile' or 'npx jake batch-compile-all' to deliberately build the suite.");
});
task ("build", ["default"]);
task ("build-all", ["default"]);
@@ -39,37 +39,38 @@ task ("release", ["default"]);
// Safe environment management tasks
task ("configure", function()
{
var targetPath = path.join(process.cwd(), ".Frameworks");
cp.execSync("find . -mindepth 2 -iname 'jakefile' -execdir sh -c 'echo \"Configuring $(basename \\\"$PWD\\\")\"; ln -sfn \"$1\" Frameworks' _ '" + targetPath + "' \\;", { stdio: "inherit" });
var targetPath = path.join(process.cwd(), ".Frameworks");
cp.execSync("find . -mindepth 2 -iname 'jakefile' -execdir sh -c 'echo \"Configuring $(basename \\\"$PWD\\\")\"; ln -sfn \"$1\" Frameworks' _ '" + targetPath + "' \\;", { stdio: "inherit" });
});
task ("clean", function()
{
var targetDir = ENV["BUILD_PATH"] || ENV["CAPP_BUILD"] || "Build";
cp.execSync("find . -name '" + targetDir + "' -type d -prune -exec rm -rf {} +", { stdio: "inherit" });
var targetDir = ENV["BUILD_PATH"] || ENV["CAPP_BUILD"] || "Build";
cp.execSync("find . -name '" + targetDir + "' -type d -prune -exec rm -rf {} +", { stdio: "inherit" });
});
task ("clobber", ["clean"], function()
{
cp.execSync("find . -mindepth 2 -type l -name 'Frameworks' -exec rm -f {} +", { stdio: "inherit" });
cp.execSync("find . -mindepth 2 -type l -name 'Frameworks' -exec rm -f {} +", { stdio: "inherit" });
cp.execSync("rm -rf .Frameworks", { stdio: "inherit" });
});
// Alien targets for manual, local execution
task ("batch-compile", function()
{
cp.execSync("find . -mindepth 2 -iname 'jakefile' -execdir npx jake build \\;", { stdio: "inherit", env: ENV });
cp.execSync("find . -mindepth 2 -iname 'jakefile' -execdir npx jake build \\;", { stdio: "inherit", env: ENV });
});
task ("batch-compile-all", ["batch-compile-debug", "batch-compile-release"]);
task ("batch-compile-debug", function()
{
ENV["CONFIGURATION"] = "Debug";
cp.execSync("find . -mindepth 2 -iname 'jakefile' -execdir npx jake debug \\;", { stdio: "inherit", env: ENV });
ENV["CONFIGURATION"] = "Debug";
cp.execSync("find . -mindepth 2 -iname 'jakefile' -execdir npx jake debug \\;", { stdio: "inherit", env: ENV });
});
task ("batch-compile-release", function()
{
ENV["CONFIGURATION"] = "Release";
cp.execSync("find . -mindepth 2 -iname 'jakefile' -execdir npx jake release \\;", { stdio: "inherit", env: ENV });
ENV["CONFIGURATION"] = "Release";
cp.execSync("find . -mindepth 2 -iname 'jakefile' -execdir npx jake release \\;", { stdio: "inherit", env: ENV });
});