Modified: trunk/Source/WebCore/rendering/RenderCombineText.cpp (291792 => 291793)
--- trunk/Source/WebCore/rendering/RenderCombineText.cpp 2022-03-24 13:04:00 UTC (rev 291792)
+++ trunk/Source/WebCore/rendering/RenderCombineText.cpp 2022-03-24 13:47:41 UTC (rev 291793)
@@ -68,14 +68,6 @@
combineTextIfNeeded();
}
-float RenderCombineText::width(unsigned from, unsigned length, const FontCascade& font, float xPosition, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
-{
- if (m_isCombined)
- return !length ? 0 : font.size();
-
- return RenderText::width(from, length, font, xPosition, fallbackFonts, glyphOverflow);
-}
-
std::optional<FloatPoint> RenderCombineText::computeTextOrigin(const FloatRect& boxRect) const
{
if (!m_isCombined)
@@ -148,7 +140,7 @@
compressedFont.update(fontSelector);
glyphOverflow.left = glyphOverflow.top = glyphOverflow.right = glyphOverflow.bottom = 0;
- float runWidth = RenderText::width(0, text().length(), compressedFont, 0, nullptr, &glyphOverflow);
+ float runWidth = width(0, text().length(), compressedFont, 0, nullptr, &glyphOverflow);
if (runWidth <= emWidth) {
combinedTextWidth = runWidth;
m_isCombined = true;
@@ -178,7 +170,7 @@
compressedFont.update(fontSelector);
glyphOverflow.left = glyphOverflow.top = glyphOverflow.right = glyphOverflow.bottom = 0;
- float runWidth = RenderText::width(0, text().length(), compressedFont, 0, nullptr, &glyphOverflow);
+ float runWidth = width(0, text().length(), compressedFont, 0, nullptr, &glyphOverflow);
if (runWidth <= emWidth) {
combinedTextWidth = runWidth;
m_isCombined = true;
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (291792 => 291793)
--- trunk/Source/WebCore/rendering/RenderText.cpp 2022-03-24 13:04:00 UTC (rev 291792)
+++ trunk/Source/WebCore/rendering/RenderText.cpp 2022-03-24 13:47:41 UTC (rev 291793)
@@ -704,19 +704,24 @@
return createVisiblePosition(0, Affinity::Downstream);
}
-ALWAYS_INLINE float RenderText::widthFromCache(const FontCascade& f, unsigned start, unsigned len, float xPos, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow, const RenderStyle& style) const
+static inline std::optional<float> combineTextWidth(const RenderText& renderer, const FontCascade& fontCascade, const RenderStyle& style)
{
- if (style.hasTextCombine() && is<RenderCombineText>(*this)) {
- const RenderCombineText& combineText = downcast<RenderCombineText>(*this);
- if (combineText.isCombined())
- return combineText.combinedTextWidth(f);
- }
+ if (!style.hasTextCombine() || !is<RenderCombineText>(renderer))
+ return { };
+ auto& combineTextRenderer = downcast<RenderCombineText>(renderer);
+ return combineTextRenderer.isCombined() ? std::make_optional(combineTextRenderer.combinedTextWidth(fontCascade)) : std::nullopt;
+}
- TextRun run = RenderBlock::constructTextRun(*this, start, len, style);
+ALWAYS_INLINE float RenderText::widthFromCache(const FontCascade& fontCascade, unsigned start, unsigned length, float xPos, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow, const RenderStyle& style) const
+{
+ if (auto width = combineTextWidth(*this, fontCascade, style))
+ return *width;
+
+ TextRun run = RenderBlock::constructTextRun(*this, start, length, style);
run.setCharacterScanForCodePath(!canUseSimpleFontCodePath());
run.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
run.setXPos(xPos);
- return f.width(run, fallbackFonts, glyphOverflow);
+ return fontCascade.width(run, fallbackFonts, glyphOverflow);
}
ALWAYS_INLINE float RenderText::widthFromCacheConsideringPossibleTrailingSpace(const RenderStyle& style, const FontCascade& font, unsigned startIndex, unsigned wordLen, float xPos, bool currentCharacterIsSpace, WordTrailingSpace& wordTrailingSpace, HashSet<const Font*>& fallbackFonts, GlyphOverflow& glyphOverflow) const
@@ -1542,16 +1547,19 @@
return width(from, len, lineStyle.fontCascade(), xPos, fallbackFonts, glyphOverflow);
}
-float RenderText::width(unsigned from, unsigned len, const FontCascade& f, float xPos, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
+float RenderText::width(unsigned from, unsigned length, const FontCascade& fontCascade, float xPos, HashSet<const Font*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
- ASSERT(from + len <= text().length());
- if (!text().length())
- return 0;
+ ASSERT(from + length <= text().length());
+ if (!text().length() || !length)
+ return 0.f;
- const RenderStyle& style = this->style();
- float w;
- if (&f == &style.fontCascade()) {
- if (!style.preserveNewline() && !from && len == text().length() && (!glyphOverflow || !glyphOverflow->computeBounds)) {
+ auto& style = this->style();
+ if (auto width = combineTextWidth(*this, fontCascade, style))
+ return *width;
+
+ float width = 0.f;
+ if (&fontCascade == &style.fontCascade()) {
+ if (!style.preserveNewline() && !from && length == text().length() && (!glyphOverflow || !glyphOverflow->computeBounds)) {
if (fallbackFonts) {
ASSERT(glyphOverflow);
if (preferredLogicalWidthsDirty() || !m_knownToHaveNoOverflowAndNoFallbackFonts) {
@@ -1559,21 +1567,21 @@
if (fallbackFonts->isEmpty() && !glyphOverflow->left && !glyphOverflow->right && !glyphOverflow->top && !glyphOverflow->bottom)
m_knownToHaveNoOverflowAndNoFallbackFonts = true;
}
- w = m_maxWidth;
+ width = m_maxWidth;
} else
- w = maxLogicalWidth();
+ width = maxLogicalWidth();
} else
- w = widthFromCache(f, from, len, xPos, fallbackFonts, glyphOverflow, style);
+ width = widthFromCache(fontCascade, from, length, xPos, fallbackFonts, glyphOverflow, style);
} else {
- TextRun run = RenderBlock::constructTextRun(*this, from, len, style);
+ TextRun run = RenderBlock::constructTextRun(*this, from, length, style);
run.setCharacterScanForCodePath(!canUseSimpleFontCodePath());
run.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
run.setXPos(xPos);
- w = f.width(run, fallbackFonts, glyphOverflow);
+ width = fontCascade.width(run, fallbackFonts, glyphOverflow);
}
- return clampTo(w, 0.f);
+ return clampTo(width, 0.f);
}
IntRect RenderText::linesBoundingBox() const
Modified: trunk/Source/WebCore/rendering/RenderText.h (291792 => 291793)
--- trunk/Source/WebCore/rendering/RenderText.h 2022-03-24 13:04:00 UTC (rev 291792)
+++ trunk/Source/WebCore/rendering/RenderText.h 2022-03-24 13:47:41 UTC (rev 291793)
@@ -91,8 +91,8 @@
void positionLineBox(LegacyInlineTextBox&);
- virtual float width(unsigned from, unsigned length, const FontCascade&, float xPos, HashSet<const Font*>* fallbackFonts = nullptr, GlyphOverflow* = nullptr) const;
- virtual float width(unsigned from, unsigned length, float xPos, bool firstLine = false, HashSet<const Font*>* fallbackFonts = nullptr, GlyphOverflow* = nullptr) const;
+ float width(unsigned from, unsigned length, const FontCascade&, float xPos, HashSet<const Font*>* fallbackFonts = nullptr, GlyphOverflow* = nullptr) const;
+ float width(unsigned from, unsigned length, float xPos, bool firstLine = false, HashSet<const Font*>* fallbackFonts = nullptr, GlyphOverflow* = nullptr) const;
float minLogicalWidth() const;
float maxLogicalWidth() const;