Bug 160547 - Overflow of formulas is hidden for display mathematics
Summary: Overflow of formulas is hidden for display mathematics
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: MathML (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
Keywords: Regression
Depends on:
Reported: 2016-08-04 06:05 PDT by Frédéric Wang (:fredw)
Modified: 2016-08-04 08:11 PDT (History)
4 users (show)

See Also:

Testcase (596 bytes, text/html)
2016-08-04 06:05 PDT, Frédéric Wang (:fredw)
no flags Details
Testcase (666 bytes, text/html)
2016-08-04 06:11 PDT, Frédéric Wang (:fredw)
no flags Details
Experimental Patch (4.02 KB, patch)
2016-08-04 08:11 PDT, Frédéric Wang (:fredw)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Frédéric Wang (:fredw) 2016-08-04 06:05:28 PDT
Created attachment 285314 [details]

Jacques Distler reported the following issue: 'The "big fraction" of https://golem.ph.utexas.edu/wiki/instiki/show/Sandbox is summarily truncated'.

It seems that the overflow is hidden for MathML formula in display="block": no scroll bars appear which may explain that the formula looks "truncated". See the attached testcase comparing a simple formula in display and inline style.
Comment 1 Frédéric Wang (:fredw) 2016-08-04 06:11:35 PDT
Created attachment 285315 [details]

A better test case using a horizontal gradient from red to green. You should be able to scroll to the green part but that does not seem possible in nightly.
Comment 2 Frédéric Wang (:fredw) 2016-08-04 08:11:42 PDT
Created attachment 285326 [details]
Experimental Patch

Some first thoughts: In general, because the preferred width of operators is overestimated (see https://bug-130326-attachments.webkit.org/attachment.cgi?id=283599). Hence all the MathML layoutBlock functions must set the correct logical width rather than relying on the preferred width. Then the RenderBox code use this logical width rather than filling the all available width.

There is an exception for <math display="block">: this must be rendered as a formula centered in the available space. Hence RenderMathMLRow::layoutBlock does not set the its logicalWidth to the width of the math content so that the centering done is this function is correct (http://tests.mathml-association.org/mathml/relations/html5-tree/display-1.html). I guess something in RenderBox also make it also occupy the whole available width. But when the available width is less than the width of the math content, the <math> tag is too narrow.

I'm attaching a hack that just injects the preferredLogicalWidth to force a minimal width but the ideal would be for RenderMathMLRow to expose the width of the math content and let RenderBox calculate the logical width by taking the maximum of the available width and of the width of the math content. Maybe rego or jfernandez have suggestions about how to do that.