Hacking Gecko or 1011020
Published on April 7, 2015.
Note
This post was previous published at blog.rgaiacs.com. Some links might got broken during the conversion from reStructuredText to Markdown.
For some time now I want to be able to contribute to native support of MathML at Gecko but
- I only know C (not C++),
- I only program command line interfaces (not graphical user interface),
- I never program a "graphical framework", ...
Frédéric recommended that I start with Bug 1011020 because shouldn't be very hard to fix this bug. So I decided to give it a try.
Reproducing the bug
The bug is about the bars of fractions, radicals etc be invisible at some zoom levels. For example, I had to zoom out three times (or to 67%) for reproduce the bug with the following example.
And if I zoom out another time (or to 50%) the bar is visible.
Compiling
I already have compile Firefox in the past and this was easy this time.
Note
If you are going to compile Firefox for the first time, take a look at https://developer.mozilla.org/en/docs/Simple_Firefox_build.
Trying GDB
Since I already program in C and GDB help me a lot when debugging I decided to try using it for Firefox. Unfortunately it didn't go very good since Firefox was very slow and because of this I decided to go back and use printf.
Finding the write file
To work with the msqrt element I :
$ ls layout/mathml | grep -P '(sqrt|root).*cpp'
nsMathMLmrootFrame.cpp
nsMathMLmsqrtFrame.cppand
$ grep -i pixel layout/mathml/nsMathMLmsqrtFrame.cpp $ grep -i bar layout/mathml/nsMathMLmsqrtFrame.cpp
Since didn't find anything, I :
$ grep -i pixel layout/mathml/nsMathMLmrootFrame.cpp
nscoord oneDevPixel = aFontMetrics->AppUnitsPerDevPixel();
oneDevPixel);
oneDevPixel);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
printf("onePixel = %d\n", onePixel);
if (ruleThickness < onePixel) {
ruleThickness = onePixel;
// adjust clearance psi to get an exact number of pixels -- this
nscoord delta = psi % onePixel;
psi += onePixel - delta; // round upand because of it I start reading layout/mathml/nsMathMLmrootFrame.cpp and adding some printf on it. Unfortunately no information was send to the terminal and I asked for help. Frédéric reply suggesting to look at layout/mathml/nsMathMLmencloseFrame.cpp that first didn't make much sense to me but after I looked at the documentation was very clear to me since I can use menclose as a replacement for msqrt, e.g.
Note
I should have look at layout/mathml/nsMathMLmsqrtFrame.h and find out that it is related with layout/mathml/nsMathMLmencloseFrame.cpp.
Then I added the printf at layout/mathml/nsMathMLmencloseFrame.cpp and started get some information (after I discovered that nscoord is int).
onePixel, mRuleThickness and mRadicalRuleThickness
Reading layout/mathml/nsMathMLmencloseFrame.cpp looks that the relevant variables was onePixel, mRuleThickness and mRadicalRuleThickness so I printed it on the terminal and take some notes.
| Zoom Level | Bar is visible | onePixel | mRuleThickness | mRadicalRuleThickness |
| 100% | Yes | 60 | 120 | 39 |
| 90% | Yes | 60 | 134 | 44 |
| 80% | Yes | 60 | 75 | 42 |
| 67% | Yes | 60 | 90 | 42 |
| 50% | No | 60 | 120 | 45 |
| 30% | Yes | 60 | 200 | 56 |
Right now I'm trying to find what this numbers have of special that could help me fixing the bug.
MathML,Mozilla,Mozilla Brasil
Tags: