|
Lines 77-83
static const StretchyCharacter stretchyCharacters[14] = {
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec1
|
| 77 |
|
77 |
|
| 78 |
MathOperator::MathOperator() |
78 |
MathOperator::MathOperator() |
| 79 |
: m_baseCharacter(0) |
79 |
: m_baseCharacter(0) |
| 80 |
, m_isVertical(false) |
80 |
, m_operatorType(OperatorType::UndefinedOperator) |
| 81 |
, m_stretchType(StretchType::Unstretched) |
81 |
, m_stretchType(StretchType::Unstretched) |
| 82 |
, m_width(0) |
82 |
, m_width(0) |
| 83 |
, m_ascent(0) |
83 |
, m_ascent(0) |
|
Lines 86-95
MathOperator::MathOperator()
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec2
|
| 86 |
{ |
86 |
{ |
| 87 |
} |
87 |
} |
| 88 |
|
88 |
|
| 89 |
void MathOperator::setOperator(UChar baseCharacter, bool isVertical) |
89 |
void MathOperator::setOperator(UChar baseCharacter, OperatorType operatorType) |
| 90 |
{ |
90 |
{ |
| 91 |
m_baseCharacter = baseCharacter; |
91 |
m_baseCharacter = baseCharacter; |
| 92 |
m_isVertical = isVertical; |
92 |
m_operatorType = operatorType; |
| 93 |
} |
93 |
} |
| 94 |
|
94 |
|
| 95 |
bool MathOperator::getBaseGlyph(const RenderStyle& style, GlyphData& baseGlyph) const |
95 |
bool MathOperator::getBaseGlyph(const RenderStyle& style, GlyphData& baseGlyph) const |
|
Lines 107-119
void MathOperator::setSizeVariant(const GlyphData& sizeVariant)
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec3
|
| 107 |
|
107 |
|
| 108 |
void MathOperator::setGlyphAssembly(const GlyphAssemblyData& assemblyData) |
108 |
void MathOperator::setGlyphAssembly(const GlyphAssemblyData& assemblyData) |
| 109 |
{ |
109 |
{ |
|
|
110 |
ASSERT(m_operatorType == OperatorType::VerticalOperator || m_operatorType == OperatorType::HorizontalOperator); |
| 110 |
m_stretchType = StretchType::GlyphAssembly; |
111 |
m_stretchType = StretchType::GlyphAssembly; |
| 111 |
m_assembly = assemblyData; |
112 |
m_assembly = assemblyData; |
| 112 |
} |
113 |
} |
| 113 |
|
114 |
|
| 114 |
void MathOperator::calculateDisplayStyleLargeOperator(const RenderStyle& style) |
115 |
void MathOperator::calculateDisplayStyleLargeOperator(const RenderStyle& style) |
| 115 |
{ |
116 |
{ |
| 116 |
ASSERT(m_isVertical); |
117 |
ASSERT(m_operatorType == OperatorType::DisplayOperator); |
| 117 |
|
118 |
|
| 118 |
GlyphData baseGlyph; |
119 |
GlyphData baseGlyph; |
| 119 |
if (!getBaseGlyph(style, baseGlyph) || !baseGlyph.font->mathData()) |
120 |
if (!getBaseGlyph(style, baseGlyph) || !baseGlyph.font->mathData()) |
|
Lines 241-247
bool MathOperator::calculateGlyphAssemblyFallBack(const RenderStyle& style, cons
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec4
|
| 241 |
|
242 |
|
| 242 |
void MathOperator::calculateStretchyData(const RenderStyle& style, float* maximumGlyphWidth, LayoutUnit targetSize) |
243 |
void MathOperator::calculateStretchyData(const RenderStyle& style, float* maximumGlyphWidth, LayoutUnit targetSize) |
| 243 |
{ |
244 |
{ |
| 244 |
ASSERT(!maximumGlyphWidth || m_isVertical); |
245 |
ASSERT(m_operatorType == OperatorType::VerticalOperator || m_operatorType == OperatorType::HorizontalOperator); |
|
|
246 |
ASSERT(!maximumGlyphWidth || m_operatorType == OperatorType::VerticalOperator); |
| 247 |
bool isVertical = m_operatorType == OperatorType::VerticalOperator; |
| 245 |
|
248 |
|
| 246 |
GlyphData baseGlyph; |
249 |
GlyphData baseGlyph; |
| 247 |
if (!getBaseGlyph(style, baseGlyph)) |
250 |
if (!getBaseGlyph(style, baseGlyph)) |
|
Lines 249-255
void MathOperator::calculateStretchyData(const RenderStyle& style, float* maximu
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec5
|
| 249 |
|
252 |
|
| 250 |
if (!maximumGlyphWidth) { |
253 |
if (!maximumGlyphWidth) { |
| 251 |
// We do not stretch if the base glyph is large enough. |
254 |
// We do not stretch if the base glyph is large enough. |
| 252 |
float baseSize = m_isVertical ? heightForGlyph(baseGlyph) : advanceWidthForGlyph(baseGlyph); |
255 |
float baseSize = isVertical ? heightForGlyph(baseGlyph) : advanceWidthForGlyph(baseGlyph); |
| 253 |
if (targetSize <= baseSize) |
256 |
if (targetSize <= baseSize) |
| 254 |
return; |
257 |
return; |
| 255 |
} |
258 |
} |
|
Lines 258-264
void MathOperator::calculateStretchyData(const RenderStyle& style, float* maximu
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec6
|
| 258 |
if (baseGlyph.font->mathData()) { |
261 |
if (baseGlyph.font->mathData()) { |
| 259 |
Vector<Glyph> sizeVariants; |
262 |
Vector<Glyph> sizeVariants; |
| 260 |
Vector<OpenTypeMathData::AssemblyPart> assemblyParts; |
263 |
Vector<OpenTypeMathData::AssemblyPart> assemblyParts; |
| 261 |
baseGlyph.font->mathData()->getMathVariants(baseGlyph.glyph, m_isVertical, sizeVariants, assemblyParts); |
264 |
baseGlyph.font->mathData()->getMathVariants(baseGlyph.glyph, isVertical, sizeVariants, assemblyParts); |
| 262 |
// We verify the size variants. |
265 |
// We verify the size variants. |
| 263 |
for (auto& sizeVariant : sizeVariants) { |
266 |
for (auto& sizeVariant : sizeVariants) { |
| 264 |
GlyphData glyphData(sizeVariant, baseGlyph.font); |
267 |
GlyphData glyphData(sizeVariant, baseGlyph.font); |
|
Lines 266-272
void MathOperator::calculateStretchyData(const RenderStyle& style, float* maximu
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec7
|
| 266 |
*maximumGlyphWidth = std::max(*maximumGlyphWidth, advanceWidthForGlyph(glyphData)); |
269 |
*maximumGlyphWidth = std::max(*maximumGlyphWidth, advanceWidthForGlyph(glyphData)); |
| 267 |
else { |
270 |
else { |
| 268 |
setSizeVariant(glyphData); |
271 |
setSizeVariant(glyphData); |
| 269 |
float size = m_isVertical ? heightForGlyph(glyphData) : advanceWidthForGlyph(glyphData); |
272 |
float size = isVertical ? heightForGlyph(glyphData) : advanceWidthForGlyph(glyphData); |
| 270 |
if (size >= targetSize) |
273 |
if (size >= targetSize) |
| 271 |
return; |
274 |
return; |
| 272 |
} |
275 |
} |
|
Lines 276-282
void MathOperator::calculateStretchyData(const RenderStyle& style, float* maximu
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec8
|
| 276 |
if (!calculateGlyphAssemblyFallBack(style, assemblyParts, assemblyData)) |
279 |
if (!calculateGlyphAssemblyFallBack(style, assemblyParts, assemblyData)) |
| 277 |
return; |
280 |
return; |
| 278 |
} else { |
281 |
} else { |
| 279 |
if (!m_isVertical) |
282 |
if (!isVertical) |
| 280 |
return; |
283 |
return; |
| 281 |
|
284 |
|
| 282 |
// If the font does not have a MATH table, we fallback to the Unicode-only constructions. |
285 |
// If the font does not have a MATH table, we fallback to the Unicode-only constructions. |
|
Lines 314-320
void MathOperator::calculateStretchyData(const RenderStyle& style, float* maximu
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec9
|
| 314 |
} |
317 |
} |
| 315 |
|
318 |
|
| 316 |
// We ensure that the size is large enough to avoid glyph overlaps. |
319 |
// We ensure that the size is large enough to avoid glyph overlaps. |
| 317 |
float minSize = m_isVertical ? |
320 |
float minSize = isVertical ? |
| 318 |
heightForGlyph(assemblyData.topOrRight) + heightForGlyph(assemblyData.middle) + heightForGlyph(assemblyData.bottomOrLeft) |
321 |
heightForGlyph(assemblyData.topOrRight) + heightForGlyph(assemblyData.middle) + heightForGlyph(assemblyData.bottomOrLeft) |
| 319 |
: advanceWidthForGlyph(assemblyData.bottomOrLeft) + advanceWidthForGlyph(assemblyData.middle) + advanceWidthForGlyph(assemblyData.topOrRight); |
322 |
: advanceWidthForGlyph(assemblyData.bottomOrLeft) + advanceWidthForGlyph(assemblyData.middle) + advanceWidthForGlyph(assemblyData.topOrRight); |
| 320 |
if (minSize > targetSize) |
323 |
if (minSize > targetSize) |
|
Lines 377-383
LayoutRect MathOperator::paintGlyph(const RenderStyle& style, PaintInfo& info, c
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec10
|
| 377 |
|
380 |
|
| 378 |
void MathOperator::fillWithVerticalExtensionGlyph(const RenderStyle& style, PaintInfo& info, const LayoutPoint& from, const LayoutPoint& to) |
381 |
void MathOperator::fillWithVerticalExtensionGlyph(const RenderStyle& style, PaintInfo& info, const LayoutPoint& from, const LayoutPoint& to) |
| 379 |
{ |
382 |
{ |
| 380 |
ASSERT(m_isVertical); |
383 |
ASSERT(m_operatorType == OperatorType::VerticalOperator); |
| 381 |
ASSERT(m_stretchType == StretchType::GlyphAssembly); |
384 |
ASSERT(m_stretchType == StretchType::GlyphAssembly); |
| 382 |
ASSERT(m_assembly.extension.isValid()); |
385 |
ASSERT(m_assembly.extension.isValid()); |
| 383 |
ASSERT(from.y() <= to.y()); |
386 |
ASSERT(from.y() <= to.y()); |
|
Lines 415-421
void MathOperator::fillWithVerticalExtensionGlyph(const RenderStyle& style, Pain
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec11
|
| 415 |
|
418 |
|
| 416 |
void MathOperator::fillWithHorizontalExtensionGlyph(const RenderStyle& style, PaintInfo& info, const LayoutPoint& from, const LayoutPoint& to) |
419 |
void MathOperator::fillWithHorizontalExtensionGlyph(const RenderStyle& style, PaintInfo& info, const LayoutPoint& from, const LayoutPoint& to) |
| 417 |
{ |
420 |
{ |
| 418 |
ASSERT(!m_isVertical); |
421 |
ASSERT(m_operatorType == OperatorType::HorizontalOperator); |
| 419 |
ASSERT(m_stretchType == StretchType::GlyphAssembly); |
422 |
ASSERT(m_stretchType == StretchType::GlyphAssembly); |
| 420 |
ASSERT(m_assembly.extension.isValid()); |
423 |
ASSERT(m_assembly.extension.isValid()); |
| 421 |
ASSERT(from.x() <= to.x()); |
424 |
ASSERT(from.x() <= to.x()); |
|
Lines 451-457
void MathOperator::fillWithHorizontalExtensionGlyph(const RenderStyle& style, Pa
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec12
|
| 451 |
|
454 |
|
| 452 |
void MathOperator::paintVerticalGlyphAssembly(const RenderStyle& style, PaintInfo& info, const LayoutPoint& paintOffset) |
455 |
void MathOperator::paintVerticalGlyphAssembly(const RenderStyle& style, PaintInfo& info, const LayoutPoint& paintOffset) |
| 453 |
{ |
456 |
{ |
| 454 |
ASSERT(m_isVertical); |
457 |
ASSERT(m_operatorType == OperatorType::VerticalOperator); |
| 455 |
ASSERT(m_stretchType == StretchType::GlyphAssembly); |
458 |
ASSERT(m_stretchType == StretchType::GlyphAssembly); |
| 456 |
ASSERT(m_assembly.topOrRight.isValid()); |
459 |
ASSERT(m_assembly.topOrRight.isValid()); |
| 457 |
ASSERT(m_assembly.bottomOrLeft.isValid()); |
460 |
ASSERT(m_assembly.bottomOrLeft.isValid()); |
|
Lines 483-492
void MathOperator::paintVerticalGlyphAssembly(const RenderStyle& style, PaintInf
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec13
|
| 483 |
|
486 |
|
| 484 |
void MathOperator::paintHorizontalGlyphAssembly(const RenderStyle& style, PaintInfo& info, const LayoutPoint& paintOffset) |
487 |
void MathOperator::paintHorizontalGlyphAssembly(const RenderStyle& style, PaintInfo& info, const LayoutPoint& paintOffset) |
| 485 |
{ |
488 |
{ |
| 486 |
ASSERT(!m_isVertical); |
489 |
ASSERT(m_operatorType == OperatorType::HorizontalOperator); |
| 487 |
ASSERT(m_stretchType == StretchType::GlyphAssembly); |
490 |
ASSERT(m_stretchType == StretchType::GlyphAssembly); |
| 488 |
ASSERT(m_assembly.bottomOrLeft.isValid()); |
|
|
| 489 |
ASSERT(m_assembly.topOrRight.isValid()); |
491 |
ASSERT(m_assembly.topOrRight.isValid()); |
|
|
492 |
ASSERT(m_assembly.bottomOrLeft.isValid()); |
| 490 |
|
493 |
|
| 491 |
// We are positioning the glyphs so that the edge of the tight glyph bounds line up exactly with the edges of our paint box. |
494 |
// We are positioning the glyphs so that the edge of the tight glyph bounds line up exactly with the edges of our paint box. |
| 492 |
LayoutPoint operatorTopLeft = paintOffset; |
495 |
LayoutPoint operatorTopLeft = paintOffset; |