Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspecting Web Views in macOS #11952

Open
guevara opened this issue Jan 17, 2025 · 0 comments
Open

Inspecting Web Views in macOS #11952

guevara opened this issue Jan 17, 2025 · 0 comments

Comments

@guevara
Copy link
Owner

guevara commented Jan 17, 2025

Inspecting Web Views in macOS



https://ift.tt/UlMh1KT



Jim Nielsen


I recently received a tantalizing email from a reader I’ve never met: Sam Henri-Gold.

Sam showed me how you can key in a couple write commands in the macOS terminal:

defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
defaults write -g WebKitDeveloperExtras -bool YES

Which will enable a context menu in a system web view:

Screenshot of the Apple Music settings in the Family Sharing pane of system preferences on macOS with a “Inspect Element” context menu element visible.

Which lets you trigger the Safari Web Inspector and inspect elements of the view — like you would any website:

Screenshot of the Apple Music settings in the Family Sharing pane of system preferences on macOS with the Safari Web Inspector tools also open and actively inspecting an element.

I find this fascinating! I’m intrigued by the ability to use system colors in CSS and these web views in macOS show how engineers at Apple are leveraging non-standard CSS keywords in Webkit to mimic UIs in macOS which are otherwise built with native system APIs.

It’s kind of like opening the developer tools in an Electron app, except these are native macOS apps with web views parading as system UI.

I’ve poked around in the “Apple ID” and “Family Sharing” panes in the macOS System Preferences where I’ve spotted a few intriguing details.

For example, in the Apple Music tab of Family Sharing preferences I find a javascript-packed.js file being loaded which appears to be leveraging React to power that particular web view.

Screenshot of the Web Inspector for the Apple Music Family Sharing pane in System Preferences showing a JavaScript file powering the view which is using React.

In another view, I see what looks like web components: custom DOM elements like <settings-app> and <graphite-panel>.

Screenshot of the web inspector for a tab in the Apple ID pane of System Preferences which shows custom elements in the DOM.

Nothing earth-shattering here, but enough to satisfy my curiosity poking around for a while.

I can imagine that views and functionality like this explain why you see particular browser features ship in Webkit/Safari. For example, the CSS4 fonts module standardizes support for leveraging system fonts in the browser. I can imagine this scenario played out something like:

  • Apple wanted to ship web views that could be embedded into “native” apps and would inherit system styles and blend into the rest of the operating system.
  • They created proprietary keywords in Webkit to trigger rendering the system font, i.e. font-family: -apple-system which would trigger Apple’s San Francisco font to display.
  • Eventually they standardize with other browser makers to make font-family: ui-sans-serif to render the system font.

Here’s an idea: guess at new features in macOS by using the work of Safari team members as a leading indicator. If they’re pushing for one particular feature to be standardized and implemented (or if non-standard keywords are making their way into Safari), it’s not far-fetched to conclude that means a new feature is coming to the OS which relies on that particular Safari feature in order for web views embedded into native apps to blend seamlessly into the experience of macOS.

Anyway, something to play around with if you feel so inclined.







via Jim Nielsen’s Blog

January 17, 2025 at 04:35PM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant