MathML operators not stretched horizontally
authorfred.wang@free.fr <fred.wang@free.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jun 2014 06:35:04 +0000 (06:35 +0000)
committerfred.wang@free.fr <fred.wang@free.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Jun 2014 06:35:04 +0000 (06:35 +0000)
commite8ef914c9b41e90595817fa9cdd12cbf1fa7925a
treeeefdcc1d05890888fa6f34781f354e99dd14e93d
parent239dedd1b45a9e879779ac575d29ca4fac690e00
MathML operators not stretched horizontally
https://bugs.webkit.org/show_bug.cgi?id=72828

Reviewed by Chris Fleizach.

Source/WebCore:
This patch adds basic horizontal stretching rules for operators inside
an <munder>, <mover> or <munderover> elements. The stretchy operators
in such an element stretch to cover the size of the non-stretchy
operators. This only works when fonts that have an OpenType MATH table
are used.

Tests: mathml/opentype/horizontal-LatinModern.html
       mathml/opentype/opentype-stretchy-horizontal.html
       mathml/opentype/horizontal-LatinModern-munderover.html

* rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::MathMLOperatorDictionary::ExtractKeyHorizontal): We add an ordered list of operators that have horizontal stretch direction.
(WebCore::RenderMathMLOperator::RenderMathMLOperator): init m_Vertical
(WebCore::RenderMathMLOperator::SetOperatorProperties): set m_Vertical by checking whether the operator is in the horizontalOperators list.
(WebCore::RenderMathMLOperator::stretchTo): We do not stretch vertically
if the operator has horizontal direction.
We also add a new version stretchTo(LayoutUnit width) for horizontal stretching only.
(WebCore::RenderMathMLOperator::computePreferredLogicalWidths): Handle horizontal stretching: the maximumGlyphWidth is the maximum of
the base size or of the stretch size.
(WebCore::RenderMathMLOperator::getDisplayStyleLargeOperator): Add an ASSERT to ensure that this function is only called for vertical stretching.
(WebCore::RenderMathMLOperator::findStretchyData): Add an ASSERT to ensure that this function is not called to get the maximum width of a horizontal stretchy operator.
We take into account m_isVertical when calling getMathVariants or computing sizes.
There is not any Unicode-only construction for horizontal stretching, so a MATH table is required for horizontal stretching.
(WebCore::RenderMathMLOperator::updateStyle): Ignore some code paths specific to vertical stretching and take into account the m_Vertical parameters.
For horizontal stretching, the m_stretch*Baseline parameters are now updated to match the metrics of the size variant or of the maximum of the parts in the glyph assembly.
(WebCore::RenderMathMLOperator::computeLogicalHeight): logicalHeight is now explicitely the sum of m_stretchHeightAboveBaseline and m_stretchDepthBelowBaseline, since it can be different from the stretchSize() in horizontal stretching.
(WebCore::RenderMathMLOperator::paintGlyph): handle trimming for horizontal stretching.
(WebCore::RenderMathMLOperator::fillWithVerticalExtensionGlyph): rename the function and ensure it is only call for m_isVertical.
(WebCore::RenderMathMLOperator::fillWithHorizontalExtensionGlyph): same as fillWithVerticalExtensionGlyph, but for horizontal stretching.
(WebCore::RenderMathMLOperator::paint): For glyph assembly, choose between paintVerticalGlyphAssembly or paintHorizontalGlyphAssembly.
(WebCore::RenderMathMLOperator::paintVerticalGlyphAssembly): rename the function and ensure it is only call for m_isVertical.
(WebCore::RenderMathMLOperator::paintHorizontalGlyphAssembly): same as paintVerticalGlyphAssembly but for horizontal stretching.
* rendering/mathml/RenderMathMLOperator.h: we add a m_isVertical member to indicate the stretch direction and a m_stretchWidth to indicate the width of the stretchy character.
We define the horizontal counterparts of fillWith*ExtensionGlyph, paint*GlyphAssembly, GlyphPaintTrimming  StretchyData.
Finally stretchSize() takes into account the stretch direction.
* rendering/mathml/RenderMathMLUnderOver.cpp: We override the layout() function to stretch munderover children horizontally.
(WebCore::RenderMathMLUnderOver::layout):
* rendering/mathml/RenderMathMLUnderOver.h: we declare layout().

LayoutTests:
Add some tests to verify horizontal stretching with the MATH data.

* mathml/opentype/horizontal-LatinModern-munderover.html: Added.
* mathml/opentype/horizontal-LatinModern.html: Added.
* mathml/opentype/opentype-stretchy-horizontal.html: Added.
* platform/efl/TestExpectations: mark tests as failing.
* platform/gtk/mathml/opentype/horizontal-LatinModern-expected.png: Added.
* platform/gtk/mathml/opentype/horizontal-LatinModern-expected.txt: Added.
* platform/gtk/mathml/opentype/horizontal-LatinModern-munderover-expected.png: Added.
* platform/gtk/mathml/opentype/horizontal-LatinModern-munderover-expected.txt: Added.
* platform/gtk/mathml/opentype/opentype-stretchy-horizontal-expected.png: Added.
* platform/gtk/mathml/opentype/opentype-stretchy-horizontal-expected.txt: Added.
* platform/mac/TestExpectations: mark tests as failing.
* platform/win/TestExpectations: ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169607 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/mathml/opentype/horizontal-LatinModern-munderover.html [new file with mode: 0644]
LayoutTests/mathml/opentype/horizontal-LatinModern.html [new file with mode: 0644]
LayoutTests/mathml/opentype/opentype-stretchy-horizontal.html [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/mathml/opentype/horizontal-LatinModern-expected.png [new file with mode: 0644]
LayoutTests/platform/gtk/mathml/opentype/horizontal-LatinModern-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/mathml/opentype/horizontal-LatinModern-munderover-expected.png [new file with mode: 0644]
LayoutTests/platform/gtk/mathml/opentype/horizontal-LatinModern-munderover-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/mathml/opentype/opentype-stretchy-horizontal-expected.png [new file with mode: 0644]
LayoutTests/platform/gtk/mathml/opentype/opentype-stretchy-horizontal-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp
Source/WebCore/rendering/mathml/RenderMathMLOperator.h
Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp
Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h