Skip to content

Commit

Permalink
SVG Text NG: Fix text scaling by :root scaling changes
Browse files Browse the repository at this point in the history
Scaling changes on :root should trigger layout of SVG <text>s.
This CL fixes a regression by crrev.com/1011855.

Bug: 1365243
Change-Id: Ied64facb518b9534567609961d37fbe6dcc2d3b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4113625
Auto-Submit: Kent Tamura <tkent@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1084853}
  • Loading branch information
tkent-google authored and Chromium LUCI CQ committed Dec 19, 2022
1 parent 085d048 commit a4da97d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
6 changes: 5 additions & 1 deletion third_party/blink/renderer/core/layout/layout_block.cc
Expand Up @@ -288,8 +288,12 @@ void LayoutBlock::StyleDidChange(StyleDifference diff,
Layer() ? Layer()->Transform() : nullptr);
// Compare local scale before and after.
if (old_squared_scale != new_squared_scale) {
for (LayoutBox* box : *View()->SvgTextDescendantsMap().at(this))
for (LayoutBox* box : *View()->SvgTextDescendantsMap().at(this)) {
To<LayoutNGSVGText>(box)->SetNeedsTextMetricsUpdate();
if (GetNode() == GetDocument().documentElement()) {
box->SetNeedsLayout(layout_invalidation_reason::kStyleChange);
}
}
}
}
}
Expand Down
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
<svg><text y=30>Text</text></svg>
</body>
</html>
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html class="reftest-wait">
<link rel="help" href="https://crbug.com/1365243">
<link rel="match" href="transform-dynamic-change-root-ref.html">
<style>
:root { scale: 1 5; }
</style>

<body>
<svg><text y=30>Text</text></svg>
<script>
requestAnimationFrame(() => {
requestAnimationFrame(() => {
document.styleSheets[0].removeRule(0);
document.documentElement.classList.remove('reftest-wait');
});
});
</script>
</body>
</html>

0 comments on commit a4da97d

Please sign in to comment.