diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp index 2b14d55b01ec..f7399d0f0636 100644 --- a/layout/svg/SVGTextFrame.cpp +++ b/layout/svg/SVGTextFrame.cpp @@ -4733,8 +4733,8 @@ void SVGTextFrame::DoAnchoring() { } bool vertical = GetWritingMode().IsVertical(); - uint32_t start = it.TextElementCharIndex(); - while (start < mPositions.Length()) { + for (uint32_t start = it.TextElementCharIndex(); start < mPositions.Length(); + start = it.TextElementCharIndex()) { it.AdvanceToCharacter(start); nsTextFrame* chunkFrame = it.TextFrame(); @@ -4770,8 +4770,6 @@ void SVGTextFrame::DoAnchoring() { ShiftAnchoredChunk(mPositions, start, end, left, right, anchor, vertical); } - - start = it.TextElementCharIndex(); } } @@ -4834,15 +4832,19 @@ void SVGTextFrame::DoGlyphPositioning() { TruncateTo(deltas, charPositions); TruncateTo(mPositions, charPositions); - // Fill in an unspecified character position at index 0. - if (!mPositions[0].IsXSpecified()) { - mPositions[0].mPosition.x = 0.0; + // Fill in an unspecified position for the first addressable character. + uint32_t first = 0; + while (first + 1 < mPositions.Length() && mPositions[first].mUnaddressable) { + ++first; } - if (!mPositions[0].IsYSpecified()) { - mPositions[0].mPosition.y = 0.0; + if (!mPositions[first].IsXSpecified()) { + mPositions[first].mPosition.x = 0.0; } - if (!mPositions[0].IsAngleSpecified()) { - mPositions[0].mAngle = 0.0; + if (!mPositions[first].IsYSpecified()) { + mPositions[first].mPosition.y = 0.0; + } + if (!mPositions[first].IsAngleSpecified()) { + mPositions[first].mAngle = 0.0; } nsPresContext* presContext = PresContext(); diff --git a/testing/web-platform/tests/svg/text/reftests/text-bidi-controls-anchors-1-ref.svg b/testing/web-platform/tests/svg/text/reftests/text-bidi-controls-anchors-1-ref.svg new file mode 100644 index 000000000000..45c955b2b9fe --- /dev/null +++ b/testing/web-platform/tests/svg/text/reftests/text-bidi-controls-anchors-1-ref.svg @@ -0,0 +1,36 @@ + + + Text anchors and bidi control characters + + + + + Start Anchor + Middle Anchor + End Anchor + + Start Anchor + Middle Anchor + End Anchor + + Start Anchor + Middle Anchor + End Anchor + + Start Anchor + Middle Anchor + End Anchor + + rohcnA tratS + rohcnA elddiM + rohcnA dnE + + tratS Anchor + elddiM Anchor + dnE Anchor + + Start rohcnA + Middle rohcnA + End rohcnA + + diff --git a/testing/web-platform/tests/svg/text/reftests/text-bidi-controls-anchors-1.svg b/testing/web-platform/tests/svg/text/reftests/text-bidi-controls-anchors-1.svg new file mode 100644 index 000000000000..92a1ed1e3fb0 --- /dev/null +++ b/testing/web-platform/tests/svg/text/reftests/text-bidi-controls-anchors-1.svg @@ -0,0 +1,47 @@ + + + Text anchors and bidi control characters + + + + + + + + + Start Anchor + Middle Anchor + End Anchor + + + ‫Start Anchor‬ + ‫Middle Anchor‬ + ‫End Anchor‬ + + + ‫Start‬ Anchor + ‫Middle‬ Anchor + ‫End‬ Anchor + + + Start ‫Anchor‬ + Middle ‫Anchor‬ + End ‫Anchor‬ + + + ‮Start Anchor‬ + ‮Middle Anchor‬ + ‮End Anchor‬ + + + ‮Start‬ Anchor + ‮Middle‬ Anchor + ‮End‬ Anchor + + + Start ‮Anchor‬ + Middle ‮Anchor‬ + End ‮Anchor‬ + + + diff --git a/testing/web-platform/tests/svg/text/reftests/text-bidi-controls-anchors-2-ref.svg b/testing/web-platform/tests/svg/text/reftests/text-bidi-controls-anchors-2-ref.svg new file mode 100644 index 000000000000..08862dc3e5ce --- /dev/null +++ b/testing/web-platform/tests/svg/text/reftests/text-bidi-controls-anchors-2-ref.svg @@ -0,0 +1,36 @@ + + + Text anchors and bidi control characters + + + + + Start Anchor + Middle Anchor + End Anchor + + Start Anchor + Middle Anchor + End Anchor + + Anchor Start + Anchor Middle + Anchor End + + Anchor Start + Anchor Middle + Anchor End + + rohcnA tratS + rohcnA elddiM + rohcnA dnE + + Anchor tratS + Anchor elddiM + Anchor dnE + + rohcnA Start + rohcnA Middle + rohcnA End + + diff --git a/testing/web-platform/tests/svg/text/reftests/text-bidi-controls-anchors-2.svg b/testing/web-platform/tests/svg/text/reftests/text-bidi-controls-anchors-2.svg new file mode 100644 index 000000000000..b9a4a9b5e7df --- /dev/null +++ b/testing/web-platform/tests/svg/text/reftests/text-bidi-controls-anchors-2.svg @@ -0,0 +1,47 @@ + + + Text anchors and bidi control characters + + + + + + + + + Start Anchor + Middle Anchor + End Anchor + + + ‫Start Anchor‬ + ‫Middle Anchor‬ + ‫End Anchor‬ + + + ‫Start‬ Anchor + ‫Middle‬ Anchor + ‫End‬ Anchor + + + Start ‫Anchor‬ + Middle ‫Anchor‬ + End ‫Anchor‬ + + + ‮Start Anchor‬ + ‮Middle Anchor‬ + ‮End Anchor‬ + + + ‮Start‬ Anchor + ‮Middle‬ Anchor + ‮End‬ Anchor + + + Start ‮Anchor‬ + Middle ‮Anchor‬ + End ‮Anchor‬ + + +