Commit Graph
6351 Commits
Author SHA1 Message Date
David Richardson 66ea130c8d AppKit: Disable Undo and Redo when a text view does not allow undo
A text view handled undo: and redo: and registered its changes even when allowsUndo was NO, so Edit > Undo stayed enabled and did nothing.

Behaviour now follows canonical Cocoa: a text view that does not allow undo registers nothing and passes undo: and redo: on to the window, and Undo and Redo are enabled only when there is a change to undo or redo.

* CPTextView/CPTextView.j: Register changes only when undo is allowed, stop responding to undo: and redo: when it is not, and validate the Undo and Redo items against the undo manager.

* CPWindow/CPWindow.j: Validate the Undo and Redo items against the window's undo manager.

* Tests/AppKit/CPTextViewTest.j: Add tests for responding to undo:, registering changes and validating the Undo item.

* Tests/Manual/TextEditor/DocumentWindowController.j: Add toggleAllowsUndo: and validateMenuItem:, so that undo can be turned on and off for the active document.

* Tests/Manual/TextEditor/Resources/MainMenu.xib, Resources/MainMenu.cib: Add Edit > Allow Undo.

* Tests/Manual/TextEditor/WORKLIST.md: Remove the entry for this gap, record Allow Undo as tested, and add the key equivalent behaviour of disabled menu items for discussion.
2026-10-23 17:20:27 -06:00
David Richardson 947fbaddfa AppKit: Show CPBundleDisplayName as the application's name
AppKit read only CPBundleName for the name that users see, so an application's display name was ignored. It now follows Cocoa, which shows CFBundleDisplayName and falls back to CFBundleName.

* CPApplication.j: Add _applicationName, which returns CPBundleDisplayName or, without one, CPBundleName, and use it as the About panel title.

* CPMenu/_CPMenuBarWindow.j: Use the display name in the browser tab title.

* Tests/Manual/TextEditor/Info.plist: Rename the display name key from CFBundleDisplayName to CPBundleDisplayName.

* Tests/Manual/TextEditor/WORKLIST.md: Remove the entry for this gap, and record the About panel as tested.
2026-10-23 16:45:51 -06:00
David Richardson 055ae6d04e AppKit: List the application's windows in the Windows menu
The Window menu never listed the application's windows, because AppKit had none of Cocoa's Windows menu support.

* CPApplication.j: Add windowsMenu, setWindowsMenu:, addWindowsItem:title:filename:, changeWindowsItem:title:filename:, removeWindowsItem:, updateWindowsItem: and arrangeInFront:; find the menu named _CPWindowsMenu in the main menu, and list the visible windows when the main menu is set.

* CPWindow/CPWindow.j: Add isExcludedFromWindowsMenu and setExcludedFromWindowsMenu:, and keep the window's item current when the window is ordered in or out, retitled, made main or no longer main, miniaturized, deminiaturized or closed.

* Tests/AppKit/CPApplicationWindowsMenuTest.j: Add tests for listing, retitling, exclusion, the main window check mark, separator handling, file name titles and moving items to another Windows menu.

* Tests/Manual/TextEditor/WORKLIST.md: Remove the entry for this gap, and record the Window menu as tested.
2026-10-23 16:29:46 -06:00
David Richardson 56aa68f832 AppKit: Reflect the toolbar's visibility in the Show Toolbar menu item
The Show Toolbar menu item toggled the toolbar, but CPWindow did not validate it, so its title never changed and it stayed enabled in windows without a toolbar.

* CPWindow/CPWindow.j: Add validateUserInterfaceItem:, which sets the toggleToolbarShown: item's title to Hide Toolbar or Show Toolbar and enables it only when the window has a toolbar.
* Tests/Manual/TextEditor/WORKLIST.md: Remove the entry for this defect, and record the menu item as tested.
2026-10-23 16:12:14 -06:00
David Richardson c1f8c8ceb3 AppKit: Store the window delegate's resize size in the window frame
A window stored the proposed size in its frame before asking its delegate through windowWillResize:toSize:, and gave the delegate's size only to the window view. When the delegate enlarged the size, hit testing used the smaller frame, so the window could no longer be moved or resized.

* CPWindow/CPWindow.j: Ask the delegate before storing the new size, and store the size it returns in the frame.
* CPWindow/_CPWindowView.j: Ask the delegate during a user resize, and move the origin by the delegate's adjustment when resizing from the left or top edge, so that the opposite edge stays in place.
* Tests/Manual/TextEditor/Resources/DocumentWindow.xib: Make the document window's content view resize with the window.
* Tests/Manual/TextEditor/WORKLIST.md: Remove the entry for this defect, record the minimum window size behaviour as tested, and add the content view resizing setting that does not reach the cib.
2026-10-23 15:21:23 -06:00
David Richardson be8d536565 Merge branch 'main' into refactor-remove-nativehost-target 2026-10-22 12:44:13 -06:00
David Richardson ac709c97bf AppKit: Document CPAlert's return code as the clicked button's tag
CPAlert's documentation described the return code as the button index, which is only its default tag.

* CPAlert: Document the alert return code as the clicked button's tag, which is its index unless changed.
2026-10-22 12:37:02 -06:00
David Richardson 203bf38b21 AppKit: Size vertical scrollers by scroller style in CPScrollView
CPScrollView's frame and content size calculations sized the vertical scroller with scrollerWidthForControlSize:, passing a scroller style, so it always took the legacy width.

* CPScrollView: Use scrollerWidthInStyle: for the vertical scroller in +contentSizeForFrameSize:… and +frameSizeForContentSize:….
* CPScrollViewTest: Add tests for both methods with a scroller whose widths differ by style.
2026-10-22 12:36:32 -06:00
David Richardson 483fff9305 Merge branch 'main' into refactor-remove-nativehost-target 2026-10-20 17:35:13 -06:00
David Richardson a49a5021df AppKit: Fix references to undefined identifiers
Several functions and methods referenced identifiers that were never declared or defined.

* CGColor: Compare color spaces by identity in CGColorEqualToColor, replacing a call to the undefined CGColorSpaceEqualToColorSpace whose test was inverted.
* CGContextCanvas: Declare abs_cos and abs_sin in scale_rotate and rotate_scale.
* CGContextText: Call CGPointMakeZero in CGContextGetTextPosition instead of the removed _CGPointMakeZero.
* CPColor: Compare pattern orientation with CPColorPatternIsVertical instead of BlendKit's PatternIsVertical.
* CPMenu: Declare _CPMenuBarImage with the file's other menu bar variables.
* CPScrollView: Test horizontalScrollerClass and verticalScrollerClass in +frameSizeForContentSize:horizontalScrollerClass:verticalScrollerClass:borderType:controlSize:scrollerStyle: instead of the undefined hFlag and vFlag.
2026-10-20 17:15:04 -06:00
daboe01 1ae6767971 aristo2 fix 2026-10-18 18:12:55 +02:00
David Richardson f1a8b154fc AppKit: Fix CPDOMAvailable read before assignment
CPDOMAvailable was read during load before it was assigned.

* CPCompatibility: Move the CPDOMAvailable assignment ahead of the engine detection, whose AppleWebKit case calls +[CPPlatform isBrowser], which reads it.
* CPCompatibilityTest: Add a test that re-executes CPCompatibility.j with an AppleWebKit user agent and CPDOMAvailable unset, failing on any exception.
2026-10-15 09:26:12 -06:00
David Richardson 572c872c31 Merge branch 'main' into refactor-remove-nativehost-target 2026-10-13 10:06:18 -06:00
David Richardson 2aee03c7fb AppKit: Annotate macOS-only standard key bindings
Record that the standard key binding table is not platform-aware.

* CPKeyBinding: Add TODO noting that CPStandardKeyBindings applies macOS bindings on every platform.

The modifier-key conflicts on Windows and Linux are now documented at the source.
2026-10-13 10:01:47 -06:00
David Richardson 15268c45c4 AppKit: Remove remaining #if DEBUG conditionals
Eliminate conditional compilation for debug builds across AppKit.

* CPAnimationContext: Remove debug logging traces.
* _CPCibCustomObject, _CPCibCustomView, _CPCibWindowTemplate: Convert unknown-class log messages to unconditional warnings.
* CPView: Convert duplicate-subview assertion to an unconditional check.
* _CPObject+Theme: Convert array-as-state assertions to unconditional checks and remove obsolete performance TODOs.

AppKit is now free of C-style preprocessor directives.
2026-10-09 16:47:46 -06:00
David Richardson bf19b09ad0 AppKit: add missed CPDOMDisplayServer.j promotion, drop its header
- the promotion commit captured the consumer imports and the test
  update but missed the new source file itself and the deletion of
  the force-included header it replaces
- without the .j, the display-server functions are absent from the
  compiled frameworks; with the .h still present, the legacy build
  force-includes the old macro definitions alongside the new
  functions
- follow-up to the display-server promotion commit
2026-10-06 19:40:40 -06:00
David Richardson 7f38fbe7c7 Tests: promote CPDOMDisplayServer.h to a real source file
- the 11 display-server primitives become plain functions in
  Platform/DOM/CPDOMDisplayServer.j; bodies verbatim from the macro
  definitions; the header was force-included into every AppKit
  compilation by the legacy build and invisible to capp-build
- CPView.j, CPImageView.j, _CPDisplayServer.j import the new file;
  this was the last header in either framework
- CPDOMDisplayServerTest: the raw #include replaced by the
  framework-qualified import
2026-10-06 18:50:09 -06:00
David Richardson 901241d74e AppKit: inline CGContextCanvas backend, last include fragment removed
- CoreGraphics/CGContextCanvas.j (635 lines) inlined into CGContext.j
  at the former #include site inside the CPHTMLCanvasFeature branch
- the 11 one-line canvas delegation macros become plain functions;
  their macro form was a 2008-era call-overhead optimization that
  modern JITs make unnecessary
- the compatibility tables, hasPath path-semantics helper, backend
  implementations and CGBitmapGraphicsContextCreate pass through
  verbatim
- capp-build's compiled AppKit gains the canvas backend for the first
  time: the deferred include previously omitted it entirely
- zero #define, #include or #pragma directives remain in AppKit or
  Foundation sources
2026-10-06 18:17:33 -06:00
David Richardson 2167c1d3b8 AppKit: delete IE-era VML rendering backend
- CoreGraphics/CGContextVML.j removed; it implemented the CGContext
  function family against Internet Explorer's VML, irrelevant in the
  supported browser landscape for over a decade
- its self-replacing CGBitmapGraphicsContextCreate wrapper called
  document.namespaces.add, an IE-only API — a latent crash on modern
  browsers had the branch ever been selected
- CGContext.j: the CPVMLFeature branch of the load-time backend
  selection removed; CPCompatibility.j: the CPVMLFeature constant and
  its feature-table entry removed
- Tests/AppKit/CGContextTest.j: the vacuous VML-incompatibility
  assertion removed
- the canvas backend and the no-canvas stubs are unchanged
2026-10-06 18:08:43 -06:00
David Richardson 1f087223a9 AppKit: remove vestigial pragma directive from CPTabView
- the spaced "# pragma mark -" form escaped the earlier MARK
  conversion pass and the directive censuses; it is dead text
- this was the last pragma directive in either framework
2026-10-06 17:55:58 -06:00
David Richardson 3fa722fa18 AppKit: convert CPFont caching macros to file-scope functions
- the seven chained macros (_CPRealFontSize, _CPFontNormalizedNames,
  _CPCachedFont, _CPUserFont, _CPSystemFontCacheKey,
  _CPCachedSystemFont, _CPSystemFont) become plain functions with
  verbatim bodies
- all 25 call sites unchanged; all arguments at call sites are pure
  expressions, so evaluation semantics are identical
- file-internal only: no other source file references these names
2026-10-06 17:50:55 -06:00
David Richardson 2322eb87e3 AppKit: remove CGColorSpace macros
- _CGColorSpaceCreateWithModel becomes a function returning the
  model record
- STANDARDIZE, whose body contains a return from the enclosing
  function, is inlined verbatim at its two call sites (alpha
  standardization and the RGB/CMYK component loop)
2026-10-06 17:43:27 -06:00
David Richardson adec5f6c04 AppKit: convert instance-state macros to private methods
- CPScrollView _shouldShowCornerView, CPSplitView
  _maybePostWillResizeNotification/_maybePostDidResizeNotification/
  _didSuppressResizeNotifications/_setResizeNotificationsSuppressed:,
  CPTableView _numberOfColumns/_updateColumnRangesIfNecessary/
  _fullRowHeight/_rowBottomOfHeightInfo:/_hasVariableRowHeights,
  CPMenuItem _decodeValueForKey:defaultValue:coder:/
  _encodeValue:forKey:ifNotEqualTo:coder:, CALayer
  _adjustContentsZIndexForLayer: and DOM: macros that referenced
  ivars, self or the enclosing method's coder become private instance
  methods; call sites rewritten from macro form to message form
2026-10-06 17:42:56 -06:00
David Richardson 315ed7f2df AppKit: convert parameter-only macros to file-scope functions
- CABackingStore PIXEL, CPDragServer DRAGGING_WINDOW,
  CPOutlineView SELECTION_SHOULD_CHANGE and SHOULD_SELECT_ITEM
  become plain functions; call syntax is unchanged at all sites
- these macros reference only their parameters, so no ambient state
  is involved
2026-10-06 17:41:26 -06:00
David Richardson 20867949ed Build: remove vestigial PLATFORM macro infrastructure
- AppKit/Platform/Platform.h deleted; it defined only the
  PLATFORM(FEATURE) macro, which no source file uses since the
  AppKit preprocessor-removal work completed
- Foundation/Jakefile: the historical --include of that header into
  every Foundation compilation is removed
- Jake/environment.js and the Objective-J subproject's copy: the
  -DPLATFORM_COMMONJS/-DPLATFORM_BROWSER/-DPLATFORM_DOM flags are
  removed; they defined symbols read only by the deleted macro
- no functional change; capp-build is unaffected (it consumes neither
  the header nor the flags)
2026-10-06 12:07:07 -06:00
David Richardson 6199b8f31b AppKit: pasteboard classes ungated (Increment D, closes structural tail)
- CPPasteboard.j and Platform/DOM/CPPlatformPasteboard.j: the
  PLATFORM(DOM) gates removed; _CPDOMDataTransferPasteboard and
  CPPlatformPasteboard now exist under both targets
- the SUPPRESS_CAPPUCCINO_CUT/PASTE one-statement macros inlined at
  their four call sites; the defines are deleted
- no #if PLATFORM gate remains anywhere in AppKit; the browser/
  CommonJS distinction is now expressed entirely through runtime
  CPDOMAvailable guards
- work-in-progress towards complete removal of CPP directives
2026-10-06 11:50:40 -06:00
David Richardson de0647b299 AppKit: platform classes unified under runtime guards (Increment C)
- CPPlatform.j and CPPlatformString.j: the PLATFORM(DOM) gates and
  CommonJS #else subclasses removed; one implementation serves both
  targets
- CPPlatform: isBrowser and supportsDragAndDrop return NO when no DOM
  is present, preserving the CommonJS results exactly; the NativeHost
  distinction (window.cpIsDesktop) is unchanged
- CPPlatformString: createDOMElements, charPositionOfString,
  sizeOfString and metricsOfFont return the former CommonJS-branch
  values (no-op / zero / zero size / zero metrics) when no DOM is
  present
- work-in-progress towards complete removal of CPP directives
2026-10-04 17:30:56 -06:00
David Richardson bfbc522721 AppKit: DOM platform window category ungated (Increment B)
- CPWindow.j: the PLATFORM(BROWSER) import gate removed; the
  CPPlatformWindow (DOM) category now loads under both targets
- category _init restructured: DOM setup (window capture, pasteboard,
  registration) behind CPDOMAvailable; CommonJS branch initializes the
  same state as the base class
- SCROLLWHEEL_LINE_PIXELS converted from #define to a file-scope
  variable; its only uses are within this file
- load-time audit: file-scope statements are DOM-free; the single
  typeof-guarded document reference takes its no-DOM branch under Node
- work-in-progress towards complete removal of CPP directives
2026-10-02 11:11:55 -06:00
David Richardson 5b852ca765 AppKit: first method-definition gates removed (Increment A)
- CPTextField, CPTokenField, CPTextView: the PLATFORM(DOM) gates
  around _inputElement (superclass and override) and _cumulativeOffset
  are removed; the methods now exist under both targets with runtime
  CPDOMAvailable guards returning nil (object methods) or a zero
  point (struct method) when no DOM is present
- contract change: under CommonJS these methods change from absent to
  present-and-inert; all callers are browser event paths never
  exercised by the theme blender or nib2cib
- zero preprocessor directives remain in these three files
- work-in-progress towards complete removal of CPP directives
2026-10-01 16:03:10 -06:00
David Richardson eda11e38ba Merge main: Tests/Manual revival, functional fixes
Merges 71 commits from main. Headline content: the Tests/Manual
integration test suite revived and reorganized after long disuse
(renames, new applications, updated cibs), restoring a large
integration validation surface. Functional fixes include replacing
unload-based termination with pagehide (back/forward cache
compatibility) and hardening CPTextField's input-element handling.

Conflict resolutions (local versions retained):

- AppKit/CPTextField.j: main's input-element logic carried, with this
  branch's preprocessor-removal sweep re-applied on top. Main's
  conditionals are re-expressed as runtime CPDOMAvailable guards; the
  _inputElement method-definition gate is retained.

- AppKit/Platform/CPPlatform.j: the DOM platform implementation stays
  inlined under the PLATFORM(DOM) gate. The split layout breaks the
  legacy build: the include fragment is compiled standalone by the
  source walk and cannot resolve its superclass. Main's pagehide
  termination fix is ported into the inlined section; the restored
  AppKit/Platform/DOM/CPPlatform.j fragment is deleted.

Verified: legacy build green through Foundation, AppKit and Tools;
Tests/Manual suite passing.
2026-10-01 14:44:51 -06:00
daboe01 66cda41bfc fixed: terminate on pagehide instead of unload instead of unload 2026-09-28 15:46:35 +02:00
daboe01 d72619660f new: replace unload listener with pagehide in CPPlatformPasteboard 2026-09-28 15:12:55 +02:00
daboe01 87fd68504c fixed: NotFoundError race when moving the shared input element 2026-09-28 14:47:04 +02:00
daboe01 55ee6de9cd fixed: copy could crash when first responder did not implement isRichText 2026-09-12 07:30:29 +02:00
David Richardson fa525e1cee 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
2026-09-01 08:34:36 -06:00
David Richardson 7d59762561 AppKit: CPLayoutManager, CPStringDrawing, CPMenu, CPCookie PLATFORM conditional removal
- 8 PLATFORM blocks resolved across four files: runtime CPDOMAvailable
  guards (3 wrapped, 2 early returns, 3 if/else preserving existing
  CommonJS branches)
- CPMenu: @global _CPDOMEventStop 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
2026-08-31 17:04:24 -06:00
David Richardson c2be4f87c5 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
2026-08-29 12:25:14 -06:00
David Richardson 4a5a25bb65 Fix undeclared _clientView instance variable in CPRulerView
Declare _clientView within the CPRulerView instance variable block.

This resolves a cold build compilation failure where the Objective-J parser flags assignments to the undeclared variable as illegal global variable creations.
2026-08-28 20:57:03 -06:00
David Richardson 3a140b07fe Fix child-node index arithmetic and expand CPTreeNode test coverage
CPTreeNode.j:
* Correct index calculations in insertObject:inChildNodesAtIndex: and replaceObjectInChildNodesAtIndex:withObject:. Nodes no longer misplace during same-parent or cross-parent moves.
 * Update _removeChildNode: to call removeObjectFromChildNodesAtIndex:. This ensures detaches notify childNodes observers on the original parent.

CPTreeNodeTest.j:
* Add test coverage for same-parent replacement, cycle rejection on replace-path, KVO during cross-parent moves, mutableChildNodes proxy operations, insertion bounds, non-recursive sorting, isLeaf, and descendantNodeAtIndexPath: edge cases.
* Disable same-parent childNodes KVO test. CPKeyValueObserving.j coalesces nested change notifications on the same key, which drops the inner removal event.
* Disable parentNode KVO test. No setParentNode: method exists to instrument.
* Add inline comments to both disabled tests explaining these mechanisms.
2026-08-28 13:35:27 -06:00
David Richardson 06ebbfb300 AppKit: CPDatePicker PLATFORM conditional removal
- 13 PLATFORM blocks resolved across the six date picker files;
  mechanical translation to runtime CPDOMAvailable guards
- the recurring _invokedByUserEvent YES/NO sandwich around
  _setDateValue translated as paired single-statement guards
- two stale "Workaround: added if PLATFORM(DOM)" comments updated
  to name the runtime guard
- work-in-progress towards complete removal of CPP directives
2026-08-27 23:17:15 -06:00
David Richardson 74039c799a Merge branch 'main' into CPTreeNode-improve-tests 2026-08-27 22:05:19 -06:00
David Richardson ee0c6fdf2d CPTreeNodeTest: fix child-move index arithmetic; correct a flawed test expectation
CPTreeNode: same-parent child moves no longer misplace the moved node — this corrects a defect in the class itself, properly exposed by the test.

Separately, the unit test's expectation for a root node's index path was itself wrong.
Corrected to match the class's existing, contract-correct behavior.

Test unit now runs cleanly.
2026-08-27 16:54:31 -06:00
daboe01 bf76c7d2c7 Merge pull request #3241 from daboe01/setBoundsSize-fix
Fixed: scale accumulation in scaleUnitSquareToSize: when setting bounds size
2026-08-27 22:37:45 +02:00
David Richardson 61e885db5f Merge branch 'main' into refactor-remove-nativehost-target 2026-08-27 13:28:50 -06:00
daboe01 bad82ee587 Merge pull request #3296 from daboe01/pageunloadfix2
fix: replace legacy `unload` event listener cleanup with `pagehide`
2026-08-27 19:40:57 +02:00
daboe01 16beb1a86c fix: replace legacy unload event listener cleanup with pagehide 2026-08-27 19:28:31 +02:00
David Richardson 690b79f113 Revert "Merge pull request #3260 from enquora/modernize-CALayer"
This reverts commit 8134b6dff7, reversing
changes made to 7083f7b268.
2026-08-27 11:20:41 -06:00
David Richardson 4d13785119 Revert "Merge pull request #3257 from enquora/modernize-CABackingStore"
This reverts commit 5bdac195fc, reversing
changes made to 8134b6dff7.
2026-08-27 11:20:30 -06:00
David Richardson 4f29b77d65 Revert "Merge pull request #3261 from enquora/modernize-CPPlatformpasteboard"
This reverts commit 10351c3d4a, reversing
changes made to 5bdac195fc.
2026-08-27 11:20:20 -06:00
David Richardson be08bed01e Revert "Merge pull request #3256 from enquora/modernize-cgcontext-canvas"
This reverts commit e107e2d804, reversing
changes made to 10351c3d4a.
2026-08-27 11:19:56 -06:00