XUL/XBL Replacement Newsletter 19
This is the nineteenth edition of the XUL/XBL Replacement Newsletter. Lots to share this time - we’re making progress on the remaining XUL replacement work, while also clearing out the XBL implementation from mozilla-central.
<html> root in browser.xhtml
We had already migrated the main browser window from a XULDocument to HTMLDocument and renamed it from browser.xul to browser.xhtml. But there are still a lot of XUL elements inside of it. Most notably, the documentElement was still a
<xul:window>, which meant that we would use a different frame structure than normal webpages.
Brendan Dahl recently landed a change to fix this. Now instead of:
<window title="Firefox"> <linkset> <link rel="localization" />.... </linkset> <script />... <the-rest-of-the-content /> </window>
The document looks like:
<html> <head> <title>Firefox</title> <link rel="localization" />.... <script />... </head> <body> <the-rest-of-the-content /> </body> </html>
Ideally, I’d like to do the same thing but for all documents in the tree and then remove
nsDocElementBoxFrame (the layout frame used for XUL root elements). This would be a big job, since there are 1200+
<window> tags in tree and the migration likely requires some automatic parsing and rewriting XML. But the browser document is an important first step and gives us confidence that it’ll work with other documents. Also, Kirk Steuber has been taking steps to make the project more manageable by migrating away from the non-“window” XUL root elements
<dialog>. I’m also hoping we can use some of the learnings and process from Emma Malysz’ ongoing work to rename all .xul files to .xhtml to help.
L20n is the code name for an effort that started three years ago to introduce Mozilla’s new localization system (called Project Fluent) into Firefox. It’s an important part of XUL replacement, but it also improves the quality and resilience of localization in Firefox as Zibi Braniecki outlines in a post summarizing the start of the project.
Since then, the work was planned, the core internationalization module in Gecko was refactored, and Fluent was landed and integrated into all major components of the Firefox UI. And recently the old DTD-based localization system for XUL/XHTML has officially been deprecated. So as of now, we are considering the L20n project complete.
The next project is to complete migrating all remaining strings in the Firefox UI to use Fluent. Today around 37% of Firefox l10n strings use Fluent, so there’s still a lot more to do. We are first focusing on removing DTD strings that can cause the “Yellow Screen Of Death” (a startup crash due to an XML parsing error), and on building tooling to help speed the remaining conversions. This work is being tracked at https://arewefluentyet.com/.
AppWindow is the new nsXULWindow/nsWebShellWindow
In the past, top level windows (e.g. the browser UI, places UI, etc) have had an nsXULWindow associated with them for controlling various things related to the OS window. However, as we migrate more of these windows to XHTML and HTML, the “nsXULWindow” name makes less sense. So after discussing with smaug, Brendan changed the name to AppWindow. As part of this cleanup we were also able to merge nsWebShellWindow into nsXULWindow, since it was the only class extending nsXULWindow. We hope the AppWindow name makes the purpose more clear.
Last newsletter, we were building GeckoView without MOZ_XBL. Since then, Brendan has landed a change to also build desktop without MOZ_XBL and Boris Zbarsky has posted to mozilla.governance about removing the XBL module. We’ve also closed all unnecessary bugs in Core::XBL on Bugzilla, and moved any still relevant bugs into appropriate components.
In the meantime, we’ve started to remove the implementation and clean up related code. Thanks to everyone who’s been pitching in here! Removing the implementation isn’t as easy as it may seem, since it’s wound through many different components and features. If you are aware of anything that can be removed or simplified now that XBL is gone, please file a bug blocking the remove-xbl-implementation metabug.
Here are some of the recent changes:
- Emilio Cobos Álvarez landed a bunch of cleanups in the layout and style systems, including simplification of the frame constructor and removing
- After that, Tom Ritter removed the exception allowing eval() of JS via userChrome.css, which is a step towards the larger goal of completely preventing eval from being used in the parent process or system context.
- I removed XBL related tests, unifdef’ed MOZ_XBL using the unifdef utility, and then removed the dom/xbl/ directory from mozilla-central.
- After that, Alex Surkov is in the process of porting the remaining still-relevant XBL tests to use Shadow DOM.
- Ehsan Akhgari removed the loadBindingDocument method from Document.webidl.
- After that, I removed the getAnonymousElementByAttribute method from Document.webidl.
- Emma Malysz is in the process of removing getAnonymousNodes, the one remaining XBL method in Document.webidl.
- Emma also removed the negative index check from GetWholeText.
- Emma also removed the xbl.properties file, which in turn helps with the larger Fluent migration work.
- Mark Banner removed eslint support for XBL. This was a custom lint processor to partially support linting XBL which required parsing the xml to extract out JS. As clever as it was, I don’t anyone will be sad to see it go now that we don’t need it anymore.
- Tim Nguyen landed some nice cleanups in xul.css, removing the xbl namespace and a handful of CSS rules and selectors.
- Nicolas Chevobbe removed the XBL categories for DevTools console messages.
- Gabriel (gl) removed XBL handling in the DevTools inspector.
- Henrik Skupin removed XBL handling in WebDriver.
- Christoph Walcher landed a few frontend simplifications - removing the “ensure the XBL binding is created eagerly” code in applicationManager.js, then removing support for
<xbl:children>in arrowscrollbox._getScrollableElements, and finally removing
[text]attribute observing from xul:label.
- Edouard Oger removed the XBL workaround for decks in Sync UI.