Skip to content

Make CHTML mglyph scale image size by hand. mathjax/MathJax-node#241 #1512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2016

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Jun 7, 2016

Make CHTML mglyph scale image size by hand rather than using offsetWidth and offsetHeight, since those cause reflow. This also makes it work in mathjax-node. Resolves mathjax/MathJax-node#241.

…dth and offsetHeight, since those cause reflow. This also makes it work in mathjax-node. Resolves mathjax/MathJax-node#241.
@pkra pkra added this to the MathJax v2.x.x milestone Jun 7, 2016
var WW = W, HH = H;
if (w !== "") {W = this.CHTMLlength2em(w,WW); H = (WW ? W/WW * HH : 0)}
if (h !== "") {H = this.CHTMLlength2em(h,HH); if (w === "") W = (HH ? H/HH * WW : 0)}
img.style.width = CHTML.Em(W); bbox.w = bbox.r = W;
Copy link
Member

Choose a reason for hiding this comment

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

So these will fire, even if w,h are undefined? Is that intended?

Copy link
Member

Choose a reason for hiding this comment

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

For future reference: The code would be a lot easier to read if it were spread out a bit and had more descriptive var names. In particular cap vs non-cap is difficult to parse.

Copy link
Member Author

Choose a reason for hiding this comment

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

So these will fire, even if w,h are undefined?

I'm not sure which line "these" refer to. Note that w and h are never undefined, though they can be empty (they come from the getValues() method, and since the defaults for these are "", if there is no explicit value, those will eventually be found, so they are always defined).

If you mean the style settings in line 68, these use the values of W and H. These come from the img width and height, and since the image has loaded when these lines run, they are always defined. Even in jsdom, they are defined (but 0, so in mathjax-node, you are expected to use explicit width and height).

Does that cover your concerns?

@zorkow
Copy link
Member

zorkow commented Jul 6, 2016

Thanks for the explanation.
lgtm.

@dpvc dpvc merged commit 1c9e74a into mathjax:develop Jul 6, 2016
@dpvc dpvc deleted the node241 branch July 6, 2016 18:01
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