Title: [291811] trunk/Source/WebCore
- Revision
- 291811
- Author
- za...@apple.com
- Date
- 2022-03-24 12:39:09 -0700 (Thu, 24 Mar 2022)
Log Message
[LFC][IFC] Remove slow codepath matching arithmetics in FontCascade::widthForSimpleText
https://bugs.webkit.org/show_bug.cgi?id=238306
Reviewed by Antti Koivisto.
By now if we measure some text using the fast codepath, we usually stay on this codepath for the rest
of the layout (i.e. preferred width computation uses the same fast codepath, and we also don't dynamically switch between modern and legacy).
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::widthForSimpleText const):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (291810 => 291811)
--- trunk/Source/WebCore/ChangeLog 2022-03-24 19:36:17 UTC (rev 291810)
+++ trunk/Source/WebCore/ChangeLog 2022-03-24 19:39:09 UTC (rev 291811)
@@ -1,3 +1,16 @@
+2022-03-24 Alan Bujtas <za...@apple.com>
+
+ [LFC][IFC] Remove slow codepath matching arithmetics in FontCascade::widthForSimpleText
+ https://bugs.webkit.org/show_bug.cgi?id=238306
+
+ Reviewed by Antti Koivisto.
+
+ By now if we measure some text using the fast codepath, we usually stay on this codepath for the rest
+ of the layout (i.e. preferred width computation uses the same fast codepath, and we also don't dynamically switch between modern and legacy).
+
+ * platform/graphics/FontCascade.cpp:
+ (WebCore::FontCascade::widthForSimpleText const):
+
2022-03-24 Gabriel Nava Marino <gnavamar...@apple.com>
FormDataConsumer callback happens more than once with an exception
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (291810 => 291811)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2022-03-24 19:36:17 UTC (rev 291810)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2022-03-24 19:39:09 UTC (rev 291811)
@@ -312,30 +312,22 @@
return *cacheEntry;
GlyphBuffer glyphBuffer;
- float beforeWidth = 0;
auto& font = primaryFont();
- for (unsigned i = 0; i < text.length(); ++i) {
+ ASSERT(!font.syntheticBoldOffset()); // This function should only be called when RenderText::computeCanUseSimplifiedTextMeasuring() returns true, and that function requires no synthetic bold.
+ for (size_t i = 0; i < text.length(); ++i) {
auto glyph = glyphDataForCharacter(text[i], false).glyph;
- ASSERT(!font.syntheticBoldOffset()); // This function should only be called when RenderText::computeCanUseSimplifiedTextMeasuring() returns true, and that function requires no synthetic bold.
- auto glyphWidth = font.widthForGlyph(glyph);
- beforeWidth += glyphWidth;
- glyphBuffer.add(glyph, font, glyphWidth, i);
+ glyphBuffer.add(glyph, font, font.widthForGlyph(glyph), i);
}
auto initialAdvance = font.applyTransforms(glyphBuffer, 0, 0, enableKerning(), requiresShaping(), fontDescription().computedLocale(), text, textDirection);
- // This is needed only to match the result of the slow path.
- // Same glyph widths but different floating point arithmetic can produce different run width.
- float afterWidth = 0;
+ auto width = 0.f;
for (size_t i = 0; i < glyphBuffer.size(); ++i)
- afterWidth += WebCore::width(glyphBuffer.advanceAt(i));
- auto additionalAdvance = afterWidth - beforeWidth;
+ width += WebCore::width(glyphBuffer.advanceAt(i));
+ width += WebCore::width(initialAdvance);
- auto finalWidth = beforeWidth + additionalAdvance;
- finalWidth += WebCore::width(initialAdvance);
-
if (cacheEntry)
- *cacheEntry = finalWidth;
- return finalWidth;
+ *cacheEntry = width;
+ return width;
}
GlyphData FontCascade::glyphDataForCharacter(UChar32 c, bool mirror, FontVariant variant) const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes