== Overview == For the rationale and initial plan see [https://lists.webkit.org/pipermail/webkit-dev/2015-December/027840.html Alex's message] on webkit-dev mailing list. The idea is now to remove the flexbox dependency (CSS properties & class inheritance) only after having rewritten MathML layout functions from scratch. Hence we no longer need to temporarily "duplicate" flexbox code and this should make review easier. When refactoring renderer classes, we also remove the anonymous renderers (and their associated style) that were created for the sake of the flexbox-based layout. == Layout changes == [http://www.mathml-association.org/MathMLinHTML5/S3.html#F1 The general box model for MathML renderers] is available on the MathML in HTML5 note where you can also find other rules specific to each element. Note that these rules strongly relies on TeX / OpenType MATH and so math rendering requires [http://trac.webkit.org/wiki/MathML/Fonts appropriate fonts] to look good. During this first step, we do not always follow completely the layout suggested in that note. Also for now, we ignore the distinction between ink VS logical metrics as well as classical CSS features like margin, padding, border, absolute position, vertical layout or linebreaking. However we do pay attention to right-to-left rendering of mathematical formulas. There are essentially four functions to look at: * '''computePreferredLogicalWidths''': it sets the preferred min/max width. For now we do not do math line breaking so these widths are equal. They are only an estimate of the final width, because we do not know the exact width of stretchy operators (e.g. vertical parenthesis) until they get their final size. * '''layoutBlock''': it calculates the (exact) logical width, the logical height and and position of child renderers. * '''firstLineBaseLine''': it calculates the ascent of the renderer. * '''paint''': it does special painting for e.g. fraction line or root overbar. === Phase 1 === The initial goal is 10) below. It now depends on the following bugs. Patches are generally more or less independent, although test expectations will depend on the exact order in which they are applied. ~~1) [https://bugs.webkit.org/show_bug.cgi?id=153208 RenderMathMLRow]: layout a row of math items (numbers, operators, variables... or any subformulas), maybe with some operators stretching vertically.~~ ~~2) [https://bugs.webkit.org/show_bug.cgi?id=153742 RenderMathMLUnderOver]: base with some scripts above and below.~~ ~~3) [https://bugs.webkit.org/show_bug.cgi?id=153917 RenderMathMLFraction]: layout a fraction with numerator & denominator. The patch also fixes some bugs and uses some parameters from the OpenType MATH table.~~ ~~4) [https://bugs.webkit.org/show_bug.cgi?id=153918 RenderMathMLScripts]: base with arbitrary number of pre/post scripts. Note that the patch introduces many parameters from the OpenType MATH table so be sure to read the [http://www.mathml-association.org/MathMLinHTML5/S3.html#SS4.SSS1 corresponding section in the MathML in HTML5 note].~~ ~~5) MathOperator module: Some stretchy operators (e.g. the radical sign) are currently drawn using anonymous RenderMathMLOperators. Since we want to get rid of anonymous renderers, we need this preliminary step. It also improves a bit the rendering of horizontal operators. See [https://bugs.webkit.org/show_bug.cgi?id=156538 bug 156538], [https://bugs.webkit.org/show_bug.cgi?id=156542 bug 156542], [https://bugs.webkit.org/show_bug.cgi?id=156571 bug 156571], [https://bugs.webkit.org/show_bug.cgi?id=156572 bug 156572], [https://bugs.webkit.org/show_bug.cgi?id=156574 bug 156574], [https://bugs.webkit.org/show_bug.cgi?id=156910 bug 156910], [https://bugs.webkit.org/show_bug.cgi?id=156913 bug 156913], [https://bugs.webkit.org/show_bug.cgi?id=156921 bug 156921], [https://bugs.webkit.org/show_bug.cgi?id=156950 bug 156950], [https://bugs.webkit.org/show_bug.cgi?id=157071 bug 157071] and finally [https://bugs.webkit.org/show_bug.cgi?id=152244 bug 152244]~~ ~~6) RenderMathMLRoot: square root or arbitrary N-th root. See [https://bugs.webkit.org/show_bug.cgi?id=156836 bug 156836] and [https://bugs.webkit.org/show_bug.cgi?id=153987 bug 153987].~~ ~~7) RenderMathMLOperator and RenderMathMLToken: Simple text (operators, variables, numbers etc). This removes anonymous renderers but the layout functions still rely on the RenderFlexibleBox's implementation. A new generic layout code will only be introduced for RenderMathMLBlock in bug 153991. See [https://bugs.webkit.org/show_bug.cgi?id=157519 bug 157519], [https://bugs.webkit.org/show_bug.cgi?id=157521 bug 157521], [https://bugs.webkit.org/show_bug.cgi?id=157568 bug 157568] and finally [https://bugs.webkit.org/show_bug.cgi?id=155018 bug 155018].~~ ~~8) [https://bugs.webkit.org/show_bug.cgi?id=155019 RenderMathMLMenclose]: A RenderMathMLRow with some additional notations on it (strikes, boxes, circles etc). It is the follow up of bug 153208. See also [https://lists.webkit.org/pipermail/webkit-dev/2016-March/028064.html this proposal].~~ ~~9) [https://bugs.webkit.org/show_bug.cgi?id=155168 RenderMathMLSpace]: Simple renderer to insert blank boxes for adjusting spacing of math formulas.~~ ~~10) [https://bugs.webkit.org/show_bug.cgi?id=153991 Remove flexbox dependency]: This is the final patch to make RenderMathMLBlock inherit from RenderBlock rather than RenderFlexibleBox~~ === Phase 2 === In a second phase we add support for important MathML features and OpenType MATH properties: ~~11) [https://bugs.webkit.org/show_bug.cgi?id=133845 Implement an internal style property for displaystyle]~~ ~~12) [https://bugs.webkit.org/show_bug.cgi?id=155542 Add support for movablelimits]~~ ~~13) [https://bugs.webkit.org/show_bug.cgi?id=108778 Add support for mathvariants that cannot be emulated via CSS]~~ ~~14) [https://bugs.webkit.org/show_bug.cgi?id=133567 Use OpenType MATH constant AxisHeight]~~ ~~15) [https://bugs.webkit.org/show_bug.cgi?id=155638 Use Radical* constants from the OpenType MATH table]~~ ~~16) [https://bugs.webkit.org/show_bug.cgi?id=155639 Use Fraction* parameters from the OpenType MATH table]~~ ~~17) [https://bugs.webkit.org/show_bug.cgi?id=155714 Use Stack* parameters from the OpenType MATH table ]~~ ~~18) [https://bugs.webkit.org/show_bug.cgi?id=155756 Use parameters from the OpenType MATH table for ]~~ ~~19) [https://bugs.webkit.org/show_bug.cgi?id=155792 Basic implementation of mpadded]~~ ~~20) [https://bugs.webkit.org/show_bug.cgi?id=85733 Add support for @href attribute in MathML]~~ 21) ~~Use OpenType MATH fonts by default. See [https://bugs.webkit.org/show_bug.cgi?id=133603 bug 133603] and [https://bugs.webkit.org/show_bug.cgi?id=156840 bug 156840]~~ === Phase 3 === In this third phase, we try and [https://bugs.webkit.org/show_bug.cgi?id=156536 move all parsing of MathML attributes from renderer classes to element classes]. Hopefully, this will also improve how we handle the update of the renderers when dynamic changes of attributes happen. ~~22) [https://bugs.webkit.org/show_bug.cgi?id=156792 Create a MathMLLength struct to handle the parsing of MathML length]~~ ~~23) [https://bugs.webkit.org/show_bug.cgi?id=156795 Move parsing of mspace attributes to a MathMLSpaceElement class]~~ ~~24) [https://bugs.webkit.org/show_bug.cgi?id=159620 Move parsing of mpadded attributes to a MathMLPaddedElement class]~~ ~~25) [https://bugs.webkit.org/show_bug.cgi?id=159622 Move parsing of subscriptshift and superscriptshift from rendering to element classes]~~ ~~26) [https://bugs.webkit.org/show_bug.cgi?id=159624 Move parsing of mfrac attributes into a MathMLFractionElementClass]~~ ~~27) [https://bugs.webkit.org/show_bug.cgi?id=159625 Move parsing of accentunder and accent attributes from renderer to element classes]~~ ~~28) [https://bugs.webkit.org/show_bug.cgi?id=159623 Move parsing of display, displaystyle and mathvariant attributes from rendering to mathml element classes]~~ 29) [https://bugs.webkit.org/show_bug.cgi?id=156537 Move parsing of operator attributes into the MathML element classes]. See also ~~[https://bugs.webkit.org/show_bug.cgi?id=159619 bug 159619]~~, ~~[https://bugs.webkit.org/show_bug.cgi?id=160034 bug 160034]~~ ~~[https://bugs.webkit.org/show_bug.cgi?id=160241 bug 160241]~~, ~~[https://bugs.webkit.org/show_bug.cgi?id=160245 bug 160245]~~, ~~[https://bugs.webkit.org/show_bug.cgi?id=160400 bug 160400]~~, ~~[https://bugs.webkit.org/show_bug.cgi?id=160239 bug 160239]~~, [https://bugs.webkit.org/show_bug.cgi?id=160190 bug 160190], [https://bugs.webkit.org/show_bug.cgi?id=160301 bug 160301], [https://bugs.webkit.org/show_bug.cgi?id=160336 160336] and [https://bugs.webkit.org/show_bug.cgi?id=160339 160339]. == Accessibility Changes == The following patches impact the a11y code: ~~3) [https://bugs.webkit.org/show_bug.cgi?id=153917 RenderMathMLFraction]: The Mac accessibility code seems to need the linethickness relative to the default linethickness (which now depends on the math font).~~ ~~4) [https://bugs.webkit.org/show_bug.cgi?id=153918 RenderMathMLScripts]: Some small box shifts happen.~~ ~~6) [https://bugs.webkit.org/show_bug.cgi?id=153987 RenderMathMLRoot]: Anonymous wrappers are removed.~~ ~~7) [https://bugs.webkit.org/show_bug.cgi?id=155018 RenderMathMLOperator and RenderMathMLToken]: The text content of token elements is now properly exposed into the accessibility tree. The management of anonymous child operators of the mfenced element must be adapted. See [https://bugs.webkit.org/show_bug.cgi?id=139582 bug 139582]~~