Changeset 180779 in webkit
- Timestamp:
- Feb 27, 2015 1:42:31 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r180777 r180779 1 2015-02-27 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r180752. 4 https://bugs.webkit.org/show_bug.cgi?id=142098 5 6 Causes 10 SVG test failures on Windows. (Requested by 7 bfulgham_ on #webkit). 8 9 Reverted changeset: 10 11 "Cache glyph widths to GlyphPages" 12 https://bugs.webkit.org/show_bug.cgi?id=142028 13 http://trac.webkit.org/changeset/180752 14 1 15 2015-02-27 David Kilzer <ddkilzer@apple.com> 2 16 -
trunk/Source/WebCore/platform/graphics/Font.cpp
r180752 r180779 55 55 , m_avgCharWidth(-1) 56 56 , m_platformData(platformData) 57 , m_treatAsFixedPitch(false) 57 58 , m_isCustomFont(isCustomFont) 58 59 , m_isLoading(isLoading) 59 60 , m_isTextOrientationFallback(isTextOrientationFallback) 61 , m_isBrokenIdeographFallback(false) 62 , m_mathData(nullptr) 63 #if ENABLE(OPENTYPE_VERTICAL) 64 , m_verticalData(0) 65 #endif 66 , m_hasVerticalGlyphs(false) 60 67 { 61 68 platformInit(); … … 73 80 : m_platformData(FontPlatformData(fontSize, syntheticBold, syntheticItalic)) 74 81 , m_svgData(WTF::move(svgData)) 82 , m_treatAsFixedPitch(false) 75 83 , m_isCustomFont(true) 84 , m_isLoading(false) 85 , m_isTextOrientationFallback(false) 86 , m_isBrokenIdeographFallback(false) 87 , m_mathData(nullptr) 88 #if ENABLE(OPENTYPE_VERTICAL) 89 , m_verticalData(0) 90 #endif 91 , m_hasVerticalGlyphs(false) 92 #if PLATFORM(IOS) 93 , m_shouldNotBeUsedForArabic(false) 94 #endif 76 95 { 77 96 m_svgData->initializeFont(this, fontSize); … … 88 107 Glyph digitZeroGlyph = glyphPageZero->glyphDataForCharacter(digitZeroChar).glyph; 89 108 if (digitZeroGlyph) 90 m_avgCharWidth = computeWidthForGlyph(digitZeroGlyph);109 m_avgCharWidth = widthForGlyph(digitZeroGlyph); 91 110 } 92 111 … … 103 122 auto* glyphPageZero = glyphPage(0); 104 123 if (!glyphPageZero) { 124 m_spaceGlyph = 0; 125 m_spaceWidth = 0; 126 m_zeroGlyph = 0; 127 m_adjustedSpaceWidth = 0; 105 128 determinePitch(); 129 m_zeroWidthSpaceGlyph = 0; 106 130 return; 107 131 } 132 108 133 // Ask for the glyph for 0 to avoid paging in ZERO WIDTH SPACE. Control characters, including 0, 109 134 // are mapped to the ZERO WIDTH SPACE glyph. 110 135 m_zeroWidthSpaceGlyph = glyphPageZero->glyphDataForCharacter(0).glyph; 136 111 137 // Nasty hack to determine if we should round or ceil space widths. 112 138 // If the font is monospace or fake monospace we ceil to ensure that 113 139 // every character and the space are the same width. Otherwise we round. 114 auto spaceGlyphData = glyphPageZero->glyphDataForCharacter(' '); 115 m_spaceGlyph = spaceGlyphData.glyph; 116 m_spaceWidth = spaceGlyphData.width; 117 m_fontMetrics.setZeroWidth(glyphPageZero->glyphDataForCharacter('0').width); 140 m_spaceGlyph = glyphPageZero->glyphDataForCharacter(' ').glyph; 141 float width = widthForGlyph(m_spaceGlyph); 142 m_spaceWidth = width; 143 m_zeroGlyph = glyphPageZero->glyphDataForCharacter('0').glyph; 144 m_fontMetrics.setZeroWidth(widthForGlyph(m_zeroGlyph)); 118 145 determinePitch(); 119 m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(m_spaceWidth) : roundf(m_spaceWidth); 120 m_glyphZeroWidth = computeWidthForGlyph(0); 146 m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(width) : roundf(width); 121 147 122 148 // Force the glyph for ZERO WIDTH SPACE to have zero width, unless it is shared with SPACE. … … 125 151 if (m_zeroWidthSpaceGlyph == m_spaceGlyph) 126 152 m_zeroWidthSpaceGlyph = 0; 127 else {128 // Fixup the page zero now that we know the zero width glyph.129 for (unsigned i = 0; i < GlyphPage::size; ++i) {130 auto glyphData = m_glyphPageZero->glyphDataForIndex(i);131 if (glyphData.glyph == m_zeroWidthSpaceGlyph)132 m_glyphPageZero->setGlyphDataForIndex(i, { glyphData.glyph, 0, glyphData.font });133 }134 }135 m_glyphPageZero->setImmutable();136 153 } 137 154 … … 155 172 } 156 173 157 RefPtr<GlyphPage> createAndFillGlyphPage(unsigned pageNumber, const Font* font)174 static RefPtr<GlyphPage> createAndFillGlyphPage(unsigned pageNumber, const Font* font) 158 175 { 159 176 #if PLATFORM(IOS) … … 228 245 return nullptr; 229 246 247 glyphPage->setImmutable(); 230 248 return glyphPage; 231 }232 233 float Font::computeWidthForGlyph(Glyph glyph) const234 {235 if (isZeroWidthSpaceGlyph(glyph))236 return 0;237 float width;238 if (isSVGFont())239 width = m_svgData->widthForSVGGlyph(glyph, m_platformData.size());240 #if ENABLE(OPENTYPE_VERTICAL)241 else if (m_verticalData)242 #if USE(CG) || USE(CAIRO)243 width = m_verticalData->advanceHeight(this, glyph) + m_syntheticBoldOffset;244 #else245 width = m_verticalData->advanceHeight(this, glyph);246 #endif247 #endif248 else249 width = platformWidthForGlyph(glyph);250 return width;251 249 } 252 250 … … 256 254 if (!m_glyphPageZero) 257 255 m_glyphPageZero = createAndFillGlyphPage(0, this); 258 // Zero page is marked immutable in platformGlyphInit.259 256 return m_glyphPageZero.get(); 260 257 } 261 258 auto addResult = m_glyphPages.add(pageNumber, nullptr); 262 auto& page = addResult.iterator->value; 263 if (addResult.isNewEntry) { 264 page = createAndFillGlyphPage(pageNumber, this); 265 if (page) 266 page->setImmutable(); 267 } 268 return page.get(); 259 if (addResult.isNewEntry) 260 addResult.iterator->value = createAndFillGlyphPage(pageNumber, this); 261 262 return addResult.iterator->value.get(); 269 263 } 270 264 … … 465 459 } 466 460 467 void GlyphPage::setGlyphDataForIndex(unsigned index, Glyph glyph, const Font* font)468 {469 setGlyphDataForIndex(index, { glyph, font ? font->computeWidthForGlyph(glyph) : 0, font });470 }471 472 473 461 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/Font.h
r180752 r180779 141 141 142 142 FloatRect boundsForGlyph(Glyph) const; 143 144 float computeWidthForGlyph(Glyph) const; 143 float widthForGlyph(Glyph) const; 144 FloatRect platformBoundsForGlyph(Glyph) const; 145 float platformWidthForGlyph(Glyph) const; 145 146 146 147 float spaceWidth() const { return m_spaceWidth; } … … 151 152 m_adjustedSpaceWidth = spaceWidth; 152 153 } 153 float glyphZeroWidth() const { return m_glyphZeroWidth; }154 154 155 155 #if USE(CG) || USE(CAIRO) … … 162 162 void setZeroWidthSpaceGlyph(Glyph spaceGlyph) { m_zeroWidthSpaceGlyph = spaceGlyph; } 163 163 bool isZeroWidthSpaceGlyph(Glyph glyph) const { return glyph == m_zeroWidthSpaceGlyph && glyph; } 164 Glyph zeroGlyph() const { return m_zeroGlyph; } 165 void setZeroGlyph(Glyph zeroGlyph) { m_zeroGlyph = zeroGlyph; } 164 166 165 167 GlyphData glyphDataForCharacter(UChar32) const; … … 226 228 PassRefPtr<Font> platformCreateScaledFont(const FontDescription&, float scaleFactor) const; 227 229 228 float platformWidthForGlyph(Glyph) const;229 FloatRect platformBoundsForGlyph(Glyph) const;230 231 230 void removeFromSystemFallbackCache(); 232 233 friend RefPtr<GlyphPage> createAndFillGlyphPage(unsigned pageNumber, const Font*);234 231 235 232 #if PLATFORM(WIN) … … 250 247 mutable HashMap<unsigned, RefPtr<GlyphPage>> m_glyphPages; 251 248 mutable std::unique_ptr<GlyphMetricsMap<FloatRect>> m_glyphToBoundsMap; 252 253 bool m_treatAsFixedPitch { false }; 254 bool m_isCustomFont { false }; // Whether or not we are custom font loaded via @font-face 255 bool m_isLoading { false }; // Whether or not this custom font is still in the act of loading. 256 257 bool m_isTextOrientationFallback { false }; 258 bool m_isBrokenIdeographFallback { false }; 249 mutable GlyphMetricsMap<float> m_glyphToWidthMap; 250 251 bool m_treatAsFixedPitch; 252 bool m_isCustomFont; // Whether or not we are custom font loaded via @font-face 253 bool m_isLoading; // Whether or not this custom font is still in the act of loading. 254 255 bool m_isTextOrientationFallback; 256 bool m_isBrokenIdeographFallback; 259 257 260 258 bool m_isUsedInSystemFallbackCache { false }; … … 264 262 RefPtr<OpenTypeVerticalData> m_verticalData; 265 263 #endif 266 bool m_hasVerticalGlyphs { false }; 267 268 Glyph m_spaceGlyph { 0 }; 269 float m_spaceWidth { 0 }; 270 float m_adjustedSpaceWidth { 0 }; 271 272 Glyph m_zeroWidthSpaceGlyph { 0 }; 273 274 float m_glyphZeroWidth { 0 }; 264 bool m_hasVerticalGlyphs; 265 266 Glyph m_spaceGlyph; 267 float m_spaceWidth; 268 Glyph m_zeroGlyph; 269 float m_adjustedSpaceWidth; 270 271 Glyph m_zeroWidthSpaceGlyph; 275 272 276 273 struct DerivedFontData { … … 313 310 #endif 314 311 #if PLATFORM(IOS) 315 bool m_shouldNotBeUsedForArabic { false };312 bool m_shouldNotBeUsedForArabic; 316 313 #endif 317 314 }; … … 336 333 } 337 334 335 ALWAYS_INLINE float Font::widthForGlyph(Glyph glyph) const 336 { 337 if (isZeroWidthSpaceGlyph(glyph)) 338 return 0; 339 340 float width = m_glyphToWidthMap.metricsForGlyph(glyph); 341 if (width != cGlyphSizeUnknown) 342 return width; 343 344 if (isSVGFont()) 345 width = m_svgData->widthForSVGGlyph(glyph, m_platformData.size()); 346 #if ENABLE(OPENTYPE_VERTICAL) 347 else if (m_verticalData) 348 #if USE(CG) || USE(CAIRO) 349 width = m_verticalData->advanceHeight(this, glyph) + m_syntheticBoldOffset; 350 #else 351 width = m_verticalData->advanceHeight(this, glyph); 352 #endif 353 #endif 354 else 355 width = platformWidthForGlyph(glyph); 356 357 m_glyphToWidthMap.setMetricsForGlyph(glyph, width); 358 return width; 359 } 360 338 361 } // namespace WebCore 339 362 -
trunk/Source/WebCore/platform/graphics/FontCascade.cpp
r180752 r180779 1335 1335 } 1336 1336 // FIXME: Use glyph bounds once they make sense for vertical fonts. 1337 return fontData-> computeWidthForGlyph(glyph) / 2;1337 return fontData->widthForGlyph(glyph) / 2; 1338 1338 } 1339 1339 -
trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp
r180752 r180779 388 388 389 389 glyphData = glyphDataForNormalVariant(c, description); 390 cachedPage->setGlyphDataForCharacter(c, glyphData );390 cachedPage->setGlyphDataForCharacter(c, glyphData.glyph, glyphData.font); 391 391 } 392 392 return glyphData; -
trunk/Source/WebCore/platform/graphics/GlyphPage.h
r180752 r180779 45 45 // character. 46 46 struct GlyphData { 47 GlyphData() { } 48 GlyphData(Glyph glyph, float width, const Font* font) 49 : glyph(glyph) 50 , width(width) 51 , font(font) 52 { } 53 54 Glyph glyph { 0 }; 55 float width { 0 }; 56 const Font* font { nullptr }; 47 GlyphData(Glyph g = 0, const Font* f = 0) 48 : glyph(g) 49 , font(f) 50 { 51 } 52 Glyph glyph; 53 const Font* font; 57 54 }; 58 55 … … 113 110 ASSERT_WITH_SECURITY_IMPLICATION(index < size); 114 111 Glyph glyph = m_glyphs[index]; 115 float width = m_widths[index];116 112 if (hasPerGlyphFontData()) 117 return { glyph, width, m_perGlyphFontData[index] };118 return { glyph, width, glyph ? m_fontForAllGlyphs : nullptr };113 return GlyphData(glyph, m_perGlyphFontData[index]); 114 return GlyphData(glyph, glyph ? m_fontForAllGlyphs : 0); 119 115 } 120 116 … … 133 129 } 134 130 135 void setGlyphDataForCharacter(UChar32 c, const GlyphData& glyphData)131 void setGlyphDataForCharacter(UChar32 c, Glyph g, const Font* f) 136 132 { 137 setGlyphDataForIndex(indexForCharacter(c), g lyphData);133 setGlyphDataForIndex(indexForCharacter(c), g, f); 138 134 } 139 135 140 void setGlyphDataForIndex(unsigned index, Glyph, const Font*); 141 142 void setGlyphDataForIndex(unsigned index, const GlyphData& glyphData) 136 void setGlyphDataForIndex(unsigned index, Glyph glyph, const Font* font) 143 137 { 144 138 ASSERT_WITH_SECURITY_IMPLICATION(index < size); 145 139 ASSERT(!m_isImmutable); 146 147 m_glyphs[index] = glyphData.glyph; 148 m_widths[index] = glyphData.width; 140 141 m_glyphs[index] = glyph; 149 142 150 143 // GlyphPage getters will always return a null Font* for glyph #0 if there's no per-glyph font array. 151 144 if (hasPerGlyphFontData()) { 152 m_perGlyphFontData[index] = glyphData.glyph ? glyphData.font : 0;145 m_perGlyphFontData[index] = glyph ? font : 0; 153 146 return; 154 147 } 155 148 156 149 // A single-font GlyphPage already assigned m_fontForAllGlyphs in the constructor. 157 ASSERT(!glyphData.glyph || glyphData.font == m_fontForAllGlyphs); 150 ASSERT(!glyph || font == m_fontForAllGlyphs); 151 } 152 153 void setGlyphDataForIndex(unsigned index, const GlyphData& glyphData) 154 { 155 setGlyphDataForIndex(index, glyphData.glyph, glyphData.font); 158 156 } 159 157 … … 171 169 { 172 170 memset(m_glyphs, 0, sizeof(m_glyphs)); 173 memset(m_widths, 0, sizeof(m_widths));174 171 if (hasPerGlyphFontData()) 175 172 memset(m_perGlyphFontData, 0, sizeof(Font*) * GlyphPage::size); … … 179 176 bool hasPerGlyphFontData() const { return !m_fontForAllGlyphs; } 180 177 181 const Font* m_fontForAllGlyphs { nullptr };178 const Font* m_fontForAllGlyphs; 182 179 Glyph m_glyphs[size]; 183 float m_widths[size];184 180 185 181 bool m_isImmutable { false }; -
trunk/Source/WebCore/platform/graphics/WidthIterator.cpp
r180752 r180779 192 192 width = m_font->tabWidth(*font, m_run.tabSize(), m_run.xPos() + m_runWidthSoFar + widthSinceLastRounding); 193 193 else { 194 width = glyphData.width;194 width = font->widthForGlyph(glyph); 195 195 196 196 // SVG uses horizontalGlyphStretch(), when textLength is used to stretch/squeeze text. -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
r180752 r180779 639 639 #if PLATFORM(IOS) 640 640 if (isEmoji && advance.width) 641 advance.width = font. computeWidthForGlyph(glyph);641 advance.width = font.widthForGlyph(glyph); 642 642 #endif 643 643 -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
r180752 r180779 164 164 m_glyphsVector.fill(0, m_glyphCount); 165 165 m_glyphs = m_glyphsVector.data(); 166 m_advancesVector.fill(CGSizeMake(m_font. glyphZeroWidth(), 0), m_glyphCount);166 m_advancesVector.fill(CGSizeMake(m_font.widthForGlyph(0), 0), m_glyphCount); 167 167 m_advances = m_advancesVector.data(); 168 168 } -
trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp
r180752 r180779 1344 1344 float RenderMathMLOperator::advanceForGlyph(const GlyphData& data) const 1345 1345 { 1346 // FIXME: MathML code synthesizes bad GlyphDatas. 1347 return data.width ? data.width : data.font->computeWidthForGlyph(data.glyph); 1346 return data.font->widthForGlyph(data.glyph); 1348 1347 } 1349 1348 -
trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp
r180752 r180779 299 299 SVGFontFaceElement* fontFaceElement; 300 300 svgFontAndFontFaceElementForFontData(&primaryFont, fontFaceElement, fontElement); 301 auto missingGlyph = fontElement->missingGlyph(); 302 return { missingGlyph, primaryFont.computeWidthForGlyph(missingGlyph), &primaryFont }; 301 return GlyphData(fontElement->missingGlyph(), &primaryFont); 303 302 } 304 303 -
trunk/Source/WebCore/svg/SVGFontData.cpp
r180752 r180779 80 80 // Fallback if x_heightAttr is not specified for the font element. 81 81 Glyph letterXGlyph = glyphPageZero->glyphDataForCharacter('x').glyph; 82 xHeight = letterXGlyph ? font-> computeWidthForGlyph(letterXGlyph) : 2 * ascent / 3;82 xHeight = letterXGlyph ? font->widthForGlyph(letterXGlyph) : 2 * ascent / 3; 83 83 } 84 84 … … 100 100 101 101 // Calculate space width. 102 auto spaceGlyphData = glyphPageZero->glyphDataForCharacter(' ');103 font->setSpaceGlyph(spaceGlyph Data.glyph);104 font->setSpaceWidths( spaceGlyphData.width);102 Glyph spaceGlyph = glyphPageZero->glyphDataForCharacter(' ').glyph; 103 font->setSpaceGlyph(spaceGlyph); 104 font->setSpaceWidths(font->widthForGlyph(spaceGlyph)); 105 105 106 106 // Estimate average character width. 107 auto numeralZeroGlyphData = glyphPageZero->glyphDataForCharacter('0');108 font->setAvgCharWidth(numeralZeroGlyph Data.glyph ? numeralZeroGlyphData.width: font->spaceWidth());107 Glyph numeralZeroGlyph = glyphPageZero->glyphDataForCharacter('0').glyph; 108 font->setAvgCharWidth(numeralZeroGlyph ? font->widthForGlyph(numeralZeroGlyph) : font->spaceWidth()); 109 109 110 110 // Estimate maximum character width. 111 auto letterWGlyphData = glyphPageZero->glyphDataForCharacter('W');112 font->setMaxCharWidth(letterWGlyph Data.glyph ? letterWGlyphData.width: ascent);111 Glyph letterWGlyph = glyphPageZero->glyphDataForCharacter('W').glyph; 112 font->setMaxCharWidth(letterWGlyph ? font->widthForGlyph(letterWGlyph) : ascent); 113 113 } 114 114
Note: See TracChangeset
for help on using the changeset viewer.