mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
layout: Correctly marking box damage when text-related style changed (#38059)
This change aims to supplement the missing incremental box tree construction when text-related styles change. Since certain text style adjustments can alter visible text content and typography. Therefore, the parent nodes of such text are marked as needing to re-collect their box tree children to ensure the correct display of text. Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
This commit is contained in:
parent
d678901122
commit
9ef4d0c9d7
4 changed files with 92 additions and 0 deletions
|
@ -658,8 +658,33 @@ impl<'dom> style::dom::TElement for ServoLayoutElement<'dom> {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let text_shaping_needs_recollect = || {
|
||||||
|
if old.clone_direction() != new.clone_direction() ||
|
||||||
|
old.clone_unicode_bidi() != new.clone_unicode_bidi()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
let old_text = old.get_inherited_text().clone();
|
||||||
|
let new_text = new.get_inherited_text().clone();
|
||||||
|
if old_text.white_space_collapse != new_text.white_space_collapse ||
|
||||||
|
old_text.text_transform != new_text.text_transform ||
|
||||||
|
old_text.word_break != new_text.word_break ||
|
||||||
|
old_text.overflow_wrap != new_text.overflow_wrap ||
|
||||||
|
old_text.letter_spacing != new_text.letter_spacing ||
|
||||||
|
old_text.word_spacing != new_text.word_spacing ||
|
||||||
|
old_text.text_rendering != new_text.text_rendering
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
false
|
||||||
|
};
|
||||||
|
|
||||||
if box_tree_needs_rebuild() {
|
if box_tree_needs_rebuild() {
|
||||||
RestyleDamage::from_bits_retain(LayoutDamage::REBUILD_BOX.bits())
|
RestyleDamage::from_bits_retain(LayoutDamage::REBUILD_BOX.bits())
|
||||||
|
} else if text_shaping_needs_recollect() {
|
||||||
|
RestyleDamage::from_bits_retain(LayoutDamage::RECOLLECT_BOX_TREE_CHILDREN.bits())
|
||||||
} else {
|
} else {
|
||||||
// This element needs to be laid out again, but does not have any damage to
|
// This element needs to be laid out again, but does not have any damage to
|
||||||
// its box. In the future, we will distinguish between types of damage to the
|
// its box. In the future, we will distinguish between types of damage to the
|
||||||
|
|
17
tests/wpt/meta/MANIFEST.json
vendored
17
tests/wpt/meta/MANIFEST.json
vendored
|
@ -271423,6 +271423,19 @@
|
||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"pre-001.html": [
|
||||||
|
"0e3e1e38c7293303d7cf07c0e64facfa76ba966d",
|
||||||
|
[
|
||||||
|
null,
|
||||||
|
[
|
||||||
|
[
|
||||||
|
"/css/css-text/white-space/reference/pre-001-ref.html",
|
||||||
|
"=="
|
||||||
|
]
|
||||||
|
],
|
||||||
|
{}
|
||||||
|
]
|
||||||
|
],
|
||||||
"pre-float-001.html": [
|
"pre-float-001.html": [
|
||||||
"8dd08d80992e6d6310a6697f84c2533d399c8e5e",
|
"8dd08d80992e6d6310a6697f84c2533d399c8e5e",
|
||||||
[
|
[
|
||||||
|
@ -453875,6 +453888,10 @@
|
||||||
"644dfc4b025e62babeddd3575af5ffee40c77e26",
|
"644dfc4b025e62babeddd3575af5ffee40c77e26",
|
||||||
[]
|
[]
|
||||||
],
|
],
|
||||||
|
"pre-001-ref.html": [
|
||||||
|
"e950bbbc4960c650cd08b2532e6b0a3309ca5ffb",
|
||||||
|
[]
|
||||||
|
],
|
||||||
"pre-float-001-ref.html": [
|
"pre-float-001-ref.html": [
|
||||||
"9753cb37b641f3f25d1045f3149875deffb1613c",
|
"9753cb37b641f3f25d1045f3149875deffb1613c",
|
||||||
[]
|
[]
|
||||||
|
|
31
tests/wpt/tests/css/css-text/white-space/pre-001.html
vendored
Normal file
31
tests/wpt/tests/css/css-text/white-space/pre-001.html
vendored
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>CSS-white-space test: restore collapsed whitespace</title>
|
||||||
|
<link rel="author" title="JoeDow" href="ibluegalaxy_taoj@163.com">
|
||||||
|
<link rel="match" href="reference/pre-001-ref.html">
|
||||||
|
<link rel="help" href="https://drafts.csswg.org/css-text-3/#white-space-property">
|
||||||
|
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
|
||||||
|
<style>
|
||||||
|
html {
|
||||||
|
font: 20px/1 Ahem;
|
||||||
|
}
|
||||||
|
.span {
|
||||||
|
background-color: blueviolet;
|
||||||
|
}
|
||||||
|
#target {
|
||||||
|
background-color: blue;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<span class="span">aa bb </span><span id="target"> target </span><span class="span">bb aa</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.onload = function() {
|
||||||
|
const target = document.getElementById("target");
|
||||||
|
// force layout
|
||||||
|
target.offsetLeft;
|
||||||
|
target.style.whiteSpace = "pre";
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
19
tests/wpt/tests/css/css-text/white-space/reference/pre-001-ref.html
vendored
Normal file
19
tests/wpt/tests/css/css-text/white-space/reference/pre-001-ref.html
vendored
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
|
||||||
|
<style>
|
||||||
|
html {
|
||||||
|
font: 20px/1 Ahem;
|
||||||
|
}
|
||||||
|
.span {
|
||||||
|
background-color: blueviolet;
|
||||||
|
}
|
||||||
|
#target {
|
||||||
|
background-color: blue;
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<span class="span">aa bb </span><span id="target"> target </span><span class="span">bb aa</span>
|
||||||
|
</div>
|
||||||
|
</body>
|
Loading…
Add table
Add a link
Reference in a new issue