void RenderCombineText::charactersToRender(int start, const UChar*& characters, int& length) const { if (m_isCombined) { length = originalText()->length(); characters = originalText()->characters(); return; } characters = text()->characters() + start; }
void RenderTextFragment::transformText() { // Don't reset first-letter here because we are only transforming the truncated fragment. String textToTransform = originalText(); if (!textToTransform.isNull()) RenderText::setText(textToTransform, true); }
size_t FrTextSpan::wordCountOriginal() const { char *words = originalText() ; size_t count = word_count(words) ; FrFree(words) ; return count ; }
void RenderQuote::updateDepth() { ASSERT(m_isAttached); int depth = 0; if (m_previous) { depth = m_previous->m_depth; if (depth < 0) depth = 0; switch (m_previous->m_type) { case OPEN_QUOTE: case NO_OPEN_QUOTE: depth++; break; case CLOSE_QUOTE: case NO_CLOSE_QUOTE: break; } } switch (m_type) { case OPEN_QUOTE: case NO_OPEN_QUOTE: break; case CLOSE_QUOTE: case NO_CLOSE_QUOTE: depth--; break; } if (m_depth == depth) return; m_depth = depth; setText(originalText()); }
void LayoutTextFragment::transformText() { // Note, we have to call LayoutText::setText here because, if we use our // version we will, potentially, screw up the first-letter settings where // we only use portions of the string. if (RefPtr<StringImpl> textToTransform = originalText()) LayoutText::setText(textToTransform.release(), true); }
char *FrTextSpan::initialText() const { const FrObject *txt = getMetaData(init_text_tag) ; if (txt && txt->consp() && ((FrList*)txt)->first() && ((FrList*)txt)->first()->stringp()) txt = ((FrList*)txt)->first() ; const char *printed = FrPrintableName(txt) ; return printed ? FrDupString(printed) : originalText() ; }
void RenderSVGInlineText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) { // Skip RenderText's possible layout scheduling on style change RenderObject::styleDidChange(diff, oldStyle); // FIXME: SVG text is apparently always transformed? if (RefPtr<StringImpl> textToTransform = originalText()) setText(textToTransform.release(), true); }
void RenderCombineText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) { setStyleInternal(RenderStyle::clone(style())); RenderText::styleDidChange(diff, oldStyle); if (m_isCombined) RenderText::setTextInternal(originalText()); // This RenderCombineText has been combined once. Restore the original text for the next combineText(). setNeedsFontUpdate(true); }
void RenderCombineText::getStringToRender(int start, StringView& string, int& length) const { ASSERT(start >= 0); if (m_isCombined) { string = StringView(originalText()); length = string.length(); return; } string = text().createView(start, length); }
void RenderCombineText::getStringToRender(int start, String& string, int& length) const { ASSERT(start >= 0); if (m_isCombined) { string = originalText(); length = string.length(); return; } string = text(); string = string.substringSharingImpl(static_cast<unsigned>(start), length); }
void RenderCombineText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) { // FIXME: This is pretty hackish. m_combineFontStyle = RenderStyle::clone(style()); RenderText::styleDidChange(diff, oldStyle); if (m_isCombined) { RenderText::setTextInternal(originalText()); // This RenderCombineText has been combined once. Restore the original text for the next combineText(). m_isCombined = false; } m_needsFontUpdate = true; }
void RenderSVGInlineText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) { RenderText::styleDidChange(diff, oldStyle); updateScaledFont(); bool newPreserves = style().whiteSpace() == PRE; bool oldPreserves = oldStyle ? oldStyle->whiteSpace() == PRE : false; if (oldPreserves && !newPreserves) { setText(applySVGWhitespaceRules(originalText(), false), true); return; } if (!oldPreserves && newPreserves) { setText(applySVGWhitespaceRules(originalText(), true), true); return; } if (diff != StyleDifferenceLayout) return; // The text metrics may be influenced by style changes. if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this)) textAncestor->subtreeStyleDidChange(this); }
void RenderCombineText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) { // FIXME: This is pretty hackish. m_combineFontStyle = RenderStyle::clone(&style()); RenderText::styleDidChange(diff, oldStyle); if (m_isCombined && selfNeedsLayout()) { // Layouts cause the text to be recombined; therefore, only only un-combine when the style diff causes a layout. RenderText::setRenderedText(originalText()); // This RenderCombineText has been combined once. Restore the original text for the next combineText(). m_isCombined = false; } m_needsFontUpdate = true; }
void RenderCounter::computePreferredLogicalWidths(float lead) { #ifndef NDEBUG // FIXME: We shouldn't be modifying the tree in computePreferredLogicalWidths. // Instead, we should properly hook the appropriate changes in the DOM and modify // the render tree then. When that's done, we also won't need to override // computePreferredLogicalWidths at all. // https://bugs.webkit.org/show_bug.cgi?id=104829 SetLayoutNeededForbiddenScope layoutForbiddenScope(this, false); #endif setTextInternal(originalText()); RenderText::computePreferredLogicalWidths(lead); }
void RenderSVGInlineText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) { RenderText::styleDidChange(diff, oldStyle); if (diff == StyleDifferenceLayout) { // The text metrics may be influenced by style changes. if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this)) textRenderer->setNeedsPositioningValuesUpdate(); } const RenderStyle* newStyle = style(); if (!newStyle || newStyle->whiteSpace() != PRE) return; if (!oldStyle || oldStyle->whiteSpace() != PRE) setText(applySVGWhitespaceRules(originalText(), true), true); }
void LayoutSVGInlineText::styleDidChange(StyleDifference diff, const ComputedStyle* oldStyle) { LayoutText::styleDidChange(diff, oldStyle); updateScaledFont(); bool newPreserves = style() ? style()->whiteSpace() == PRE : false; bool oldPreserves = oldStyle ? oldStyle->whiteSpace() == PRE : false; if (oldPreserves != newPreserves) { setText(originalText(), true); return; } if (!diff.needsFullLayout()) return; // The text metrics may be influenced by style changes. if (LayoutSVGText* textLayoutObject = LayoutSVGText::locateLayoutSVGTextAncestor(this)) textLayoutObject->setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::StyleChange); }
void RenderCombineText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) { // FIXME: This is pretty hackish. // Only cache a new font style if our old one actually changed. We do this to avoid // clobbering width variants and shrink-to-fit changes, since we won't recombine when // the font doesn't change. if (!oldStyle || oldStyle->fontCascade() != style().fontCascade()) m_combineFontStyle = RenderStyle::clone(&style()); RenderText::styleDidChange(diff, oldStyle); if (m_isCombined && selfNeedsLayout()) { // Layouts cause the text to be recombined; therefore, only only un-combine when the style diff causes a layout. RenderText::setRenderedText(originalText()); // This RenderCombineText has been combined once. Restore the original text for the next combineText(). m_isCombined = false; } m_needsFontUpdate = true; }
void RenderQuote::updateDepth() { ASSERT(m_attached); int oldDepth = m_depth; m_depth = 0; if (m_previous) { m_depth = m_previous->m_depth; switch (m_previous->m_type) { case OPEN_QUOTE: case NO_OPEN_QUOTE: m_depth++; break; case CLOSE_QUOTE: case NO_CLOSE_QUOTE: if (m_depth) m_depth--; break; } } if (oldDepth != m_depth) setText(originalText()); }
void RenderCounter::computePreferredLogicalWidths(float lead) { setTextInternal(originalText()); RenderText::computePreferredLogicalWidths(lead); }
void RenderCounter::updateCounter() { setTextInternal(originalText()); }
void RenderCounter::calcPrefWidths(int lead) { setTextInternal(originalText()); RenderText::calcPrefWidths(lead); }
char *FrTextSpan::getText() const { return m_text ? FrDupString(m_text) : originalText() ; }
void RenderQuote::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) { RenderText::styleDidChange(diff, oldStyle); setText(originalText()); }
void LayoutCounter::updateCounter() { setText(originalText()); }
void RenderCombineText::combineText() { if (!m_needsFontUpdate) return; // An ancestor element may trigger us to lay out again, even when we're already combined. if (m_isCombined) RenderText::setRenderedText(originalText()); m_isCombined = false; m_needsFontUpdate = false; // CSS3 spec says text-combine works only in vertical writing mode. if (style().isHorizontalWritingMode()) return; auto description = originalFont().fontDescription(); float emWidth = description.computedSize() * textCombineMargin; bool shouldUpdateFont = false; description.setOrientation(Horizontal); // We are going to draw combined text horizontally. GlyphOverflow glyphOverflow; glyphOverflow.computeBounds = true; float combinedTextWidth = width(0, textLength(), originalFont(), 0, nullptr, &glyphOverflow); float bestFitDelta = combinedTextWidth - emWidth; auto bestFitDescription = description; m_isCombined = combinedTextWidth <= emWidth; FontSelector* fontSelector = style().fontCascade().fontSelector(); if (m_isCombined) shouldUpdateFont = m_combineFontStyle->setFontDescription(description); // Need to change font orientation to horizontal. else { // Need to try compressed glyphs. static const FontWidthVariant widthVariants[] = { HalfWidth, ThirdWidth, QuarterWidth }; for (size_t i = 0 ; i < WTF_ARRAY_LENGTH(widthVariants) ; ++i) { description.setWidthVariant(widthVariants[i]); // When modifying this, make sure to keep it in sync with FontPlatformData::isForTextCombine()! FontCascade compressedFont(description, style().fontCascade().letterSpacing(), style().fontCascade().wordSpacing()); compressedFont.update(fontSelector); glyphOverflow.left = glyphOverflow.top = glyphOverflow.right = glyphOverflow.bottom = 0; float runWidth = RenderText::width(0, textLength(), compressedFont, 0, nullptr, &glyphOverflow); if (runWidth <= emWidth) { combinedTextWidth = runWidth; m_isCombined = true; // Replace my font with the new one. shouldUpdateFont = m_combineFontStyle->setFontDescription(description); break; } float widthDelta = runWidth - emWidth; if (widthDelta < bestFitDelta) { bestFitDelta = widthDelta; bestFitDescription = description; } } } if (!m_isCombined) { float scaleFactor = std::max(0.4f, emWidth / (emWidth + bestFitDelta)); float originalSize = bestFitDescription.computedSize(); do { float computedSize = originalSize * scaleFactor; bestFitDescription.setComputedSize(computedSize); shouldUpdateFont = m_combineFontStyle->setFontDescription(bestFitDescription); FontCascade compressedFont(bestFitDescription, style().fontCascade().letterSpacing(), style().fontCascade().wordSpacing()); compressedFont.update(fontSelector); glyphOverflow.left = glyphOverflow.top = glyphOverflow.right = glyphOverflow.bottom = 0; float runWidth = RenderText::width(0, textLength(), compressedFont, 0, nullptr, &glyphOverflow); if (runWidth <= emWidth) { combinedTextWidth = runWidth; m_isCombined = true; break; } scaleFactor -= 0.05f; } while (scaleFactor >= 0.4f); } if (shouldUpdateFont) m_combineFontStyle->fontCascade().update(fontSelector); if (m_isCombined) { static NeverDestroyed<String> objectReplacementCharacterString(&objectReplacementCharacter, 1); RenderText::setRenderedText(objectReplacementCharacterString.get()); m_combinedTextWidth = combinedTextWidth; m_combinedTextAscent = glyphOverflow.top; m_combinedTextDescent = glyphOverflow.bottom; } }