void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(RenderSVGText& textRoot)
{
    SVGTextPositioningElement* outermostTextElement = SVGTextPositioningElement::elementFromRenderer(textRoot);
    ASSERT(outermostTextElement);

    // Grab outermost <text> element value lists and insert them in the character data map.
    TextPosition wholeTextPosition(outermostTextElement, 0, m_textLength);
    fillCharacterDataMap(wholeTextPosition);

    // Handle x/y default attributes.
    SVGCharacterDataMap::iterator it = m_characterDataMap.find(1);
    if (it == m_characterDataMap.end()) {
        SVGCharacterData data;
        data.x = 0;
        data.y = 0;
        m_characterDataMap.set(1, data);
    } else {
        SVGCharacterData& data = it->value;
        if (data.x == SVGTextLayoutAttributes::emptyValue())
            data.x = 0;
        if (data.y == SVGTextLayoutAttributes::emptyValue())
            data.y = 0;
    }

    // Fill character data map using child text positioning elements in top-down order. 
    unsigned size = m_textPositions.size();
    for (unsigned i = 0; i < size; ++i)
        fillCharacterDataMap(m_textPositions[i]);
}
Beispiel #2
0
void SVGTextLayoutAttributesBuilder::buildLayoutAttributesForAllCharacters(RenderSVGText* textRoot, unsigned textLength)
{
    ASSERT(textLength);

    SVGTextPositioningElement* outermostTextElement = SVGTextPositioningElement::elementFromRenderer(textRoot);
    ASSERT(outermostTextElement);

    // Fill the lists with the special emptyValue marker.
    m_positioningLists.fillWithEmptyValues(textLength);

    // Grab outermost <text> element value lists and insert them in the m_positioningLists.
    TextPosition wholeTextPosition(outermostTextElement, 0, textLength);
    fillAttributesAtPosition(wholeTextPosition);

    // Handle x/y default attributes.
    float& xFirst = m_positioningLists.xValues.first();
    if (xFirst == SVGTextLayoutAttributes::emptyValue())
        xFirst = 0;

    float& yFirst = m_positioningLists.yValues.first();
    if (yFirst == SVGTextLayoutAttributes::emptyValue())
        yFirst = 0;

    // Fill m_positioningLists using child text positioning elements in top-down order. 
    unsigned size = m_textPositions.size();
    for (unsigned i = 0; i < size; ++i)
        fillAttributesAtPosition(m_textPositions[i]);

    // Now m_positioningLists.contains a x/y/dx/dy/rotate value for each character in the <text> subtree.
}