feat(libSceNKWebKit): implement WebCore GridPosition, Length functions and unitedBoundingBoxes #15515

Merged
Jawschamp merged 18 commits from upstream-pr/15515 into main 2026-11-14 20:56:57 +00:00
Jawschamp commented 2026-11-03 17:10:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Jawschamp on 2026-11-03T17:10:05Z.


What

Implements 6 libSceNKWebKit exports that still threw NotImplemented_nid_no_patch as parameterless placeholders on current main: WebCore::GridPosition setExplicitPosition, setSpanPosition and setMaxPositionForTesting; valueForLength and floatValueForLength; and unitedBoundingBoxes. Their placeholders leave Export.cpp and include/InventoryExports.hpp, and docs/dev/debt/libSceNKWebKit.md goes from 5995 to 5989 additional callable exports and loses their 6 table rows. Declarations with real signatures are in include/WebCoreLayoutExports.hpp, the code in src/WebCoreLayout.cpp.

GridPosition::integerPosition and spanPosition were already implemented on main as measured field getters (offset 0x4). This branch no longer redefines them; the layout tests still call those main symbols to read back values written by the setters.

  • Behaviour is a port of the pinned PS5-WebKit-11.x LengthFunctions.cpp, GridPosition.h / GridPosition.cpp and FloatQuad.cpp.
  • ASSERT paths follow release-build behaviour. A null this on the setters throws.
  • Calculated Length is checked against pinned valueForLength / floatValueForLength in LengthFunctions.cpp (Calculated goes through minimumValueForLength or Length::nonNanCalculatedValue). WebKit evaluates the calculation-value heap object (calculationValues().get(handle).evaluate(maxValue), NaN becomes 0). That map and CalculationValue are not implemented here, so these two exports throw std::invalid_argument for LengthType::Calculated rather than guessing an evaluation. That is a deliberate gap, not the ASSERT-not-reached path used for the other non-fixed types.
  • setSpanPosition is checked against pinned GridPosition::setSpanPosition and setIntegerPosition, which clamp to [min(), max()] (min() is -max(), default ±1000000, or the testing maximum). The export therefore still accepts and clamps negatives. CSS span is positive-only in a different function, consumeGridLine, which rejects a negative (or zero) span integer before style conversion; createGridPosition then calls setSpanPosition(gridLineNumber ? gridLineNumber : 1, ...). That parser is not this export, so the signed clamp was left unchanged.
  • The named grid line is retained with the WTF String reference count.
  • The GridPosition, Length and WTF::Vector layouts are taken from the pinned source and asserted at compile time; they are not measured on a console. The field-getter offsets already on main match m_integerPosition at 0x4.
  • src/WebCoreLayout.cpp and include/WebCoreLayoutExports.hpp carry the verbatim upstream licence notices from the pinned files, each with a Derived from <path>@80f77e94c63ee7202eec3d4b5b1a021dd89011ba line, matching src/WebCoreViewport.cpp.
  • Not included: computeViewportAttributes, restrictMinimumScaleFactorToViewportSize, computeMinimumScaleFactorForContentContained and restrictScaleFactorToInitialScaleIfNotUserScalable, which open PR #15125 already implements.

Tested

Linux x86_64, GCC 14.2, -DBUILD_TESTING=ON, after merging current main (021d3612e8) as 0d888b9bac (and earlier 65351c2931 as 964ee94e92), dropping the duplicate getters in 75d45116c7, and adding the upstream licence notices in d589a74423. Hardware and titles: not tested.

  • nkwebkit_webcorelayout and nkwebkit_fieldgetters both pass, and libSceNKWebKit links with a single definition of integerPosition / spanPosition.
  • tools/check_conventions.py --base origin/main --head HEAD, tools/check_test_registration.py and core/libs/tests/test_public_headers.py --audit-only pass. Licence blocks are allowed by check_conventions.py (license_run) and do not trip the no-comments rule.
  • The Windows failure on a15f0cbb38 was a link error (multiple definition of integerPosition and spanPosition in WebCoreLayout.cpp vs FieldGetters.cpp), not agc_commands. Waiting on a green run of this head for 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
  • 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:5141420494 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15515). Originally posted by [Jawschamp](https://github.com/Jawschamp) on 2026-11-03T17:10:05Z. --- ### What Implements 6 libSceNKWebKit exports that still threw `NotImplemented_nid_no_patch` as parameterless placeholders on current `main`: `WebCore::GridPosition` `setExplicitPosition`, `setSpanPosition` and `setMaxPositionForTesting`; `valueForLength` and `floatValueForLength`; and `unitedBoundingBoxes`. Their placeholders leave `Export.cpp` and `include/InventoryExports.hpp`, and `docs/dev/debt/libSceNKWebKit.md` goes from 5995 to 5989 additional callable exports and loses their 6 table rows. Declarations with real signatures are in `include/WebCoreLayoutExports.hpp`, the code in `src/WebCoreLayout.cpp`. `GridPosition::integerPosition` and `spanPosition` were already implemented on `main` as measured field getters (offset `0x4`). This branch no longer redefines them; the layout tests still call those `main` symbols to read back values written by the setters. - Behaviour is a port of the pinned [PS5-WebKit-11.x](https://github.com/neonmodder123/PS5-WebKit-11.x/tree/80f77e94c63ee7202eec3d4b5b1a021dd89011ba) `LengthFunctions.cpp`, `GridPosition.h` / `GridPosition.cpp` and `FloatQuad.cpp`. - `ASSERT` paths follow release-build behaviour. A null `this` on the setters throws. - Calculated `Length` is checked against pinned `valueForLength` / `floatValueForLength` in [`LengthFunctions.cpp`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/platform/LengthFunctions.cpp#L39-L45) (Calculated goes through [`minimumValueForLength`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/platform/LengthFunctions.h#L50-L59) or [`Length::nonNanCalculatedValue`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/platform/Length.cpp#L237-L244)). WebKit evaluates the calculation-value heap object (`calculationValues().get(handle).evaluate(maxValue)`, NaN becomes 0). That map and `CalculationValue` are not implemented here, so these two exports throw `std::invalid_argument` for `LengthType::Calculated` rather than guessing an evaluation. That is a deliberate gap, not the ASSERT-not-reached path used for the other non-fixed types. - `setSpanPosition` is checked against pinned [`GridPosition::setSpanPosition`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/rendering/style/GridPosition.cpp#L54-L62) and [`setIntegerPosition`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/rendering/style/GridPosition.h#L90), which clamp to `[min(), max()]` (`min()` is `-max()`, default ±1000000, or the testing maximum). The export therefore still accepts and clamps negatives. CSS `span` is positive-only in a different function, [`consumeGridLine`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp#L7526-L7529), which rejects a negative (or zero) span integer before style conversion; [`createGridPosition`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WebCore/style/StyleBuilderConverter.h#L1257-L1258) then calls `setSpanPosition(gridLineNumber ? gridLineNumber : 1, ...)`. That parser is not this export, so the signed clamp was left unchanged. - The named grid line is retained with the WTF `String` reference count. - The `GridPosition`, `Length` and `WTF::Vector` layouts are taken from the pinned source and asserted at compile time; they are not measured on a console. The field-getter offsets already on `main` match `m_integerPosition` at `0x4`. - `src/WebCoreLayout.cpp` and `include/WebCoreLayoutExports.hpp` carry the verbatim upstream licence notices from the pinned files, each with a `Derived from <path>@80f77e94c63ee7202eec3d4b5b1a021dd89011ba` line, matching `src/WebCoreViewport.cpp`. - Not included: `computeViewportAttributes`, `restrictMinimumScaleFactorToViewportSize`, `computeMinimumScaleFactorForContentContained` and `restrictScaleFactorToInitialScaleIfNotUserScalable`, which open PR #15125 already implements. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Linux x86_64, GCC 14.2, `-DBUILD_TESTING=ON`, after merging current `main` (`021d3612e8`) as `0d888b9bac` (and earlier `65351c2931` as `964ee94e92`), dropping the duplicate getters in `75d45116c7`, and adding the upstream licence notices in `d589a74423`. Hardware and titles: not tested. - `nkwebkit_webcorelayout` and `nkwebkit_fieldgetters` both pass, and `libSceNKWebKit` links with a single definition of `integerPosition` / `spanPosition`. - `tools/check_conventions.py --base origin/main --head HEAD`, `tools/check_test_registration.py` and `core/libs/tests/test_public_headers.py --audit-only` pass. Licence blocks are allowed by `check_conventions.py` (`license_run`) and do not trip the no-comments rule. - The Windows failure on `a15f0cbb38` was a link error (`multiple definition` of `integerPosition` and `spanPosition` in `WebCoreLayout.cpp` vs `FieldGetters.cpp`), not `agc_commands`. Waiting on a green run of this head for 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) - [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
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!15515
No description provided.