Changeset 200185 in webkit
- Timestamp:
- Apr 28, 2016 5:09:38 AM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r200184 r200185 1 2016-04-28 Frederic Wang <fred.wang@free.fr> 2 3 RenderMathMLOperator refactoring: introduce getBaseGlyph and remove parameter from getDisplayStyleLargeOperator 4 https://bugs.webkit.org/show_bug.cgi?id=156910 5 6 Reviewed by Alejandro G. Castro. 7 8 No new tests, the behavior is not changed. 9 10 * rendering/mathml/RenderMathMLOperator.cpp: 11 (WebCore::RenderMathMLOperator::italicCorrection): We do not need to pass m_textContent 12 to getDisplayStyleLargeOperator. 13 (WebCore::RenderMathMLOperator::computePreferredLogicalWidths): We use getBaseGlyph and do 14 not pass m_textContent to getDisplayStyleLargeOperator or findStretchyData. 15 (WebCore::RenderMathMLOperator::getBaseGlyph): Introduce a helper function to retrieve the 16 base glyph and do some validity checks. 17 (WebCore::RenderMathMLOperator::getDisplayStyleLargeOperator): We remove the character 18 parameter as it is always m_textContent. 19 We use getBaseGlyph and replace primaryFont with baseGlyph.font. 20 (WebCore::RenderMathMLOperator::findStretchyData): Ditto. 21 (WebCore::RenderMathMLOperator::updateStyle): We do not pass m_textContent to 22 getDisplayStyleLargeOperator or findStretchyData. 23 * rendering/mathml/RenderMathMLOperator.h: Declare getBaseGlyph and remove the parameter 24 from getDisplayStyleLargeOperator and findStretchyData. 25 1 26 2016-04-28 Carlos Garcia Campos <cgarcia@igalia.com> 2 27 -
trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp
r200041 r200185 208 208 const auto& primaryFont = style().fontCascade().primaryFont(); 209 209 if (auto* mathData = primaryFont.mathData()) { 210 StretchyData largeOperator = getDisplayStyleLargeOperator( m_textContent);210 StretchyData largeOperator = getDisplayStyleLargeOperator(); 211 211 return mathData->getItalicCorrection(primaryFont, largeOperator.variant().glyph); 212 212 } … … 307 307 } 308 308 309 GlyphData data = style().fontCascade().glyphDataForCharacter(m_textContent, !style().isLeftToRightDirection());310 float maximumGlyphWidth = advanceWidthForGlyph(data);309 GlyphData baseGlyph; 310 float maximumGlyphWidth = getBaseGlyph(style(), baseGlyph) ? advanceWidthForGlyph(baseGlyph) : 0; 311 311 if (!m_isVertical) { 312 312 if (maximumGlyphWidth < stretchSize()) … … 318 318 if (isLargeOperatorInDisplayStyle()) { 319 319 // Large operators in STIX Word have incorrect advance width, causing misplacement of superscript, so we use the glyph bound instead (http://sourceforge.net/p/stixfonts/tracking/49/). 320 StretchyData largeOperator = getDisplayStyleLargeOperator( m_textContent);320 StretchyData largeOperator = getDisplayStyleLargeOperator(); 321 321 if (largeOperator.mode() == DrawSizeVariant) 322 322 maximumGlyphWidth = boundsForGlyph(largeOperator.variant()).width(); 323 323 } else { 324 324 // FIXME: some glyphs (e.g. the one for "FRACTION SLASH" in the STIX Math font or large operators) have a width that depends on the height, resulting in large gaps (https://bugs.webkit.org/show_bug.cgi?id=130326). 325 findStretchyData( m_textContent,&maximumGlyphWidth);325 findStretchyData(&maximumGlyphWidth); 326 326 } 327 327 m_maxPreferredLogicalWidth = m_minPreferredLogicalWidth = m_leadingSpace + maximumGlyphWidth + m_trailingSpace; … … 385 385 RenderMathMLBlock::styleDidChange(diff, oldStyle); 386 386 updateOperatorProperties(); 387 } 388 389 bool RenderMathMLOperator::getBaseGlyph(const RenderStyle& style, GlyphData& baseGlyph) const 390 { 391 baseGlyph = style.fontCascade().glyphDataForCharacter(m_textContent, !style.isLeftToRightDirection()); 392 return baseGlyph.isValid() && baseGlyph.font == &style.fontCascade().primaryFont(); 387 393 } 388 394 … … 497 503 } 498 504 499 RenderMathMLOperator::StretchyData RenderMathMLOperator::getDisplayStyleLargeOperator( UChar character) const505 RenderMathMLOperator::StretchyData RenderMathMLOperator::getDisplayStyleLargeOperator() const 500 506 { 501 507 StretchyData data; … … 503 509 ASSERT(m_isVertical && isLargeOperatorInDisplayStyle()); 504 510 505 const auto& primaryFont = style().fontCascade().primaryFont(); 506 GlyphData baseGlyph = style().fontCascade().glyphDataForCharacter(character, !style().isLeftToRightDirection()); 507 if (!primaryFont.mathData() || baseGlyph.font != &primaryFont || !baseGlyph.font || !baseGlyph.glyph) 511 GlyphData baseGlyph; 512 if (!getBaseGlyph(style(), baseGlyph) || !baseGlyph.font->mathData()) 508 513 return data; 509 514 … … 512 517 513 518 // The value of displayOperatorMinHeight is sometimes too small, so we ensure that it is at least \sqrt{2} times the size of the base glyph. 514 float displayOperatorMinHeight = std::max(baseGlyph.font->boundsForGlyph(baseGlyph.glyph).height() * sqrtOfTwoFloat, primaryFont.mathData()->getMathConstant(primaryFont, OpenTypeMathData::DisplayOperatorMinHeight));515 516 primaryFont.mathData()->getMathVariants(baseGlyph.glyph, true, sizeVariants, assemblyParts);519 float displayOperatorMinHeight = std::max(baseGlyph.font->boundsForGlyph(baseGlyph.glyph).height() * sqrtOfTwoFloat, baseGlyph.font->mathData()->getMathConstant(*baseGlyph.font, OpenTypeMathData::DisplayOperatorMinHeight)); 520 521 baseGlyph.font->mathData()->getMathVariants(baseGlyph.glyph, true, sizeVariants, assemblyParts); 517 522 518 523 // We choose the first size variant that is larger than the expected displayOperatorMinHeight and otherwise fallback to the largest variant. … … 520 525 GlyphData sizeVariant; 521 526 sizeVariant.glyph = variant; 522 sizeVariant.font = &primaryFont;527 sizeVariant.font = baseGlyph.font; 523 528 data.setSizeVariantMode(sizeVariant); 524 529 if (boundsForGlyph(sizeVariant).height() >= displayOperatorMinHeight) … … 528 533 } 529 534 530 RenderMathMLOperator::StretchyData RenderMathMLOperator::findStretchyData( UChar character,float* maximumGlyphWidth)535 RenderMathMLOperator::StretchyData RenderMathMLOperator::findStretchyData(float* maximumGlyphWidth) 531 536 { 532 537 ASSERT(!maximumGlyphWidth || m_isVertical); … … 535 540 StretchyData assemblyData; 536 541 537 const auto& primaryFont = style().fontCascade().primaryFont(); 538 GlyphData baseGlyph = style().fontCascade().glyphDataForCharacter(character, !style().isLeftToRightDirection()); 542 GlyphData baseGlyph; 543 if (!getBaseGlyph(style(), baseGlyph)) 544 return data; 539 545 540 if ( primaryFont.mathData() && baseGlyph.font == &primaryFont) {546 if (baseGlyph.font->mathData()) { 541 547 Vector<Glyph> sizeVariants; 542 548 Vector<OpenTypeMathData::AssemblyPart> assemblyParts; 543 primaryFont.mathData()->getMathVariants(baseGlyph.glyph, m_isVertical, sizeVariants, assemblyParts);549 baseGlyph.font->mathData()->getMathVariants(baseGlyph.glyph, m_isVertical, sizeVariants, assemblyParts); 544 550 // We verify the size variants. 545 551 for (auto& variant : sizeVariants) { 546 552 GlyphData sizeVariant; 547 553 sizeVariant.glyph = variant; 548 sizeVariant.font = &primaryFont;554 sizeVariant.font = baseGlyph.font; 549 555 if (maximumGlyphWidth) 550 556 *maximumGlyphWidth = std::max(*maximumGlyphWidth, advanceWidthForGlyph(sizeVariant)); … … 568 574 const unsigned maxIndex = WTF_ARRAY_LENGTH(stretchyCharacters); 569 575 for (unsigned index = 0; index < maxIndex; ++index) { 570 if (stretchyCharacters[index].character == character) {576 if (stretchyCharacters[index].character == m_textContent) { 571 577 stretchyCharacter = &stretchyCharacters[index]; 572 578 if (!style().isLeftToRightDirection() && index < leftRightPairsCount * 2) { … … 642 648 643 649 if (m_isVertical && isLargeOperatorInDisplayStyle()) 644 m_stretchyData = getDisplayStyleLargeOperator( m_textContent);650 m_stretchyData = getDisplayStyleLargeOperator(); 645 651 else { 646 652 // We do not stretch if the base glyph is large enough. … … 649 655 if (stretchSize() <= baseSize) 650 656 return; 651 m_stretchyData = findStretchyData( m_textContent,nullptr);657 m_stretchyData = findStretchyData(nullptr); 652 658 } 653 659 -
trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h
r200041 r200185 142 142 bool shouldAllowStretching() const; 143 143 144 bool getBaseGlyph(const RenderStyle&, GlyphData&) const; 144 145 bool getGlyphAssemblyFallBack(Vector<OpenTypeMathData::AssemblyPart>, StretchyData&) const; 145 StretchyData getDisplayStyleLargeOperator( UChar) const;146 StretchyData findStretchyData( UChar,float* maximumGlyphWidth);146 StretchyData getDisplayStyleLargeOperator() const; 147 StretchyData findStretchyData(float* maximumGlyphWidth); 147 148 148 149 enum GlyphPaintTrimming {
Note: See TracChangeset
for help on using the changeset viewer.