Bug 156921

Summary: Move selection and drawing of stretchy operators into a separate MathOperator class
Product: WebKit Reporter: Frédéric Wang (:fredw) <fred.wang>
Component: MathMLAssignee: Frédéric Wang (:fredw) <fred.wang>
Status: RESOLVED FIXED    
Severity: Normal CC: alex, mrobinson, rego
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 156906, 156910, 156913    
Bug Blocks: 152244, 156950, 157071    
Attachments:
Description Flags
Patch
none
Patch for EWS testing
none
Patch for EWS testing
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch mrobinson: review+

Description Frédéric Wang (:fredw) 2016-04-22 12:50:07 PDT
Yet another step towards bug 152244.
Comment 1 Frédéric Wang (:fredw) 2016-04-22 13:02:38 PDT
Created attachment 277087 [details]
Patch
Comment 2 Frédéric Wang (:fredw) 2016-04-22 13:03:11 PDT
Created attachment 277088 [details]
Patch for EWS testing
Comment 3 Frédéric Wang (:fredw) 2016-04-23 01:32:14 PDT
Created attachment 277144 [details]
Patch for EWS testing

I'm removing the ASSERT for large operator until we know the exact operator type (bug 156950).
Comment 4 Frédéric Wang (:fredw) 2016-04-25 01:03:44 PDT
Created attachment 277231 [details]
Patch

Update patch to fix conflict after bug 156846 and bug 156906.
Comment 5 Frédéric Wang (:fredw) 2016-04-25 09:14:53 PDT
Created attachment 277253 [details]
Patch
Comment 6 Frédéric Wang (:fredw) 2016-04-26 05:07:51 PDT
Created attachment 277355 [details]
Patch
Comment 7 Frédéric Wang (:fredw) 2016-04-27 06:24:01 PDT
Created attachment 277473 [details]
Patch

Minor change: Remove useless MathOperator:: prefix in setGlyphAssembly during the code move.
Comment 8 Frédéric Wang (:fredw) 2016-05-09 00:50:56 PDT
Created attachment 278390 [details]
Patch

Updating after https://trac.webkit.org/changeset/200569
Comment 9 Martin Robinson 2016-06-06 09:06:22 PDT
Comment on attachment 278390 [details]
Patch

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

Most of this is just code movement, so it looks good to me. I have a couple quick questions and nits though:

> Source/WebCore/rendering/mathml/MathOperator.cpp:85
> +    : m_baseCharacter(0)
> +    , m_isVertical(false)
> +    , m_stretchType(StretchType::Unstretched)
> +    , m_width(0)
> +    , m_ascent(0)
> +    , m_descent(0)
> +    , m_italicCorrection(0)

I think we are preferring in-class declaration initializers now. Perhaps that will allow you to remove this constructor.

http://www.stroustrup.com/C++11FAQ.html#member-init

> Source/WebCore/rendering/mathml/MathOperator.cpp:103
> +    ASSERT(sizeVariant.isValid() && sizeVariant.font->mathData());

Make this ASSERT two separate ASSERTs so it is easier to tell from a stack trace which one failed.

> Source/WebCore/rendering/mathml/MathOperator.cpp:128
> +    baseGlyph.font->mathData()->getMathVariants(baseGlyph.glyph, true, sizeVariants, assemblyParts);

Move the declaration of sizeVariants and assemblyParts right before this line.

> Source/WebCore/rendering/mathml/MathOperator.cpp:137
> +        GlyphData glyphData(sizeVariant, baseGlyph.font);
> +        setSizeVariant(glyphData);
> +        m_italicCorrection = glyphData.font->mathData()->getItalicCorrection(*glyphData.font, glyphData.glyph);
> +        if (heightForGlyph(glyphData) >= displayOperatorMinHeight)
> +            break;
> +    }

Why not wait to call setSizeVariant and set m_italicCorrection until heightForGlyph(glyphData) >= displayOperatorMinHeight is true?

> Source/WebCore/rendering/mathml/MathOperator.cpp:140
> +bool MathOperator::calculateGlyphAssemblyFallBack(const RenderStyle& style, const Vector<OpenTypeMathData::AssemblyPart>& assemblyParts, GlyphAssemblyData& assemblyData) const

Nit: FallBack -> Fallback
Comment 10 Frédéric Wang (:fredw) 2016-06-06 09:11:30 PDT
(In reply to comment #9)
> > Source/WebCore/rendering/mathml/MathOperator.cpp:85
> > +    : m_baseCharacter(0)
> > +    , m_isVertical(false)
> > +    , m_stretchType(StretchType::Unstretched)
> > +    , m_width(0)
> > +    , m_ascent(0)
> > +    , m_descent(0)
> > +    , m_italicCorrection(0)
> 
> I think we are preferring in-class declaration initializers now. Perhaps
> that will allow you to remove this constructor.

OK, I think I already did that in my branch after feedback in other patches :-)

> > Source/WebCore/rendering/mathml/MathOperator.cpp:137
> > +        GlyphData glyphData(sizeVariant, baseGlyph.font);
> > +        setSizeVariant(glyphData);
> > +        m_italicCorrection = glyphData.font->mathData()->getItalicCorrection(*glyphData.font, glyphData.glyph);
> > +        if (heightForGlyph(glyphData) >= displayOperatorMinHeight)
> > +            break;
> > +    }
> 
> Why not wait to call setSizeVariant and set m_italicCorrection until
> heightForGlyph(glyphData) >= displayOperatorMinHeight is true?

So the idea is that if we were not able to find a large enough stretchy operator, we use the latest (largest) one in the list as a fallback.
Comment 11 Martin Robinson 2016-06-06 10:01:42 PDT
(In reply to comment #10)

> > > Source/WebCore/rendering/mathml/MathOperator.cpp:137
> > > +        GlyphData glyphData(sizeVariant, baseGlyph.font);
> > > +        setSizeVariant(glyphData);
> > > +        m_italicCorrection = glyphData.font->mathData()->getItalicCorrection(*glyphData.font, glyphData.glyph);
> > > +        if (heightForGlyph(glyphData) >= displayOperatorMinHeight)
> > > +            break;
> > > +    }
> > 
> > Why not wait to call setSizeVariant and set m_italicCorrection until
> > heightForGlyph(glyphData) >= displayOperatorMinHeight is true?
> 
> So the idea is that if we were not able to find a large enough stretchy
> operator, we use the latest (largest) one in the list as a fallback.

Ah, I understand. Thanks!
Comment 12 Frédéric Wang (:fredw) 2016-06-08 00:05:21 PDT
Created attachment 280783 [details]
Patch
Comment 13 Frédéric Wang (:fredw) 2016-06-08 23:16:21 PDT
Committed r201854: <http://trac.webkit.org/changeset/201854>