3 ms·
> It would be good if there was some fallback mode where Firefox would render UI elements using HTML itself, without relying on UI toolkits. This isn't quite a
by db48x 9y ago
> It would be good if there was some fallback mode where Firefox would render UI elements using HTML itself, without relying on UI toolkits.
This isn't quite a meaningful assertion. The way it works in Firefox is that a UI developer specifies in a xul or html document that there should be a button:
<button id="myButton" label="Click me!"/>
Then Gecko applies several CSS rules for button elements. One tells it what binding to use (https://dxr.mozilla.org/mozilla-central/source/toolkit/content/xul.css#109-111 https://dxr.mozilla.org/mozilla-central/source/toolkit/conte...) (a binding is an means of abstraction that packages up behavior and document structure). The other tells it what appearance to use (https://dxr.mozilla.org/mozilla-central/source/toolkit/themes/linux/global/button.css#13-19 https://dxr.mozilla.org/mozilla-central/source/toolkit/theme...).
Note in particular the `-moz-appearance: button;`. This tells the rendering engine to figure out how big the button is, ask the OS to draw a button of that dimension, and then composite the OS button on top of the button node. I'm not an expert but a quick glance at the code points me to https://dxr.mozilla.org/mozilla-central/source/widget/gtk/nsNativeThemeGTK.cpp#1095-1100 https://dxr.mozilla.org/mozilla-central/source/widget/gtk/ns..., which seems to be the main entry point for Gecko to ask for a widget to be rendered.
As you can see, Firefox does not rely on a toolkit to tell it how buttons _work_, only how they _look_. You could supply a stylesheet that overrides the -moz-appearance rules and you'll get buttons that are rendered purely by Firefox. (You might need to supply some more style rules so that they actually look like buttons.)
If you want to compile without GTK, that's a little more complicated. Firefox uses the toolkit for things like the message loop, mouse and keyboard event processing, etc. You could do all of that in straight Xlib, but who would want to? Certainly nobody has wanted to enough that they've been maintaining an Xlib port all of these years.
- shmerl 9y agoNo Xlib for sure, since it should work on Wayland. I think GTK isn't a good choice for that purpose. Since Webrender is designed like a game engine, may be it should use SDL or something of that sort.
- gue5t 9y agoWebrender works like the rendering logic of a game engine. The input-handling logic of SDL and friends are badly impoverished compared to what full-blown GUI toolkits support; input methods, accessibility, multiple windows, tooltips, modal dialogs, etc. are all things the GUI toolkit takes care of. It would be easier to simply build a Qt version of the bits that depend on GTK, so Linux users can choose between those two. But considering how little Firefox seems to care about Linux user experience (FF has been broken with transparent GTK themes since forever and nobody cares; FF removed Linux native audio support and nobody cares), I doubt this will happen and I doubt a patch would be accepted upstream for reasons of "maintenance overhead". This ignores that maintenance overhead is much higher when two independent parties have to maintain the upstream and a patchset, but is for some reason accepted practice in the open-source world.
- shmerl 9y agoYeah. Qt support was actually in good shape in Firefox in the past, but Mozilla never backed it officially, and it fell apart.
- majewsky 9y ago> FF removed Linux native audio support and nobody cares No, they didn't. I'm listening to Soundcloud in my Firefox right now; it's sending sound to PulseAudio just fine. What you actually meant to say is that Firefox removed support for those 1% of Linux users (i.e. 0.01% of total users) that don't have PulseAudio for whatever reason.
- gue5t 9y agoLinux's native audio API is ALSA; consult the kernel sources if you don't believe me. Pulse is a common userspace audio system, but is not the native Linux audio API.
- shmerl 9y agoWhich doesn't mean Firefox should support the kernel API directly, or every audio system out there. And other systems probably have wrappers for PulseAudio API.