<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: firefox2</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/firefox2.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2025-12-17T01:48:54+00:00</updated><author><name>Simon Willison</name></author><entry><title>firefox parser/html/java/README.txt</title><link href="https://simonwillison.net/2025/Dec/17/firefox-parser/#atom-tag" rel="alternate"/><published>2025-12-17T01:48:54+00:00</published><updated>2025-12-17T01:48:54+00:00</updated><id>https://simonwillison.net/2025/Dec/17/firefox-parser/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/mozilla-firefox/firefox/tree/main/parser/html/java"&gt;firefox parser/html/java/README.txt&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
TIL (or TIR - &lt;a href="https://simonwillison.net/2009/Jul/11/john/"&gt;Today I was Reminded&lt;/a&gt;) that the HTML5 Parser used by Firefox is maintained as Java code (&lt;a href="https://github.com/mozilla-firefox/firefox/commits/main/parser/html/javasrc"&gt;commit history here&lt;/a&gt;) and converted to C++ using a custom translation script.&lt;/p&gt;
&lt;p&gt;You can see that in action by checking out the ~8GB Firefox repository and running:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd parser/html/java
make sync
make translate
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here's &lt;a href="http://gistpreview.github.io/?e53ff836cb44816670adddc3a518b3cc"&gt;a terminal session where I did that&lt;/a&gt;, including the output of &lt;code&gt;git diff&lt;/code&gt; showing the updated C++ files.&lt;/p&gt;
&lt;p&gt;I did some digging and found that the code that does the translation work lives, weirdly, in the &lt;a href="https://github.com/validator/validator"&gt;Nu Html Checker&lt;/a&gt; repository on GitHub which powers the W3C's &lt;a href="https://validator.w3.org/nu/"&gt;validator.w3.org/nu/&lt;/a&gt; validation service!&lt;/p&gt;
&lt;p&gt;Here's a snippet from &lt;a href="https://github.com/validator/validator/blob/dfd1948624259c63027bc5953e89bdeee81fb7b0/htmlparser/translator-src/nu/validator/htmlparser/cpptranslate/CppVisitor.java#L421-L442"&gt;htmlparser/cpptranslate/CppVisitor.java&lt;/a&gt; showing how a class declaration is converted into C++:&lt;/p&gt;
&lt;pre&gt;    &lt;span class="pl-k"&gt;protected&lt;/span&gt; &lt;span class="pl-smi"&gt;void&lt;/span&gt; &lt;span class="pl-en"&gt;startClassDeclaration&lt;/span&gt;() {
        &lt;span class="pl-s1"&gt;printer&lt;/span&gt;.&lt;span class="pl-en"&gt;print&lt;/span&gt;(&lt;span class="pl-s"&gt;"#define "&lt;/span&gt;);
        &lt;span class="pl-s1"&gt;printer&lt;/span&gt;.&lt;span class="pl-en"&gt;print&lt;/span&gt;(&lt;span class="pl-s1"&gt;className&lt;/span&gt;);
        &lt;span class="pl-s1"&gt;printer&lt;/span&gt;.&lt;span class="pl-en"&gt;printLn&lt;/span&gt;(&lt;span class="pl-s"&gt;"_cpp__"&lt;/span&gt;);
        &lt;span class="pl-s1"&gt;printer&lt;/span&gt;.&lt;span class="pl-en"&gt;printLn&lt;/span&gt;();

        &lt;span class="pl-k"&gt;for&lt;/span&gt; (&lt;span class="pl-smi"&gt;int&lt;/span&gt; &lt;span class="pl-s1"&gt;i&lt;/span&gt; = &lt;span class="pl-c1"&gt;0&lt;/span&gt;; &lt;span class="pl-s1"&gt;i&lt;/span&gt; &amp;lt; &lt;span class="pl-smi"&gt;Main&lt;/span&gt;.&lt;span class="pl-c1"&gt;H_LIST&lt;/span&gt;.&lt;span class="pl-s1"&gt;length&lt;/span&gt;; &lt;span class="pl-s1"&gt;i&lt;/span&gt;++) {
            &lt;span class="pl-smi"&gt;String&lt;/span&gt; &lt;span class="pl-s1"&gt;klazz&lt;/span&gt; = &lt;span class="pl-smi"&gt;Main&lt;/span&gt;.&lt;span class="pl-c1"&gt;H_LIST&lt;/span&gt;[&lt;span class="pl-s1"&gt;i&lt;/span&gt;];
            &lt;span class="pl-k"&gt;if&lt;/span&gt; (!&lt;span class="pl-s1"&gt;klazz&lt;/span&gt;.&lt;span class="pl-en"&gt;equals&lt;/span&gt;(&lt;span class="pl-s1"&gt;javaClassName&lt;/span&gt;)) {
                &lt;span class="pl-s1"&gt;printer&lt;/span&gt;.&lt;span class="pl-en"&gt;print&lt;/span&gt;(&lt;span class="pl-s"&gt;"#include &lt;span class="pl-cce"&gt;\"&lt;/span&gt;"&lt;/span&gt;);
                &lt;span class="pl-s1"&gt;printer&lt;/span&gt;.&lt;span class="pl-en"&gt;print&lt;/span&gt;(&lt;span class="pl-s1"&gt;cppTypes&lt;/span&gt;.&lt;span class="pl-en"&gt;classPrefix&lt;/span&gt;());
                &lt;span class="pl-s1"&gt;printer&lt;/span&gt;.&lt;span class="pl-en"&gt;print&lt;/span&gt;(&lt;span class="pl-s1"&gt;klazz&lt;/span&gt;);
                &lt;span class="pl-s1"&gt;printer&lt;/span&gt;.&lt;span class="pl-en"&gt;printLn&lt;/span&gt;(&lt;span class="pl-s"&gt;".h&lt;span class="pl-cce"&gt;\"&lt;/span&gt;"&lt;/span&gt;);
            }
        }

        &lt;span class="pl-s1"&gt;printer&lt;/span&gt;.&lt;span class="pl-en"&gt;printLn&lt;/span&gt;();
        &lt;span class="pl-s1"&gt;printer&lt;/span&gt;.&lt;span class="pl-en"&gt;print&lt;/span&gt;(&lt;span class="pl-s"&gt;"#include &lt;span class="pl-cce"&gt;\"&lt;/span&gt;"&lt;/span&gt;);
        &lt;span class="pl-s1"&gt;printer&lt;/span&gt;.&lt;span class="pl-en"&gt;print&lt;/span&gt;(&lt;span class="pl-s1"&gt;className&lt;/span&gt;);
        &lt;span class="pl-s1"&gt;printer&lt;/span&gt;.&lt;span class="pl-en"&gt;printLn&lt;/span&gt;(&lt;span class="pl-s"&gt;".h&lt;span class="pl-cce"&gt;\"&lt;/span&gt;"&lt;/span&gt;);
        &lt;span class="pl-s1"&gt;printer&lt;/span&gt;.&lt;span class="pl-en"&gt;printLn&lt;/span&gt;();
    }&lt;/pre&gt;

&lt;p&gt;Here's a &lt;a href="https://johnresig.com/blog/html-5-parsing/"&gt;fascinating blog post&lt;/a&gt; from John Resig explaining how validator author Henri Sivonen introduced the new parser into Firefox in 2009.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://news.ycombinator.com/item?id=46295771#46296888"&gt;Hacker News conversation&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/c-plus-plus"&gt;c-plus-plus&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/firefox"&gt;firefox&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/firefox2"&gt;firefox2&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/henri-sivonen"&gt;henri-sivonen&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/java"&gt;java&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/john-resig"&gt;john-resig&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/mozilla"&gt;mozilla&lt;/a&gt;&lt;/p&gt;



</summary><category term="c-plus-plus"/><category term="firefox"/><category term="firefox2"/><category term="henri-sivonen"/><category term="java"/><category term="john-resig"/><category term="mozilla"/></entry><entry><title>When Bugs Collide: Fixing Text Dimming in Firefox 2</title><link href="https://simonwillison.net/2008/Jun/19/when/#atom-tag" rel="alternate"/><published>2008-06-19T18:09:13+00:00</published><updated>2008-06-19T18:09:13+00:00</updated><id>https://simonwillison.net/2008/Jun/19/when/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://allinthehead.com/retro/328/when-bugs-collide-fixing-text-dimming-in-firefox-2"&gt;When Bugs Collide: Fixing Text Dimming in Firefox 2&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Handy tips from Drew on fixing the glitchy text rendering in Firefox  2 when you animate opacity without breaking alpha-transparent PNGs in IE6.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/browsers"&gt;browsers&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/bugs"&gt;bugs&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/css"&gt;css&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/drew-mclellan"&gt;drew-mclellan&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/firefox"&gt;firefox&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/firefox2"&gt;firefox2&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ie6"&gt;ie6&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/javascript"&gt;javascript&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jquery"&gt;jquery&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/opacity"&gt;opacity&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/pngs"&gt;pngs&lt;/a&gt;&lt;/p&gt;



</summary><category term="browsers"/><category term="bugs"/><category term="css"/><category term="drew-mclellan"/><category term="firefox"/><category term="firefox2"/><category term="ie6"/><category term="javascript"/><category term="jquery"/><category term="opacity"/><category term="pngs"/></entry></feed>