feat(libSceNKWebKit): implement WebCore::DisplayList state items #22555

Merged
RiverWhy merged 3 commits from upstream-pr/22555 into main 2026-11-18 13:30:15 +00:00
RiverWhy commented 2026-11-17 20:38:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by RiverWhy on 2026-11-17T20:38:44Z.


What

Implements the constructors and destructors of WebCore::DisplayList::Item, DrawingItem and 15 state items: 83 3.20 exports that all throw on main today.

  • Item, DrawingItem (8): C2(ItemType), D0/D1/D2.
  • 15 items × C1/C2/D0/D1/D2 (75): Save, Restore, Translate, Rotate, Scale, SetCTM, ConcatenateCTM, SetLineCap, SetLineDash, SetLineJoin, SetMiterLimit, ClearShadow, ApplyDeviceScaleFactor, Clip, ClipOut.

This is the base for the drawing items and the color and image items in the two PRs that follow.

Source: DisplayListItems.cpp and DisplayList.h at c55364d53f97 (September 2020). The exports are the pre-2021 design, in which items are RefCounted and have virtual destructors, and this is the first revision whose PutImageData constructors take the destFormat the exported ones have. ItemType values count DrawNativeImage (USE(CAIRO)), which this module exports.

ABI, measured by compiling that source with -fdump-lang-class:

  • Item: 16 bytes (vtable, reference count 1 at 8, type at 12). DrawingItem adds its Optional<FloatRect> extent at 16 (flag first, rect at 20). Derived fields start at 16 for items and at 36 for drawing items, in the base's tail padding.
  • The vtable is [D1, D0, apply, isDrawingItem], plus [localBounds, globalBounds] for drawing items. Constructors install host vtables of that shape; after destruction the object holds Item's vtable, as the base destructors leave it.
  • The DrawingItem constructor writes only what the 2020 Optional default constructor writes: the flag and the first storage byte.

apply needs a GraphicsContext, which NKWebKit doesn't have. One shared slot throws NotImplemented_nid_no_patch, naming the item from its type. That slot is the "+1 declared function" in the progress report. The "+122 implemented" also counts the local vtable callbacks; the PR implements 83 exports.

Other details:

  • SetLineDash copies its DashArray with WTF::fastMalloc and keeps the source's capacity. At this revision, Vector's copy constructor did Base(other.capacity(), other.size()); 2021 switched to the size.
  • Deleting destructors free the item with the guest operator delete.
  • A null object or argument, or a vector whose size exceeds its capacity, throws before anything is written.

Debt: a fragment, docs/dev/debt/changes/feat-nkwebkit-display-list-state-items.md, adds the entry. These are 3.20 exports with no inventory rows.

Overlap: pr_overlap.py finds no open PR with these exports. It could not compare #21957 and #21958, which conflict with main; I checked their diffs by hand and they have no DisplayList code. The conflicts it reports are lines next to each other only: the shared last include line of libSceNKWebKit.hpp (#18797, #18805, #20327, #21422, #21432, #21979, #22449–#22456, #22480–#22482), and stubs next to these ones that #18377, #19636, #20296, #20326, #20327, #22450 and #22480–#22482 also remove.

Tested

Linux Mint 22.3. A shared driver constructs random items of every kind from random floats (zero, small, fractional, large), transforms, dash arrays with spare capacity, and enum values. It installs them over a 0xCD-filled buffer and hashes every byte outside the pointers, the vector contents and capacity, isDrawingItem, the bounds, and the reference counts after destruction. The hash is compared with the one from the real September 2020 item classes, constructors and FloatRect code, compiled against WTF with that revision's Vector copy constructor and running the same driver.

  • New nkwebkit_displayliststateitems test: 16 sequences of 500 items match. As a one-off, 300 sequences of 5,000 also matched.
  • Hand checks:
    • the base constructors and their bytes;
    • the vtable left after destruction;
    • deleting destructors through the export and through the vtable, with the guest allocation count back to where it started;
    • apply throwing for every kind;
    • dash copy capacity and invalid vectors;
    • null refusals.
  • Negative control: copying the dash array with its size as capacity fails the transcript check.
  • All 120 NKWebKit tests pass, including forwarding and base.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5364601415 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22555). Originally posted by [RiverWhy](https://github.com/RiverWhy) on 2026-11-17T20:38:44Z. --- ### What Implements the constructors and destructors of `WebCore::DisplayList::Item`, `DrawingItem` and 15 state items: 83 3.20 exports that all throw on `main` today. - **Item, DrawingItem (8):** `C2(ItemType)`, `D0`/`D1`/`D2`. - **15 items × `C1`/`C2`/`D0`/`D1`/`D2` (75):** `Save`, `Restore`, `Translate`, `Rotate`, `Scale`, `SetCTM`, `ConcatenateCTM`, `SetLineCap`, `SetLineDash`, `SetLineJoin`, `SetMiterLimit`, `ClearShadow`, `ApplyDeviceScaleFactor`, `Clip`, `ClipOut`. This is the base for the drawing items and the color and image items in the two PRs that follow. Source: [DisplayListItems.cpp](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp#L53-L460) and [DisplayList.h](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WebCore/platform/graphics/displaylists/DisplayList.h#L42-L160) at `c55364d53f97` (September 2020). The exports are the pre-2021 design, in which items are `RefCounted` and have virtual destructors, and this is the first revision whose `PutImageData` constructors take the `destFormat` the exported ones have. `ItemType` values count `DrawNativeImage` (`USE(CAIRO)`), which this module exports. ABI, measured by compiling that source with `-fdump-lang-class`: - `Item`: 16 bytes (vtable, reference count 1 at 8, type at 12). `DrawingItem` adds its `Optional<FloatRect>` extent at 16 (flag first, rect at 20). Derived fields start at 16 for items and at 36 for drawing items, in the base's tail padding. - The vtable is `[D1, D0, apply, isDrawingItem]`, plus `[localBounds, globalBounds]` for drawing items. Constructors install host vtables of that shape; after destruction the object holds `Item`'s vtable, as the base destructors leave it. - The `DrawingItem` constructor writes only what the 2020 `Optional` default constructor writes: the flag and the first storage byte. `apply` needs a `GraphicsContext`, which NKWebKit doesn't have. One shared slot throws `NotImplemented_nid_no_patch`, naming the item from its type. That slot is the "+1 declared function" in the progress report. The "+122 implemented" also counts the local vtable callbacks; the PR implements 83 exports. Other details: - `SetLineDash` copies its `DashArray` with `WTF::fastMalloc` and keeps the source's capacity. At this revision, `Vector`'s copy constructor did `Base(other.capacity(), other.size())`; 2021 switched to the size. - Deleting destructors free the item with the guest `operator delete`. - A null object or argument, or a vector whose size exceeds its capacity, throws before anything is written. Debt: a fragment, `docs/dev/debt/changes/feat-nkwebkit-display-list-state-items.md`, adds the entry. These are 3.20 exports with no inventory rows. Overlap: `pr_overlap.py` finds no open PR with these exports. It could not compare #21957 and #21958, which conflict with `main`; I checked their diffs by hand and they have no DisplayList code. The conflicts it reports are lines next to each other only: the shared last include line of `libSceNKWebKit.hpp` (#18797, #18805, #20327, #21422, #21432, #21979, #22449–#22456, #22480–#22482), and stubs next to these ones that #18377, #19636, #20296, #20326, #20327, #22450 and #22480–#22482 also remove. ### Tested Linux Mint 22.3. A shared driver constructs random items of every kind from random floats (zero, small, fractional, large), transforms, dash arrays with spare capacity, and enum values. It installs them over a `0xCD`-filled buffer and hashes every byte outside the pointers, the vector contents and capacity, `isDrawingItem`, the bounds, and the reference counts after destruction. The hash is compared with the one from the real September 2020 item classes, constructors and `FloatRect` code, compiled against WTF with that revision's `Vector` copy constructor and running the same driver. - New `nkwebkit_displayliststateitems` test: 16 sequences of 500 items match. As a one-off, 300 sequences of 5,000 also matched. - Hand checks: - the base constructors and their bytes; - the vtable left after destruction; - deleting destructors through the export and through the vtable, with the guest allocation count back to where it started; - `apply` throwing for every kind; - dash copy capacity and invalid vectors; - null refusals. - Negative control: copying the dash array with its size as capacity fails the transcript check. - All 120 NKWebKit tests pass, including `forwarding` and `base`. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-17 20:42:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-17T20:42:45Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 41237a0c94:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_displayliststateitems_tests built cleanly.
  • CTest (nkwebkit_displayliststateitems):
    1/1 Test #4443: nkwebkit_displayliststateitems ...   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/Api.hpp, core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libSceNKWebKit/src/DisplayListItem.cpp, core/libs/prx/libSceNKWebKit/src/DisplayListStateItems.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified all 83 WebCore::DisplayList Item, DrawingItem, and state item constructor and destructor exports in core/libs/prx/libSceNKWebKit/include/DisplayListItemExports.hpp and core/libs/prx/libSceNKWebKit/src/DisplayListItem.cpp against WebKit c55364d53f97 ABI layouts and virtual method conventions.
    • Confirmed Checked() pointer safety checks and null-handling logic across all constructor and destructor entry points.
    • Audited struct layouts, offsets, and tail-padding field alignments (FloatRect, FloatSize, AffineTransform, Vector) against standard Itanium C++ ABI specifications.
    • Checked memory deallocation routines in D0 deleting destructors to ensure operator delete is called properly with matching sizes/types.
    • Verified AGENTS.md compliance regarding comments, conventions gate passes, debt fragments, and conventional commits.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5946289481 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22555#pullrequestreview-5946289481). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-17T20:42:45Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `41237a0c94`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_displayliststateitems_tests` built cleanly. - **CTest** (`nkwebkit_displayliststateitems`): ``` 1/1 Test #4443: nkwebkit_displayliststateitems ... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/Api.hpp`, `core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp`, `core/libs/prx/libSceNKWebKit/src/DisplayListItem.cpp`, `core/libs/prx/libSceNKWebKit/src/DisplayListStateItems.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified all 83 WebCore::DisplayList Item, DrawingItem, and state item constructor and destructor exports in core/libs/prx/libSceNKWebKit/include/DisplayListItemExports.hpp and core/libs/prx/libSceNKWebKit/src/DisplayListItem.cpp against WebKit c55364d53f97 ABI layouts and virtual method conventions. - Confirmed Checked() pointer safety checks and null-handling logic across all constructor and destructor entry points. - Audited struct layouts, offsets, and tail-padding field alignments (FloatRect, FloatSize, AffineTransform, Vector<double>) against standard Itanium C++ ABI specifications. - Checked memory deallocation routines in D0 deleting destructors to ensure operator delete is called properly with matching sizes/types. - Verified AGENTS.md compliance regarding comments, conventions gate passes, debt fragments, and conventional commits. Looks Good To Me
PrivacyOnion commented 2026-11-17 23:53:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-17T23:53:43Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 53ad6f3c80:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_displayliststateitems_tests built cleanly.
  • CTest (nkwebkit_displayliststateitems):
    1/1 Test #4472: nkwebkit_displayliststateitems ...   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/Api.hpp, core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libSceNKWebKit/src/DisplayListItem.cpp, core/libs/prx/libSceNKWebKit/src/DisplayListStateItems.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified ABI layouts, field offsets, and static_asserts in core/libs/prx/libSceNKWebKit/include/DisplayListItemExports.hpp against WebKit c55364d53f97 specifications
    • Audited all 83 WebCore::DisplayList Item, DrawingItem, and state item constructor and destructor export signatures and mangled symbol definitions
    • Checked memory safety, pointer handling, and Checked() validations across DisplayListItem.cpp and DisplayListStateItems.cpp entry points
    • Confirmed Itanium C++ ABI virtual destructor semantics (D0 deleting destructor calls operator delete, D1 complete destructor, D2 base destructor)
    • Validated strict AGENTS.md compliance regarding no forbidden comments, technical debt documentation, and conventional commit structure

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5948620132 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22555#pullrequestreview-5948620132). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-17T23:53:43Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `53ad6f3c80`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_displayliststateitems_tests` built cleanly. - **CTest** (`nkwebkit_displayliststateitems`): ``` 1/1 Test #4472: nkwebkit_displayliststateitems ... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/Api.hpp`, `core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp`, `core/libs/prx/libSceNKWebKit/src/DisplayListItem.cpp`, `core/libs/prx/libSceNKWebKit/src/DisplayListStateItems.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified ABI layouts, field offsets, and static_asserts in core/libs/prx/libSceNKWebKit/include/DisplayListItemExports.hpp against WebKit c55364d53f97 specifications - Audited all 83 WebCore::DisplayList Item, DrawingItem, and state item constructor and destructor export signatures and mangled symbol definitions - Checked memory safety, pointer handling, and Checked() validations across DisplayListItem.cpp and DisplayListStateItems.cpp entry points - Confirmed Itanium C++ ABI virtual destructor semantics (D0 deleting destructor calls operator delete, D1 complete destructor, D2 base destructor) - Validated strict AGENTS.md compliance regarding no forbidden comments, technical debt documentation, and conventional commit structure Looks Good To Me
MarcZX10 commented 2026-11-17 23:59:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T23:59:25Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the behavior claims in the description are supported by the source and prepared test report.

What I ran

Reviewed head 53ad6f3c8028174c655c84da069fb581b7ed7aad. No commands or tests were run. The author reports the Linux Mint 22.3 comparison test and all 120 NKWebKit tests passed; these results were not independently verified.

Results

Check Result Note
Source review passed Changed implementation and ABI declarations read
Automated checks not run Results in the description are author reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

Export.cpp was not read in full because it was excluded as too large; only its opening lines were checked. tests/DisplayListStateItems.cpp was read only through line 120 of 590. include/LegacyExports.hpp was listed but not read. The remainder of the diff, test source, and all reported test runs were not independently verified. Files read: description.md, commits.md, manifest.json, diff.patch lines 1–599, include/Api.hpp, include/DisplayListItemExports.hpp, libSceNKWebKit.hpp, src/DisplayListItem.cpp, src/DisplayListItemAbi.hpp, src/DisplayListStateItems.cpp, and tests/DisplayListStateItems.cpp lines 1–120. Excluded changed file: Export.cpp (too large for the review folder).

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5948673557 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22555#pullrequestreview-5948673557). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-17T23:59:25Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the behavior claims in the description are supported by the source and prepared test report. ## What I ran Reviewed head `53ad6f3c8028174c655c84da069fb581b7ed7aad`. No commands or tests were run. The author reports the Linux Mint 22.3 comparison test and all 120 NKWebKit tests passed; these results were not independently verified. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Changed implementation and ABI declarations read | | Automated checks | not run | Results in the description are author reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified `Export.cpp` was not read in full because it was excluded as too large; only its opening lines were checked. `tests/DisplayListStateItems.cpp` was read only through line 120 of 590. `include/LegacyExports.hpp` was listed but not read. The remainder of the diff, test source, and all reported test runs were not independently verified. Files read: `description.md`, `commits.md`, `manifest.json`, `diff.patch` lines 1–599, `include/Api.hpp`, `include/DisplayListItemExports.hpp`, `libSceNKWebKit.hpp`, `src/DisplayListItem.cpp`, `src/DisplayListItemAbi.hpp`, `src/DisplayListStateItems.cpp`, and `tests/DisplayListStateItems.cpp` lines 1–120. Excluded changed file: `Export.cpp` (too large for the review folder). ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-18 13:14:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T13:14:08Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this review; the available source supports the reported ABI layout and constructor/destructor approach, but the full review is incomplete.

What I ran

Read the prepared description, commit list, manifest, diff excerpt, ABI header, implementation excerpt, export declarations, and test excerpt at head 0692cab1db8b8fcd3654933e236e1b97464c6093. No commands or tests were run.

Results

Check Result Note
Source inspection not run Partial review only
Tests not run Author reports passing tests

Findings

Blocking

None verified in the inspected portions.

Non-blocking

None.

Not verified

The full changed implementation, the remaining test code, Export.cpp (excluded because it is too large), and behavior on the reported test environment were not verified. Files read: description.md, commits.md, manifest.json, diff.patch excerpt, DisplayListItemAbi.hpp, DisplayListItem.cpp excerpt, DisplayListStateItems.cpp excerpt, and DisplayListItemExports.hpp excerpt. Export.cpp was excluded from the review folder and not read.

To get this to a good state

Nothing is required. Optional: complete inspection of the unreviewed changed code before making a formal approval decision.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5957284502 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22555#pullrequestreview-5957284502). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-18T13:14:08Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this review; the available source supports the reported ABI layout and constructor/destructor approach, but the full review is incomplete. ## What I ran Read the prepared description, commit list, manifest, diff excerpt, ABI header, implementation excerpt, export declarations, and test excerpt at head `0692cab1db8b8fcd3654933e236e1b97464c6093`. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Source inspection | not run | Partial review only | | Tests | not run | Author reports passing tests | ## Findings ### Blocking None verified in the inspected portions. ### Non-blocking None. ## Not verified The full changed implementation, the remaining test code, `Export.cpp` (excluded because it is too large), and behavior on the reported test environment were not verified. Files read: `description.md`, `commits.md`, `manifest.json`, `diff.patch` excerpt, `DisplayListItemAbi.hpp`, `DisplayListItem.cpp` excerpt, `DisplayListStateItems.cpp` excerpt, and `DisplayListItemExports.hpp` excerpt. `Export.cpp` was excluded from the review folder and not read. ## To get this to a good state Nothing is required. Optional: complete inspection of the unreviewed changed code before making a formal approval decision.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!22555
No description provided.