5 ms·
> We could not block the web content rendering entirely from reading the filesystem because Firefox still uses GTK directly - we draw webpage HTML widgets using
by shmerl 9y ago
> We could not block the web content rendering entirely from reading the filesystem because Firefox still uses GTK directly - we draw webpage HTML widgets using the same theming as the native desktop.
Is there a way to build Firefox without GTK? For example for something like Plasma Mobile? It would be good if there was some fallback mode where Firefox would render UI elements using HTML itself, without relying on UI toolkits.
- robin_reala 9y agoPresumably GTK is not just used from drawing visible elements but also for things like file pickers, print windows etc.
- kuschku 9y agoWhich sucks so horribly that several distros actually maintain a full fork of Firefox where all those are patched to use Qt instead.
- mook 9y agoInteresting; do you know which distros do that? I know Nokia started the Qt stuff (for Maemo), but wasn't aware that anybody was continuing to maintain it. But I haven't looked at things at a level that would have let me know in quite a while.
- shmerl 9y agoSailfishOS developers were dragging it along, but after Mozilla dropped support for IPC Embedlite[1] (they never even accepted it officially), I think they got stuck with outdated Gecko. No idea what they are doing about it. 1. https://wiki.mozilla.org/Embedding/IPCLiteAPI https://wiki.mozilla.org/Embedding/IPCLiteAPI
- kuschku 9y agoThe SUSE distros are patching Firefox to use QT dialogs for everything, but kept the GTK core loop.
- shmerl 9y agoWhy didn't they replace all GTK with Qt and proposed to upstream it? That would have been really good.
- kuschku 9y agoThat was done several times before, but Mozilla rejected such proposals. Even if that means Firefox breaks every few weeks due to a new GTK release. Even if that means Firefox never will properly support multi-monitor HiDPI on Linux (and not at all on X11).
- shmerl 9y agoDid they provide any reason, or those who make decisions there have some irrational bias and prefer GTK? I can see why it can be harder to bind to Qt from Rust, but this is now a solved problem I think: https://phabricator.kde.org/source/rust-qt-binding-generator/ https://phabricator.kde.org/source/rust-qt-binding-generator...
- shmerl 9y agoFennec used to work without GTK? And Firefox on Android does, but there it's probably using another toolkit. It causes this exact problem - porting Firefox to a new system is impossible without rewriting all that.
- Sylos 9y agoYeah, Android Firefox uses the native Android UI toolkit. A long time ago, they had it in XUL, which allowed for some really nice customization and just in general a more conform behaviour with the desktop browser, but performance back then was really just terrible, so that's why they changed it to the native Android UI toolkit.
- clouddrover 9y ago> Firefox would render UI elements using HTML itself Browser.html is an experiment in that idea for Servo: https://github.com/browserhtml/browserhtml https://github.com/browserhtml/browserhtml If it works out it may end up in Firefox in the long term.
- shmerl 9y agoYeah, I hope this will be usable in Plasma Mobile.
- Sylos 9y agoI don't fully understand this, but I think this is a lot more complicated than it might seem. Because well, you'd first of all need to set up a separate Gecko instance to render the UI, which isn't fundamentally different from what they're doing with tabs, but still an architectural change. Well, and then you'd probably run into security restrictions, as under normal circumstances, you don't ever want something from inside Gecko to communicate with extensions and probably other things, but for this you need that capability. Having said that, Mozilla is actually exploring into this direction: https://github.com/browserhtml/browserhtml/blob/master/README.md https://github.com/browserhtml/browserhtml/blob/master/READM... And presumably, this is the future, as it would also allow them to get rid of the XUL UI Toolkit, meaning they can entirely focus on core browser technologies. (Which is something different from the XUL/XPCOM extension API that they're deprecating on Tuesday.)
- toyg 9y agoI have to say though, having chrome that is virtually indistinguishable from a webpage is a phisher's dream. You also lose 25 years of low-level graphic development in platform toolkits, which likely means losing a lot of performance.
- shmerl 9y agoThe alternative would be maintaining many toolkit backends. We already see how well that worked out. Qt backend wasn't maintained in a while, and fell into bit rot. That basically prevents Firefox from being used Plasma Mobile and the like. Having HTML backend is better than having none at all.
- Sylos 9y ago> I have to say though, having chrome that is virtually indistinguishable from a webpage is a phisher's dream. That's not terribly hard to do today either. That's why browsers implemented those obnoxious fullscreen animations and notifications somewhen last year.
- petecox 9y agoFirefox OS - IIRC, it rendered the entire UI using HTML drawing directly to the screen using Open GL ES with no 'native' toolkit to speak of, nor requiring any X11 or Wayland backend.
- 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.