feat(libSceNKWebKit): implement the WebCore::DragImage special members #22977

Merged
FinleyLaempe merged 2 commits from upstream-pr/22977 into main 2026-11-20 07:13:00 +00:00
FinleyLaempe commented 2026-11-18 15:28:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by FinleyLaempe on 2026-11-18T15:28:19Z.


What

Implements the WebCore::DragImage special members in libSceNKWebKit — WebCore::DragImage::DragImage(), WebCore::DragImage::DragImage(WebCore::DragImage&&), WebCore::DragImage::operator=(WebCore::DragImage&&) and WebCore::DragImage::~DragImage(), each in its complete- and base-object variant — replacing the seven parameterless int stubs in Export.cpp.

  • Special members follow the pinned DragImage.cpp: default construction leaves the surface ref null, move construction steals it and move-constructs the optional members, move assignment releases the target's previous surface and steals the source's.
  • Upstream's deleteDragImage takes its DragImageRef (RefPtr<cairo_surface_t>) by value and is a no-op, so destruction amounts to one dereference of the surface; implemented through libcairo's cairo_surface_destroy, reached from this library through a new CairoSurfaceDestroy_nid_no_patch helper in libcairo/Surface.cpp because another library cannot import the NID-patched cairo_surface_destroy export on Windows.
  • Guest layout is the Cairo DragImage.h variant: a 200-byte DragImage holding WtfAbi::RefPtr<CairoSurface> m_dragImageRef, Optional<TextIndicatorData> m_indicatorData and Optional<Path> m_visiblePath, with engagement stored after the payload and the 64-byte Path tagged union carrying its index after the union. Sizes and offsets are pinned by static_asserts in src/DragImageAbi.hpp.
  • Reuses WtfAbi::Vector from the existing src/WtfVector.hpp for TextIndicatorData::textRectsInBoundingRectCoordinates (freed through the existing _ZN3WTF8fastFreeEPv) and the WebCore::Color and geometry types from src/WebCoreTypes.hpp; the new src/WtfRefPtr.hpp adds the 8-byte WtfAbi::RefPtr.
  • Color moves steal the packed m_colorAndFlags bits, empty the source and no-op on packed equality, following Color.cpp.
  • The destructor and move assignment call NotImplemented_nid_no_patch when the engaged TextIndicatorData holds a non-null Image (contentImage, contentImageWithHighlight or contentImageWithoutSelection) or an out-of-line estimatedBackgroundColor (bit 51), or the engaged Path holds a PathImpl, because those destructors are unmodeled.
  • Null objects throw std::invalid_argument where WebKit would fault: null this for every entry point, null source for move construction and move assignment; self-assignment returns early.
  • Export.cpp loses the seven stub definitions and include/InventoryExports.hpp their int declarations; they move to the new include/DragImageExports.hpp with real signatures (void/DragImage&, self and source pointers). libSceNKWebKit.hpp includes the new header, and CMake links libcairo plus the new dragimage test.
  • New tests/DragImage.cpp covers construct, move, assign and destruct round-trips over poisoned storage, surface release tracking via cairo user data, the throw paths and the color/optional/Path move edge cases.
  • Debt: the fragment docs/dev/debt/changes/feat-nkwebkit-drag-image.md adds a Functional entry that records the guest layout as derived from the Cairo variant and the console ABI as not compared with a console module; the seven _ZN7WebCore9DragImage* rows are removed from the NID inventory.

Tested

Arch Linux x86-64, GCC 16.2.1, Release build with -DBUILD_TESTING=ON: the new nkwebkit_dragimage test and every other nkwebkit_* test, 143 of 143 passed. python3 tools/check_conventions.py --base upstream/main passes. Not tested on a console or on Windows.

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:5378874768 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22977). Originally posted by [FinleyLaempe](https://github.com/FinleyLaempe) on 2026-11-18T15:28:19Z. --- ### What Implements the `WebCore::DragImage` special members in libSceNKWebKit — `WebCore::DragImage::DragImage()`, `WebCore::DragImage::DragImage(WebCore::DragImage&&)`, `WebCore::DragImage::operator=(WebCore::DragImage&&)` and `WebCore::DragImage::~DragImage()`, each in its complete- and base-object variant — replacing the seven parameterless `int` stubs in `Export.cpp`. - Special members follow the pinned [`DragImage.cpp`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/platform/DragImage.cpp#L247-L279): default construction leaves the surface ref null, move construction steals it and move-constructs the optional members, move assignment releases the target's previous surface and steals the source's. - Upstream's `deleteDragImage` takes its `DragImageRef` (`RefPtr<cairo_surface_t>`) by value and is a no-op, so destruction amounts to one dereference of the surface; implemented through libcairo's `cairo_surface_destroy`, reached from this library through a new `CairoSurfaceDestroy_nid_no_patch` helper in `libcairo/Surface.cpp` because another library cannot import the NID-patched `cairo_surface_destroy` export on Windows. - Guest layout is the Cairo [`DragImage.h`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/platform/DragImage.h) variant: a 200-byte `DragImage` holding `WtfAbi::RefPtr<CairoSurface> m_dragImageRef`, `Optional<TextIndicatorData> m_indicatorData` and `Optional<Path> m_visiblePath`, with engagement stored after the payload and the 64-byte `Path` tagged union carrying its index after the union. Sizes and offsets are pinned by `static_assert`s in `src/DragImageAbi.hpp`. - Reuses `WtfAbi::Vector` from the existing `src/WtfVector.hpp` for `TextIndicatorData::textRectsInBoundingRectCoordinates` (freed through the existing `_ZN3WTF8fastFreeEPv`) and the `WebCore::Color` and geometry types from `src/WebCoreTypes.hpp`; the new `src/WtfRefPtr.hpp` adds the 8-byte `WtfAbi::RefPtr`. - Color moves steal the packed `m_colorAndFlags` bits, empty the source and no-op on packed equality, following [`Color.cpp`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/platform/graphics/Color.cpp#L52-L78). - The destructor and move assignment call `NotImplemented_nid_no_patch` when the engaged `TextIndicatorData` holds a non-null `Image` (`contentImage`, `contentImageWithHighlight` or `contentImageWithoutSelection`) or an out-of-line `estimatedBackgroundColor` (bit 51), or the engaged `Path` holds a `PathImpl`, because those destructors are unmodeled. - Null objects throw `std::invalid_argument` where WebKit would fault: null `this` for every entry point, null source for move construction and move assignment; self-assignment returns early. - `Export.cpp` loses the seven stub definitions and `include/InventoryExports.hpp` their `int` declarations; they move to the new `include/DragImageExports.hpp` with real signatures (`void`/`DragImage&`, self and source pointers). `libSceNKWebKit.hpp` includes the new header, and CMake links `libcairo` plus the new `dragimage` test. - New `tests/DragImage.cpp` covers construct, move, assign and destruct round-trips over poisoned storage, surface release tracking via cairo user data, the throw paths and the color/optional/`Path` move edge cases. - Debt: the fragment `docs/dev/debt/changes/feat-nkwebkit-drag-image.md` adds a Functional entry that records the guest layout as derived from the Cairo variant and the console ABI as not compared with a console module; the seven `_ZN7WebCore9DragImage*` rows are removed from the NID inventory. ### Tested Arch Linux x86-64, GCC 16.2.1, Release build with `-DBUILD_TESTING=ON`: the new `nkwebkit_dragimage` test and every other `nkwebkit_*` test, 143 of 143 passed. `python3 tools/check_conventions.py --base upstream/main` passes. Not tested on a console or on Windows. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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
copilot-pull-request-reviewer[bot] commented 2026-11-18 15:28:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-18T15:28:33Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5959635742 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22977#pullrequestreview-5959635742). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-18T15:28:33Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
PrivacyOnion commented 2026-11-18 15:33:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T15:33:25Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_dragimage_tests built cleanly.
  • CTest (nkwebkit_dragimage):
    1/1 Test #4522: nkwebkit_dragimage ...............   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/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libSceNKWebKit/src/DragImage.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified DragImage Abi layout in DragImageAbi.hpp matching sizes, alignments, and member offsets (sizeof 200, m_indicatorData at 8, m_visiblePath at 128) against static_assert checks
    • Checked pointer safety and null checks via Checked() and Source() helpers throwing std::invalid_argument for null 'this' and source pointers across C1, C2, D1, D2, and operator=
    • Verified resource handling in Destruct() and MoveAssignInto() using cairo_surface_destroy and WTF fastFree on textRects buffer without memory leaks
    • Verified unmodeled state rejection throwing NotImplemented_nid_no_patch for non-null Image ptrs, held PathImpl (index == 2 with non-null impl), and out-of-line color flag (bit 51)
    • Verified self-move assignment guard (&target == &source) preserving existing surface and optional indicator/path state correctly
    • Checked technical debt fragment in docs/dev/debt/changes/feat-nkwebkit-drag-image.md properly documenting gaps, removed NIDs, and closing criteria

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5959723490 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22977#pullrequestreview-5959723490). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T15:33:25Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `e9e048c32f`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_dragimage_tests` built cleanly. - **CTest** (`nkwebkit_dragimage`): ``` 1/1 Test #4522: nkwebkit_dragimage ............... 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/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp`, `core/libs/prx/libSceNKWebKit/src/DragImage.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified DragImage Abi layout in DragImageAbi.hpp matching sizes, alignments, and member offsets (sizeof 200, m_indicatorData at 8, m_visiblePath at 128) against static_assert checks - Checked pointer safety and null checks via Checked() and Source() helpers throwing std::invalid_argument for null 'this' and source pointers across C1, C2, D1, D2, and operator= - Verified resource handling in Destruct() and MoveAssignInto() using cairo_surface_destroy and WTF fastFree on textRects buffer without memory leaks - Verified unmodeled state rejection throwing NotImplemented_nid_no_patch for non-null Image ptrs, held PathImpl (index == 2 with non-null impl), and out-of-line color flag (bit 51) - Verified self-move assignment guard (&target == &source) preserving existing surface and optional indicator/path state correctly - Checked technical debt fragment in docs/dev/debt/changes/feat-nkwebkit-drag-image.md properly documenting gaps, removed NIDs, and closing criteria Looks Good To Me
PrivacyOnion commented 2026-11-18 16:43:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T16:43:21Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_dragimage_tests built cleanly.
  • CTest (nkwebkit_dragimage):
    1/1 Test #4525: nkwebkit_dragimage ...............   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libcairo/Surface.cpp, core/libs/prx/libcairo/include/Surface.hpp, core/libs/prx/libSceNKWebKit/src/DragImage.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 layout and offsets in DragImageAbi.hpp (sizeof(DragImage)==200, m_indicatorData at 8, m_visiblePath at 128) matching standard-layout WebCore Cairo definitions
    • Verified null 'this' and source pointer validation throwing std::invalid_argument in Checked() and Source() across DragImage constructors, destructors, and move assignment in DragImage.cpp
    • Verified resource lifecycle in Destruct() and MoveAssignInto() using CairoSurfaceDestroy_nid_no_patch and WTF::fastFree for textRects buffer without leaks or double-frees
    • Verified unmodeled state throwing NotImplemented_nid_no_patch in Destruct and operator= for non-null Image, active PathImpl, and out-of-line color bits (1ULL << 51)
    • Verified self-move assignment guard (&target == &source) in ZN7WebCore9DragImageaSEOS0 properly returns target without modifying or destroying state
    • Verified technical debt tracking in docs/dev/debt/changes/feat-nkwebkit-drag-image.md correctly specifies removed NIDs and functional debt

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5961036829 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22977#pullrequestreview-5961036829). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T16:43:21Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `ea8046f03e`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_dragimage_tests` built cleanly. - **CTest** (`nkwebkit_dragimage`): ``` 1/1 Test #4525: nkwebkit_dragimage ............... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp`, `core/libs/prx/libcairo/Surface.cpp`, `core/libs/prx/libcairo/include/Surface.hpp`, `core/libs/prx/libSceNKWebKit/src/DragImage.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 layout and offsets in DragImageAbi.hpp (sizeof(DragImage)==200, m_indicatorData at 8, m_visiblePath at 128) matching standard-layout WebCore Cairo definitions - Verified null 'this' and source pointer validation throwing std::invalid_argument in Checked() and Source() across DragImage constructors, destructors, and move assignment in DragImage.cpp - Verified resource lifecycle in Destruct() and MoveAssignInto() using CairoSurfaceDestroy_nid_no_patch and WTF::fastFree for textRects buffer without leaks or double-frees - Verified unmodeled state throwing NotImplemented_nid_no_patch in Destruct and operator= for non-null Image, active PathImpl, and out-of-line color bits (1ULL << 51) - Verified self-move assignment guard (&target == &source) in _ZN7WebCore9DragImageaSEOS0_ properly returns target without modifying or destroying state - Verified technical debt tracking in docs/dev/debt/changes/feat-nkwebkit-drag-image.md correctly specifies removed NIDs and functional debt Looks Good To Me
MarcZX10 commented 2026-11-18 17:06:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T17:06:00Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the points below are optional.

What I ran

No commands were run. I reviewed head ea8046f03e4bf798b0f9344d1124ad603086f80b; the author reports 143 tests passed and the conventions check passed. I read all added lines in the included changed files, plus the changed declaration ranges in Export.cpp and InventoryExports.hpp, WebCoreTypes.hpp, and WtfVector.hpp. The two large changed files were read only at their relevant ranges. No repository files were excluded from review; files.json was unavailable, so the review-folder README served as the changed-file inventory.

Results

Check Result Note
Source review passed Relevant changed code and declarations read
Tests and conventions not run Results supplied by author only
Console and Windows behavior not run Not verified

Findings

Blocking

None.

Non-blocking

  • The claimed layout and special-member behavior are derived from the upstream Cairo variant, and the debt note says the console ABI has not been compared with a console module. Confirm that comparison before treating the layout as established for console execution. See DragImageAbi.hpp:225 and docs/dev/debt/changes/feat-nkwebkit-drag-image.md:4.

Not verified

  • Export.cpp and InventoryExports.hpp were not read in full; only the relevant changed declaration ranges in InventoryExports.hpp and the diff hunks were inspected. The exact full-file export/inventory consistency was not verified.
  • The author-reported test and conventions results were not independently reproduced.
  • Console ABI/layout behavior and Windows linking/runtime behavior were not verified.

To get this to a good state

Nothing is required. Optional: compare the ABI against a console module as recorded in the debt entry.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5961428961 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22977#pullrequestreview-5961428961). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-18T17:06:00Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the points below are optional. ## What I ran No commands were run. I reviewed head `ea8046f03e4bf798b0f9344d1124ad603086f80b`; the author reports 143 tests passed and the conventions check passed. I read all added lines in the included changed files, plus the changed declaration ranges in `Export.cpp` and `InventoryExports.hpp`, `WebCoreTypes.hpp`, and `WtfVector.hpp`. The two large changed files were read only at their relevant ranges. No repository files were excluded from review; `files.json` was unavailable, so the review-folder README served as the changed-file inventory. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Relevant changed code and declarations read | | Tests and conventions | not run | Results supplied by author only | | Console and Windows behavior | not run | Not verified | ## Findings ### Blocking None. ### Non-blocking - The claimed layout and special-member behavior are derived from the upstream Cairo variant, and the debt note says the console ABI has not been compared with a console module. Confirm that comparison before treating the layout as established for console execution. See `DragImageAbi.hpp:225` and `docs/dev/debt/changes/feat-nkwebkit-drag-image.md:4`. ## Not verified - `Export.cpp` and `InventoryExports.hpp` were not read in full; only the relevant changed declaration ranges in `InventoryExports.hpp` and the diff hunks were inspected. The exact full-file export/inventory consistency was not verified. - The author-reported test and conventions results were not independently reproduced. - Console ABI/layout behavior and Windows linking/runtime behavior were not verified. ## To get this to a good state Nothing is required. Optional: compare the ABI against a console module as recorded in the debt entry.
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!22977
No description provided.