Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h (211764 => 211765)
--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h 2017-02-07 02:08:37 UTC (rev 211764)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h 2017-02-07 02:14:53 UTC (rev 211765)
@@ -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 const struct __CTRun * CTRunRef;
typedef const struct __CTLine * CTLineRef;
-namespace WTF {
-template<> struct VectorTraits<CGPoint> : SimpleClassVectorTraits { };
-}
-
namespace WebCore {
class FontCascade;
@@ -78,19 +74,19 @@
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; }
@@ -97,12 +93,12 @@
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 @@
* 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);
+ 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<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;
+ 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 @@
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 @@
const FontCascade& m_font;
const TextRun& m_run;
-
+
unsigned m_currentCharacter { 0 };
unsigned m_end { 0 };
@@ -234,5 +227,3 @@
};
} // namespace WebCore
-
-#endif // ComplexTextController_h
Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm (211764 => 211765)
--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm 2017-02-07 02:08:37 UTC (rev 211764)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm 2017-02-07 02:14:53 UTC (rev 211765)
@@ -42,10 +42,9 @@
#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 @@
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();
}
+ m_coreTextIndices.reserveInitialCapacity(m_glyphCount);
+ for (unsigned i = 0; i < m_glyphCount; ++i)
+ m_coreTextIndices.uncheckedAppend(coreTextIndicesPtr[i]);
- if (!m_glyphs) {
- m_glyphsVector.grow(m_glyphCount);
- CTRunGetGlyphs(ctRun, CFRangeMake(0, 0), m_glyphsVector.data());
- m_glyphs = m_glyphsVector.data();
+ 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 @@
{
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 @@
// 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 @@
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));
}
}
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp (211764 => 211765)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp 2017-02-07 02:08:37 UTC (rev 211764)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ComplexTextController.cpp 2017-02-07 02:14:53 UTC (rev 211765)
@@ -55,20 +55,20 @@
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,7 +76,7 @@
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);
@@ -83,18 +83,18 @@
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,19 +106,19 @@
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);
@@ -125,7 +125,7 @@
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);
@@ -132,18 +132,18 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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));