feat(libSceNKWebKit): implement WebCore::parseHTMLNonNegativeInteger #15241

Merged
AlexWhitehouse merged 2 commits from upstream-pr/15241 into main 2026-11-06 12:13:36 +00:00
AlexWhitehouse commented 2026-11-02 22:00:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlexWhitehouse on 2026-11-02T22:00:27Z.


What

Implements the libSceNKWebKit export WebCore::parseHTMLNonNegativeInteger(WTF::StringView) (_ZN7WebCore27parseHTMLNonNegativeIntegerEN3WTF10StringViewE, NID V4T4zWxST6E), which threw through NotImplemented_nid_no_patch.

It is ported from the PS5 WebKit source the library's debt file already pins, neonmodder123/PS5-WebKit-11.x@80f77e94c63e: parseHTMLNonNegativeInteger and the parseHTMLIntegerInternal and parseHTMLInteger it calls, from HTMLParserIdioms.cpp lines 130 to 194. Behaviour matches upstream:

  • Accepted input: leading ASCII whitespace (space, tab, LF, CR, FF, as WTF's isASCIIWhitespace) and an optional +; parsing stops at the first non-digit; -0 is 0.
  • Limit: the upper limit is INT_MAX, not UINT_MAX, because upstream parses a signed integer first.
  • Errors: HTMLIntegerParsingError (HTMLParserIdioms.h:57) keeps its three values. An empty view is Other, an overflowing positive number is PositiveOverflow, and any negative number or negative overflow is NegativeOverflow.
  • Null characters: a non-empty StringView with null characters throws, where upstream would dereference null.

The new file core/libs/prx/libSceNKWebKit/src/HtmlInteger.cpp starts with HTMLParserIdioms.cpp's copyright and licence notice, copied byte for byte from the pinned revision, followed by a Derived from neonmodder123/PS5-WebKit-11.x/Source/WebCore/html/parser/HTMLParserIdioms.cpp@80f77e94c63ee7202eec3d4b5b1a021dd89011ba line.

Return type: the export returns upstream's Expected<unsigned, HTMLIntegerParsingError>. HTMLNonNegativeIntegerResult in src/WtfStringAbi.hpp reproduces the pinned Expected.h storage:

  • the value/error union at offset 0, then the has-value bool at offset 4;
  • 8 bytes, 4-byte aligned, trivially copyable and destructible, so SysV x86-64 returns it in rax;
  • static_asserts pin all of this. A probe compiled against the pinned Expected.h gave the same layout and return register.

Debt (docs/dev/debt/libSceNKWebKit.md):

  • The export's table row is removed.
  • The value-layouts entry gains one clause for the Expected layout.
  • The inventory count is recounted against the stubs in Export.cpp: 6982 of the table's rows on main still throw, matching its prose (the table also still lists URL::lastPathComponent and URL::strippedForUseAsReferrer, which #14387 implemented). It now says 6981.

Tested

  • nkwebkit_htmlinteger (core/libs/prx/libSceNKWebKit/tests/HtmlInteger.cpp, registered by the existing tests/*.cpp glob) covers:
    • 8-bit and 16-bit views;
    • leading whitespace, + and -, and trailing junk;
    • empty input, -0 and negatives;
    • 2147483647, 2147483648 and long overflowing inputs;
    • the exact error value for each failure.
  • Linux (Ubuntu 26.04, GCC 15):
    • on unchanged main with only the test added, nkwebkit_htmlinteger fails with _ZN7WebCore27parseHTMLNonNegativeIntegerEN3WTF10StringViewE not implemented;
    • with this PR rebased on main (38379be3f0) all 27 NKWebKit tests pass, including guest_nkwebkit_dates, guest_nkwebkit_numbers and guest_nkwebkit_urls.
  • Windows 11 (MinGW GCC 15.2.0):
    • with this PR (a76d7ab3d9), all 11 NKWebKit tests pass, with no compiler warnings in HtmlInteger.cpp;
    • the disassembly reads the result from RAX: the value or error in the low 32 bits and hasValue at bit 32;
    • on main the new test doesn't compile, because it needs the new declarations; there the export is the NotImplemented_nid_no_patch stub.
  • Mutation check: raising the limit to UINT_MAX fails nkwebkit_htmlinteger at its has-value check (line 25), because inputs above INT_MAX are then accepted.
  • python3 tools/check_conventions.py --base origin/main: all conventions checks passed. The public-header audit passes.
  • python3 tools/pr_overlap.py: no other PR implements this export.
    • The debt count line is shared with about 50 open libSceNKWebKit PRs, as every implementation in this library edits it. Whichever merges second rebases that line.
    • The value-layouts entry is also edited by #14172, #14917–#14920, #14932 and #14946–#14948.
    • WtfExports.hpp: the declaration's sorted place is next to #14607's.
    • #13486 is listed for the same export only because its branch carries the old stub; its diff does not touch it.
    • #15213 (foldQuoteMarks, defaultMIMEType, redirectChainAllowsReuse) edits the same count line and headers, not this export.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5128106912 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15241). Originally posted by [AlexWhitehouse](https://github.com/AlexWhitehouse) on 2026-11-02T22:00:27Z. --- ### What Implements the libSceNKWebKit export `WebCore::parseHTMLNonNegativeInteger(WTF::StringView)` (`_ZN7WebCore27parseHTMLNonNegativeIntegerEN3WTF10StringViewE`, NID `V4T4zWxST6E`), which threw through `NotImplemented_nid_no_patch`. It is ported from the PS5 WebKit source the library's debt file already pins, [`neonmodder123/PS5-WebKit-11.x@80f77e94c63e`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/html/parser/HTMLParserIdioms.cpp#L130-L194): `parseHTMLNonNegativeInteger` and the `parseHTMLIntegerInternal` and `parseHTMLInteger` it calls, from `HTMLParserIdioms.cpp` lines 130 to 194. Behaviour matches upstream: - **Accepted input:** leading ASCII whitespace (space, tab, LF, CR, FF, as WTF's `isASCIIWhitespace`) and an optional `+`; parsing stops at the first non-digit; `-0` is 0. - **Limit:** the upper limit is `INT_MAX`, not `UINT_MAX`, because upstream parses a signed integer first. - **Errors:** `HTMLIntegerParsingError` (`HTMLParserIdioms.h:57`) keeps its three values. An empty view is `Other`, an overflowing positive number is `PositiveOverflow`, and any negative number or negative overflow is `NegativeOverflow`. - **Null characters:** a non-empty `StringView` with null characters throws, where upstream would dereference null. The new file `core/libs/prx/libSceNKWebKit/src/HtmlInteger.cpp` starts with `HTMLParserIdioms.cpp`'s copyright and licence notice, copied byte for byte from the pinned revision, followed by a `Derived from neonmodder123/PS5-WebKit-11.x/Source/WebCore/html/parser/HTMLParserIdioms.cpp@80f77e94c63ee7202eec3d4b5b1a021dd89011ba` line. **Return type:** the export returns upstream's `Expected<unsigned, HTMLIntegerParsingError>`. `HTMLNonNegativeIntegerResult` in `src/WtfStringAbi.hpp` reproduces the pinned [`Expected.h`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/Expected.h#L305-L431) storage: - the value/error union at offset 0, then the has-value `bool` at offset 4; - 8 bytes, 4-byte aligned, trivially copyable and destructible, so SysV x86-64 returns it in `rax`; - `static_assert`s pin all of this. A probe compiled against the pinned `Expected.h` gave the same layout and return register. **Debt** (`docs/dev/debt/libSceNKWebKit.md`): - The export's table row is removed. - The value-layouts entry gains one clause for the `Expected` layout. - The inventory count is recounted against the stubs in `Export.cpp`: 6982 of the table's rows on `main` still throw, matching its prose (the table also still lists `URL::lastPathComponent` and `URL::strippedForUseAsReferrer`, which #14387 implemented). It now says 6981. ### Tested - **`nkwebkit_htmlinteger`** (`core/libs/prx/libSceNKWebKit/tests/HtmlInteger.cpp`, registered by the existing `tests/*.cpp` glob) covers: - 8-bit and 16-bit views; - leading whitespace, `+` and `-`, and trailing junk; - empty input, `-0` and negatives; - `2147483647`, `2147483648` and long overflowing inputs; - the exact error value for each failure. - **Linux (Ubuntu 26.04, GCC 15):** - on unchanged `main` with only the test added, `nkwebkit_htmlinteger` fails with `_ZN7WebCore27parseHTMLNonNegativeIntegerEN3WTF10StringViewE not implemented`; - with this PR rebased on `main` (38379be3f0) all 27 NKWebKit tests pass, including `guest_nkwebkit_dates`, `guest_nkwebkit_numbers` and `guest_nkwebkit_urls`. - **Windows 11 (MinGW GCC 15.2.0):** - with this PR (a76d7ab3d9), all 11 NKWebKit tests pass, with no compiler warnings in `HtmlInteger.cpp`; - the disassembly reads the result from `RAX`: the value or error in the low 32 bits and `hasValue` at bit 32; - on `main` the new test doesn't compile, because it needs the new declarations; there the export is the `NotImplemented_nid_no_patch` stub. - **Mutation check:** raising the limit to `UINT_MAX` fails `nkwebkit_htmlinteger` at its has-value check (line 25), because inputs above `INT_MAX` are then accepted. - `python3 tools/check_conventions.py --base origin/main`: all conventions checks passed. The public-header audit passes. - **`python3 tools/pr_overlap.py`:** no other PR implements this export. - **The debt count line** is shared with about 50 open libSceNKWebKit PRs, as every implementation in this library edits it. Whichever merges second rebases that line. - **The value-layouts entry** is also edited by #14172, #14917–#14920, #14932 and #14946–#14948. - **`WtfExports.hpp`:** the declaration's sorted place is next to #14607's. - **#13486** is listed for the same export only because its branch carries the old stub; its diff does not touch it. - **#15213** (foldQuoteMarks, defaultMIMEType, redirectChainAllowsReuse) edits the same count line and headers, not this export. ### 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 🤖 Generated with [Claude Code](https://claude.com/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!15241
No description provided.