Show
Ignore:
Timestamp:
03/26/08 18:52:55 (2 years ago)
Author:
hyatt@apple.com
Message:

2008-03-26 David Hyatt < hyatt@apple.com>

Add support for the rendering and measurement of the <altGlyph> element in SVG. This patch brings
is half of what's needed to reach 100/100 on Acid3 and pass the test. Maciej has coded up the other half. :)

Reviewed by mjs

Added svg/custom/altGlyph.svg

  • svg/SVGAltGlyphElement.cpp: (WebCore::SVGAltGlyphElement::childShouldCreateRenderer): (WebCore::SVGAltGlyphElement::glyphElement):
  • svg/SVGAltGlyphElement.h:
  • svg/SVGFont.cpp: (WebCore::SVGTextRunWalker::walk):
  • svg/SVGFontFaceElement.cpp: (WebCore::SVGFontFaceElement::insertedIntoDocument):
  • svg/SVGGlyphElement.cpp: (WebCore::SVGGlyphElement::insertedIntoDocument): (WebCore::SVGGlyphElement::removedFromDocument):
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/svg/SVGFont.cpp

    r31324 r31338  
    2828#include "RenderObject.h" 
    2929#include "SimpleFontData.h" 
     30#include "SVGAltGlyphElement.h" 
    3031#include "SVGFontData.h" 
    3132#include "SVGGlyphElement.h" 
     
    250251        int endOfScanRange = to + m_walkerData.extraCharsAvailable; 
    251252 
     253        bool haveAltGlyph = false; 
     254        SVGGlyphIdentifier altGlyphIdentifier; 
     255        if (RenderObject* renderObject = run.referencingRenderObject()) { 
     256            if (renderObject->element() && renderObject->element()->hasTagName(SVGNames::altGlyphTag)) { 
     257                SVGGlyphElement* glyphElement = static_cast<SVGAltGlyphElement*>(renderObject->element())->glyphElement(); 
     258                if (glyphElement) { 
     259                    haveAltGlyph = true; 
     260                    altGlyphIdentifier = glyphElement->buildGlyphIdentifier(); 
     261                    altGlyphIdentifier.isValid = true; 
     262                    altGlyphIdentifier.nameLength = to - from; 
     263                } 
     264            } 
     265        } 
     266         
    252267        for (int i = from; i < to; ++i) { 
    253268            // If characterLookupRange is > 0, then the font defined ligatures (length of unicode property value > 1). 
     
    257272 
    258273            String lookupString(run.data(run.rtl() ? run.length() - (i + characterLookupRange) : i), characterLookupRange); 
    259  
    260274            Vector<SVGGlyphIdentifier> glyphs; 
    261             m_fontElement->getGlyphIdentifiersForString(lookupString, glyphs); 
     275            if (haveAltGlyph) 
     276                glyphs.append(altGlyphIdentifier); 
     277            else 
     278                m_fontElement->getGlyphIdentifiersForString(lookupString, glyphs); 
     279 
    262280            Vector<SVGGlyphIdentifier>::iterator it = glyphs.begin(); 
    263281            Vector<SVGGlyphIdentifier>::iterator end = glyphs.end();