Migrate ComplexTextController to use platform-independent types
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Feb 2017 02:14:53 +0000 (02:14 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Feb 2017 02:14:53 +0000 (02:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167833

Reviewed by Brent Fulgham.

Source/WebCore:

ComplexTextController will eventually be used on all ports to perform complex text layout.
This is a mechanical patch which migrates the shared parts of ComplexTextController away from
using CoreGraphics and CoreFoundation types in favor of WebCore/platform types. Eventually,
ComplexTextController will get moved to PAL but there is a layering violation (TextLayout) to
fix first.

No new tests because there is no behavior change.

* platform/graphics/GlyphBuffer.h:
(WebCore::GlyphBufferAdvance::GlyphBufferAdvance):
* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::ComplexTextController::offsetForPosition):
(WebCore::advanceByCombiningCharacterSequence):
(WebCore::ComplexTextController::ComplexTextRun::indexAt):
(WebCore::ComplexTextController::ComplexTextRun::setIsNonMonotonic):
(WebCore::ComplexTextController::advance):
(WebCore::ComplexTextController::adjustGlyphsAndAdvances):
* platform/graphics/mac/ComplexTextController.h:
(WebCore::ComplexTextController::ComplexTextRun::create):
(WebCore::ComplexTextController::ComplexTextRun::stringLength):
(WebCore::ComplexTextController::ComplexTextRun::indexBegin):
(WebCore::ComplexTextController::ComplexTextRun::indexEnd):
(WebCore::ComplexTextController::ComplexTextRun::endOffsetAt):
(WebCore::ComplexTextController::ComplexTextRun::glyphs):
(WebCore::ComplexTextController::ComplexTextRun::growInitialAdvanceHorizontally):
(WebCore::ComplexTextController::ComplexTextRun::initialAdvance):
(WebCore::ComplexTextController::ComplexTextRun::baseAdvances):
(WebCore::ComplexTextController::ComplexTextRun::glyphOrigins):
(WebCore::ComplexTextController::glyphOrigin):
(WebCore::ComplexTextController::ComplexTextRun::createForTesting): Deleted.
* platform/graphics/mac/ComplexTextControllerCoreText.mm:
(SOFT_LINK):
(WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
(WebCore::ComplexTextController::collectComplexTextRunsForCharacters):

Tools:

Migrate tests away from platform-dependent types.

* TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp:
(TestWebKitAPI::TEST_F):

LayoutTests:

Rebaseline tiny rounding result.

* platform/mac/fast/text/complex-text-opacity-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211765 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/mac/fast/text/complex-text-opacity-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GlyphBuffer.h
Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
Source/WebCore/platform/graphics/mac/ComplexTextController.h
Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp

index 9f55f35..09968ac 100644 (file)
@@ -1,3 +1,14 @@
+2017-02-06  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Migrate ComplexTextController to use platform-independent types
+        https://bugs.webkit.org/show_bug.cgi?id=167833
+
+        Reviewed by Brent Fulgham.
+
+        Rebaseline tiny rounding result.
+
+        * platform/mac/fast/text/complex-text-opacity-expected.txt:
+
 2017-02-06  Youenn Fablet  <youennf@gmail.com>
 
         Allow some schemes to opt-out of CORS
index d76afc4..6774cdd 100644 (file)
@@ -24,8 +24,8 @@ layer at (0,0) size 800x600
           text run at (139,4) width 7: " "
         RenderText {#text} at (188,4) size 7x29
           text run at (188,4) width 7: " "
-        RenderText {#text} at (237,4) size 7x29
-          text run at (237,4) width 7: " "
+        RenderText {#text} at (236,4) size 8x29
+          text run at (236,4) width 8: " "
         RenderText {#text} at (285,4) size 7x29
           text run at (285,4) width 7: " "
         RenderText {#text} at (334,4) size 7x29
index a57fbbd..7eed305 100644 (file)
@@ -1,3 +1,45 @@
+2017-02-06  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Migrate ComplexTextController to use platform-independent types
+        https://bugs.webkit.org/show_bug.cgi?id=167833
+
+        Reviewed by Brent Fulgham.
+
+        ComplexTextController will eventually be used on all ports to perform complex text layout.
+        This is a mechanical patch which migrates the shared parts of ComplexTextController away from
+        using CoreGraphics and CoreFoundation types in favor of WebCore/platform types. Eventually,
+        ComplexTextController will get moved to PAL but there is a layering violation (TextLayout) to
+        fix first.
+
+        No new tests because there is no behavior change.
+
+        * platform/graphics/GlyphBuffer.h:
+        (WebCore::GlyphBufferAdvance::GlyphBufferAdvance):
+        * platform/graphics/mac/ComplexTextController.cpp:
+        (WebCore::ComplexTextController::offsetForPosition):
+        (WebCore::advanceByCombiningCharacterSequence):
+        (WebCore::ComplexTextController::ComplexTextRun::indexAt):
+        (WebCore::ComplexTextController::ComplexTextRun::setIsNonMonotonic):
+        (WebCore::ComplexTextController::advance):
+        (WebCore::ComplexTextController::adjustGlyphsAndAdvances):
+        * platform/graphics/mac/ComplexTextController.h:
+        (WebCore::ComplexTextController::ComplexTextRun::create):
+        (WebCore::ComplexTextController::ComplexTextRun::stringLength):
+        (WebCore::ComplexTextController::ComplexTextRun::indexBegin):
+        (WebCore::ComplexTextController::ComplexTextRun::indexEnd):
+        (WebCore::ComplexTextController::ComplexTextRun::endOffsetAt):
+        (WebCore::ComplexTextController::ComplexTextRun::glyphs):
+        (WebCore::ComplexTextController::ComplexTextRun::growInitialAdvanceHorizontally):
+        (WebCore::ComplexTextController::ComplexTextRun::initialAdvance):
+        (WebCore::ComplexTextController::ComplexTextRun::baseAdvances):
+        (WebCore::ComplexTextController::ComplexTextRun::glyphOrigins):
+        (WebCore::ComplexTextController::glyphOrigin):
+        (WebCore::ComplexTextController::ComplexTextRun::createForTesting): Deleted.
+        * platform/graphics/mac/ComplexTextControllerCoreText.mm:
+        (SOFT_LINK):
+        (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
+        (WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
+
 2017-02-06  Brent Fulgham  <bfulgham@apple.com>
 
         Correct File Path Handling in SecurityOrigin and FileSystem
index 48c80d3..61f3f05 100644 (file)
@@ -62,7 +62,12 @@ typedef Glyph GlyphBufferGlyph;
 struct GlyphBufferAdvance : CGSize {
 public:
     GlyphBufferAdvance() : CGSize(CGSizeZero) { }
-    GlyphBufferAdvance(CGSize size) : CGSize(size)
+    GlyphBufferAdvance(CGSize size)
+        : CGSize(size)
+    {
+    }
+    GlyphBufferAdvance(float width, float height)
+        : CGSize(CGSizeMake(width, height))
     {
     }
 
index cfa8b83..dd9f3ca 100644 (file)
@@ -175,61 +175,63 @@ unsigned ComplexTextController::offsetForPosition(float h, bool includePartialGl
     if (h < 0)
         return m_run.ltr() ? 0 : m_end;
 
-    CGFloat x = h;
+    float x = h;
 
     size_t runCount = m_complexTextRuns.size();
-    size_t offsetIntoAdjustedGlyphs = 0;
+    unsigned offsetIntoAdjustedGlyphs = 0;
 
     for (size_t r = 0; r < runCount; ++r) {
         const ComplexTextRun& complexTextRun = *m_complexTextRuns[r];
         for (unsigned j = 0; j < complexTextRun.glyphCount(); ++j) {
-            size_t index = offsetIntoAdjustedGlyphs + j;
-            CGFloat adjustedAdvance = m_adjustedBaseAdvances[index].width;
+            unsigned index = offsetIntoAdjustedGlyphs + j;
+            float adjustedAdvance = m_adjustedBaseAdvances[index].width();
             if (x < adjustedAdvance) {
-                CFIndex hitGlyphStart = complexTextRun.indexAt(j);
-                CFIndex hitGlyphEnd;
+                unsigned hitGlyphStart = complexTextRun.indexAt(j);
+                unsigned hitGlyphEnd;
                 if (m_run.ltr())
-                    hitGlyphEnd = std::max<CFIndex>(hitGlyphStart, j + 1 < complexTextRun.glyphCount() ? complexTextRun.indexAt(j + 1) : static_cast<CFIndex>(complexTextRun.indexEnd()));
+                    hitGlyphEnd = std::max(hitGlyphStart, j + 1 < complexTextRun.glyphCount() ? complexTextRun.indexAt(j + 1) : complexTextRun.indexEnd());
                 else
-                    hitGlyphEnd = std::max<CFIndex>(hitGlyphStart, j > 0 ? complexTextRun.indexAt(j - 1) : static_cast<CFIndex>(complexTextRun.indexEnd()));
+                    hitGlyphEnd = std::max(hitGlyphStart, j > 0 ? complexTextRun.indexAt(j - 1) : complexTextRun.indexEnd());
 
                 // FIXME: Instead of dividing the glyph's advance equally between the characters, this
                 // could use the glyph's "ligature carets". This is available in CoreText via CTFontGetLigatureCaretPositions().
-                CFIndex hitIndex = hitGlyphStart + (hitGlyphEnd - hitGlyphStart) * (m_run.ltr() ? x / adjustedAdvance : 1 - x / adjustedAdvance);
-                int stringLength = complexTextRun.stringLength();
+                unsigned hitIndex = hitGlyphStart + (hitGlyphEnd - hitGlyphStart) * (m_run.ltr() ? x / adjustedAdvance : 1 - x / adjustedAdvance);
+                unsigned stringLength = complexTextRun.stringLength();
                 UBreakIterator* cursorPositionIterator = cursorMovementIterator(StringView(complexTextRun.characters(), stringLength));
-                int clusterStart;
+                unsigned clusterStart;
                 if (ubrk_isBoundary(cursorPositionIterator, hitIndex))
                     clusterStart = hitIndex;
                 else {
-                    clusterStart = ubrk_preceding(cursorPositionIterator, hitIndex);
-                    if (clusterStart == UBRK_DONE)
-                        clusterStart = 0;
+                    int preceeding = ubrk_preceding(cursorPositionIterator, hitIndex);
+                    clusterStart = preceeding == UBRK_DONE ? 0 : preceeding;
                 }
 
                 if (!includePartialGlyphs)
                     return complexTextRun.stringLocation() + clusterStart;
 
-                int clusterEnd = ubrk_following(cursorPositionIterator, hitIndex);
-                if (clusterEnd == UBRK_DONE)
-                    clusterEnd = stringLength;
+                int following = ubrk_following(cursorPositionIterator, hitIndex);
+                unsigned clusterEnd = following == UBRK_DONE ? stringLength : following;
 
-                CGFloat clusterWidth;
+                float clusterWidth;
                 // FIXME: The search stops at the boundaries of complexTextRun. In theory, it should go on into neighboring ComplexTextRuns
                 // derived from the same CTLine. In practice, we do not expect there to be more than one CTRun in a CTLine, as no
                 // reordering and no font fallback should occur within a CTLine.
                 if (clusterEnd - clusterStart > 1) {
                     clusterWidth = adjustedAdvance;
-                    int firstGlyphBeforeCluster = j - 1;
-                    while (firstGlyphBeforeCluster >= 0 && complexTextRun.indexAt(firstGlyphBeforeCluster) >= clusterStart && complexTextRun.indexAt(firstGlyphBeforeCluster) < clusterEnd) {
-                        CGFloat width = m_adjustedBaseAdvances[offsetIntoAdjustedGlyphs + firstGlyphBeforeCluster].width;
-                        clusterWidth += width;
-                        x += width;
-                        firstGlyphBeforeCluster--;
+                    if (j) {
+                        unsigned firstGlyphBeforeCluster = j - 1;
+                        while (complexTextRun.indexAt(firstGlyphBeforeCluster) >= clusterStart && complexTextRun.indexAt(firstGlyphBeforeCluster) < clusterEnd) {
+                            float width = m_adjustedBaseAdvances[offsetIntoAdjustedGlyphs + firstGlyphBeforeCluster].width();
+                            clusterWidth += width;
+                            x += width;
+                            if (!firstGlyphBeforeCluster)
+                                break;
+                            firstGlyphBeforeCluster--;
+                        }
                     }
                     unsigned firstGlyphAfterCluster = j + 1;
                     while (firstGlyphAfterCluster < complexTextRun.glyphCount() && complexTextRun.indexAt(firstGlyphAfterCluster) >= clusterStart && complexTextRun.indexAt(firstGlyphAfterCluster) < clusterEnd) {
-                        clusterWidth += m_adjustedBaseAdvances[offsetIntoAdjustedGlyphs + firstGlyphAfterCluster].width;
+                        clusterWidth += m_adjustedBaseAdvances[offsetIntoAdjustedGlyphs + firstGlyphAfterCluster].width();
                         firstGlyphAfterCluster++;
                     }
                 } else {
@@ -238,8 +240,7 @@ unsigned ComplexTextController::offsetForPosition(float h, bool includePartialGl
                 }
                 if (x <= clusterWidth / 2)
                     return complexTextRun.stringLocation() + (m_run.ltr() ? clusterStart : clusterEnd);
-                else
-                    return complexTextRun.stringLocation() + (m_run.ltr() ? clusterEnd : clusterStart);
+                return complexTextRun.stringLocation() + (m_run.ltr() ? clusterEnd : clusterStart);
             }
             x -= adjustedAdvance;
         }
@@ -270,9 +271,10 @@ static bool advanceByCombiningCharacterSequence(const UChar*& iterator, const UC
     bool sawJoiner = false;
     while (iterator < end) {
         UChar32 nextCharacter;
-        int markLength = 0;
+        unsigned markLength = 0;
         bool shouldContinue = false;
-        U16_NEXT(iterator, markLength, end - iterator, nextCharacter);
+        ASSERT(end >= iterator);
+        U16_NEXT(iterator, markLength, static_cast<unsigned>(end - iterator), nextCharacter);
 
         if (isVariationSelector(nextCharacter) || isEmojiFitzpatrickModifier(nextCharacter))
             shouldContinue = true;
@@ -453,7 +455,7 @@ void ComplexTextController::collectComplexTextRuns()
         m_complexTextRuns.reverse();
 }
 
-CFIndex ComplexTextController::ComplexTextRun::indexAt(size_t i) const
+unsigned ComplexTextController::ComplexTextRun::indexAt(unsigned i) const
 {
     ASSERT(i < m_glyphCount);
 
@@ -466,15 +468,15 @@ void ComplexTextController::ComplexTextRun::setIsNonMonotonic()
     m_isMonotonic = false;
 
     Vector<bool, 64> mappedIndices(m_stringLength, false);
-    for (size_t i = 0; i < m_glyphCount; ++i) {
-        ASSERT(indexAt(i) < static_cast<CFIndex>(m_stringLength));
+    for (unsigned i = 0; i < m_glyphCount; ++i) {
+        ASSERT(indexAt(i) < m_stringLength);
         mappedIndices[indexAt(i)] = true;
     }
 
     m_glyphEndOffsets.grow(m_glyphCount);
     for (unsigned i = 0; i < m_glyphCount; ++i) {
-        CFIndex nextMappedIndex = m_indexEnd;
-        for (size_t j = indexAt(i) + 1; j < m_stringLength; ++j) {
+        unsigned nextMappedIndex = m_indexEnd;
+        for (unsigned j = indexAt(i) + 1; j < m_stringLength; ++j) {
             if (mappedIndices[j]) {
                 nextMappedIndex = j;
                 break;
@@ -580,7 +582,7 @@ void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer, G
     while (m_currentRun < runCount) {
         const ComplexTextRun& complexTextRun = *m_complexTextRuns[currentRunIndex];
         bool ltr = complexTextRun.isLTR();
-        size_t glyphCount = complexTextRun.glyphCount();
+        unsigned glyphCount = complexTextRun.glyphCount();
         unsigned glyphIndexIntoCurrentRun = ltr ? m_glyphInCurrentRun : glyphCount - 1 - m_glyphInCurrentRun;
         unsigned glyphIndexIntoComplexTextController = indexOfLeftmostGlyphInCurrentRun + glyphIndexIntoCurrentRun;
         if (fallbackFonts && &complexTextRun.font() != &m_font.primaryFont())
@@ -590,41 +592,41 @@ void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer, G
         // When leftmostGlyph is 0, it represents the first glyph to draw, taking into
         // account the text direction.
         if (!indexOfLeftmostGlyphInCurrentRun && glyphBuffer)
-            glyphBuffer->setInitialAdvance(complexTextRun.initialAdvance());
+            glyphBuffer->setInitialAdvance(GlyphBufferAdvance(complexTextRun.initialAdvance().width(), complexTextRun.initialAdvance().height()));
 
         while (m_glyphInCurrentRun < glyphCount) {
             unsigned glyphStartOffset = complexTextRun.indexAt(glyphIndexIntoCurrentRun);
             unsigned glyphEndOffset;
             if (complexTextRun.isMonotonic()) {
                 if (ltr)
-                    glyphEndOffset = std::max<unsigned>(glyphStartOffset, static_cast<unsigned>(glyphIndexIntoCurrentRun + 1 < glyphCount ? complexTextRun.indexAt(glyphIndexIntoCurrentRun + 1) : complexTextRun.indexEnd()));
+                    glyphEndOffset = std::max(glyphStartOffset, glyphIndexIntoCurrentRun + 1 < glyphCount ? complexTextRun.indexAt(glyphIndexIntoCurrentRun + 1) : complexTextRun.indexEnd());
                 else
-                    glyphEndOffset = std::max<unsigned>(glyphStartOffset, static_cast<unsigned>(glyphIndexIntoCurrentRun > 0 ? complexTextRun.indexAt(glyphIndexIntoCurrentRun - 1) : complexTextRun.indexEnd()));
+                    glyphEndOffset = std::max(glyphStartOffset, glyphIndexIntoCurrentRun > 0 ? complexTextRun.indexAt(glyphIndexIntoCurrentRun - 1) : complexTextRun.indexEnd());
             } else
                 glyphEndOffset = complexTextRun.endOffsetAt(glyphIndexIntoCurrentRun);
 
-            CGSize adjustedBaseAdvance = m_adjustedBaseAdvances[glyphIndexIntoComplexTextController];
+            FloatSize adjustedBaseAdvance = m_adjustedBaseAdvances[glyphIndexIntoComplexTextController];
 
             if (glyphStartOffset + complexTextRun.stringLocation() >= m_currentCharacter)
                 return;
 
             if (glyphBuffer && !m_characterInCurrentGlyph) {
                 auto currentGlyphOrigin = glyphOrigin(glyphIndexIntoComplexTextController);
-                GlyphBufferAdvance paintAdvance = adjustedBaseAdvance;
+                GlyphBufferAdvance paintAdvance(adjustedBaseAdvance);
                 if (!glyphIndexIntoCurrentRun) {
                     // The first layout advance of every run includes the "initial layout advance." However, here, we need
                     // paint advances, so subtract it out before transforming the layout advance into a paint advance.
-                    paintAdvance.setWidth(paintAdvance.width() - (complexTextRun.initialAdvance().width - currentGlyphOrigin.x));
-                    paintAdvance.setHeight(paintAdvance.height() - (complexTextRun.initialAdvance().height - currentGlyphOrigin.y));
+                    paintAdvance.setWidth(paintAdvance.width() - (complexTextRun.initialAdvance().width() - currentGlyphOrigin.x()));
+                    paintAdvance.setHeight(paintAdvance.height() - (complexTextRun.initialAdvance().height() - currentGlyphOrigin.y()));
                 }
-                paintAdvance.setWidth(paintAdvance.width() + glyphOrigin(glyphIndexIntoComplexTextController + 1).x - currentGlyphOrigin.x);
-                paintAdvance.setHeight(paintAdvance.height() + glyphOrigin(glyphIndexIntoComplexTextController + 1).y - currentGlyphOrigin.y);
+                paintAdvance.setWidth(paintAdvance.width() + glyphOrigin(glyphIndexIntoComplexTextController + 1).x() - currentGlyphOrigin.x());
+                paintAdvance.setHeight(paintAdvance.height() + glyphOrigin(glyphIndexIntoComplexTextController + 1).y() - currentGlyphOrigin.y());
                 if (glyphIndexIntoCurrentRun == glyphCount - 1 && currentRunIndex + 1 < runCount) {
                     // Our paint advance points to the end of the run. However, the next run may have an
                     // initial advance, and our paint advance needs to point to the location of the next
                     // glyph. So, we need to add in the next run's initial advance.
-                    paintAdvance.setWidth(paintAdvance.width() - glyphOrigin(glyphIndexIntoComplexTextController + 1).x + m_complexTextRuns[currentRunIndex + 1]->initialAdvance().width);
-                    paintAdvance.setHeight(paintAdvance.height() - glyphOrigin(glyphIndexIntoComplexTextController + 1).y + m_complexTextRuns[currentRunIndex + 1]->initialAdvance().height);
+                    paintAdvance.setWidth(paintAdvance.width() - glyphOrigin(glyphIndexIntoComplexTextController + 1).x() + m_complexTextRuns[currentRunIndex + 1]->initialAdvance().width());
+                    paintAdvance.setHeight(paintAdvance.height() - glyphOrigin(glyphIndexIntoComplexTextController + 1).y() + m_complexTextRuns[currentRunIndex + 1]->initialAdvance().height());
                 }
                 paintAdvance.setHeight(-paintAdvance.height()); // Increasing y points down
                 glyphBuffer->add(m_adjustedGlyphs[glyphIndexIntoComplexTextController], &complexTextRun.font(), paintAdvance, complexTextRun.indexAt(m_glyphInCurrentRun));
@@ -632,7 +634,7 @@ void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer, G
 
             unsigned oldCharacterInCurrentGlyph = m_characterInCurrentGlyph;
             m_characterInCurrentGlyph = std::min(m_currentCharacter - complexTextRun.stringLocation(), glyphEndOffset) - glyphStartOffset;
-            m_runWidthSoFar += adjustedBaseAdvance.width * runWidthSoFarFraction(glyphStartOffset, glyphEndOffset, oldCharacterInCurrentGlyph, iterationStyle);
+            m_runWidthSoFar += adjustedBaseAdvance.width() * runWidthSoFarFraction(glyphStartOffset, glyphEndOffset, oldCharacterInCurrentGlyph, iterationStyle);
 
             if (glyphEndOffset + complexTextRun.stringLocation() > m_currentCharacter)
                 return;
@@ -681,7 +683,7 @@ static inline std::pair<bool, bool> expansionLocation(bool ideograph, bool treat
 void ComplexTextController::adjustGlyphsAndAdvances()
 {
     bool afterExpansion = (m_run.expansionBehavior() & LeadingExpansionMask) == ForbidLeadingExpansion;
-    CGFloat widthSinceLastCommit = 0;
+    float widthSinceLastCommit = 0;
     size_t runCount = m_complexTextRuns.size();
     bool hasExtraSpacing = (m_font.letterSpacing() || m_font.wordSpacing() || m_expansion) && !m_run.spacingDisabled();
     bool runForcesLeadingExpansion = (m_run.expansionBehavior() & LeadingExpansionMask) == ForceLeadingExpansion;
@@ -699,17 +701,17 @@ void ComplexTextController::adjustGlyphsAndAdvances()
             m_isLTROnly = false;
 
         const CGGlyph* glyphs = complexTextRun.glyphs();
-        const CGSize* advances = complexTextRun.baseAdvances();
+        const FloatSize* advances = complexTextRun.baseAdvances();
 
         bool lastRun = runIndex + 1 == runCount;
         float spaceWidth = font.spaceWidth() - font.syntheticBoldOffset();
         const UChar* cp = complexTextRun.characters();
-        CGPoint glyphOrigin = CGPointZero;
-        CFIndex lastCharacterIndex = m_run.ltr() ? std::numeric_limits<CFIndex>::min() : std::numeric_limits<CFIndex>::max();
+        FloatPoint glyphOrigin;
+        unsigned lastCharacterIndex = m_run.ltr() ? std::numeric_limits<unsigned>::min() : std::numeric_limits<unsigned>::max();
         bool isMonotonic = true;
 
         for (unsigned i = 0; i < glyphCount; i++) {
-            CFIndex characterIndex = complexTextRun.indexAt(i);
+            unsigned characterIndex = complexTextRun.indexAt(i);
             if (m_run.ltr()) {
                 if (characterIndex < lastCharacterIndex)
                     isMonotonic = false;
@@ -729,35 +731,32 @@ void ComplexTextController::adjustGlyphsAndAdvances()
 
             bool treatAsSpace = FontCascade::treatAsSpace(ch);
             CGGlyph glyph = treatAsSpace ? font.spaceGlyph() : glyphs[i];
-            CGSize advance = treatAsSpace ? CGSizeMake(spaceWidth, advances[i].height) : advances[i];
+            FloatSize advance = treatAsSpace ? FloatSize(spaceWidth, advances[i].height()) : advances[i];
 
             if (ch == '\t' && m_run.allowTabs())
-                advance.width = m_font.tabWidth(font, m_run.tabSize(), m_run.xPos() + m_totalWidth + widthSinceLastCommit);
+                advance.setWidth(m_font.tabWidth(font, m_run.tabSize(), m_run.xPos() + m_totalWidth + widthSinceLastCommit));
             else if (FontCascade::treatAsZeroWidthSpace(ch) && !treatAsSpace) {
-                advance.width = 0;
+                advance.setWidth(0);
                 glyph = font.spaceGlyph();
             }
 
             if (!i) {
-                advance.width += complexTextRun.initialAdvance().width;
-                advance.height += complexTextRun.initialAdvance().height;
-                if (auto* origins = complexTextRun.glyphOrigins()) {
-                    advance.width -= origins[0].x;
-                    advance.height -= origins[0].y;
-                }
+                advance.expand(complexTextRun.initialAdvance().width(), complexTextRun.initialAdvance().height());
+                if (auto* origins = complexTextRun.glyphOrigins())
+                    advance.expand(-origins[0].x(), -origins[0].y());
             }
 
-            advance.width += font.syntheticBoldOffset();
+            advance.expand(font.syntheticBoldOffset(), 0);
 
             if (hasExtraSpacing) {
                 // If we're a glyph with an advance, add in letter-spacing.
-                // That way we weed out zero width lurkers.  This behavior matches the fast text code path.
-                if (advance.width)
-                    advance.width += m_font.letterSpacing();
+                // That way we weed out zero width lurkers. This behavior matches the fast text code path.
+                if (advance.width())
+                    advance.expand(m_font.letterSpacing(), 0);
 
                 unsigned characterIndexInRun = characterIndex + complexTextRun.stringLocation();
                 bool isFirstCharacter = !(characterIndex + complexTextRun.stringLocation());
-                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)));
+                bool isLastCharacter = characterIndexInRun + 1 == m_run.length() || (U16_IS_LEAD(ch) && characterIndexInRun + 2 == m_run.length() && U16_IS_TRAIL(*(cp + characterIndex + 1)));
 
                 bool forceLeadingExpansion = false; // On the left, regardless of m_run.ltr()
                 bool forceTrailingExpansion = false; // On the right, regardless of m_run.ltr()
@@ -779,13 +778,13 @@ void ComplexTextController::adjustGlyphsAndAdvances()
                         bool expandLeft, expandRight;
                         std::tie(expandLeft, expandRight) = expansionLocation(ideograph, treatAsSpace, m_run.ltr(), afterExpansion, forbidLeadingExpansion, forbidTrailingExpansion, forceLeadingExpansion, forceTrailingExpansion);
                         m_expansion -= m_expansionPerOpportunity;
-                        advance.width += m_expansionPerOpportunity;
+                        advance.expand(m_expansionPerOpportunity, 0);
                         if (expandLeft) {
                             // Increase previous width
                             if (m_adjustedBaseAdvances.isEmpty())
                                 complexTextRun.growInitialAdvanceHorizontally(m_expansionPerOpportunity);
                             else
-                                m_adjustedBaseAdvances.last().width += m_expansionPerOpportunity;
+                                m_adjustedBaseAdvances.last().expand(m_expansionPerOpportunity, 0);
                         }
                         if (expandRight)
                             afterExpansion = true;
@@ -794,12 +793,12 @@ void ComplexTextController::adjustGlyphsAndAdvances()
 
                     // Account for word-spacing.
                     if (treatAsSpace && (ch != '\t' || !m_run.allowTabs()) && (characterIndex > 0 || runIndex > 0) && m_font.wordSpacing())
-                        advance.width += m_font.wordSpacing();
+                        advance.expand(m_font.wordSpacing(), 0);
                 } else
                     afterExpansion = false;
             }
 
-            widthSinceLastCommit += advance.width
+            widthSinceLastCommit += advance.width();
 
             // FIXME: Combining marks should receive a text emphasis mark if they are combine with a space.
             if (m_forTextEmphasis && (!FontCascade::canReceiveTextEmphasis(ch) || (U_GET_GC_MASK(ch) & U_GC_M_MASK)))
@@ -815,13 +814,12 @@ void ComplexTextController::adjustGlyphsAndAdvances()
             m_adjustedGlyphs.append(glyph);
             
             FloatRect glyphBounds = font.boundsForGlyph(glyph);
-            glyphBounds.move(glyphOrigin.x, glyphOrigin.y);
+            glyphBounds.move(glyphOrigin.x(), glyphOrigin.y());
             m_minGlyphBoundingBoxX = std::min(m_minGlyphBoundingBoxX, glyphBounds.x());
             m_maxGlyphBoundingBoxX = std::max(m_maxGlyphBoundingBoxX, glyphBounds.maxX());
             m_minGlyphBoundingBoxY = std::min(m_minGlyphBoundingBoxY, glyphBounds.y());
             m_maxGlyphBoundingBoxY = std::max(m_maxGlyphBoundingBoxY, glyphBounds.maxY());
-            glyphOrigin.x += advance.width;
-            glyphOrigin.y += advance.height;
+            glyphOrigin.move(advance);
             
             lastCharacterIndex = characterIndex;
         }
index 7771b11..09aba55 100644 (file)
@@ -22,9 +22,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef ComplexTextController_h
-#define ComplexTextController_h
+#pragma once
 
+#include "FloatPoint.h"
 #include "GlyphBuffer.h"
 #include <wtf/HashSet.h>
 #include <wtf/RefCounted.h>
@@ -39,10 +39,6 @@ typedef unsigned short CGGlyph;
 typedef const struct __CTRun * CTRunRef;
 typedef const struct __CTLine * CTLineRef;
 
-namespace WTF {
-template<> struct VectorTraits<CGPoint> : SimpleClassVectorTraits { };
-}
-
 namespace WebCore {
 
 class FontCascade;
@@ -78,31 +74,31 @@ public:
 
     class ComplexTextRun : public RefCounted<ComplexTextRun> {
     public:
-        static Ref<ComplexTextRun> create(CTRunRef ctRun, const Font& font, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)
+        static Ref<ComplexTextRun> create(CTRunRef ctRun, const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd)
         {
-            return adoptRef(*new ComplexTextRun(ctRun, font, characters, stringLocation, stringLength, runRange));
+            return adoptRef(*new ComplexTextRun(ctRun, font, characters, stringLocation, stringLength, indexBegin, indexEnd));
         }
 
-        static Ref<ComplexTextRun> create(const Font& font, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr)
+        static Ref<ComplexTextRun> create(const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr)
         {
-            return adoptRef(*new ComplexTextRun(font, characters, stringLocation, stringLength, ltr));
+            return adoptRef(*new ComplexTextRun(font, characters, stringLocation, stringLength, indexBegin, indexEnd, ltr));
         }
 
-        static Ref<ComplexTextRun> createForTesting(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)
+        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)
         {
-            return adoptRef(*new ComplexTextRun(advances, origins, glyphs, stringIndices, initialAdvance, font, characters, stringLocation, stringLength, runRange, ltr));
+            return adoptRef(*new ComplexTextRun(advances, origins, glyphs, stringIndices, initialAdvance, font, characters, stringLocation, stringLength, indexBegin, indexEnd, ltr));
         }
 
         unsigned glyphCount() const { return m_glyphCount; }
         const Font& font() const { return m_font; }
         const UChar* characters() const { return m_characters; }
         unsigned stringLocation() const { return m_stringLocation; }
-        size_t stringLength() const { return m_stringLength; }
-        ALWAYS_INLINE CFIndex indexAt(size_t i) const;
-        CFIndex indexBegin() const { return m_indexBegin; }
-        CFIndex indexEnd() const { return m_indexEnd; }
-        CFIndex endOffsetAt(size_t i) const { ASSERT(!m_isMonotonic); return m_glyphEndOffsets[i]; }
-        const CGGlyph* glyphs() const { return m_glyphs; }
+        unsigned stringLength() const { return m_stringLength; }
+        ALWAYS_INLINE unsigned indexAt(unsigned) const;
+        unsigned indexBegin() const { return m_indexBegin; }
+        unsigned indexEnd() const { return m_indexEnd; }
+        unsigned endOffsetAt(unsigned i) const { ASSERT(!m_isMonotonic); return m_glyphEndOffsets[i]; }
+        const CGGlyph* glyphs() const { return m_glyphs.data(); }
 
         /*
          * This is the format of the information CoreText gives us about each run:
@@ -131,33 +127,30 @@ public:
          *                X--------------------------------------------------X--------------------------X--------------------------X
          * (text position ^)                (layout advance)                       (layout advance)           (layout advance)
          */
-        void growInitialAdvanceHorizontally(CGFloat delta) { m_initialAdvance.width += delta; }
-        CGSize initialAdvance() const { return m_initialAdvance; }
-        const CGSize* baseAdvances() const { return m_baseAdvances; }
-        const CGPoint* glyphOrigins() const { return m_glyphOrigins.size() == glyphCount() ? m_glyphOrigins.data() : nullptr; }
+        void growInitialAdvanceHorizontally(float delta) { m_initialAdvance.expand(delta, 0); }
+        FloatSize initialAdvance() const { return m_initialAdvance; }
+        const FloatSize* baseAdvances() const { return m_baseAdvances.data(); }
+        const FloatPoint* glyphOrigins() const { return m_glyphOrigins.size() == glyphCount() ? m_glyphOrigins.data() : nullptr; }
         bool isLTR() const { return m_isLTR; }
         bool isMonotonic() const { return m_isMonotonic; }
         void setIsNonMonotonic();
 
     private:
-        ComplexTextRun(CTRunRef, const Font&, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange);
-        ComplexTextRun(const Font&, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr);
-        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);
-
-        Vector<CGSize, 64> m_baseAdvancesVector;
-        Vector<CGPoint, 64> m_glyphOrigins;
-        Vector<CGGlyph, 64> m_glyphsVector;
-        Vector<CFIndex, 64> m_glyphEndOffsets;
-        Vector<CFIndex, 64> m_coreTextIndicesVector;
-        CGSize m_initialAdvance;
+        ComplexTextRun(CTRunRef, const Font&, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd);
+        ComplexTextRun(const Font&, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr);
+        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);
+
+        Vector<FloatSize, 64> m_baseAdvances;
+        Vector<FloatPoint, 64> m_glyphOrigins;
+        Vector<CGGlyph, 64> m_glyphs;
+        Vector<unsigned, 64> m_glyphEndOffsets;
+        Vector<unsigned, 64> m_coreTextIndices;
+        FloatSize m_initialAdvance;
         const Font& m_font;
         const UChar* m_characters;
-        size_t m_stringLength;
-        const CFIndex* m_coreTextIndices;
-        const CGGlyph* m_glyphs;
-        const CGSize* m_baseAdvances;
-        CFIndex m_indexBegin;
-        CFIndex m_indexEnd;
+        unsigned m_stringLength;
+        unsigned m_indexBegin;
+        unsigned m_indexEnd;
         unsigned m_glyphCount;
         unsigned m_stringLocation;
         bool m_isLTR;
@@ -180,10 +173,10 @@ private:
 
     float runWidthSoFarFraction(unsigned glyphStartOffset, unsigned glyphEndOffset, unsigned oldCharacterInCurrentGlyph, GlyphIterationStyle) const;
 
-    CGPoint glyphOrigin(unsigned index) const { return index < m_glyphOrigins.size() ? m_glyphOrigins[index] : CGPointZero; }
+    FloatPoint glyphOrigin(unsigned index) const { return index < m_glyphOrigins.size() ? m_glyphOrigins[index] : FloatPoint(); }
 
-    Vector<CGSize, 256> m_adjustedBaseAdvances;
-    Vector<CGPoint, 256> m_glyphOrigins;
+    Vector<FloatSize, 256> m_adjustedBaseAdvances;
+    Vector<FloatPoint, 256> m_glyphOrigins;
     Vector<CGGlyph, 256> m_adjustedGlyphs;
 
     Vector<UChar, 256> m_smallCapsBuffer;
@@ -210,7 +203,7 @@ private:
 
     const FontCascade& m_font;
     const TextRun& m_run;
+
     unsigned m_currentCharacter { 0 };
     unsigned m_end { 0 };
 
@@ -234,5 +227,3 @@ private:
 };
 
 } // namespace WebCore
-
-#endif // ComplexTextController_h
index 8824310..24bf27e 100644 (file)
 
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101100) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 90000)
 SOFT_LINK_FRAMEWORK(CoreText);
-SOFT_LINK(CoreText, CTRunGetBaseAdvancesAndOrigins, void, (CTRunRef run, CFRange range, CGSize baseAdvances[], CGPoint origins[]), (run, range, baseAdvances, origins))
+SOFT_LINK(CoreText, CTRunGetBaseAdvancesAndOrigins, void, (CTRunRef run, CFRange range, FloatSize baseAdvances[], FloatPoint origins[]), (run, range, baseAdvances, origins))
 #endif
 
-
 // Note: CTFontDescriptorRefs can live forever in caches inside CoreText, so this object can too.
 @interface WebCascadeList : NSArray {
     @private
@@ -106,97 +105,108 @@ SOFT_LINK(CoreText, CTRunGetBaseAdvancesAndOrigins, void, (CTRunRef run, CFRange
 
 namespace WebCore {
 
-ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const Font& font, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)
+ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd)
     : m_initialAdvance(CTRunGetInitialAdvance(ctRun))
     , m_font(font)
     , m_characters(characters)
     , m_stringLength(stringLength)
-    , m_coreTextIndices(CTRunGetStringIndicesPtr(ctRun))
-    , m_glyphs(CTRunGetGlyphsPtr(ctRun))
-    , m_indexBegin(runRange.location)
-    , m_indexEnd(runRange.location + runRange.length)
+    , m_indexBegin(indexBegin)
+    , m_indexEnd(indexEnd)
     , m_glyphCount(CTRunGetGlyphCount(ctRun))
     , m_stringLocation(stringLocation)
     , m_isLTR(!(CTRunGetStatus(ctRun) & kCTRunStatusRightToLeft))
 {
-    if (!m_coreTextIndices) {
-        m_coreTextIndicesVector.grow(m_glyphCount);
-        CTRunGetStringIndices(ctRun, CFRangeMake(0, 0), m_coreTextIndicesVector.data());
-        m_coreTextIndices = m_coreTextIndicesVector.data();
+    const CFIndex* coreTextIndicesPtr = CTRunGetStringIndicesPtr(ctRun);
+    Vector<CFIndex> coreTextIndices;
+    if (!coreTextIndicesPtr) {
+        coreTextIndices.grow(m_glyphCount);
+        CTRunGetStringIndices(ctRun, CFRangeMake(0, 0), coreTextIndices.data());
+        coreTextIndicesPtr = coreTextIndices.data();
     }
-
-    if (!m_glyphs) {
-        m_glyphsVector.grow(m_glyphCount);
-        CTRunGetGlyphs(ctRun, CFRangeMake(0, 0), m_glyphsVector.data());
-        m_glyphs = m_glyphsVector.data();
+    m_coreTextIndices.reserveInitialCapacity(m_glyphCount);
+    for (unsigned i = 0; i < m_glyphCount; ++i)
+        m_coreTextIndices.uncheckedAppend(coreTextIndicesPtr[i]);
+
+    const CGGlyph* glyphsPtr = CTRunGetGlyphsPtr(ctRun);
+    Vector<CGGlyph> glyphs;
+    if (!glyphsPtr) {
+        glyphs.grow(m_glyphCount);
+        CTRunGetGlyphs(ctRun, CFRangeMake(0, 0), glyphs.data());
+        glyphsPtr = glyphs.data();
     }
+    m_glyphs.reserveInitialCapacity(m_glyphCount);
+    for (unsigned i = 0; i < m_glyphCount; ++i)
+        m_glyphs.uncheckedAppend(glyphsPtr[i]);
 
 #if USE_LAYOUT_SPECIFIC_ADVANCES
     if (CTRunGetStatus(ctRun) & kCTRunStatusHasOrigins) {
-        m_baseAdvancesVector.grow(m_glyphCount);
-        m_glyphOrigins.grow(m_glyphCount);
-        CTRunGetBaseAdvancesAndOrigins(ctRun, CFRangeMake(0, 0), m_baseAdvancesVector.data(), m_glyphOrigins.data());
-        m_baseAdvances = m_baseAdvancesVector.data();
+        Vector<CGSize> baseAdvances(m_glyphCount);
+        Vector<CGPoint> glyphOrigins(m_glyphCount);
+        CTRunGetBaseAdvancesAndOrigins(ctRun, CFRangeMake(0, 0), baseAdvances.data(), glyphOrigins.data());
+        m_baseAdvances.reserveInitialCapacity(m_glyphCount);
+        m_glyphOrigins.reserveInitialCapacity(m_glyphCount);
+        for (unsigned i = 0; i < m_glyphCount; ++i) {
+            m_baseAdvances.uncheckedAppend(baseAdvances[i]);
+            m_glyphOrigins.uncheckedAppend(glyphOrigins[i]);
+        }
     } else
 #endif
     {
-        m_baseAdvances = CTRunGetAdvancesPtr(ctRun);
-        if (!m_baseAdvances) {
-            m_baseAdvancesVector.grow(m_glyphCount);
-            CTRunGetAdvances(ctRun, CFRangeMake(0, 0), m_baseAdvancesVector.data());
-            m_baseAdvances = m_baseAdvancesVector.data();
+        const CGSize* baseAdvances = CTRunGetAdvancesPtr(ctRun);
+        Vector<CGSize> baseAdvancesVector;
+        if (!baseAdvances) {
+            baseAdvancesVector.grow(m_glyphCount);
+            CTRunGetAdvances(ctRun, CFRangeMake(0, 0), baseAdvancesVector.data());
+            baseAdvances = baseAdvancesVector.data();
         }
+        m_baseAdvances.reserveInitialCapacity(m_glyphCount);
+        for (unsigned i = 0; i < m_glyphCount; ++i)
+            m_baseAdvances.uncheckedAppend(baseAdvances[i]);
     }
 }
 
 // Missing glyphs run constructor. Core Text will not generate a run of missing glyphs, instead falling back on
 // glyphs from LastResort. We want to use the primary font's missing glyph in order to match the fast text code path.
-ComplexTextController::ComplexTextRun::ComplexTextRun(const Font& font, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr)
-    : m_initialAdvance(CGSizeZero)
-    , m_font(font)
+ComplexTextController::ComplexTextRun::ComplexTextRun(const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr)
+    : m_font(font)
     , m_characters(characters)
     , m_stringLength(stringLength)
-    , m_indexBegin(0)
-    , m_indexEnd(stringLength)
+    , m_indexBegin(indexBegin)
+    , m_indexEnd(indexEnd)
     , m_stringLocation(stringLocation)
     , m_isLTR(ltr)
 {
-    m_coreTextIndicesVector.reserveInitialCapacity(m_stringLength);
-    unsigned r = 0;
-    while (r < m_stringLength) {
-        m_coreTextIndicesVector.uncheckedAppend(r);
+    auto runLengthInCodeUnits = m_indexEnd - m_indexBegin;
+    m_coreTextIndices.reserveInitialCapacity(runLengthInCodeUnits);
+    unsigned r = m_indexBegin;
+    while (r < m_indexEnd) {
+        m_coreTextIndices.uncheckedAppend(r);
         UChar32 character;
         U16_NEXT(m_characters, r, m_stringLength, character);
     }
-    m_glyphCount = m_coreTextIndicesVector.size();
+    m_glyphCount = m_coreTextIndices.size();
     if (!ltr) {
         for (unsigned r = 0, end = m_glyphCount - 1; r < m_glyphCount / 2; ++r, --end)
-            std::swap(m_coreTextIndicesVector[r], m_coreTextIndicesVector[end]);
+            std::swap(m_coreTextIndices[r], m_coreTextIndices[end]);
     }
-    m_coreTextIndices = m_coreTextIndicesVector.data();
 
     // Synthesize a run of missing glyphs.
-    m_glyphsVector.fill(0, m_glyphCount);
-    m_glyphs = m_glyphsVector.data();
-    m_baseAdvancesVector.fill(CGSizeMake(m_font.widthForGlyph(0), 0), m_glyphCount);
-    m_baseAdvances = m_baseAdvancesVector.data();
+    m_glyphs.fill(0, m_glyphCount);
+    m_baseAdvances.fill(FloatSize(m_font.widthForGlyph(0), 0), m_glyphCount);
 }
 
 
-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)
-    : m_baseAdvancesVector(advances)
+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)
+    : m_baseAdvances(advances)
     , m_glyphOrigins(origins)
-    , m_glyphsVector(glyphs)
-    , m_coreTextIndicesVector(stringIndices)
+    , m_glyphs(glyphs)
+    , m_coreTextIndices(stringIndices)
     , m_initialAdvance(initialAdvance)
     , m_font(font)
     , m_characters(characters)
     , m_stringLength(stringLength)
-    , m_coreTextIndices(m_coreTextIndicesVector.data())
-    , m_glyphs(m_glyphsVector.data())
-    , m_baseAdvances(m_baseAdvancesVector.data())
-    , m_indexBegin(runRange.location)
-    , m_indexEnd(runRange.location + runRange.length)
+    , m_indexBegin(indexBegin)
+    , m_indexEnd(indexEnd)
     , m_glyphCount(glyphs.size())
     , m_stringLocation(stringLocation)
     , m_isLTR(ltr)
@@ -229,7 +239,7 @@ void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cp,
 {
     if (!font) {
         // Create a run of missing glyphs from the primary font.
-        m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFont(), cp, stringLocation, length, m_run.ltr()));
+        m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFont(), cp, stringLocation, length, 0, length, m_run.ltr()));
         return;
     }
 
@@ -313,7 +323,7 @@ void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cp,
                     // NSFontRenderingMode.
                     RetainPtr<CFStringRef> fontName = adoptCF(CTFontCopyPostScriptName(runCTFont));
                     if (CFEqual(fontName.get(), CFSTR("LastResort"))) {
-                        m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFont(), cp, stringLocation + runRange.location, runRange.length, m_run.ltr()));
+                        m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFont(), cp, stringLocation, length, runRange.location, runRange.location + runRange.length, m_run.ltr()));
                         continue;
                     }
                     auto& fontCache = FontCache::singleton();
@@ -332,7 +342,7 @@ void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cp,
         if (m_fallbackFonts && runFont != &m_font.primaryFont())
             m_fallbackFonts->add(font);
 
-        m_complexTextRuns.append(ComplexTextRun::create(ctRun, *runFont, cp, stringLocation, length, runRange));
+        m_complexTextRuns.append(ComplexTextRun::create(ctRun, *runFont, cp, stringLocation, length, runRange.location, runRange.location + runRange.length));
     }
 }
 
index 0e055d6..515c90f 100644 (file)
@@ -1,3 +1,15 @@
+2017-02-06  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Migrate ComplexTextController to use platform-independent types
+        https://bugs.webkit.org/show_bug.cgi?id=167833
+
+        Reviewed by Brent Fulgham.
+
+        Migrate tests away from platform-dependent types.
+
+        * TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2017-02-06  Brent Fulgham  <bfulgham@apple.com>
 
         Correct File Path Handling in SecurityOrigin and FileSystem
index 8c91fde..c6b7ddc 100644 (file)
@@ -55,20 +55,20 @@ TEST_F(ComplexTextControllerTest, InitialAdvanceWithLeftRunInRTL)
     auto spaceWidth = font.primaryFont().spaceWidth();
 
 #if USE_LAYOUT_SPECIFIC_ADVANCES
-    Vector<CGSize> advances = { CGSizeZero, CGSizeMake(21.640625, 0.0), CGSizeMake(42.3046875, 0.0), CGSizeMake(55.8984375, 0.0), CGSizeMake(22.34375, 0.0) };
-    Vector<CGPoint> origins = { CGPointMake(-15.15625, 18.046875), CGPointZero, CGPointZero, CGPointZero, CGPointZero };
+    Vector<FloatSize> advances = { FloatSize(), FloatSize(21.640625, 0.0), FloatSize(42.3046875, 0.0), FloatSize(55.8984375, 0.0), FloatSize(22.34375, 0.0) };
+    Vector<FloatPoint> origins = { FloatPoint(-15.15625, 18.046875), FloatPoint(), FloatPoint(), FloatPoint(), FloatPoint() };
 #else
-    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) };
-    Vector<CGPoint> origins = { };
+    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) };
+    Vector<FloatPoint> origins = { };
 #endif
 
-    CGSize initialAdvance = CGSizeMake(-15.15625, 18.046875);
+    FloatSize initialAdvance = FloatSize(-15.15625, 18.046875);
 
     UChar characters[] = { 0x644, 0x637, 0x641, 0x627, 0x64b, 0x20 };
     size_t charactersLength = WTF_ARRAY_LENGTH(characters);
     TextRun textRun(StringView(characters, charactersLength));
-    auto run1 = ComplexTextController::ComplexTextRun::createForTesting({ CGSizeMake(21.875, 0) }, { CGPointZero }, { 5 }, { 5 }, CGSizeZero, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(5, 1), false);
-    auto run2 = ComplexTextController::ComplexTextRun::createForTesting(advances, origins, { 193, 377, 447, 431, 458 }, { 4, 3, 2, 1, 0 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 5), false);
+    auto run1 = ComplexTextController::ComplexTextRun::create({ FloatSize(21.875, 0) }, { FloatPoint() }, { 5 }, { 5 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 5, 6, false);
+    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);
     Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
     runs.append(WTFMove(run1));
     runs.append(WTFMove(run2));
@@ -76,25 +76,25 @@ TEST_F(ComplexTextControllerTest, InitialAdvanceWithLeftRunInRTL)
 
     CGFloat totalWidth = 0;
     for (size_t i = 1; i < advances.size(); ++i)
-        totalWidth += advances[i].width;
+        totalWidth += advances[i].width();
     EXPECT_NEAR(controller.totalWidth(), spaceWidth + totalWidth, 0.0001);
     GlyphBuffer glyphBuffer;
     EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
     controller.advance(0, &glyphBuffer);
     EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
     controller.advance(1, &glyphBuffer);
-    EXPECT_NEAR(controller.runWidthSoFar(), advances[4].width, 0.0001);
+    EXPECT_NEAR(controller.runWidthSoFar(), advances[4].width(), 0.0001);
     controller.advance(6, &glyphBuffer);
     EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + totalWidth, 0.0001);
     EXPECT_NEAR(glyphBuffer.initialAdvance().width(), 0, 0.0001);
     EXPECT_NEAR(glyphBuffer.initialAdvance().height(), 0, 0.0001);
     EXPECT_EQ(glyphBuffer.size(), 6U);
-    EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), advances[4].width, 0.0001);
-    EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), advances[3].width, 0.0001);
-    EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), advances[2].width, 0.0001);
-    EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), advances[1].width, 0.0001);
-    EXPECT_NEAR(glyphBuffer.advanceAt(4).width(), -initialAdvance.width, 0.0001);
-    EXPECT_NEAR(glyphBuffer.advanceAt(5).width(), spaceWidth + initialAdvance.width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), advances[4].width(), 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), advances[3].width(), 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), advances[2].width(), 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), advances[1].width(), 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(4).width(), -initialAdvance.width(), 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(5).width(), spaceWidth + initialAdvance.width(), 0.0001);
 }
 
 TEST_F(ComplexTextControllerTest, InitialAdvanceInRTL)
@@ -106,44 +106,44 @@ TEST_F(ComplexTextControllerTest, InitialAdvanceInRTL)
     font.update();
 
 #if USE_LAYOUT_SPECIFIC_ADVANCES
-    Vector<CGSize> advances = { CGSizeZero, CGSizeMake(21.640625, 0.0), CGSizeMake(42.3046875, 0.0), CGSizeMake(55.8984375, 0.0), CGSizeMake(22.34375, 0.0) };
-    Vector<CGPoint> origins = { CGPointMake(-15.15625, 18.046875), CGPointZero, CGPointZero, CGPointZero, CGPointZero };
+    Vector<FloatSize> advances = { FloatSize(), FloatSize(21.640625, 0.0), FloatSize(42.3046875, 0.0), FloatSize(55.8984375, 0.0), FloatSize(22.34375, 0.0) };
+    Vector<FloatPoint> origins = { FloatPoint(-15.15625, 18.046875), FloatPoint(), FloatPoint(), FloatPoint(), FloatPoint() };
 #else
-    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) };
-    Vector<CGPoint> origins = { };
+    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) };
+    Vector<FloatPoint> origins = { };
 #endif
 
-    CGSize initialAdvance = CGSizeMake(-15.15625, 18.046875);
+    FloatSize initialAdvance = FloatSize(-15.15625, 18.046875);
 
     UChar characters[] = { 0x644, 0x637, 0x641, 0x627, 0x64b };
     size_t charactersLength = WTF_ARRAY_LENGTH(characters);
     TextRun textRun(StringView(characters, charactersLength));
-    auto run = ComplexTextController::ComplexTextRun::createForTesting(advances, origins, { 193, 377, 447, 431, 458 }, { 4, 3, 2, 1, 0 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 5), false);
+    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);
     Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
     runs.append(WTFMove(run));
     ComplexTextController controller(font, textRun, runs);
 
     CGFloat totalWidth = 0;
     for (size_t i = 1; i < advances.size(); ++i)
-        totalWidth += advances[i].width;
+        totalWidth += advances[i].width();
     EXPECT_NEAR(controller.totalWidth(), totalWidth, 0.0001);
     GlyphBuffer glyphBuffer;
     EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
     controller.advance(0, &glyphBuffer);
     EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
     controller.advance(1, &glyphBuffer);
-    EXPECT_NEAR(controller.runWidthSoFar(), advances[4].width, 0.0001);
+    EXPECT_NEAR(controller.runWidthSoFar(), advances[4].width(), 0.0001);
     controller.advance(5, &glyphBuffer);
     EXPECT_NEAR(controller.runWidthSoFar(), totalWidth, 0.0001);
-    EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width, 0.0001);
-    EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height, 0.0001);
+    EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width(), 0.0001);
+    EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height(), 0.0001);
     EXPECT_EQ(glyphBuffer.size(), 5U);
-    EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), advances[4].width, 0.0001);
-    EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), advances[3].width, 0.0001);
-    EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), advances[2].width, 0.0001);
-    EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), advances[1].width, 0.0001);
-    EXPECT_NEAR(glyphBuffer.advanceAt(4).width(), -initialAdvance.width, 0.0001);
-    EXPECT_NEAR(glyphBuffer.advanceAt(4).height(), initialAdvance.height, 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), advances[4].width(), 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), advances[3].width(), 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), advances[2].width(), 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(3).width(), advances[1].width(), 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(4).width(), -initialAdvance.width(), 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(4).height(), initialAdvance.height(), 0.0001);
 }
 
 TEST_F(ComplexTextControllerTest, InitialAdvanceWithLeftRunInLTR)
@@ -156,26 +156,26 @@ TEST_F(ComplexTextControllerTest, InitialAdvanceWithLeftRunInLTR)
     auto spaceWidth = font.primaryFont().spaceWidth();
 
 #if USE_LAYOUT_SPECIFIC_ADVANCES
-    Vector<CGSize> advances = { CGSizeMake(76.347656, 0.000000), CGSizeMake(0.000000, 0.000000) };
-    Vector<CGPoint> origins = { CGPointZero, CGPointMake(-23.281250, -8.398438) };
+    Vector<FloatSize> advances = { FloatSize(76.347656, 0.000000), FloatSize(0.000000, 0.000000) };
+    Vector<FloatPoint> origins = { FloatPoint(), FloatPoint(-23.281250, -8.398438) };
 #else
-    Vector<CGSize> advances = { CGSizeMake(53.066406, -8.398438), CGSizeMake(23.281250, 8.398438) };
-    Vector<CGPoint> origins = { };
+    Vector<FloatSize> advances = { FloatSize(53.066406, -8.398438), FloatSize(23.281250, 8.398438) };
+    Vector<FloatPoint> origins = { };
 #endif
 
-    CGSize initialAdvance = CGSizeMake(28.144531, 0);
+    FloatSize initialAdvance = FloatSize(28.144531, 0);
 
     UChar characters[] = { 0x20, 0x61, 0x20e3 };
     size_t charactersLength = WTF_ARRAY_LENGTH(characters);
     TextRun textRun(StringView(characters, charactersLength));
-    auto run1 = ComplexTextController::ComplexTextRun::createForTesting({ CGSizeMake(spaceWidth, 0) }, { CGPointZero }, { 5 }, { 0 }, CGSizeZero, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 1), true);
-    auto run2 = ComplexTextController::ComplexTextRun::createForTesting(advances, origins, { 68, 1471 }, { 1, 2 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(1, 2), true);
+    auto run1 = ComplexTextController::ComplexTextRun::create({ FloatSize(spaceWidth, 0) }, { FloatPoint() }, { 5 }, { 0 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 0, 1, true);
+    auto run2 = ComplexTextController::ComplexTextRun::create(advances, origins, { 68, 1471 }, { 1, 2 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, 1, 3, true);
     Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
     runs.append(WTFMove(run1));
     runs.append(WTFMove(run2));
     ComplexTextController controller(font, textRun, runs);
 
-    EXPECT_NEAR(controller.totalWidth(), spaceWidth + 76.347656 + initialAdvance.width, 0.0001);
+    EXPECT_NEAR(controller.totalWidth(), spaceWidth + 76.347656 + initialAdvance.width(), 0.0001);
     GlyphBuffer glyphBuffer;
     EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
     controller.advance(0, &glyphBuffer);
@@ -183,13 +183,13 @@ TEST_F(ComplexTextControllerTest, InitialAdvanceWithLeftRunInLTR)
     controller.advance(1, &glyphBuffer);
     EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth, 0.0001);
     controller.advance(2, &glyphBuffer);
-    EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + advances[0].width + initialAdvance.width, 0.0001);
+    EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + advances[0].width() + initialAdvance.width(), 0.0001);
     controller.advance(3, &glyphBuffer);
-    EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + 76.347656 + initialAdvance.width, 0.0001);
+    EXPECT_NEAR(controller.runWidthSoFar(), spaceWidth + 76.347656 + initialAdvance.width(), 0.0001);
     EXPECT_NEAR(glyphBuffer.initialAdvance().width(), 0, 0.0001);
     EXPECT_NEAR(glyphBuffer.initialAdvance().height(), 0, 0.0001);
     EXPECT_EQ(glyphBuffer.size(), 3U);
-    EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), spaceWidth + initialAdvance.width, 0.0001);
+    EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), spaceWidth + initialAdvance.width(), 0.0001);
     EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), 53.066406, 0.0001);
     EXPECT_NEAR(glyphBuffer.advanceAt(2).width(), 23.281250, 0.0001);
 }
@@ -203,34 +203,34 @@ TEST_F(ComplexTextControllerTest, InitialAdvanceInLTR)
     font.update();
 
 #if USE_LAYOUT_SPECIFIC_ADVANCES
-    Vector<CGSize> advances = { CGSizeMake(76.347656, 0.000000), CGSizeMake(0.000000, 0.000000) };
-    Vector<CGPoint> origins = { CGPointZero, CGPointMake(-23.281250, -8.398438) };
+    Vector<FloatSize> advances = { FloatSize(76.347656, 0.000000), FloatSize(0.000000, 0.000000) };
+    Vector<FloatPoint> origins = { FloatPoint(), FloatPoint(-23.281250, -8.398438) };
 #else
-    Vector<CGSize> advances = { CGSizeMake(53.066406, -8.398438), CGSizeMake(23.281250, 8.398438) };
-    Vector<CGPoint> origins = { };
+    Vector<FloatSize> advances = { FloatSize(53.066406, -8.398438), FloatSize(23.281250, 8.398438) };
+    Vector<FloatPoint> origins = { };
 #endif
 
-    CGSize initialAdvance = CGSizeMake(28.144531, 0);
+    FloatSize initialAdvance = FloatSize(28.144531, 0);
 
     UChar characters[] = { 0x61, 0x20e3 };
     size_t charactersLength = WTF_ARRAY_LENGTH(characters);
     TextRun textRun(StringView(characters, charactersLength));
-    auto run = ComplexTextController::ComplexTextRun::createForTesting(advances, origins, { 68, 1471 }, { 0, 1 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 2), true);
+    auto run = ComplexTextController::ComplexTextRun::create(advances, origins, { 68, 1471 }, { 0, 1 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, 0, 2, true);
     Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
     runs.append(WTFMove(run));
     ComplexTextController controller(font, textRun, runs);
 
-    EXPECT_NEAR(controller.totalWidth(), 76.347656 + initialAdvance.width, 0.0001);
+    EXPECT_NEAR(controller.totalWidth(), 76.347656 + initialAdvance.width(), 0.0001);
     GlyphBuffer glyphBuffer;
     EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
     controller.advance(0, &glyphBuffer);
     EXPECT_NEAR(controller.runWidthSoFar(), 0, 0.0001);
     controller.advance(1, &glyphBuffer);
-    EXPECT_NEAR(controller.runWidthSoFar(), advances[0].width + initialAdvance.width, 0.0001);
+    EXPECT_NEAR(controller.runWidthSoFar(), advances[0].width() + initialAdvance.width(), 0.0001);
     controller.advance(2, &glyphBuffer);
-    EXPECT_NEAR(controller.runWidthSoFar(), 76.347656 + initialAdvance.width, 0.0001);
-    EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width, 0.0001);
-    EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height, 0.0001);
+    EXPECT_NEAR(controller.runWidthSoFar(), 76.347656 + initialAdvance.width(), 0.0001);
+    EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width(), 0.0001);
+    EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height(), 0.0001);
     EXPECT_EQ(glyphBuffer.size(), 2U);
     EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), 53.066406, 0.0001);
     EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), 23.281250, 0.0001);
@@ -244,14 +244,14 @@ TEST_F(ComplexTextControllerTest, InitialAdvanceInRTLNoOrigins)
     FontCascade font(description);
     font.update();
 
-    CGSize initialAdvance = CGSizeMake(4.33996383363472, 12.368896925859);
+    FloatSize initialAdvance = FloatSize(4.33996383363472, 12.368896925859);
 
     UChar characters[] = { 0x633, 0x20, 0x627, 0x650 };
     size_t charactersLength = WTF_ARRAY_LENGTH(characters);
     TextRun textRun(StringView(characters, charactersLength));
-    auto run1 = ComplexTextController::ComplexTextRun::createForTesting({ CGSizeMake(-4.33996383363472, -12.368896925859), CGSizeMake(14.0397830018083, 0) }, { }, { 884, 240 }, { 3, 2 }, initialAdvance, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(2, 2), false);
-    auto run2 = ComplexTextController::ComplexTextRun::createForTesting({ CGSizeMake(12.0, 0) }, { }, { 3 }, { 1 }, CGSizeZero, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(1, 1), false);
-    auto run3 = ComplexTextController::ComplexTextRun::createForTesting({ CGSizeMake(43.8119349005425, 0) }, { }, { 276 }, { 0 }, CGSizeZero, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 1), false);
+    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);
+    auto run2 = ComplexTextController::ComplexTextRun::create({ FloatSize(12.0, 0) }, { }, { 3 }, { 1 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 1, 2, false);
+    auto run3 = ComplexTextController::ComplexTextRun::create({ FloatSize(43.8119349005425, 0) }, { }, { 276 }, { 0 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 0, 1, false);
     Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
     runs.append(WTFMove(run1));
     runs.append(WTFMove(run2));
@@ -272,8 +272,8 @@ TEST_F(ComplexTextControllerTest, InitialAdvanceInRTLNoOrigins)
     EXPECT_NEAR(controller.runWidthSoFar(), totalWidth, 0.0001);
     controller.advance(4, &glyphBuffer);
     EXPECT_NEAR(controller.runWidthSoFar(), totalWidth, 0.0001);
-    EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width, 0.0001);
-    EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height, 0.0001);
+    EXPECT_NEAR(glyphBuffer.initialAdvance().width(), initialAdvance.width(), 0.0001);
+    EXPECT_NEAR(glyphBuffer.initialAdvance().height(), initialAdvance.height(), 0.0001);
     EXPECT_EQ(glyphBuffer.size(), 4U);
     EXPECT_NEAR(glyphBuffer.advanceAt(0).width(), 43.8119349005425, 0.0001);
     EXPECT_NEAR(glyphBuffer.advanceAt(1).width(), 12.0, 0.0001);
@@ -293,7 +293,7 @@ TEST_F(ComplexTextControllerTest, LeadingExpansion)
     UChar characters[] = { 'a' };
     size_t charactersLength = WTF_ARRAY_LENGTH(characters);
     TextRun textRun(StringView(characters, charactersLength), 0, 100, ForceLeadingExpansion);
-    auto run = ComplexTextController::ComplexTextRun::createForTesting({ CGSizeMake(24, 0) }, { }, { 16 }, { 0 }, CGSizeZero, font.primaryFont(), characters, 0, charactersLength, CFRangeMake(0, 1), true);
+    auto run = ComplexTextController::ComplexTextRun::create({ FloatSize(24, 0) }, { }, { 16 }, { 0 }, FloatSize(), font.primaryFont(), characters, 0, charactersLength, 0, 1, true);
     Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
     runs.append(WTFMove(run));
     ComplexTextController controller(font, textRun, runs);
@@ -323,8 +323,8 @@ TEST_F(ComplexTextControllerTest, VerticalAdvances)
     UChar characters[] = { 'a', 'b', 'c', 'd' };
     size_t charactersLength = WTF_ARRAY_LENGTH(characters);
     TextRun textRun(StringView(characters, charactersLength));
-    auto run1 = ComplexTextController::ComplexTextRun::createForTesting({ 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);
-    auto run2 = ComplexTextController::ComplexTextRun::createForTesting({ 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);
+    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);
+    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);
     Vector<Ref<ComplexTextController::ComplexTextRun>> runs;
     runs.append(WTFMove(run1));
     runs.append(WTFMove(run2));