How does Safari and SFSafariViewController scale content

Safari and SFSafariViewController have a Format Options button ("aA" button) where the user can increase and decrease the size of size/content in the page.

How does this work and can it be achieved in an iOS app using WKWebView?

I'm aware of "-webkit-text-size-adjust" but not sure this is how it works, and if this would need to be changed by evaluated javascript, unless there is a native API for it?
I’ve been looking into this a bit more.

. -webkit-text-size-adjust or (webkitTextSizeAdjust in JavaScript) is not the same.

The new iOS 14 API WKWebView.pageZoom is not the same.

The closest I have got so far is to notice that when Safari scales a page the viewport is changed. For instance the value of document.documentElement.clientWidth changes. I haven’t found a way to do this myself yet.

I’ve submitted FB7847944 asking for a new WKWebView API to do this.
Still looking for a solution for this.

Can't attach screenshots here, so I've put them in a gist: https://gist.github.com/Ashton-W/25b2cb387e989ba4d6371e57dabccf6a
I've found a solution to this using SPI (Thanks to finding this report before submitting my own on WebKit Bugzilla https://bugs.webkit.org/show_bug.cgi?id=213603)

The SPI _setViewScale behaves exactly the same as Safari and SFSafariViewController's 'Page Scale' function.
I've updated FB7847944 to mention this, as this is what needs to be made public API.

Would still love to find a solution that doesn't use SPI.

I submitted FB9060375 in March to ask for a public API equivalent to the SPI.

How does Safari and SFSafariViewController scale content
 
 
Q