TextRun SVGInlineTextBox::constructTextRun(const ComputedStyle& style, const SVGTextFragment& fragment) const { LineLayoutText text = lineLayoutItem(); // FIXME(crbug.com/264211): This should not be necessary but can occur if we // layout during layout. Remove this when 264211 is fixed. RELEASE_ASSERT(!text.needsLayout()); TextRun run(static_cast<const LChar*>(nullptr) // characters, will be set below if non-zero. , 0 // length, will be set below if non-zero. , 0 // xPos, only relevant with allowTabs=true , 0 // padding, only relevant for justified text, not relevant for SVG , TextRun::AllowTrailingExpansion , direction() , dirOverride() || style.rtlOrdering() == VisualOrder /* directionalOverride */); if (fragment.length) { if (text.is8Bit()) run.setText(text.characters8() + fragment.characterOffset, fragment.length); else run.setText(text.characters16() + fragment.characterOffset, fragment.length); } // We handle letter & word spacing ourselves. run.disableSpacing(); // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring. run.setCharactersLength(text.textLength() - fragment.characterOffset); ASSERT(run.charactersLength() >= run.length()); return run; }
TextRun SVGInlineTextBox::constructTextRun( const ComputedStyle& style, const SVGTextFragment& fragment) const { LineLayoutText text = getLineLayoutItem(); CHECK(!text.needsLayout()); TextRun run( // characters, will be set below if non-zero. static_cast<const LChar*>(nullptr), 0, // length, will be set below if non-zero. 0, // xPos, only relevant with allowTabs=true 0, // padding, only relevant for justified text, not relevant for SVG TextRun::AllowTrailingExpansion, direction(), dirOverride() || style.rtlOrdering() == VisualOrder /* directionalOverride */); if (fragment.length) { if (text.is8Bit()) run.setText(text.characters8() + fragment.characterOffset, fragment.length); else run.setText(text.characters16() + fragment.characterOffset, fragment.length); } // We handle letter & word spacing ourselves. run.disableSpacing(); // Propagate the maximum length of the characters buffer to the TextRun, even // when we're only processing a substring. run.setCharactersLength(text.textLength() - fragment.characterOffset); ASSERT(run.charactersLength() >= run.length()); return run; }