feat(libSceNKWebKit): implement WebCore localized strings #19523
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19523"
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 MatteoSid on 2026-11-13T13:17:33Z.
What
This PR implements four
WebCorelocalized-string exports in libSceNKWebKit. Before it, each one threw throughNotImplemented_nid_no_patch:_ZN7WebCore15localizedStringEPKc(localizedString(const char*))0cKbHa0gdeg_ZN7WebCore22multipleFileUploadTextEj(multipleFileUploadText(unsigned))3aeIfu8G6SE_ZN7WebCore18pluginTooSmallTextEv(pluginTooSmallText())ryA0BvjZKrY_ZN7WebCore32useBlockedPlugInContextMenuTitleEv(useBlockedPlugInContextMenuTitle())KYICSuDQehAWhich platform code applies. Neither the PS5 11.x tree nor WebKit
c55364d53f97has a PlayStation localized-strings file:platform/playstationat 11.x80f77e94c6holds only the MIME type registry, screen, scrollbar theme, user agent and widget files.platform/playstationatc55364d53f97is the same, without the widget file.PlatformPlayStation.cmakeadds no localization source.The port therefore builds the shared
platform/LocalizedStrings.cppfromSources.txt.USE(CF)is defined only forPLATFORM(COCOA)andUSE(GLIB)only for GTK and WPE (PlatformUse.h), andOptionsPlayStation.cmakesets neither. So the PlayStation build takes the generic branch of each macro. The Cocoa, Win and GLib versions do not apply.What the code does. It follows the PS5 11.x
LocalizedStrings.cpp, the 11.x tree the library's otherDerived from Sony PS5 WebKit 11.xfiles pin:localizedString(const char* key): the non-Cocoa, non-Win branch at L152-L157 isString::fromUTF8(key, strlen(key)). The key comes back as UTF-8 and is not translated.c55364d53f97has the same body (L72-L79).pluginTooSmallText()(L998-L1001):WEB_UI_STRING_KEYexpands tolocalizedString(key)(LocalizedStrings.hL423-L427). The result isPlug-In too small.useBlockedPlugInContextMenuTitle()(L1434-L1437) returnslocalizedString("Show in blocked plug-in"). Inc55364d53f97(L1155-L1158) the same string passes through aformatLocalizedStringwith no arguments, which gives the same text.multipleFileUploadText(unsigned)(L1003-L1006):WEB_UI_FORMAT_STRINGexpands toformatLocalizedString("%d files", numberOfFiles)(LocalizedStrings.hL454). The code follows thePLATFORM(PLAYSTATION)branch offormatLocalizedString(L83-L102):vsnprintfmeasures the length, and a result of 0 or less returnsString::fromUTF8(format);length + 1buffer and returnsString::fromUTF8of that buffer.The format is
%dwith anunsignedargument, so a count aboveINT_MAXprints as negative: 4294967295 gives-1 files. ThatformatLocalizedStringis a file-local helper here; it has no export.c55364d53f97has no PlayStation branch informatLocalizedString. It would callnotImplemented()and return the unformatted%d files. This PR uses the Sony branch because it is the PlayStation code. The debt entry records the difference.The length probe calls
vsnprintf(nullptr, 0, ...), where upstream callsvsnprintf(&ch, 1, ...). Both return the same length, and the upstream form makes GCC 13 warn with-Wformat-truncationfor this constant format. Strings are built with the mergedWTF::String::fromUTF8(const LChar*, size_t)andfromUTF8(const LChar*)exports (src/WtfString.cpp). No new String layout or allocator is added. A nulllocalizedStringkey throwsstd::invalid_argumentwhere WebKit callsstrlenon it.Files
src/LocalizedStrings.cpp. It starts with aDerived from Sony PS5 WebKit 11.x revision 80f77e94c6, Source/WebCore/platform/LocalizedStrings.cppline, followed by the upstream Apple and Igalia notice, byte-identical to lines 1-25 of the pinned file. Line 24 keeps the upstream trailing space, asWtfUrlEscape.cppand other files onmainalready do.include/LocalizedStringsExports.hppwith the declarations. It is included fromlibSceNKWebKit.hppafterLegacyExports.hpp, not at the end of the file, where #18797 and #18805 append.tests/LocalizedStrings.cpp. The existing glob inCMakeLists.txtpicks it up, so no CMake change is needed.Export.cppandInventoryExports.hpp.docs/dev/debt/changes/feat-nkwebkit-localized-strings.md(#17217);docs/dev/debt/libSceNKWebKit.mditself is unchanged. The fragment removes the four table rows. The "Additional callable exports" inventory line has had no count since #19603, so it is unchanged. A new entry at the end of "Unknown function info" records that the code was not compared with a console module. It also records that whether firmware 13.42 translates these strings is unverified, and thec55364d53f97difference.Reachability.
localizedStringtakes a plain C string.multipleFileUploadTexttakes a plainunsigned. The other two take no argument. None of them reads an object, a global or earlier state, so any caller reaches the whole implementation, including WebCore code in the same module. Each result is an ordinaryWTF::Stringfrom the mergedfromUTF8exports.Tested
Head
593b030703only adds a clean merge ofmain6a86d4d1a9cand moves the debt changes to the fragment;tools/debt_fold.py --checkpasses on it.Linux,
anyps5-dev:24.04container (Ubuntu 24.04, GCC 13.3), Release,-DBUILD_TESTING=ON. Heade291d3b690mergesmainat0be82c823d, which includes #19603. The merge commit ise291d3b690. Earlier merges ofmainwere at:74ad6380f1, withmainat3208530a32(after #19460);88874438bd, withmainat032fd92d67.The branch was first based on
mainat0294cba8dc.#19603 rewrote the "Additional callable exports" line without a count. In
e291d3b690the union merge kept both that line and our old "5935 of the 8703" line. The merge keepsmain's count-free line exactly and drops ours. After that merge,docs/dev/debt/libSceNKWebKit.mddiffered frommainonly in two ways: the new LocalizedStrings entry, and the four removed table rows. Both are now in the fragment. The repeated### Functionalheading andHitTestResult gettersentry are already onmain.e291d3b690I built all 78 libSceNKWebKit test targets and the NID-patchedlibSceNKWebKit.prxwith no errors and no new warnings.ctest -R "^nkwebkit_localizedstrings$"passes 1 of 1.ctest -R "nkwebkit|^public_headers$"passes 79 of 79: the 78 libSceNKWebKit tests, includingnkwebkit_localizedstringsand the mergednkwebkit_palfilesizeformatter, pluspublic_headers.python3 tools/check_conventions.py --base origin/main --head HEADpasses.git diff --check origin/main HEADreports only line 25 ofsrc/LocalizedStrings.cpp. That line holds the trailing space of the verbatim upstream notice.74ad6380f1: 78 test targets, andctest -R "nkwebkit|^public_headers$"passed 79 of 79;88874438bd: 77 test targets, and the samectestpassed 78 of 78.nkwebkit_localizedstringschecks exact contents, the 8-bit or 16-bit flag, and that each result holds one reference:localizedString:Choose Fileand%d filescome back unchanged and 8-bit;caf\xC3\xA9gives the 16-bitcafé, and\xE2\x98\xBA!gives☺!;""gives a non-null empty string, andbad\xFFgives a null String (invalid UTF-8);"Submit\0Reset"stops at the first NUL.multipleFileUploadText: 00 files, 11 files, 22 files, 1010 files, 12345671234567 files, 21474836472147483647 files, 2147483648-2147483648 files, 4294967295-1 files.pluginTooSmallTextreturnsPlug-In too small, anduseBlockedPlugInContextMenuTitlereturnsShow in blocked plug-in. Two calls return distinct impls.88874438bd(the code is unchanged since then), one change at a time: 12 of 12 make the test fail at run time, none by a build error. The mutations:%dchanged to%u;filessuffix changed;strlen + 1andstrlen - 1;fromUTF8WithLatin1Fallbackused instead offromUTF8;nm -D --defined-onlyon the patchedlibSceNKWebKit.prxate291d3b690shows0cKbHa0gdeg,3aeIfu8G6SE,ryA0BvjZKrYandKYICSuDQehA. Each matchestools/nid_names.pycompute_nidof the mangled name.tools/pr_overlap.py --branch feat/nkwebkit-localized-strings, run on head88874438bdinanyps5-dev-gh:24.04against the 1504 open PRs:libSceNKWebKit.hpp, so the include moved to line 7.maincould not be compared automatically. I searched their diffs for the four symbols: none implements them. #16510 showspluginTooSmallTextEvonly as a hunk-header context line.gh pr list --searchfor each symbol and NID finds no open PR.git merge-tree --write-tree(git 2.43) of head88874438bdwith #19302 (77928b987d) and with #19460 (65e48e8917) is clean for both.InventoryExports.hppand the debt table (theVelocityDatarows), and 13 in the debt gap section.docs/dev/debt/*.mdusesmerge=union, so a merge with #19460 kept both count lines (5936 and 5939). #19460 is now merged, and since #19603 the line has no count.nkwebkit_localizedstringson head88874438bdmerged ontomain(Windows 11, WinLibs GCC 15.2 UCRT, Release); it passes in 3 of 3 runs (comment).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)