Lines Matching full:chunk
49 // Text chunk creation is complex and the whole process
268 info.chunk.boxes.clear();
269 info.chunk.boxes.append(SVGInlineBoxCharacterRange());
271 info.chunk.start = info.it;
277 ASSERT(!info.chunk.boxes.last().isOpen());
278 ASSERT(info.chunk.boxes.last().isClosed());
280 info.chunk.end = info.it;
281 ASSERT(info.chunk.end >= info.chunk.start);
283 info.svgTextChunks.append(info.chunk);
677 // Render text, chunk-by-chunk
754 static float cummulatedWidthOrHeightOfTextChunk(SVGTextChunk& chunk, bool calcWidthOnly)
757 Vector<SVGChar>::iterator charIt = chunk.start;
759 Vector<SVGInlineBoxCharacterRange>::iterator it = chunk.boxes.begin();
760 Vector<SVGInlineBoxCharacterRange>::iterator end = chunk.boxes.end();
769 ASSERT(charIt <= chunk.end);
800 if (itSearch > chunk.start && itSearch < chunk.end) {
824 ASSERT(charIt == chunk.end);
828 static float cummulatedWidthOfTextChunk(SVGTextChunk& chunk)
830 return cummulatedWidthOrHeightOfTextChunk(chunk, true);
833 static float cummulatedHeightOfTextChunk(SVGTextChunk& chunk)
835 return cummulatedWidthOrHeightOfTextChunk(chunk, false);
838 static float calculateTextAnchorShiftForTextChunk(SVGTextChunk& chunk, ETextAnchor anchor)
842 if (chunk.isVerticalText)
843 shift = cummulatedHeightOfTextChunk(chunk);
845 shift = cummulatedWidthOfTextChunk(chunk);
855 static void applyTextAnchorToTextChunk(SVGTextChunk& chunk)
860 if (chunk.anchor == TA_START)
863 float shift = calculateTextAnchorShiftForTextChunk(chunk, chunk.anchor);
865 // Apply correction to chunk
866 Vector<SVGChar>::iterator chunkIt = chunk.start;
867 for (; chunkIt != chunk.end; ++chunkIt) {
870 if (chunk.isVerticalText)
877 Vector<SVGInlineBoxCharacterRange>::iterator boxIt = chunk.boxes.begin();
878 Vector<SVGInlineBoxCharacterRange>::iterator boxEnd = chunk.boxes.end();
887 if (chunk.isVerticalText)
894 static float calculateTextLengthCorrectionForTextChunk(SVGTextChunk& chunk, ELengthAdjust lengthAdjust, float& computedLength)
896 if (chunk.textLength <= 0.0f)
899 float computedWidth = cummulatedWidthOfTextChunk(chunk);
900 float computedHeight = cummulatedHeightOfTextChunk(chunk);
902 if ((computedWidth <= 0.0f && !chunk.isVerticalText) ||
903 (computedHeight <= 0.0f && chunk.isVerticalText))
906 if (chunk.isVerticalText)
912 if (chunk.isVerticalText)
913 chunk.ctm.scaleNonUniform(1.0f, chunk.textLength / computedLength);
915 chunk.ctm.scaleNonUniform(chunk.textLength / computedLength, 1.0f);
920 return (chunk.textLength - computedLength) / float(chunk.end - chunk.start);
923 static void applyTextLengthCorrectionToTextChunk(SVGTextChunk& chunk)
928 // lengthAdjust="spacingAndGlyphs" is handled by modifying chunk.ctm
930 float spacingToApply = calculateTextLengthCorrectionForTextChunk(chunk, chunk.lengthAdjust, computedLength);
932 if (!chunk.ctm.isIdentity() && chunk.lengthAdjust == SVGTextContentElement::LENGTHADJUST_SPACINGANDGLYPHS) {
933 SVGChar& firstChar = *(chunk.start);
935 // Assure we apply the chunk scaling in the right origin
936 AffineTransform newChunkCtm(chunk.ctm);
940 chunk.ctm = newChunkCtm;
943 // Apply correction to chunk
945 Vector<SVGChar>::iterator chunkIt = chunk.start;
946 for (; chunkIt != chunk.end; ++chunkIt) {
950 chunk.isVerticalText)
951 curChar.y += (chunkIt - chunk.start) * spacingToApply;
953 curChar.x += (chunkIt - chunk.start) * spacingToApply;
1051 SVGTextChunk& chunk = *it;
1054 info.pathExtraAdvance += calculateTextLengthCorrectionForTextChunk(chunk, lengthAdjust, computedLength);
1058 info.pathChunkLength += chunk.textLength;
1065 textAnchorStartOffset += calculateTextAnchorShiftForTextChunk(chunk, anchor);
1443 info.chunk.start = svgChars.begin();
1444 info.chunk.end = svgChars.begin();
1483 // Start new character range for the first chunk
1484 bool isFirstCharacter = info.svgTextChunks.isEmpty() && info.chunk.start == info.it && info.chunk.start == info.chunk.end;
1486 ASSERT(info.chunk.boxes.isEmpty());
1487 info.chunk.boxes.append(SVGInlineBoxCharacterRange());
1489 ASSERT(!info.chunk.boxes.isEmpty());
1491 // Walk string to find out new chunk positions, if existent
1495 SVGInlineBoxCharacterRange& range = info.chunk.boxes.last();
1505 // If a new (or the first) chunk has been started, record it's text-anchor and writing mode.
1509 info.chunk.isVerticalText = isVerticalWritingMode(text->style()->svgStyle());
1510 info.chunk.isTextPath = info.handlingTextPath;
1511 info.chunk.anchor = text->style()->svgStyle()->textAnchor();
1512 info.chunk.textLength = textContent->textLength().value(textContent);
1513 info.chunk.lengthAdjust = (ELengthAdjust) textContent->lengthAdjust();
1516 fprintf(stderr, " | -> Assign chunk properties, isVerticalText=%i, anchor=%i\n", info.chunk.isVerticalText, info.chunk.anchor);
1521 // Close mid chunk & character range
1529 fprintf(stderr, " | -> Close mid-text chunk, at endOffset: %i and starting new mid chunk!\n", range.endOffset);
1532 // Prepare for next chunk, if we're not at the end
1536 fprintf(stderr, " | -> Record last chunk of inline text box!\n");
1540 SVGInlineBoxCharacterRange& range = info.chunk.boxes.last();
1543 info.chunk.isVerticalText = isVerticalWritingMode(text->style()->svgStyle());
1544 info.chunk.isTextPath = info.handlingTextPath;
1545 info.chunk.anchor = text->style()->svgStyle()->textAnchor();
1546 info.chunk.textLength = textContent->textLength().value(textContent);
1547 info.chunk.lengthAdjust = (ELengthAdjust) textContent->lengthAdjust();
1557 // This should only hold true for the first character of the first chunk
1568 SVGInlineBoxCharacterRange& range = info.chunk.boxes.last();
1574 // Current text chunk is not yet closed. Finish the current range, but don't start a new chunk.
1583 // character starts a new chunk, then close the current chunk and start a new one.
1586 fprintf(stderr, " -> Next character starts new chunk! Closing current chunk, and starting a new one...\n");
1593 info.chunk.boxes.append(SVGInlineBoxCharacterRange());
1596 fprintf(stderr, " -> Next character does NOT start a new chunk! Starting new character range...\n");
1601 fprintf(stderr, " -> Closing final chunk! Finished processing!\n");
1604 // Close final chunk, once we're at the end of the last box
1647 SVGTextChunk& chunk = *it;
1651 fprintf(stderr, "Handle TEXT CHUNK! anchor=%i, textLength=%f, lengthAdjust=%i, isVerticalText=%i, isTextPath=%i start=%p, end=%p -> dist: %i\n",
1652 (int) chunk.anchor, chunk.textLength, (int) chunk.lengthAdjust, (int) chunk.isVerticalText,
1653 (int) chunk.isTextPath, chunk.start, chunk.end, (unsigned int) (chunk.end - chunk.start));
1655 Vector<SVGInlineBoxCharacterRange>::iterator boxIt = chunk.boxes.begin();
1656 Vector<SVGInlineBoxCharacterRange>::iterator boxEnd = chunk.boxes.end();
1666 if (chunk.isTextPath)
1670 applyTextLengthCorrectionToTextChunk(chunk);
1673 applyTextAnchorToTextChunk(chunk);
1757 // Eventually notify that we started a new chunk
1764 // Eventually apply new style, as this chunk spans multiple boxes (with possible different styling)
1779 // Process this chunk portion