[webkit-dev] MathML layout refactor proposal
Alejandro Garcia Castro
alex at igalia.com
Wed Dec 9 03:35:55 PST 2015
In the last months we have been working on refactoring the MathML
layout code to make it more maintainable, because in the current point
fixing issues or adding new features has been too complex.
We have reached the point where we think we have to discuss whether
this work makes sense and whether it is interesting for the WebKit
community. If so, we will start pushing the initial patches from our
branch to upstream.
The idea behind the refactor is to remove FlexBox dependency and
create its own layout MathML methods. The main reasons to do this are:
- Reduce code complexity: Adapting FlexBox layout (which is already
complex) in order to create the MahtML layout made the code too
complex, a big technical debt that made the improvement of MathML
more difficult every day.
- Avoid just another FlexBox dependent code: When we had to add
general layout alignment support we had a lot of problems trying
to solve some the MathML issues because it was not clear how it
worked with the FlexBox.
- Improve performance: We do not need all the features FlexBox
layout adds for most of the MathML blocks but we are executing
all that code. We also can simplify the render tree structures
that were created to make the FlexBox layout work.
- Make easier to improve the MathML implementation: Using
independent renderer classes gives more flexibility to get exact
positioning and spacing required to get high-quality math
rendering based on TeX rules and the OpenType MATH table. (cf
We have a working prototype that basically passes the current MathML
tests and removes the FlexBox dependency in:
We have basically one commit per MathML renderer that we had to
replace. This is still initial code and we need more work and add more
tests to make sure we are improving the situation.
We want to do it incrementally with 2 steps:
1. Remove FlexBox dependency but do not break the tests, this means
keep the RenderTree structure. This is basically done, and we just
need review and try to push them.
2. Refactor the RenderTree structure, removing the anonymous nodes
created to make FlexBox work and all the code that it was
required. We already have the Fractions and Underover implemented
and the code is much clearer. This will break the tests relying on
a PNG image or a render tree reference. Hence we will do it also
per renderer and rebasing the tests after each commit.
The main con of the change that the code could be bigger in some parts
of the renderers, but more direct and simple, so it should be actually
good regarding maintenance.
If you have any question, proposal or comment just send it, it would
be great to hear some more feedback, and check if we should proceed
with this effort.
More information about the webkit-dev