Bug 1753105 - Deal with negative letter-spacing in SVGTextFrame. r=jfkthame

Otherwise we can end up with a rect with negative width, bad stuff to
follow.

Differential Revision: https://phabricator.services.mozilla.com/D137881
This commit is contained in:
Emilio Cobos Álvarez 2022-02-04 23:25:22 +00:00
Родитель 8185be07ba
Коммит 739ada1351
2 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -855,6 +855,10 @@ SVGBBox TextRenderedRun::GetRunUserSpaceRect(nsPresContext* aContext,
if (aFlags & eNoHorizontalOverflow) {
x = 0.0;
width = textRun->GetAdvanceWidth(range, &provider);
if (width < 0.0) {
x = width;
width = -width;
}
} else {
x = metrics.mBoundingBox.x;
width = metrics.mBoundingBox.width;

Просмотреть файл

@ -0,0 +1,14 @@
<!DOCTYPE html>
<script>
document.addEventListener("DOMContentLoaded", () => {
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg")
const text = document.createElementNS("http://www.w3.org/2000/svg", "text")
text.setAttribute("letter-spacing", "-37vw")
const node = document.createTextNode("\n\n\r7%٠\0ó …§ð†ªã€€&**=ðŸ¯šð¯‚ï¸¡ó ”©Û¹â€Ùªv*/𯄝𖹧垝纶*;{0ð–£”9̆뢻\r\n^掶𩹺*|\r\nðŸ©Ù«ð‡½ë«»e犮㇆᭲ð¡‡\u2028ᨲ⁤\rv+🧌8שּׁ\n𯏎è¥ó „ˆêº¡\nâð±Ù ۹𖯸0ó ¤™/á¾ð«ž¾99 a&Û¹ð¯©ã™2ó ¥µ^0ê𝗻𝅻\0X%+0*/镳 ٪ȺXá©¿L2⼤ðªˆÂ­ðª¸ð‰")
text.appendChild(node)
svg.appendChild(text)
document.documentElement.appendChild(svg)
const rect = document.documentElement.getBoundingClientRect()
node.convertRectFromNode(rect, svg, {})
})
</script>