Changeset 31338 in webkit


Ignore:
Timestamp:
Mar 26, 2008 6:52:55 PM (16 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):
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r31337 r31338  
     12008-03-26  David Hyatt  <hyatt@apple.com>
     2
     3        Add support for the rendering and measurement of the <altGlyph> element in SVG.  This patch brings
     4        is half of what's needed to reach 100/100 on Acid3 and pass the test.  Maciej has coded up the other half. :)
     5
     6        Reviewed by mjs
     7
     8        Added svg/custom/altGlyph.svg
     9
     10        * svg/SVGAltGlyphElement.cpp:
     11        (WebCore::SVGAltGlyphElement::childShouldCreateRenderer):
     12        (WebCore::SVGAltGlyphElement::glyphElement):
     13        * svg/SVGAltGlyphElement.h:
     14        * svg/SVGFont.cpp:
     15        (WebCore::SVGTextRunWalker::walk):
     16        * svg/SVGFontFaceElement.cpp:
     17        (WebCore::SVGFontFaceElement::insertedIntoDocument):
     18        * svg/SVGGlyphElement.cpp:
     19        (WebCore::SVGGlyphElement::insertedIntoDocument):
     20        (WebCore::SVGGlyphElement::removedFromDocument):
     21
    1222008-03-26  Adam Roben  <aroben@apple.com>
    223
  • trunk/WebCore/svg/SVGAltGlyphElement.cpp

    r31240 r31338  
    2828#include "RenderInline.h"
    2929#include "RenderSVGTSpan.h"
     30#include "SVGGlyphElement.h"
    3031#include "SVGNames.h"
     32#include "XLinkNames.h"
    3133
    3234namespace WebCore {
     
    6567    if (child->isTextNode())
    6668        return true;
    67 
    6869    return false;
    6970}
     
    7475}
    7576
     77SVGGlyphElement* SVGAltGlyphElement::glyphElement() const
     78{
     79    Element* elt = document()->getElementById(getTarget(getAttribute(XLinkNames::hrefAttr)));
     80    if (!elt || !elt->hasTagName(SVGNames::glyphTag))
     81        return 0;
     82    return static_cast<SVGGlyphElement*>(elt);
     83}
     84
    7685}
    7786
  • trunk/WebCore/svg/SVGAltGlyphElement.h

    r31240 r31338  
    3030namespace WebCore
    3131{
     32    class SVGGlyphElement;
     33
    3234    class SVGAltGlyphElement : public SVGTextPositioningElement, public SVGURIReference
    3335    {
     
    4446        void setFormat(const AtomicString&, ExceptionCode&);
    4547   
     48        SVGGlyphElement* glyphElement() const;
     49
    4650    protected:
    4751        virtual const SVGElement* contextElement() const { return this; }
  • 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();
  • trunk/WebCore/svg/SVGFontFaceElement.cpp

    r31309 r31338  
    351351{
    352352    rebuildFontFace();
     353    SVGElement::insertedIntoDocument();
    353354}
    354355
  • trunk/WebCore/svg/SVGGlyphElement.cpp

    r29700 r31338  
    5252            element->addGlyphToCache(this);
    5353    }
     54    SVGStyledElement::insertedIntoDocument();
    5455}
    5556
     
    6162            element->removeGlyphFromCache(this);
    6263    }
     64    SVGStyledElement::removedFromDocument();
    6365}
    6466
Note: See TracChangeset for help on using the changeset viewer.