From a20d0bccef0706cdfaac8d932e80782581ad542f Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Tue, 4 Apr 2017 09:16:26 -0400 Subject: [PATCH] Overwrite default RunInfo values with the first real ones encountered. --- components/layout/text.rs | 25 +++++++++++-------- tests/wpt/mozilla/meta/MANIFEST.json | 25 +++++++++++++++++++ .../tests/css/ellipsis_font_panic-ref.html | 13 ++++++++++ .../tests/css/ellipsis_font_panic.html | 17 +++++++++++++ 4 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 tests/wpt/mozilla/tests/css/ellipsis_font_panic-ref.html create mode 100644 tests/wpt/mozilla/tests/css/ellipsis_font_panic.html diff --git a/components/layout/text.rs b/components/layout/text.rs index 0299199af39..5c9b93edee1 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -234,17 +234,22 @@ impl TextRunScanner { let flush_run = run_info.font_index != font_index || run_info.bidi_level != bidi_level || !compatible_script; - let flush_mapping = flush_run || mapping.selected != selected; + let new_mapping_needed = flush_run || mapping.selected != selected; - if flush_mapping { - mapping.flush(&mut mappings, - &mut run_info, - &**text, - compression, - text_transform, - &mut last_whitespace, - &mut start_position, - end_position); + if new_mapping_needed { + // We ignore empty mappings at the very start of a fragment. + // The run info values are uninitialized at this point so + // flushing an empty mapping is pointless. + if end_position > 0 { + mapping.flush(&mut mappings, + &mut run_info, + &**text, + compression, + text_transform, + &mut last_whitespace, + &mut start_position, + end_position); + } if run_info.text.len() > 0 { if flush_run { run_info.flush(&mut run_info_list, &mut insertion_point); diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index f4d1b1e32ca..7a65b9afbdb 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -1451,6 +1451,18 @@ {} ] ], + "css/ellipsis_font_panic.html": [ + [ + "/_mozilla/css/ellipsis_font_panic.html", + [ + [ + "/_mozilla/css/ellipsis_font_panic-ref.html", + "==" + ] + ], + {} + ] + ], "css/empty_cells_a.html": [ [ "/_mozilla/css/empty_cells_a.html", @@ -7329,6 +7341,11 @@ {} ] ], + "css/ellipsis_font_panic-ref.html": [ + [ + {} + ] + ], "css/empty_cells_ref.html": [ [ {} @@ -20919,6 +20936,14 @@ "24dfcfa8ac401233d287631e57ea64edb94883cc", "support" ], + "css/ellipsis_font_panic-ref.html": [ + "21988e7f477117e23eb0d6770eec3896bac3b4a2", + "support" + ], + "css/ellipsis_font_panic.html": [ + "037c81c6f2f550b6d7e415b0fc7f3d0476202b76", + "reftest" + ], "css/empty-keyframes.html": [ "366edc7d29168809b6385ce7139786a0446ba560", "testharness" diff --git a/tests/wpt/mozilla/tests/css/ellipsis_font_panic-ref.html b/tests/wpt/mozilla/tests/css/ellipsis_font_panic-ref.html new file mode 100644 index 00000000000..1471933c7bc --- /dev/null +++ b/tests/wpt/mozilla/tests/css/ellipsis_font_panic-ref.html @@ -0,0 +1,13 @@ + + + + +
E…
diff --git a/tests/wpt/mozilla/tests/css/ellipsis_font_panic.html b/tests/wpt/mozilla/tests/css/ellipsis_font_panic.html new file mode 100644 index 00000000000..6d63195ea18 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/ellipsis_font_panic.html @@ -0,0 +1,17 @@ + + + + + +
English