feat(libSceNKWebKit): implement WebCore::HistoryItem field accessors and mutators #15230

Merged
simnJS merged 8 commits from upstream-pr/15230 into main 2026-11-07 17:25:18 +00:00
simnJS commented 2026-11-02 21:25:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simnJS on 2026-11-02T21:25:13Z.


What

Implements 28 WebCore::HistoryItem exports in libSceNKWebKit: the accessors urlString, originalURLString, title, alternateTitle, referrer, target, scrollPosition, pageScaleFactor, isTargetItem, shouldRestoreScrollPosition, shouldOpenExternalURLsPolicy, documentState, children, hasChildren, formData, formContentType and hasCachedPageExpired, and the matching mutators.

They follow Source/WebCore/history/HistoryItem.h and .cpp of the PS5 11.x WebKit snapshot neonmodder123/PS5-WebKit-11.x at 80f77e9, the snapshot #13992 uses. formContentType returns a String by value, as HistoryItem.h declares it, unlike the reference-returning accessors. hasCachedPageExpired with a cached page, url, originalURL, copy, the constructors and the destructors stay NotImplemented_nid_no_patch. The object layout comes from those sources and is not verified against the console module; the debt file records it and the build assumptions.

Tested

Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release: nkwebkit_historyitem passes (strings and reference counts, scalars, containers, null arguments). Only this test was run, not the full suite. Not run on Linux or on a title.

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
  • 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:5127669191 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15230). Originally posted by [simnJS](https://github.com/simnJS) on 2026-11-02T21:25:13Z. --- ### What Implements 28 `WebCore::HistoryItem` exports in `libSceNKWebKit`: the accessors `urlString`, `originalURLString`, `title`, `alternateTitle`, `referrer`, `target`, `scrollPosition`, `pageScaleFactor`, `isTargetItem`, `shouldRestoreScrollPosition`, `shouldOpenExternalURLsPolicy`, `documentState`, `children`, `hasChildren`, `formData`, `formContentType` and `hasCachedPageExpired`, and the matching mutators. They follow `Source/WebCore/history/HistoryItem.h` and `.cpp` of the PS5 11.x WebKit snapshot neonmodder123/PS5-WebKit-11.x at 80f77e9, the snapshot #13992 uses. `formContentType` returns a `String` by value, as `HistoryItem.h` declares it, unlike the reference-returning accessors. `hasCachedPageExpired` with a cached page, `url`, `originalURL`, `copy`, the constructors and the destructors stay `NotImplemented_nid_no_patch`. The object layout comes from those sources and is not verified against the console module; the debt file records it and the build assumptions. ### Tested Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release: `nkwebkit_historyitem` passes (strings and reference counts, scalars, containers, null arguments). Only this test was run, not the full suite. Not run on Linux or on a title. ### 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) - [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
BunnyFl commented 2026-11-04 00:02:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T00:02:33Z.

Review: APPROVED


@simnJS approved at fdfb6ef10f. I checked your layout against the console module, and every offset I could reach matches.

What I ran: this head merged onto main (merge 06a6a07b7a), Windows 11, WinLibs GCC, Release.

  • nkwebkit_historyitem, nkwebkit_base and public_headers pass (3 of 3).
  • tools/check_conventions.py --base upstream/main --head on this head: all checks pass.
  • Mutation: with urlString returning originalURLString, nkwebkit_historyitem fails at line 60 (1 of 1).

Layout against firmware 13.42 system_ex/common_ex/lib/libSceNKWebKit.sprx (sha256 e63acdc164592330a287cf6914c265336b27a357098a449c1609f8f82e104409), read from disassembly, not run. Each accessor reads the offset your static_assert gives:

Accessor Address Body
urlString 0x99440 lea 0x8(%rdi),%rax
originalURLString 0x1aceb0 lea 0x10(%rdi),%rax
referrer 0x1bf890 lea 0x18(%rdi),%rax
target 0x2d88e0 lea 0x20(%rdi),%rax
title 0xe5680 lea 0x28(%rdi),%rax
alternateTitle 0x27adb0 lea 0x30(%rdi),%rax (your displayTitle)
scrollPosition 0xc6990 lea 0x38(%rdi),%rax
pageScaleFactor 0x3a7550 vmovss 0x40(%rdi),%xmm0
documentState 0x210d10 lea 0x48(%rdi),%rax
shouldOpenExternalURLsPolicy 0x120770 movzbl 0x58(%rdi),%eax
children const 0x18dca0 lea 0x60(%rdi),%rax
hasChildren 0x15cb0 cmpl $0x0,0x6c(%rdi) (the vector's size at 0x60 + 12)
isTargetItem 0x2f6140 movzbl 0x71(%rdi),%eax
shouldRestoreScrollPosition 0xb9ce0 movzbl 0x74(%rdi),%eax
formData 0x2d88f0 mov 0x90(%rdi),%rax
formContentType 0xf2f10 mov 0x98(%rsi),%rcx, with the result object in rdi, so by value, as you have it
hasCachedPageExpired 0x365360 mov 0xa0(%rdi),%rbx; returns false when it's null, otherwise compares a time with 0x8(%rbx)
  • The setters agree too:
    • setScrollPosition (0x6da50) stores 8 bytes at 0x38, and setIsTargetItem (0xe3c00) a byte at 0x71.
    • setTitle (0x1f5bb0) and setURLString (0x112580) add 2 to the new string's refcount, swap it into 0x28 or 0x8, and release the old one. That is your Assign, with the += 2 step of WtfStringAbi.hpp:57.
  • hasCachedPageExpired throwing once a cached page is set matches what's left: the firmware calls out for the current time there.

The notifyChanged you note in the debt entry: after the swap, setTitle loads a function pointer from 0x33649a8 and calls it through a range check (from 1f5bf0). That fits WebKit's notifyHistoryItemChanged hook. Leaving it out is fine while nothing in AnyPS5 installs that hook.

With the table above, the debt entry could cite these firmware offsets instead of "is not checked against the PS5 module". Not blocking.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5761236068 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15230#pullrequestreview-5761236068). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-04T00:02:33Z. **Review:** APPROVED --- @simnJS approved at `fdfb6ef10f`. I checked your layout against the console module, and every offset I could reach matches. **What I ran:** this head merged onto `main` (merge `06a6a07b7a`), Windows 11, WinLibs GCC, Release. - `nkwebkit_historyitem`, `nkwebkit_base` and `public_headers` pass (3 of 3). - `tools/check_conventions.py --base upstream/main --head` on this head: all checks pass. - **Mutation:** with `urlString` returning `originalURLString`, `nkwebkit_historyitem` fails at line 60 (1 of 1). **Layout against firmware 13.42** `system_ex/common_ex/lib/libSceNKWebKit.sprx` (sha256 `e63acdc164592330a287cf6914c265336b27a357098a449c1609f8f82e104409`), read from disassembly, not run. Each accessor reads the offset your `static_assert` gives: | Accessor | Address | Body | |---|---|---| | `urlString` | `0x99440` | `lea 0x8(%rdi),%rax` | | `originalURLString` | `0x1aceb0` | `lea 0x10(%rdi),%rax` | | `referrer` | `0x1bf890` | `lea 0x18(%rdi),%rax` | | `target` | `0x2d88e0` | `lea 0x20(%rdi),%rax` | | `title` | `0xe5680` | `lea 0x28(%rdi),%rax` | | `alternateTitle` | `0x27adb0` | `lea 0x30(%rdi),%rax` (your `displayTitle`) | | `scrollPosition` | `0xc6990` | `lea 0x38(%rdi),%rax` | | `pageScaleFactor` | `0x3a7550` | `vmovss 0x40(%rdi),%xmm0` | | `documentState` | `0x210d10` | `lea 0x48(%rdi),%rax` | | `shouldOpenExternalURLsPolicy` | `0x120770` | `movzbl 0x58(%rdi),%eax` | | `children` const | `0x18dca0` | `lea 0x60(%rdi),%rax` | | `hasChildren` | `0x15cb0` | `cmpl $0x0,0x6c(%rdi)` (the vector's size at 0x60 + 12) | | `isTargetItem` | `0x2f6140` | `movzbl 0x71(%rdi),%eax` | | `shouldRestoreScrollPosition` | `0xb9ce0` | `movzbl 0x74(%rdi),%eax` | | `formData` | `0x2d88f0` | `mov 0x90(%rdi),%rax` | | `formContentType` | `0xf2f10` | `mov 0x98(%rsi),%rcx`, with the result object in `rdi`, so by value, as you have it | | `hasCachedPageExpired` | `0x365360` | `mov 0xa0(%rdi),%rbx`; returns false when it's null, otherwise compares a time with `0x8(%rbx)` | - The setters agree too: - `setScrollPosition` (`0x6da50`) stores 8 bytes at `0x38`, and `setIsTargetItem` (`0xe3c00`) a byte at `0x71`. - `setTitle` (`0x1f5bb0`) and `setURLString` (`0x112580`) add 2 to the new string's refcount, swap it into `0x28` or `0x8`, and release the old one. That is your `Assign`, with the `+= 2` step of `WtfStringAbi.hpp:57`. - `hasCachedPageExpired` throwing once a cached page is set matches what's left: the firmware calls out for the current time there. **The `notifyChanged` you note in the debt entry:** after the swap, `setTitle` loads a function pointer from `0x33649a8` and calls it through a range check (from `1f5bf0`). That fits WebKit's `notifyHistoryItemChanged` hook. Leaving it out is fine while nothing in AnyPS5 installs that hook. With the table above, the debt entry could cite these firmware offsets instead of "is not checked against the PS5 module". Not blocking.
BunnyFl commented 2026-11-06 17:52:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-06T17:52:14Z.

Review: APPROVED


@simnJS thanks for adding the hook line to the debt entry. Re-checked at cfa34bca05, and the approval stands.

Since my approval at fdfb6ef10f, the PR's own code changed in two places (from git diff of the PR's +/- lines at both heads, listed below). HistoryItem.cpp gained the Derived from Source/WebCore/history/HistoryItem.cpp@80f77e94c63ee7202eec3d4b5b1a021dd89011ba line in its licence header. The HistoryItemExports.hpp include in libSceNKWebKit.hpp moved from after Api.hpp to the line after #pragma once, from the merge resolution. The +/- lines of the other six code and test files are identical to fdfb6ef10f's. The rest is two main merges plus cfa34bca05, which adds the TL1XjYe1xLo sentence word for word. The branch merges cleanly with main again.

What I ran

Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0, Release, this head merged onto current main (merge 03d7febac1):

  • nkwebkit_historyitem, nkwebkit_base and public_headers: 3 of 3 pass.
  • Mutation, on the same merge (bc1ae70375): with urlString returning originalURLString, nkwebkit_historyitem aborts (0xc0000409), 0 of 1 pass.
  • tools/check_conventions.py --base upstream/main --head on this head: all checks pass.
  • tools/pr_overlap.py --branch: the line conflicts it confirms are all in docs/dev/debt/libSceNKWebKit.md, at the entry list (L49) and the "Additional callable exports" count line (L63), with #14607, #15212, #15214, #15246, #15249, #15260, #15326, #16041, #16066, #16261 and #16383. #15212, #15249 and #15260 also conflict at the include list of libSceNKWebKit.hpp (L1). The same-exports row it prints for #13486 isn't real: that PR's GitHub file list is three relinker files.

One wording point, non-blocking

The entry still says the layout "is not checked against the PS5 module". My approval table at fdfb6ef10f checked the offset of every accessor this PR implements against firmware 13.42's libSceNKWebKit.sprx (sha256 e63acdc164592330a287cf6914c265336b27a357098a449c1609f8f82e104409, disassembly only). It also checked the stores of setScrollPosition, setIsTargetItem, setTitle and setURLString, and my follow-up comment above quotes setShouldRestoreScrollPosition storing at 0x74. I didn't check which offsets the other setters store to. With that table (in my approval above), the clause could be narrowed to what's still open. For example: "the offsets the accessors read, and those setScrollPosition, setIsTargetItem, setTitle, setURLString and setShouldRestoreScrollPosition write, match firmware 13.42 (read from disassembly, not run); the other setters and the rest of the layout, which the constructors, destructor and copy would use, are not checked."

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5804587410 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15230#pullrequestreview-5804587410). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-06T17:52:14Z. **Review:** APPROVED --- @simnJS thanks for adding the hook line to the debt entry. Re-checked at `cfa34bca05`, and the approval stands. Since my approval at `fdfb6ef10f`, the PR's own code changed in two places (from `git diff` of the PR's +/- lines at both heads, listed below). `HistoryItem.cpp` gained the `Derived from Source/WebCore/history/HistoryItem.cpp@80f77e94c63ee7202eec3d4b5b1a021dd89011ba` line in its licence header. The `HistoryItemExports.hpp` include in `libSceNKWebKit.hpp` moved from after `Api.hpp` to the line after `#pragma once`, from the merge resolution. The +/- lines of the other six code and test files are identical to `fdfb6ef10f`'s. The rest is two `main` merges plus `cfa34bca05`, which adds the `TL1XjYe1xLo` sentence word for word. The branch merges cleanly with `main` again. ## What I ran Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0, Release, this head merged onto current `main` (merge `03d7febac1`): - `nkwebkit_historyitem`, `nkwebkit_base` and `public_headers`: 3 of 3 pass. - **Mutation**, on the same merge (`bc1ae70375`): with `urlString` returning `originalURLString`, `nkwebkit_historyitem` aborts (`0xc0000409`), 0 of 1 pass. - `tools/check_conventions.py --base upstream/main --head` on this head: all checks pass. - `tools/pr_overlap.py --branch`: the line conflicts it confirms are all in `docs/dev/debt/libSceNKWebKit.md`, at the entry list (L49) and the "Additional callable exports" count line (L63), with #14607, #15212, #15214, #15246, #15249, #15260, #15326, #16041, #16066, #16261 and #16383. #15212, #15249 and #15260 also conflict at the include list of `libSceNKWebKit.hpp` (L1). The same-exports row it prints for #13486 isn't real: that PR's GitHub file list is three relinker files. ## One wording point, non-blocking The entry still says the layout "is not checked against the PS5 module". My approval table at `fdfb6ef10f` checked the offset of every accessor this PR implements against firmware 13.42's `libSceNKWebKit.sprx` (sha256 `e63acdc164592330a287cf6914c265336b27a357098a449c1609f8f82e104409`, disassembly only). It also checked the stores of `setScrollPosition`, `setIsTargetItem`, `setTitle` and `setURLString`, and my follow-up comment above quotes `setShouldRestoreScrollPosition` storing at `0x74`. I didn't check which offsets the other setters store to. With that table (in my approval above), the clause could be narrowed to what's still open. For example: "the offsets the accessors read, and those `setScrollPosition`, `setIsTargetItem`, `setTitle`, `setURLString` and `setShouldRestoreScrollPosition` write, match firmware 13.42 (read from disassembly, not run); the other setters and the rest of the layout, which the constructors, destructor and `copy` would use, are not checked." AI-assisted: yes (Claude Code)
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!15230
No description provided.