|
Lines 94-100
void MathOperator::setOperator(const RenderStyle& style, UChar baseCharacter, Ty
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec1
|
| 94 |
|
94 |
|
| 95 |
void MathOperator::reset(const RenderStyle& style) |
95 |
void MathOperator::reset(const RenderStyle& style) |
| 96 |
{ |
96 |
{ |
| 97 |
m_stretchType = StretchType::Unstretched; |
97 |
m_variantOrAssembly = Nullopt; |
| 98 |
m_maxPreferredWidth = 0; |
98 |
m_maxPreferredWidth = 0; |
| 99 |
m_width = 0; |
99 |
m_width = 0; |
| 100 |
m_ascent = 0; |
100 |
m_ascent = 0; |
|
Lines 131-138
void MathOperator::setSizeVariant(const GlyphData& sizeVariant)
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec2
|
| 131 |
{ |
131 |
{ |
| 132 |
ASSERT(sizeVariant.font); |
132 |
ASSERT(sizeVariant.font); |
| 133 |
ASSERT(sizeVariant.font->mathData()); |
133 |
ASSERT(sizeVariant.font->mathData()); |
| 134 |
m_stretchType = StretchType::SizeVariant; |
134 |
m_variantOrAssembly = sizeVariant; |
| 135 |
m_variant = sizeVariant; |
|
|
| 136 |
m_width = advanceWidthForGlyph(sizeVariant); |
135 |
m_width = advanceWidthForGlyph(sizeVariant); |
| 137 |
getAscentAndDescentForGlyph(sizeVariant, m_ascent, m_descent); |
136 |
getAscentAndDescentForGlyph(sizeVariant, m_ascent, m_descent); |
| 138 |
} |
137 |
} |
|
Lines 140-167
void MathOperator::setSizeVariant(const GlyphData& sizeVariant)
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec3
|
| 140 |
void MathOperator::setGlyphAssembly(const GlyphAssemblyData& assemblyData) |
139 |
void MathOperator::setGlyphAssembly(const GlyphAssemblyData& assemblyData) |
| 141 |
{ |
140 |
{ |
| 142 |
ASSERT(m_operatorType == Type::VerticalOperator || m_operatorType == Type::HorizontalOperator); |
141 |
ASSERT(m_operatorType == Type::VerticalOperator || m_operatorType == Type::HorizontalOperator); |
| 143 |
m_stretchType = StretchType::GlyphAssembly; |
142 |
m_variantOrAssembly = assemblyData; |
| 144 |
m_assembly = assemblyData; |
|
|
| 145 |
if (m_operatorType == Type::VerticalOperator) { |
143 |
if (m_operatorType == Type::VerticalOperator) { |
| 146 |
m_width = 0; |
144 |
m_width = 0; |
| 147 |
m_width = std::max<LayoutUnit>(m_width, advanceWidthForGlyph(m_assembly.topOrRight)); |
145 |
m_width = std::max<LayoutUnit>(m_width, advanceWidthForGlyph(assemblyData.topOrRight)); |
| 148 |
m_width = std::max<LayoutUnit>(m_width, advanceWidthForGlyph(m_assembly.extension)); |
146 |
m_width = std::max<LayoutUnit>(m_width, advanceWidthForGlyph(assemblyData.extension)); |
| 149 |
m_width = std::max<LayoutUnit>(m_width, advanceWidthForGlyph(m_assembly.bottomOrLeft)); |
147 |
m_width = std::max<LayoutUnit>(m_width, advanceWidthForGlyph(assemblyData.bottomOrLeft)); |
| 150 |
m_width = std::max<LayoutUnit>(m_width, advanceWidthForGlyph(m_assembly.middle)); |
148 |
m_width = std::max<LayoutUnit>(m_width, advanceWidthForGlyph(assemblyData.middle)); |
| 151 |
} else { |
149 |
} else { |
| 152 |
m_ascent = 0; |
150 |
m_ascent = 0; |
| 153 |
m_descent = 0; |
151 |
m_descent = 0; |
| 154 |
LayoutUnit ascent, descent; |
152 |
LayoutUnit ascent, descent; |
| 155 |
getAscentAndDescentForGlyph(m_assembly.bottomOrLeft, ascent, descent); |
153 |
getAscentAndDescentForGlyph(assemblyData.bottomOrLeft, ascent, descent); |
| 156 |
m_ascent = std::max(m_ascent, ascent); |
154 |
m_ascent = std::max(m_ascent, ascent); |
| 157 |
m_descent = std::max(m_descent, descent); |
155 |
m_descent = std::max(m_descent, descent); |
| 158 |
getAscentAndDescentForGlyph(m_assembly.extension, ascent, descent); |
156 |
getAscentAndDescentForGlyph(assemblyData.extension, ascent, descent); |
| 159 |
m_ascent = std::max(m_ascent, ascent); |
157 |
m_ascent = std::max(m_ascent, ascent); |
| 160 |
m_descent = std::max(m_descent, descent); |
158 |
m_descent = std::max(m_descent, descent); |
| 161 |
getAscentAndDescentForGlyph(m_assembly.topOrRight, ascent, descent); |
159 |
getAscentAndDescentForGlyph(assemblyData.topOrRight, ascent, descent); |
| 162 |
m_ascent = std::max(m_ascent, ascent); |
160 |
m_ascent = std::max(m_ascent, ascent); |
| 163 |
m_descent = std::max(m_descent, descent); |
161 |
m_descent = std::max(m_descent, descent); |
| 164 |
getAscentAndDescentForGlyph(m_assembly.middle, ascent, descent); |
162 |
getAscentAndDescentForGlyph(assemblyData.middle, ascent, descent); |
| 165 |
m_ascent = std::max(m_ascent, ascent); |
163 |
m_ascent = std::max(m_ascent, ascent); |
| 166 |
m_descent = std::max(m_descent, descent); |
164 |
m_descent = std::max(m_descent, descent); |
| 167 |
} |
165 |
} |
|
Lines 439-445
void MathOperator::stretchTo(const RenderStyle& style, LayoutUnit targetSize)
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec4
|
| 439 |
{ |
437 |
{ |
| 440 |
ASSERT(m_operatorType == Type::VerticalOperator || m_operatorType == Type::HorizontalOperator); |
438 |
ASSERT(m_operatorType == Type::VerticalOperator || m_operatorType == Type::HorizontalOperator); |
| 441 |
calculateStretchyData(style, false, targetSize); |
439 |
calculateStretchyData(style, false, targetSize); |
| 442 |
if (m_stretchType == StretchType::GlyphAssembly) { |
440 |
if (isAssembly()) { |
| 443 |
if (m_operatorType == Type::VerticalOperator) { |
441 |
if (m_operatorType == Type::VerticalOperator) { |
| 444 |
m_ascent = targetSize; |
442 |
m_ascent = targetSize; |
| 445 |
m_descent = 0; |
443 |
m_descent = 0; |
|
Lines 503-510
LayoutRect MathOperator::paintGlyph(const RenderStyle& style, PaintInfo& info, c
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec5
|
| 503 |
void MathOperator::fillWithVerticalExtensionGlyph(const RenderStyle& style, PaintInfo& info, const LayoutPoint& from, const LayoutPoint& to) |
501 |
void MathOperator::fillWithVerticalExtensionGlyph(const RenderStyle& style, PaintInfo& info, const LayoutPoint& from, const LayoutPoint& to) |
| 504 |
{ |
502 |
{ |
| 505 |
ASSERT(m_operatorType == Type::VerticalOperator); |
503 |
ASSERT(m_operatorType == Type::VerticalOperator); |
| 506 |
ASSERT(m_stretchType == StretchType::GlyphAssembly); |
504 |
ASSERT(isAssembly()); |
| 507 |
ASSERT(m_assembly.extension.font); |
505 |
auto& assembly = this->assembly(); |
|
|
506 |
ASSERT(assembly.extension.font); |
| 508 |
ASSERT(from.y() <= to.y()); |
507 |
ASSERT(from.y() <= to.y()); |
| 509 |
|
508 |
|
| 510 |
// If there is no space for the extension glyph, we don't need to do anything. |
509 |
// If there is no space for the extension glyph, we don't need to do anything. |
|
Lines 513-519
void MathOperator::fillWithVerticalExtensionGlyph(const RenderStyle& style, Pain
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec6
|
| 513 |
|
512 |
|
| 514 |
GraphicsContextStateSaver stateSaver(info.context()); |
513 |
GraphicsContextStateSaver stateSaver(info.context()); |
| 515 |
|
514 |
|
| 516 |
FloatRect glyphBounds = boundsForGlyph(m_assembly.extension); |
515 |
FloatRect glyphBounds = boundsForGlyph(assembly.extension); |
| 517 |
|
516 |
|
| 518 |
// Clipping the extender region here allows us to draw the bottom extender glyph into the |
517 |
// Clipping the extender region here allows us to draw the bottom extender glyph into the |
| 519 |
// regions of the bottom glyph without worrying about overdraw (hairy pixels) and simplifies later clipping. |
518 |
// regions of the bottom glyph without worrying about overdraw (hairy pixels) and simplifies later clipping. |
|
Lines 529-535
void MathOperator::fillWithVerticalExtensionGlyph(const RenderStyle& style, Pain
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec7
|
| 529 |
|
528 |
|
| 530 |
// In practice, only small stretch sizes are requested but we limit the number of glyphs to avoid hangs. |
529 |
// In practice, only small stretch sizes are requested but we limit the number of glyphs to avoid hangs. |
| 531 |
for (unsigned extensionCount = 0; lastPaintedGlyphRect.maxY() < to.y() && extensionCount < kMaximumExtensionCount; extensionCount++) { |
530 |
for (unsigned extensionCount = 0; lastPaintedGlyphRect.maxY() < to.y() && extensionCount < kMaximumExtensionCount; extensionCount++) { |
| 532 |
lastPaintedGlyphRect = paintGlyph(style, info, m_assembly.extension, glyphOrigin, TrimTopAndBottom); |
531 |
lastPaintedGlyphRect = paintGlyph(style, info, assembly.extension, glyphOrigin, TrimTopAndBottom); |
| 533 |
glyphOrigin.setY(glyphOrigin.y() + lastPaintedGlyphRect.height()); |
532 |
glyphOrigin.setY(glyphOrigin.y() + lastPaintedGlyphRect.height()); |
| 534 |
|
533 |
|
| 535 |
// There's a chance that if the font size is small enough the glue glyph has been reduced to an empty rectangle |
534 |
// There's a chance that if the font size is small enough the glue glyph has been reduced to an empty rectangle |
|
Lines 542-549
void MathOperator::fillWithVerticalExtensionGlyph(const RenderStyle& style, Pain
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec8
|
| 542 |
void MathOperator::fillWithHorizontalExtensionGlyph(const RenderStyle& style, PaintInfo& info, const LayoutPoint& from, const LayoutPoint& to) |
541 |
void MathOperator::fillWithHorizontalExtensionGlyph(const RenderStyle& style, PaintInfo& info, const LayoutPoint& from, const LayoutPoint& to) |
| 543 |
{ |
542 |
{ |
| 544 |
ASSERT(m_operatorType == Type::HorizontalOperator); |
543 |
ASSERT(m_operatorType == Type::HorizontalOperator); |
| 545 |
ASSERT(m_stretchType == StretchType::GlyphAssembly); |
544 |
ASSERT(isAssembly()); |
| 546 |
ASSERT(m_assembly.extension.font); |
545 |
auto& assembly = this->assembly(); |
|
|
546 |
ASSERT(assembly.extension.font); |
| 547 |
ASSERT(from.x() <= to.x()); |
547 |
ASSERT(from.x() <= to.x()); |
| 548 |
ASSERT(from.y() == to.y()); |
548 |
ASSERT(from.y() == to.y()); |
| 549 |
|
549 |
|
|
Lines 567-573
void MathOperator::fillWithHorizontalExtensionGlyph(const RenderStyle& style, Pa
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec9
|
| 567 |
|
567 |
|
| 568 |
// In practice, only small stretch sizes are requested but we limit the number of glyphs to avoid hangs. |
568 |
// In practice, only small stretch sizes are requested but we limit the number of glyphs to avoid hangs. |
| 569 |
for (unsigned extensionCount = 0; lastPaintedGlyphRect.maxX() < to.x() && extensionCount < kMaximumExtensionCount; extensionCount++) { |
569 |
for (unsigned extensionCount = 0; lastPaintedGlyphRect.maxX() < to.x() && extensionCount < kMaximumExtensionCount; extensionCount++) { |
| 570 |
lastPaintedGlyphRect = paintGlyph(style, info, m_assembly.extension, glyphOrigin, TrimLeftAndRight); |
570 |
lastPaintedGlyphRect = paintGlyph(style, info, assembly.extension, glyphOrigin, TrimLeftAndRight); |
| 571 |
glyphOrigin.setX(glyphOrigin.x() + lastPaintedGlyphRect.width()); |
571 |
glyphOrigin.setX(glyphOrigin.x() + lastPaintedGlyphRect.width()); |
| 572 |
|
572 |
|
| 573 |
// There's a chance that if the font size is small enough the glue glyph has been reduced to an empty rectangle |
573 |
// There's a chance that if the font size is small enough the glue glyph has been reduced to an empty rectangle |
|
Lines 580-607
void MathOperator::fillWithHorizontalExtensionGlyph(const RenderStyle& style, Pa
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec10
|
| 580 |
void MathOperator::paintVerticalGlyphAssembly(const RenderStyle& style, PaintInfo& info, const LayoutPoint& paintOffset) |
580 |
void MathOperator::paintVerticalGlyphAssembly(const RenderStyle& style, PaintInfo& info, const LayoutPoint& paintOffset) |
| 581 |
{ |
581 |
{ |
| 582 |
ASSERT(m_operatorType == Type::VerticalOperator); |
582 |
ASSERT(m_operatorType == Type::VerticalOperator); |
| 583 |
ASSERT(m_stretchType == StretchType::GlyphAssembly); |
583 |
ASSERT(isAssembly()); |
| 584 |
ASSERT(m_assembly.topOrRight.font); |
584 |
auto& assembly = this->assembly(); |
| 585 |
ASSERT(m_assembly.bottomOrLeft.font); |
585 |
ASSERT(assembly.topOrRight.font); |
|
|
586 |
ASSERT(assembly.bottomOrLeft.font); |
| 586 |
|
587 |
|
| 587 |
// We are positioning the glyphs so that the edge of the tight glyph bounds line up exactly with the edges of our paint box. |
588 |
// We are positioning the glyphs so that the edge of the tight glyph bounds line up exactly with the edges of our paint box. |
| 588 |
LayoutPoint operatorTopLeft = paintOffset; |
589 |
LayoutPoint operatorTopLeft = paintOffset; |
| 589 |
FloatRect topGlyphBounds = boundsForGlyph(m_assembly.topOrRight); |
590 |
FloatRect topGlyphBounds = boundsForGlyph(assembly.topOrRight); |
| 590 |
LayoutPoint topGlyphOrigin(operatorTopLeft.x(), operatorTopLeft.y() - topGlyphBounds.y()); |
591 |
LayoutPoint topGlyphOrigin(operatorTopLeft.x(), operatorTopLeft.y() - topGlyphBounds.y()); |
| 591 |
LayoutRect topGlyphPaintRect = paintGlyph(style, info, m_assembly.topOrRight, topGlyphOrigin, TrimBottom); |
592 |
LayoutRect topGlyphPaintRect = paintGlyph(style, info, assembly.topOrRight, topGlyphOrigin, TrimBottom); |
| 592 |
|
593 |
|
| 593 |
FloatRect bottomGlyphBounds = boundsForGlyph(m_assembly.bottomOrLeft); |
594 |
FloatRect bottomGlyphBounds = boundsForGlyph(assembly.bottomOrLeft); |
| 594 |
LayoutPoint bottomGlyphOrigin(operatorTopLeft.x(), operatorTopLeft.y() + stretchSize() - (bottomGlyphBounds.height() + bottomGlyphBounds.y())); |
595 |
LayoutPoint bottomGlyphOrigin(operatorTopLeft.x(), operatorTopLeft.y() + stretchSize() - (bottomGlyphBounds.height() + bottomGlyphBounds.y())); |
| 595 |
LayoutRect bottomGlyphPaintRect = paintGlyph(style, info, m_assembly.bottomOrLeft, bottomGlyphOrigin, TrimTop); |
596 |
LayoutRect bottomGlyphPaintRect = paintGlyph(style, info, assembly.bottomOrLeft, bottomGlyphOrigin, TrimTop); |
| 596 |
|
597 |
|
| 597 |
if (m_assembly.middle.font) { |
598 |
if (assembly.middle.font) { |
| 598 |
// Center the glyph origin between the start and end glyph paint extents. Then shift it half the paint height toward the bottom glyph. |
599 |
// Center the glyph origin between the start and end glyph paint extents. Then shift it half the paint height toward the bottom glyph. |
| 599 |
FloatRect middleGlyphBounds = boundsForGlyph(m_assembly.middle); |
600 |
FloatRect middleGlyphBounds = boundsForGlyph(assembly.middle); |
| 600 |
LayoutPoint middleGlyphOrigin(operatorTopLeft.x(), topGlyphOrigin.y()); |
601 |
LayoutPoint middleGlyphOrigin(operatorTopLeft.x(), topGlyphOrigin.y()); |
| 601 |
middleGlyphOrigin.moveBy(LayoutPoint(0, (bottomGlyphPaintRect.y() - topGlyphPaintRect.maxY()) / 2.0)); |
602 |
middleGlyphOrigin.moveBy(LayoutPoint(0, (bottomGlyphPaintRect.y() - topGlyphPaintRect.maxY()) / 2.0)); |
| 602 |
middleGlyphOrigin.moveBy(LayoutPoint(0, middleGlyphBounds.height() / 2.0)); |
603 |
middleGlyphOrigin.moveBy(LayoutPoint(0, middleGlyphBounds.height() / 2.0)); |
| 603 |
|
604 |
|
| 604 |
LayoutRect middleGlyphPaintRect = paintGlyph(style, info, m_assembly.middle, middleGlyphOrigin, TrimTopAndBottom); |
605 |
LayoutRect middleGlyphPaintRect = paintGlyph(style, info, assembly.middle, middleGlyphOrigin, TrimTopAndBottom); |
| 605 |
fillWithVerticalExtensionGlyph(style, info, topGlyphPaintRect.minXMaxYCorner(), middleGlyphPaintRect.minXMinYCorner()); |
606 |
fillWithVerticalExtensionGlyph(style, info, topGlyphPaintRect.minXMaxYCorner(), middleGlyphPaintRect.minXMinYCorner()); |
| 606 |
fillWithVerticalExtensionGlyph(style, info, middleGlyphPaintRect.minXMaxYCorner(), bottomGlyphPaintRect.minXMinYCorner()); |
607 |
fillWithVerticalExtensionGlyph(style, info, middleGlyphPaintRect.minXMaxYCorner(), bottomGlyphPaintRect.minXMinYCorner()); |
| 607 |
} else |
608 |
} else |
|
Lines 611-635
void MathOperator::paintVerticalGlyphAssembly(const RenderStyle& style, PaintInf
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec11
|
| 611 |
void MathOperator::paintHorizontalGlyphAssembly(const RenderStyle& style, PaintInfo& info, const LayoutPoint& paintOffset) |
612 |
void MathOperator::paintHorizontalGlyphAssembly(const RenderStyle& style, PaintInfo& info, const LayoutPoint& paintOffset) |
| 612 |
{ |
613 |
{ |
| 613 |
ASSERT(m_operatorType == Type::HorizontalOperator); |
614 |
ASSERT(m_operatorType == Type::HorizontalOperator); |
| 614 |
ASSERT(m_stretchType == StretchType::GlyphAssembly); |
615 |
ASSERT(isAssembly()); |
| 615 |
ASSERT(m_assembly.bottomOrLeft.font); |
616 |
auto& assembly = this->assembly(); |
| 616 |
ASSERT(m_assembly.topOrRight.font); |
617 |
ASSERT(assembly.bottomOrLeft.font); |
|
|
618 |
ASSERT(assembly.topOrRight.font); |
| 617 |
|
619 |
|
| 618 |
// We are positioning the glyphs so that the edge of the tight glyph bounds line up exactly with the edges of our paint box. |
620 |
// We are positioning the glyphs so that the edge of the tight glyph bounds line up exactly with the edges of our paint box. |
| 619 |
LayoutPoint operatorTopLeft = paintOffset; |
621 |
LayoutPoint operatorTopLeft = paintOffset; |
| 620 |
LayoutUnit baselineY = operatorTopLeft.y() + m_ascent; |
622 |
LayoutUnit baselineY = operatorTopLeft.y() + m_ascent; |
| 621 |
LayoutPoint leftGlyphOrigin(operatorTopLeft.x(), baselineY); |
623 |
LayoutPoint leftGlyphOrigin(operatorTopLeft.x(), baselineY); |
| 622 |
LayoutRect leftGlyphPaintRect = paintGlyph(style, info, m_assembly.bottomOrLeft, leftGlyphOrigin, TrimRight); |
624 |
LayoutRect leftGlyphPaintRect = paintGlyph(style, info, assembly.bottomOrLeft, leftGlyphOrigin, TrimRight); |
| 623 |
|
625 |
|
| 624 |
FloatRect rightGlyphBounds = boundsForGlyph(m_assembly.topOrRight); |
626 |
FloatRect rightGlyphBounds = boundsForGlyph(assembly.topOrRight); |
| 625 |
LayoutPoint rightGlyphOrigin(operatorTopLeft.x() + stretchSize() - rightGlyphBounds.width(), baselineY); |
627 |
LayoutPoint rightGlyphOrigin(operatorTopLeft.x() + stretchSize() - rightGlyphBounds.width(), baselineY); |
| 626 |
LayoutRect rightGlyphPaintRect = paintGlyph(style, info, m_assembly.topOrRight, rightGlyphOrigin, TrimLeft); |
628 |
LayoutRect rightGlyphPaintRect = paintGlyph(style, info, assembly.topOrRight, rightGlyphOrigin, TrimLeft); |
| 627 |
|
629 |
|
| 628 |
if (m_assembly.middle.font) { |
630 |
if (assembly.middle.font) { |
| 629 |
// Center the glyph origin between the start and end glyph paint extents. |
631 |
// Center the glyph origin between the start and end glyph paint extents. |
| 630 |
LayoutPoint middleGlyphOrigin(operatorTopLeft.x(), baselineY); |
632 |
LayoutPoint middleGlyphOrigin(operatorTopLeft.x(), baselineY); |
| 631 |
middleGlyphOrigin.moveBy(LayoutPoint((rightGlyphPaintRect.x() - leftGlyphPaintRect.maxX()) / 2.0, 0)); |
633 |
middleGlyphOrigin.moveBy(LayoutPoint((rightGlyphPaintRect.x() - leftGlyphPaintRect.maxX()) / 2.0, 0)); |
| 632 |
LayoutRect middleGlyphPaintRect = paintGlyph(style, info, m_assembly.middle, middleGlyphOrigin, TrimLeftAndRight); |
634 |
LayoutRect middleGlyphPaintRect = paintGlyph(style, info, assembly.middle, middleGlyphOrigin, TrimLeftAndRight); |
| 633 |
fillWithHorizontalExtensionGlyph(style, info, LayoutPoint(leftGlyphPaintRect.maxX(), baselineY), LayoutPoint(middleGlyphPaintRect.x(), baselineY)); |
635 |
fillWithHorizontalExtensionGlyph(style, info, LayoutPoint(leftGlyphPaintRect.maxX(), baselineY), LayoutPoint(middleGlyphPaintRect.x(), baselineY)); |
| 634 |
fillWithHorizontalExtensionGlyph(style, info, LayoutPoint(middleGlyphPaintRect.maxX(), baselineY), LayoutPoint(rightGlyphPaintRect.x(), baselineY)); |
636 |
fillWithHorizontalExtensionGlyph(style, info, LayoutPoint(middleGlyphPaintRect.maxX(), baselineY), LayoutPoint(rightGlyphPaintRect.x(), baselineY)); |
| 635 |
} else |
637 |
} else |
|
Lines 656-662
void MathOperator::paint(const RenderStyle& style, PaintInfo& info, const Layout
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec12
|
| 656 |
} |
658 |
} |
| 657 |
} |
659 |
} |
| 658 |
|
660 |
|
| 659 |
if (m_stretchType == StretchType::GlyphAssembly) { |
661 |
if (isAssembly()) { |
| 660 |
if (m_operatorType == Type::VerticalOperator) |
662 |
if (m_operatorType == Type::VerticalOperator) |
| 661 |
paintVerticalGlyphAssembly(style, info, paintOffset); |
663 |
paintVerticalGlyphAssembly(style, info, paintOffset); |
| 662 |
else |
664 |
else |
|
Lines 665-677
void MathOperator::paint(const RenderStyle& style, PaintInfo& info, const Layout
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec13
|
| 665 |
} |
667 |
} |
| 666 |
|
668 |
|
| 667 |
GlyphData glyphData; |
669 |
GlyphData glyphData; |
| 668 |
ASSERT(m_stretchType == StretchType::Unstretched || m_stretchType == StretchType::SizeVariant); |
670 |
ASSERT(!m_variantOrAssembly || isVariant()); |
| 669 |
if (m_stretchType == StretchType::Unstretched) { |
671 |
if (!m_variantOrAssembly) { |
| 670 |
if (!getBaseGlyph(style, glyphData)) |
672 |
if (!getBaseGlyph(style, glyphData)) |
| 671 |
return; |
673 |
return; |
| 672 |
} else if (m_stretchType == StretchType::SizeVariant) { |
674 |
} else if (isVariant()) { |
| 673 |
ASSERT(m_variant.font); |
675 |
auto& variant = this->variant(); |
| 674 |
glyphData = m_variant; |
676 |
ASSERT(variant.font); |
|
|
677 |
glyphData = variant; |
| 675 |
} |
678 |
} |
| 676 |
GlyphBuffer buffer; |
679 |
GlyphBuffer buffer; |
| 677 |
buffer.add(glyphData.glyph, glyphData.font, advanceWidthForGlyph(glyphData)); |
680 |
buffer.add(glyphData.glyph, glyphData.font, advanceWidthForGlyph(glyphData)); |
|
Lines 681-686
void MathOperator::paint(const RenderStyle& style, PaintInfo& info, const Layout
a/Source/WebCore/rendering/mathml/MathOperator.cpp_sec14
|
| 681 |
paintInfo.context().drawGlyphs(style.fontCascade(), *glyphData.font, buffer, 0, 1, operatorOrigin); |
684 |
paintInfo.context().drawGlyphs(style.fontCascade(), *glyphData.font, buffer, 0, 1, operatorOrigin); |
| 682 |
} |
685 |
} |
| 683 |
|
686 |
|
|
|
687 |
bool MathOperator::isVariant() const |
| 688 |
{ |
| 689 |
if (!m_variantOrAssembly) |
| 690 |
return false; |
| 691 |
|
| 692 |
bool result = false; |
| 693 |
auto visitor = WTF::makeVisitor( |
| 694 |
[&](GlyphData&) { result = true; }, |
| 695 |
[&](GlyphAssemblyData&) { result = false; } |
| 696 |
); |
| 697 |
std::experimental::visit(visitor, m_variantOrAssembly); |
| 698 |
return result; |
| 699 |
} |
| 700 |
|
| 701 |
bool MathOperator::isAssembly() const |
| 702 |
{ |
| 703 |
if (!m_variantOrAssembly) |
| 704 |
return false; |
| 705 |
|
| 706 |
bool result = false; |
| 707 |
auto visitor = WTF::makeVisitor( |
| 708 |
[&](GlyphData&) { result = false; }, |
| 709 |
[&](GlyphAssemblyData&) { result = true; } |
| 710 |
); |
| 711 |
std::experimental::visit(visitor, m_variantOrAssembly); |
| 712 |
return result; |
| 713 |
} |
| 714 |
|
| 715 |
GlyphData& MathOperator::variant() |
| 716 |
{ |
| 717 |
ASSERT(m_variantOrAssembly); |
| 718 |
GlyphData* result = nullptr; |
| 719 |
auto visitor = WTF::makeVisitor( |
| 720 |
[&](GlyphData& m_variant) { result = &m_variant; }, |
| 721 |
[&](GlyphAssemblyData&) { CRASH_WITH_SECURITY_IMPLICATION(); } |
| 722 |
); |
| 723 |
std::experimental::visit(visitor, m_variantOrAssembly.value()); |
| 724 |
return *result; |
| 725 |
} |
| 726 |
|
| 727 |
GlyphAssemblyData& MathOperator::assembly() |
| 728 |
{ |
| 729 |
ASSERT(m_variantOrAssembly); |
| 730 |
GlyphAssemblyData* result = nullptr; |
| 731 |
auto visitor = WTF::makeVisitor( |
| 732 |
[&](GlyphData&) { CRASH_WITH_SECURITY_IMPLICATION() }, |
| 733 |
[&](GlyphAssemblyData&, m_assembly) { result = &m_assembly; } |
| 734 |
); |
| 735 |
std::experimental::visit(visitor, m_variantOrAssembly.value()); |
| 736 |
return *result; |
| 737 |
} |
| 738 |
|
| 684 |
} |
739 |
} |
| 685 |
|
740 |
|
| 686 |
#endif |
741 |
#endif |