mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
layout: Fix bug where whitespace didn't have line decorations (#38007)
This PR fixes the issue where underlines weren't appearing on whitespaces. This was due to whitespace being ignored in the `glyphs` function of `components/layout/display_list/mod.rs` when the fragment didn't have a selection. I added in a check to include the whitespace if there's a selection or if there are any line decorations. I also renamed the field from `ignore_whitespace` to `include_whitespace` to make it a bit clearer since it was being reversed everywhere it was used anyway. **Before:** <img width="1235" height="169" alt="image" src="https://github.com/user-attachments/assets/51d47781-355f-4915-8100-f3a7db81027f" /> **After:** <img width="1235" height="169" alt="image" src="https://github.com/user-attachments/assets/9b44fe77-d600-4080-9f3a-2c9b33924f51" /> Testing: `/css/css-text/white-space/pre-wrap-018.html` is now passing. Also verified manually by running `data:text/html;base64,PGRpdiBzdHlsZT0idGV4dC1kZWNvcmF0aW9uOiB1bmRlcmxpbmU7Ij5IZWxsbyBXb3JsZCE8L2Rpdj4= ` Fixes: https://github.com/servo/servo/issues/33463 --------- Signed-off-by: Leo Ring <leoring03@gmail.com> Signed-off-by: leo030303 <59373587+leo030303@users.noreply.github.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
35a145613e
commit
93e5b672a7
3 changed files with 7 additions and 5 deletions
|
@ -740,12 +740,14 @@ impl Fragment {
|
|||
let rect = fragment.rect.translate(containing_block.origin.to_vector());
|
||||
let mut baseline_origin = rect.origin;
|
||||
baseline_origin.y += fragment.font_metrics.ascent;
|
||||
let include_whitespace =
|
||||
fragment.has_selection() || text_decorations.iter().any(|item| !item.line.is_empty());
|
||||
|
||||
let glyphs = glyphs(
|
||||
&fragment.glyphs,
|
||||
baseline_origin,
|
||||
fragment.justification_adjustment,
|
||||
!fragment.has_selection(),
|
||||
include_whitespace,
|
||||
);
|
||||
if glyphs.is_empty() {
|
||||
return;
|
||||
|
@ -1628,7 +1630,7 @@ fn glyphs(
|
|||
glyph_runs: &[Arc<GlyphStore>],
|
||||
mut baseline_origin: PhysicalPoint<Au>,
|
||||
justification_adjustment: Au,
|
||||
ignore_whitespace: bool,
|
||||
include_whitespace: bool,
|
||||
) -> Vec<wr::GlyphInstance> {
|
||||
use fonts_traits::ByteIndex;
|
||||
use range::Range;
|
||||
|
@ -1636,7 +1638,7 @@ fn glyphs(
|
|||
let mut glyphs = vec![];
|
||||
for run in glyph_runs {
|
||||
for glyph in run.iter_glyphs_for_byte_range(&Range::new(ByteIndex(0), run.len())) {
|
||||
if !run.is_whitespace() || !ignore_whitespace {
|
||||
if !run.is_whitespace() || include_whitespace {
|
||||
let glyph_offset = glyph.offset().unwrap_or(Point2D::zero());
|
||||
let point = units::LayoutPoint::new(
|
||||
baseline_origin.x.to_f32_px() + glyph_offset.x.to_f32_px(),
|
||||
|
|
2
tests/wpt/meta/css/css-text-decor/text-decoration-skip-spaces-003.html.ini
vendored
Normal file
2
tests/wpt/meta/css/css-text-decor/text-decoration-skip-spaces-003.html.ini
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
[text-decoration-skip-spaces-003.html]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[pre-wrap-018.html]
|
||||
expected: FAIL
|
Loading…
Add table
Add a link
Reference in a new issue