Use size variants and glyph assembly from the MATH data.
authorfred.wang@free.fr <fred.wang@free.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 May 2014 04:56:50 +0000 (04:56 +0000)
committerfred.wang@free.fr <fred.wang@free.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 May 2014 04:56:50 +0000 (04:56 +0000)
commit4868f3151e031608f3d3f72592ba315af73c3707
tree6a029751503b2ec98d9c11c30a012c867e893ffa
parentfdf1a67124e0c8477c6eba8260a2bf86555cae8c
Use size variants and glyph assembly from the MATH data.
https://bugs.webkit.org/show_bug.cgi?id=130322

Reviewed by Chris Fleizach.

Source/WebCore:
This patch modifies the RenderMathMLOperator code to use the MATH table
when one is provided in the current font on the <math> tag. More
precisely, the MathVariants table is used to draw a size variant or
a glyph assembly. The displaystyle attribute is not supported yet, so
for now large operators are always assumed to be in display style. The
MATH support does not work well with all platforms+fonts, so at the
moment the default font-family on the <math> is not changed.

Tests: mathml/opentype/large-operators-LatinModern.html
       mathml/opentype/opentype-stretchy.html
       mathml/opentype/vertical-LatinModern.html

* css/mathml.css: We only specify the default font-family on the math root, so that people can easily style the mathematics.
For now, old fonts without the MATH table are still used as the default.
(math):
(math, mfenced > *): Deleted.
(mo, mfenced): Deleted.
* platform/graphics/SimpleFontData.cpp: don't return the math data if the font is loading.
(WebCore::SimpleFontData::mathData):
* platform/graphics/opentype/OpenTypeMathData.cpp: update #ifdef so that disabling ENABLE_OPENTYPE_MATH won't lead to errors with unused parameters.
(WebCore::OpenTypeMathData::OpenTypeMathData):
(WebCore::OpenTypeMathData::getMathConstant):
(WebCore::OpenTypeMathData::getItalicCorrection):
(WebCore::OpenTypeMathData::getMathVariants):
* rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::boundsForGlyph):
(WebCore::RenderMathMLOperator::heightForGlyph):
(WebCore::RenderMathMLOperator::advanceForGlyph):
(WebCore::RenderMathMLOperator::computePreferredLogicalWidths): We handle preferred width of size variants.
(WebCore::RenderMathMLOperator::shouldAllowStretching): This function now only returns whether the operator will stretch and no longer has side effect.
(WebCore::RenderMathMLOperator::getGlyphAssemblyFallBack): We add a function to convert from the MathVariant table data to the format supported by RenderMathMLOperator.
(WebCore::RenderMathMLOperator::getDisplayStyleLargeOperator): We add a function to get the glyph that will be used for large operators in display style.
(WebCore::RenderMathMLOperator::findStretchyData): We make this function handle size variants.
(WebCore::RenderMathMLOperator::updateStyle): We handle size variants.
(WebCore::RenderMathMLOperator::paint): We handle size variants.
* rendering/mathml/RenderMathMLOperator.h:

LayoutTests:
This adds some pixel tests for large operators and vertical stretchy operators.

* mathml/opentype/LICENSE-LatinModern.txt: Added.
* mathml/opentype/large-operators-LatinModern.html: Added.
* mathml/opentype/latinmodern-math.woff: Added.
* mathml/opentype/opentype-stretchy.html: Added.
* mathml/opentype/stretchy.woff: Added.
* mathml/opentype/vertical-LatinModern.html: Added.
* platform/efl/mathml/opentype/large-operators-LatinModern-expected.png: Added.
* platform/efl/mathml/opentype/large-operators-LatinModern-expected.txt: Added.
* platform/efl/mathml/opentype/opentype-stretchy-expected.png: Added.
* platform/efl/mathml/opentype/opentype-stretchy-expected.txt: Added.
* platform/efl/mathml/opentype/vertical-LatinModern-expected.png: Added.
* platform/efl/mathml/opentype/vertical-LatinModern-expected.txt: Added.
* platform/gtk/mathml/opentype/large-operators-LatinModern-expected.png: Added.
* platform/gtk/mathml/opentype/large-operators-LatinModern-expected.txt: Added.
* platform/gtk/mathml/opentype/opentype-stretchy-expected.png: Added.
* platform/gtk/mathml/opentype/opentype-stretchy-expected.txt: Added.
* platform/gtk/mathml/opentype/vertical-LatinModern-expected.png: Added.
* platform/gtk/mathml/opentype/vertical-LatinModern-expected.txt: Added.
* platform/gtk/mathml/presentation/mo-stretch-expected.png: update reference due to change in mathml.css
* platform/gtk/mathml/presentation/mo-stretch-expected.txt: ditto
* platform/mac/mathml/opentype/large-operators-LatinModern-expected.txt: Added.
* platform/mac/mathml/opentype/opentype-stretchy-expected.txt: Added.
* platform/mac/mathml/opentype/vertical-LatinModern-expected.txt: Added.
* platform/mac-wk2/mathml/opentype/large-operators-LatinModern-expected.txt: Added.
* platform/mac-wk2/mathml/opentype/opentype-stretchy-expected.txt: Added.
* platform/mac-wk2/mathml/opentype/vertical-LatinModern-expected.txt: Added.
* platform/win/TestExpectations: Mark the OpenType MATH tests as failing

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169305 268f45cc-cd09-0410-ab3c-d52691b4dbfc
34 files changed:
LayoutTests/ChangeLog
LayoutTests/mathml/opentype/LICENSE-LatinModern.txt [new file with mode: 0644]
LayoutTests/mathml/opentype/large-operators-LatinModern.html [new file with mode: 0644]
LayoutTests/mathml/opentype/latinmodern-math.woff [new file with mode: 0644]
LayoutTests/mathml/opentype/opentype-stretchy.html [new file with mode: 0644]
LayoutTests/mathml/opentype/stretchy.woff [new file with mode: 0644]
LayoutTests/mathml/opentype/vertical-LatinModern.html [new file with mode: 0644]
LayoutTests/platform/efl/mathml/opentype/large-operators-LatinModern-expected.png [new file with mode: 0644]
LayoutTests/platform/efl/mathml/opentype/large-operators-LatinModern-expected.txt [new file with mode: 0644]
LayoutTests/platform/efl/mathml/opentype/opentype-stretchy-expected.png [new file with mode: 0644]
LayoutTests/platform/efl/mathml/opentype/opentype-stretchy-expected.txt [new file with mode: 0644]
LayoutTests/platform/efl/mathml/opentype/vertical-LatinModern-expected.png [new file with mode: 0644]
LayoutTests/platform/efl/mathml/opentype/vertical-LatinModern-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/mathml/opentype/large-operators-LatinModern-expected.png [new file with mode: 0644]
LayoutTests/platform/gtk/mathml/opentype/large-operators-LatinModern-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/mathml/opentype/opentype-stretchy-expected.png [new file with mode: 0644]
LayoutTests/platform/gtk/mathml/opentype/opentype-stretchy-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/mathml/opentype/vertical-LatinModern-expected.png [new file with mode: 0644]
LayoutTests/platform/gtk/mathml/opentype/vertical-LatinModern-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/mathml/presentation/mo-stretch-expected.png
LayoutTests/platform/gtk/mathml/presentation/mo-stretch-expected.txt
LayoutTests/platform/mac-wk2/mathml/opentype/large-operators-LatinModern-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-wk2/mathml/opentype/opentype-stretchy-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-wk2/mathml/opentype/vertical-LatinModern-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/mathml/opentype/large-operators-LatinModern-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/mathml/opentype/opentype-stretchy-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/mathml/opentype/vertical-LatinModern-expected.txt [new file with mode: 0644]
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/css/mathml.css
Source/WebCore/platform/graphics/SimpleFontData.cpp
Source/WebCore/platform/graphics/opentype/OpenTypeMathData.cpp
Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp
Source/WebCore/rendering/mathml/RenderMathMLOperator.h