Skip to content

Commit a635980

Browse files
committed
[SVG text] Implement the SVG 2 text layout algorithm
https://bugs.webkit.org/show_bug.cgi?id=327817 rdar://problem/190204825 Reviewed by Alan Baradlay. The old SVGTextLayoutEngine is built around assumptions of the legacy line layout. We can do better. This patch adds SVGTextLayoutAlgorithm which implements the text layout algorithm as described by the SVG 2 specification (https://w3c.github.io/svgwg/svg2-draft/text.html#TextLayoutAlgorithm). The code maps directly to spec language making it much more readable than the old code. It is also more correct. Following the spec steps fixes textLength with x/y lists and on text paths, and lengthAdjust="spacingAndGlyphs" and whitespace collapsing now match Chrome and Firefox. It also performs better. The old implementation measured text repeatedly, checked grapheme cluster boundaries for every character and used hash maps for temporary storage. The new one caches the measurements, skips the cluster checks for 8-bit text and uses index-based storage. On a microbenchmark with 10k text labels text changes are about 25% faster. Speedometer Charts-observable-plot improves by about 1% and React-Stockcharts-SVG by about 0.5%. The new path is behind the internal SVG2TextLayoutAlgorithmEnabled flag, off by default for now. * LayoutTests/svg/text/textLength-spacing-absolute-positions-expected.txt: Added. * LayoutTests/svg/text/textLength-spacing-absolute-positions.html: Added. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/rendering/svg/RenderSVGInlineText.cpp: (WebCore::RenderSVGInlineText::setTextInternal): (WebCore::RenderSVGInlineText::styleDidChange): (WebCore::RenderSVGInlineText::updateScaledFont): Invalidate the cached text metrics. * Source/WebCore/rendering/svg/RenderSVGInlineText.h: * Source/WebCore/rendering/svg/RenderSVGText.cpp: (WebCore::RenderSVGText::shouldHandleSubtreeMutations const): (WebCore::RenderSVGText::subtreeTextDidChange): (WebCore::RenderSVGText::layout): Skip the layout attribute building with the new path. (WebCore::RenderSVGText::computePerCharacterLayoutInformation): (WebCore::RenderSVGText::usesSVGTextLayoutAlgorithm const): * Source/WebCore/rendering/svg/RenderSVGText.h: * Source/WebCore/rendering/svg/SVGTextLayoutAlgorithm.cpp: Added. * Source/WebCore/rendering/svg/SVGTextLayoutAlgorithm.h: Added. * Source/WebCore/rendering/svg/SVGTextLayoutEngine.cpp: (WebCore::SVGTextLayoutEngine::layoutTextOnLineOrPath): * Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp: (WebCore::SVGTextLayoutEngineBaseline::dominantBaselineToAlignmentBaseline const): (WebCore::SVGTextLayoutEngineBaseline::calculateAlignmentBaselineShift const): Take the style instead of the renderer so layout boxes can use it. * Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.h: Canonical link: https://commits.webkit.org/323987@main
1 parent 8bcd0e2 commit a635980

14 files changed

Lines changed: 1328 additions & 24 deletions
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
abc
2+
abc
3+
😀😀😀
4+
😀
5+
XXXX
6+
abc
7+
abc
8+
9+
PASS Absolute x positions are not moved by textLength spacing
10+
PASS textLength spacing is distributed between the characters of a single chunk
11+
PASS textLength spacing on a path counts characters, not code units
12+
PASS textLength with lengthAdjust=spacingAndGlyphs stretches advances and glyphs of a single chunk
13+
PASS Absolute x positions are not moved by textLength spacingAndGlyphs, the glyphs stretch in place
14+
PASS Absolute x positions at the natural advances are not moved by textLength spacingAndGlyphs
15+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<!DOCTYPE html><!-- webkit-test-runner [ SVG2TextLayoutAlgorithmEnabled=true ] -->
2+
<meta charset="utf-8">
3+
<title>textLength with absolutely positioned characters</title>
4+
<script src="../../resources/testharness.js"></script>
5+
<script src="../../resources/testharnessreport.js"></script>
6+
<svg width="600" height="200" font-family="Ahem" font-size="20">
7+
<text id="absolute" x="10 100 200" y="30" textLength="300" lengthAdjust="spacing">abc</text>
8+
<text id="single" x="10" y="60" textLength="300" lengthAdjust="spacing">abc</text>
9+
<path id="path" d="M 10 150 L 590 150"/>
10+
<text id="onPath"><textPath href="#path" textLength="300" lengthAdjust="spacing">&#x1F600;&#x1F600;&#x1F600;</textPath></text>
11+
<text id="reference" x="10" y="190">&#x1F600;</text>
12+
<text id="glyphs" x="0 50 100 150" y="120" font-size="50" textLength="100" lengthAdjust="spacingAndGlyphs">XXXX</text>
13+
<text id="glyphsAbsolute" x="10 100 200" y="90" textLength="300" lengthAdjust="spacingAndGlyphs">abc</text>
14+
<text id="glyphsSingle" x="10" y="90" textLength="300" lengthAdjust="spacingAndGlyphs">abc</text>
15+
</svg>
16+
<script>
17+
function startX(id, index)
18+
{
19+
return document.getElementById(id).getStartPositionOfChar(index).x;
20+
}
21+
22+
test(() => {
23+
assert_approx_equals(startX("absolute", 0), 10, 0.01);
24+
assert_approx_equals(startX("absolute", 1), 100, 0.01);
25+
assert_approx_equals(startX("absolute", 2), 200, 0.01);
26+
}, "Absolute x positions are not moved by textLength spacing");
27+
28+
test(() => {
29+
assert_approx_equals(startX("single", 0), 10, 0.01);
30+
assert_approx_equals(startX("single", 1), 150, 0.01);
31+
assert_approx_equals(startX("single", 2), 290, 0.01);
32+
}, "textLength spacing is distributed between the characters of a single chunk");
33+
34+
test(() => {
35+
const advance = document.getElementById("reference").getComputedTextLength();
36+
// Each emoji is a surrogate pair. Spacing goes between the three characters, not the six code units.
37+
const spacing = (300 - 3 * advance) / 2;
38+
assert_approx_equals(startX("onPath", 2) - startX("onPath", 0), advance + spacing, 0.5);
39+
assert_approx_equals(startX("onPath", 4) - startX("onPath", 0), 2 * (advance + spacing), 0.5);
40+
}, "textLength spacing on a path counts characters, not code units");
41+
42+
function assertExtents(id, expectedXs, expectedWidth)
43+
{
44+
const text = document.getElementById(id);
45+
expectedXs.forEach((expectedX, i) => {
46+
const extent = text.getExtentOfChar(i);
47+
assert_approx_equals(extent.x, expectedX, 0.01, `character ${i} x`);
48+
assert_approx_equals(extent.width, expectedWidth, 0.01, `character ${i} width`);
49+
});
50+
}
51+
52+
test(() => {
53+
assertExtents("glyphsSingle", [10, 110, 210], 100);
54+
}, "textLength with lengthAdjust=spacingAndGlyphs stretches advances and glyphs of a single chunk");
55+
56+
test(() => {
57+
assertExtents("glyphsAbsolute", [10, 100, 200], 100);
58+
}, "Absolute x positions are not moved by textLength spacingAndGlyphs, the glyphs stretch in place");
59+
60+
test(() => {
61+
assertExtents("glyphs", [0, 50, 100, 150], 25);
62+
}, "Absolute x positions at the natural advances are not moved by textLength spacingAndGlyphs");
63+
</script>

‎Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5270,6 +5270,13 @@ SKAttributionEnabled:
52705270
humanReadableDescription: "SKAttribution"
52715271
defaultValue: true
52725272

5273+
SVG2TextLayoutAlgorithmEnabled:
5274+
type: bool
5275+
status: internal
5276+
humanReadableName: "SVG 2 text layout algorithm"
5277+
humanReadableDescription: "Use the SVG 2 text layout algorithm for SVG text"
5278+
defaultValue: false
5279+
52735280
SVGExternalResourcesEnabled:
52745281
type: bool
52755282
status: stable

‎Source/WebCore/Sources.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3212,6 +3212,7 @@ rendering/svg/SVGRenderingContext.cpp @header:RenderStyleGetters
32123212
rendering/svg/SVGTextBoxPainter.cpp @header:RenderStyleGetters
32133213
rendering/svg/SVGTextChunk.cpp @header:RenderStyleGetters
32143214
rendering/svg/SVGTextChunkBuilder.cpp
3215+
rendering/svg/SVGTextLayoutAlgorithm.cpp @header:RenderStyleGetters
32153216
rendering/svg/SVGTextLayoutAttributes.cpp
32163217
rendering/svg/SVGTextLayoutAttributesBuilder.cpp @header:RenderStyleGetters
32173218
rendering/svg/SVGTextLayoutEngine.cpp @header:RenderStyleGetters

‎Source/WebCore/WebCore.xcodeproj/project.pbxproj‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6868,6 +6868,7 @@
68686868
E403B7A2251B11930019E800 /* LayoutIntegrationCoverage.h in Headers */ = {isa = PBXBuildFile; fileRef = E403B7A1251B11930019E800 /* LayoutIntegrationCoverage.h */; };
68696869
E403B7A3251B11C10019E800 /* LayoutIntegrationPagination.h in Headers */ = {isa = PBXBuildFile; fileRef = E4312AB724B3265600678349 /* LayoutIntegrationPagination.h */; };
68706870
C814C569BBA6F36D17A949B9 /* SVGTextDisplayContentBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C34B552C743CB4BA7256D9A /* SVGTextDisplayContentBuilder.h */; };
6871+
89ACE0522BC1BB06CFFF1775 /* SVGTextLayoutAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 00580A55849484D03A89EE07 /* SVGTextLayoutAlgorithm.h */; };
68716872
E406204C2E5F2EC0009144F4 /* StyleRuleFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = E406204B2E5F2EC0009144F4 /* StyleRuleFunction.h */; };
68726873
E415EB13270C351300E8DA1B /* InlineIteratorInlineBox.h in Headers */ = {isa = PBXBuildFile; fileRef = E415EB11270C351200E8DA1B /* InlineIteratorInlineBox.h */; };
68736874
E418025523D4549B00FFB071 /* LayoutIntegrationBoxTreeUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = E418025323D4549A00FFB071 /* LayoutIntegrationBoxTreeUpdater.h */; };
@@ -22781,6 +22782,8 @@
2278122782
E4312AB724B3265600678349 /* LayoutIntegrationPagination.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutIntegrationPagination.h; sourceTree = "<group>"; };
2278222783
5D3C5B1036F71428B78A1EE2 /* SVGTextDisplayContentBuilder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTextDisplayContentBuilder.cpp; sourceTree = "<group>"; };
2278322784
8C34B552C743CB4BA7256D9A /* SVGTextDisplayContentBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGTextDisplayContentBuilder.h; sourceTree = "<group>"; };
22785+
B6422CEB4AEBB2DE83C8EDC7 /* SVGTextLayoutAlgorithm.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTextLayoutAlgorithm.cpp; sourceTree = "<group>"; };
22786+
00580A55849484D03A89EE07 /* SVGTextLayoutAlgorithm.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGTextLayoutAlgorithm.h; sourceTree = "<group>"; };
2278422787
E43A023A17EB370A004CDD25 /* RenderElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderElement.h; sourceTree = "<group>"; };
2278522788
E43A023C17EB3713004CDD25 /* RenderElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderElement.cpp; sourceTree = "<group>"; };
2278622789
E43AF8E41AC5B7DD00CA717E /* CacheValidation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CacheValidation.cpp; sourceTree = "<group>"; };
@@ -24918,6 +24921,8 @@
2491824921
081668D1125603BF006F25DE /* SVGTextChunkBuilder.cpp */,
2491924922
081668D2125603BF006F25DE /* SVGTextChunkBuilder.h */,
2492024923
08F0BFBF1255C53C00075185 /* SVGTextFragment.h */,
24924+
B6422CEB4AEBB2DE83C8EDC7 /* SVGTextLayoutAlgorithm.cpp */,
24925+
00580A55849484D03A89EE07 /* SVGTextLayoutAlgorithm.h */,
2492124926
088C2F7512390080003D65CE /* SVGTextLayoutAttributes.cpp */,
2492224927
088C2F7612390080003D65CE /* SVGTextLayoutAttributes.h */,
2492324928
081093D91255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.cpp */,
@@ -49654,6 +49659,7 @@
4965449659
C814C569BBA6F36D17A949B9 /* SVGTextDisplayContentBuilder.h in Headers */,
4965549660
B2227ACB0D00BF220071B782 /* SVGTextElement.h in Headers */,
4965649661
08F0BFC41255C53C00075185 /* SVGTextFragment.h in Headers */,
49662+
89ACE0522BC1BB06CFFF1775 /* SVGTextLayoutAlgorithm.h in Headers */,
4965749663
088C2F7A12390081003D65CE /* SVGTextLayoutAttributes.h in Headers */,
4965849664
081093DC1255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.h in Headers */,
4965949665
081668DA125603D5006F25DE /* SVGTextLayoutEngine.h in Headers */,

‎Source/WebCore/rendering/svg/RenderSVGInlineText.cpp‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ String RenderSVGInlineText::originalText() const
9494
void RenderSVGInlineText::setTextInternal(const String& newText, bool force)
9595
{
9696
RenderText::setTextInternal(newText, force);
97+
m_hasValidTextMetrics = false;
9798
if (!force)
9899
setRenderedText(newText);
99100
if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this))
@@ -104,6 +105,8 @@ void RenderSVGInlineText::styleDidChange(Style::Difference diff, const Style::Co
104105
{
105106
RenderText::styleDidChange(diff, oldStyle);
106107
updateScaledFont();
108+
if (oldStyle && (oldStyle->writingMode() != style().writingMode() || oldStyle->unicodeBidi() != style().unicodeBidi()))
109+
m_hasValidTextMetrics = false;
107110

108111
bool newPreserves = style().whiteSpaceCollapse() == WhiteSpaceCollapse::Preserve;
109112
bool oldPreserves = oldStyle && oldStyle->whiteSpaceCollapse() == WhiteSpaceCollapse::Preserve;
@@ -225,8 +228,16 @@ PositionWithAffinity RenderSVGInlineText::positionForPoint(const LayoutPoint& po
225228

226229
void RenderSVGInlineText::updateScaledFont()
227230
{
228-
if (computeNewScaledFontForStyle(*this, style(), m_scalingFactor, m_scaledFont))
231+
// FIXME: FontCascade comparison also compares the font list, which FontCascadeCache::invalidate() replaces,
232+
// so the text metrics are dropped after complex text measurement even if the font did not change.
233+
float scalingFactor = 1;
234+
FontCascade scaledFont;
235+
if (computeNewScaledFontForStyle(*this, style(), scalingFactor, scaledFont))
229236
m_canUseSimplifiedTextMeasuring = { };
237+
if (scalingFactor != m_scalingFactor || scaledFont != m_scaledFont)
238+
m_hasValidTextMetrics = false;
239+
m_scalingFactor = scalingFactor;
240+
m_scaledFont = WTF::move(scaledFont);
230241
}
231242

232243
float RenderSVGInlineText::computeScalingFactorForRenderer(const RenderObject& renderer)

‎Source/WebCore/rendering/svg/RenderSVGInlineText.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class RenderSVGInlineText final : public RenderText {
4242
SVGTextLayoutAttributes* layoutAttributes() LIFETIME_BOUND { return &m_layoutAttributes; }
4343
const SVGTextLayoutAttributes* layoutAttributes() const LIFETIME_BOUND { return &m_layoutAttributes; }
4444

45+
// Used by SVGTextLayoutAlgorithm, which measures only when the text or the font changes.
46+
bool hasValidTextMetrics() const { return m_hasValidTextMetrics; }
47+
void setHasValidTextMetrics(bool value) { m_hasValidTextMetrics = value; }
48+
4549
// computeScalingFactor() returns the font-size scaling factor, ignoring the text-rendering mode.
4650
// scalingFactor() takes it into account, and thus returns 1 whenever text-rendering is set to 'geometricPrecision'.
4751
// Therefore if you need access to the vanilla scaling factor, use this method directly (e.g. for non-scaling-stroke).
@@ -71,6 +75,7 @@ class RenderSVGInlineText final : public RenderText {
7175
float m_scalingFactor;
7276
FontCascade m_scaledFont;
7377
SVGTextLayoutAttributes m_layoutAttributes;
78+
bool m_hasValidTextMetrics { false };
7479
};
7580

7681
} // namespace WebCore

‎Source/WebCore/rendering/svg/RenderSVGText.cpp‎

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include "SVGResourcesCache.h"
6363
#include "SVGTextBoxPainter.h"
6464
#include "SVGTextElement.h"
65+
#include "SVGTextLayoutAlgorithm.h"
6566
#include "SVGTextLayoutEngine.h"
6667
#include "SVGURIReference.h"
6768
#include "SVGVisitedRendererTracking.h"
@@ -155,6 +156,10 @@ static inline std::tuple<SVGTextLayoutAttributes*, SVGTextLayoutAttributes*> fin
155156

156157
inline bool RenderSVGText::shouldHandleSubtreeMutations() const
157158
{
159+
// SVGTextLayoutAlgorithm rebuilds everything except the text metrics on each layout.
160+
// FIXME: Switching back to the old path after a layout leaves m_layoutAttributes empty, and the text disappears.
161+
if (usesSVGTextLayoutAlgorithm())
162+
return false;
158163
if (beingDestroyed() || !m_hasPerformedLayout) {
159164
ASSERT(m_layoutAttributes.isEmpty());
160165
ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements());
@@ -276,6 +281,10 @@ void RenderSVGText::subtreeTextDidChange(RenderSVGInlineText* text)
276281
{
277282
ASSERT(text);
278283
ASSERT(!beingDestroyed());
284+
if (usesSVGTextLayoutAlgorithm()) {
285+
setNeedsLayout();
286+
return;
287+
}
279288
if (!m_hasPerformedLayout) {
280289
ASSERT(m_layoutAttributes.isEmpty());
281290
ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements());
@@ -342,7 +351,25 @@ void RenderSVGText::layout()
342351
updateCachedBoundariesInParents = true;
343352
}
344353

345-
if (!m_hasPerformedLayout) {
354+
auto isLayoutSizeChanged = [&] {
355+
if (auto* legacyRootObject = lineageOfType<LegacyRenderSVGRoot>(*this).first())
356+
return legacyRootObject->isLayoutSizeChanged();
357+
if (auto* rootObject = lineageOfType<RenderSVGRoot>(*this).first())
358+
return rootObject->isLayoutSizeChanged();
359+
return false;
360+
};
361+
362+
if (usesSVGTextLayoutAlgorithm()) {
363+
if (!m_hasPerformedLayout || m_needsTextMetricsUpdate || isLayoutSizeChanged() || m_needsTransformUpdate) {
364+
// Text renderers remeasure if the on-screen font changed.
365+
updateFontInAllDescendants(*this);
366+
updateCachedBoundariesInParents = true;
367+
}
368+
if (m_needsPositioningValuesUpdate)
369+
updateCachedBoundariesInParents = true;
370+
m_needsTextMetricsUpdate = false;
371+
m_needsPositioningValuesUpdate = false;
372+
} else if (!m_hasPerformedLayout) {
346373
// When laying out initially, collect all layout attributes, build the character data map,
347374
// and propogate resulting SVGLayoutAttributes to all RenderSVGInlineText children in the subtree.
348375
ASSERT(m_layoutAttributes.isEmpty());
@@ -363,13 +390,7 @@ void RenderSVGText::layout()
363390
m_needsPositioningValuesUpdate = false;
364391
updateCachedBoundariesInParents = true;
365392
} else {
366-
bool isLayoutSizeChanged = false;
367-
if (auto* legacyRootObject = lineageOfType<LegacyRenderSVGRoot>(*this).first())
368-
isLayoutSizeChanged = legacyRootObject->isLayoutSizeChanged();
369-
else if (auto* rootObject = lineageOfType<RenderSVGRoot>(*this).first())
370-
isLayoutSizeChanged = rootObject->isLayoutSizeChanged();
371-
372-
if (m_needsTextMetricsUpdate || isLayoutSizeChanged || m_needsTransformUpdate) {
393+
if (m_needsTextMetricsUpdate || isLayoutSizeChanged() || m_needsTransformUpdate) {
373394
// If the root layout size changed (eg. window size changes) or the transform to the root
374395
// context has changed then recompute the on-screen font size.
375396
updateFontInAllDescendants(*this);
@@ -381,7 +402,8 @@ void RenderSVGText::layout()
381402
m_layoutAttributesBuilder.rebuildMetricsForSubtree(*this);
382403
}
383404

384-
checkLayoutAttributesConsistency(this, m_layoutAttributes);
405+
if (!usesSVGTextLayoutAlgorithm())
406+
checkLayoutAttributesConsistency(this, m_layoutAttributes);
385407

386408
// Reduced version of RenderBlock::layoutBlock(), which only takes care of SVG text.
387409
// All if branches that could cause early exit in RenderBlocks layoutBlock() method are turned into assertions.
@@ -556,13 +578,19 @@ void RenderSVGText::computePerCharacterLayoutInformation()
556578
if (!hasSVGContent)
557579
return;
558580

559-
if (m_layoutAttributes.isEmpty())
581+
if (!usesSVGTextLayoutAlgorithm() && m_layoutAttributes.isEmpty())
560582
return;
561583

562584
CheckedRef lineLayout = *inlineLayout();
563585
auto [boxes, fragmentsForBoxes] = lineLayout->resetSVGTextFragments();
564586
ASSERT(!boxes.isEmpty() && boxes[0].isRootInlineBox());
565587

588+
if (usesSVGTextLayoutAlgorithm()) {
589+
SVGTextLayoutAlgorithm { *layoutBox(), boxes, fragmentsForBoxes }.layout();
590+
updatePositionAndOverflow(lineLayout->applySVGTextFragments());
591+
return;
592+
}
593+
566594
SVGTextLayoutEngine characterLayout(m_layoutAttributes, fragmentsForBoxes);
567595
auto endIndex = layoutCharactersInDisplayBoxes(boxes, 0, &characterLayout);
568596
ASSERT_UNUSED(endIndex, endIndex == boxes.size());
@@ -572,6 +600,11 @@ void RenderSVGText::computePerCharacterLayoutInformation()
572600
updatePositionAndOverflow(lineLayout->applySVGTextFragments());
573601
}
574602

603+
bool RenderSVGText::usesSVGTextLayoutAlgorithm() const
604+
{
605+
return document().settings().svg2TextLayoutAlgorithmEnabled();
606+
}
607+
575608
bool RenderSVGText::nodeAtFloatPoint(const HitTestRequest& request, HitTestResult& result, const FloatPoint& pointInParent, HitTestAction hitTestAction)
576609
{
577610
ASSERT(!document().settings().layerBasedSVGEngineEnabled());

‎Source/WebCore/rendering/svg/RenderSVGText.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class RenderSVGText final : public RenderSVGBlock {
4646

4747
void setNeedsPositioningValuesUpdate() { m_needsPositioningValuesUpdate = true; }
4848
void setNeedsTextMetricsUpdate() { m_needsTextMetricsUpdate = true; }
49+
bool usesSVGTextLayoutAlgorithm() const;
4950

5051
// FIXME: [LBSE] Only needed for legacy SVG engine.
5152
void setNeedsTransformUpdate() override { m_needsTransformUpdate = true; }

0 commit comments

Comments
 (0)