void SVGCharacterLayoutInfo::addLayoutInformation(InlineFlowBox* flowBox, float textAnchorStartOffset) { bool wasInitialLayout = isInitialLayout(); RenderSVGTextPath* textPath = toRenderSVGTextPath(flowBox->renderer()); Path path = textPath->layoutPath(); float baselineShift = calculateBaselineShift(textPath); layoutPath = path; layoutPathLength = path.length(); if (layoutPathLength <= 0.0f) return; startOffset = textPath->startOffset(); if (textPath->startOffset() >= 0.0f && textPath->startOffset() <= 1.0f) startOffset *= layoutPathLength; startOffset += textAnchorStartOffset; currentOffset = startOffset; // Only baseline-shift is handled through the normal layout system addStackContent(BaselineShiftStack, baselineShift); if (wasInitialLayout) { xStackChanged = false; yStackChanged = false; dxStackChanged = false; dyStackChanged = false; angleStackChanged = false; baselineShiftStackChanged = false; } }
void SVGCharacterLayoutInfo::addLayoutInformation(SVGTextPositioningElement* element) { bool isInitialLayout = xStack.isEmpty() && yStack.isEmpty() && dxStack.isEmpty() && dyStack.isEmpty() && angleStack.isEmpty() && baselineShiftStack.isEmpty() && curx == 0.0f && cury == 0.0f; float baselineShift = calculateBaselineShift(element->renderer()); addStackContent(XStack, element->x(), element); addStackContent(YStack, element->y(), element); addStackContent(DxStack, element->dx(), element); addStackContent(DyStack, element->dy(), element); addStackContent(AngleStack, element->rotate()); addStackContent(BaselineShiftStack, baselineShift); if (isInitialLayout) { xStackChanged = false; yStackChanged = false; dxStackChanged = false; dyStackChanged = false; angleStackChanged = false; baselineShiftStackChanged = false; } }
void SVGCharacterLayoutInfo::addStackContent(StackType type, SVGLengthList* list, const SVGElement* context) { unsigned length = list->numberOfItems(); if (!length) return; PositionedFloatVector newLayoutInfo; ExceptionCode ec = 0; for (unsigned i = 0; i < length; ++i) { float value = list->getItem(i, ec).value(context); ASSERT(ec == 0); newLayoutInfo.append(value); } addStackContent(type, newLayoutInfo); }
void SVGCharacterLayoutInfo::addStackContent(StackType type, SVGNumberList* list) { unsigned length = list->numberOfItems(); if (!length) return; PositionedFloatVector newLayoutInfo; // TODO: Convert more efficiently! ExceptionCode ec = 0; for (unsigned i = 0; i < length; ++i) { float value = list->getItem(i, ec); ASSERT(ec == 0); newLayoutInfo.append(value); } addStackContent(type, newLayoutInfo); }