Protect canonical AppKit and Foundation APIs with compatibility tests
Add regression and drop-in compatibility test suites to preserve canonical AppKit and Foundation public contracts and archived behavior, incorporating immediate fixes for defects exposed by the improved tests.
* DropInSnapshot.j:
- Describe a CPDate by its UTC instant instead of its class name.
- Record the string value of a control holding a date by the date's instant, since the browser formats it in the local time zone.
* DropInArchives.json: Update the CPDatePicker entry to the instant it archives.
* DropInArchiveTest.j: State that the test must pass in every time zone, and how to check it in UTC.
* CPTableView.j: Add forward @class declaration for CPTableView preceding _CPTableRowView.
* CPOutlineView.j:
- Import CPCompatibility.j and declare the global document reference.
- Replace partial DOM guards in -[CPDisclosureButton drawRect:] with an early return.
* AppController.j: Import through a progress panel driven by a CPProgress, with a Cancel button.
- Parse in chunks between run loop passes.
- Report the total import time, and rows past the browser's maximum element height.
* CSVParser.j: Parse incrementally, cutting each field with a single substring, and skip empty lines.
* Resources/Samples/.gitattributes: Preserve the sample files' bytes.
Partial implementation, gaps and impossibilities noted internally as TODO comments.
* CPProgress.j: Introduce CPProgress, modelled on NSProgress.
- Count units of work, with fraction completed, finished and indeterminate states.
- Compose progress trees through explicit children and the current progress object.
- Cancel, pause and resume, with handlers, propagating to children.
- Announce unit-count changes through key-value observing across the tree.
* CPError.j: Add CPUserCancelledError.
* CPItemProvider.j:
- Return a CPProgress from each load, counting bytes read for files and aborting the read on cancellation.
- Pass file contents to CPData as a binary string rather than a byte array.
- Implement -canLoadObjectOfClass: and -loadObjectOfClass:completionHandler:.
- Add the CPString (CPItemProvider) reading category.
* CPString+Encoding.j: Decode data held as a binary string through a Uint8Array, without building a byte array.
* Foundation.j: Import CPProgress.j.
* CPProgressTest.j: Add unit tests covering counts, children, the current progress object, cancellation, pausing, observation and user information.
* CPItemProviderTest.j: Add unit tests covering read progress, cancellation, completion and string loading.
* AppController.j: Import CSV files through CPOpenPanel into a table built from the header row.
- Run the panel with a message and an options accessory view, or with neither.
- Add options for a sheet, several files, a folder, and a delegate that rejects files.
- Decode each file with a chosen encoding, or with encoding detection.
- Assign columns to fixed fields in a sheet that shows sample values.
* CSVParser.j: Parse RFC 4180 records with any one-character delimiter, and detect the delimiter.
* main.j, Info.plist, index.html, index-debug.html, Jakefile: Add the application's entry points and build tasks.
* Resources/Samples: Add sample files in several encodings and delimiters, with files for the rejection paths.
* CPItemProvider.j: Introduce CPItemProvider, modelled on NSItemProvider.
- Register data representations keyed by MIME type, with wildcard matching.
- Load representations asynchronously, completing inside a run loop pass.
- Read browser File objects with FileReader.
- Document remaining NSItemProvider compatibility gaps via TODO comments.
* Foundation.j: Import CPItemProvider.j.
* CPPlatformFilePanel.j: Introduce the DOM platform class that runs the browser's file dialog through a hidden file input.
* CPOpenPanel.j: Replace the NativeHost implementation with a browser implementation.
- Implement -beginWithCompletionHandler: and -beginSheetModalForWindow:completionHandler:.
- Add allowed file types, message, prompt, and an accessory view behind an Options button.
- Validate chosen files through the window delegate's panel:validateURL:error:.
- Add -itemProviders, and -URLs holding file names.
- Raise an exception from -runModal.
- Document remaining NSOpenPanel compatibility gaps via TODO comments.
* CPTextView.j: Insert images through CPOpenPanel and CPItemProvider, for both -insertImage: and paste.
* CPItemProviderTest.j, CPOpenPanelTest.j: Add unit tests covering registration, loading, type matching, panel results, and cancelled runs.
Brings format string parsing into line with canonical NSPredicate.
* _CPPredicate: Accept a one-argument selector as a comparison operator.
* CPPredicateTest: Verify parsing and evaluation of custom selector comparisons.
Accommodate Build directories created by capp-build at framework level.
These would otherwise interfere with the Node compiler and orchestration's operation.
* AppKit/Jakefile: Add Build to the clobber target.
* Foundation/Jakefile: Add Build to the clobber target.
Ensure time zone results are verified identically on any date and host,
including zones in jurisdictions that have abolished seasonal offset changes,
by asserting against fixed dates in January and July. Abbreviations are
computed for the current date, as in Cocoa.
* CPTimeZone:
* Compute abbreviation for the current date.
* Use the computed abbreviation in description.
* CPTimeZoneTest:
* Assert offsets, abbreviations and daylight saving state at fixed dates.
* Replace host-dependent and season-dependent assertions.
Regression tests and their supporting framework fixes are incorporated.
Remaining test failures identify Aristo3 defects.
Conflict resolutions:
* CPButtonBar: Retain Aristo3 decoding and observe the hidden state of decoded buttons.
* CPPopUpButton: Retain the Aristo3 bezel style and clear the inherited button value.
Ensure objects held and shared by views are correct by verifying they retain
the properties applications read after archiving.
* CPAppearance: Add the name accessor.
* CPShadow:
* Add CPCoding.
* Add init with the default shadow values.
* CPObjectArchivingTest: Verifies round trips of Foundation values, AppKit
values, and objects that belong to views.
* DropInArchiveTest: State the reasons the MainMenu cibs are not included.
Ensure decoded views are correct by verifying they retain their connections and
respond as before archiving.
A decoded table no longer raises, and decoded button bars, tab views, text
fields and outlines retain their observers, selection, delegates and data source
methods.
* CPButtonBar: Observe the hidden state of decoded buttons.
* CPOutlineView: Decode the data source and delegate through their setters.
* CPTableView: Set the data source and delegate after _init during decoding.
* CPTabView: Select the archived tab view item during decoding, before the
delegate is set.
* CPTextField: Archive the delegate.
* CPViewDecodedBehaviorTest: Verifies connections, the view hierarchy, and the
behaviour of objects each class creates or observes after decoding.
Protects runtime theme changes by verifying that views resolve the correct
values, and request layout and display, when a theme, state, theme class or
per-view value changes.
* CPViewThemeChangeTest: Verifies resolution order, theme and default theme
changes, propagation to nested views, state and theme class selection, and
preservation of per-view values through theme changes and archiving.
Protects themed drawing by verifying that the states selecting theme values
remain correct as views enter and leave windows and as window status changes.
* CPViewThemeStateTest: Verifies the key window, first responder and appearance
states across nested views, including views added, removed and moved between
windows; the key and main states of the window view; and the order of window
move notifications.
Protects the selection, editing and drag and drop contracts of tables and
outlines by verifying the events, delegate calls and data source calls that
applications depend on. A drop retargeted between the children of an item is
delivered to that item.
* CPOutlineView: Set the retargeted drop operation in
setDropItem:dropChildIndex:.
* CPTableViewInteractionTest: Verify selection by mouse and keyboard, editing,
drag initiation and drop handling, including refusal and retargeting by the
delegate and data source.
* CPOutlineViewInteractionTest: Verify dragged items, proposed parents and child
indexes, drop retargeting, and expansion and its cancellation during a hover.
Keyed archiving preserves view hierarchies created in code. Decoded views
retain their content, subviews and state, and each view class is verified
against its own description before archiving.
* CPAccordionView: Add CPCoding to CPAccordionView and CPAccordionViewItem.
* CPBox:
* Encode the content, title and box views unconditionally.
* Clear the superviews of the box and title views during decoding.
* CPButton: Initialize the value to CPOffState.
* CPMapTable: Add CPCoding.
* CPPopUpButton: Clear the inherited button value.
* CPSearchField: Update the cancel button when the object value changes.
* CPSplitView: Return nil from dividerColor when the theme defines no divider
image.
* CPStepper: Discard the decoded buttons before recreating them.
* CPTabView:
* Encode the current tab view items.
* Exclude the tabs from the encoded subviews.
* CPTokenField:
* Discard the decoded scroll view before recreating it.
* Add the decoded tokens to the new document view.
* CPVisualEffectView: Resolve the backdrop filter property only when a DOM is
available.
* CPBoxTest: Verify preservation of the content view, hierarchy and title, and
decoding of an untitled box without warnings.
* CPButtonTest: Verify the initial value of a button.
* CPMapTableTest: Verify preservation of entries through archiving.
* DropInArchiveFixtures: Add populated view fixtures, tree comparison, and
round trip and saved archive helpers.
* DropInArchiveGenerator: Save cib descriptions and view archives, and write no
archive data if any view fails its round trip.
* DropInArchiveTest: Verify new archives, saved archives and reference cibs, and
treat decoding warnings as failures.
* DropInSnapshot:
* Describe the view hierarchy through private views, with state and content.
* Add DropInWithFixedScrollerStyle.
* DropInArchives, DropInCibs: Add saved view archives, cib descriptions and
reference cibs.
Protects the add, remove and action controls placed below table and outline views by verifying that a button bar supplies usable buttons independently of the active theme.
* CPButtonBarTest: Verifies the standard size of the plus, minus and
action popup buttons; button placement within the bar, order and
shared borders; closure of the gap left by a hidden button; right
edge alignment of right buttons; and acceptance of application
buttons.
The drop-in baseline preserves framework backward-compatibility contracts by recording expected defaults and states.
Explicit value comparisons are enforced and omitted snapshot entries are reported to detect unintended default modifications.
* DropInSnapshot:
* Record booleans, numbers and strings by value.
* Serialize plain objects with sorted keys, and record functions
and circular references without raising an exception.
* Extract DropInViewState, and isolate each getter so that an
exception leaves the remaining state intact.
* Add throwIfError, so that a generator does not save an exception
as expected state.
* Add a skipped list that names each class or window style left out
of a snapshot.
* Add DropInCibTree, with view, menu and object descriptions and a
cib owner, to describe the objects a cib produces.
* DropInBaselineGenerator: Pass throwIfError and print each skipped
entry.
* DropInBaseline: Regenerate with recorded values and sorted keys.
Protects custom row rendering by verifying that content remains synchronized and current through standard operational cycles.
* CPOutlineViewRowContentTest: Verifies that selection changes, scrolling, column resizing and hiding, item expansion and collapse, data reloads, and grid or row style modifications trigger complete redraws for visible rows; ensures row content remains unoccluded and idle tables do not execute redundant redrawing.
Adds targeted test infrastructure and validation checks to protect table drawing hooks and drop-in framework contracts against unintended modifications.
* CPTableViewDrawingTest: Verifies subclass invocation order for drawing steps and ensures application-specified background colors persist across theme-state changes.
* DropInCompatibilityTest: Validates default theme names, window control configurations, pop-up button bezel styles, and table class defaults.
* DropInSnapshot: Encapsulates theme attribute defaults, public API surface, default view construction, and window controls as structured data.
* DropInBaselineGenerator: Provides tooling to capture current framework state as a baseline.
* DropInBaselineTest: Compares framework artifacts against the established baseline, permitting additions while reporting modifications and removals.
* DropInBaseline.json: Introduces the initial compatibility baseline artifact.
Merge TextEditor: zoom and CPScrollView magnification
* AppKit: Add NSScrollView's magnification API to CPScrollView. A view
whose scale returns to 1.0 now drops its CSS scale. Scroll views from
cibs compiled by nib2cib can now zoom.
* TextEditor: View > Zoom Level, Zoom In, Zoom Out and Actual Size, from
25% to 200%, as a test of view scaling for the Aristo3 merge. The work
list records the scaling defects found as open.
CPScrollView previously lacked magnification support, preventing document
zooming and leaving view scaling infrastructure without practical test coverage.
Additionally, views resetting to a 1.0 scale retained stale CSS transform properties,
and legacy cibs compiled via nib2cib omitted explicit magnification limits,
breaking zoom functionality in older archives.
* AppKit/CPScrollView.j:
- Implement magnification methods and properties (`magnification`, `setMagnification:`, `setMagnification:centeredAtPoint:`, `allowsMagnification`, `minMagnification`, and `maxMagnification`) modelled on NSScrollView, with keyed archiving.
- Scale clip view bounds and synchronize resizing document view widths.
- Define standard Cocoa default limits (0.25 and 4.0) as named constants.
- Implement robust decoding validation to assign default limits to unset or invalid archive values and reject non-positive magnification inputs, ensuring full compatibility with legacy cibs.
* AppKit/CPView.j:
- Remove stale CSS scale styling when a view's scale factor returns to 1.0.
* Tests/AppKit/CPScrollViewTest.j:
- Add comprehensive unit tests covering magnification scaling, archiving, and fallback decoding for unconfigured limits.
* Tests/Manual/TextEditor/DocumentWindowController.j:
- Implement zoom action handlers (`zoomToLevel:`, `zoomToActualSize:`, `zoomIn:`, and `zoomOut:`) driven by menu item tag values.
* Tests/Manual/TextEditor/Resources/MainMenu.xib, MainMenu.cib:
- Add View menu options for Actual Size, Zoom In, Zoom Out, and explicit Zoom Levels (25% to 200%).
* Tests/Manual/TextEditor/WORKLIST.md:
- Mark zoom functionality as tested; log discovered scaling edge cases as open items.
CPScrollView and TextEditor now support robust document magnification from 25% to 200%, validating core view scaling mechanics.
Merge TextEditor fixes: attachments wider than the text
* AppKit: An attachment wider than the text container keeps its line's
height and baseline. A table in a narrowed window was drawn above its
line, over the preceding text.
When text attachments (such as tables or wide images) exceeded container width,
`CPTypesetter` correctly forced a line break following the attachment but
erroneously reverted the line's height and baseline to pre-attachment metrics.
Consequently, oversized attachments rendered on the baseline of preceding text,
causing them to overlap and obscure content above them in narrowed viewports.
* AppKit/CPTextView/CPTypesetter.j:
- Update line layout logic to incorporate attachment dimensions into line height
and baseline calculations when line breaks encompass overflowing attachments.
* Tests/Manual/TextEditor/WORKLIST.md:
- Mark wide/overflowing table layout tests as completed.
Attachments and tables wider than the text container now correctly occupy their own distinct lines without overlapping preceding content.
Merge TextEditor fixes: attachments move with their lines
* AppKit: When unchanged lines below an edit are kept and moved, their
attachment views and text spans now move on the screen at once. A
table pasted together with images was shown at the wrong position
until a scroll or resize.
When CPLayoutManager retained and repositioned unchanged line fragments
below an edit, `_CPLineFragment` incorrectly modified attachment view frames
directly and assigned an unused property to text spans. Consequently, moved
views remained visually stationary on screen because subsequent layout-pass
`setFrameOrigin:` calls detected matching origins, causing asynchronously loaded
elements (such as pasted tables combined with images) to render at incorrect
offsets until forced by a scroll or resize event.
* AppKit/CPTextView/CPLayoutManager.j:
- Update attachment view relocation to correctly trigger `setFrameOrigin:`.
- Shift rendered text spans via their style coordinate top properties.
* Tests/Manual/TextEditor/WORKLIST.md:
- Mark composite paste workflows (text containing both images and tables) as tested.
Attachment views and text spans now immediately track their corresponding line fragments when text is inserted or modified above them.
Merge TextEditor fixes: lists and Unicode in RTF, images in pasted text
* AppKit: The RTF producer and parser carry text lists, in Cocoa's form
and readable from Word's, Unicode characters, and the first line indent
relative to the left indent.
* AppKit: Copy and paste within an application keeps images, tables and
lists, through the internal archive. Tables can now be archived.
* TextEditor: The work list records that browsers deliver only plain
text to native applications, so rich text for them needs HTML.
The RTF producer and parser lacked support for text lists, failed to encode
non-ASCII characters properly (\uN), and treated first-line indents (\fi) as
absolute values rather than offsets relative to left indents (\li).
Additionally, paste operations ingested application-generated RTF rather than
the native internal archive, causing image attachments and tables to be stripped
during copy-paste workflows within the application.
* AppKit/CPTextView/_CPRTFProducer.j:
- Implement RTF serialization for text lists using list tables, override tables,
\levelmarker, \levelprepend, \lsN\ilvlK tags, and \listtext marker blocks.
- Encode non-ASCII characters via \uc0\uN syntax and compute \fi indents
relative to \li.
- Omit image attachment characters from text runs and adjust run starting indices
to accommodate list markers.
* AppKit/CPTextView/_CPRTFParser.j:
- Implement pre-pass parsing for list and override tables.
- Assign shared text lists to items using \ls and \ilvl, extracting marker formats
from \levelmarker or standard number/level definitions.
- Parse \uN sequences (skipping fallback characters) and evaluate relative \fi offsets.
* AppKit/CPTextView/CPTextView.j:
- Configure paste handling to prioritize internal archives when clipboard RTF
originates from the application, ensuring image attachments and tables survive internal copy-paste.
* AppKit/CPTextView/_CPTableTextAttachment.j:
- Implement keyed archiving and decoding for table headers, rows, widths,
and configuration settings, reconstructing cell instances upon unarchiving.
* Tests/AppKit/CPRTFTest.j:
- Add comprehensive unit tests covering Unicode encoding, relative first-line indents,
TextEdit and Word list interoperability, and nested list round-trip fidelity.
* Tests/AppKit/CPTextAttachmentTest.j:
- Add test coverage for table attachment archiving.
* Tests/Manual/TextEditor/WORKLIST.md:
- Mark intra-application copy and paste testing as completed.
- Log external rich text exchange limitations as open items.
Intra-application copy and paste now fully preserves images, tables, and lists,
while RTF serialization supports Unicode and structured hierarchical lists.
Merge TextEditor: table demonstration
* TextEditor: Edit > Insert Table Example inserts a sample document with
a table, built from Markdown by CPMarkdownParser. It demonstrates the
existing table support in a real document. The work list records the
remaining table checks and known gaps.
TextEditor lacked a mechanism to showcase or test CPMarkdownParser's
table rendering capabilities within a live document context.
* Tests/Manual/TextEditor/TableExample.j:
- Add a Markdown sample containing a heading, a formatted table with a header row and styled cells, and accompanying text, converted to an attributed string via CPMarkdownParser.
* Tests/Manual/TextEditor/DocumentWindowController.j:
- Implement insertTableExample: action to insert the table sample at the current selection.
* Tests/Manual/TextEditor/Resources/MainMenu.xib, MainMenu.cib:
- Add Edit > Insert Table Example menu item.
* Tests/Manual/TextEditor/WORKLIST.md:
- Record table rendering as tested; log interactive validation and known table limitations as open items.
TextEditor now provides a live demonstration and testing baseline for rich text table layouts.
AppKit: Apply font changes without a selection to CPTextView typing attributes
When no text was selected, CPTextView's changeFont: implementation
erroneously extracted the font to convert from the text storage at the
insertion point rather than from current typing attributes. Consequently,
repeated adjustments like Bigger or Smaller failed to accumulate, blank
document font sizing remained locked after one step, and output arguments
risked overwriting selection state.
* AppKit/CPTextView/CPTextView.j:
- Update changeFont: to derive and convert fonts directly from typing
attributes when no selection is active, and post corresponding typing
attribute update notifications.
- Eliminate selection range output arguments that could inadvertently
modify active selection bounds.
* Tests/AppKit/CPTextViewTest.j:
- Add unit tests verifying that repeated font modifications accumulate correctly
at zero-length insertion points.
* Tests/Manual/TextEditor/WORKLIST.md:
- Mark Bigger and Smaller actions without a selection as tested.
Bigger and Smaller menu commands now correctly compound font size adjustments for subsequent typed text, matching Cocoa behavior.