Changeset 211765 in webkit
- Timestamp:
- Feb 6, 2017 6:14:53 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r211758 r211765 1 2017-02-06 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Migrate ComplexTextController to use platform-independent types 4 https://bugs.webkit.org/show_bug.cgi?id=167833 5 6 Reviewed by Brent Fulgham. 7 8 Rebaseline tiny rounding result. 9 10 * platform/mac/fast/text/complex-text-opacity-expected.txt: 11 1 12 2017-02-06 Youenn Fablet <youennf@gmail.com> 2 13 -
trunk/LayoutTests/platform/mac/fast/text/complex-text-opacity-expected.txt
r187126 r211765 25 25 RenderText {#text} at (188,4) size 7x29 26 26 text run at (188,4) width 7: " " 27 RenderText {#text} at (23 7,4) size 7x2928 text run at (23 7,4) width 7: " "27 RenderText {#text} at (236,4) size 8x29 28 text run at (236,4) width 8: " " 29 29 RenderText {#text} at (285,4) size 7x29 30 30 text run at (285,4) width 7: " " -
trunk/Source/WebCore/ChangeLog
r211763 r211765 1 2017-02-06 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Migrate ComplexTextController to use platform-independent types 4 https://bugs.webkit.org/show_bug.cgi?id=167833 5 6 Reviewed by Brent Fulgham. 7 8 ComplexTextController will eventually be used on all ports to perform complex text layout. 9 This is a mechanical patch which migrates the shared parts of ComplexTextController away from 10 using CoreGraphics and CoreFoundation types in favor of WebCore/platform types. Eventually, 11 ComplexTextController will get moved to PAL but there is a layering violation (TextLayout) to 12 fix first. 13 14 No new tests because there is no behavior change. 15 16 * platform/graphics/GlyphBuffer.h: 17 (WebCore::GlyphBufferAdvance::GlyphBufferAdvance): 18 * platform/graphics/mac/ComplexTextController.cpp: 19 (WebCore::ComplexTextController::offsetForPosition): 20 (WebCore::advanceByCombiningCharacterSequence): 21 (WebCore::ComplexTextController::ComplexTextRun::indexAt): 22 (WebCore::ComplexTextController::ComplexTextRun::setIsNonMonotonic): 23 (WebCore::ComplexTextController::advance): 24 (WebCore::ComplexTextController::adjustGlyphsAndAdvances): 25 * platform/graphics/mac/ComplexTextController.h: 26 (WebCore::ComplexTextController::ComplexTextRun::create): 27 (WebCore::ComplexTextController::ComplexTextRun::stringLength): 28 (WebCore::ComplexTextController::ComplexTextRun::indexBegin): 29 (WebCore::ComplexTextController::ComplexTextRun::indexEnd): 30 (WebCore::ComplexTextController::ComplexTextRun::endOffsetAt): 31 (WebCore::ComplexTextController::ComplexTextRun::glyphs): 32 (WebCore::ComplexTextController::ComplexTextRun::growInitialAdvanceHorizontally): 33 (WebCore::ComplexTextController::ComplexTextRun::initialAdvance): 34 (WebCore::ComplexTextController::ComplexTextRun::baseAdvances): 35 (WebCore::ComplexTextController::ComplexTextRun::glyphOrigins): 36 (WebCore::ComplexTextController::glyphOrigin): 37 (WebCore::ComplexTextController::ComplexTextRun::createForTesting): Deleted. 38 * platform/graphics/mac/ComplexTextControllerCoreText.mm: 39 (SOFT_LINK): 40 (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): 41 (WebCore::ComplexTextController::collectComplexTextRunsForCharacters): 42 1 43 2017-02-06 Brent Fulgham <bfulgham@apple.com> 2 44 -
trunk/Source/WebCore/platform/graphics/GlyphBuffer.h
r211382 r211765 63 63 public: 64 64 GlyphBufferAdvance() : CGSize(CGSizeZero) { } 65 GlyphBufferAdvance(CGSize size) : CGSize(size) 65 GlyphBufferAdvance(CGSize size) 66 : CGSize(size) 67 { 68 } 69 GlyphBufferAdvance(float width, float height) 70 : CGSize(CGSizeMake(width, height)) 66 71 { 67 72 } -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
r211382 r211765 176 176 return m_run.ltr() ? 0 : m_end; 177 177 178 CGFloat x = h;178 float x = h; 179 179 180 180 size_t runCount = m_complexTextRuns.size(); 181 size_toffsetIntoAdjustedGlyphs = 0;181 unsigned offsetIntoAdjustedGlyphs = 0; 182 182 183 183 for (size_t r = 0; r < runCount; ++r) { 184 184 const ComplexTextRun& complexTextRun = *m_complexTextRuns[r]; 185 185 for (unsigned j = 0; j < complexTextRun.glyphCount(); ++j) { 186 size_tindex = offsetIntoAdjustedGlyphs + j;187 CGFloat adjustedAdvance = m_adjustedBaseAdvances[index].width;186 unsigned index = offsetIntoAdjustedGlyphs + j; 187 float adjustedAdvance = m_adjustedBaseAdvances[index].width(); 188 188 if (x < adjustedAdvance) { 189 CFIndexhitGlyphStart = complexTextRun.indexAt(j);190 CFIndexhitGlyphEnd;189 unsigned hitGlyphStart = complexTextRun.indexAt(j); 190 unsigned hitGlyphEnd; 191 191 if (m_run.ltr()) 192 hitGlyphEnd = std::max <CFIndex>(hitGlyphStart, j + 1 < complexTextRun.glyphCount() ? complexTextRun.indexAt(j + 1) : static_cast<CFIndex>(complexTextRun.indexEnd()));192 hitGlyphEnd = std::max(hitGlyphStart, j + 1 < complexTextRun.glyphCount() ? complexTextRun.indexAt(j + 1) : complexTextRun.indexEnd()); 193 193 else 194 hitGlyphEnd = std::max <CFIndex>(hitGlyphStart, j > 0 ? complexTextRun.indexAt(j - 1) : static_cast<CFIndex>(complexTextRun.indexEnd()));194 hitGlyphEnd = std::max(hitGlyphStart, j > 0 ? complexTextRun.indexAt(j - 1) : complexTextRun.indexEnd()); 195 195 196 196 // FIXME: Instead of dividing the glyph's advance equally between the characters, this 197 197 // could use the glyph's "ligature carets". This is available in CoreText via CTFontGetLigatureCaretPositions(). 198 CFIndexhitIndex = hitGlyphStart + (hitGlyphEnd - hitGlyphStart) * (m_run.ltr() ? x / adjustedAdvance : 1 - x / adjustedAdvance);199 intstringLength = complexTextRun.stringLength();198 unsigned hitIndex = hitGlyphStart + (hitGlyphEnd - hitGlyphStart) * (m_run.ltr() ? x / adjustedAdvance : 1 - x / adjustedAdvance); 199 unsigned stringLength = complexTextRun.stringLength(); 200 200 UBreakIterator* cursorPositionIterator = cursorMovementIterator(StringView(complexTextRun.characters(), stringLength)); 201 intclusterStart;201 unsigned clusterStart; 202 202 if (ubrk_isBoundary(cursorPositionIterator, hitIndex)) 203 203 clusterStart = hitIndex; 204 204 else { 205 clusterStart = ubrk_preceding(cursorPositionIterator, hitIndex); 206 if (clusterStart == UBRK_DONE) 207 clusterStart = 0; 205 int preceeding = ubrk_preceding(cursorPositionIterator, hitIndex); 206 clusterStart = preceeding == UBRK_DONE ? 0 : preceeding; 208 207 } 209 208 … … 211 210 return complexTextRun.stringLocation() + clusterStart; 212 211 213 int clusterEnd = ubrk_following(cursorPositionIterator, hitIndex); 214 if (clusterEnd == UBRK_DONE) 215 clusterEnd = stringLength; 216 217 CGFloat clusterWidth; 212 int following = ubrk_following(cursorPositionIterator, hitIndex); 213 unsigned clusterEnd = following == UBRK_DONE ? stringLength : following; 214 215 float clusterWidth; 218 216 // FIXME: The search stops at the boundaries of complexTextRun. In theory, it should go on into neighboring ComplexTextRuns 219 217 // derived from the same CTLine. In practice, we do not expect there to be more than one CTRun in a CTLine, as no … … 221 219 if (clusterEnd - clusterStart > 1) { 222 220 clusterWidth = adjustedAdvance; 223 int firstGlyphBeforeCluster = j - 1; 224 while (firstGlyphBeforeCluster >= 0 && complexTextRun.indexAt(firstGlyphBeforeCluster) >= clusterStart && complexTextRun.indexAt(firstGlyphBeforeCluster) < clusterEnd) { 225 CGFloat width = m_adjustedBaseAdvances[offsetIntoAdjustedGlyphs + firstGlyphBeforeCluster].width; 226 clusterWidth += width; 227 x += width; 228 firstGlyphBeforeCluster--; 221 if (j) { 222 unsigned firstGlyphBeforeCluster = j - 1; 223 while (complexTextRun.indexAt(firstGlyphBeforeCluster) >= clusterStart && complexTextRun.indexAt(firstGlyphBeforeCluster) < clusterEnd) { 224 float width = m_adjustedBaseAdvances[offsetIntoAdjustedGlyphs + firstGlyphBeforeCluster].width(); 225 clusterWidth += width; 226 x += width; 227 if (!firstGlyphBeforeCluster) 228 break; 229 firstGlyphBeforeCluster--; 230 } 229 231 } 230 232 unsigned firstGlyphAfterCluster = j + 1; 231 233 while (firstGlyphAfterCluster < complexTextRun.glyphCount() && complexTextRun.indexAt(firstGlyphAfterCluster) >= clusterStart && complexTextRun.indexAt(firstGlyphAfterCluster) < clusterEnd) { 232 clusterWidth += m_adjustedBaseAdvances[offsetIntoAdjustedGlyphs + firstGlyphAfterCluster].width ;234 clusterWidth += m_adjustedBaseAdvances[offsetIntoAdjustedGlyphs + firstGlyphAfterCluster].width(); 233 235 firstGlyphAfterCluster++; 234 236 } … … 239 241 if (x <= clusterWidth / 2) 240 242 return complexTextRun.stringLocation() + (m_run.ltr() ? clusterStart : clusterEnd); 241 else 242 return complexTextRun.stringLocation() + (m_run.ltr() ? clusterEnd : clusterStart); 243 return complexTextRun.stringLocation() + (m_run.ltr() ? clusterEnd : clusterStart); 243 244 } 244 245 x -= adjustedAdvance; … … 271 272 while (iterator < end) { 272 273 UChar32 nextCharacter; 273 intmarkLength = 0;274 unsigned markLength = 0; 274 275 bool shouldContinue = false; 275 U16_NEXT(iterator, markLength, end - iterator, nextCharacter); 276 ASSERT(end >= iterator); 277 U16_NEXT(iterator, markLength, static_cast<unsigned>(end - iterator), nextCharacter); 276 278 277 279 if (isVariationSelector(nextCharacter) || isEmojiFitzpatrickModifier(nextCharacter)) … … 454 456 } 455 457 456 CFIndex ComplexTextController::ComplexTextRun::indexAt(size_ti) const458 unsigned ComplexTextController::ComplexTextRun::indexAt(unsigned i) const 457 459 { 458 460 ASSERT(i < m_glyphCount); … … 467 469 468 470 Vector<bool, 64> mappedIndices(m_stringLength, false); 469 for ( size_ti = 0; i < m_glyphCount; ++i) {470 ASSERT(indexAt(i) < static_cast<CFIndex>(m_stringLength));471 for (unsigned i = 0; i < m_glyphCount; ++i) { 472 ASSERT(indexAt(i) < m_stringLength); 471 473 mappedIndices[indexAt(i)] = true; 472 474 } … … 474 476 m_glyphEndOffsets.grow(m_glyphCount); 475 477 for (unsigned i = 0; i < m_glyphCount; ++i) { 476 CFIndexnextMappedIndex = m_indexEnd;477 for ( size_tj = indexAt(i) + 1; j < m_stringLength; ++j) {478 unsigned nextMappedIndex = m_indexEnd; 479 for (unsigned j = indexAt(i) + 1; j < m_stringLength; ++j) { 478 480 if (mappedIndices[j]) { 479 481 nextMappedIndex = j; … … 581 583 const ComplexTextRun& complexTextRun = *m_complexTextRuns[currentRunIndex]; 582 584 bool ltr = complexTextRun.isLTR(); 583 size_tglyphCount = complexTextRun.glyphCount();585 unsigned glyphCount = complexTextRun.glyphCount(); 584 586 unsigned glyphIndexIntoCurrentRun = ltr ? m_glyphInCurrentRun : glyphCount - 1 - m_glyphInCurrentRun; 585 587 unsigned glyphIndexIntoComplexTextController = indexOfLeftmostGlyphInCurrentRun + glyphIndexIntoCurrentRun; … … 591 593 // account the text direction. 592 594 if (!indexOfLeftmostGlyphInCurrentRun && glyphBuffer) 593 glyphBuffer->setInitialAdvance( complexTextRun.initialAdvance());595 glyphBuffer->setInitialAdvance(GlyphBufferAdvance(complexTextRun.initialAdvance().width(), complexTextRun.initialAdvance().height())); 594 596 595 597 while (m_glyphInCurrentRun < glyphCount) { … … 598 600 if (complexTextRun.isMonotonic()) { 599 601 if (ltr) 600 glyphEndOffset = std::max <unsigned>(glyphStartOffset, static_cast<unsigned>(glyphIndexIntoCurrentRun + 1 < glyphCount ? complexTextRun.indexAt(glyphIndexIntoCurrentRun + 1) : complexTextRun.indexEnd()));602 glyphEndOffset = std::max(glyphStartOffset, glyphIndexIntoCurrentRun + 1 < glyphCount ? complexTextRun.indexAt(glyphIndexIntoCurrentRun + 1) : complexTextRun.indexEnd()); 601 603 else 602 glyphEndOffset = std::max <unsigned>(glyphStartOffset, static_cast<unsigned>(glyphIndexIntoCurrentRun > 0 ? complexTextRun.indexAt(glyphIndexIntoCurrentRun - 1) : complexTextRun.indexEnd()));604 glyphEndOffset = std::max(glyphStartOffset, glyphIndexIntoCurrentRun > 0 ? complexTextRun.indexAt(glyphIndexIntoCurrentRun - 1) : complexTextRun.indexEnd()); 603 605 } else 604 606 glyphEndOffset = complexTextRun.endOffsetAt(glyphIndexIntoCurrentRun); 605 607 606 CGSize adjustedBaseAdvance = m_adjustedBaseAdvances[glyphIndexIntoComplexTextController];608 FloatSize adjustedBaseAdvance = m_adjustedBaseAdvances[glyphIndexIntoComplexTextController]; 607 609 608 610 if (glyphStartOffset + complexTextRun.stringLocation() >= m_currentCharacter) … … 611 613 if (glyphBuffer && !m_characterInCurrentGlyph) { 612 614 auto currentGlyphOrigin = glyphOrigin(glyphIndexIntoComplexTextController); 613 GlyphBufferAdvance paintAdvance = adjustedBaseAdvance;615 GlyphBufferAdvance paintAdvance(adjustedBaseAdvance); 614 616 if (!glyphIndexIntoCurrentRun) { 615 617 // The first layout advance of every run includes the "initial layout advance." However, here, we need 616 618 // paint advances, so subtract it out before transforming the layout advance into a paint advance. 617 paintAdvance.setWidth(paintAdvance.width() - (complexTextRun.initialAdvance().width - currentGlyphOrigin.x));618 paintAdvance.setHeight(paintAdvance.height() - (complexTextRun.initialAdvance().height - currentGlyphOrigin.y));619 paintAdvance.setWidth(paintAdvance.width() - (complexTextRun.initialAdvance().width() - currentGlyphOrigin.x())); 620 paintAdvance.setHeight(paintAdvance.height() - (complexTextRun.initialAdvance().height() - currentGlyphOrigin.y())); 619 621 } 620 paintAdvance.setWidth(paintAdvance.width() + glyphOrigin(glyphIndexIntoComplexTextController + 1).x - currentGlyphOrigin.x);621 paintAdvance.setHeight(paintAdvance.height() + glyphOrigin(glyphIndexIntoComplexTextController + 1).y - currentGlyphOrigin.y);622 paintAdvance.setWidth(paintAdvance.width() + glyphOrigin(glyphIndexIntoComplexTextController + 1).x() - currentGlyphOrigin.x()); 623 paintAdvance.setHeight(paintAdvance.height() + glyphOrigin(glyphIndexIntoComplexTextController + 1).y() - currentGlyphOrigin.y()); 622 624 if (glyphIndexIntoCurrentRun == glyphCount - 1 && currentRunIndex + 1 < runCount) { 623 625 // Our paint advance points to the end of the run. However, the next run may have an 624 626 // initial advance, and our paint advance needs to point to the location of the next 625 627 // glyph. So, we need to add in the next run's initial advance. 626 paintAdvance.setWidth(paintAdvance.width() - glyphOrigin(glyphIndexIntoComplexTextController + 1).x + m_complexTextRuns[currentRunIndex + 1]->initialAdvance().width);627 paintAdvance.setHeight(paintAdvance.height() - glyphOrigin(glyphIndexIntoComplexTextController + 1).y + m_complexTextRuns[currentRunIndex + 1]->initialAdvance().height);628 paintAdvance.setWidth(paintAdvance.width() - glyphOrigin(glyphIndexIntoComplexTextController + 1).x() + m_complexTextRuns[currentRunIndex + 1]->initialAdvance().width()); 629 paintAdvance.setHeight(paintAdvance.height() - glyphOrigin(glyphIndexIntoComplexTextController + 1).y() + m_complexTextRuns[currentRunIndex + 1]->initialAdvance().height()); 628 630 } 629 631 paintAdvance.setHeight(-paintAdvance.height()); // Increasing y points down … … 633 635 unsigned oldCharacterInCurrentGlyph = m_characterInCurrentGlyph; 634 636 m_characterInCurrentGlyph = std::min(m_currentCharacter - complexTextRun.stringLocation(), glyphEndOffset) - glyphStartOffset; 635 m_runWidthSoFar += adjustedBaseAdvance.width * runWidthSoFarFraction(glyphStartOffset, glyphEndOffset, oldCharacterInCurrentGlyph, iterationStyle);637 m_runWidthSoFar += adjustedBaseAdvance.width() * runWidthSoFarFraction(glyphStartOffset, glyphEndOffset, oldCharacterInCurrentGlyph, iterationStyle); 636 638 637 639 if (glyphEndOffset + complexTextRun.stringLocation() > m_currentCharacter) … … 682 684 { 683 685 bool afterExpansion = (m_run.expansionBehavior() & LeadingExpansionMask) == ForbidLeadingExpansion; 684 CGFloat widthSinceLastCommit = 0;686 float widthSinceLastCommit = 0; 685 687 size_t runCount = m_complexTextRuns.size(); 686 688 bool hasExtraSpacing = (m_font.letterSpacing() || m_font.wordSpacing() || m_expansion) && !m_run.spacingDisabled(); … … 700 702 701 703 const CGGlyph* glyphs = complexTextRun.glyphs(); 702 const CGSize* advances = complexTextRun.baseAdvances();704 const FloatSize* advances = complexTextRun.baseAdvances(); 703 705 704 706 bool lastRun = runIndex + 1 == runCount; 705 707 float spaceWidth = font.spaceWidth() - font.syntheticBoldOffset(); 706 708 const UChar* cp = complexTextRun.characters(); 707 CGPoint glyphOrigin = CGPointZero;708 CFIndex lastCharacterIndex = m_run.ltr() ? std::numeric_limits<CFIndex>::min() : std::numeric_limits<CFIndex>::max();709 FloatPoint glyphOrigin; 710 unsigned lastCharacterIndex = m_run.ltr() ? std::numeric_limits<unsigned>::min() : std::numeric_limits<unsigned>::max(); 709 711 bool isMonotonic = true; 710 712 711 713 for (unsigned i = 0; i < glyphCount; i++) { 712 CFIndexcharacterIndex = complexTextRun.indexAt(i);714 unsigned characterIndex = complexTextRun.indexAt(i); 713 715 if (m_run.ltr()) { 714 716 if (characterIndex < lastCharacterIndex) … … 730 732 bool treatAsSpace = FontCascade::treatAsSpace(ch); 731 733 CGGlyph glyph = treatAsSpace ? font.spaceGlyph() : glyphs[i]; 732 CGSize advance = treatAsSpace ? CGSizeMake(spaceWidth, advances[i].height) : advances[i];734 FloatSize advance = treatAsSpace ? FloatSize(spaceWidth, advances[i].height()) : advances[i]; 733 735 734 736 if (ch == '\t' && m_run.allowTabs()) 735 advance. width = m_font.tabWidth(font, m_run.tabSize(), m_run.xPos() + m_totalWidth + widthSinceLastCommit);737 advance.setWidth(m_font.tabWidth(font, m_run.tabSize(), m_run.xPos() + m_totalWidth + widthSinceLastCommit)); 736 738 else if (FontCascade::treatAsZeroWidthSpace(ch) && !treatAsSpace) { 737 advance. width = 0;739 advance.setWidth(0); 738 740 glyph = font.spaceGlyph(); 739 741 } 740 742 741 743 if (!i) { 742 advance.width += complexTextRun.initialAdvance().width; 743 advance.height += complexTextRun.initialAdvance().height; 744 if (auto* origins = complexTextRun.glyphOrigins()) { 745 advance.width -= origins[0].x; 746 advance.height -= origins[0].y; 747 } 748 } 749 750 advance.width += font.syntheticBoldOffset(); 744 advance.expand(complexTextRun.initialAdvance().width(), complexTextRun.initialAdvance().height()); 745 if (auto* origins = complexTextRun.glyphOrigins()) 746 advance.expand(-origins[0].x(), -origins[0].y()); 747 } 748 749 advance.expand(font.syntheticBoldOffset(), 0); 751 750 752 751 if (hasExtraSpacing) { 753 752 // If we're a glyph with an advance, add in letter-spacing. 754 // That way we weed out zero width lurkers. 755 if (advance.width )756 advance. width += m_font.letterSpacing();753 // That way we weed out zero width lurkers. This behavior matches the fast text code path. 754 if (advance.width()) 755 advance.expand(m_font.letterSpacing(), 0); 757 756 758 757 unsigned characterIndexInRun = characterIndex + complexTextRun.stringLocation(); 759 758 bool isFirstCharacter = !(characterIndex + complexTextRun.stringLocation()); 760 bool isLastCharacter = static_cast<unsigned>(characterIndexInRun + 1) == m_run.length() || (U16_IS_LEAD(ch) && static_cast<unsigned>(characterIndexInRun + 2)== m_run.length() && U16_IS_TRAIL(*(cp + characterIndex + 1)));759 bool isLastCharacter = characterIndexInRun + 1 == m_run.length() || (U16_IS_LEAD(ch) && characterIndexInRun + 2 == m_run.length() && U16_IS_TRAIL(*(cp + characterIndex + 1))); 761 760 762 761 bool forceLeadingExpansion = false; // On the left, regardless of m_run.ltr() … … 780 779 std::tie(expandLeft, expandRight) = expansionLocation(ideograph, treatAsSpace, m_run.ltr(), afterExpansion, forbidLeadingExpansion, forbidTrailingExpansion, forceLeadingExpansion, forceTrailingExpansion); 781 780 m_expansion -= m_expansionPerOpportunity; 782 advance. width += m_expansionPerOpportunity;781 advance.expand(m_expansionPerOpportunity, 0); 783 782 if (expandLeft) { 784 783 // Increase previous width … … 786 785 complexTextRun.growInitialAdvanceHorizontally(m_expansionPerOpportunity); 787 786 else 788 m_adjustedBaseAdvances.last(). width += m_expansionPerOpportunity;787 m_adjustedBaseAdvances.last().expand(m_expansionPerOpportunity, 0); 789 788 } 790 789 if (expandRight) … … 795 794 // Account for word-spacing. 796 795 if (treatAsSpace && (ch != '\t' || !m_run.allowTabs()) && (characterIndex > 0 || runIndex > 0) && m_font.wordSpacing()) 797 advance. width += m_font.wordSpacing();796 advance.expand(m_font.wordSpacing(), 0); 798 797 } else 799 798 afterExpansion = false; 800 799 } 801 800 802 widthSinceLastCommit += advance.width ;801 widthSinceLastCommit += advance.width(); 803 802 804 803 // FIXME: Combining marks should receive a text emphasis mark if they are combine with a space. … … 816 815 817 816 FloatRect glyphBounds = font.boundsForGlyph(glyph); 818 glyphBounds.move(glyphOrigin.x , glyphOrigin.y);817 glyphBounds.move(glyphOrigin.x(), glyphOrigin.y()); 819 818 m_minGlyphBoundingBoxX = std::min(m_minGlyphBoundingBoxX, glyphBounds.x()); 820 819 m_maxGlyphBoundingBoxX = std::max(m_maxGlyphBoundingBoxX, glyphBounds.maxX()); 821 820 m_minGlyphBoundingBoxY = std::min(m_minGlyphBoundingBoxY, glyphBounds.y()); 822 821 m_maxGlyphBoundingBoxY = std::max(m_maxGlyphBoundingBoxY, glyphBounds.maxY()); 823 glyphOrigin.x += advance.width; 824 glyphOrigin.y += advance.height; 822 glyphOrigin.move(advance); 825 823 826 824 lastCharacterIndex = characterIndex; -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h
r211382 r211765 23 23 */ 24 24 25 # ifndef ComplexTextController_h26 #define ComplexTextController_h 27 25 #pragma once 26 27 #include "FloatPoint.h" 28 28 #include "GlyphBuffer.h" 29 29 #include <wtf/HashSet.h> … … 40 40 typedef const struct __CTLine * CTLineRef; 41 41 42 namespace WTF {43 template<> struct VectorTraits<CGPoint> : SimpleClassVectorTraits { };44 }45 46 42 namespace WebCore { 47 43 … … 79 75 class ComplexTextRun : public RefCounted<ComplexTextRun> { 80 76 public: 81 static Ref<ComplexTextRun> create(CTRunRef ctRun, const Font& font, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)77 static Ref<ComplexTextRun> create(CTRunRef ctRun, const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd) 82 78 { 83 return adoptRef(*new ComplexTextRun(ctRun, font, characters, stringLocation, stringLength, runRange));79 return adoptRef(*new ComplexTextRun(ctRun, font, characters, stringLocation, stringLength, indexBegin, indexEnd)); 84 80 } 85 81 86 static Ref<ComplexTextRun> create(const Font& font, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr)82 static Ref<ComplexTextRun> create(const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr) 87 83 { 88 return adoptRef(*new ComplexTextRun(font, characters, stringLocation, stringLength, ltr));84 return adoptRef(*new ComplexTextRun(font, characters, stringLocation, stringLength, indexBegin, indexEnd, ltr)); 89 85 } 90 86 91 static Ref<ComplexTextRun> create ForTesting(const Vector<CGSize>& advances, const Vector<CGPoint>& origins, const Vector<CGGlyph>& glyphs, const Vector<CFIndex>& stringIndices, CGSize initialAdvance, const Font& font, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange, bool ltr)87 static Ref<ComplexTextRun> create(const Vector<FloatSize>& advances, const Vector<FloatPoint>& origins, const Vector<Glyph>& glyphs, const Vector<unsigned>& stringIndices, FloatSize initialAdvance, const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr) 92 88 { 93 return adoptRef(*new ComplexTextRun(advances, origins, glyphs, stringIndices, initialAdvance, font, characters, stringLocation, stringLength, runRange, ltr));89 return adoptRef(*new ComplexTextRun(advances, origins, glyphs, stringIndices, initialAdvance, font, characters, stringLocation, stringLength, indexBegin, indexEnd, ltr)); 94 90 } 95 91 … … 98 94 const UChar* characters() const { return m_characters; } 99 95 unsigned stringLocation() const { return m_stringLocation; } 100 size_tstringLength() const { return m_stringLength; }101 ALWAYS_INLINE CFIndex indexAt(size_t i) const;102 CFIndexindexBegin() const { return m_indexBegin; }103 CFIndexindexEnd() const { return m_indexEnd; }104 CFIndex endOffsetAt(size_ti) const { ASSERT(!m_isMonotonic); return m_glyphEndOffsets[i]; }105 const CGGlyph* glyphs() const { return m_glyphs ; }96 unsigned stringLength() const { return m_stringLength; } 97 ALWAYS_INLINE unsigned indexAt(unsigned) const; 98 unsigned indexBegin() const { return m_indexBegin; } 99 unsigned indexEnd() const { return m_indexEnd; } 100 unsigned endOffsetAt(unsigned i) const { ASSERT(!m_isMonotonic); return m_glyphEndOffsets[i]; } 101 const CGGlyph* glyphs() const { return m_glyphs.data(); } 106 102 107 103 /* … … 132 128 * (text position ^) (layout advance) (layout advance) (layout advance) 133 129 */ 134 void growInitialAdvanceHorizontally( CGFloat delta) { m_initialAdvance.width += delta; }135 CGSize initialAdvance() const { return m_initialAdvance; }136 const CGSize* baseAdvances() const { return m_baseAdvances; }137 const CGPoint* glyphOrigins() const { return m_glyphOrigins.size() == glyphCount() ? m_glyphOrigins.data() : nullptr; }130 void growInitialAdvanceHorizontally(float delta) { m_initialAdvance.expand(delta, 0); } 131 FloatSize initialAdvance() const { return m_initialAdvance; } 132 const FloatSize* baseAdvances() const { return m_baseAdvances.data(); } 133 const FloatPoint* glyphOrigins() const { return m_glyphOrigins.size() == glyphCount() ? m_glyphOrigins.data() : nullptr; } 138 134 bool isLTR() const { return m_isLTR; } 139 135 bool isMonotonic() const { return m_isMonotonic; } … … 141 137 142 138 private: 143 ComplexTextRun(CTRunRef, const Font&, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange);144 ComplexTextRun(const Font&, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr);145 WEBCORE_EXPORT ComplexTextRun(const Vector< CGSize>& advances, const Vector<CGPoint>& origins, const Vector<CGGlyph>& glyphs, const Vector<CFIndex>& stringIndices, CGSize initialAdvance, const Font&, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange, bool ltr);146 147 Vector< CGSize, 64> m_baseAdvancesVector;148 Vector< CGPoint, 64> m_glyphOrigins;149 Vector<CGGlyph, 64> m_glyphs Vector;150 Vector< CFIndex, 64> m_glyphEndOffsets;151 Vector< CFIndex, 64> m_coreTextIndicesVector;152 CGSize m_initialAdvance;139 ComplexTextRun(CTRunRef, const Font&, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd); 140 ComplexTextRun(const Font&, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr); 141 WEBCORE_EXPORT ComplexTextRun(const Vector<FloatSize>& advances, const Vector<FloatPoint>& origins, const Vector<Glyph>& glyphs, const Vector<unsigned>& stringIndices, FloatSize initialAdvance, const Font&, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr); 142 143 Vector<FloatSize, 64> m_baseAdvances; 144 Vector<FloatPoint, 64> m_glyphOrigins; 145 Vector<CGGlyph, 64> m_glyphs; 146 Vector<unsigned, 64> m_glyphEndOffsets; 147 Vector<unsigned, 64> m_coreTextIndices; 148 FloatSize m_initialAdvance; 153 149 const Font& m_font; 154 150 const UChar* m_characters; 155 size_t m_stringLength; 156 const CFIndex* m_coreTextIndices; 157 const CGGlyph* m_glyphs; 158 const CGSize* m_baseAdvances; 159 CFIndex m_indexBegin; 160 CFIndex m_indexEnd; 151 unsigned m_stringLength; 152 unsigned m_indexBegin; 153 unsigned m_indexEnd; 161 154 unsigned m_glyphCount; 162 155 unsigned m_stringLocation; … … 181 174 float runWidthSoFarFraction(unsigned glyphStartOffset, unsigned glyphEndOffset, unsigned oldCharacterInCurrentGlyph, GlyphIterationStyle) const; 182 175 183 CGPoint glyphOrigin(unsigned index) const { return index < m_glyphOrigins.size() ? m_glyphOrigins[index] : CGPointZero; }184 185 Vector< CGSize, 256> m_adjustedBaseAdvances;186 Vector< CGPoint, 256> m_glyphOrigins;176 FloatPoint glyphOrigin(unsigned index) const { return index < m_glyphOrigins.size() ? m_glyphOrigins[index] : FloatPoint(); } 177 178 Vector<FloatSize, 256> m_adjustedBaseAdvances; 179 Vector<FloatPoint, 256> m_glyphOrigins; 187 180 Vector<CGGlyph, 256> m_adjustedGlyphs; 188 181 … … 211 204 const FontCascade& m_font; 212 205 const TextRun& m_run; 213 206 214 207 unsigned m_currentCharacter { 0 }; 215 208 unsigned m_end { 0 }; … … 235 228 236 229 } // namespace WebCore 237 238 #endif // ComplexTextController_h -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
r211308 r211765 43 43 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101100) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 90000) 44 44 SOFT_LINK_FRAMEWORK(CoreText); 45 SOFT_LINK(CoreText, CTRunGetBaseAdvancesAndOrigins, void, (CTRunRef run, CFRange range, CGSize baseAdvances[], CGPoint origins[]), (run, range, baseAdvances, origins))45 SOFT_LINK(CoreText, CTRunGetBaseAdvancesAndOrigins, void, (CTRunRef run, CFRange range, FloatSize baseAdvances[], FloatPoint origins[]), (run, range, baseAdvances, origins)) 46 46 #endif 47 48 47 49 48 // Note: CTFontDescriptorRefs can live forever in caches inside CoreText, so this object can too. … … 107 106 namespace WebCore { 108 107 109 ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const Font& font, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)108 ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd) 110 109 : m_initialAdvance(CTRunGetInitialAdvance(ctRun)) 111 110 , m_font(font) 112 111 , m_characters(characters) 113 112 , m_stringLength(stringLength) 114 , m_coreTextIndices(CTRunGetStringIndicesPtr(ctRun)) 115 , m_glyphs(CTRunGetGlyphsPtr(ctRun)) 116 , m_indexBegin(runRange.location) 117 , m_indexEnd(runRange.location + runRange.length) 113 , m_indexBegin(indexBegin) 114 , m_indexEnd(indexEnd) 118 115 , m_glyphCount(CTRunGetGlyphCount(ctRun)) 119 116 , m_stringLocation(stringLocation) 120 117 , m_isLTR(!(CTRunGetStatus(ctRun) & kCTRunStatusRightToLeft)) 121 118 { 122 if (!m_coreTextIndices) { 123 m_coreTextIndicesVector.grow(m_glyphCount); 124 CTRunGetStringIndices(ctRun, CFRangeMake(0, 0), m_coreTextIndicesVector.data()); 125 m_coreTextIndices = m_coreTextIndicesVector.data(); 126 } 127 128 if (!m_glyphs) { 129 m_glyphsVector.grow(m_glyphCount); 130 CTRunGetGlyphs(ctRun, CFRangeMake(0, 0), m_glyphsVector.data()); 131 m_glyphs = m_glyphsVector.data(); 132 } 119 const CFIndex* coreTextIndicesPtr = CTRunGetStringIndicesPtr(ctRun); 120 Vector<CFIndex> coreTextIndices; 121 if (!coreTextIndicesPtr) { 122 coreTextIndices.grow(m_glyphCount); 123 CTRunGetStringIndices(ctRun, CFRangeMake(0, 0), coreTextIndices.data()); 124 coreTextIndicesPtr = coreTextIndices.data(); 125 } 126 m_coreTextIndices.reserveInitialCapacity(m_glyphCount); 127 for (unsigned i = 0; i < m_glyphCount; ++i) 128 m_coreTextIndices.uncheckedAppend(coreTextIndicesPtr[i]); 129 130 const CGGlyph* glyphsPtr = CTRunGetGlyphsPtr(ctRun); 131 Vector<CGGlyph> glyphs; 132 if (!glyphsPtr) { 133 glyphs.grow(m_glyphCount); 134 CTRunGetGlyphs(ctRun, CFRangeMake(0, 0), glyphs.data()); 135 glyphsPtr = glyphs.data(); 136 } 137 m_glyphs.reserveInitialCapacity(m_glyphCount); 138 for (unsigned i = 0; i < m_glyphCount; ++i) 139 m_glyphs.uncheckedAppend(glyphsPtr[i]); 133 140 134 141 #if USE_LAYOUT_SPECIFIC_ADVANCES 135 142 if (CTRunGetStatus(ctRun) & kCTRunStatusHasOrigins) { 136 m_baseAdvancesVector.grow(m_glyphCount); 137 m_glyphOrigins.grow(m_glyphCount); 138 CTRunGetBaseAdvancesAndOrigins(ctRun, CFRangeMake(0, 0), m_baseAdvancesVector.data(), m_glyphOrigins.data()); 139 m_baseAdvances = m_baseAdvancesVector.data(); 143 Vector<CGSize> baseAdvances(m_glyphCount); 144 Vector<CGPoint> glyphOrigins(m_glyphCount); 145 CTRunGetBaseAdvancesAndOrigins(ctRun, CFRangeMake(0, 0), baseAdvances.data(), glyphOrigins.data()); 146 m_baseAdvances.reserveInitialCapacity(m_glyphCount); 147 m_glyphOrigins.reserveInitialCapacity(m_glyphCount); 148 for (unsigned i = 0; i < m_glyphCount; ++i) { 149 m_baseAdvances.uncheckedAppend(baseAdvances[i]); 150 m_glyphOrigins.uncheckedAppend(glyphOrigins[i]); 151 } 140 152 } else 141 153 #endif 142 154 { 143 m_baseAdvances = CTRunGetAdvancesPtr(ctRun); 144 if (!m_baseAdvances) { 145 m_baseAdvancesVector.grow(m_glyphCount); 146 CTRunGetAdvances(ctRun, CFRangeMake(0, 0), m_baseAdvancesVector.data()); 147 m_baseAdvances = m_baseAdvancesVector.data(); 155 const CGSize* baseAdvances = CTRunGetAdvancesPtr(ctRun); 156 Vector<CGSize> baseAdvancesVector; 157 if (!baseAdvances) { 158 baseAdvancesVector.grow(m_glyphCount); 159 CTRunGetAdvances(ctRun, CFRangeMake(0, 0), baseAdvancesVector.data()); 160 baseAdvances = baseAdvancesVector.data(); 148 161 } 162 m_baseAdvances.reserveInitialCapacity(m_glyphCount); 163 for (unsigned i = 0; i < m_glyphCount; ++i) 164 m_baseAdvances.uncheckedAppend(baseAdvances[i]); 149 165 } 150 166 } … … 152 168 // Missing glyphs run constructor. Core Text will not generate a run of missing glyphs, instead falling back on 153 169 // glyphs from LastResort. We want to use the primary font's missing glyph in order to match the fast text code path. 154 ComplexTextController::ComplexTextRun::ComplexTextRun(const Font& font, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr) 155 : m_initialAdvance(CGSizeZero) 156 , m_font(font) 170 ComplexTextController::ComplexTextRun::ComplexTextRun(const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr) 171 : m_font(font) 157 172 , m_characters(characters) 158 173 , m_stringLength(stringLength) 159 , m_indexBegin( 0)160 , m_indexEnd( stringLength)174 , m_indexBegin(indexBegin) 175 , m_indexEnd(indexEnd) 161 176 , m_stringLocation(stringLocation) 162 177 , m_isLTR(ltr) 163 178 { 164 m_coreTextIndicesVector.reserveInitialCapacity(m_stringLength); 165 unsigned r = 0; 166 while (r < m_stringLength) { 167 m_coreTextIndicesVector.uncheckedAppend(r); 179 auto runLengthInCodeUnits = m_indexEnd - m_indexBegin; 180 m_coreTextIndices.reserveInitialCapacity(runLengthInCodeUnits); 181 unsigned r = m_indexBegin; 182 while (r < m_indexEnd) { 183 m_coreTextIndices.uncheckedAppend(r); 168 184 UChar32 character; 169 185 U16_NEXT(m_characters, r, m_stringLength, character); 170 186 } 171 m_glyphCount = m_coreTextIndices Vector.size();187 m_glyphCount = m_coreTextIndices.size(); 172 188 if (!ltr) { 173 189 for (unsigned r = 0, end = m_glyphCount - 1; r < m_glyphCount / 2; ++r, --end) 174 std::swap(m_coreTextIndicesVector[r], m_coreTextIndicesVector[end]); 175 } 176 m_coreTextIndices = m_coreTextIndicesVector.data(); 190 std::swap(m_coreTextIndices[r], m_coreTextIndices[end]); 191 } 177 192 178 193 // Synthesize a run of missing glyphs. 179 m_glyphsVector.fill(0, m_glyphCount); 180 m_glyphs = m_glyphsVector.data(); 181 m_baseAdvancesVector.fill(CGSizeMake(m_font.widthForGlyph(0), 0), m_glyphCount); 182 m_baseAdvances = m_baseAdvancesVector.data(); 183 } 184 185 186 ComplexTextController::ComplexTextRun::ComplexTextRun(const Vector<CGSize>& advances, const Vector<CGPoint>& origins, const Vector<CGGlyph>& glyphs, const Vector<CFIndex>& stringIndices, CGSize initialAdvance, const Font& font, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange, bool ltr) 187 : m_baseAdvancesVector(advances) 194 m_glyphs.fill(0, m_glyphCount); 195 m_baseAdvances.fill(FloatSize(m_font.widthForGlyph(0), 0), m_glyphCount); 196 } 197 198 199 ComplexTextController::ComplexTextRun::ComplexTextRun(const Vector<FloatSize>& advances, const Vector<FloatPoint>& origins, const Vector<Glyph>& glyphs, const Vector<unsigned>& stringIndices, FloatSize initialAdvance, const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr) 200 : m_baseAdvances(advances) 188 201 , m_glyphOrigins(origins) 189 , m_glyphs Vector(glyphs)190 , m_coreTextIndices Vector(stringIndices)202 , m_glyphs(glyphs) 203 , m_coreTextIndices(stringIndices) 191 204 , m_initialAdvance(initialAdvance) 192 205 , m_font(font) 193 206 , m_characters(characters) 194 207 , m_stringLength(stringLength) 195 , m_coreTextIndices(m_coreTextIndicesVector.data()) 196 , m_glyphs(m_glyphsVector.data()) 197 , m_baseAdvances(m_baseAdvancesVector.data()) 198 , m_indexBegin(runRange.location) 199 , m_indexEnd(runRange.location + runRange.length) 208 , m_indexBegin(indexBegin) 209 , m_indexEnd(indexEnd) 200 210 , m_glyphCount(glyphs.size()) 201 211 , m_stringLocation(stringLocation) … … 230 240 if (!font) { 231 241 // Create a run of missing glyphs from the primary font. 232 m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFont(), cp, stringLocation, length, m_run.ltr()));242 m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFont(), cp, stringLocation, length, 0, length, m_run.ltr())); 233 243 return; 234 244 } … … 314 324 RetainPtr<CFStringRef> fontName = adoptCF(CTFontCopyPostScriptName(runCTFont)); 315 325 if (CFEqual(fontName.get(), CFSTR("LastResort"))) { 316 m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFont(), cp, stringLocation + runRange.location,runRange.length, m_run.ltr()));326 m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFont(), cp, stringLocation, length, runRange.location, runRange.location + runRange.length, m_run.ltr())); 317 327 continue; 318 328 } … … 333 343 m_fallbackFonts->add(font); 334 344 335 m_complexTextRuns.append(ComplexTextRun::create(ctRun, *runFont, cp, stringLocation, length, runRange ));345 m_complexTextRuns.append(ComplexTextRun::create(ctRun, *runFont, cp, stringLocation, length, runRange.location, runRange.location + runRange.length)); 336 346 } 337 347 } -
trunk/Tools/ChangeLog
r211763 r211765 1 2017-02-06 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Migrate ComplexTextController to use platform-independent types 4 https://bugs.webkit.org/show_bug.cgi?id=167833 5 6 Reviewed by Brent Fulgham. 7 8 Migrate tests away from platform-dependent types. 9 10 * TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp: 11 (TestWebKitAPI::TEST_F): 12 1 13 2017-02-06 Brent Fulgham <bfulgham@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp
r211382 r211765 56 56 57 57 #if USE_LAYOUT_SPECIFIC_ADVANCES 58 Vector< CGSize> advances = { CGSizeZero, CGSizeMake(21.640625, 0.0), CGSizeMake(42.3046875, 0.0), CGSizeMake(55.8984375, 0.0), CGSizeMake(22.34375, 0.0) };59 Vector< CGPoint> origins = { CGPointMake(-15.15625, 18.046875), CGPointZero, CGPointZero, CGPointZero, CGPointZero};58 Vector<FloatSize> advances = { FloatSize(), FloatSize(21.640625, 0.0), FloatSize(42.3046875, 0.0), FloatSize(55.8984375, 0.0), FloatSize(22.34375, 0.0) }; 59 Vector<FloatPoint> origins = { FloatPoint(-15.15625, 18.046875), FloatPoint(), FloatPoint(), FloatPoint(), FloatPoint() }; 60 60 #else 61 Vector< CGSize> advances = { CGSizeMake(15.15625, -18.046875), CGSizeMake(21.640625, 0.0), CGSizeMake(42.3046875, 0.0), CGSizeMake(55.8984375, 0.0), CGSizeMake(22.34375, 0.0) };62 Vector< CGPoint> origins = { };61 Vector<FloatSize> advances = { FloatSize(15.15625, -18.046875), FloatSize(21.640625, 0.0), FloatSize(42.3046875, 0.0), FloatSize(55.8984375, 0.0), FloatSize(22.34375, 0.0) }; 62 Vector<FloatPoint> origins = { }; 63 63 #endif 64 64 65 CGSize initialAdvance = CGSizeMake(-15.15625, 18.046875);65 FloatSize initialAdvance = FloatSize(-15.15625, 18.046875); 66 66 67 67 UChar characters[] = { 0x644, 0x637, 0x641, 0x627, 0x64b, 0x20 }; 68 68 size_t charactersLength = WTF_ARRAY_LENGTH(characters); 69 69 TextRun textRun(StringView(characters, charactersLength)); 70 auto run1 = ComplexTextController::ComplexTextRun::create ForTesting({ CGSizeMake(21.875, 0) }, { CGPointZero }, { 5 }, { 5 }, CGSizeZero, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(5, 1), false);71 auto run2 = ComplexTextController::ComplexTextRun::create ForTesting(advances, origins, { 193, 377, 447, 431, 458 }, { 4, 3, 2, 1, 0 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 5), false);70 auto run1 = ComplexTextController::ComplexTextRun::create({ FloatSize(21.875, 0) }, { FloatPoint() }, { 5 }, { 5 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 5, 6, false); 71 auto run2 = ComplexTextController::ComplexTextRun::create(advances, origins, { 193, 377, 447, 431, 458 }, { 4, 3, 2, 1, 0 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, 0, 5, false); 72 72 Vector<Ref<ComplexTextController::ComplexTextRun>> runs; 73 73 runs.append(WTFMove(run1)); … … 77 77 CGFloat totalWidth = 0; 78 78 for (size_t i = 1; i < advances.size(); ++i) 79 totalWidth += advances[i].width ;79 totalWidth += advances[i].width(); 80 80 EXPECT_NEAR(controller.totalWidth(), spaceWidth + totalWidth, 0.0001); 81 81 GlyphBuffer glyphBuffer; … … 84 84 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001); 85 85 controller.advance(1, &glyphBuffer); 86 EXPECT_NEAR(controller.runWidthSoFar(), advances[4].width , 0.0001);86 EXPECT_NEAR(controller.runWidthSoFar(), advances[4].width(), 0.0001); 87 87 controller.advance(6, &glyphBuffer); 88 88 EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + totalWidth, 0.0001); … … 90 90 EXPECT_NEAR(glyphBuffer.initialAdvance().height(), 0, 0.0001); 91 91 EXPECT_EQ(glyphBuffer.size(), 6U); 92 EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), advances[4].width , 0.0001);93 EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), advances[3].width , 0.0001);94 EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), advances[2].width , 0.0001);95 EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), advances[1].width , 0.0001);96 EXPECT_NEAR(glyphBuffer.advanceAt(4).width(), -initialAdvance.width , 0.0001);97 EXPECT_NEAR(glyphBuffer.advanceAt(5).width(), spaceWidth + initialAdvance.width , 0.0001);92 EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), advances[4].width(), 0.0001); 93 EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), advances[3].width(), 0.0001); 94 EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), advances[2].width(), 0.0001); 95 EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), advances[1].width(), 0.0001); 96 EXPECT_NEAR(glyphBuffer.advanceAt(4).width(), -initialAdvance.width(), 0.0001); 97 EXPECT_NEAR(glyphBuffer.advanceAt(5).width(), spaceWidth + initialAdvance.width(), 0.0001); 98 98 } 99 99 … … 107 107 108 108 #if USE_LAYOUT_SPECIFIC_ADVANCES 109 Vector< CGSize> advances = { CGSizeZero, CGSizeMake(21.640625, 0.0), CGSizeMake(42.3046875, 0.0), CGSizeMake(55.8984375, 0.0), CGSizeMake(22.34375, 0.0) };110 Vector< CGPoint> origins = { CGPointMake(-15.15625, 18.046875), CGPointZero, CGPointZero, CGPointZero, CGPointZero};109 Vector<FloatSize> advances = { FloatSize(), FloatSize(21.640625, 0.0), FloatSize(42.3046875, 0.0), FloatSize(55.8984375, 0.0), FloatSize(22.34375, 0.0) }; 110 Vector<FloatPoint> origins = { FloatPoint(-15.15625, 18.046875), FloatPoint(), FloatPoint(), FloatPoint(), FloatPoint() }; 111 111 #else 112 Vector< CGSize> advances = { CGSizeMake(15.15625, -18.046875), CGSizeMake(21.640625, 0.0), CGSizeMake(42.3046875, 0.0), CGSizeMake(55.8984375, 0.0), CGSizeMake(22.34375, 0.0) };113 Vector< CGPoint> origins = { };112 Vector<FloatSize> advances = { FloatSize(15.15625, -18.046875), FloatSize(21.640625, 0.0), FloatSize(42.3046875, 0.0), FloatSize(55.8984375, 0.0), FloatSize(22.34375, 0.0) }; 113 Vector<FloatPoint> origins = { }; 114 114 #endif 115 115 116 CGSize initialAdvance = CGSizeMake(-15.15625, 18.046875);116 FloatSize initialAdvance = FloatSize(-15.15625, 18.046875); 117 117 118 118 UChar characters[] = { 0x644, 0x637, 0x641, 0x627, 0x64b }; 119 119 size_t charactersLength = WTF_ARRAY_LENGTH(characters); 120 120 TextRun textRun(StringView(characters, charactersLength)); 121 auto run = ComplexTextController::ComplexTextRun::create ForTesting(advances, origins, { 193, 377, 447, 431, 458 }, { 4, 3, 2, 1, 0 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 5), false);121 auto run = ComplexTextController::ComplexTextRun::create(advances, origins, { 193, 377, 447, 431, 458 }, { 4, 3, 2, 1, 0 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, 0, 5, false); 122 122 Vector<Ref<ComplexTextController::ComplexTextRun>> runs; 123 123 runs.append(WTFMove(run)); … … 126 126 CGFloat totalWidth = 0; 127 127 for (size_t i = 1; i < advances.size(); ++i) 128 totalWidth += advances[i].width ;128 totalWidth += advances[i].width(); 129 129 EXPECT_NEAR(controller.totalWidth(), totalWidth, 0.0001); 130 130 GlyphBuffer glyphBuffer; … … 133 133 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001); 134 134 controller.advance(1, &glyphBuffer); 135 EXPECT_NEAR(controller.runWidthSoFar(), advances[4].width , 0.0001);135 EXPECT_NEAR(controller.runWidthSoFar(), advances[4].width(), 0.0001); 136 136 controller.advance(5, &glyphBuffer); 137 137 EXPECT_NEAR(controller.runWidthSoFar(), totalWidth, 0.0001); 138 EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width , 0.0001);139 EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height , 0.0001);138 EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width(), 0.0001); 139 EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height(), 0.0001); 140 140 EXPECT_EQ(glyphBuffer.size(), 5U); 141 EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), advances[4].width , 0.0001);142 EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), advances[3].width , 0.0001);143 EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), advances[2].width , 0.0001);144 EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), advances[1].width , 0.0001);145 EXPECT_NEAR(glyphBuffer.advanceAt(4).width(), -initialAdvance.width , 0.0001);146 EXPECT_NEAR(glyphBuffer.advanceAt(4).height(), initialAdvance.height , 0.0001);141 EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), advances[4].width(), 0.0001); 142 EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), advances[3].width(), 0.0001); 143 EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), advances[2].width(), 0.0001); 144 EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), advances[1].width(), 0.0001); 145 EXPECT_NEAR(glyphBuffer.advanceAt(4).width(), -initialAdvance.width(), 0.0001); 146 EXPECT_NEAR(glyphBuffer.advanceAt(4).height(), initialAdvance.height(), 0.0001); 147 147 } 148 148 … … 157 157 158 158 #if USE_LAYOUT_SPECIFIC_ADVANCES 159 Vector< CGSize> advances = { CGSizeMake(76.347656, 0.000000), CGSizeMake(0.000000, 0.000000) };160 Vector< CGPoint> origins = { CGPointZero, CGPointMake(-23.281250, -8.398438) };159 Vector<FloatSize> advances = { FloatSize(76.347656, 0.000000), FloatSize(0.000000, 0.000000) }; 160 Vector<FloatPoint> origins = { FloatPoint(), FloatPoint(-23.281250, -8.398438) }; 161 161 #else 162 Vector< CGSize> advances = { CGSizeMake(53.066406, -8.398438), CGSizeMake(23.281250, 8.398438) };163 Vector< CGPoint> origins = { };162 Vector<FloatSize> advances = { FloatSize(53.066406, -8.398438), FloatSize(23.281250, 8.398438) }; 163 Vector<FloatPoint> origins = { }; 164 164 #endif 165 165 166 CGSize initialAdvance = CGSizeMake(28.144531, 0);166 FloatSize initialAdvance = FloatSize(28.144531, 0); 167 167 168 168 UChar characters[] = { 0x20, 0x61, 0x20e3 }; 169 169 size_t charactersLength = WTF_ARRAY_LENGTH(characters); 170 170 TextRun textRun(StringView(characters, charactersLength)); 171 auto run1 = ComplexTextController::ComplexTextRun::create ForTesting({ CGSizeMake(spaceWidth, 0) }, { CGPointZero }, { 5 }, { 0 }, CGSizeZero, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 1), true);172 auto run2 = ComplexTextController::ComplexTextRun::create ForTesting(advances, origins, { 68, 1471 }, { 1, 2 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(1, 2), true);171 auto run1 = ComplexTextController::ComplexTextRun::create({ FloatSize(spaceWidth, 0) }, { FloatPoint() }, { 5 }, { 0 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 0, 1, true); 172 auto run2 = ComplexTextController::ComplexTextRun::create(advances, origins, { 68, 1471 }, { 1, 2 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, 1, 3, true); 173 173 Vector<Ref<ComplexTextController::ComplexTextRun>> runs; 174 174 runs.append(WTFMove(run1)); … … 176 176 ComplexTextController controller(font, textRun, runs); 177 177 178 EXPECT_NEAR(controller.totalWidth(), spaceWidth + 76.347656 + initialAdvance.width , 0.0001);178 EXPECT_NEAR(controller.totalWidth(), spaceWidth + 76.347656 + initialAdvance.width(), 0.0001); 179 179 GlyphBuffer glyphBuffer; 180 180 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001); … … 184 184 EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth, 0.0001); 185 185 controller.advance(2, &glyphBuffer); 186 EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + advances[0].width + initialAdvance.width, 0.0001);186 EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + advances[0].width() + initialAdvance.width(), 0.0001); 187 187 controller.advance(3, &glyphBuffer); 188 EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + 76.347656 + initialAdvance.width , 0.0001);188 EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + 76.347656 + initialAdvance.width(), 0.0001); 189 189 EXPECT_NEAR(glyphBuffer.initialAdvance().width(), 0, 0.0001); 190 190 EXPECT_NEAR(glyphBuffer.initialAdvance().height(), 0, 0.0001); 191 191 EXPECT_EQ(glyphBuffer.size(), 3U); 192 EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), spaceWidth + initialAdvance.width , 0.0001);192 EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), spaceWidth + initialAdvance.width(), 0.0001); 193 193 EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), 53.066406, 0.0001); 194 194 EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), 23.281250, 0.0001); … … 204 204 205 205 #if USE_LAYOUT_SPECIFIC_ADVANCES 206 Vector< CGSize> advances = { CGSizeMake(76.347656, 0.000000), CGSizeMake(0.000000, 0.000000) };207 Vector< CGPoint> origins = { CGPointZero, CGPointMake(-23.281250, -8.398438) };206 Vector<FloatSize> advances = { FloatSize(76.347656, 0.000000), FloatSize(0.000000, 0.000000) }; 207 Vector<FloatPoint> origins = { FloatPoint(), FloatPoint(-23.281250, -8.398438) }; 208 208 #else 209 Vector< CGSize> advances = { CGSizeMake(53.066406, -8.398438), CGSizeMake(23.281250, 8.398438) };210 Vector< CGPoint> origins = { };209 Vector<FloatSize> advances = { FloatSize(53.066406, -8.398438), FloatSize(23.281250, 8.398438) }; 210 Vector<FloatPoint> origins = { }; 211 211 #endif 212 212 213 CGSize initialAdvance = CGSizeMake(28.144531, 0);213 FloatSize initialAdvance = FloatSize(28.144531, 0); 214 214 215 215 UChar characters[] = { 0x61, 0x20e3 }; 216 216 size_t charactersLength = WTF_ARRAY_LENGTH(characters); 217 217 TextRun textRun(StringView(characters, charactersLength)); 218 auto run = ComplexTextController::ComplexTextRun::create ForTesting(advances, origins, { 68, 1471 }, { 0, 1 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 2), true);218 auto run = ComplexTextController::ComplexTextRun::create(advances, origins, { 68, 1471 }, { 0, 1 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, 0, 2, true); 219 219 Vector<Ref<ComplexTextController::ComplexTextRun>> runs; 220 220 runs.append(WTFMove(run)); 221 221 ComplexTextController controller(font, textRun, runs); 222 222 223 EXPECT_NEAR(controller.totalWidth(), 76.347656 + initialAdvance.width , 0.0001);224 GlyphBuffer glyphBuffer; 225 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001); 226 controller.advance(0, &glyphBuffer); 227 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001); 228 controller.advance(1, &glyphBuffer); 229 EXPECT_NEAR(controller.runWidthSoFar(), advances[0].width + initialAdvance.width, 0.0001);223 EXPECT_NEAR(controller.totalWidth(), 76.347656 + initialAdvance.width(), 0.0001); 224 GlyphBuffer glyphBuffer; 225 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001); 226 controller.advance(0, &glyphBuffer); 227 EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001); 228 controller.advance(1, &glyphBuffer); 229 EXPECT_NEAR(controller.runWidthSoFar(), advances[0].width() + initialAdvance.width(), 0.0001); 230 230 controller.advance(2, &glyphBuffer); 231 EXPECT_NEAR(controller.runWidthSoFar(), 76.347656 + initialAdvance.width , 0.0001);232 EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width , 0.0001);233 EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height , 0.0001);231 EXPECT_NEAR(controller.runWidthSoFar(), 76.347656 + initialAdvance.width(), 0.0001); 232 EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width(), 0.0001); 233 EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height(), 0.0001); 234 234 EXPECT_EQ(glyphBuffer.size(), 2U); 235 235 EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), 53.066406, 0.0001); … … 245 245 font.update(); 246 246 247 CGSize initialAdvance = CGSizeMake(4.33996383363472, 12.368896925859);247 FloatSize initialAdvance = FloatSize(4.33996383363472, 12.368896925859); 248 248 249 249 UChar characters[] = { 0x633, 0x20, 0x627, 0x650 }; 250 250 size_t charactersLength = WTF_ARRAY_LENGTH(characters); 251 251 TextRun textRun(StringView(characters, charactersLength)); 252 auto run1 = ComplexTextController::ComplexTextRun::create ForTesting({ CGSizeMake(-4.33996383363472, -12.368896925859), CGSizeMake(14.0397830018083, 0) }, { }, { 884, 240 }, { 3, 2 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(2, 2), false);253 auto run2 = ComplexTextController::ComplexTextRun::create ForTesting({ CGSizeMake(12.0, 0) }, { }, { 3 }, { 1 }, CGSizeZero, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(1, 1), false);254 auto run3 = ComplexTextController::ComplexTextRun::create ForTesting({ CGSizeMake(43.8119349005425, 0) }, { }, { 276 }, { 0 }, CGSizeZero, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 1), false);252 auto run1 = ComplexTextController::ComplexTextRun::create({ FloatSize(-4.33996383363472, -12.368896925859), FloatSize(14.0397830018083, 0) }, { }, { 884, 240 }, { 3, 2 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, 2, 4, false); 253 auto run2 = ComplexTextController::ComplexTextRun::create({ FloatSize(12.0, 0) }, { }, { 3 }, { 1 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 1, 2, false); 254 auto run3 = ComplexTextController::ComplexTextRun::create({ FloatSize(43.8119349005425, 0) }, { }, { 276 }, { 0 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 0, 1, false); 255 255 Vector<Ref<ComplexTextController::ComplexTextRun>> runs; 256 256 runs.append(WTFMove(run1)); … … 273 273 controller.advance(4, &glyphBuffer); 274 274 EXPECT_NEAR(controller.runWidthSoFar(), totalWidth, 0.0001); 275 EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width , 0.0001);276 EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height , 0.0001);275 EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width(), 0.0001); 276 EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height(), 0.0001); 277 277 EXPECT_EQ(glyphBuffer.size(), 4U); 278 278 EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), 43.8119349005425, 0.0001); … … 294 294 size_t charactersLength = WTF_ARRAY_LENGTH(characters); 295 295 TextRun textRun(StringView(characters, charactersLength), 0, 100, ForceLeadingExpansion); 296 auto run = ComplexTextController::ComplexTextRun::create ForTesting({ CGSizeMake(24, 0) }, { }, { 16 }, { 0 }, CGSizeZero, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 1), true);296 auto run = ComplexTextController::ComplexTextRun::create({ FloatSize(24, 0) }, { }, { 16 }, { 0 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 0, 1, true); 297 297 Vector<Ref<ComplexTextController::ComplexTextRun>> runs; 298 298 runs.append(WTFMove(run)); … … 324 324 size_t charactersLength = WTF_ARRAY_LENGTH(characters); 325 325 TextRun textRun(StringView(characters, charactersLength)); 326 auto run1 = ComplexTextController::ComplexTextRun::create ForTesting({ CGSizeMake(0, 1), CGSizeMake(0, 2) }, { CGPointMake(0, 4), CGPointMake(0, 8) }, { 16, 17 }, { 0, 1 }, CGSizeMake(0, 16), font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 2), true);327 auto run2 = ComplexTextController::ComplexTextRun::create ForTesting({ CGSizeMake(0, 32), CGSizeMake(0, 64) }, { CGPointMake(0, 128), CGPointMake(0, 256) }, { 18, 19 }, { 2, 3 }, CGSizeMake(0, 512), font.primaryFont(), characters, 0, charactersLength, CFRangeMake(2, 2), true);326 auto run1 = ComplexTextController::ComplexTextRun::create({ FloatSize(0, 1), FloatSize(0, 2) }, { FloatPoint(0, 4), FloatPoint(0, 8) }, { 16, 17 }, { 0, 1 }, FloatSize(0, 16), font.primaryFont(), characters, 0, charactersLength, 0, 2, true); 327 auto run2 = ComplexTextController::ComplexTextRun::create({ FloatSize(0, 32), FloatSize(0, 64) }, { FloatPoint(0, 128), FloatPoint(0, 256) }, { 18, 19 }, { 2, 3 }, FloatSize(0, 512), font.primaryFont(), characters, 0, charactersLength, 2, 4, true); 328 328 Vector<Ref<ComplexTextController::ComplexTextRun>> runs; 329 329 runs.append(WTFMove(run1));
Note: See TracChangeset
for help on using the changeset viewer.