Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (189556 => 189557)
--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2015-09-09 22:26:16 UTC (rev 189556)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2015-09-09 22:42:50 UTC (rev 189557)
@@ -95,12 +95,24 @@
float advanceAtCharacter;
};
-typedef Vector<std::pair<int, OriginalAdvancesForCharacterTreatedAsSpace>, 64> CharactersTreatedAsSpace;
+static inline bool isSoftBankEmoji(UChar32 codepoint)
+{
+ return codepoint >= 0xE001 && codepoint <= 0xE537;
+}
-static inline float applyFontTransforms(GlyphBuffer* glyphBuffer, bool ltr, int& lastGlyphCount, const Font* font, WidthIterator& iterator, TypesettingFeatures typesettingFeatures, bool force, CharactersTreatedAsSpace& charactersTreatedAsSpace)
+inline auto WidthIterator::shouldApplyFontTransforms(const GlyphBuffer* glyphBuffer, int lastGlyphCount, UChar32 previousCharacter) const -> TransformsType
{
- ASSERT(typesettingFeatures & (Kerning | Ligatures));
+ if (glyphBuffer && glyphBuffer->size() == (lastGlyphCount + 1) && isSoftBankEmoji(previousCharacter))
+ return TransformsType::Forced;
+ if (m_run.length() <= 1 || !(m_typesettingFeatures & (Kerning | Ligatures)))
+ return TransformsType::None;
+ return TransformsType::NotForced;
+}
+inline float WidthIterator::applyFontTransforms(GlyphBuffer* glyphBuffer, bool ltr, int& lastGlyphCount, const Font* font, TypesettingFeatures typesettingFeatures, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace& charactersTreatedAsSpace)
+{
+ ASSERT_UNUSED(previousCharacter, shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter) != WidthIterator::TransformsType::None);
+
if (!glyphBuffer)
return 0;
@@ -118,16 +130,14 @@
if (!ltr)
glyphBuffer->reverse(lastGlyphCount, glyphBufferSize - lastGlyphCount);
-#if !ENABLE(SVG_FONTS)
- UNUSED_PARAM(iterator);
-#else
+#if ENABLE(SVG_FONTS)
// We need to handle transforms on SVG fonts internally, since they are rendered internally.
if (font->isSVGFont()) {
// SVG font ligatures are handled during glyph selection, only kerning remaining.
- if (iterator.run().renderingContext() && (typesettingFeatures & Kerning)) {
+ if (run().renderingContext() && (typesettingFeatures & Kerning)) {
// FIXME: We could pass the necessary context down to this level so we can lazily create rendering contexts at this point.
// However, a larger refactoring of SVG fonts might necessary to sidestep this problem completely.
- iterator.run().renderingContext()->applySVGKerning(font, iterator, glyphBuffer, lastGlyphCount);
+ run().renderingContext()->applySVGKerning(font, *this, glyphBuffer, lastGlyphCount);
}
} else
#endif
@@ -194,20 +204,6 @@
return std::make_pair(expandLeft, expandRight);
}
-static inline bool isSoftBankEmoji(UChar32 codepoint)
-{
- return codepoint >= 0xE001 && codepoint <= 0xE537;
-}
-
-inline auto WidthIterator::shouldApplyFontTransforms(const GlyphBuffer* glyphBuffer, int lastGlyphCount, UChar32 previousCharacter) const -> TransformsType
-{
- if (glyphBuffer && glyphBuffer->size() == lastGlyphCount + 1 && isSoftBankEmoji(previousCharacter))
- return TransformsType::Forced;
- if (m_run.length() <= 1 || !(m_typesettingFeatures & (Kerning | Ligatures)))
- return TransformsType::None;
- return TransformsType::NotForced;
-}
-
template <typename TextIterator>
inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, GlyphBuffer* glyphBuffer)
{
@@ -269,7 +265,7 @@
if (font != lastFontData && width) {
auto transformsType = shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter);
if (transformsType != TransformsType::None) {
- m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, *this, m_typesettingFeatures, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
+ m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, m_typesettingFeatures, previousCharacter, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
if (glyphBuffer)
glyphBuffer->shrink(lastGlyphCount);
}
@@ -427,7 +423,7 @@
auto transformsType = shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter);
if (transformsType != TransformsType::None) {
- m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, *this, m_typesettingFeatures, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
+ m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, m_typesettingFeatures, previousCharacter, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
if (glyphBuffer)
glyphBuffer->shrink(lastGlyphCount);
}
Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.h (189556 => 189557)
--- trunk/Source/WebCore/platform/graphics/WidthIterator.h 2015-09-09 22:26:16 UTC (rev 189556)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.h 2015-09-09 22:42:50 UTC (rev 189557)
@@ -35,7 +35,10 @@
class Font;
class TextRun;
struct GlyphData;
+struct OriginalAdvancesForCharacterTreatedAsSpace;
+typedef Vector<std::pair<int, OriginalAdvancesForCharacterTreatedAsSpace>, 64> CharactersTreatedAsSpace;
+
struct WidthIterator {
WTF_MAKE_FAST_ALLOCATED;
public:
@@ -90,6 +93,7 @@
enum class TransformsType { None, Forced, NotForced };
TransformsType shouldApplyFontTransforms(const GlyphBuffer*, int lastGlyphCount, UChar32 previousCharacter) const;
+ float applyFontTransforms(GlyphBuffer*, bool ltr, int& lastGlyphCount, const Font*, TypesettingFeatures, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace&);
TypesettingFeatures m_typesettingFeatures;
HashSet<const Font*>* m_fallbackFonts;