feat(libSceNKWebKit): implement WebCore ViewportArguments resolution and scale helpers #15125
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15125"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by ashwin280802 on 2026-11-02T17:40:09Z.
What
Implements four
libSceNKWebKitexports from WebCore'sViewportArguments.cpp, all pure float math:computeViewportAttributes(ViewportArguments, int, int, int, float, IntSize)restrictMinimumScaleFactorToViewportSize(ViewportAttributes&, IntSize, float)computeMinimumScaleFactorForContentContained(const ViewportAttributes&, const IntSize&, const IntSize&)restrictScaleFactorToInitialScaleIfNotUserScalable(ViewportAttributes&)Source:
ViewportArguments.cppL47-L291 (helpers,ViewportArguments::resolveand the four functions) andViewportArguments.hL44-L104 (struct layouts).Divergences from the source:
resolveis a file-local function rather than a member, and theASSERTs are dropped. The struct layouts (ViewportArguments56 bytes,ViewportAttributes36 bytes,Typewithout the iOS-only values) come from that 11.x source and are pinned withstatic_assert; I did not check them against the console binary, so they are listed in the layouts entry of the library's debt file.Overlap: I compared this branch with the 15 open PRs that can be merged against
main. Each touches the export count line in the debt file, and #14172 also edits the layouts line I extend; none shares an export or a new file. I read the added lines of the three PRs that conflict withmain(#13515, #14152, #14212) and found none of these names.Tested
Windows 11, MinGW GCC 15.2.0, Release, at 88fa5584e0.
ctest --test-dir build-vp -R nkwebkit --output-on-failure; the new test isnkwebkit_webcoreviewport. Its cases cover the Implicit, ViewportMeta and CSSDeviceAdaptation paths, clamping, a device pixel ratio of 2, the pass-through fields and each helper.The last line is
python3 tools/check_conventions.py --base origin/main.I changed 138 conditions and statements one at a time (136 compiled) and the test failed on 126. The 10 survivors cannot be observed with finite inputs: six are
static_assertdeletions, and the other four leave the result unchanged because a later line recomputes the same value or the changed term is multiplied by 1 or ignored by amax.Not verified: the full Windows suite at this revision; the Linux suite, which I could not run because the container cannot configure CMake from a git worktree on my machine; the struct layouts against the console binary.
Not covered by a test: the by-value 56-byte
ViewportArgumentsand sretViewportAttributescalling convention from guest code. The test calls the exports with the same declarations, so it checks caller and callee agreement and thestatic_asserts check the layout, not a console caller.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T19:32:39Z.
Review: APPROVED
Looks right, and the layouts and calling convention match the console module, which the description lists as unchecked. Firmware 13.42's
system_ex/common_ex/lib/libSceNKWebKit.sprx(sha256e63acdc164592330a287cf6914c265336b27a357098a449c1609f8f82e104409), disassembly only:computeViewportAttributes(NugBItcC7YY,0x1d5f20):Its reads of the arguments are exactly the fields at 0x0 through 0x34 in this PR's
ViewportArguments(widthWasExplicitat 0x35 is never read, and this PR doesn't read it either). The result writes land onViewportAttributesoffsets 0x0 through 0x20, includinginitialScale,minimumScaleandmaximumScaleat 0x8, 0xc and 0x10.The three helpers use the same offsets:
restrictScaleFactorToInitialScaleIfNotUserScalable(0x1319c0): whenuserScalable(0x14) compares equal to 0.0, it copiesinitialScale(0x8) into0xcand0x10.computeMinimumScaleFactorForContentContained(0x1ccf50):max(max(visible/contents), minimumScale at 0xc).restrictMinimumScaleFactorToViewportSize(0xcb6e0): scales by1/dprwhen dpr != 1.0f, using a multiply (cb700/cb704) exactly asConvertToUserSpacedoes, then stores the new minimum at0xc.Tested on Windows 11, WinLibs GCC 15.2.0, with this head merged onto current
main:nkwebkit_webcoreviewport,nkwebkit_webcoregeometry,nkwebkit_baseandpublic_headerspass. Withmain'sExport.cpp,InventoryExports.hppandWebCoreExports.hpp, the new test doesn't build against the old declarations.Non-blocking: the layouts entry in the debt file could now say the 56- and 36-byte layouts and the by-value/sret convention match the 13.42 module. I compared the field offsets and register use, not every branch of the arithmetic.
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T18:48:51Z.
Review: APPROVED
@ashwin280802 approved again at
a14116375b.The rebase:
git range-diffagainst my approved88fa5584e0changes none of this PR's own+/-lines. The only difference is the debt file's hunk context, wheremainmoved the lines around the entry.What I ran: head
a14116375b, which already containsmain9ab6a281ea. Windows 11, WinLibs GCC 15.2.0, Release:nkwebkit_webcoreviewportandpublic_headerspass (2 of 2).WebCoreViewport.cppset to0.5finstead of0.25f,nkwebkit_webcoreviewportaborts (WebCore viewport check failed at line 34). So the tests cover the defaults.tools/check_conventions.py --base upstream/main --headon the head: all checks passed.pr_overlap.py --branchon the head:docs/dev/debt/libSceNKWebKit.md, #14858 among them. Whichever lands later will need a rebase there.WebCoreexports. That PR only carries the old argument-less inventory stubs that this PR removes, for exampleint APS5_VABI _ZN7WebCore25computeViewportAttributesENS_17ViewportArgumentsEiiifNS_7IntSizeE()in itsExport.cpp. So it doesn't implement them.