Changeset 177637 in webkit
- Timestamp:
- Dec 22, 2014, 11:14:58 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r177630 r177637 1 2014-12-22 Antti Koivisto <antti@apple.com> 2 3 Generic font code should not know about SVG font missing glyph 4 https://bugs.webkit.org/show_bug.cgi?id=139864 5 6 Reviewed by Andreas Kling and Myles Maxfield. 7 8 The defined missing glyph is an SVG font concept and should be handled in SVG code. 9 10 * platform/graphics/FontGlyphs.cpp: 11 (WebCore::FontGlyphs::glyphDataForSystemFallback): 12 (WebCore::FontGlyphs::glyphDataForVariant): 13 14 Return null glyph instead of the missing glyph (the missing glyph was already a null glyph in all non-svg-font cases). 15 Use early return style. 16 17 * platform/graphics/FontGlyphs.h: 18 * platform/graphics/SegmentedFontData.cpp: 19 * platform/graphics/SimpleFontData.cpp: 20 (WebCore::SimpleFontData::platformGlyphInit): 21 * platform/graphics/SimpleFontData.h: 22 23 Remove the missingGlyph member. 24 25 * platform/graphics/WidthIterator.cpp: 26 (WebCore::WidthIterator::advanceInternal): 27 28 Explicitly skip over null glyphs. Before they had non-null fontData and would get skipped implicitly. 29 30 * platform/graphics/mac/SimpleFontDataMac.mm: 31 * rendering/svg/SVGTextRunRenderingContext.cpp: 32 (WebCore::missingGlyphForFont): 33 34 Get the missing glyph from the SVG font element. 35 36 (WebCore::SVGTextRunRenderingContext::glyphDataForCharacter): 37 38 Return the missing glyph if the normal lookup didn't produce results. 39 40 * svg/SVGFontData.cpp: 41 (WebCore::SVGFontData::initializeFontData): 42 1 43 2014-12-22 Chris Dumez <cdumez@apple.com> 2 44 -
trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp
r177490 r177637 32 32 #include "Font.h" 33 33 #include "FontCache.h" 34 #include "GlyphPageTreeNode.h" 34 35 #include "SegmentedFontData.h" 35 36 … … 278 279 const SimpleFontData* originalFontData = primaryFontData(description)->fontDataForCharacter(c); 279 280 RefPtr<SimpleFontData> characterFontData = fontCache().systemFallbackForCharacters(description, originalFontData, m_isForPlatformFont, codeUnits, codeUnitsLength); 280 if (characterFontData) { 281 if (characterFontData->platformData().orientation() == Vertical && !characterFontData->hasVerticalGlyphs() && Font::isCJKIdeographOrSymbol(c)) 282 variant = BrokenIdeographVariant; 283 if (variant != NormalVariant) 284 characterFontData = characterFontData->variantFontData(description, variant); 285 } 286 if (characterFontData) { 287 // Got the fallback glyph and font. 288 GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterFontData.get(), pageNumber)->page(); 289 GlyphData data = fallbackPage && fallbackPage->fontDataForCharacter(c) ? fallbackPage->glyphDataForCharacter(c) : characterFontData->missingGlyphData(); 290 // Cache it so we don't have to do system fallback again next time. 291 if (variant == NormalVariant) { 292 node.page()->setGlyphDataForCharacter(c, data.glyph, data.fontData); 293 data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData->maxGlyphPageTreeLevel(), node.level())); 294 if (!Font::isCJKIdeographOrSymbol(c) && data.fontData->platformData().orientation() != Horizontal && !data.fontData->isTextOrientationFallback()) 295 return glyphDataForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data, pageNumber); 296 } 297 return data; 298 } 299 300 // Even system fallback can fail; use the missing glyph in that case. 301 // FIXME: It would be nicer to use the missing glyph from the last resort font instead. 302 GlyphData data = primarySimpleFontData(description)->missingGlyphData(); 303 if (variant == NormalVariant) { 281 if (!characterFontData) 282 return GlyphData(); 283 284 if (characterFontData->platformData().orientation() == Vertical && !characterFontData->hasVerticalGlyphs() && Font::isCJKIdeographOrSymbol(c)) 285 variant = BrokenIdeographVariant; 286 if (variant != NormalVariant) { 287 characterFontData = characterFontData->variantFontData(description, variant); 288 ASSERT(characterFontData); 289 } 290 291 GlyphData data; 292 if (GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterFontData.get(), pageNumber)->page()) 293 data = fallbackPage->glyphDataForCharacter(c); 294 295 // Cache it so we don't have to do system fallback again next time. 296 if (variant == NormalVariant && data.glyph) { 304 297 node.page()->setGlyphDataForCharacter(c, data.glyph, data.fontData); 305 298 data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData->maxGlyphPageTreeLevel(), node.level())); 299 if (!Font::isCJKIdeographOrSymbol(c) && data.fontData->platformData().orientation() != Horizontal && !data.fontData->isTextOrientationFallback()) 300 return glyphDataForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data, pageNumber); 306 301 } 307 302 return data; … … 322 317 GlyphPageTreeNode* variantNode = GlyphPageTreeNode::getRootChild(variantFontData.get(), pageNumber); 323 318 GlyphPage* variantPage = variantNode->page(); 324 if (variantPage) { 325 GlyphData data = variantPage->glyphDataForCharacter(c); 326 if (data.fontData) 327 return data; 328 } 319 if (variantPage) 320 return variantPage->glyphDataForCharacter(c); 329 321 330 322 // Do not attempt system fallback off the variantFontData. This is the very unlikely case that 331 323 // a font has the lowercase character but the small caps font does not have its uppercase version. 332 return variantFontData->missingGlyphData();324 return GlyphData(); 333 325 } 334 326 -
trunk/Source/WebCore/platform/graphics/FontGlyphs.h
r177490 r177637 23 23 24 24 #include "FontSelector.h" 25 #include "GlyphPage.h" 25 26 #include "SimpleFontData.h" 26 27 #include "WidthCache.h" -
trunk/Source/WebCore/platform/graphics/SegmentedFontData.cpp
r177316 r177637 27 27 #include "SegmentedFontData.h" 28 28 29 #include "GlyphPageTreeNode.h" 29 30 #include "SimpleFontData.h" 30 31 #include <wtf/Assertions.h> -
trunk/Source/WebCore/platform/graphics/SimpleFontData.cpp
r175960 r177637 36 36 #include "Font.h" 37 37 #include "FontCache.h" 38 #include "GlyphPageTreeNode.h" 38 39 #include "OpenTypeMathData.h" 39 40 #include <wtf/MathExtras.h> … … 125 126 determinePitch(); 126 127 m_zeroWidthSpaceGlyph = 0; 127 m_missingGlyphData.fontData = this;128 m_missingGlyphData.glyph = 0;129 128 return; 130 129 } … … 150 149 if (m_zeroWidthSpaceGlyph == m_spaceGlyph) 151 150 m_zeroWidthSpaceGlyph = 0; 152 153 m_missingGlyphData.fontData = this;154 m_missingGlyphData.glyph = 0;155 151 } 156 152 -
trunk/Source/WebCore/platform/graphics/SimpleFontData.h
r177527 r177637 32 32 #include "GlyphBuffer.h" 33 33 #include "GlyphMetricsMap.h" 34 #include "GlyphPageTreeNode.h"35 34 #include "OpenTypeMathData.h" 36 35 #if ENABLE(OPENTYPE_VERTICAL) … … 61 60 namespace WebCore { 62 61 62 class GlyphPage; 63 63 class FontDescription; 64 64 class SharedBuffer; 65 struct GlyphData; 65 66 struct WidthIterator; 66 67 … … 181 182 virtual bool isSegmented() const override; 182 183 183 const GlyphData& missingGlyphData() const { return m_missingGlyphData; }184 void setMissingGlyphData(const GlyphData& glyphData) { m_missingGlyphData = glyphData; }185 186 184 #ifndef NDEBUG 187 185 virtual String description() const override; … … 272 270 273 271 Glyph m_zeroWidthSpaceGlyph; 274 275 GlyphData m_missingGlyphData;276 272 277 273 struct DerivedFontData { -
trunk/Source/WebCore/platform/graphics/WidthIterator.cpp
r174297 r177637 180 180 const GlyphData& glyphData = glyphDataForCharacter(character, rtl, currentCharacter, advanceLength, normalizedSpacesStringCache); 181 181 Glyph glyph = glyphData.glyph; 182 if (!glyph) { 183 textIterator.advance(advanceLength); 184 continue; 185 } 182 186 const SimpleFontData* fontData = glyphData.fontData; 183 184 187 ASSERT(fontData); 185 188 -
trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
r177527 r177637 36 36 #import "FontCache.h" 37 37 #import "FontDescription.h" 38 #import "GlyphPageTreeNode.h" 38 39 #import "SharedBuffer.h" 39 40 #import "WebCoreSystemInterface.h" -
trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp
r177490 r177637 291 291 } 292 292 293 static GlyphData missingGlyphForFont(const Font& font) 294 { 295 const SimpleFontData* primaryFontData = font.primaryFont(); 296 if (!primaryFontData->isSVGFont()) 297 return GlyphData(); 298 SVGFontElement* fontElement; 299 SVGFontFaceElement* fontFaceElement; 300 svgFontAndFontFaceElementForFontData(primaryFontData, fontFaceElement, fontElement); 301 return GlyphData(fontElement->missingGlyph(), primaryFontData); 302 } 303 293 304 GlyphData SVGTextRunRenderingContext::glyphDataForCharacter(const Font& font, WidthIterator& iterator, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength, String& normalizedSpacesStringCache) 294 305 { 295 const SimpleFontData* primaryFont = font.primaryFont();296 ASSERT(primaryFont);297 298 306 GlyphData glyphData = font.glyphDataForCharacter(character, mirror, AutoVariant); 299 300 // Check if we have the missing glyph data, in which case we can just return. 301 GlyphData missingGlyphData = primaryFont->missingGlyphData(); 302 if (glyphData.glyph == missingGlyphData.glyph && glyphData.fontData == missingGlyphData.fontData) { 303 ASSERT(glyphData.fontData); 304 return glyphData; 305 } 307 if (!glyphData.glyph) 308 return missingGlyphForFont(font); 309 310 ASSERT(glyphData.fontData); 306 311 307 312 // Characters enclosed by an <altGlyph> element, may not be registered in the GlyphPage. 308 if ( glyphData.fontData &&!glyphData.fontData->isSVGFont()) {313 if (!glyphData.fontData->isSVGFont()) { 309 314 auto& elementRenderer = is<RenderElement>(renderer()) ? downcast<RenderElement>(renderer()) : *renderer().parent(); 310 315 if (Element* parentRendererElement = elementRenderer.element()) { 311 316 if (is<SVGAltGlyphElement>(*parentRendererElement)) 312 glyphData.fontData = primaryFont;317 glyphData.fontData = font.primaryFont(); 313 318 } 314 319 } 315 320 316 const SimpleFontData* fontData = glyphData.fontData; 317 if (!fontData || !fontData->isSVGFont()) 321 if (!glyphData.fontData->isSVGFont()) 318 322 return glyphData; 319 323 320 324 SVGFontElement* fontElement = nullptr; 321 325 SVGFontFaceElement* fontFaceElement = nullptr; 322 const SVGFontData* svgFontData = svgFontAndFontFaceElementForFontData( fontData, fontFaceElement, fontElement);326 const SVGFontData* svgFontData = svgFontAndFontFaceElementForFontData(glyphData.fontData, fontFaceElement, fontElement); 323 327 if (!svgFontData) 324 328 return glyphData; … … 330 334 if (svgFontData->applySVGGlyphSelection(iterator, glyphData, mirror, currentCharacter, advanceLength, normalizedSpacesStringCache)) 331 335 return glyphData; 336 337 GlyphData missingGlyphData = missingGlyphForFont(font); 332 338 if (missingGlyphData.glyph) 333 339 return missingGlyphData; -
trunk/Source/WebCore/svg/SVGFontData.cpp
r176298 r177637 23 23 #include "SVGFontData.h" 24 24 25 #include "GlyphPageTreeNode.h" 25 26 #include "RenderElement.h" 26 27 #include "SVGAltGlyphElement.h" … … 64 65 ASSERT(svgFontFaceElement); 65 66 66 SVGFontElement* svgFontElement = svgFontFaceElement->associatedFontElement();67 ASSERT(svgFontElement);68 GlyphData missingGlyphData;69 missingGlyphData.fontData = fontData;70 missingGlyphData.glyph = svgFontElement->missingGlyph();71 fontData->setMissingGlyphData(missingGlyphData);72 73 67 fontData->setZeroWidthSpaceGlyph(0); 74 68 fontData->determinePitch();
Note:
See TracChangeset
for help on using the changeset viewer.