Skip to content

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented May 17, 2016

This path changes how the container width is determined so that it can be used within shrink-wrap elements like table cells and inline-block elements, while still properly handling floating elements that reduce the width.

The old approach was to use an <hr> element to get the width, since that would fill the available space, but not overlap floating elements. The problem with that approach is that shrink-wrap elements would end up being width 0 if they don't have any other content than the math.

To resolve this, we can use an element with display:table-cell and width set to some large amount, since the table will shrink the cell to the available space, but the large width will force it to be as large as possible. Thus it gets the full width of that is available. (This was the technique used in the handle-floats extension for displaying the HTML-CSS output within the available space, but it was not used for measuring the space.) This is more effective than the <hr> technique, since it means that in a shrink-wrapped element, the table cell will try to be as large as possible (forcing the container to be as large as possible), whereas the rule would not, leaving the width of 0.

The HTML-CSS and CHTML output now include the CSS used in the handle-floats extension to make sure that the output fits within the floating elements. This was not being done with the CHTML output (and there was no handle-floats extension for it), and this makes the current handle-floats for HTML-CSS obsolete.

I would recommend reviewing the SVG output first, then the HTML-CSS and finally the CHTML output.

Note: IE < 8 will not get the container width correct inside shrink-wrap elements, since it doesn't implement display:table-cell properly, and we are forced to use display:block; width:100% instead, which doesn't force the container to be as wide as possible. But since display:block is also implemented incorrectly in IE < 8, it does get the proper width between floating elements when not used inside a shrink-wrap element. This only applies to HTML-CSS output, since SVG only works in IE9 and above, and CHTML only in IE8 and above.

dpvc added 4 commits May 17, 2016 15:52
…ry to handle the problem with full-width equations being too wide when the ex-size isn't measured accurately enough. Issue mathjax#1478.
…L-CSS, and add the CSS from handle-floats into the standard HTML-CSS. Remove the content of the handle-floats extension. Issue mathjax#1478.
@pkra pkra added this to the MathJax v2.x.x milestone May 18, 2016
HUB.Insert(style,({
left: {marginLeft: SVG.Ex(shift)},
right: {marginRight: SVG.Ex(-shift), marginLeft: SVG.Ex(Math.max(0,shift-(l+svg.w+r)))},
right: {marginRight: SVG.Ex(-shift), marginLeft: SVG.Ex(Math.max(0,shift-(w)))},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there something missing? O/w maybe remove parentheses around (w).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it. It's a query-replace artifact.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I'll fix it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@zorkow
Copy link
Member

zorkow commented Jun 8, 2016

I can't really comment much on the code. But if it works, fine.

@zorkow
Copy link
Member

zorkow commented Jun 8, 2016

lgtm.

@dpvc dpvc merged commit abb7084 into mathjax:develop Jun 8, 2016
@dpvc dpvc deleted the issue1478 branch June 8, 2016 11:32
@dpvc dpvc mentioned this pull request Jul 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants