TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFragment& fragment) const { ASSERT(style); TextRun run(renderer().characters() + fragment.characterOffset , fragment.length , 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 (textRunNeedsRenderingContext(style->font())) run.setRenderingContext(SVGTextRunRenderingContext::create(&renderer())); run.disableRoundingHacks(); // 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(renderer().textLength() - fragment.characterOffset); ASSERT(run.charactersLength() >= run.length()); return run; }
TextRun InlineTextBox::constructTextRun( const ComputedStyle& style, StringView string, int maximumLength, StringBuilder* charactersWithHyphen) const { if (charactersWithHyphen) { const AtomicString& hyphenString = style.hyphenString(); charactersWithHyphen->reserveCapacity(string.length() + hyphenString.length()); charactersWithHyphen->append(string); charactersWithHyphen->append(hyphenString); string = charactersWithHyphen->toString(); maximumLength = string.length(); } ASSERT(maximumLength >= static_cast<int>(string.length())); TextRun run(string, textPos().toFloat(), expansion(), expansionBehavior(), direction(), dirOverride() || style.rtlOrdering() == EOrder::Visual); run.setTabSize(!style.collapseWhiteSpace(), style.getTabSize()); run.setTextJustify(style.getTextJustify()); // Propagate the maximum length of the characters buffer to the TextRun, even // when we're only processing a substring. run.setCharactersLength(maximumLength); ASSERT(run.charactersLength() >= run.length()); return run; }
TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFragment& fragment) const { ASSERT(style); RenderText* text = &renderer(); // 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*>(0) // 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; }