コード例 #1
0
void SVGTextLayoutAttributesBuilder::buildLayoutScope(LayoutScope& scope, RenderObject* renderer, unsigned textContentStart, unsigned textContentLength) const
{
    ASSERT(renderer);
    ASSERT(renderer->style());

    scope.textContentStart = textContentStart;
    scope.textContentLength = textContentLength;

    SVGTextPositioningElement* element = SVGTextPositioningElement::elementFromRenderer(renderer);
    if (!element)
        return;

    SVGTextLayoutAttributes& attributes = scope.attributes;
    extractFloatValuesFromSVGLengthList(element, element->x(), attributes.xValues(), textContentLength);
    extractFloatValuesFromSVGLengthList(element, element->y(), attributes.yValues(), textContentLength);
    extractFloatValuesFromSVGLengthList(element, element->dx(), attributes.dxValues(), textContentLength);
    extractFloatValuesFromSVGLengthList(element, element->dy(), attributes.dyValues(), textContentLength);
    extractFloatValuesFromSVGNumberList(element->rotate(), attributes.rotateValues(), textContentLength);

    // The last rotation value spans the whole scope.
    Vector<float>& rotateValues = attributes.rotateValues();
    if (rotateValues.isEmpty())
        return;

    unsigned rotateValuesSize = rotateValues.size();
    if (rotateValuesSize == textContentLength)
        return;

    float lastRotation = rotateValues.last();

    rotateValues.resize(textContentLength);
    for (unsigned i = rotateValuesSize; i < textContentLength; ++i)
        rotateValues.at(i) = lastRotation;
}
コード例 #2
0
void SVGTextLayoutAttributesBuilder::fillAttributesAtPosition(const TextPosition& position)
{
    Vector<float> values;
    extractFloatValuesFromSVGLengthList(position.element, position.element->x(), values, position.length);
    fillListAtPosition(m_positioningLists.xValues, values, position.start);

    values.clear();
    extractFloatValuesFromSVGLengthList(position.element, position.element->y(), values, position.length);
    fillListAtPosition(m_positioningLists.yValues, values, position.start);

    values.clear();
    extractFloatValuesFromSVGLengthList(position.element, position.element->dx(), values, position.length);
    fillListAtPosition(m_positioningLists.dxValues, values, position.start);

    values.clear();
    extractFloatValuesFromSVGLengthList(position.element, position.element->dy(), values, position.length);
    fillListAtPosition(m_positioningLists.dyValues, values, position.start);

    values.clear();
    extractFloatValuesFromSVGNumberList(position.element->rotate(), values, position.length);
    fillListAtPosition(m_positioningLists.rotateValues, values, position.start);

    // The last rotation value always spans the whole scope.
    if (values.isEmpty())
        return;

    float lastValue = values.last();
    for (unsigned i = values.size(); i < position.length; ++i)
        m_positioningLists.rotateValues[position.start + i] = lastValue;
}