Bug 43819

Summary: MathML: nested square root symbols have varying descenders
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: MathMLAssignee: Dave Barton <dbarton>
Status: RESOLVED FIXED    
Severity: Normal CC: alex, bdakin, cdumez, cmarcelo, davidc, dbarton, eric, fred.wang, jchaffraix, jkjiang, macpherson, menard, mitz, sausset, webkit.review.bot
Priority: P2 Keywords: HasReduction, WebExposed
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on: 88476    
Bug Blocks: 151592    
Attachments:
Description Flags
Test case
none
mroot & msubsup test case
none
Patch
none
Patch
none
Patch eric: review+, webkit.review.bot: commit-queue-

Description David Kilzer (:ddkilzer) 2010-08-10 17:24:14 PDT
Created attachment 64057 [details]
Test case

* SUMMARY
When loading the attached test case, the bottom of the square root symbols different in how far below the baseline they're drawn.  This seems like a bug.

* STEPS TO REPRODUCE
1. Open the attached test case on a WebKit nightly build.

* RESULTS
Note that the "descender" of the square root symbol varies depending on which one you look at.

* REGRESSION
N/A
Comment 1 François Sausset 2010-08-11 00:34:42 PDT
In the test case, only the first and the last root are problematic.
For the left one, the problem is known and it is due to the fact that you have more than one element inside mroot/msqrt. To fix it, we have to implement inferred mrow that will wrap around the child elements.
The implementation was planned and I hope to have time to do it soon.
For the right root, I'll investigate.
Comment 2 François Sausset 2010-08-11 01:48:32 PDT
The problem for the square root around the "A" (the one on the right) is only appearing with STIX fonts and not with Apple Symbol one.
Strange...

The problem due to the lack of the inferred mrow implementation is font independent, as expected.
Comment 3 Alex Milowski 2010-10-17 12:47:11 PDT
I believe this has been address by the patch from Bug 43588.  Can you please test again and let me know if you accept the rendering?
Comment 4 François Sausset 2010-10-18 02:32:30 PDT
(In reply to comment #3)
> I believe this has been address by the patch from Bug 43588.  Can you please test again and let me know if you accept the rendering?

Indeed, the problem is now solved by this patch when using Apple Symbols font.
With STIX fonts, the different problem occurring around the "A" in the test is still there, but it should be solved by a patch that I have in preparation.
Comment 5 Dave Barton 2012-05-08 18:16:15 PDT
This appears fixed now to me, probably due to the fix for bug 83736. At least the right radical is now shorter, and the left radicals grow by design. Note that TeX also has large radical signs have larger descenders like this, though Firefox does not.

Any objections to closing this bug?
Comment 6 Dave Barton 2012-05-16 08:32:55 PDT
Created attachment 142269 [details]
mroot & msubsup test case

msqrt descenders seem ok in the latest nightlies, but mroot ones are not! Here are some examples from a couple of mathml LayoutTests. It's tricky to catch this, because in DumpRenderTree these examples look fine. This is explained in the ChangeLog for the patch I'm about to upload - RenderInline::offsetHeight() for a text span in the font STIXGeneral 16, for instance, may have an offsetHeight() of 24 in e.g. Safari or Chrome.
Comment 7 Dave Barton 2012-05-16 08:43:04 PDT
Created attachment 142272 [details]
Patch
Comment 8 mitz 2012-05-16 08:50:29 PDT
Comment on attachment 142272 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=142272&action=review

> Source/WebCore/ChangeLog:15
> +        This is hard to troubleshoot because for the STIXGeneral font, DumpRenderTree returns a
> +        similar result either way, whereas Safari and Chrome for instance may return much
> +        different values. This can be seen by looking at the existing test files roots.xhtml and

Why does WebKit behavior differ between Safari and DumpRenderTree?
Comment 9 mitz 2012-05-16 08:52:16 PDT
(In reply to comment #8)
> (From update of attachment 142272 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=142272&action=review
> 
> > Source/WebCore/ChangeLog:15
> > +        This is hard to troubleshoot because for the STIXGeneral font, DumpRenderTree returns a
> > +        similar result either way, whereas Safari and Chrome for instance may return much
> > +        different values. This can be seen by looking at the existing test files roots.xhtml and
> 
> Why does WebKit behavior differ between Safari and DumpRenderTree?

Does STIX need to be added to allowedFontFamilySet() in DumpRenderTree.mm (and the corresponding set in WebKitTestRunner)?
Comment 10 Dave Barton 2012-05-16 09:02:59 PDT
> Why does WebKit behavior differ between Safari and DumpRenderTree?

> Does STIX need to be added to allowedFontFamilySet() in DumpRenderTree.mm (and the corresponding set in WebKitTestRunner)?

Thanks for asking yourself these questions so I didn't have to! :) Seriously, this is why I added you to this bug, and I greatly appreciate your expert help. I will investigate this given your pointers, or any other info you experts think I need ...
Comment 11 Dave Barton 2012-05-21 09:10:14 PDT
Comment on attachment 142272 [details]
Patch

I am reworking the patch using { -webkit-line-box-contain: glyphs replaced } - see <http://dev.w3.org/csswg/css3-linebox/#LineStacking>. This is exciting, and seems clearly to be the right approach for MathML rendering, but it does change several things.
Comment 12 Dave Barton 2012-06-15 22:20:46 PDT
Created attachment 147950 [details]
Patch
Comment 13 Julien Chaffraix 2012-06-21 14:47:58 PDT
Comment on attachment 147950 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=147950&action=review

Global comments as I don't the line box layout much.

> Source/WebCore/rendering/mathml/RenderMathMLBlock.h:79
> +    virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;

OVERRIDE

> Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp:334
> +PassRefPtr<RenderStyle> RenderMathMLOperator::createStackableStyle(int /* lineHeight */, int maxHeightForRenderer, int topRelative)

Nit: Just remove the parameter name |lineHeight| and move the FIXME to the function declaration.

> Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp:170
> -    int baseHeight = roundToInt(getBoxModelObjectHeight(firstChild()));
> +    int baseHeight = contentLogicalHeight();

You still need to round contentLogicalHeight as it returns a LayoutUnit.

> Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp:149
> +    LayoutUnit baseWrapperBaseline = toRenderBox(firstChild())->firstLineBoxBaseline();

You can use: baseWrapper->firstLineBoxBaseline()

> Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp:150
> +    LayoutUnit baseBaseline = baseWrapperBaseline - baseWrapper->paddingTop();

For consistency with the rest of the code who is writing-mode aware, it should be paddingBefore. Note that the rest of the code doesn't look really 100% writing mode proof so it shouldn't block the patch but at least that avoids one issue.

> Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp:153
> +    LayoutUnit superscriptHeight = superscriptWrapper->logicalHeight() - superscriptWrapper->paddingBottom();

Same comment as above it should be paddingAfter()

> Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp:158
> +        /* fall through */

For one line comment, WebKit uses // not /* */

This is very weird that over uses the under computation. I would have expected the other around for UnderOver.
Comment 14 Dave Barton 2012-06-21 22:51:00 PDT
Comment on attachment 147950 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=147950&action=review

Thanks as always for the review, Julien!

Sorry this patch looks so big, but hopefully it will be the last one to rebaseline all the MathML tests for a while.

>> Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp:149
>> +    LayoutUnit baseWrapperBaseline = toRenderBox(firstChild())->firstLineBoxBaseline();
> 
> You can use: baseWrapper->firstLineBoxBaseline()

That doesn't compile:
RenderBlock.h:425: error: 'virtual WebCore::LayoutUnit WebCore::RenderBlock::firstLineBoxBaseline() const' is protected

>> Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp:158
>> +        /* fall through */
> 
> For one line comment, WebKit uses // not /* */
> 
> This is very weird that over uses the under computation. I would have expected the other around for UnderOver.

To compute the UnderOver baseline, one must use the base's baseline in any case, plus the overscript's height if it exists.
Comment 15 Dave Barton 2012-06-21 22:59:02 PDT
Created attachment 148962 [details]
Patch
Comment 16 Eric Seidel (no email) 2012-08-01 16:09:29 PDT
Comment on attachment 148962 [details]
Patch

LGTM.  Thanks.
Comment 17 Eric Seidel (no email) 2012-08-01 16:09:56 PDT
Sorry this got ignore so long.  I've not been watching teh general review queue as closely as I should be.
Comment 18 WebKit Review Bot 2012-08-01 16:12:20 PDT
Comment on attachment 148962 [details]
Patch

Rejecting attachment 148962 [details] from commit-queue.

Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 2

Last 500 characters of output:
cted.txt
patching file LayoutTests/platform/mac/mathml/presentation/tables-expected.txt
patching file LayoutTests/platform/mac/mathml/presentation/tokenElements-expected.txt
patching file LayoutTests/platform/mac/mathml/presentation/under-expected.txt
patching file LayoutTests/platform/mac/mathml/presentation/underover-expected.txt

Failed to run "[u'/mnt/git/webkit-commit-queue/Tools/Scripts/svn-apply', u'--force', u'--reviewer', u'Eric Seidel']" exit_code: 1 cwd: /mnt/git/webkit-commit-queue/

Full output: http://queues.webkit.org/results/13415354
Comment 19 Dave Barton 2012-08-02 13:33:08 PDT
Thanks for the r+! I'll merge in the couple test rebaselines from bug 91677 and then try to land the result.
Comment 20 Dave Barton 2012-08-02 15:35:00 PDT
Committed r124512: <http://trac.webkit.org/changeset/124512>