aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout')
-rw-r--r--components/layout/fragment.rs5
-rw-r--r--components/layout/text.rs13
2 files changed, 9 insertions, 9 deletions
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs
index 520e4c5ab66..f2da09b734c 100644
--- a/components/layout/fragment.rs
+++ b/components/layout/fragment.rs
@@ -1971,6 +1971,11 @@ impl Fragment {
}
}
SpecificFragmentInfo::ScannedText(ref text_fragment) => {
+ // Fragments with no glyphs don't contribute any inline metrics.
+ // TODO: Filter out these fragments during flow construction?
+ if text_fragment.content_size.inline == Au(0) {
+ return InlineMetrics::new(Au(0), Au(0), Au(0));
+ }
// See CSS 2.1 § 10.8.1.
let line_height = self.calculate_line_height(layout_context);
let font_derived_metrics =
diff --git a/components/layout/text.rs b/components/layout/text.rs
index 1848a9b8741..3ba9be9f949 100644
--- a/components/layout/text.rs
+++ b/components/layout/text.rs
@@ -197,17 +197,12 @@ impl TextRunScanner {
for (byte_index, character) in text.char_indices() {
// Search for the first font in this font group that contains a glyph for this
// character.
- let mut font_index = 0;
+ let font_index = fontgroup.fonts.iter().position(|font| {
+ font.borrow().glyph_index(character).is_some()
+ }).unwrap_or(0);
+
// The following code panics one way or another if this condition isn't met.
assert!(fontgroup.fonts.len() > 0);
- while font_index < fontgroup.fonts.len() - 1 {
- if fontgroup.fonts.get(font_index).unwrap().borrow()
- .glyph_index(character)
- .is_some() {
- break
- }
- font_index += 1;
- }
let bidi_level = match bidi_levels {
Some(levels) => levels[*paragraph_bytes_processed],