Bug 156921 - Move selection and drawing of stretchy operators into a separate MathOperator class
Summary: Move selection and drawing of stretchy operators into a separate MathOperator...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: MathML (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Frédéric Wang (:fredw)
URL:
Keywords:
Depends on: 156906 156910 156913
Blocks: 152244 156950 157071
  Show dependency treegraph
 
Reported: 2016-04-22 12:50 PDT by Frédéric Wang (:fredw)
Modified: 2016-06-08 23:16 PDT (History)
3 users (show)

See Also:


Attachments
Patch (73.98 KB, patch)
2016-04-22 13:02 PDT, Frédéric Wang (:fredw)
no flags Details | Formatted Diff | Diff
Patch for EWS testing (81.81 KB, patch)
2016-04-22 13:03 PDT, Frédéric Wang (:fredw)
no flags Details | Formatted Diff | Diff
Patch for EWS testing (81.71 KB, patch)
2016-04-23 01:32 PDT, Frédéric Wang (:fredw)
no flags Details | Formatted Diff | Diff
Patch (74.95 KB, patch)
2016-04-25 01:03 PDT, Frédéric Wang (:fredw)
no flags Details | Formatted Diff | Diff
Patch (74.90 KB, patch)
2016-04-25 09:14 PDT, Frédéric Wang (:fredw)
no flags Details | Formatted Diff | Diff
Patch (74.86 KB, patch)
2016-04-26 05:07 PDT, Frédéric Wang (:fredw)
no flags Details | Formatted Diff | Diff
Patch (74.84 KB, patch)
2016-04-27 06:24 PDT, Frédéric Wang (:fredw)
no flags Details | Formatted Diff | Diff
Patch (75.41 KB, patch)
2016-05-09 00:50 PDT, Frédéric Wang (:fredw)
no flags Details | Formatted Diff | Diff
Patch (75.30 KB, patch)
2016-06-08 00:05 PDT, Frédéric Wang (:fredw)
mrobinson: review+
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-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>