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;
}
Example #2
0
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;
}
Example #3
0
TextRun constructTextRun(const Font& font,
                         const LineLayoutText text,
                         unsigned offset,
                         unsigned length,
                         const ComputedStyle& style) {
  ASSERT(offset + length <= text.textLength());
  if (text.hasEmptyText())
    return constructTextRunInternal(font, static_cast<const LChar*>(nullptr), 0,
                                    style, LTR);
  if (text.is8Bit())
    return constructTextRunInternal(font, text.characters8() + offset, length,
                                    style, LTR);

  TextRun run = constructTextRunInternal(font, text.characters16() + offset,
                                         length, style, LTR);
  run.setDirection(directionForRun(run));
  return run;
}